mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:00:42 +00:00
fix(plugins): restore missing native runtime deps
This commit is contained in:
@@ -227,6 +227,75 @@ describe("bundled plugin postinstall", () => {
|
||||
expect(spawnSync).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("reinstalls bundled runtime deps when optional native children are missing", async () => {
|
||||
const extensionsDir = await createExtensionsDir();
|
||||
const packageRoot = path.dirname(path.dirname(extensionsDir));
|
||||
await writePluginPackage(extensionsDir, "discord", {
|
||||
dependencies: {
|
||||
"@snazzah/davey": "0.1.11",
|
||||
},
|
||||
});
|
||||
await fs.mkdir(path.join(packageRoot, "node_modules", "@snazzah", "davey"), {
|
||||
recursive: true,
|
||||
});
|
||||
await fs.writeFile(
|
||||
path.join(packageRoot, "node_modules", "@snazzah", "davey", "package.json"),
|
||||
JSON.stringify({
|
||||
optionalDependencies: {
|
||||
"@snazzah/davey-win32-arm64-msvc": "0.1.11",
|
||||
},
|
||||
}),
|
||||
);
|
||||
const spawnSync = vi.fn(() => ({ status: 0, stderr: "", stdout: "" }));
|
||||
|
||||
runBundledPluginPostinstall({
|
||||
env: { HOME: "/tmp/home" },
|
||||
extensionsDir,
|
||||
packageRoot,
|
||||
arch: "arm64",
|
||||
npmRunner: createBareNpmRunner(["@snazzah/davey@0.1.11"]),
|
||||
platform: "win32",
|
||||
spawnSync,
|
||||
log: { log: vi.fn(), warn: vi.fn() },
|
||||
});
|
||||
|
||||
expectNpmInstallSpawn(spawnSync, packageRoot, ["@snazzah/davey@0.1.11"]);
|
||||
});
|
||||
|
||||
it("does not reinstall when only another platform optional native child is missing", async () => {
|
||||
const extensionsDir = await createExtensionsDir();
|
||||
const packageRoot = path.dirname(path.dirname(extensionsDir));
|
||||
await writePluginPackage(extensionsDir, "discord", {
|
||||
dependencies: {
|
||||
"@snazzah/davey": "0.1.11",
|
||||
},
|
||||
});
|
||||
await fs.mkdir(path.join(packageRoot, "node_modules", "@snazzah", "davey"), {
|
||||
recursive: true,
|
||||
});
|
||||
await fs.writeFile(
|
||||
path.join(packageRoot, "node_modules", "@snazzah", "davey", "package.json"),
|
||||
JSON.stringify({
|
||||
optionalDependencies: {
|
||||
"@snazzah/davey-win32-arm64-msvc": "0.1.11",
|
||||
},
|
||||
}),
|
||||
);
|
||||
const spawnSync = vi.fn();
|
||||
|
||||
runBundledPluginPostinstall({
|
||||
env: { HOME: "/tmp/home" },
|
||||
extensionsDir,
|
||||
packageRoot,
|
||||
arch: "arm64",
|
||||
platform: "darwin",
|
||||
spawnSync,
|
||||
log: { log: vi.fn(), warn: vi.fn() },
|
||||
});
|
||||
|
||||
expect(spawnSync).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("discovers bundled plugin runtime deps from extension manifests", async () => {
|
||||
const extensionsDir = await createExtensionsDir();
|
||||
await writePluginPackage(extensionsDir, "slack", {
|
||||
|
||||
Reference in New Issue
Block a user