fix(migrate): preserve direct port arithmetic

This commit is contained in:
Mohamed Boudra
2026-07-19 03:53:07 +02:00
parent 6240b2d17c
commit 548e15c177
2 changed files with 13 additions and 1 deletions
@@ -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", () => {
@@ -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;
}