build: remove private QA package compat shims

This commit is contained in:
Peter Steinberger
2026-04-27 00:25:54 +01:00
parent 09a635a28b
commit eccb79db99
19 changed files with 123 additions and 194 deletions

View File

@@ -5,8 +5,6 @@
import { spawnSync } from "node:child_process";
import fs from "node:fs";
const INVENTORY_COMPAT_MISSING_ENTRIES = new Set(["dist/extensions/qa-channel/runtime-api.js"]);
function usage() {
return "Usage: node scripts/check-openclaw-package-tarball.mjs <openclaw.tgz>";
}
@@ -77,9 +75,6 @@ if (entrySet.has("dist/postinstall-inventory.json")) {
} else {
for (const inventoryEntry of inventory) {
const normalizedEntry = inventoryEntry.replace(/\\/gu, "/");
if (INVENTORY_COMPAT_MISSING_ENTRIES.has(normalizedEntry)) {
continue;
}
if (!entrySet.has(normalizedEntry)) {
errors.push(`inventory references missing tar entry ${normalizedEntry}`);
}

View File

@@ -30,6 +30,16 @@ function readEntrypoints() {
return new Set(entrypoints.filter((entry) => entry !== "index"));
}
function readPrivateLocalOnlySubpaths() {
const subpaths = JSON.parse(
readFileSync(
path.join(repoRoot, "scripts/lib/plugin-sdk-private-local-only-subpaths.json"),
"utf8",
),
);
return new Set(subpaths.filter((entry) => typeof entry === "string" && !entry.includes("/")));
}
function parsePluginSdkSubpath(specifier) {
if (!specifier.startsWith("openclaw/plugin-sdk/")) {
return null;
@@ -51,6 +61,7 @@ function compareEntries(left, right) {
async function collectViolations() {
const entrypoints = readEntrypoints();
const exports = readPackageExports();
const privateLocalOnlySubpaths = readPrivateLocalOnlySubpaths();
const files = (await collectTypeScriptFilesFromRoots(scanRoots, { includeTests: true })).toSorted(
(left, right) =>
normalizeRepoPath(repoRoot, left).localeCompare(normalizeRepoPath(repoRoot, right)),
@@ -72,6 +83,9 @@ async function collectViolations() {
if (!subpath) {
return;
}
if (privateLocalOnlySubpaths.has(subpath)) {
return;
}
const missingFrom = [];
if (!entrypoints.has(subpath)) {

View File

@@ -246,8 +246,6 @@
"native-command-registry",
"nextcloud-talk",
"nostr",
"qa-channel",
"qa-channel-protocol",
"provider-auth",
"provider-auth-runtime",
"provider-auth-api-key",

View File

@@ -1 +1 @@
["qa-lab", "qa-runtime"]
["qa-channel", "qa-channel-protocol", "qa-lab", "qa-runtime"]

View File

@@ -74,6 +74,11 @@ const FORBIDDEN_PACKED_PATH_RULES = [
describe: (packedPath: string) =>
`npm package must not include generated docs artifact "${packedPath}".`,
},
{
prefix: "docs/channels/qa-channel.md",
describe: (packedPath: string) =>
`npm package must not include private QA channel docs "${packedPath}".`,
},
{
prefix: "dist/extensions/qa-channel/",
describe: (packedPath: string) =>
@@ -84,11 +89,26 @@ const FORBIDDEN_PACKED_PATH_RULES = [
describe: (packedPath: string) =>
`npm package must not include private QA lab artifact "${packedPath}".`,
},
{
prefix: "dist/plugin-sdk/extensions/qa-channel/",
describe: (packedPath: string) =>
`npm package must not include private QA channel type artifact "${packedPath}".`,
},
{
prefix: "dist/plugin-sdk/extensions/qa-lab/",
describe: (packedPath: string) =>
`npm package must not include private QA lab type artifact "${packedPath}".`,
},
{
prefix: "dist/plugin-sdk/qa-channel.",
describe: (packedPath: string) =>
`npm package must not include private QA channel SDK artifact "${packedPath}".`,
},
{
prefix: "dist/plugin-sdk/qa-channel-protocol.",
describe: (packedPath: string) =>
`npm package must not include private QA channel SDK artifact "${packedPath}".`,
},
{
prefix: "dist/qa-runtime-",
describe: (packedPath: string) =>
@@ -103,6 +123,8 @@ const FORBIDDEN_PACKED_PATH_RULES = [
const FORBIDDEN_PRIVATE_QA_CONTENT_MARKERS = [
"//#region extensions/qa-lab/",
"qa-channel/runtime-api.js",
"qa-channel.js",
"qa-channel-protocol.js",
"qa-lab/cli.js",
"qa-lab/runtime-api.js",
] as const;
@@ -559,9 +581,6 @@ export function collectForbiddenPackedContentErrors(
const textPathPattern = /\.(?:[cm]?js|d\.ts|json|md|mjs|cjs)$/u;
const errors: string[] = [];
for (const packedPath of paths) {
if (packedPath === PACKAGE_DIST_INVENTORY_RELATIVE_PATH) {
continue;
}
if (
!FORBIDDEN_PRIVATE_QA_CONTENT_SCAN_PREFIXES.some((prefix) => packedPath.startsWith(prefix))
) {

View File

@@ -11,7 +11,6 @@ import {
closeSync,
existsSync,
lstatSync,
mkdirSync,
openSync,
readdirSync,
readFileSync,
@@ -35,18 +34,6 @@ const DISABLE_POSTINSTALL_ENV = "OPENCLAW_DISABLE_BUNDLED_PLUGIN_POSTINSTALL";
const DISABLE_PLUGIN_REGISTRY_MIGRATION_ENV = "OPENCLAW_DISABLE_PLUGIN_REGISTRY_MIGRATION";
const EAGER_BUNDLED_PLUGIN_DEPS_ENV = "OPENCLAW_EAGER_BUNDLED_PLUGIN_DEPS";
const DIST_INVENTORY_PATH = "dist/postinstall-inventory.json";
const LEGACY_QA_CHANNEL_DIR = ["qa", "channel"].join("-");
const LEGACY_QA_LAB_DIR = ["qa", "lab"].join("-");
const LEGACY_UPDATE_COMPAT_SIDECARS = [
{
path: `dist/extensions/${LEGACY_QA_CHANNEL_DIR}/runtime-api.js`,
content: "export {};\n",
},
{
path: `dist/extensions/${LEGACY_QA_LAB_DIR}/runtime-api.js`,
content: "export {};\n",
},
];
const BAILEYS_MEDIA_FILE = join(
"node_modules",
"@whiskeysockets",
@@ -329,29 +316,6 @@ export function pruneInstalledPackageDist(params = {}) {
return removed;
}
export function restoreLegacyUpdaterCompatSidecars(params = {}) {
const packageRoot = params.packageRoot ?? DEFAULT_PACKAGE_ROOT;
const writeFile = params.writeFileSync ?? writeFileSync;
const makeDirectory = params.mkdirSync ?? mkdirSync;
const log = params.log ?? console;
const restored = [];
for (const sidecar of LEGACY_UPDATE_COMPAT_SIDECARS) {
// Older npm updater builds verify these exact sidecars after npm has
// already replaced the package, so generate them independently of prune
// results.
const sidecarPath = join(packageRoot, sidecar.path);
makeDirectory(dirname(sidecarPath), { recursive: true });
writeFile(sidecarPath, sidecar.content, "utf8");
restored.push(sidecar.path);
}
if (restored.length > 0) {
log.log(`[postinstall] restored legacy updater compat sidecars: ${restored.join(", ")}`);
}
return restored;
}
function dependencySentinelPath(depName) {
return join("node_modules", ...depName.split("/"), "package.json");
}
@@ -781,7 +745,7 @@ export function runBundledPluginPostinstall(params = {}) {
});
return;
}
const prunedDistFiles = pruneInstalledPackageDist({
pruneInstalledPackageDist({
packageRoot,
existsSync: pathExists,
readFileSync: params.readFileSync,
@@ -789,13 +753,6 @@ export function runBundledPluginPostinstall(params = {}) {
rmSync: params.rmSync,
log,
});
restoreLegacyUpdaterCompatSidecars({
packageRoot,
removedFiles: prunedDistFiles,
mkdirSync: params.mkdirSync,
writeFileSync: params.writeFileSync,
log,
});
if (
!shouldRunBundledPluginPostinstall({
env,

View File

@@ -79,19 +79,27 @@ const forbiddenPrefixes = [
"dist/OpenClaw.app/",
"dist/extensions/qa-channel/",
"dist/extensions/qa-lab/",
"dist/plugin-sdk/extensions/qa-channel/",
"dist/plugin-sdk/extensions/qa-lab/",
"dist/plugin-sdk/qa-channel.",
"dist/plugin-sdk/qa-channel-protocol.",
"dist/plugin-sdk/qa-lab.",
"dist/plugin-sdk/qa-runtime.",
"dist/plugin-sdk/src/plugin-sdk/qa-channel.d.ts",
"dist/plugin-sdk/src/plugin-sdk/qa-channel-protocol.d.ts",
"dist/plugin-sdk/src/plugin-sdk/qa-lab.d.ts",
"dist/plugin-sdk/src/plugin-sdk/qa-runtime.d.ts",
"dist/qa-runtime-",
"dist/plugin-sdk/.tsbuildinfo",
"docs/.generated/",
"docs/channels/qa-channel.md",
"qa/",
];
const forbiddenPrivateQaContentMarkers = [
"//#region extensions/qa-lab/",
"qa-channel/runtime-api.js",
"qa-channel.js",
"qa-channel-protocol.js",
"qa-lab/cli.js",
"qa-lab/runtime-api.js",
] as const;
@@ -602,9 +610,6 @@ export function collectForbiddenPackContentPaths(
const textPathPattern = /\.(?:[cm]?js|d\.ts|json|md|mjs|cjs)$/u;
return [...paths]
.filter((packedPath) => {
if (packedPath === PACKAGE_DIST_INVENTORY_RELATIVE_PATH) {
return false;
}
if (!forbiddenPrivateQaContentScanPrefixes.some((prefix) => packedPath.startsWith(prefix))) {
return false;
}

View File

@@ -1,10 +0,0 @@
#!/usr/bin/env -S node --import tsx
import fs from "node:fs";
import path from "node:path";
import { NPM_UPDATE_COMPAT_SIDECARS } from "../src/infra/npm-update-compat-sidecars.ts";
for (const entry of NPM_UPDATE_COMPAT_SIDECARS) {
fs.mkdirSync(path.dirname(entry.path), { recursive: true });
fs.writeFileSync(entry.path, entry.content, "utf8");
}