Skip to content

Commit cb2965d

Browse files
fix(scripts): use direct-run helper for Windows guards (#110877)
* fix(scripts): normalize Windows direct-run guards * test(scripts): cover direct-run routing --------- Co-authored-by: Vincent Koc <[email protected]>
1 parent d06fc25 commit cb2965d

13 files changed

Lines changed: 141 additions & 13 deletions

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@
18981898
"test:unit:fast:audit": "node scripts/test-unit-fast-audit.mjs",
18991899
"test:voicecall:closedloop": "node scripts/test-voicecall-closedloop.mjs",
19001900
"test:watch": "node scripts/test-projects.mjs --watch",
1901-
"test:windows:ci": "node scripts/test-projects.mjs src/shared/runtime-import.test.ts src/infra/sqlite-snapshot.test.ts src/infra/ssh-client.windows.test.ts src/infra/update-managed-service-handoff.test.ts src/infra/exec-allowlist-pattern.test.ts src/infra/fs-safe-remove.test.ts src/snapshot/local-repository.windows.test.ts src/state/openclaw-database-paths.windows.test.ts src/commands/backup-verify.test.ts src/infra/state-migrations.legacy-session-store.test.ts src/test-utils/openclaw-test-state.test.ts src/agents/sessions/windows-git-bash-path.test.ts src/agents/bash-tools.exec.script-preflight.test.ts src/process/exec.windows.test.ts src/process/exec.windows.integration.test.ts src/process/windows-command.test.ts src/infra/windows-install-roots.test.ts src/node-host/invoke-system-run-allowlist.test.ts src/daemon/schtasks.startup-fallback.test.ts extensions/lobster/src/lobster-runner.test.ts extensions/mxc/test/mxc-backend.test.ts extensions/mxc/test/sandbox-policy-loader.test.ts test/e2e/qa-lab/runtime/package-openclaw-for-docker.e2e.test.ts test/scripts/format-generated-module.test.ts test/scripts/npm-runner.test.ts test/scripts/openclaw-cross-os-installer.windows.test.ts test/scripts/openclaw-cross-os-release-workflow.test.ts test/scripts/pnpm-runner.test.ts test/scripts/run-with-env.test.ts test/scripts/ts-topology.test.ts test/scripts/ui.test.ts test/scripts/vitest-process-group.test.ts",
1901+
"test:windows:ci": "node scripts/test-projects.mjs src/shared/runtime-import.test.ts src/infra/sqlite-snapshot.test.ts src/infra/ssh-client.windows.test.ts src/infra/update-managed-service-handoff.test.ts src/infra/exec-allowlist-pattern.test.ts src/infra/fs-safe-remove.test.ts src/snapshot/local-repository.windows.test.ts src/state/openclaw-database-paths.windows.test.ts src/commands/backup-verify.test.ts src/infra/state-migrations.legacy-session-store.test.ts src/test-utils/openclaw-test-state.test.ts src/agents/sessions/windows-git-bash-path.test.ts src/agents/bash-tools.exec.script-preflight.test.ts src/process/exec.windows.test.ts src/process/exec.windows.integration.test.ts src/process/windows-command.test.ts src/infra/windows-install-roots.test.ts src/node-host/invoke-system-run-allowlist.test.ts src/daemon/schtasks.startup-fallback.test.ts extensions/lobster/src/lobster-runner.test.ts extensions/mxc/test/mxc-backend.test.ts extensions/mxc/test/sandbox-policy-loader.test.ts test/e2e/qa-lab/runtime/package-openclaw-for-docker.e2e.test.ts test/scripts/direct-run-entrypoints.test.ts test/scripts/format-generated-module.test.ts test/scripts/npm-runner.test.ts test/scripts/openclaw-cross-os-installer.windows.test.ts test/scripts/openclaw-cross-os-release-workflow.test.ts test/scripts/pnpm-runner.test.ts test/scripts/run-with-env.test.ts test/scripts/ts-topology.test.ts test/scripts/ui.test.ts test/scripts/vitest-process-group.test.ts",
19021902
"test:windows:schtasks:integration": "node scripts/run-with-env.mjs CI_WINDOWS_SCHTASKS_INTEGRATION=1 OPENCLAW_E2E_VERBOSE=1 OPENCLAW_VITEST_MAX_WORKERS=1 -- node scripts/run-vitest.mjs src/daemon/schtasks.integration.e2e.test.ts",
19031903
"tool-display:check": "node --import tsx scripts/tool-display.ts --check",
19041904
"tool-display:write": "node --import tsx scripts/tool-display.ts --write",

‎scripts/android-app-i18n.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
33
import path from "node:path";
44
import { fileURLToPath } from "node:url";
55
import { expectDefined } from "../packages/normalization-core/src/expect.js";
6+
import { isDirectRunUrl } from "./lib/direct-run.mjs";
67
import { NATIVE_I18N_LOCALES } from "./native-i18n-locales.ts";
78

89
const HERE = path.dirname(fileURLToPath(import.meta.url));
@@ -1612,7 +1613,7 @@ export async function checkAndroidAppI18n(options: { tolerateManagedPending?: bo
16121613
);
16131614
}
16141615

1615-
if (process.argv[1] && import.meta.url === `file://${path.resolve(process.argv[1])}`) {
1616+
if (isDirectRunUrl(process.argv[1], import.meta.url)) {
16161617
const [command] = process.argv.slice(2);
16171618
if (command === "sync") {
16181619
await syncAndroidAppI18n();

‎scripts/android-pin-version.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
syncAndroidVersioning,
1010
writeAndroidVersionManifest,
1111
} from "./lib/android-version.ts";
12+
import { isDirectRunUrl } from "./lib/direct-run.mjs";
1213

1314
type CliOptions = {
1415
explicitVersion: string | null;
@@ -194,7 +195,7 @@ export async function main(argv: string[]): Promise<number> {
194195
}
195196
}
196197

197-
if (import.meta.url === `file://${process.argv[1]}`) {
198+
if (isDirectRunUrl(process.argv[1], import.meta.url)) {
198199
const exitCode = await main(process.argv.slice(2));
199200
if (exitCode !== 0) {
200201
process.exit(exitCode);

‎scripts/ci-changed-scope.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ const NODE_SCOPE_RE =
5050
/^(src\/|test\/|extensions\/|packages\/|scripts\/|ui\/|\.github\/|openclaw\.mjs$|package\.json$|pnpm-lock\.yaml$|pnpm-workspace\.yaml$|tsconfig.*\.json$|vitest.*\.ts$|tsdown\.config\.ts$|\.oxlintrc\.json$|\.oxfmtrc\.jsonc$)/;
5151
const WINDOWS_SQLITE_SCOPE_RE = /^src\/(?:state\/|.*sqlite.*\.ts$)/;
5252
const WINDOWS_SCOPE_RE =
53-
/^(extensions\/mxc\/|src\/agents\/(?:bash-tools\.exec-script-(?:preflight|target)|bash-tools\.exec\.script-preflight\.test)\.ts$|src\/config\/sessions\/(?:session-accessor\.sqlite-archive|store\.session-lifecycle-mutation\.test)\.ts$|src\/process\/|src\/infra\/(?:(?:exec-allowlist-pattern|fs-safe-remove)(?:\.test)?|ssh-client(?:\.windows\.test)?|update-managed-service-handoff(?:\.test)?|windows-install-roots)\.ts$|src\/shared\/(?:import-specifier|runtime-import)(?:\.test)?\.ts$|src\/test-utils\/openclaw-test-state(?:\.test)?\.ts$|scripts\/(?:install\.ps1|openclaw-cross-os-release-checks\.ts|github\/run-openclaw-cross-os-release-checks\.sh|(?:npm-runner|pnpm-runner|ui|vitest-process-group)\.(?:mjs|js)|lib\/(?:format-generated-module\.mjs|cross-os-release-checks\/[^/]+\.ts))$|test\/scripts\/(?:format-generated-module|install-ps1|npm-runner|openclaw-cross-os-release-workflow|pnpm-runner|ui|vitest-process-group)\.test\.ts$|package\.json$|pnpm-lock\.yaml$|pnpm-workspace\.yaml$|\.github\/workflows\/(?:ci|openclaw-cross-os-release-checks-reusable)\.yml$|\.github\/actions\/setup-node-env\/action\.yml$|\.github\/actions\/setup-pnpm-store-cache\/action\.yml$)/;
53+
/^(extensions\/mxc\/|src\/agents\/(?:bash-tools\.exec-script-(?:preflight|target)|bash-tools\.exec\.script-preflight\.test)\.ts$|src\/config\/sessions\/(?:session-accessor\.sqlite-archive|store\.session-lifecycle-mutation\.test)\.ts$|src\/process\/|src\/infra\/(?:(?:exec-allowlist-pattern|fs-safe-remove)(?:\.test)?|ssh-client(?:\.windows\.test)?|update-managed-service-handoff(?:\.test)?|windows-install-roots)\.ts$|src\/shared\/(?:import-specifier|runtime-import)(?:\.test)?\.ts$|src\/test-utils\/openclaw-test-state(?:\.test)?\.ts$|scripts\/(?:android-(?:app-i18n|pin-version)\.ts|ci-run-timings\.mjs|e2e\/lib\/package-compat\.mjs|generate-bundled-channel-config-metadata\.ts|install\.ps1|openclaw-cross-os-release-checks\.ts|plan-release-workflow-matrix\.mjs|run-additional-boundary-checks\.mjs|verify-docker-attestations\.mjs|github\/run-openclaw-cross-os-release-checks\.sh|(?:npm-runner|pnpm-runner|ui|vitest-process-group)\.(?:mjs|js)|lib\/(?:direct-run\.mjs|format-generated-module\.mjs|cross-os-release-checks\/[^/]+\.ts))$|test\/scripts\/(?:direct-run-entrypoints|format-generated-module|install-ps1|npm-runner|openclaw-cross-os-release-workflow|pnpm-runner|ui|vitest-process-group)\.test\.ts$|package\.json$|pnpm-lock\.yaml$|pnpm-workspace\.yaml$|\.github\/workflows\/(?:ci|openclaw-cross-os-release-checks-reusable)\.yml$|\.github\/actions\/setup-node-env\/action\.yml$|\.github\/actions\/setup-pnpm-store-cache\/action\.yml$)/;
5454
const WINDOWS_TEST_SCOPE_RE =
55-
/^(extensions\/mxc\/test\/(?:mxc-backend|sandbox-policy-loader)\.test\.ts$|src\/agents\/bash-tools\.exec\.script-preflight\.test\.ts$|src\/config\/sessions\/store\.session-lifecycle-mutation\.test\.ts$|src\/process\/(?:exec\.windows|windows-command)\.test\.ts$|src\/infra\/(?:exec-allowlist-pattern|fs-safe-remove|ssh-client\.windows|update-managed-service-handoff|windows-install-roots)\.test\.ts$|src\/shared\/runtime-import\.test\.ts$|src\/state\/openclaw-database-paths\.windows\.test\.ts$|src\/test-utils\/openclaw-test-state\.test\.ts$|test\/scripts\/(?:format-generated-module|npm-runner|openclaw-cross-os-release-workflow|pnpm-runner|ui|vitest-process-group)\.test\.ts$)/;
55+
/^(extensions\/mxc\/test\/(?:mxc-backend|sandbox-policy-loader)\.test\.ts$|src\/agents\/bash-tools\.exec\.script-preflight\.test\.ts$|src\/config\/sessions\/store\.session-lifecycle-mutation\.test\.ts$|src\/process\/(?:exec\.windows|windows-command)\.test\.ts$|src\/infra\/(?:exec-allowlist-pattern|fs-safe-remove|ssh-client\.windows|update-managed-service-handoff|windows-install-roots)\.test\.ts$|src\/shared\/runtime-import\.test\.ts$|src\/state\/openclaw-database-paths\.windows\.test\.ts$|src\/test-utils\/openclaw-test-state\.test\.ts$|test\/scripts\/(?:direct-run-entrypoints|format-generated-module|npm-runner|openclaw-cross-os-release-workflow|pnpm-runner|ui|vitest-process-group)\.test\.ts$)/;
5656
const WINDOWS_DAEMON_SCOPE_RE =
5757
/^src\/daemon\/(?:schtasks(?:[-.][^/]+)?|runtime-hints\.windows-paths(?:\.test)?|test-helpers\/schtasks-(?:base-mocks|fixtures))\.ts$/;
5858
const CONTROL_UI_I18N_SCOPE_RE =

‎scripts/ci-run-timings.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// Summarizes GitHub Actions run/job timings for CI analysis.
44
import { execFileSync } from "node:child_process";
5+
import { isDirectRunUrl } from "./lib/direct-run.mjs";
56
import { parsePositiveInt } from "./lib/numeric-options.mjs";
67
import { execPlainGh } from "./lib/plain-gh.mjs";
78

@@ -503,6 +504,6 @@ async function main() {
503504
}
504505
}
505506

506-
if (import.meta.url === `file://${process.argv[1]}`) {
507+
if (isDirectRunUrl(process.argv[1], import.meta.url)) {
507508
await main();
508509
}

‎scripts/e2e/lib/package-compat.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Package-version compatibility helpers for E2E acceptance scripts.
2+
import { isDirectRunUrl } from "../../lib/direct-run.mjs";
3+
24
export function legacyPackageAcceptanceCompat(version) {
35
const match = /^(\d{4})\.(\d{1,2})\.(\d{1,2})(?:[-+].*)?/.exec(version || "");
46
const [year, month, day] = match?.slice(1, 4).map(Number) ?? [];
@@ -7,6 +9,6 @@ export function legacyPackageAcceptanceCompat(version) {
79
);
810
}
911

10-
if (import.meta.url === `file://${process.argv[1]}`) {
12+
if (isDirectRunUrl(process.argv[1], import.meta.url)) {
1113
console.log(legacyPackageAcceptanceCompat(process.argv[2]) ? "1" : "0");
1214
}

‎scripts/generate-bundled-channel-config-metadata.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import fs from "node:fs";
44
import path from "node:path";
55
import { loadBundledPluginPublicArtifactModuleSync } from "../src/plugins/public-surface-loader.js";
6+
import { isDirectRunUrl } from "./lib/direct-run.mjs";
67
import { loadChannelConfigSurfaceModule } from "./load-channel-config-surface.ts";
78

89
const GENERATED_BY = "scripts/generate-bundled-channel-config-metadata.ts";
@@ -341,7 +342,7 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = JSON.parse(
341342
});
342343
}
343344

344-
if (import.meta.url === new URL(process.argv[1] ?? "", "file://").href) {
345+
if (isDirectRunUrl(process.argv[1], import.meta.url)) {
345346
const check = process.argv.includes("--check");
346347
const result = await writeBundledChannelConfigMetadataModule({ check });
347348
if (!result.changed) {

‎scripts/plan-release-workflow-matrix.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Plans release workflow matrix entries from profile and suite inputs.
2+
import { isDirectRunUrl } from "./lib/direct-run.mjs";
3+
24
const DOCKER_E2E_CHUNKS = [
35
{
46
chunk_id: "core",
@@ -236,7 +238,7 @@ function writeOutputs(plan) {
236238
}
237239
}
238240

239-
if (import.meta.url === `file://${process.argv[1]}`) {
241+
if (isDirectRunUrl(process.argv[1], import.meta.url)) {
240242
const plan = createReleaseWorkflowMatrixPlan({
241243
dockerLanes: process.env.DOCKER_LANES,
242244
includeLiveSuites: process.env.INCLUDE_LIVE_SUITES,

‎scripts/run-additional-boundary-checks.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { spawn } from "node:child_process";
55
import { performance } from "node:perf_hooks";
66
import pMap from "p-map";
77
import prettyMilliseconds from "pretty-ms";
8+
import { isDirectRunUrl } from "./lib/direct-run.mjs";
89

910
const DEFAULT_CHECK_TIMEOUT_MS = 10 * 60 * 1000;
1011
const DEFAULT_OUTPUT_MAX_BYTES = 512 * 1024;
@@ -584,7 +585,7 @@ export function parseCliArgs(args, env = process.env) {
584585
return { help, shardSpec };
585586
}
586587

587-
if (import.meta.url === `file://${process.argv[1]}`) {
588+
if (isDirectRunUrl(process.argv[1], import.meta.url)) {
588589
try {
589590
const cliArgs = parseCliArgs(process.argv.slice(2), process.env);
590591
if (cliArgs.help) {

‎scripts/verify-docker-attestations.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Verifies Docker image attestations cover required platforms and predicates.
44
import { execFileSync } from "node:child_process";
55
import process from "node:process";
6+
import { isDirectRunUrl } from "./lib/direct-run.mjs";
67

78
const ATTESTATION_REFERENCE_TYPE = "attestation-manifest";
89
const EXPECTED_ATTESTATION_ARTIFACT_TYPE = "application/vnd.docker.attestation.manifest.v1+json";
@@ -227,7 +228,7 @@ async function main() {
227228
});
228229
}
229230

230-
if (import.meta.url === `file://${process.argv[1]}`) {
231+
if (isDirectRunUrl(process.argv[1], import.meta.url)) {
231232
main().catch(
232233
/** @param {unknown} error */ (error) => {
233234
console.error(error instanceof Error ? error.message : String(error));

0 commit comments

Comments
 (0)