diff --git a/apps/cli/src/App.tsx b/apps/cli/src/App.tsx index e071272..9e79209 100644 --- a/apps/cli/src/App.tsx +++ b/apps/cli/src/App.tsx @@ -183,11 +183,12 @@ const App = (props: { pkg: string; version: string; port: number; + upgrade: boolean; token?: string; }) => { const { exit } = useApp(); - const { model, language, pkg, version, token, port } = props; + const { model, language, pkg, version, token, port, upgrade } = props; const [columns, rows] = useStdoutDimensions(); @@ -254,6 +255,7 @@ const App = (props: { "-p", `${port}`, ...(token ? ["-t", token] : []), + ...(upgrade ? [] : ["-n"]), ], { shell: true, diff --git a/apps/cli/src/index.tsx b/apps/cli/src/index.tsx index 4d3a6e1..34a4f07 100644 --- a/apps/cli/src/index.tsx +++ b/apps/cli/src/index.tsx @@ -40,11 +40,12 @@ const command = program (val) => parseInt(val), 3000, ) + .option("-n, --no-upgrade", "skip applying the upgrade") .option("-s, --simple", "simple mode") .option("-i, --ipc", "run in ipc mode") .parse(); -const { model, language, port, ipc, simple, token } = command.opts(); +const { model, language, port, ipc, simple, token, upgrade } = command.opts(); let [pkg, version] = command.processedArgs; @@ -113,13 +114,17 @@ const bumpgen = makeBumpgen({ }); if (simple) { - for await (const event of bumpgen.execute()) { + for await (const event of bumpgen.execute({ + upgrade, + })) { console.log("event", event); } } else if (ipc) { console.log("Running in IPC mode"); - for await (const event of bumpgen.executeSerializeable()) { + for await (const event of bumpgen.executeSerializeable({ + upgrade, + })) { console.log("event", event); try { const options = { @@ -147,6 +152,7 @@ if (simple) { version={version} token={token} port={port} + upgrade={upgrade} />, ); await app.waitUntilExit(); diff --git a/packages/bumpgen-core/src/index.ts b/packages/bumpgen-core/src/index.ts index af88b52..2648430 100644 --- a/packages/bumpgen-core/src/index.ts +++ b/packages/bumpgen-core/src/index.ts @@ -394,22 +394,26 @@ const bumpgen = ({ const execute = async function* (options?: { maxIterations?: number; timeout?: number; + upgrade?: boolean; }) { + const upgrade = options?.upgrade ?? true; let id; try { - id = v4(); - yield { - type: "upgrade.apply" as const, - status: "started" as const, - id, - }; - const applied = await bumpgen.upgrade.apply(); - yield { - type: "upgrade.apply" as const, - status: "finished" as const, - data: applied, - id, - }; + if (upgrade) { + id = v4(); + yield { + type: "upgrade.apply" as const, + status: "started" as const, + id, + }; + const applied = await bumpgen.upgrade.apply(); + yield { + type: "upgrade.apply" as const, + status: "finished" as const, + data: applied, + id, + }; + } let iteration = 0; const startedAt = Date.now(); @@ -500,8 +504,12 @@ const bumpgen = ({ } }; - const executeSerializeable = async function* () { - for await (const event of execute()) { + const executeSerializeable = async function* (options?: { + maxIterations?: number; + timeout?: number; + upgrade?: boolean; + }) { + for await (const event of execute(options)) { if (event.type === "graph.initialize" && event.status === "finished") { yield { ...event,