release: WRNexusJS 0.4.0

This commit is contained in:
2026-07-27 12:42:18 +05:30
parent 8b728a3e5d
commit 30e5721e84
250 changed files with 10065 additions and 3923 deletions
+88 -4
View File
@@ -23,6 +23,7 @@ import {
mkdirSync,
readFileSync,
readdirSync,
rmSync,
statSync,
writeFileSync,
} from "node:fs";
@@ -971,7 +972,7 @@ const MIGRATIONS: Migration[] = [
},
{
version: "0.3.3",
id: "component-fix",
id: "component-fix-0-3-3",
description: "UI component fixes.",
apply() {
// Compiler-only fix. Existing WRN source files require no migration.
@@ -979,7 +980,7 @@ const MIGRATIONS: Migration[] = [
},
{
version: "0.3.4",
id: "component-fix",
id: "component-fix-0-3-4",
description: "UI component fixes.",
apply() {
// Compiler-only fix. Existing WRN source files require no migration.
@@ -987,7 +988,7 @@ const MIGRATIONS: Migration[] = [
},
{
version: "0.3.5",
id: "new-component-added",
id: "new-component-added-0-3-5",
description: "UI component Added.",
apply() {
// Compiler-only fix. Existing WRN source files require no migration.
@@ -995,12 +996,95 @@ const MIGRATIONS: Migration[] = [
},
{
version: "0.3.6",
id: "new-component-added",
id: "new-component-added-0-3-6",
description: "UI component Added.",
apply() {
// Compiler-only fix. Existing WRN source files require no migration.
},
},
{
version: "0.4.0",
id: "package-runtime-and-asset-platform",
description:
"Enables automatic package discovery, package components/routes/migrations, and page-scoped client runtime injection without manually copied JavaScript assets.",
apply(ctx) {
const packageFile = join(ctx.appRoot, "package.json");
const pkg = JSON.parse(readFileSync(packageFile, "utf8")) as Record<string, any>;
const scripts = (pkg.scripts ??= {});
const additions: Record<string, string> = {
"inspect:plugins": "wrnexus inspect plugins .",
"inspect:runtimes": "wrnexus inspect runtimes .",
"inspect:assets": "wrnexus inspect assets .",
"inspect:routes": "wrnexus inspect routes .",
};
const addedScripts: string[] = [];
for (const [name, command] of Object.entries(additions)) {
if (!scripts[name]) {
scripts[name] = command;
addedScripts.push(name);
}
}
if (addedScripts.length) ctx.log(`+ package scripts: ${addedScripts.join(", ")}`);
if (!ctx.dryRun && addedScripts.length) {
writeFileSync(packageFile, JSON.stringify(pkg, null, 2) + "\n", "utf8");
}
const changedFiles: string[] = [];
const legacyCaptchaScript =
/\s*<script\b[^>]*\bsrc\s*=\s*["']\/(?:__wrnexus\/captcha|assets\/wrnexus\/captcha)\.js(?:\?[^"']*)?["'][^>]*>(?:\s*<\/script>)?\s*/gi;
for (const file of walkProjectFiles(join(ctx.appRoot, "app"), ".wrn")) {
const before = readFileSync(file, "utf8");
const after = before.replace(legacyCaptchaScript, "\n");
if (after === before) continue;
const relativeFile = file.slice(ctx.appRoot.length + 1).replace(/\\/g, "/");
changedFiles.push(relativeFile);
ctx.log(`~ removed legacy CAPTCHA script tag from ${relativeFile}`);
if (!ctx.dryRun) writeFileSync(file, after, "utf8");
}
const movedAssets: string[] = [];
for (const relativeFile of [
"public/assets/wrnexus/captcha.js",
"public/__wrnexus/captcha.js",
]) {
const source = join(ctx.appRoot, relativeFile);
if (!existsSync(source)) continue;
const destination = join(ctx.appRoot, ".wrnexus", "legacy-assets", "0.4.0", relativeFile);
movedAssets.push(relativeFile);
ctx.log(`~ archived legacy ${relativeFile}`);
if (!ctx.dryRun) {
mkdirSync(dirname(destination), { recursive: true });
cpSync(source, destination);
rmSync(source, { force: true });
}
}
const reportFile = join(ctx.appRoot, ".wrnexus", "migrations", "0.4.0.json");
ctx.log(
`+ .wrnexus/migrations/0.4.0.json (${changedFiles.length} source files, ${movedAssets.length} legacy assets)`,
);
if (!ctx.dryRun) {
mkdirSync(dirname(reportFile), { recursive: true });
writeFileSync(
reportFile,
JSON.stringify(
{
version: "0.4.0",
from: ctx.from,
appliedAt: new Date().toISOString(),
changedFiles,
movedAssets,
packageRuntimeDiscovery: true,
manualCaptchaRuntimeRequired: false,
},
null,
2,
) + "\n",
"utf8",
);
}
},
},
];
/** Release tooling uses this to require an explicit migration entry per version. */