#!/usr/bin/env node // fix use strict: command not found import 'reflect-metadata'; // https://blog.logrocket.com/dependency-injection-node-js-typedi/#typedi-achieving-dependency-injection-node-js import { Command } from 'commander'; import { ComposeCommand } from './commands/compose/composeCommand'; import { ProfileCommand } from './commands/profile/profileCommand'; import { LoginCommand } from './commands/loginCommand'; import { PullerCommand } from './commands/pullers/pullerCommand'; import { TaskCommand } from './commands/tasks/taskCommand'; import { ConnectionCommand } from './commands/profile/generators/connections/connectionCommand'; import { PusherCommand } from './commands/pushers/pusherCommand'; import { DependenciesCommand } from './commands/profile/generators/dependencies/dependencyCommand'; import { ReportCommand } from './commands/profile/generators/reports/reportCommand'; import { ValidationCommand } from './commands/profile/generators/validations/validationCommand'; import { TransformationCommand } from './commands/profile/generators/transformations/transformationCommand'; import { TableCommand } from './commands/tables/tableCommand'; import { SchemaCommand } from './commands/profile/generators/schemas/schemaCommand'; import { WebhookCommand } from './commands/profile/generators/webhooks/webhookCommand'; import { StepCommand } from './commands/profile/generators/steps/stepCommand'; import { TestActionCommand } from './commands/testCommand'; import { ConnectorCommand } from './commands/connectorCommand'; import { WorkerCommand } from './commands/workerCommand'; import { VersionCommand } from './commands/versionCommand'; import { IntellisenseCommand } from './commands/intellisense/intellisenseCommand'; import { ExplainCommand } from './commands/explainCommand'; import { EnvCommand } from './commands/envCommand'; import { McpCommand } from './commands/mcpCommand'; import chalk from 'chalk'; const verbose = process.argv.includes('--verbose'); process.on('uncaughtException', (err) => { console.error(''); console.error(chalk.red(`✗ ${err?.message || err}`)); if (verbose) { console.error(chalk.gray(err?.stack || '')); } else { console.error( chalk.gray(' Rerun with --verbose to see the full stack trace.'), ); } process.exit(1); }); async function main() { const program = new Command(); program.option('--verbose', 'Show full stack trace on errors'); program.addCommand(McpCommand()); program.addCommand(EnvCommand()); program.addCommand(ExplainCommand()); program.addCommand(LoginCommand()); program.addCommand(ProfileCommand()); program.addCommand(ConnectionCommand()); program.addCommand(PullerCommand()); program.addCommand(TaskCommand()); program.addCommand(PusherCommand()); program.addCommand(DependenciesCommand()); program.addCommand(ReportCommand()); program.addCommand(TableCommand()); program.addCommand(SchemaCommand()); program.addCommand(WebhookCommand()); program.addCommand(ValidationCommand()); program.addCommand(TransformationCommand()); program.addCommand(StepCommand()); program.addCommand(ComposeCommand()); program.addCommand(TestActionCommand()); program.addCommand(ConnectorCommand()); program.addCommand(WorkerCommand()); program.addCommand(VersionCommand()); program.addCommand(IntellisenseCommand()); // program.addCommand(TestProfileCommand()); // parseAsync, not parse: several actions are async (compose, compose description, tables…) // and `parse` ignores the promise an action handler returns, so a rejection escaped this // function's error handling and surfaced as an unhandled rejection instead of a clean exit. await program.parseAsync(process.argv); } main().catch((err) => { console.error(''); console.error(chalk.red(`✗ ${err?.message || err}`)); if (verbose) { console.error(chalk.gray(err?.stack || '')); } else { console.error( chalk.gray(' Rerun with --verbose to see the full stack trace.'), ); } process.exit(1); });