Skip to content

Commit eda7d63

Browse files
t3dotggcursoragent
authored andcommitted
fix(server): parse CLI version in update preflight (pingdotgg#4389)
(cherry picked from commit 88c69ff)
1 parent 67e6e3e commit eda7d63

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

apps/server/src/cloud/selfUpdate.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const makeRecordingRunnerLayer = (
5454
return {
5555
stdout:
5656
options?.stdoutFor?.(input.command, input.args) ??
57-
(versionFromPath === undefined ? "" : `${versionFromPath}\n`),
57+
(versionFromPath === undefined ? "" : `t3 v${versionFromPath}\n`),
5858
stderr: failed ? `${input.command} exploded` : "",
5959
code: ChildProcessSpawner.ExitCode(failed ? 1 : 0),
6060
timedOut: false,
@@ -427,7 +427,7 @@ it.layer(NodeServices.layer)("ServerSelfUpdate.update", (it) => {
427427
Effect.gen(function* () {
428428
const context = yield* makeContext({
429429
stdoutFor: (command, args) =>
430-
command === NODE_PATH && args[1] === "--version" ? "0.0.28\n" : undefined,
430+
command === NODE_PATH && args[1] === "--version" ? "t3 v0.0.28\n" : undefined,
431431
});
432432
const versionDir = context.path.join(context.baseDir, "runtime", "versions", "0.0.29");
433433

apps/server/src/cloud/selfUpdate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,10 @@ export const make = Effect.fn("cloud.server_self_update.make")(function* (option
273273
failWith(`Could not verify the installed t3@${targetVersion}.`, cause),
274274
),
275275
);
276-
const preflightVersion = preflight.stdout.trim();
277-
if (preflight.code !== 0 || preflightVersion !== targetVersion) {
276+
// Effect CLI's unstable formatVersion currently emits `${name} v${version}`.
277+
// Extract the version token so surrounding presentation changes do not break updates.
278+
const reportedVersion = /\bv(\S+)\s*$/.exec(preflight.stdout)?.[1];
279+
if (preflight.code !== 0 || reportedVersion !== targetVersion) {
278280
// A completed npm install can still be unusable under this Node or on
279281
// this machine. Remove its sentinel and tree so a retry of the same
280282
// version performs a clean install instead of reusing a known-bad one.

0 commit comments

Comments
 (0)