From 9f1e09098a6de363fbde39e897372c091873fae1 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Mon, 23 Oct 2023 07:41:31 +0200 Subject: [PATCH] feat(cli): add commands for starting and stopping apps --- .../cli/src/executors/app/app.executors.ts | 2 +- packages/cli/src/index.ts | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/executors/app/app.executors.ts b/packages/cli/src/executors/app/app.executors.ts index 8b700df1..6054d86e 100644 --- a/packages/cli/src/executors/app/app.executors.ts +++ b/packages/cli/src/executors/app/app.executors.ts @@ -152,10 +152,10 @@ export class AppExecutors { try { this.logger.info(`Stopping app ${appId}`); - this.logger.info(`Regenerating app.env file for app ${appId}`); await this.ensureAppDir(appId); if (!skipEnvGeneration) { + this.logger.info(`Regenerating app.env file for app ${appId}`); await generateEnvFile(appId, config); } await compose(appId, 'rm --force --stop'); diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 1e5d4802..e41eaa18 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -4,7 +4,7 @@ import { program } from 'commander'; import chalk from 'chalk'; import { description, version } from '../package.json'; import { startWorker } from './services/watcher/watcher'; -import { SystemExecutors } from './executors'; +import { AppExecutors, SystemExecutors } from './executors'; const main = async () => { program.description(description).version(version); @@ -69,6 +69,25 @@ const main = async () => { await systemExecutors.cleanLogs(); }); + // Start app: ./cli app start + // Stop app: ./cli app stop + program + .command('app [command] ') + .description('App management') + .action(async (command, app) => { + const appExecutors = new AppExecutors(); + switch (command) { + case 'start': + await appExecutors.startApp(app, {}); + break; + case 'stop': + await appExecutors.stopApp(app, {}, true); + break; + default: + console.log(chalk.red('✗'), 'Unknown command'); + } + }); + program.parse(process.argv); };