Skip to content

Commit cd775c7

Browse files
committed
perf(release): reuse bundled plugin package inventory
1 parent 4f0dcd4 commit cd775c7

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

‎scripts/openclaw-npm-postpublish-verify.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ type InstalledBundledExtensionManifestRecord = {
6060
const MAX_BUNDLED_EXTENSION_MANIFEST_BYTES = 1024 * 1024;
6161
const LEGACY_CONTEXT_ENGINE_UNRESOLVED_RUNTIME_MARKER =
6262
"Failed to load legacy context engine runtime.";
63+
const PACKAGED_BUNDLED_PLUGIN_ARTIFACTS = new Set(listBundledPluginPackArtifacts());
6364
const PUBLISHED_BUNDLED_RUNTIME_SIDECAR_PATHS = BUNDLED_RUNTIME_SIDECAR_PATHS.filter(
64-
(relativePath) => listBundledPluginPackArtifacts().includes(relativePath),
65+
(relativePath) => PACKAGED_BUNDLED_PLUGIN_ARTIFACTS.has(relativePath),
6566
);
6667
const NODE_BUILTIN_MODULES = new Set(builtinModules.map((name) => name.replace(/^node:/u, "")));
6768
const MAX_INSTALLED_ROOT_PACKAGE_JSON_BYTES = 1024 * 1024;
@@ -946,7 +947,7 @@ export function resolveInstalledBinaryCommandInvocation(
946947

947948
function collectExpectedBundledExtensionPackageIds(): ReadonlySet<string> {
948949
const ids = new Set<string>();
949-
for (const relativePath of listBundledPluginPackArtifacts()) {
950+
for (const relativePath of PACKAGED_BUNDLED_PLUGIN_ARTIFACTS) {
950951
const match = /^dist\/extensions\/([^/]+)\/package\.json$/u.exec(relativePath);
951952
if (match) {
952953
ids.add(expectDefined(match[1], "bundled package extension id"));

‎test/openclaw-npm-postpublish-verify.test.ts‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ import {
2525
verifyNpmProvenanceAttestation,
2626
verifyNpmRegistrySignatures,
2727
} from "../scripts/openclaw-npm-postpublish-verify.ts";
28+
import { withEnv } from "../src/test-utils/env.js";
2829

2930
const INSTALLED_ROOT_DIST_JS_FILE_SCAN_LIMIT = 10_000;
31+
const requiredBundledPluginPackPaths = listBundledPluginPackArtifacts();
3032

3133
describe("parseOpenClawNpmPostpublishVerifyArgs", () => {
3234
it("keeps trusted release verification independent from target app dependencies", () => {
@@ -571,7 +573,7 @@ describe("collectInstalledPackageErrors", () => {
571573
omittedIds: readonly string[] = [],
572574
): void {
573575
const omitted = new Set(omittedIds);
574-
for (const relativePath of listBundledPluginPackArtifacts()) {
576+
for (const relativePath of requiredBundledPluginPackPaths) {
575577
const match = /^dist\/extensions\/([^/]+)\/package\.json$/u.exec(relativePath);
576578
if (!match || omitted.has(match[1] ?? "")) {
577579
continue;
@@ -656,6 +658,35 @@ describe("collectInstalledPackageErrors", () => {
656658
}
657659
});
658660

661+
it("keeps bundled manifest requirements stable after the build filter changes", () => {
662+
const packageRoot = makeInstalledPackageRoot();
663+
664+
try {
665+
const expectedErrors = collectInstalledBundledExtensionManifestErrors(packageRoot);
666+
const filteredErrors = withEnv({ OPENCLAW_BUNDLED_PLUGIN_BUILD_IDS: "ollama" }, () =>
667+
collectInstalledBundledExtensionManifestErrors(packageRoot),
668+
);
669+
670+
expect(filteredErrors).toStrictEqual(expectedErrors);
671+
expect(filteredErrors).toEqual(
672+
expect.arrayContaining(
673+
["ollama", "lmstudio"].map(
674+
(providerId) =>
675+
`installed bundled extension manifest missing: ${join(
676+
packageRoot,
677+
"dist",
678+
"extensions",
679+
providerId,
680+
"package.json",
681+
)}.`,
682+
),
683+
),
684+
);
685+
} finally {
686+
rmSync(packageRoot, { recursive: true, force: true });
687+
}
688+
});
689+
659690
it("does not require excluded external or private plugin package manifests", () => {
660691
const packageRoot = makeInstalledPackageRoot();
661692

0 commit comments

Comments
 (0)