mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-25 23:47:20 +00:00
fix(runtime): stabilize image generation auth/runtime loading
This commit is contained in:
@@ -2,7 +2,10 @@ import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { copyStaticExtensionAssets } from "../../scripts/runtime-postbuild.mjs";
|
||||
import {
|
||||
copyStaticExtensionAssets,
|
||||
writeStableRootRuntimeAliases,
|
||||
} from "../../scripts/runtime-postbuild.mjs";
|
||||
|
||||
const cleanupDirs: string[] = [];
|
||||
|
||||
@@ -50,4 +53,35 @@ describe("runtime postbuild static assets", () => {
|
||||
"[runtime-postbuild] static asset not found, skipping: missing/file.mjs",
|
||||
);
|
||||
});
|
||||
|
||||
it("writes stable aliases for hashed root runtime modules", async () => {
|
||||
const rootDir = await createTempRoot();
|
||||
const distDir = path.join(rootDir, "dist");
|
||||
await fs.mkdir(distDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "runtime-model-auth.runtime-XyZ987.js"),
|
||||
"export const auth = true;\n",
|
||||
"utf8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "runtime-tts.runtime-AbCd1234.js"),
|
||||
"export const tts = true;\n",
|
||||
"utf8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "library-Other123.js"),
|
||||
"export const x = true;\n",
|
||||
"utf8",
|
||||
);
|
||||
|
||||
writeStableRootRuntimeAliases({ rootDir });
|
||||
|
||||
expect(await fs.readFile(path.join(distDir, "runtime-model-auth.runtime.js"), "utf8")).toBe(
|
||||
'export * from "./runtime-model-auth.runtime-XyZ987.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "runtime-tts.runtime.js"), "utf8")).toBe(
|
||||
'export * from "./runtime-tts.runtime-AbCd1234.js";\n',
|
||||
);
|
||||
await expect(fs.stat(path.join(distDir, "library.js"))).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user