@decocms/blocks-cli 7.16.8 → 7.17.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 +2 -2
- package/scripts/generate-schema.ts +41 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/blocks-cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.17.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Deco codegen (generate-blocks, generate-schema, generate-invoke) and Fresh-to-TanStack migration tooling",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"lint:unused": "knip"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@decocms/blocks": "7.
|
|
33
|
+
"@decocms/blocks": "7.17.0",
|
|
34
34
|
"ts-morph": "^27.0.0",
|
|
35
35
|
"tsx": "^4.22.5"
|
|
36
36
|
},
|
|
@@ -27,6 +27,12 @@ import { fileURLToPath } from "node:url";
|
|
|
27
27
|
* --skip-apps Skip app schema generation
|
|
28
28
|
* --out Output file (default: ".deco/meta.gen.json")
|
|
29
29
|
* --platform Platform name (default: "cloudflare")
|
|
30
|
+
* --compose Run composeMeta() before writing so the output is
|
|
31
|
+
* SELF-CONTAINED (bakes in Page, matchers, __SECTION_REF__,
|
|
32
|
+
* Resolvable). For consumers that read meta.gen.json straight
|
|
33
|
+
* from disk with no runtime (FS-based Studio / Eitri stack).
|
|
34
|
+
* --framework With --compose, the value written to the `framework` field
|
|
35
|
+
* (default: "tanstack-start").
|
|
30
36
|
*
|
|
31
37
|
* If no `--out` is passed and the OLD default (src/server/admin/meta.gen.json)
|
|
32
38
|
* still exists on disk, a one-line legacy warning is printed to stderr and the
|
|
@@ -75,6 +81,15 @@ let APPS_REL = "src/apps";
|
|
|
75
81
|
let SKIP_APPS = false;
|
|
76
82
|
let OUT_REL = NEW_DEFAULT_OUT_REL;
|
|
77
83
|
let PLATFORM = "cloudflare";
|
|
84
|
+
// When true, run composeMeta() over the generated site meta before writing, so
|
|
85
|
+
// the output file is SELF-CONTAINED — it carries the framework block types
|
|
86
|
+
// (Page, matchers, __SECTION_REF__, Resolvable) that composeMeta otherwise
|
|
87
|
+
// injects at runtime. Required by consumers that read meta.gen.json straight
|
|
88
|
+
// from the filesystem with no runtime (e.g. the FS-based Studio / Eitri stack).
|
|
89
|
+
let COMPOSE = false;
|
|
90
|
+
// Value written to the composed meta's `framework` field (only used with
|
|
91
|
+
// --compose). Defaults to composeMeta's historical "tanstack-start".
|
|
92
|
+
let FRAMEWORK = "tanstack-start";
|
|
78
93
|
|
|
79
94
|
if (isMainModule()) {
|
|
80
95
|
SITE_NAMESPACE = arg("namespace", SITE_NAMESPACE);
|
|
@@ -87,6 +102,8 @@ if (isMainModule()) {
|
|
|
87
102
|
const outFileExplicit = argv.includes("--out");
|
|
88
103
|
OUT_REL = arg("out", NEW_DEFAULT_OUT_REL);
|
|
89
104
|
PLATFORM = arg("platform", PLATFORM);
|
|
105
|
+
COMPOSE = argv.includes("--compose");
|
|
106
|
+
FRAMEWORK = arg("framework", FRAMEWORK);
|
|
90
107
|
if (!outFileExplicit && fs.existsSync(path.resolve(process.cwd(), OLD_DEFAULT_OUT_REL))) {
|
|
91
108
|
warnLegacyArtifact(OLD_DEFAULT_OUT_REL, NEW_DEFAULT_OUT_REL);
|
|
92
109
|
}
|
|
@@ -1441,16 +1458,28 @@ function isMainModule(): boolean {
|
|
|
1441
1458
|
}
|
|
1442
1459
|
|
|
1443
1460
|
if (isMainModule()) {
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1461
|
+
// Wrapped in an async IIFE so --compose can dynamically import composeMeta
|
|
1462
|
+
// ONLY when requested — the default path (and any test importing this
|
|
1463
|
+
// module's pure exports) never pulls in the @decocms/blocks/cms barrel.
|
|
1464
|
+
void (async () => {
|
|
1465
|
+
let meta = generateMeta();
|
|
1466
|
+
if (COMPOSE) {
|
|
1467
|
+
const { composeMeta } = await import("@decocms/blocks/cms");
|
|
1468
|
+
// composeMeta returns @decocms/blocks' MetaResponse (platform optional);
|
|
1469
|
+
// this file's local MetaResponse requires platform. It's always present
|
|
1470
|
+
// (composeMeta spreads siteMeta, which set it), so the cast is safe.
|
|
1471
|
+
meta = composeMeta(meta, { framework: FRAMEWORK }) as MetaResponse;
|
|
1472
|
+
}
|
|
1473
|
+
const outPath = path.resolve(process.cwd(), OUT_REL);
|
|
1474
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
1475
|
+
fs.writeFileSync(outPath, JSON.stringify(meta, null, 2));
|
|
1476
|
+
|
|
1477
|
+
const defCount = Object.keys(meta.schema.definitions).length;
|
|
1478
|
+
const secCount = Object.keys(meta.manifest.blocks.sections || {}).length;
|
|
1479
|
+
const ldrCount = Object.keys(meta.manifest.blocks.loaders || {}).length;
|
|
1480
|
+
const appCount = Object.keys(meta.manifest.blocks.apps || {}).length;
|
|
1481
|
+
console.log(
|
|
1482
|
+
`\nGenerated schema${COMPOSE ? " (self-contained)" : ""}: ${defCount} definitions, ${secCount} sections, ${ldrCount} loaders, ${appCount} apps → ${path.relative(process.cwd(), outPath)}`,
|
|
1483
|
+
);
|
|
1484
|
+
})();
|
|
1456
1485
|
}
|