diff --git a/packages/migrate/src/sources/conductor/project-config.test.ts b/packages/migrate/src/sources/conductor/project-config.test.ts index 2f8dbe8fd4..d344a6c8fc 100644 --- a/packages/migrate/src/sources/conductor/project-config.test.ts +++ b/packages/migrate/src/sources/conductor/project-config.test.ts @@ -158,6 +158,9 @@ test("preserves literal or escaped Conductor names and rewrites active variables bare: { command: "printf CONDUCTOR_PORT" }, heredoc: { command: "cat <<'EOF'\n$CONDUCTOR_PORT\nEOF" }, active: { command: "printf \"'$CONDUCTOR_PORT'\"" }, + arithmeticDirect: { command: "serve --port $(( $CONDUCTOR_PORT ))" }, + arithmeticBraced: { command: "serve --port $(( ${CONDUCTOR_PORT} ))" }, + arithmeticOffset: { command: "serve --port $(( CONDUCTOR_PORT + 1 ))" }, }, }, }); @@ -166,6 +169,8 @@ test("preserves literal or escaped Conductor names and rewrites active variables worktree: { setup: "printf '%s\\n' '$CONDUCTOR_WORKSPACE_PATH'" }, scripts: { active: { command: "printf \"'$PASEO_PORT'\"", type: "service" }, + arithmeticBraced: { command: "serve --port $(( ${PASEO_PORT} ))", type: "service" }, + arithmeticDirect: { command: "serve --port $(( $PASEO_PORT ))", type: "service" }, bare: { command: "printf CONDUCTOR_PORT" }, escaped: { command: "printf \\$CONDUCTOR_PORT" }, escapedDouble: { command: 'printf "\\$CONDUCTOR_PORT"' }, @@ -176,6 +181,12 @@ test("preserves literal or escaped Conductor names and rewrites active variables level: "warning", message: "scripts.heredoc: Here-document commands are not imported.", }); + expect(inspected.notices).toContainEqual({ + code: "conductor-setting-unsupported", + level: "warning", + message: + "scripts.arithmeticOffset.port_arithmetic: Conductor port arithmetic is not imported because Paseo reserves one service port.", + }); }); test("skips cwd scripts on Windows instead of emitting POSIX shell syntax", () => { diff --git a/packages/migrate/src/sources/conductor/project-config.ts b/packages/migrate/src/sources/conductor/project-config.ts index 3b8e63f335..1e8fa3645c 100644 --- a/packages/migrate/src/sources/conductor/project-config.ts +++ b/packages/migrate/src/sources/conductor/project-config.ts @@ -703,10 +703,11 @@ function containsArithmeticVariable(command: string, name: string): boolean { function containsArithmeticVariableOperation(command: string, name: string): boolean { const identifier = new RegExp(`(^|[^A-Za-z0-9_])${name}(?![A-Za-z0-9_])`); + const directVariable = new RegExp(`^(?:${name}|\\$${name}|\\$\\{${name}\\})$`); let found = false; forEachActiveArithmetic(command, (value) => { const body = value.trim(); - if (identifier.test(body) && body !== name) found = true; + if (identifier.test(body) && !directVariable.test(body)) found = true; }); return found; }