@decocms/blocks-cli 7.16.0 → 7.16.1

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.16.0",
3
+ "version": "7.16.1",
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.16.0",
33
+ "@decocms/blocks": "7.16.1",
34
34
  "ts-morph": "^27.0.0",
35
35
  "tsx": "^4.22.5"
36
36
  },
@@ -579,10 +579,11 @@ export function buildPlan(cwd: string, opts: CliOptions): GeneratorPlan[] {
579
579
  ...(opts.pruneByDecofile ? ["--prune-by-decofile", opts.pruneByDecofile] : []),
580
580
  ],
581
581
  stage: 1,
582
- ...enabledIf(
583
- fs.existsSync(loadersDirAbs) || fs.existsSync(actionsDirAbs),
584
- `neither ${opts.loadersDir} nor ${opts.actionsDir} exists`,
585
- ),
582
+ // Always run even when src/loaders and src/actions don't exist yet —
583
+ // generate-loaders.ts handles missing dirs gracefully (emits an empty
584
+ // siteLoaders map). This ensures .deco/loaders.gen.ts is always present
585
+ // so scaffolded commerce-loaders.ts imports resolve on first boot.
586
+ enabled: true,
586
587
  inputs: () =>
587
588
  sortEntries([
588
589
  ...walkTree(cwd, loadersDirAbs, [".ts", ".tsx"]),
@@ -50,15 +50,18 @@ function writeMultiFile(ctx: MigrationContext, files: Record<string, string>) {
50
50
  export function scaffold(ctx: MigrationContext): void {
51
51
  logPhase("Scaffold");
52
52
 
53
- // Root config files. wrangler.jsonc is intentionally NOT generated by
54
- // the migration script -- it's per-site, lives in the site repo, and
55
- // is wired by hand on first deploy (D6.3 interim state until the
56
- // Cloudflare Workers Builds onboarding lands).
53
+ // Root config files.
54
+ // wrangler.jsonc is scaffolded with a minimal dev config. For deploy,
55
+ // Cloudflare Workers Builds ignores the `name` field (D6.3 the
56
+ // repo<->worker connection is wired once in the CF dashboard). Committing
57
+ // this file is required for `@cloudflare/vite-plugin` to mount the worker
58
+ // in local dev; without it every route returns a silent 404.
57
59
  writeFile(ctx, "package.json", generatePackageJson(ctx));
58
60
  writeFile(ctx, "tsconfig.json", generateTsconfig());
59
61
  writeFile(ctx, "vite.config.ts", generateViteConfig(ctx));
60
62
  writeFile(ctx, "knip.config.ts", generateKnipConfig());
61
63
  writeFile(ctx, ".gitignore", generateGitignore());
64
+ writeFile(ctx, "wrangler.jsonc", generateWranglerConfig(ctx));
62
65
 
63
66
  // Deploy / preview pipelines are owned by Cloudflare Workers Builds
64
67
  // configured per-worker in the CF dashboard (D6.3). The migration
@@ -216,6 +219,20 @@ export { type Font as SiteThemeFont };
216
219
  `;
217
220
  }
218
221
 
222
+ function generateWranglerConfig(ctx: MigrationContext): string {
223
+ return JSON.stringify(
224
+ {
225
+ name: ctx.siteName,
226
+ main: "src/worker-entry.ts",
227
+ compatibility_date: "2025-05-01",
228
+ compatibility_flags: ["nodejs_compat", "no_handle_cross_request_promise_resolution"],
229
+ kv_namespaces: [{ binding: "SITES_KV", id: "dev-sites-kv" }],
230
+ },
231
+ null,
232
+ 2,
233
+ ) + "\n";
234
+ }
235
+
219
236
  function generateGitignore(): string {
220
237
  return `# Dependencies
221
238
  node_modules/
@@ -13,6 +13,10 @@ const REQUIRED_FILES = [
13
13
  "package.json",
14
14
  "tsconfig.json",
15
15
  "vite.config.ts",
16
+ // Required for @cloudflare/vite-plugin to mount the worker in local dev
17
+ // (without it every route returns a silent 404). For deploy, Cloudflare
18
+ // Workers Builds ignores the `name` field (D6.3 — wired in CF dashboard).
19
+ "wrangler.jsonc",
16
20
  // Deploy / preview / sync-secrets pipelines are owned by Cloudflare
17
21
  // Workers Builds (D6.3) -- configured in the CF dashboard, not via
18
22
  // GitHub workflow files in the site repo.