release: WRNexusJS 0.4.0
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user