@fabricorg/fabric-gen 0.3.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fabricorg/fabric-gen",
3
- "version": "0.3.2",
4
- "description": "Thin CLI for deterministic Fabric manifest generator targets.",
3
+ "version": "0.6.0",
4
+ "description": "Fabric capability scaffolding, deterministic generation, and application composition checks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
@@ -27,22 +27,25 @@
27
27
  "CHANGELOG.md"
28
28
  ],
29
29
  "dependencies": {
30
- "@fabricorg/compiler": "^2.1.0",
31
- "@fabricorg/gen-capability": "^0.4.0",
32
- "@fabricorg/gen-conformance": "^0.2.0",
33
- "@fabricorg/gen-docs": "^0.2.3",
34
- "@fabricorg/gen-events": "^0.2.3",
35
- "@fabricorg/gen-graphql": "^3.0.0",
36
- "@fabricorg/gen-prisma": "^2.0.0",
37
- "@fabricorg/gen-sdui": "^0.5.0",
38
- "@fabricorg/gen-types": "^2.0.0"
30
+ "@fabricorg/assembly": "^0.4.0",
31
+ "@fabricorg/compiler": "^2.2.1",
32
+ "@fabricorg/gen-docs": "^0.2.4",
33
+ "@fabricorg/gen-capability": "^0.5.1",
34
+ "@fabricorg/gen-conformance": "^1.0.0",
35
+ "@fabricorg/gen-graphql": "^4.0.0",
36
+ "@fabricorg/gen-types": "^2.0.2",
37
+ "@fabricorg/sdui-release": "^0.5.0",
38
+ "@fabricorg/gen-events": "^0.2.4",
39
+ "@fabricorg/sdui-composer": "^0.2.0",
40
+ "@fabricorg/gen-sdui": "^0.5.2",
41
+ "@fabricorg/gen-prisma": "^2.0.2"
39
42
  },
40
43
  "devDependencies": {
41
44
  "@types/node": "^22.10.0",
42
45
  "tsup": "^8.5.0",
43
46
  "typescript": "^5.7.3",
44
47
  "vitest": "^4.1.5",
45
- "@fabricorg/platform": "^1.1.0"
48
+ "@fabricorg/platform": "^1.3.0"
46
49
  },
47
50
  "engines": {
48
51
  "node": ">=20"
@@ -1,74 +0,0 @@
1
- // index.ts
2
- import { mkdir, readFile, readdir, rm, writeFile } from "fs/promises";
3
- import path from "path";
4
- import { compileManifestBundle, runGenerator } from "@fabricorg/compiler";
5
- import { capabilityGenerator } from "@fabricorg/gen-capability";
6
- import { docsGenerator } from "@fabricorg/gen-docs";
7
- import { eventsGenerator } from "@fabricorg/gen-events";
8
- import { typesGenerator } from "@fabricorg/gen-types";
9
- import { prismaGenerator } from "@fabricorg/gen-prisma";
10
- import { graphqlGenerator } from "@fabricorg/gen-graphql";
11
- import { sduiGenerator } from "@fabricorg/gen-sdui";
12
- import { conformanceGenerator } from "@fabricorg/gen-conformance";
13
- var GENERATOR_TARGETS = {
14
- types: typesGenerator,
15
- events: eventsGenerator,
16
- capability: capabilityGenerator,
17
- docs: docsGenerator,
18
- prisma: prismaGenerator,
19
- graphql: graphqlGenerator,
20
- sdui: sduiGenerator,
21
- conformance: conformanceGenerator
22
- };
23
- var compareCanonicalStrings = (left, right) => left < right ? -1 : left > right ? 1 : 0;
24
- async function generateFromManifest(options) {
25
- const input = JSON.parse(await readFile(options.inputPath, "utf8"));
26
- if (!input || typeof input !== "object" || Array.isArray(input)) throw new Error("Manifest input must be a JSON object.");
27
- const bundle = "modules" in input ? input : { manifestVersion: input.manifestVersion, modules: [input] };
28
- const ir = compileManifestBundle(bundle);
29
- const files = (await Promise.all(options.targets.map(async (name) => {
30
- const target = GENERATOR_TARGETS[name];
31
- if (!target) throw new Error(`Unknown generator target "${name}".`);
32
- return (await runGenerator(target, ir)).map((file) => ({ ...file, path: `${name}/${file.path}` }));
33
- }))).flat().sort((left, right) => compareCanonicalStrings(left.path, right.path));
34
- const expected = new Set(files.map((file) => file.path));
35
- const existing = await listFiles(options.outputDirectory);
36
- const selectedPrefixes = options.targets.map((target) => `${target}/`);
37
- const stale = existing.filter((file) => selectedPrefixes.some((prefix) => file.startsWith(prefix)) && !expected.has(file));
38
- if (!options.check) await Promise.all(stale.map((file) => rm(path.join(options.outputDirectory, file), { force: true })));
39
- const changed = [];
40
- for (const file of files) {
41
- const target = path.join(options.outputDirectory, file.path);
42
- let current;
43
- try {
44
- current = await readFile(target, "utf8");
45
- } catch {
46
- current = void 0;
47
- }
48
- if (current !== file.content) {
49
- changed.push(file.path);
50
- if (!options.check) {
51
- await mkdir(path.dirname(target), { recursive: true });
52
- await writeFile(target, file.content, "utf8");
53
- }
54
- }
55
- }
56
- if (options.check && (changed.length || stale.length)) throw new Error(`Generated artifacts drifted: ${[...changed, ...stale.map((file) => `stale:${file}`)].join(", ")}`);
57
- return { changed, stale, files };
58
- }
59
- async function listFiles(directory, prefix = "") {
60
- let entries;
61
- try {
62
- entries = await readdir(directory, { withFileTypes: true });
63
- } catch {
64
- return [];
65
- }
66
- const nested = await Promise.all(entries.map((entry) => entry.isDirectory() ? listFiles(path.join(directory, entry.name), `${prefix}${entry.name}/`) : [`${prefix}${entry.name}`]));
67
- return nested.flat().sort();
68
- }
69
-
70
- export {
71
- GENERATOR_TARGETS,
72
- generateFromManifest
73
- };
74
- //# sourceMappingURL=chunk-QOD7G4YK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../index.ts"],"sourcesContent":["import { mkdir, readFile, readdir, rm, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { compileManifestBundle, runGenerator, type GeneratedFile, type GeneratorTarget } from \"@fabricorg/compiler\";\nimport { capabilityGenerator } from \"@fabricorg/gen-capability\";\nimport { docsGenerator } from \"@fabricorg/gen-docs\";\nimport { eventsGenerator } from \"@fabricorg/gen-events\";\nimport { typesGenerator } from \"@fabricorg/gen-types\";\nimport { prismaGenerator } from \"@fabricorg/gen-prisma\";\nimport { graphqlGenerator } from \"@fabricorg/gen-graphql\";\nimport { sduiGenerator } from \"@fabricorg/gen-sdui\";\nimport { conformanceGenerator } from \"@fabricorg/gen-conformance\";\n\nexport const GENERATOR_TARGETS: Record<string, GeneratorTarget> = {\n\ttypes: typesGenerator,\n\tevents: eventsGenerator,\n\tcapability: capabilityGenerator,\n\tdocs: docsGenerator,\n\tprisma: prismaGenerator,\n\tgraphql: graphqlGenerator,\n\tsdui: sduiGenerator,\n\tconformance: conformanceGenerator,\n};\nconst compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface GenerateOptions { inputPath: string; outputDirectory: string; targets: string[]; check?: boolean; }\nexport interface GenerateResult { changed: string[]; stale: string[]; files: GeneratedFile[]; }\n\nexport async function generateFromManifest(options: GenerateOptions): Promise<GenerateResult> {\n\tconst input = JSON.parse(await readFile(options.inputPath, \"utf8\"));\n\tif (!input || typeof input !== \"object\" || Array.isArray(input)) throw new Error(\"Manifest input must be a JSON object.\");\n\tconst bundle = \"modules\" in input ? input : { manifestVersion: input.manifestVersion, modules: [input] };\n\tconst ir = compileManifestBundle(bundle);\n\tconst files = (await Promise.all(options.targets.map(async (name) => {\n\t\tconst target = GENERATOR_TARGETS[name];\n\t\tif (!target) throw new Error(`Unknown generator target \"${name}\".`);\n\t\treturn (await runGenerator(target, ir)).map((file) => ({ ...file, path: `${name}/${file.path}` }));\n\t}))).flat().sort((left, right) => compareCanonicalStrings(left.path, right.path));\n\tconst expected = new Set(files.map((file) => file.path));\n\tconst existing = await listFiles(options.outputDirectory);\n\tconst selectedPrefixes = options.targets.map((target) => `${target}/`);\n\tconst stale = existing.filter((file) => selectedPrefixes.some((prefix) => file.startsWith(prefix)) && !expected.has(file));\n\tif (!options.check) await Promise.all(stale.map((file) => rm(path.join(options.outputDirectory, file), { force: true })));\n\tconst changed: string[] = [];\n\tfor (const file of files) {\n\t\tconst target = path.join(options.outputDirectory, file.path);\n\t\tlet current: string | undefined;\n\t\ttry { current = await readFile(target, \"utf8\"); } catch { current = undefined; }\n\t\tif (current !== file.content) {\n\t\t\tchanged.push(file.path);\n\t\t\tif (!options.check) { await mkdir(path.dirname(target), { recursive: true }); await writeFile(target, file.content, \"utf8\"); }\n\t\t}\n\t}\n\tif (options.check && (changed.length || stale.length)) throw new Error(`Generated artifacts drifted: ${[...changed, ...stale.map((file) => `stale:${file}`)].join(\", \")}`);\n\treturn { changed, stale, files };\n}\n\nasync function listFiles(directory: string, prefix = \"\"): Promise<string[]> {\n\tlet entries;\n\ttry { entries = await readdir(directory, { withFileTypes: true }); } catch { return []; }\n\tconst nested = await Promise.all(entries.map((entry) => entry.isDirectory() ? listFiles(path.join(directory, entry.name), `${prefix}${entry.name}/`) : [`${prefix}${entry.name}`]));\n\treturn nested.flat().sort();\n}\n"],"mappings":";AAAA,SAAS,OAAO,UAAU,SAAS,IAAI,iBAAiB;AACxD,OAAO,UAAU;AACjB,SAAS,uBAAuB,oBAA8D;AAC9F,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AAE9B,IAAM,oBAAqD;AAAA,EACjE,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,aAAa;AACd;AACA,IAAM,0BAA0B,CAAC,MAAc,UAA0B,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAKhH,eAAsB,qBAAqB,SAAmD;AAC7F,QAAM,QAAQ,KAAK,MAAM,MAAM,SAAS,QAAQ,WAAW,MAAM,CAAC;AAClE,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,OAAM,IAAI,MAAM,uCAAuC;AACxH,QAAM,SAAS,aAAa,QAAQ,QAAQ,EAAE,iBAAiB,MAAM,iBAAiB,SAAS,CAAC,KAAK,EAAE;AACvG,QAAM,KAAK,sBAAsB,MAAM;AACvC,QAAM,SAAS,MAAM,Q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