release: WRNexusJS 0.8.0
This commit is contained in:
@@ -286,3 +286,56 @@ test("0.4 migration removes manual CAPTCHA runtime wiring and archives copied as
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("0.8 migration modernizes every WRN source with imports and a review report", () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "wrnexus-update-current-source-"));
|
||||
mkdirSync(join(root, "app", "components"), { recursive: true });
|
||||
mkdirSync(join(root, "app", "layouts"), { recursive: true });
|
||||
mkdirSync(join(root, "app", "pages"), { recursive: true });
|
||||
writeFileSync(
|
||||
join(root, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "source-app",
|
||||
dependencies: { "@wrnexus/core": "^0.7.0" },
|
||||
wrnexus: { version: "0.7.0" },
|
||||
}),
|
||||
);
|
||||
writeFileSync(
|
||||
join(root, "app", "components", "Notice.wrn"),
|
||||
'component Notice {\r\n props { label = "Ready" count = 1 } \r\n view { <p>{label}</p> }\r\n}',
|
||||
);
|
||||
writeFileSync(
|
||||
join(root, "app", "layouts", "shell.wrn"),
|
||||
"layout Shell {\n view { <main><slot /></main> }\n}\n",
|
||||
);
|
||||
writeFileSync(
|
||||
join(root, "app", "pages", "index.wrn"),
|
||||
'page Home {\n layout = "shell"\n view { <Notice label={"Updated"} /> <Missing /> }\n}\n',
|
||||
);
|
||||
|
||||
try {
|
||||
updateApp(root, "0.8.0", false);
|
||||
const first = readFileSync(join(root, "app", "pages", "index.wrn"), "utf8");
|
||||
expect(first).toContain('import Notice from "@/components/Notice.wrn"');
|
||||
expect(first).toContain('import Shell from "@/layouts/shell.wrn"');
|
||||
expect(first).toContain("layout = Shell");
|
||||
expect(first).toContain("label='{\"Updated\"}'");
|
||||
expect(first.endsWith("\n")).toBe(true);
|
||||
|
||||
const component = readFileSync(join(root, "app", "components", "Notice.wrn"), "utf8");
|
||||
expect(component).toContain('props {\n label = "Ready"\n count = 1\n }');
|
||||
expect(component).not.toContain("\r");
|
||||
|
||||
const reportPath = join(root, ".wrnexus", "migrations", "0.8.0-source-modernization.json");
|
||||
const report = JSON.parse(readFileSync(reportPath, "utf8"));
|
||||
expect(report.changedFiles).toContain("app/pages/index.wrn");
|
||||
expect(report.unresolvedImports).toContain(
|
||||
"app/pages/index.wrn: component 'Missing' could not be resolved",
|
||||
);
|
||||
|
||||
updateApp(root, "0.8.0", false);
|
||||
expect(readFileSync(join(root, "app", "pages", "index.wrn"), "utf8")).toBe(first);
|
||||
} finally {
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user