release: WRNexusJS 0.4.0
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { blockingVerificationChecks, updateApp, verificationCommands } from "../src/update.ts";
|
||||
@@ -226,3 +226,63 @@ test("update verification still blocks real doctor errors", () => {
|
||||
]),
|
||||
).toEqual([fatal]);
|
||||
});
|
||||
|
||||
test("0.4 migration removes manual CAPTCHA runtime wiring and archives copied assets", () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "wrnexus-update-"));
|
||||
mkdirSync(join(root, "app", "pages"), { recursive: true });
|
||||
mkdirSync(join(root, "public", "assets", "wrnexus"), { recursive: true });
|
||||
writeFileSync(
|
||||
join(root, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "captcha-app",
|
||||
scripts: { dev: "wrnexus dev ." },
|
||||
dependencies: { "@wrnexus/captcha": "^0.3.6" },
|
||||
wrnexus: { version: "0.3.6" },
|
||||
}),
|
||||
);
|
||||
writeFileSync(
|
||||
join(root, "app", "pages", "index.wrn"),
|
||||
`page Home {
|
||||
view {
|
||||
<Captcha type="number" action="login" />
|
||||
<script src="/assets/wrnexus/captcha.js" defer></script>
|
||||
}
|
||||
}`,
|
||||
);
|
||||
writeFileSync(
|
||||
join(root, "public", "assets", "wrnexus", "captcha.js"),
|
||||
"window.legacyCaptcha = true;\n",
|
||||
);
|
||||
|
||||
try {
|
||||
updateApp(root, "0.4.0", false);
|
||||
const page = readFileSync(join(root, "app", "pages", "index.wrn"), "utf8");
|
||||
const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
||||
expect(page).toContain("<Captcha");
|
||||
expect(page).not.toContain("captcha.js");
|
||||
expect(pkg.dependencies["@wrnexus/captcha"]).toBe("^0.4.0");
|
||||
expect(pkg.scripts["inspect:runtimes"]).toBe("wrnexus inspect runtimes .");
|
||||
expect(
|
||||
readFileSync(
|
||||
join(
|
||||
root,
|
||||
".wrnexus",
|
||||
"legacy-assets",
|
||||
"0.4.0",
|
||||
"public",
|
||||
"assets",
|
||||
"wrnexus",
|
||||
"captcha.js",
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
).toContain("legacyCaptcha");
|
||||
expect(existsSync(join(root, "public", "assets", "wrnexus", "captcha.js"))).toBe(false);
|
||||
const report = JSON.parse(
|
||||
readFileSync(join(root, ".wrnexus", "migrations", "0.4.0.json"), "utf8"),
|
||||
);
|
||||
expect(report.manualCaptchaRuntimeRequired).toBe(false);
|
||||
} finally {
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user