@hszrdm/create-commerce 1.10.0 → 1.11.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.
Files changed (38) hide show
  1. package/README.md +6 -0
  2. package/package.json +1 -1
  3. package/src/cli.mjs +20 -4
  4. package/src/upgrade.mjs +79 -4
  5. package/templates/backend/.env.example +8 -0
  6. package/templates/backend/package.json +2 -1
  7. package/templates/backend/scripts/commerce-instance-status.mjs +135 -0
  8. package/templates/backend/scripts/commerce-ops.mjs +61 -2
  9. package/templates/backend/scripts/core-restore.mjs +40 -5
  10. package/templates/backend/scripts/lib/core-backup-common.mjs +91 -11
  11. package/templates/backend/scripts/production-assets/backup.sh +6 -51
  12. package/templates/backend/scripts/production-assets/deploy.sh +10 -62
  13. package/templates/backend/scripts/production-assets/install.sh +23 -195
  14. package/templates/backend/scripts/production-assets/restore.sh +17 -66
  15. package/templates/backend/src/scripts/sync-integration-runtime.ts +1 -0
  16. package/templates/storefront/package.json +5 -1
  17. package/templates/storefront/src/app/checkout/success/page.tsx +2 -0
  18. package/templates/storefront/src/app/globals.css +32 -0
  19. package/templates/storefront/src/app/layout.tsx +7 -1
  20. package/templates/storefront/src/app/legal/page.tsx +3 -3
  21. package/templates/storefront/src/components/analytics.tsx +10 -8
  22. package/templates/storefront/src/components/checkout-flow.tsx +539 -75
  23. package/templates/storefront/src/components/fogyasztobarat-embed.tsx +6 -2
  24. package/templates/storefront/src/components/google-analytics-purchase.tsx +33 -0
  25. package/templates/storefront/src/components/stripe-payment.tsx +186 -62
  26. package/templates/storefront/src/lib/core/checkout-addresses.ts +166 -0
  27. package/templates/storefront/src/lib/core/checkout.ts +12 -0
  28. package/templates/storefront/src/lib/core/commerce.ts +12 -2
  29. package/templates/storefront/src/lib/core/company-tax.ts +132 -0
  30. package/templates/storefront/src/lib/core/ga4-bootstrap.ts +35 -0
  31. package/templates/storefront/src/lib/core/legal.ts +1 -0
  32. package/templates/storefront/src/lib/core/public-error.ts +1 -0
  33. package/templates/storefront/src/lib/core/stripe-checkout-phase.ts +23 -0
  34. package/templates/storefront/src/lib/core/tracking.ts +11 -2
  35. package/templates/storefront/tests/checkout-addresses.test.mjs +148 -0
  36. package/templates/storefront/tests/company-tax.test.mjs +68 -0
  37. package/templates/storefront/tests/ga4-bootstrap.test.mjs +74 -0
  38. package/templates/storefront/tests/stripe-checkout-phase.test.mjs +92 -0
@@ -138,6 +138,38 @@ input[readonly] { background: var(--surface-soft); color: var(--muted); }
138
138
 
139
139
  .checkout-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
140
140
  .checkout-summary { position: sticky; top: 18px; }
141
+
142
+ /* Stripe SDK and Payment Element both have an explicit loading stage.
143
+ Keep Elements mounted (for onReady/confirmPayment) underneath the loader. */
144
+ .stripe-payment-stage { position: relative; min-height: 72px; }
145
+ .stripe-payment-fields { transition: opacity .16s ease; }
146
+ .stripe-payment-loading {
147
+ display: flex;
148
+ align-items: center;
149
+ gap: 12px;
150
+ min-height: 72px;
151
+ padding: 14px 16px;
152
+ border-radius: 12px;
153
+ border: 1px solid var(--line);
154
+ background: var(--surface-soft);
155
+ color: var(--muted);
156
+ font-size: .9rem;
157
+ font-weight: 650;
158
+ }
159
+ .stripe-loading-spinner {
160
+ flex: 0 0 auto;
161
+ width: 22px;
162
+ height: 22px;
163
+ border: 2px solid var(--line);
164
+ border-top-color: var(--brand);
165
+ border-radius: 50%;
166
+ animation: stripe-loading-spin .8s linear infinite;
167
+ }
168
+ @keyframes stripe-loading-spin { to { transform: rotate(360deg); } }
169
+ @media (prefers-reduced-motion: reduce) {
170
+ .stripe-loading-spinner { animation-duration: 2s; }
171
+ .stripe-payment-fields { transition: none; }
172
+ }
141
173
  .section-title { display: flex; align-items: center; gap: 10px; }
142
174
  .section-title h2 { margin: 0; }
143
175
  .step-badge { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; background: var(--brand); color: white; font-size: .8rem; font-weight: 850; }
@@ -11,10 +11,12 @@ import { CartProvider } from "@/components/cart-provider"
11
11
  import { ConsentBanner } from "@/components/consent-banner"
12
12
  import { CustomerCartResumeGate } from "@/components/customer-cart-resume-gate"
13
13
  import { GoogleAdsCartRemarketing } from "@/components/google-ads-cart-remarketing"
14
+ import { FogyasztobaratEmbed } from "@/components/fogyasztobarat-embed"
14
15
  import { NewsletterSignup } from "@/components/newsletter-signup"
15
16
  import { StorefrontHeader } from "@/components/storefront-header"
16
17
  import { ToastProvider } from "@/components/toast-provider"
17
18
  import { getCoreConfig } from "@/lib/core/client"
19
+ import { getLegalEmbed, type LegalEmbedConfig } from "@/lib/core/legal"
18
20
  import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
19
21
  import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
20
22
 
@@ -47,9 +49,10 @@ export async function generateMetadata(): Promise<Metadata> {
47
49
  }
48
50
 
49
51
  export default async function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
50
- const [config, locale] = await Promise.all([
52
+ const [config, locale, fogyasztobarat] = await Promise.all([
51
53
  getCoreConfig(),
52
54
  requestStorefrontLocale(),
55
+ getLegalEmbed().catch((): LegalEmbedConfig => ({ enabled: false })),
53
56
  ])
54
57
  const routes = STOREFRONT_ROUTES[locale]
55
58
  const en = locale === "en"
@@ -95,6 +98,9 @@ export default async function RootLayout({ children }: Readonly<{ children: Reac
95
98
  </footer>
96
99
  <AnalyticsGate analytics={config.analytics} googleAds={config.marketing.google_ads} />
97
100
  <ConsentBanner enabled={config.features.analytics || config.features.google_ads} />
101
+ {fogyasztobarat.enabled && fogyasztobarat.placement === "global" ? (
102
+ <FogyasztobaratEmbed embed={fogyasztobarat} />
103
+ ) : null}
98
104
  </CartProvider>
99
105
  </ToastProvider>
100
106
  </AccessibilityPreferencesProvider>
@@ -1,6 +1,6 @@
1
1
  import { FogyasztobaratEmbed } from "@/components/fogyasztobarat-embed"
2
2
  import { getCoreConfig } from "@/lib/core/client"
3
- import { getLegalEmbed, listLegalDocuments } from "@/lib/core/legal"
3
+ import { getLegalEmbed, listLegalDocuments, type LegalEmbedConfig } from "@/lib/core/legal"
4
4
  import { storefrontCopy } from "@/lib/storefront-copy"
5
5
  import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
6
6
 
@@ -12,7 +12,7 @@ export default async function LegalPage() {
12
12
  const copy = storefrontCopy(locale)
13
13
  const [{ documents }, embed] = await Promise.all([
14
14
  listLegalDocuments(config),
15
- getLegalEmbed().catch(() => ({ enabled: false })),
15
+ getLegalEmbed().catch((): LegalEmbedConfig => ({ enabled: false })),
16
16
  ])
17
17
  const en = locale === "en"
18
18
 
@@ -22,7 +22,7 @@ export default async function LegalPage() {
22
22
  <div><p className="eyebrow">{copy.legalEyebrow}</p><h1>{copy.legalTitle}</h1><p className="muted">{copy.legalDescription}</p></div>
23
23
  </div>
24
24
 
25
- {embed.enabled ? (
25
+ {embed.enabled && embed.placement !== "global" ? (
26
26
  <section className="panel stack-sm">
27
27
  <div>
28
28
  <p className="eyebrow">{en ? "Consumer information" : "Fogyasztói tájékoztatás"}</p>
@@ -9,6 +9,7 @@ import {
9
9
  readConsentPreferences,
10
10
  type ConsentPreferences,
11
11
  } from "@/lib/core/consent"
12
+ import { ensureDirectGa4Initialized } from "@/lib/core/ga4-bootstrap"
12
13
  import { analyticsTrackingMode, trackWebshopPageView } from "@/lib/core/tracking"
13
14
  import type { CoreConfig } from "@/lib/core/types"
14
15
 
@@ -46,6 +47,8 @@ export function AnalyticsGate({
46
47
  const [preferences, setPreferences] = useState<ConsentPreferences | null>(null)
47
48
  const [ready, setReady] = useState(false)
48
49
  const sensitivePath = SENSITIVE_ANALYTICS_PATHS.has(pathname)
50
+ const mode = analyticsTrackingMode(analytics)
51
+ const ga4Id = analytics.google_analytics.measurement_id
49
52
 
50
53
  useEffect(() => {
51
54
  const stored = readConsentPreferences()
@@ -71,9 +74,15 @@ export function AnalyticsGate({
71
74
  trackWebshopPageView()
72
75
  }, [pathname, sensitivePath])
73
76
 
77
+ useEffect(() => {
78
+ if (!ready || sensitivePath || !preferences?.analytics || mode !== "ga4") return
79
+ // Configure GA4 in the same shared helper used by purchase/cart events.
80
+ // This avoids queued ecommerce hits running before the GA4 config command.
81
+ ensureDirectGa4Initialized(ga4Id, true)
82
+ }, [ready, sensitivePath, preferences?.analytics, mode, ga4Id])
83
+
74
84
  if (!ready || sensitivePath) return null
75
85
 
76
- const mode = analyticsTrackingMode(analytics)
77
86
  const analyticsGranted = Boolean(preferences?.analytics)
78
87
  const marketingGranted = Boolean(preferences?.marketing)
79
88
 
@@ -88,7 +97,6 @@ export function AnalyticsGate({
88
97
  : loadDirectAds
89
98
  ? googleAds.conversion_id
90
99
  : null
91
- const configureGa4 = loadGa4
92
100
  const configureAds = loadDirectAds
93
101
 
94
102
  return (
@@ -101,12 +109,6 @@ export function AnalyticsGate({
101
109
  />
102
110
  ) : null}
103
111
 
104
- {configureGa4 ? (
105
- <Script id="core-ga4-config" strategy="afterInteractive">
106
- {`gtag('js',new Date());gtag('config','${analytics.google_analytics.measurement_id}');`}
107
- </Script>
108
- ) : null}
109
-
110
112
  {configureAds ? (
111
113
  <Script id="core-google-ads-config" strategy="afterInteractive">
112
114
  {`gtag('config','${googleAds.conversion_id}',{'allow_ad_personalization_signals':${googleAds.remarketing_enabled ? "true" : "false"}});`}