release: WRNexusJS 0.4.0

This commit is contained in:
2026-07-27 12:54:43 +05:30
parent 30e5721e84
commit 76c768099d
2 changed files with 29 additions and 17 deletions
+17 -3
View File
@@ -1,11 +1,22 @@
import { readdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { format, resolveConfig } from "prettier";
const uiRoot = join(import.meta.dirname, "..", "packages", "ui");
const componentsDir = join(uiRoot, "components");
const catalog = JSON.parse(readFileSync(join(uiRoot, "component-catalog.json"), "utf8"));
const metadata = new Map(catalog.components.map((entry) => [entry.name, entry]));
async function writeFormatted(path, source, parser) {
const config = (await resolveConfig(path)) ?? {};
const formatted = await format(source, {
...config,
filepath: path,
parser,
});
writeFileSync(path, formatted);
}
function block(source, keyword) {
const start = source.indexOf(`${keyword} {`);
if (start < 0) return "";
@@ -84,13 +95,15 @@ const components = readdirSync(componentsDir)
})
.sort((left, right) => left.name.localeCompare(right.name));
writeFileSync(
join(uiRoot, "component-reference.json"),
const referencePath = join(uiRoot, "component-reference.json");
await writeFormatted(
referencePath,
JSON.stringify(
{ generatedFrom: "packages/ui/components/*.wrn", count: components.length, components },
null,
2,
) + "\n",
"json",
);
const lines = [
@@ -123,4 +136,5 @@ for (const category of [...new Set(components.map((component) => component.categ
);
}
}
writeFileSync(join(uiRoot, "COMPONENTS.md"), `${lines.join("\n").trimEnd()}\n`);
const componentsPath = join(uiRoot, "COMPONENTS.md");
await writeFormatted(componentsPath, `${lines.join("\n").trimEnd()}\n`, "markdown");