Files
openclaw/test/scripts/pr-wrapper.test-support.ts
RoboClawandsteipete 1a5325f035 refactor: remove narrowly used helper dependencies (#158573)
* refactor: remove narrowly used helper dependencies

Replace markdown-it-task-lists and grammY runner sequencing with their local owners. Remove direct ms/pretty-ms usage and share the existing duration factors and formatting. Preserve rendering and parsing contracts, and keep overlapping Telegram lanes ordered when a predecessor fails.

Remove obsolete mocks, declarations, dependency metadata, and build references; regenerate the lockfile and Control UI boot manifest. Deduplicate an inherited over-limit replay test without changing coverage.

Closes #158499

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>

* refactor: remove narrowly used helper dependencies

Worked on by:
- @steipete

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
OpenClaw-Publication: f4ef665a-7e2b-47ce-a454-adc19e798bee

* refactor: remove narrowly used helper dependencies

Worked on by:
- @steipete

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
OpenClaw-Publication: abec5219-5bd0-4480-8604-a57c1063f638

* fix(ci): preserve base-only dependencies in UI comparison

Materialize removed dependency declarations from the archived base lockfile before overlaying the candidate toolchain. Keep both builds on the same Vite and compressor without restoring removed application dependencies.

Extend the real build regression with a dependency absent from the candidate and verify the original comparator fails to resolve it.

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>

* refactor: remove narrowly used helper dependencies

Worked on by:
- @steipete

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
OpenClaw-Publication: 2db2eea4-87fe-4071-ab37-28da02f1bd24

* refactor: remove narrowly used helper dependencies

Worked on by:
- @steipete

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
OpenClaw-Publication: 8c381a6d-38f2-417f-85ee-9353cb5694dc

---------

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
2026-09-26 22:38:09 -07:00

78 lines
2.3 KiB
TypeScript

import { cpSync, lstatSync, mkdirSync, readFileSync, realpathSync, symlinkSync } from "node:fs";
import { dirname, join } from "node:path";
export function createIndependentPrFixtureEnv(
parentEnv: NodeJS.ProcessEnv = process.env,
): NodeJS.ProcessEnv {
const env = { ...parentEnv };
// Independent fixtures own wrapper routing, Git selection, and supervisor bindings.
for (const key of Object.keys(env)) {
if (key === "GIT_EXEC" || key.startsWith("OPENCLAW_PR_")) {
delete env[key];
}
}
return env;
}
export function copyPrWrapperSources(destination: string): string[] {
// Keep fixture sources and commits on the production inventory. Extracted
// execution tests catch missing dependencies without a second source list.
const components = [
"scripts/pr",
"scripts/pr-lib",
...readFileSync("scripts/pr-lib/wrapper-components.txt", "utf8").trim().split("\n"),
];
for (const component of components) {
mkdirSync(dirname(join(destination, component)), { recursive: true });
cpSync(component, join(destination, component), { recursive: true });
}
return components;
}
export function linkPrWrapperDependencies(destination: string): void {
// Fixture initialization may repeat; stale-base squash merges have reintroduced
// duplicate initialization twice.
const modulesDir = join(destination, "node_modules");
mkdirSync(modulesDir, { recursive: true });
// Use installed third-party packages only, never workspace source or loader mocks.
for (const dependency of [
"@openclaw/fs-safe",
"@openclaw/proxyline",
"acorn",
"chalk",
"commander",
"dotenv",
"execa",
"hosted-git-info",
"import-meta-resolve",
"ipaddr.js",
"jiti",
"json5",
"koffi",
"kysely",
"minimatch",
"p-map",
"semver",
"string-width",
"tsdown",
"tslog",
"tsx",
"typebox",
"typescript",
"undici",
"yaml",
"zod",
]) {
const linkedDependency = join(modulesDir, dependency);
mkdirSync(dirname(linkedDependency), { recursive: true });
if (lstatSync(linkedDependency, { throwIfNoEntry: false })) {
continue;
}
symlinkSync(
realpathSync(join("node_modules", dependency)),
linkedDependency,
process.platform === "win32" ? "junction" : "dir",
);
}
}