From 68882ec483026cd8ea6abf62efc6699d1c30513d Mon Sep 17 00:00:00 2001 From: martmull Date: Mon, 22 Sep 2025 16:26:01 +0200 Subject: [PATCH] Merge commands (#14647) - duplicates between install and deploy commands - remove list command that call findManyAgents --- .../src/commands/app-install.command.ts | 57 ------------------- .../src/commands/app-list.command.ts | 45 --------------- ...-deploy.command.ts => app-sync.command.ts} | 10 ++-- .../twenty-cli/src/commands/app.command.ts | 37 ++---------- 4 files changed, 10 insertions(+), 139 deletions(-) delete mode 100644 packages/twenty-cli/src/commands/app-install.command.ts delete mode 100644 packages/twenty-cli/src/commands/app-list.command.ts rename packages/twenty-cli/src/commands/{app-deploy.command.ts => app-sync.command.ts} (71%) diff --git a/packages/twenty-cli/src/commands/app-install.command.ts b/packages/twenty-cli/src/commands/app-install.command.ts deleted file mode 100644 index a103ad82d1..0000000000 --- a/packages/twenty-cli/src/commands/app-install.command.ts +++ /dev/null @@ -1,57 +0,0 @@ -import chalk from 'chalk'; -import inquirer from 'inquirer'; -import { ApiService } from '../services/api.service'; - -export class AppInstallCommand { - private apiService = new ApiService(); - - async execute(options: { source?: string; type: string }): Promise { - try { - const source = await this.getSource(options.source); - - this.logInstallInfo(source, options.type); - - const result = await this.apiService.installApplication( - source, - options.type as 'local' | 'git' | 'marketplace', - ); - - if (!result.success) { - console.error(chalk.red('❌ Installation failed:'), result.error); - process.exit(1); - } - - console.log(chalk.green('✅ Application installed successfully')); - } catch (error) { - console.error( - chalk.red('Installation failed:'), - error instanceof Error ? error.message : error, - ); - process.exit(1); - } - } - - private async getSource(providedSource?: string): Promise { - if (providedSource) { - return providedSource; - } - - const answer = await inquirer.prompt([ - { - type: 'input', - name: 'source', - message: 'Application source (URL, path, or ID):', - validate: (input) => input.length > 0 || 'Source is required', - }, - ]); - - return answer.source; - } - - private logInstallInfo(source: string, type: string): void { - console.log(chalk.blue('📦 Installing Twenty Application')); - console.log(chalk.gray(`📍 Source: ${source}`)); - console.log(chalk.gray(`🔧 Type: ${type}`)); - console.log(''); - } -} diff --git a/packages/twenty-cli/src/commands/app-list.command.ts b/packages/twenty-cli/src/commands/app-list.command.ts deleted file mode 100644 index df95a7fecf..0000000000 --- a/packages/twenty-cli/src/commands/app-list.command.ts +++ /dev/null @@ -1,45 +0,0 @@ -import chalk from 'chalk'; -import { ApiService } from '../services/api.service'; - -export class AppListCommand { - private apiService = new ApiService(); - - async execute(): Promise { - try { - console.log(chalk.blue('📋 Listing Twenty Applications')); - console.log(''); - - const result = await this.apiService.listApplications(); - - if (!result.success || !result.data) { - console.error( - chalk.red('❌ Failed to list applications:'), - result.error, - ); - process.exit(1); - } - - this.displayApplications(result.data); - } catch (error) { - console.error( - chalk.red('List failed:'), - error instanceof Error ? error.message : error, - ); - process.exit(1); - } - } - - private displayApplications(apps: any[]): void { - if (apps.length === 0) { - console.log(chalk.yellow('No applications found')); - return; - } - - apps.forEach((app: any, index: number) => { - console.log(`${index + 1}. ${chalk.bold(app.name)}`); - console.log(` ${chalk.gray(app.description || 'No description')}`); - console.log(` ${chalk.gray(`Version: ${app.version || 'N/A'}`)}`); - console.log(''); - }); - } -} diff --git a/packages/twenty-cli/src/commands/app-deploy.command.ts b/packages/twenty-cli/src/commands/app-sync.command.ts similarity index 71% rename from packages/twenty-cli/src/commands/app-deploy.command.ts rename to packages/twenty-cli/src/commands/app-sync.command.ts index b7eaecd535..786381f302 100644 --- a/packages/twenty-cli/src/commands/app-deploy.command.ts +++ b/packages/twenty-cli/src/commands/app-sync.command.ts @@ -3,28 +3,28 @@ import { ApiService } from '../services/api.service'; import { resolveAppPath } from '../utils/app-path-resolver'; import { syncApp } from '../utils/app-sync'; -export class AppDeployCommand { +export class AppSyncCommand { private apiService = new ApiService(); async execute(options: { path?: string }): Promise { try { const appPath = await resolveAppPath(options.path); - console.log(chalk.blue('🚀 Deploying Twenty Application')); + console.log(chalk.blue('🚀 Syncing Twenty Application')); console.log(chalk.gray(`📁 App Path: ${appPath}`)); console.log(''); const result = await syncApp(appPath, this.apiService); if (!result.success) { - console.error(chalk.red('❌ Deployment failed:'), result.error); + console.error(chalk.red('❌ Sync failed:'), result.error); process.exit(1); } - console.log(chalk.green('✅ Application deployed successfully')); + console.log(chalk.green('✅ Application synced successfully')); } catch (error) { console.error( - chalk.red('Deployment failed:'), + chalk.red('Sync failed:'), error instanceof Error ? error.message : error, ); process.exit(1); diff --git a/packages/twenty-cli/src/commands/app.command.ts b/packages/twenty-cli/src/commands/app.command.ts index 749cfbef0b..9bb511d2bc 100644 --- a/packages/twenty-cli/src/commands/app.command.ts +++ b/packages/twenty-cli/src/commands/app.command.ts @@ -1,15 +1,11 @@ import { Command } from 'commander'; -import { AppDeployCommand } from './app-deploy.command'; +import { AppSyncCommand } from './app-sync.command'; import { AppDevCommand } from './app-dev.command'; import { AppInitCommand } from './app-init.command'; -import { AppInstallCommand } from './app-install.command'; -import { AppListCommand } from './app-list.command'; export class AppCommand { private devCommand = new AppDevCommand(); - private deployCommand = new AppDeployCommand(); - private installCommand = new AppInstallCommand(); - private listCommand = new AppListCommand(); + private syncCommand = new AppSyncCommand(); private initCommand = new AppInitCommand(); getCommand(): Command { @@ -29,37 +25,14 @@ export class AppCommand { }); appCommand - .command('deploy') - .description('Deploy application to Twenty') + .command('sync') + .description('Sync application to Twenty') .option( '-p, --path ', 'Application directory path (auto-detected if not specified)', ) .action(async (options) => { - await this.deployCommand.execute(options); - }); - - appCommand - .command('install') - .description('Install application from source') - .option( - '-s, --source ', - 'Application source (git URL, local path, or marketplace ID)', - ) - .option( - '-t, --type ', - 'Source type (git, local, marketplace)', - 'local', - ) - .action(async (options) => { - await this.installCommand.execute(options); - }); - - appCommand - .command('list') - .description('List installed applications') - .action(async () => { - await this.listCommand.execute(); + await this.syncCommand.execute(options); }); appCommand