@decocms/start 0.32.2 → 0.32.3

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/start",
3
- "version": "0.32.2",
3
+ "version": "0.32.3",
4
4
  "type": "module",
5
5
  "description": "Deco framework for TanStack Start - CMS bridge, admin protocol, hooks, schema generation",
6
6
  "main": "./src/index.ts",
@@ -38,6 +38,7 @@ export function scaffold(ctx: MigrationContext): void {
38
38
  writeFile(ctx, "vite.config.ts", generateViteConfig(ctx));
39
39
  writeFile(ctx, "wrangler.jsonc", generateWrangler(ctx));
40
40
  writeFile(ctx, "knip.config.ts", generateKnipConfig());
41
+ writeFile(ctx, ".gitignore", generateGitignore());
41
42
  writeFile(ctx, ".prettierrc", JSON.stringify({
42
43
  semi: true,
43
44
  singleQuote: false,
@@ -113,6 +114,45 @@ function generateAppCss(_ctx: MigrationContext): string {
113
114
  `;
114
115
  }
115
116
 
117
+ function generateGitignore(): string {
118
+ return `# Dependencies
119
+ node_modules/
120
+
121
+ # Build output
122
+ dist/
123
+ .cache/
124
+
125
+ # Cloudflare Workers
126
+ .wrangler/
127
+ .dev.vars
128
+
129
+ # TanStack Router (auto-generated)
130
+ src/routeTree.gen.ts
131
+ .tanstack/
132
+
133
+ # Vite
134
+ vite.config.timestamp_*
135
+ *.local
136
+
137
+ # Environment
138
+ .env
139
+ .env.*
140
+
141
+ # OS
142
+ .DS_Store
143
+
144
+ # Deco CMS
145
+ .deco/metadata/*
146
+
147
+ # Bun lock file (if using npm, keep package-lock.json instead)
148
+ # package-lock.json
149
+
150
+ # IDE
151
+ .vscode/
152
+ .idea/
153
+ `;
154
+ }
155
+
116
156
  function generateSiteApp(ctx: MigrationContext): string {
117
157
  return `export type Platform =
118
158
  | "vtex"
@@ -8,10 +8,13 @@ function extractNpmDeps(importMap: Record<string, string>): Record<string, strin
8
8
  const deps: Record<string, string> = {};
9
9
  for (const [key, value] of Object.entries(importMap)) {
10
10
  if (!value.startsWith("npm:")) continue;
11
- // Skip preact, deco, and other framework deps we handle ourselves
11
+ // Skip framework deps we handle ourselves
12
12
  if (key.startsWith("preact") || key.startsWith("@preact/")) continue;
13
13
  if (key.startsWith("@deco/")) continue;
14
- if (key === "daisyui") continue; // we pin our own version
14
+ if (key === "daisyui") continue;
15
+ if (key === "preact-render-to-string") continue;
16
+ if (key === "simple-git") continue; // dev tool, not needed in runtime
17
+ if (key === "fast-json-patch") continue; // used by old deco runtime
15
18
 
16
19
  const raw = value.slice(4); // remove "npm:"
17
20
  const atIdx = raw.lastIndexOf("@");
@@ -19,8 +22,13 @@ function extractNpmDeps(importMap: Record<string, string>): Record<string, strin
19
22
  deps[raw] = "*";
20
23
  } else {
21
24
  const name = raw.slice(0, atIdx);
22
- const version = raw.slice(atIdx + 1);
23
- deps[name] = `^${version}`;
25
+ let version = raw.slice(atIdx + 1);
26
+ // Don't double-prefix with ^ if version already has a range prefix
27
+ if (/^[~^>=<]/.test(version)) {
28
+ deps[name] = version;
29
+ } else {
30
+ deps[name] = `^${version}`;
31
+ }
24
32
  }
25
33
  }
26
34
  return deps;
@@ -39,6 +47,8 @@ export function generatePackageJson(ctx: MigrationContext): string {
39
47
  description: `${ctx.siteName} storefront powered by TanStack Start`,
40
48
  scripts: {
41
49
  dev: "vite dev",
50
+ "dev:clean":
51
+ "rm -rf node_modules/.vite .wrangler/state .tanstack && vite dev",
42
52
  "generate:blocks":
43
53
  "tsx node_modules/@decocms/start/scripts/generate-blocks.ts",
44
54
  "generate:routes": "tsr generate",
@@ -21,9 +21,13 @@ if (typeof document === "undefined") {
21
21
  }
22
22
 
23
23
  // -- Section Registry --
24
- // Discovers all .tsx files under src/sections/ and registers them as CMS blocks.
25
- const sectionModules = import.meta.glob("./sections/**/*.tsx");
26
- registerSections(sectionModules);
24
+ // CMS blocks reference sections as "site/sections/X.tsx", so we remap the glob keys.
25
+ const sectionGlob = import.meta.glob("./sections/**/*.tsx") as Record<string, () => Promise<any>>;
26
+ const sections: Record<string, () => Promise<any>> = {};
27
+ for (const [path, loader] of Object.entries(sectionGlob)) {
28
+ sections["site/" + path.slice(2)] = loader;
29
+ }
30
+ registerSections(sections);
27
31
 
28
32
  // -- Matchers --
29
33
  registerBuiltinMatchers();
@@ -24,7 +24,8 @@
24
24
  */
25
25
 
26
26
  import * as path from "node:path";
27
- import { createContext } from "./migrate/types.ts";
27
+ import { execSync } from "node:child_process";
28
+ import { createContext, logPhase } from "./migrate/types.ts";
28
29
  import { analyze } from "./migrate/phase-analyze.ts";
29
30
  import { scaffold } from "./migrate/phase-scaffold.ts";
30
31
  import { transform } from "./migrate/phase-transform.ts";
@@ -126,10 +127,49 @@ async function main() {
126
127
  if (!ok) {
127
128
  process.exit(2);
128
129
  }
130
+
131
+ // Phase 7: Bootstrap (install + generate)
132
+ if (!ctx.dryRun) {
133
+ bootstrap(ctx);
134
+ }
129
135
  } catch (error) {
130
136
  console.error(`\n ${red("Migration failed:")}`, error);
131
137
  process.exit(1);
132
138
  }
133
139
  }
134
140
 
141
+ function bootstrap(ctx: { sourceDir: string }) {
142
+ logPhase("Bootstrap (install + generate)");
143
+
144
+ let failures = 0;
145
+ const run = (cmd: string, label: string, critical = false) => {
146
+ console.log(` Running: ${label}...`);
147
+ try {
148
+ execSync(cmd, { cwd: ctx.sourceDir, stdio: "pipe" });
149
+ console.log(` ${green("✓")} ${label}`);
150
+ } catch (e: any) {
151
+ failures++;
152
+ const icon = critical ? red("✗") : yellow("⚠");
153
+ console.log(` ${icon} ${label} failed: ${e.message?.split("\n")[0]}`);
154
+ if (critical) {
155
+ console.log(`\n ${red("Bootstrap aborted.")} Fix the error above and run manually.\n`);
156
+ return false;
157
+ }
158
+ }
159
+ return true;
160
+ };
161
+
162
+ // Detect package manager
163
+ const pm = process.env.npm_execpath?.includes("bun") ? "bun" : "npm";
164
+ if (!run(`${pm} install`, "Install dependencies", true)) return;
165
+ run("npx tsx node_modules/@decocms/start/scripts/generate-blocks.ts", "Generate CMS blocks");
166
+ run("npx tsr generate", "Generate TanStack routes");
167
+
168
+ if (failures > 0) {
169
+ console.log(`\n ${yellow("Bootstrap completed with warnings.")} Check errors above before running dev.\n`);
170
+ } else {
171
+ console.log(`\n ${green("Ready!")} Run \`${pm} run dev\` to start the dev server.\n`);
172
+ }
173
+ }
174
+
135
175
  main();