release: WRNexusJS 0.3.0

This commit is contained in:
2026-07-22 17:29:08 +05:30
parent 13dfa31d19
commit 07d8fb59d6
145 changed files with 9664 additions and 3881 deletions
+56
View File
@@ -0,0 +1,56 @@
import { existsSync, readFileSync } from "node:fs";
import { join, resolve } from "node:path";
interface BuildReport {
frameworkVersion: string;
generatedAt: string;
adapter: string;
routes: Array<{ path: string; source: string; sourceBytes: number; dynamicParams: string[] }>;
assets: Array<{ file: string; bytes: number }>;
measurements: Record<string, number>;
budgetViolations: Array<{ metric: string; budget: number; actual: number; overBy: number }>;
}
function bytes(value: number): string {
if (value < 1024) return `${value} B`;
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`;
return `${(value / 1024 / 1024).toFixed(2)} MB`;
}
export function runAnalyze(appRoot: string, args: string[]): boolean {
const root = resolve(appRoot);
const path = join(root, "dist", "build-report.json");
if (!existsSync(path)) {
console.error("WRN-BUILD-REPORT-MISSING: run `wrnexus build` before `wrnexus analyze`.");
return false;
}
const report = JSON.parse(readFileSync(path, "utf8")) as BuildReport;
if (args.includes("--json")) {
console.log(JSON.stringify(report, null, 2));
return report.budgetViolations.length === 0;
}
console.log(`WRNexus build analysis (${report.frameworkVersion})`);
console.log(` Generated: ${report.generatedAt}`);
console.log(` Adapter: ${report.adapter}`);
console.log(` Routes: ${report.routes.length}`);
console.log("\nMeasurements:");
for (const [metric, value] of Object.entries(report.measurements)) {
console.log(` ${metric.padEnd(18)} ${bytes(value)}`);
}
console.log("\nLargest assets:");
for (const asset of report.assets.slice(0, 12)) {
console.log(` ${bytes(asset.bytes).padStart(10)} ${asset.file}`);
}
if (report.budgetViolations.length) {
console.log("\nBudget violations:");
for (const violation of report.budgetViolations) {
console.log(
`${violation.metric}: ${bytes(violation.actual)} > ${bytes(violation.budget)}`,
);
}
} else {
console.log("\n ✓ No configured performance budget violations.");
}
return report.budgetViolations.length === 0;
}