Files
twenty/packages/twenty-sdk/src/cli/commands/logic-function/logic-function-logs.ts
T
martmullandGitHub 53c314d0fa 2094 extensibility define postinstall orand preinstall function to run in application (#18037)
- add a new optional key `postInstallLogicFunctionUniversalIdentifier`
in applicationConfig
- seed postInstall function in create-twenty-app
- update execute:function options
- update doc
2026-02-18 15:38:22 +00:00

68 lines
1.8 KiB
TypeScript

import { ApiService } from '@/cli/utilities/api/api-service';
import { CURRENT_EXECUTION_DIRECTORY } from '@/cli/utilities/config/current-execution-directory';
import chalk from 'chalk';
import { readManifestFromFile } from '@/cli/utilities/build/manifest/manifest-reader';
export class LogicFunctionLogsCommand {
private apiService = new ApiService();
async execute({
appPath = CURRENT_EXECUTION_DIRECTORY,
functionUniversalIdentifier,
functionName,
}: {
appPath?: string;
functionUniversalIdentifier?: string;
functionName?: string;
}): Promise<void> {
try {
const manifest = await readManifestFromFile(appPath);
if (!manifest) {
process.exit(1);
}
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('');
}
}