mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:30:43 +00:00
fix(update): keep plugin install runtime aliases stable
This commit is contained in:
committed by
Peter Steinberger
parent
b63336186a
commit
112924b113
@@ -145,6 +145,34 @@ describe("runtime postbuild static assets", () => {
|
||||
await expect(fs.stat(path.join(distDir, "install.runtime.js"))).rejects.toThrow();
|
||||
});
|
||||
|
||||
it("writes a stable plugin install runtime alias when install runtimes collide", async () => {
|
||||
const rootDir = createTempDir("openclaw-runtime-postbuild-");
|
||||
const distDir = path.join(rootDir, "dist");
|
||||
await fs.mkdir(distDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "install.runtime-Aaa111.js"),
|
||||
[
|
||||
"export const scanPackageInstallSource = true;",
|
||||
"export const scanFileInstallSource = true;",
|
||||
"export const scanInstalledPackageDependencyTree = true;",
|
||||
"export const scanBundleInstallSource = true;",
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "install.runtime-Bbb222.js"),
|
||||
"export const daemonInstall = true;\n",
|
||||
"utf8",
|
||||
);
|
||||
|
||||
writeStableRootRuntimeAliases({ rootDir });
|
||||
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-Aaa111.js";\n',
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps stable aliases when one colliding root runtime chunk re-exports the implementation", async () => {
|
||||
const rootDir = createTempDir("openclaw-runtime-postbuild-");
|
||||
const distDir = path.join(rootDir, "dist");
|
||||
@@ -294,6 +322,47 @@ describe("runtime postbuild static assets", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("rewrites plugin install runtime imports to stable aliases when install runtimes collide", async () => {
|
||||
const rootDir = createTempDir("openclaw-runtime-postbuild-");
|
||||
const distDir = path.join(rootDir, "dist");
|
||||
await fs.mkdir(distDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "install.runtime-Aaa111.js"),
|
||||
[
|
||||
"export const scanPackageInstallSource = true;",
|
||||
"export const scanFileInstallSource = true;",
|
||||
"export const scanInstalledPackageDependencyTree = true;",
|
||||
"export const scanBundleInstallSource = true;",
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "install.runtime-Bbb222.js"),
|
||||
"export const daemonInstall = true;\n",
|
||||
"utf8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "install-OldHash.js"),
|
||||
[
|
||||
'const pluginRuntime = () => import("./install.runtime-Aaa111.js");',
|
||||
'const daemonRuntime = () => import("./install.runtime-Bbb222.js");',
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
rewriteRootRuntimeImportsToStableAliases({ rootDir });
|
||||
|
||||
expect(await fs.readFile(path.join(distDir, "install-OldHash.js"), "utf8")).toBe(
|
||||
[
|
||||
'const pluginRuntime = () => import("./install.runtime.js");',
|
||||
'const daemonRuntime = () => import("./install.runtime-Bbb222.js");',
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
});
|
||||
|
||||
it("leaves stable alias files pointing at their hashed runtime chunks", async () => {
|
||||
const rootDir = createTempDir("openclaw-runtime-postbuild-");
|
||||
const distDir = path.join(rootDir, "dist");
|
||||
@@ -330,6 +399,22 @@ describe("runtime postbuild static assets", () => {
|
||||
'export * from "./provider-dispatcher.runtime-NewHash.js";\n',
|
||||
"utf8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "install.runtime-NewPluginHash.js"),
|
||||
[
|
||||
"export const scanPackageInstallSource = true;",
|
||||
"export const scanFileInstallSource = true;",
|
||||
"export const scanInstalledPackageDependencyTree = true;",
|
||||
"export const scanBundleInstallSource = true;",
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "install.runtime-OtherHash.js"),
|
||||
"export const installFromValidatedNpmSpecArchive = true;\n",
|
||||
"utf8",
|
||||
);
|
||||
|
||||
writeLegacyRootRuntimeCompatAliases({ rootDir });
|
||||
|
||||
@@ -342,6 +427,33 @@ describe("runtime postbuild static assets", () => {
|
||||
expect(await fs.readFile(path.join(distDir, "provider-dispatcher-6EQEtc-t.js"), "utf8")).toBe(
|
||||
'export * from "./provider-dispatcher.runtime.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime-D7SL02B2.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-NewPluginHash.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime-Deq6Beal.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-NewPluginHash.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime-BRVACueI.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-NewPluginHash.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime-DX8jy7tN.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-NewPluginHash.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime-D6FSd9v2.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-NewPluginHash.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime-DQ-ui3nL.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-NewPluginHash.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime-Xom5hOHq.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-NewPluginHash.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime-tnhNR9WW.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-NewPluginHash.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "install.runtime-CNHwKOIb.js"), "utf8")).toBe(
|
||||
'export * from "./install.runtime-NewPluginHash.js";\n',
|
||||
);
|
||||
});
|
||||
|
||||
it("writes compatibility aliases for previous gateway shutdown chunk names", async () => {
|
||||
|
||||
Reference in New Issue
Block a user