fix: cli not running with prod image

This commit is contained in:
Nicolas Meienberger 2026-01-02 15:22:44 +01:00
parent 658c42a53b
commit 5d7c6bd543
3 changed files with 27 additions and 4 deletions

View file

@ -8,13 +8,29 @@ program.addCommand(resetPasswordCommand);
export async function runCLI(argv: string[]): Promise<boolean> {
const args = argv.slice(2);
const hasCommand = args.length > 0 && !args[0].startsWith("-");
const isCLIMode = process.env.ZEROBYTE_CLI === "1";
if (!hasCommand) {
if (args.length === 0) {
if (isCLIMode) {
program.help();
return true;
}
return false;
}
await program.parseAsync(argv);
if (!isCLIMode && args[0].startsWith("-")) {
return false;
}
await program.parseAsync(argv).catch((err) => {
if (err.message.includes("SIGINT")) {
process.exit(0);
}
console.error(err.message);
process.exit(1);
});
return true;
}

View file

@ -8,6 +8,12 @@ import { REQUIRED_MIGRATIONS } from "./core/constants";
import { validateRequiredMigrations } from "./modules/lifecycle/checkpoint";
import { createApp } from "./app";
import { config } from "./core/config";
import { runCLI } from "./cli";
const cliRun = await runCLI(Bun.argv);
if (cliRun) {
process.exit(0);
}
const app = createApp();

View file

@ -7,7 +7,8 @@
"build": "react-router build",
"dev": "bunx --bun vite",
"start": "bun ./dist/server/index.js",
"cli": "bun run app/server/cli/main.ts",
"cli:dev": "bun run app/server/cli/main.ts",
"cli": "ZEROBYTE_CLI=1 bun ./dist/server/index.js",
"tsc": "react-router typegen && tsc",
"lint": "biome check .",
"lint:ci": "biome ci . --changed --error-on-warnings --no-errors-on-unmatched",