Pārlūkot izejas kodu

fix(cli): mark app store repo as git safe folder before pulling

Nicolas Meienberger 1 gadu atpakaļ
vecāks
revīzija
86ed9503a7

+ 6 - 1
packages/cli/src/executors/app/app.executors.ts

@@ -62,10 +62,15 @@ export class AppExecutors {
    */
   public installApp = async (appId: string, config: Record<string, unknown>) => {
     try {
+      if (process.getuid && process.getgid) {
+        this.logger.info(`Installing app ${appId} as User ID: ${process.getuid()}, Group ID: ${process.getgid()}`);
+      } else {
+        this.logger.info(`Installing app ${appId}. No User ID or Group ID found.`);
+      }
+
       const { rootFolderHost, appsRepoId } = getEnv();
 
       const { appDirPath, repoPath, appDataDirPath } = this.getAppPaths(appId);
-      this.logger.info(`Installing app ${appId}`);
 
       // Check if app exists in repo
       const apps = await fs.promises.readdir(path.join(rootFolderHost, 'repos', appsRepoId, 'apps'));

+ 1 - 0
packages/cli/src/executors/repo/repo.executors.ts

@@ -76,6 +76,7 @@ export class RepoExecutors {
       this.logger.info(`Pulling repo ${repoUrl} to ${repoPath}`);
 
       await execAsync(`git config --global --add safe.directory ${repoPath}`);
+      await execAsync(`git -C ${repoPath} reset --hard`);
       const { stdout, stderr } = await execAsync(`git -C ${repoPath} pull`);
 
       if (stderr) {

+ 9 - 0
packages/cli/src/executors/system/system.executors.ts

@@ -1,3 +1,4 @@
+/* eslint-disable no-await-in-loop */
 import { Queue } from 'bullmq';
 import fs from 'fs';
 import cliProgress from 'cli-progress';
@@ -117,6 +118,14 @@ export class SystemExecutors {
         const apps = await fs.promises.readdir(path.join(this.rootFolder, 'apps'));
         const appExecutor = new AppExecutors();
 
+        // eslint-disable-next-line no-restricted-syntax
+        for (const app of apps) {
+          spinner.setMessage(`Stopping ${app}...`);
+          spinner.start();
+          await appExecutor.stopApp(app, {}, true);
+          spinner.done(`${app} stopped`);
+        }
+
         await Promise.all(
           apps.map(async (app) => {
             const appSpinner = new TerminalSpinner(`Stopping ${app}...`);