mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-15 10:36:09 +00:00
* chore(types): add declaration files for scripts/lib and scripts/e2e modules
* chore(types): add declaration files for top-level script modules (a-m)
* chore(types): add declaration files for top-level script modules (n-z)
* test: use a non-secret-shaped gateway token fixture
* test: type ci workflow guard helpers for the root test lane
* chore(tooling): typecheck root test/** with a dedicated tsgo lane
- test/tsconfig/tsconfig.test.root.json: root-test program (strict unused checks,
fixtures excluded; two Docker E2E clients that import built dist/** stay out,
same rationale as the scripts/e2e exclusion in tsconfig.scripts.json)
- tsgo:test:root wired into tsgo:test, check:test-types, scripts/check.mjs, and
the ci.yml test-types shard, mirroring the tsgo:scripts lane (#104348)
- changed-lane routing: test/**/*.ts (excluding fixtures) and the lane tsconfig
now trigger 'typecheck test root' in check:changed; previously test/ paths ran
lint only, so harness type errors surfaced first in CI (#104287 envDir case)
- burn down all 1071 latent type errors in the program: precise param/local
types across test/scripts, test/vitest, test/e2e, and transitive scripts/e2e
program members; 205 sibling .d.mts declaration files for imported .mjs
modules (committed separately); zero any, zero ts-expect-error
- resolve the pre-existing testing star-export ambiguity in
scripts/e2e/parallels/common.ts with an explicit re-export
Closes #104388
* chore(types): correct declaration fidelity per structured review
- re-derive 51 .d.mts files from implementation data flow instead of
initializers: fix a wrong never return (runTestProjectsDelegation returns
the child), add encoding-sensitive exec/spawn overloads (plain-gh), restore
the full release profile union, make parsed paths string | null, add missing
parseArgs fields via help/non-help unions, add a missing sibling declaration
(budget-number-args), drop 15 unused lint directives
- precise install-record/tuple typing removes the type-aware oxlint
regressions the first declarations caused in scripts/e2e implementations
- route .mts declaration edits under test/ to the testRoot lane and reference
the test-root project from tsconfig.projects.json so tsgo:all covers it
(closes both review findings against the lane wiring)
* chore(scripts): keep telegram runner dist typing structural for the boundary guard
* chore(types): declare runtime pack and gateway readiness exports added on main
* test: pin the importTargetPlan form of the plugin-contract plan import
The guard expectation still referenced the raw await import( form that
7ae5996bb3 (#103975) replaced with the importTargetPlan fallback helper;
the assertion fails on current main.
185 lines
5.6 KiB
TypeScript
185 lines
5.6 KiB
TypeScript
// Check Package Patches tests cover check package patches script behavior.
|
|
import { execFileSync } from "node:child_process";
|
|
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import { collectPackagePatchViolations } from "../../scripts/check-package-patches.mjs";
|
|
import { cleanupTempDirs, makeTempRepoRoot, writeJsonFile } from "../helpers/temp-repo.js";
|
|
|
|
const tempDirs: string[] = [];
|
|
|
|
const nestedGitEnvKeys = [
|
|
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
"GIT_DIR",
|
|
"GIT_INDEX_FILE",
|
|
"GIT_OBJECT_DIRECTORY",
|
|
"GIT_QUARANTINE_PATH",
|
|
"GIT_WORK_TREE",
|
|
] as const;
|
|
|
|
function createNestedGitEnv(): NodeJS.ProcessEnv {
|
|
const env: NodeJS.ProcessEnv = {
|
|
...process.env,
|
|
GIT_CONFIG_NOSYSTEM: "1",
|
|
GIT_TERMINAL_PROMPT: "0",
|
|
};
|
|
for (const key of nestedGitEnvKeys) {
|
|
delete env[key];
|
|
}
|
|
return env;
|
|
}
|
|
|
|
function git(cwd: string, args: string[]) {
|
|
execFileSync("git", args, {
|
|
cwd,
|
|
encoding: "utf8",
|
|
env: createNestedGitEnv(),
|
|
});
|
|
}
|
|
|
|
function makeRepo() {
|
|
const dir = makeTempRepoRoot(tempDirs, "openclaw-package-patches-");
|
|
git(dir, ["init", "-q", "--initial-branch=main"]);
|
|
writeJsonFile(path.join(dir, "package.json"), { name: "fixture" });
|
|
writeFileSync(path.join(dir, "pnpm-workspace.yaml"), "packages:\n - .\n", "utf8");
|
|
writeFileSync(path.join(dir, "pnpm-lock.yaml"), "lockfileVersion: '9.0'\n", "utf8");
|
|
git(dir, ["add", "package.json", "pnpm-workspace.yaml", "pnpm-lock.yaml"]);
|
|
return dir;
|
|
}
|
|
|
|
afterEach(() => {
|
|
cleanupTempDirs(tempDirs);
|
|
});
|
|
|
|
describe("check-package-patches", () => {
|
|
it("allows approved pnpm patches", () => {
|
|
const dir = makeRepo();
|
|
mkdirSync(path.join(dir, "patches"), { recursive: true });
|
|
writeFileSync(
|
|
path.join(dir, "pnpm-workspace.yaml"),
|
|
`packages:
|
|
- .
|
|
patchedDependencies:
|
|
"@openclaw/fs-safe@0.4.1": "patches/@openclaw__fs-safe@0.4.1.patch"
|
|
"baileys@7.0.0-rc12": "patches/baileys@7.0.0-rc12.patch"
|
|
`,
|
|
"utf8",
|
|
);
|
|
writeFileSync(
|
|
path.join(dir, "pnpm-lock.yaml"),
|
|
`lockfileVersion: '9.0'
|
|
patchedDependencies:
|
|
"@openclaw/fs-safe@0.4.1": fs-safe-hash
|
|
baileys@7.0.0-rc12: a9aea1790d2c65b1ae543c77faca4119bbfb91ee3b6ca6c38d1cad4f5702ada2
|
|
`,
|
|
"utf8",
|
|
);
|
|
writeFileSync(path.join(dir, "patches", "baileys@7.0.0-rc12.patch"), "diff\n", "utf8");
|
|
writeFileSync(path.join(dir, "patches", "@openclaw__fs-safe@0.4.1.patch"), "diff\n", "utf8");
|
|
git(dir, ["add", "pnpm-workspace.yaml", "pnpm-lock.yaml", "patches"]);
|
|
|
|
expect(collectPackagePatchViolations(dir)).toEqual([]);
|
|
});
|
|
|
|
it("rejects new workspace patchedDependencies and patch files", () => {
|
|
const dir = makeRepo();
|
|
mkdirSync(path.join(dir, "patches"), { recursive: true });
|
|
mkdirSync(path.join(dir, "fixtures"), { recursive: true });
|
|
writeFileSync(
|
|
path.join(dir, "pnpm-workspace.yaml"),
|
|
`packages:
|
|
- .
|
|
patchedDependencies:
|
|
"left-pad@1.3.0": "patches/left-pad@1.3.0.patch"
|
|
`,
|
|
"utf8",
|
|
);
|
|
writeFileSync(path.join(dir, "patches", "left-pad@1.3.0.patch"), "diff\n", "utf8");
|
|
writeFileSync(path.join(dir, "fixtures", "fixture.patch"), "diff\n", "utf8");
|
|
git(dir, ["add", "pnpm-workspace.yaml", "patches", "fixtures"]);
|
|
|
|
expect(collectPackagePatchViolations(dir)).toEqual([
|
|
{
|
|
file: "pnpm-workspace.yaml",
|
|
kind: "patchedDependency",
|
|
detail: "left-pad@1.3.0 -> patches/left-pad@1.3.0.patch",
|
|
},
|
|
{
|
|
file: "fixtures/fixture.patch",
|
|
kind: "patchFile",
|
|
detail: "new package patch file",
|
|
},
|
|
{
|
|
file: "patches/left-pad@1.3.0.patch",
|
|
kind: "patchFile",
|
|
detail: "new package patch file",
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("allows deleted legacy patch files during the commit that removes them", () => {
|
|
const dir = makeRepo();
|
|
mkdirSync(path.join(dir, "patches"), { recursive: true });
|
|
writeFileSync(
|
|
path.join(dir, "patches", "@agentclientprotocol__claude-agent-acp@0.33.1.patch"),
|
|
"diff\n",
|
|
"utf8",
|
|
);
|
|
git(dir, ["add", "patches"]);
|
|
rmSync(path.join(dir, "patches", "@agentclientprotocol__claude-agent-acp@0.33.1.patch"));
|
|
|
|
expect(collectPackagePatchViolations(dir)).toEqual([]);
|
|
});
|
|
|
|
it("rejects lockfile-only and package-local patch declarations", () => {
|
|
const dir = makeRepo();
|
|
writeJsonFile(path.join(dir, "package.json"), {
|
|
name: "fixture",
|
|
pnpm: {
|
|
patchedDependencies: {
|
|
"nested@1.0.0": "patches/nested.patch",
|
|
},
|
|
},
|
|
});
|
|
writeFileSync(
|
|
path.join(dir, "pnpm-lock.yaml"),
|
|
`lockfileVersion: '9.0'
|
|
patchedDependencies:
|
|
hidden@1.0.0: abc123
|
|
`,
|
|
"utf8",
|
|
);
|
|
git(dir, ["add", "package.json", "pnpm-lock.yaml"]);
|
|
|
|
expect(collectPackagePatchViolations(dir)).toEqual([
|
|
{
|
|
file: "pnpm-lock.yaml",
|
|
kind: "patchedDependency",
|
|
detail: "hidden@1.0.0 -> abc123",
|
|
},
|
|
{
|
|
file: "package.json",
|
|
kind: "packageJsonPatchedDependency",
|
|
detail: "nested@1.0.0 -> patches/nested.patch",
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("skips tracked package manifests deleted in the worktree", () => {
|
|
const dir = makeRepo();
|
|
mkdirSync(path.join(dir, "packages", "deleted"), { recursive: true });
|
|
writeJsonFile(path.join(dir, "packages", "deleted", "package.json"), {
|
|
name: "deleted",
|
|
pnpm: {
|
|
patchedDependencies: {
|
|
"deleted-only@1.0.0": "patches/deleted-only.patch",
|
|
},
|
|
},
|
|
});
|
|
git(dir, ["add", "packages/deleted/package.json"]);
|
|
rmSync(path.join(dir, "packages", "deleted", "package.json"));
|
|
|
|
expect(collectPackagePatchViolations(dir)).toEqual([]);
|
|
});
|
|
});
|