Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
149 lines
4.5 KiB
JavaScript
149 lines
4.5 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Guards pnpm package patches against unapproved additions.
|
|
import { execFileSync } from "node:child_process";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import YAML from "yaml";
|
|
|
|
const ALLOWED_PATCHED_DEPENDENCIES = new Map([
|
|
// Remove after fs-safe ships pinned-write fsync with best-effort EPERM handling.
|
|
["@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"],
|
|
["baileys@7.0.0-rc13", "patches/baileys@7.0.0-rc13.patch"],
|
|
]);
|
|
|
|
const ALLOWED_PATCH_FILES = new Set(["patches/.gitkeep", ...ALLOWED_PATCHED_DEPENDENCIES.values()]);
|
|
|
|
function listTrackedFiles(cwd, patterns) {
|
|
return execFileSync("git", ["ls-files", "-z", "--", ...patterns], {
|
|
cwd,
|
|
encoding: "utf8",
|
|
})
|
|
.split("\0")
|
|
.filter(Boolean)
|
|
.toSorted((left, right) => left.localeCompare(right));
|
|
}
|
|
|
|
function readYamlFile(cwd, relativePath) {
|
|
const filePath = path.join(cwd, relativePath);
|
|
if (!fs.existsSync(filePath)) {
|
|
return {};
|
|
}
|
|
return YAML.parse(fs.readFileSync(filePath, "utf8")) ?? {};
|
|
}
|
|
|
|
function readJsonFile(cwd, relativePath) {
|
|
const filePath = path.join(cwd, relativePath);
|
|
if (!fs.existsSync(filePath)) {
|
|
return undefined;
|
|
}
|
|
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
}
|
|
|
|
function collectPatchedDependencyViolations(file, patchedDependencies, violations, options = {}) {
|
|
for (const [specifier, patchPathOrHash] of Object.entries(patchedDependencies ?? {})) {
|
|
if (
|
|
options.allowAnyValueForLegacy === true
|
|
? ALLOWED_PATCHED_DEPENDENCIES.has(specifier)
|
|
: ALLOWED_PATCHED_DEPENDENCIES.get(specifier) === patchPathOrHash
|
|
) {
|
|
continue;
|
|
}
|
|
violations.push({
|
|
file,
|
|
kind: "patchedDependency",
|
|
detail: `${specifier} -> ${String(patchPathOrHash)}`,
|
|
});
|
|
}
|
|
}
|
|
|
|
function collectWorkspacePatchViolations(cwd, violations) {
|
|
const workspace = readYamlFile(cwd, "pnpm-workspace.yaml");
|
|
collectPatchedDependencyViolations(
|
|
"pnpm-workspace.yaml",
|
|
workspace?.patchedDependencies,
|
|
violations,
|
|
);
|
|
}
|
|
|
|
function collectLockfilePatchViolations(cwd, violations) {
|
|
const lockfile = readYamlFile(cwd, "pnpm-lock.yaml");
|
|
collectPatchedDependencyViolations("pnpm-lock.yaml", lockfile?.patchedDependencies, violations, {
|
|
allowAnyValueForLegacy: true,
|
|
});
|
|
}
|
|
|
|
function collectPackageJsonPatchViolations(cwd, violations) {
|
|
for (const relativePath of listTrackedFiles(cwd, ["*package.json"])) {
|
|
const packageJson = readJsonFile(cwd, relativePath);
|
|
const patchedDependencies = packageJson?.pnpm?.patchedDependencies;
|
|
for (const [specifier, patchPath] of Object.entries(patchedDependencies ?? {})) {
|
|
violations.push({
|
|
file: relativePath,
|
|
kind: "packageJsonPatchedDependency",
|
|
detail: `${specifier} -> ${String(patchPath)}`,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
function collectPatchFileViolations(cwd, violations) {
|
|
for (const relativePath of listTrackedFiles(cwd, ["*.patch"])) {
|
|
if (!fs.existsSync(path.join(cwd, relativePath))) {
|
|
continue;
|
|
}
|
|
if (ALLOWED_PATCH_FILES.has(relativePath)) {
|
|
continue;
|
|
}
|
|
violations.push({
|
|
file: relativePath,
|
|
kind: "patchFile",
|
|
detail: "new package patch file",
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Collects disallowed package patch declarations and patch files.
|
|
*/
|
|
export function collectPackagePatchViolations(cwd = process.cwd()) {
|
|
const violations = [];
|
|
collectWorkspacePatchViolations(cwd, violations);
|
|
collectLockfilePatchViolations(cwd, violations);
|
|
collectPackageJsonPatchViolations(cwd, violations);
|
|
collectPatchFileViolations(cwd, violations);
|
|
return violations;
|
|
}
|
|
|
|
/**
|
|
* Runs the package patch guard.
|
|
*/
|
|
export async function main() {
|
|
const violations = collectPackagePatchViolations();
|
|
if (violations.length === 0) {
|
|
process.stdout.write(
|
|
`PASS package patch guard: no new pnpm patches; ${ALLOWED_PATCHED_DEPENDENCIES.size} approved patches allowlisted.\n`,
|
|
);
|
|
return;
|
|
}
|
|
|
|
console.error(
|
|
"FAIL package patch guard: new pnpm package patches are not allowed. Upstream the fix, publish a new package version, then bump the dependency instead.",
|
|
);
|
|
for (const violation of violations) {
|
|
console.error(`- ${violation.file}: ${violation.kind}: ${violation.detail}`);
|
|
}
|
|
process.exitCode = 1;
|
|
}
|
|
|
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
main().catch(
|
|
/** @param {unknown} error */ (error) => {
|
|
console.error(error);
|
|
process.exit(1);
|
|
},
|
|
);
|
|
}
|