@cimplify/cli 0.5.1 → 0.5.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.
Files changed (104) hide show
  1. package/dist/{add-IJELMSCY.mjs → add-3DANJHCI.mjs} +1 -1
  2. package/dist/{chunk-O7SMBTHQ.mjs → chunk-2547SIWD.mjs} +1 -1
  3. package/dist/{chunk-U3DWSQYY.mjs → chunk-BB7IBX6X.mjs} +1 -1
  4. package/dist/{chunk-DENWIVVB.mjs → chunk-ZEGSQVM5.mjs} +23 -23
  5. package/dist/dispatcher.mjs +9 -9
  6. package/dist/{doctor-NUKNW4S3.mjs → doctor-TD4RZCCM.mjs} +2 -2
  7. package/dist/{explain-TGRXJW3V.mjs → explain-7OSAQVJ6.mjs} +1 -1
  8. package/dist/{introspect-5W72YWFT.mjs → introspect-SKQMAYFJ.mjs} +2 -2
  9. package/dist/{list-VO4LKRDN.mjs → list-XLJOS2DK.mjs} +1 -1
  10. package/dist/{update-V7XIKMFU.mjs → update-4GX2J3IB.mjs} +1 -1
  11. package/package.json +1 -1
  12. package/templates/manifest.json +2 -2
  13. package/templates/storefront-auto/.env.example +9 -18
  14. package/templates/storefront-auto/README.md +1 -3
  15. package/templates/storefront-auto/app/.well-known/ucp/route.ts +42 -20
  16. package/templates/storefront-auto/app/layout.tsx +31 -26
  17. package/templates/storefront-auto/app/llms.txt/route.ts +3 -5
  18. package/templates/storefront-auto/app/opensearch.xml/route.ts +5 -6
  19. package/templates/storefront-auto/app/products/[slug]/page.tsx +5 -5
  20. package/templates/storefront-auto/app/robots.ts +5 -6
  21. package/templates/storefront-auto/app/sitemap.ts +6 -7
  22. package/templates/storefront-auto/components/providers.tsx +3 -12
  23. package/templates/storefront-auto/lib/site-url.ts +29 -0
  24. package/templates/storefront-auto/next.config.ts +10 -16
  25. package/templates/storefront-bakery/.env.example +9 -18
  26. package/templates/storefront-bakery/README.md +1 -3
  27. package/templates/storefront-bakery/app/.well-known/ucp/route.ts +42 -20
  28. package/templates/storefront-bakery/app/layout.tsx +40 -35
  29. package/templates/storefront-bakery/app/llms.txt/route.ts +3 -5
  30. package/templates/storefront-bakery/app/opensearch.xml/route.ts +5 -6
  31. package/templates/storefront-bakery/app/robots.ts +5 -6
  32. package/templates/storefront-bakery/app/sitemap.ts +6 -7
  33. package/templates/storefront-bakery/components/providers.tsx +3 -12
  34. package/templates/storefront-bakery/lib/site-url.ts +29 -0
  35. package/templates/storefront-bakery/next.config.ts +10 -16
  36. package/templates/storefront-fashion/.env.example +9 -18
  37. package/templates/storefront-fashion/README.md +2 -4
  38. package/templates/storefront-fashion/app/.well-known/ucp/route.ts +42 -20
  39. package/templates/storefront-fashion/app/layout.tsx +31 -26
  40. package/templates/storefront-fashion/app/llms.txt/route.ts +3 -5
  41. package/templates/storefront-fashion/app/opensearch.xml/route.ts +5 -6
  42. package/templates/storefront-fashion/app/products/[slug]/page.tsx +5 -5
  43. package/templates/storefront-fashion/app/robots.ts +5 -6
  44. package/templates/storefront-fashion/app/sitemap.ts +6 -7
  45. package/templates/storefront-fashion/components/providers.tsx +3 -12
  46. package/templates/storefront-fashion/lib/site-url.ts +29 -0
  47. package/templates/storefront-fashion/next.config.ts +10 -16
  48. package/templates/storefront-grocery/.env.example +9 -18
  49. package/templates/storefront-grocery/README.md +2 -4
  50. package/templates/storefront-grocery/app/.well-known/ucp/route.ts +42 -20
  51. package/templates/storefront-grocery/app/layout.tsx +31 -26
  52. package/templates/storefront-grocery/app/llms.txt/route.ts +3 -5
  53. package/templates/storefront-grocery/app/opensearch.xml/route.ts +5 -6
  54. package/templates/storefront-grocery/app/robots.ts +5 -6
  55. package/templates/storefront-grocery/app/sitemap.ts +6 -7
  56. package/templates/storefront-grocery/components/providers.tsx +3 -12
  57. package/templates/storefront-grocery/lib/site-url.ts +29 -0
  58. package/templates/storefront-grocery/next.config.ts +10 -16
  59. package/templates/storefront-pharmacy/.env.example +9 -18
  60. package/templates/storefront-pharmacy/README.md +1 -3
  61. package/templates/storefront-pharmacy/app/.well-known/ucp/route.ts +42 -20
  62. package/templates/storefront-pharmacy/app/layout.tsx +31 -26
  63. package/templates/storefront-pharmacy/app/llms.txt/route.ts +3 -5
  64. package/templates/storefront-pharmacy/app/opensearch.xml/route.ts +5 -6
  65. package/templates/storefront-pharmacy/app/products/[slug]/page.tsx +5 -5
  66. package/templates/storefront-pharmacy/app/robots.ts +5 -6
  67. package/templates/storefront-pharmacy/app/sitemap.ts +6 -7
  68. package/templates/storefront-pharmacy/components/providers.tsx +3 -12
  69. package/templates/storefront-pharmacy/lib/site-url.ts +29 -0
  70. package/templates/storefront-pharmacy/next.config.ts +10 -16
  71. package/templates/storefront-restaurant/.env.example +9 -18
  72. package/templates/storefront-restaurant/README.md +2 -4
  73. package/templates/storefront-restaurant/app/.well-known/ucp/route.ts +42 -20
  74. package/templates/storefront-restaurant/app/layout.tsx +31 -26
  75. package/templates/storefront-restaurant/app/llms.txt/route.ts +3 -5
  76. package/templates/storefront-restaurant/app/opensearch.xml/route.ts +5 -6
  77. package/templates/storefront-restaurant/app/robots.ts +5 -6
  78. package/templates/storefront-restaurant/app/sitemap.ts +6 -7
  79. package/templates/storefront-restaurant/components/providers.tsx +3 -12
  80. package/templates/storefront-restaurant/lib/site-url.ts +29 -0
  81. package/templates/storefront-restaurant/next.config.ts +10 -16
  82. package/templates/storefront-retail/.env.example +9 -18
  83. package/templates/storefront-retail/README.md +1 -3
  84. package/templates/storefront-retail/app/.well-known/ucp/route.ts +42 -20
  85. package/templates/storefront-retail/app/layout.tsx +31 -26
  86. package/templates/storefront-retail/app/llms.txt/route.ts +3 -5
  87. package/templates/storefront-retail/app/opensearch.xml/route.ts +5 -6
  88. package/templates/storefront-retail/app/products/[slug]/page.tsx +5 -5
  89. package/templates/storefront-retail/app/robots.ts +5 -6
  90. package/templates/storefront-retail/app/sitemap.ts +6 -7
  91. package/templates/storefront-retail/components/providers.tsx +3 -12
  92. package/templates/storefront-retail/lib/site-url.ts +29 -0
  93. package/templates/storefront-retail/next.config.ts +10 -16
  94. package/templates/storefront-services/.env.example +9 -18
  95. package/templates/storefront-services/README.md +2 -4
  96. package/templates/storefront-services/app/.well-known/ucp/route.ts +42 -20
  97. package/templates/storefront-services/app/layout.tsx +31 -26
  98. package/templates/storefront-services/app/llms.txt/route.ts +3 -5
  99. package/templates/storefront-services/app/opensearch.xml/route.ts +5 -6
  100. package/templates/storefront-services/app/robots.ts +5 -6
  101. package/templates/storefront-services/app/sitemap.ts +6 -7
  102. package/templates/storefront-services/components/providers.tsx +3 -12
  103. package/templates/storefront-services/lib/site-url.ts +29 -0
  104. package/templates/storefront-services/next.config.ts +10 -16
@@ -0,0 +1,29 @@
1
+ import { headers } from "next/headers";
2
+
3
+ /**
4
+ * Canonical absolute URL for this storefront, derived at request time.
5
+ *
6
+ * Resolution order:
7
+ * 1. `NEXT_PUBLIC_SITE_URL` — set when you need a fixed canonical
8
+ * (multiple domains, www-vs-apex preference, etc.).
9
+ * 2. The request `Host` header — works automatically on every deploy,
10
+ * including preview URLs and custom domains.
11
+ * 3. `https://example.com` — only ever returned during prerender of
12
+ * a page that has no live request (rare in App Router).
13
+ */
14
+ export async function getSiteUrl(): Promise<string> {
15
+ const explicit = process.env.NEXT_PUBLIC_SITE_URL?.trim();
16
+ if (explicit) return explicit;
17
+
18
+ try {
19
+ const h = await headers();
20
+ const host = h.get("host");
21
+ if (host) {
22
+ const isLocal = host.startsWith("localhost") || host.startsWith("127.");
23
+ return `${isLocal ? "http" : "https"}://${host}`;
24
+ }
25
+ } catch {
26
+ // `headers()` is unavailable in some build contexts — fall through.
27
+ }
28
+ return "https://example.com";
29
+ }
@@ -1,18 +1,12 @@
1
1
  import type { NextConfig } from "next";
2
2
 
3
- const MOCK_URL = process.env.NEXT_PUBLIC_CIMPLIFY_API_URL?.trim() || "http://127.0.0.1:8787";
3
+ // Same-origin proxy target for the storefront API. Local mock in dev,
4
+ // hosted Cimplify in prod.
5
+ const STOREFRONT_URL =
6
+ process.env.NODE_ENV === "production"
7
+ ? "https://storefronts.cimplify.io"
8
+ : "http://127.0.0.1:8787";
4
9
 
5
- /**
6
- * Same-origin proxy to the Cimplify mock so the browser never makes a
7
- * cross-origin request in dev (no CORS preflights, no flaky `Origin`
8
- * mismatches). The SDK's base URL stays empty/relative — requests go to
9
- * `/api/v1/...` on the Next origin, then this rewrite forwards them to
10
- * the mock at `127.0.0.1:8787`.
11
- *
12
- * In production, point `NEXT_PUBLIC_CIMPLIFY_API_URL` at your Cimplify
13
- * host and the rewrite continues to work the same way (or remove it and
14
- * pass the absolute URL through `<CimplifyProvider/>`).
15
- */
16
10
  const nextConfig: NextConfig = {
17
11
  // Enable Next 16's `cacheComponents` mode so we can use `'use cache'` +
18
12
  // `cacheTag` / `cacheLife` for SSR caching. Cached chrome streams first,
@@ -20,10 +14,10 @@ const nextConfig: NextConfig = {
20
14
  cacheComponents: true,
21
15
  async rewrites() {
22
16
  return [
23
- { source: "/api/v1/:path*", destination: `${MOCK_URL}/api/v1/:path*` },
24
- { source: "/img/:path*", destination: `${MOCK_URL}/img/:path*` },
25
- { source: "/elements/:path*", destination: `${MOCK_URL}/elements/:path*` },
26
- { source: "/_mock/:path*", destination: `${MOCK_URL}/_mock/:path*` },
17
+ { source: "/api/v1/:path*", destination: `${STOREFRONT_URL}/api/v1/:path*` },
18
+ { source: "/img/:path*", destination: `${STOREFRONT_URL}/img/:path*` },
19
+ { source: "/elements/:path*", destination: `${STOREFRONT_URL}/elements/:path*` },
20
+ { source: "/_mock/:path*", destination: `${STOREFRONT_URL}/_mock/:path*` },
27
21
  ];
28
22
  },
29
23
  images: {