refactor: extract config generation startup flow

This commit is contained in:
2026-02-10 00:55:43 -08:00
parent bb605fc051
commit b21204c7a0
4 changed files with 110 additions and 12 deletions

View File

@@ -0,0 +1,26 @@
import { CliArgs } from "../../cli/args";
export interface ConfigGenerationRuntimeDeps {
shouldStartApp: (args: CliArgs) => boolean;
generateConfig: (args: CliArgs) => Promise<number>;
onSuccess: (exitCode: number) => void;
onError: (error: Error) => void;
}
export function runGenerateConfigFlowRuntimeService(
args: CliArgs,
deps: ConfigGenerationRuntimeDeps,
): boolean {
if (!args.generateConfig || deps.shouldStartApp(args)) {
return false;
}
deps.generateConfig(args)
.then((exitCode) => {
deps.onSuccess(exitCode);
})
.catch((error: Error) => {
deps.onError(error);
});
return true;
}