Merge commands (#14647)

- duplicates between install and deploy commands
- remove list command that call findManyAgents
This commit is contained in:
martmull
2025-09-22 16:26:01 +02:00
committed by GitHub
parent 40240ce514
commit 68882ec483
4 changed files with 10 additions and 139 deletions
@@ -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<void> {
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<string> {
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('');
}
}
@@ -1,45 +0,0 @@
import chalk from 'chalk';
import { ApiService } from '../services/api.service';
export class AppListCommand {
private apiService = new ApiService();
async execute(): Promise<void> {
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('');
});
}
}
@@ -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<void> {
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);
@@ -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 <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 <source>',
'Application source (git URL, local path, or marketplace ID)',
)
.option(
'-t, --type <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