import { CliExitCode, runCli } from './jobs/run-cli'; import { resolveRole } from './runtime/role'; import { assertStartupEnvironment } from './runtime/startup-checks'; /** * Entry point of the job role: `node dist/cli.js [args]`, one run per * CronJob pod. Role and environment are checked like in main.ts and * worker.ts, before any module connects. Resolves with the exit code: * 0 succeeded, 1 failed, 2 wrong call. `env` is for tests; the modules * themselves read process.env. */ export async function bootstrapCli( argv: readonly string[] = process.argv.slice(2), env: NodeJS.ProcessEnv = process.env, ): Promise { const role = resolveRole('cli', env); assertStartupEnvironment(role, env); return runCli(argv); } // Started as `node dist/cli.js`; importing this file starts nothing. if (require.main === module) { void bootstrapCli().then((code) => { process.exitCode = code; }); }