openclaw/scripts/lib/packed-cargo-policy.mts
Peter Steinberger 9491d5a5a3
refactor(scripts): deslop scripts/lib (#159362)
* refactor(scripts): deslop scripts/lib

Consolidate script lifecycle, scenario, planner, report, release and
packaging helpers while retaining CLI and publication contracts.

Keep config-boundary source caches within one scan so repeated in-process
checks observe edits. Carry extracted helpers through selective fixtures
and iOS scope routing. Leave PR tooling and its library import closure intact.

* fix(scripts): retain sanitizer fast path after helper cleanup

* fix(scripts): model watchdog shell consumer in dead-code checks
2026-09-27 17:13:58 -07:00

77 lines
1.9 KiB
TypeScript

import { LOCAL_BUILD_METADATA_DIST_PATHS } from "./local-build-metadata-paths.mts";
const FORBIDDEN_PACKED_PATH_RULES = [
...LOCAL_BUILD_METADATA_DIST_PATHS.map((prefix) => ({
prefix,
kind: "local build metadata",
})),
{
prefix: "dist-runtime/",
kind: "local runtime build output",
},
{
prefix: "dist/OpenClaw.app/",
kind: "local application build output",
},
{
prefix: "docs/.generated/",
kind: "generated docs artifact",
},
{
prefix: "docs/channels/qa-channel.md",
kind: "private QA channel docs",
},
{
prefix: "dist/extensions/qa-channel/",
kind: "private QA channel artifact",
},
{
prefix: "dist/extensions/qa-lab/",
kind: "private QA lab artifact",
},
{
prefix: "dist/plugin-sdk/extensions/qa-channel/",
kind: "private QA channel type artifact",
},
{
prefix: "dist/plugin-sdk/extensions/qa-lab/",
kind: "private QA lab type artifact",
},
{
prefix: "dist/plugin-sdk/qa-channel.",
kind: "private QA channel SDK artifact",
},
{
prefix: "dist/plugin-sdk/qa-channel-protocol.",
kind: "private QA channel SDK artifact",
},
{
prefix: "dist/plugin-sdk/qa-lab.",
kind: "private QA lab SDK artifact",
},
{
prefix: "dist/plugin-sdk/qa-runtime.",
kind: "private QA runtime SDK artifact",
},
{
prefix: "dist/qa-runtime-",
kind: "private QA runtime chunk",
},
{
prefix: "qa/",
kind: "private QA suite artifact",
},
] as const;
export function collectForbiddenPackedPathErrors(paths: Iterable<string>): string[] {
const errors: string[] = [];
for (const packedPath of paths) {
const matchedRule = FORBIDDEN_PACKED_PATH_RULES.find((rule) =>
packedPath.startsWith(rule.prefix),
);
if (matchedRule) {
errors.push(`npm package must not include ${matchedRule.kind} "${packedPath}".`);
}
}
return errors.toSorted((left, right) => left.localeCompare(right));
}