mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 06:31:11 +00:00
fix(release): preserve plugin-local runtime deps in postpublish verify
This commit is contained in:
parent
5b0ee04c0d
commit
f191dd3d53
2 changed files with 94 additions and 1 deletions
|
|
@ -283,6 +283,8 @@ export function collectInstalledRootDependencyManifestErrors(packageRoot: string
|
|||
];
|
||||
}
|
||||
const missingImporters = new Map<string, Set<string>>();
|
||||
const bundledExtensionRuntimeDependencyOwners =
|
||||
collectBundledExtensionRuntimeDependencyOwners(packageRoot);
|
||||
|
||||
for (const filePath of distFiles) {
|
||||
const fileStat = lstatSync(filePath);
|
||||
|
|
@ -305,7 +307,12 @@ export function collectInstalledRootDependencyManifestErrors(packageRoot: string
|
|||
if (
|
||||
!dependencyName ||
|
||||
NODE_BUILTIN_MODULES.has(dependencyName) ||
|
||||
declaredRuntimeDeps.has(dependencyName)
|
||||
declaredRuntimeDeps.has(dependencyName) ||
|
||||
isBundledExtensionOwnedRuntimeImport({
|
||||
dependencyName,
|
||||
ownersByDependency: bundledExtensionRuntimeDependencyOwners,
|
||||
source,
|
||||
})
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -323,6 +330,35 @@ export function collectInstalledRootDependencyManifestErrors(packageRoot: string
|
|||
.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
function collectBundledExtensionRuntimeDependencyOwners(
|
||||
packageRoot: string,
|
||||
): Map<string, Set<string>> {
|
||||
const ownersByDependency = new Map<string, Set<string>>();
|
||||
const { manifests } = readBundledExtensionPackageJsons(packageRoot);
|
||||
for (const { id, manifest } of manifests) {
|
||||
for (const dependencyName of collectRuntimeDependencySpecs(manifest).keys()) {
|
||||
const owners = ownersByDependency.get(dependencyName) ?? new Set<string>();
|
||||
owners.add(id);
|
||||
ownersByDependency.set(dependencyName, owners);
|
||||
}
|
||||
}
|
||||
return ownersByDependency;
|
||||
}
|
||||
|
||||
function isBundledExtensionOwnedRuntimeImport(params: {
|
||||
dependencyName: string;
|
||||
ownersByDependency: Map<string, Set<string>>;
|
||||
source: string;
|
||||
}): boolean {
|
||||
const owners = params.ownersByDependency.get(params.dependencyName);
|
||||
if (!owners) {
|
||||
return false;
|
||||
}
|
||||
return [...owners].some((pluginId) =>
|
||||
params.source.includes(`//#region extensions/${pluginId}/`),
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveInstalledBinaryPath(prefixDir: string, platform = process.platform): string {
|
||||
return platform === "win32"
|
||||
? join(prefixDir, "openclaw.cmd")
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { describe, expect, it } from "vitest";
|
|||
import { listBundledPluginPackArtifacts } from "../scripts/lib/bundled-plugin-build-entries.mjs";
|
||||
import { listPluginSdkDistArtifacts } from "../scripts/lib/plugin-sdk-entries.mjs";
|
||||
import { WORKSPACE_TEMPLATE_PACK_PATHS } from "../scripts/lib/workspace-bootstrap-smoke.mjs";
|
||||
import { collectInstalledRootDependencyManifestErrors } from "../scripts/openclaw-npm-postpublish-verify.ts";
|
||||
import {
|
||||
collectAppcastSparkleVersionErrors,
|
||||
collectBundledExtensionManifestErrors,
|
||||
|
|
@ -277,6 +278,62 @@ describe("bundled plugin root runtime mirrors", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("does not require root deps for root chunks sourced from the owning installed plugin", () => {
|
||||
const tempRoot = mkdtempSync(join(tmpdir(), "openclaw-root-owned-installed-"));
|
||||
|
||||
try {
|
||||
mkdirSync(join(tempRoot, "dist", "extensions", "memory-lancedb"), { recursive: true });
|
||||
writeFileSync(
|
||||
join(tempRoot, "package.json"),
|
||||
`{"name":"openclaw","dependencies":{}}\n`,
|
||||
"utf8",
|
||||
);
|
||||
writeFileSync(
|
||||
join(tempRoot, "dist", "extensions", "memory-lancedb", "package.json"),
|
||||
`{"name":"@openclaw/memory-lancedb","dependencies":{"@lancedb/lancedb":"^0.27.2"}}\n`,
|
||||
"utf8",
|
||||
);
|
||||
writeFileSync(
|
||||
join(tempRoot, "dist", "lancedb-runtime-7TYK-Pto.js"),
|
||||
`//#region extensions/memory-lancedb/lancedb-runtime.ts\nimport("@lancedb/lancedb");\n`,
|
||||
"utf8",
|
||||
);
|
||||
|
||||
expect(collectInstalledRootDependencyManifestErrors(tempRoot)).toEqual([]);
|
||||
} finally {
|
||||
rmSync(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("still requires root deps for root-owned installed chunks", () => {
|
||||
const tempRoot = mkdtempSync(join(tmpdir(), "openclaw-root-owned-installed-missing-"));
|
||||
|
||||
try {
|
||||
mkdirSync(join(tempRoot, "dist", "extensions", "memory-lancedb"), { recursive: true });
|
||||
writeFileSync(
|
||||
join(tempRoot, "package.json"),
|
||||
`{"name":"openclaw","dependencies":{}}\n`,
|
||||
"utf8",
|
||||
);
|
||||
writeFileSync(
|
||||
join(tempRoot, "dist", "extensions", "memory-lancedb", "package.json"),
|
||||
`{"name":"@openclaw/memory-lancedb","dependencies":{"@lancedb/lancedb":"^0.27.2"}}\n`,
|
||||
"utf8",
|
||||
);
|
||||
writeFileSync(
|
||||
join(tempRoot, "dist", "root-runtime.js"),
|
||||
`import("@lancedb/lancedb");\n`,
|
||||
"utf8",
|
||||
);
|
||||
|
||||
expect(collectInstalledRootDependencyManifestErrors(tempRoot)).toEqual([
|
||||
"installed package root is missing declared runtime dependency '@lancedb/lancedb' for dist importers: root-runtime.js. Add it to package.json dependencies/optionalDependencies.",
|
||||
]);
|
||||
} finally {
|
||||
rmSync(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("does not compare root mirror versions for plugin manifest deps", () => {
|
||||
expect(
|
||||
collectBundledPluginRootRuntimeMirrorErrors({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue