@decocms/start 0.40.1 → 0.42.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/README.md CHANGED
@@ -79,13 +79,19 @@ The skill handles compatibility checking, import rewrites, config generation, se
79
79
  ### Or run the script manually
80
80
 
81
81
  ```bash
82
- # From a new TanStack Start project with @decocms/start installed:
83
- npx tsx node_modules/@decocms/start/scripts/migrate.ts --source /path/to/fresh-site
84
-
85
- # Preview first without writing:
86
- npx tsx node_modules/@decocms/start/scripts/migrate.ts --source /path/to/fresh-site --dry-run --verbose
82
+ # From your Fresh site directory (nothing to install beforehand):
83
+ npx -p @decocms/start deco-migrate
87
84
  ```
88
85
 
86
+ **Options:**
87
+
88
+ | Flag | Description |
89
+ |------|-------------|
90
+ | `--source <dir>` | Source directory (default: current directory) |
91
+ | `--dry-run` | Preview changes without writing files |
92
+ | `--verbose` | Show detailed output |
93
+ | `--help`, `-h` | Show help message |
94
+
89
95
  The script runs 7 phases automatically:
90
96
 
91
97
  1. **Analyze** — scan source, detect Preact/Fresh/Deco patterns
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@decocms/start",
3
- "version": "0.40.1",
3
+ "version": "0.42.0",
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",
7
+ "bin": {
8
+ "deco-migrate": "./scripts/migrate.ts"
9
+ },
7
10
  "exports": {
8
11
  ".": "./src/index.ts",
9
12
  "./cms": "./src/cms/index.ts",
@@ -80,6 +83,9 @@
80
83
  "registry": "https://registry.npmjs.org",
81
84
  "access": "public"
82
85
  },
86
+ "dependencies": {
87
+ "tsx": "^4.19.0"
88
+ },
83
89
  "peerDependencies": {
84
90
  "@tanstack/react-start": ">=1.0.0",
85
91
  "@tanstack/store": ">=0.7.0",
@@ -5,8 +5,8 @@
5
5
  * Converts a Deco storefront from the old Fresh/Deno stack to the new TanStack Start stack.
6
6
  * Part of the @decocms/start framework — run from a site's root directory.
7
7
  *
8
- * Usage (from site root):
9
- * npx tsx node_modules/@decocms/start/scripts/migrate.ts [options]
8
+ * Usage (from your Fresh site directory):
9
+ * npx -p @decocms/start deco-migrate [options]
10
10
  *
11
11
  * Options:
12
12
  * --source <dir> Source directory (default: current directory)
@@ -71,7 +71,7 @@ function showHelp() {
71
71
  @decocms/start — Migration Script: Fresh/Deno → TanStack Start
72
72
 
73
73
  Usage:
74
- npx tsx node_modules/@decocms/start/scripts/migrate.ts [options]
74
+ npx -p @decocms/start deco-migrate [options]
75
75
 
76
76
  Options:
77
77
  --source <dir> Source directory (default: .)
@@ -80,9 +80,9 @@ function showHelp() {
80
80
  --help, -h Show this help message
81
81
 
82
82
  Examples:
83
- npx tsx node_modules/@decocms/start/scripts/migrate.ts --dry-run --verbose
84
- npx tsx node_modules/@decocms/start/scripts/migrate.ts --source ./my-site
85
- npx tsx node_modules/@decocms/start/scripts/migrate.ts
83
+ npx -p @decocms/start deco-migrate --dry-run --verbose
84
+ npx -p @decocms/start deco-migrate --source ./my-site
85
+ npx -p @decocms/start deco-migrate
86
86
  `);
87
87
  }
88
88
 
@@ -37,6 +37,9 @@ import { cleanPathForCacheKey } from "./urlUtils";
37
37
  import { isMobileUA } from "./useDevice";
38
38
  import { getRenderShellConfig } from "../admin/setup";
39
39
  import { RequestContext } from "./requestContext";
40
+ import type { MatcherContext } from "../cms/resolve";
41
+ import { resolveDecoPage } from "../cms/resolve";
42
+ import { runSectionLoaders } from "../cms/sectionLoaders";
40
43
 
41
44
  /**
42
45
  * Append Link preload headers for CSS and fonts so the browser starts
@@ -669,6 +672,40 @@ export function createDecoWorkerEntry(
669
672
  return handlePurge(request, env);
670
673
  }
671
674
 
675
+ // ?asJson — return resolved page data as JSON (legacy deco compat)
676
+ if (url.searchParams.has("asJson") && request.method === "GET") {
677
+ const basePath = url.pathname;
678
+ const cookies: Record<string, string> = {};
679
+ for (const pair of (request.headers.get("cookie") ?? "").split(";")) {
680
+ const [k, ...v] = pair.split("=");
681
+ if (k?.trim()) cookies[k.trim()] = v.join("=").trim();
682
+ }
683
+ const matcherCtx: MatcherContext = {
684
+ userAgent: request.headers.get("user-agent") ?? "",
685
+ url: url.toString(),
686
+ path: basePath,
687
+ cookies,
688
+ request,
689
+ };
690
+ const page = await resolveDecoPage(basePath, matcherCtx);
691
+ if (!page) {
692
+ return Response.json(null, { status: 404, headers: { "Access-Control-Allow-Origin": "*" } });
693
+ }
694
+ const enrichedSections = await runSectionLoaders(page.resolvedSections, request);
695
+ const { seoSection: _seo, ...pageData } = page;
696
+ const result = {
697
+ ...pageData,
698
+ resolvedSections: enrichedSections,
699
+ };
700
+ return Response.json(result, {
701
+ headers: {
702
+ "Access-Control-Allow-Origin": "*",
703
+ "Access-Control-Allow-Headers": "Content-Type, Authorization",
704
+ "Access-Control-Allow-Methods": "GET, OPTIONS",
705
+ },
706
+ });
707
+ }
708
+
672
709
  // Commerce proxy (checkout, account, API, etc.)
673
710
  if (options.proxyHandler) {
674
711
  const proxyResponse = await options.proxyHandler(request, url);