fix(custom-widgets): harden v2 authoring
This commit is contained in:
171 files changed
+20311
-50527
No files matched your search
@@ -1,20 +1,20 @@
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
import { customJsxComponentRegistry } from "../src/core/component-registry";
|
||||
import type { CustomJsxAuthoringCatalog } from "../src/core/component-catalog-types";
|
||||
import { renderCustomWidgetComponentReferences } from "./component-docs";
|
||||
|
||||
const output = customJsxComponentRegistry.map(
|
||||
({ name, package: packageName, category, safety, reason, documentationUrl }) => ({
|
||||
name,
|
||||
package: packageName,
|
||||
category,
|
||||
safety,
|
||||
reason,
|
||||
documentationUrl,
|
||||
}),
|
||||
);
|
||||
const packageRoot = resolve(import.meta.dirname, "..");
|
||||
const sourcePath = resolve(packageRoot, "src/core/component-catalog.generated.json");
|
||||
const publicDirectory = resolve(packageRoot, "../../apps/docs/static/custom-widgets");
|
||||
const publicPath = resolve(publicDirectory, "component-catalog-v1.json");
|
||||
const skillReferenceDirectory = resolve(packageRoot, "../../.agents/skills/homarr-custom-widget/references");
|
||||
const contents = await readFile(sourcePath, "utf8");
|
||||
const catalog = JSON.parse(contents) as CustomJsxAuthoringCatalog;
|
||||
const references = renderCustomWidgetComponentReferences(catalog);
|
||||
|
||||
await writeFile(
|
||||
resolve(import.meta.dirname, "../../../apps/docs/src/generated/custom-jsx-components.json"),
|
||||
`${JSON.stringify(output, null, 2)}\n`,
|
||||
);
|
||||
await Promise.all([mkdir(publicDirectory, { recursive: true }), mkdir(skillReferenceDirectory, { recursive: true })]);
|
||||
await Promise.all([
|
||||
writeFile(publicPath, contents),
|
||||
...Object.entries(references).map(([path, content]) => writeFile(resolve(skillReferenceDirectory, path), content)),
|
||||
]);
|
||||
Reference in new issue
Block a user