mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 20:01:33 +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
75 lines
2.5 KiB
JavaScript
75 lines
2.5 KiB
JavaScript
#!/usr/bin/env node
|
|
// Prepares package-derived Docker E2E fixtures for git-style npm installs.
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
const [command, rootArg] = process.argv.slice(2);
|
|
|
|
function usage() {
|
|
console.error("usage: package-git-fixture.mjs prepare <fixture-root>");
|
|
process.exit(2);
|
|
}
|
|
|
|
function readJson(file) {
|
|
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
}
|
|
|
|
function writeJson(file, value) {
|
|
fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
}
|
|
|
|
function withoutAiRuntimeDependency(value) {
|
|
if (!Array.isArray(value)) {
|
|
return value;
|
|
}
|
|
const next = value.filter((entry) => entry !== "@openclaw/ai");
|
|
return next.length > 0 ? next : undefined;
|
|
}
|
|
|
|
function ensureDependencyIgnores(root) {
|
|
const gitignorePath = path.join(root, ".gitignore");
|
|
const existing = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, "utf8") : "";
|
|
const lines = new Set(existing.split(/\r?\n/u));
|
|
const required = ["node_modules", "**/node_modules/", "pnpm-lock.yaml"];
|
|
const missing = required.filter((entry) => !lines.has(entry));
|
|
if (missing.length === 0) {
|
|
return;
|
|
}
|
|
const prefix = existing.length === 0 || existing.endsWith("\n") ? existing : `${existing}\n`;
|
|
fs.writeFileSync(gitignorePath, `${prefix}${missing.join("\n")}\n`);
|
|
}
|
|
|
|
function prepare(root) {
|
|
ensureDependencyIgnores(root);
|
|
const packageJsonPath = path.join(root, "package.json");
|
|
const packageJson = readJson(packageJsonPath);
|
|
const aiRuntimeSource = path.join(root, "node_modules", "@openclaw", "ai");
|
|
const aiRuntimePackageJson = path.join(aiRuntimeSource, "package.json");
|
|
if (!fs.existsSync(aiRuntimePackageJson)) {
|
|
return;
|
|
}
|
|
|
|
const aiRuntimeTarget = path.join(root, ".openclaw-fixture", "packages", "ai");
|
|
fs.rmSync(aiRuntimeTarget, { force: true, recursive: true });
|
|
fs.mkdirSync(path.dirname(aiRuntimeTarget), { recursive: true });
|
|
fs.renameSync(aiRuntimeSource, aiRuntimeTarget);
|
|
|
|
packageJson.dependencies ??= {};
|
|
packageJson.dependencies["@openclaw/ai"] = "file:.openclaw-fixture/packages/ai";
|
|
packageJson.bundleDependencies = withoutAiRuntimeDependency(packageJson.bundleDependencies);
|
|
packageJson.bundledDependencies = withoutAiRuntimeDependency(packageJson.bundledDependencies);
|
|
if (packageJson.bundleDependencies === undefined) {
|
|
delete packageJson.bundleDependencies;
|
|
}
|
|
if (packageJson.bundledDependencies === undefined) {
|
|
delete packageJson.bundledDependencies;
|
|
}
|
|
writeJson(packageJsonPath, packageJson);
|
|
}
|
|
|
|
if (command !== "prepare" || !rootArg) {
|
|
usage();
|
|
}
|
|
|
|
prepare(path.resolve(rootArg));
|