2091 extensibility twenty sdk add command twenty app function logs and twenty app function test (#17278)

add `function:logs` and `function:execute` cli commands
This commit is contained in:
martmull
2026-01-20 15:10:01 +01:00
committed by GitHub
parent f9c400cd78
commit 801878cb2b
18 changed files with 400 additions and 35 deletions
@@ -0,0 +1,62 @@
import chalk from 'chalk';
import { CURRENT_EXECUTION_DIRECTORY } from '@/cli/utilities/config/constants/current-execution-directory';
import { ApiService } from '@/cli/utilities/api/services/api.service';
import { buildManifest } from '@/cli/utilities/manifest/utils/manifest-build';
export class FunctionLogsCommand {
private apiService = new ApiService();
async execute({
appPath = CURRENT_EXECUTION_DIRECTORY,
functionUniversalIdentifier,
functionName,
}: {
appPath?: string;
functionUniversalIdentifier?: string;
functionName?: string;
}): Promise<void> {
try {
const { manifest } = await buildManifest(appPath);
this.logWatchInfo({
appName: manifest.application.displayName,
functionUniversalIdentifier,
functionName,
});
await this.apiService.subscribeToLogs({
applicationUniversalIdentifier:
manifest.application.universalIdentifier,
functionUniversalIdentifier,
functionName,
});
} catch (error) {
console.error(
chalk.red('Watch logs failed:'),
error instanceof Error ? error.message : error,
);
process.exit(1);
}
}
private logWatchInfo({
appName,
functionUniversalIdentifier,
functionName,
}: {
appName?: string;
functionUniversalIdentifier?: string;
functionName?: string;
}): void {
const appPath = appName ?? 'Twenty Application';
const functionIdentifier =
functionUniversalIdentifier || functionName
? `function "${functionUniversalIdentifier || functionName}"`
: 'functions';
console.log(
chalk.blue(`🚀 Watching ${appPath} ${functionIdentifier} logs:`),
);
console.log('');
}
}