@decocms/blocks-cli 7.52.0 → 7.53.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/blocks-cli",
3
- "version": "7.52.0",
3
+ "version": "7.53.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": {
@@ -33,7 +33,7 @@
33
33
  "lint:unused": "knip"
34
34
  },
35
35
  "dependencies": {
36
- "@decocms/blocks": "7.52.0",
36
+ "@decocms/blocks": "7.53.0",
37
37
  "ts-morph": "^27.0.0",
38
38
  "tsx": "^4.22.5"
39
39
  },
@@ -27,12 +27,14 @@ 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
30
+ * --framework Value written to the composed meta's `framework` field
35
31
  * (default: "tanstack-start").
32
+ *
33
+ * The output is ALWAYS run through composeMeta() before writing, so
34
+ * meta.gen.json is self-contained (bakes in Page, matchers, __SECTION_REF__,
35
+ * Resolvable). This matters for consumers that read the file straight from
36
+ * disk with no runtime (FS-based Studio / Eitri stack); runtime readers
37
+ * re-compose idempotently (see composeMeta's `framework` sentinel).
36
38
  */
37
39
  import {
38
40
  type Symbol as MorphSymbol,
@@ -72,14 +74,12 @@ let APPS_REL = "src/apps";
72
74
  let SKIP_APPS = false;
73
75
  let OUT_REL = NEW_DEFAULT_OUT_REL;
74
76
  let PLATFORM = "cloudflare";
75
- // When true, run composeMeta() over the generated site meta before writing, so
76
- // the output file is SELF-CONTAINED — it carries the framework block types
77
- // (Page, matchers, __SECTION_REF__, Resolvable) that composeMeta otherwise
78
- // injects at runtime. Required by consumers that read meta.gen.json straight
79
- // from the filesystem with no runtime (e.g. the FS-based Studio / Eitri stack).
80
- let COMPOSE = false;
81
- // Value written to the composed meta's `framework` field (only used with
82
- // --compose). Defaults to composeMeta's historical "tanstack-start".
77
+ // Value written to the composed meta's `framework` field. Defaults to
78
+ // composeMeta's historical "tanstack-start". composeMeta ALWAYS runs before
79
+ // writing (see the write block below), so the output file is SELF-CONTAINED —
80
+ // it carries the framework block types (Page, matchers, __SECTION_REF__,
81
+ // Resolvable). Required by consumers that read meta.gen.json straight from the
82
+ // filesystem with no runtime (e.g. the FS-based Studio / Eitri stack).
83
83
  let FRAMEWORK = "tanstack-start";
84
84
 
85
85
  if (isMainModule()) {
@@ -92,7 +92,6 @@ if (isMainModule()) {
92
92
  SKIP_APPS = argv.includes("--skip-apps");
93
93
  OUT_REL = arg("out", NEW_DEFAULT_OUT_REL);
94
94
  PLATFORM = arg("platform", PLATFORM);
95
- COMPOSE = argv.includes("--compose");
96
95
  FRAMEWORK = arg("framework", FRAMEWORK);
97
96
  }
98
97
 
@@ -1543,18 +1542,17 @@ function isMainModule(): boolean {
1543
1542
  }
1544
1543
 
1545
1544
  if (isMainModule()) {
1546
- // Wrapped in an async IIFE so --compose can dynamically import composeMeta
1547
- // ONLY when requested — the default path (and any test importing this
1548
- // module's pure exports) never pulls in the @decocms/blocks/cms barrel.
1545
+ // Wrapped in an async IIFE so the composeMeta dynamic import happens only
1546
+ // when this module is actually run (any test importing this module's pure
1547
+ // exports never reaches here, so it never pulls in the @decocms/blocks/cms
1548
+ // barrel). composeMeta always runs, making the written file self-contained.
1549
1549
  void (async () => {
1550
- let meta = generateMeta();
1551
- if (COMPOSE) {
1552
- const { composeMeta } = await import("@decocms/blocks/cms");
1553
- // composeMeta returns @decocms/blocks' MetaResponse (platform optional);
1554
- // this file's local MetaResponse requires platform. It's always present
1555
- // (composeMeta spreads siteMeta, which set it), so the cast is safe.
1556
- meta = composeMeta(meta, { framework: FRAMEWORK }) as MetaResponse;
1557
- }
1550
+ const rawMeta = generateMeta();
1551
+ const { composeMeta } = await import("@decocms/blocks/cms");
1552
+ // composeMeta returns @decocms/blocks' MetaResponse (platform optional);
1553
+ // this file's local MetaResponse requires platform. It's always present
1554
+ // (composeMeta spreads siteMeta, which set it), so the cast is safe.
1555
+ const meta = composeMeta(rawMeta, { framework: FRAMEWORK }) as MetaResponse;
1558
1556
  const outPath = path.resolve(process.cwd(), OUT_REL);
1559
1557
  fs.mkdirSync(path.dirname(outPath), { recursive: true });
1560
1558
  fs.writeFileSync(outPath, JSON.stringify(meta, null, 2));
@@ -1564,7 +1562,7 @@ if (isMainModule()) {
1564
1562
  const ldrCount = Object.keys(meta.manifest.blocks.loaders || {}).length;
1565
1563
  const appCount = Object.keys(meta.manifest.blocks.apps || {}).length;
1566
1564
  console.log(
1567
- `\nGenerated schema${COMPOSE ? " (self-contained)" : ""}: ${defCount} definitions, ${secCount} sections, ${ldrCount} loaders, ${appCount} apps → ${path.relative(process.cwd(), outPath)}`,
1565
+ `\nGenerated schema (self-contained): ${defCount} definitions, ${secCount} sections, ${ldrCount} loaders, ${appCount} apps → ${path.relative(process.cwd(), outPath)}`,
1568
1566
  );
1569
1567
  })();
1570
1568
  }
@@ -242,8 +242,7 @@ describe("buildPlan --platform eitri", () => {
242
242
  expect(byName[name].disabledReason).toBe("not used by --platform eitri");
243
243
  }
244
244
 
245
- // schema is asked to bake composeMeta's framework block types in.
246
- expect(byName.schema.args).toContain("--compose");
245
+ // schema tags the composed meta with the eitri framework name.
247
246
  const fwIdx = byName.schema.args.indexOf("--framework");
248
247
  expect(byName.schema.args[fwIdx + 1]).toBe("eitri");
249
248
  } finally {
@@ -658,15 +658,15 @@ export function buildPlan(cwd: string, opts: CliOptions): GeneratorPlan[] {
658
658
  ...(opts.namespace ? ["--namespace", opts.namespace] : []),
659
659
  ...(opts.platform ? ["--platform", opts.platform] : []),
660
660
  ...(opts.skipApps ? ["--skip-apps"] : []),
661
- // Always bake composeMeta's framework block types (Page, matchers,
662
- // __SECTION_REF__, Resolvable) into meta.gen.json so the file is
663
- // SELF-CONTAINED for every consumer that reads it straight from disk —
664
- // the FS-based Studio and the Eitri stack, but also anyone diffing the
665
- // committed artifact against /live/_meta. The tanstack runtime re-runs
666
- // composeMeta on load, which is now idempotent (it returns an
667
- // already-composed meta unchanged — see composeMeta's `framework`
668
- // sentinel), so this is a no-op there rather than a double-compose.
669
- "--compose",
661
+ // generate-schema always bakes composeMeta's framework block types
662
+ // (Page, matchers, __SECTION_REF__, Resolvable) into meta.gen.json, so
663
+ // the file is SELF-CONTAINED for every consumer that reads it straight
664
+ // from disk — the FS-based Studio and the Eitri stack, but also anyone
665
+ // diffing the committed artifact against /live/_meta. The tanstack
666
+ // runtime re-runs composeMeta on load, which is idempotent (it returns
667
+ // an already-composed meta unchanged — see composeMeta's `framework`
668
+ // sentinel), so that's a no-op rather than a double-compose.
669
+ //
670
670
  // Non-React stacks (Eitri) tag the composed meta with their own
671
671
  // framework name; everyone else gets composeMeta's default
672
672
  // ("tanstack-start").