mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 06:51:35 +00:00
* build(deps): remove npm shrinkwrap; mirror pnpm lock into transient package locks npm 12 removed shrinkwrap (command + tarball/root loading). Delete all 82 committed npm-shrinkwrap.json files and stop publishing lockfiles; keep pnpm-lock.yaml as the single reviewed dependency boundary. The generator becomes scripts/generate-npm-package-lock.mjs and feeds plugin bundling via a transient package-lock.json + npm ci (works on npm 11 and 12). Tarball validation treats the published 2026.7.2 beta train as a shrinkwrap transition; self-update npm detection now uses install topology instead of the shipped shrinkwrap. * fix(deps): repair lint, deadcode, and test-type lanes for the npm 12 migration - sort integrity comparisons with an explicit comparator (oxlint) - keep resolveBunGlobalNodeModules module-local (knip unused-export gate) - model npm pack --json as npm<=11 array / npm 12 name-keyed object - default calver destructuring in the tarball test fixture
123 lines
4.1 KiB
TypeScript
123 lines
4.1 KiB
TypeScript
// Dependency Changes Report tests cover dependency changes report script behavior.
|
|
import { spawnSync } from "node:child_process";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
createDependencyChangesReport,
|
|
dependencyDiffPathspecs,
|
|
isDependencyFile,
|
|
parseArgs,
|
|
} from "../../scripts/dependency-changes-report.mjs";
|
|
|
|
function runCli(...args: string[]) {
|
|
return spawnSync(process.execPath, ["scripts/dependency-changes-report.mjs", ...args], {
|
|
cwd: path.resolve("."),
|
|
encoding: "utf8",
|
|
});
|
|
}
|
|
|
|
function expectNoNodeStack(stderr: string) {
|
|
expect(stderr).not.toContain("Node.js");
|
|
expect(stderr).not.toContain("\n at ");
|
|
}
|
|
|
|
describe("dependency-changes-report", () => {
|
|
it("reports added, removed, and changed packages", () => {
|
|
const report = createDependencyChangesReport({
|
|
basePayload: {
|
|
removed: ["1.0.0"],
|
|
stable: ["1.0.0"],
|
|
changed: ["1.0.0"],
|
|
},
|
|
headPayload: {
|
|
added: ["1.0.0"],
|
|
stable: ["1.0.0"],
|
|
changed: ["2.0.0"],
|
|
},
|
|
dependencyFileChanges: [
|
|
{ status: "M", path: "pnpm-lock.yaml", oldPath: null },
|
|
{ status: "M", path: "pnpm-workspace.yaml", oldPath: null },
|
|
],
|
|
generatedAt: "2026-05-12T00:00:00Z",
|
|
});
|
|
|
|
expect(report.summary).toEqual({
|
|
basePackages: 3,
|
|
headPackages: 3,
|
|
addedPackages: 1,
|
|
removedPackages: 1,
|
|
changedPackages: 1,
|
|
dependencyFileChanges: 2,
|
|
});
|
|
expect(report.dependencyFileChanges).toEqual([
|
|
{ status: "M", path: "pnpm-lock.yaml", oldPath: null },
|
|
{ status: "M", path: "pnpm-workspace.yaml", oldPath: null },
|
|
]);
|
|
expect(report.addedPackages).toEqual([{ packageName: "added", versions: ["1.0.0"] }]);
|
|
expect(report.removedPackages).toEqual([{ packageName: "removed", versions: ["1.0.0"] }]);
|
|
expect(report.changedPackages).toEqual([
|
|
{ packageName: "changed", addedVersions: ["2.0.0"], removedVersions: ["1.0.0"] },
|
|
]);
|
|
});
|
|
|
|
it("treats committed dependency locks as dependency files", () => {
|
|
expect(isDependencyFile("pnpm-lock.yaml")).toBe(true);
|
|
expect(isDependencyFile(".github/release/clawhub-cli/package-lock.json")).toBe(true);
|
|
expect(isDependencyFile("extensions/discord/package-lock.json")).toBe(false);
|
|
expect(isDependencyFile("docs/gateway/security/index.md")).toBe(false);
|
|
});
|
|
|
|
it("includes committed dependency locks in git diff pathspecs", () => {
|
|
expect(dependencyDiffPathspecs()).toContain("pnpm-lock.yaml");
|
|
expect(dependencyDiffPathspecs()).toContain(".github/release/clawhub-cli/package-lock.json");
|
|
});
|
|
|
|
it("rejects missing report artifact path option values", () => {
|
|
for (const flag of [
|
|
"--root",
|
|
"--base-ref",
|
|
"--base-lockfile",
|
|
"--head-lockfile",
|
|
"--json",
|
|
"--markdown",
|
|
]) {
|
|
expect(() => parseArgs([flag, "--json"])).toThrow(`${flag} requires a value`);
|
|
expect(() => parseArgs([flag, "-h"])).toThrow(`${flag} requires a value`);
|
|
}
|
|
});
|
|
|
|
it("rejects duplicate and conflicting dependency report inputs", () => {
|
|
for (const flag of [
|
|
"--root",
|
|
"--base-ref",
|
|
"--base-lockfile",
|
|
"--head-lockfile",
|
|
"--json",
|
|
"--markdown",
|
|
]) {
|
|
expect(() => parseArgs(["--base-ref", "main", flag, "one", flag, "two"])).toThrow(
|
|
`${flag} was provided more than once.`,
|
|
);
|
|
}
|
|
expect(() => parseArgs(["--base-ref", "main", "--base-lockfile", "base-lock.yaml"])).toThrow(
|
|
"Use either --base-ref or --base-lockfile, not both.",
|
|
);
|
|
});
|
|
|
|
it("reports CLI argument errors without a Node stack trace", () => {
|
|
const missingBase = runCli();
|
|
expect(missingBase.status).toBe(1);
|
|
expect(missingBase.stdout).toBe("");
|
|
expect(missingBase.stderr.trim()).toBe(
|
|
"Expected --base-ref <git-ref> or --base-lockfile <path>.",
|
|
);
|
|
expectNoNodeStack(missingBase.stderr);
|
|
|
|
const unknownArg = runCli("--wat");
|
|
expect(unknownArg.status).toBe(1);
|
|
expect(unknownArg.stdout).toBe("");
|
|
expect(unknownArg.stderr.trim()).toBe("Unsupported argument: --wat");
|
|
expectNoNodeStack(unknownArg.stderr);
|
|
});
|
|
});
|