@pradip1995/create-storefront-app 0.2.2 → 0.3.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 (53) hide show
  1. package/bin/create-storefront-app.js +149 -53
  2. package/lib/build-backend-package.js +54 -0
  3. package/lib/build-homepage-defaults.cjs +50 -0
  4. package/lib/deps.js +3 -1
  5. package/lib/docker-template-vars.js +32 -0
  6. package/lib/medusa-plugin-versions.json +55 -0
  7. package/lib/scaffold-backend.js +107 -0
  8. package/lib/scaffold-docker.js +82 -0
  9. package/lib/versions.js +4 -3
  10. package/package.json +3 -2
  11. package/templates/backend/.cursor/commands/seed-backend.md +16 -0
  12. package/templates/backend/.cursor/rules/medusa-backend.mdc +55 -0
  13. package/templates/backend/config/README.md +21 -0
  14. package/templates/backend/config/homepage-config.json +568 -0
  15. package/templates/backend/env.template +53 -0
  16. package/templates/backend/gitignore +8 -0
  17. package/templates/backend/medusa-config.full.ts +251 -0
  18. package/templates/backend/medusa-config.minimal.ts +141 -0
  19. package/templates/backend/scripts/build-dynamic-config-defaults.mjs +25 -0
  20. package/templates/backend/scripts/build-homepage-defaults.cjs +50 -0
  21. package/templates/backend/src/config/product-metadata-descriptors.ts +27 -0
  22. package/templates/backend/src/scripts/seed.ts +212 -0
  23. package/templates/backend/tsconfig.json +24 -0
  24. package/templates/docker/Makefile +86 -0
  25. package/templates/docker/backend/.dockerignore +8 -0
  26. package/templates/docker/backend/Dockerfile +30 -0
  27. package/templates/docker/data/README.md +12 -0
  28. package/templates/docker/data/dump.sql +3 -0
  29. package/templates/docker/docker/.env.example +36 -0
  30. package/templates/docker/docker/frontend.build.defaults +7 -0
  31. package/templates/docker/docker/gitignore +1 -0
  32. package/templates/docker/docker/postgres/01-create-postgres-role.sql +9 -0
  33. package/templates/docker/docker/postgres/docker-entrypoint-wrapper.sh +49 -0
  34. package/templates/docker/docker-compose.infra.yml +64 -0
  35. package/templates/docker/docker-compose.yml +138 -0
  36. package/templates/docker/storefront/.dockerignore +9 -0
  37. package/templates/docker/storefront/Dockerfile +53 -0
  38. package/templates/root/.cursor/commands/docker-dev.md +32 -0
  39. package/templates/root/.cursor/rules/monorepo-layout.mdc +55 -0
  40. package/templates/shared/.cursor/commands/change-theme-colors.md +28 -0
  41. package/templates/shared/.cursor/commands/fix-segment-issue.md +56 -0
  42. package/templates/shared/.cursor/commands/rebuild-storefront.md +19 -0
  43. package/templates/shared/.cursor/commands/update-home-sections.md +50 -0
  44. package/templates/shared/.cursor/rules/customize-sections.mdc +49 -0
  45. package/templates/shared/.cursor/rules/customize-theme.mdc +57 -0
  46. package/templates/shared/.cursor/rules/storefront-architecture.mdc +41 -0
  47. package/templates/shared/.cursor/skills/customize-storefront-theme/SKILL.md +47 -0
  48. package/templates/shared/.cursor/skills/fix-segment-issues/SKILL.md +68 -0
  49. package/templates/shared/.cursor/skills/update-storefront-sections/SKILL.md +52 -0
  50. package/templates/shared/README.md +100 -0
  51. package/templates/shared/root-gitignore +6 -0
  52. package/templates/shared/storefront-only-README.md +25 -0
  53. package/templates/shared/theme-overrides.css +16 -0
@@ -0,0 +1,9 @@
1
+ node_modules
2
+ .generated-app
3
+ .next
4
+ .git
5
+ .env
6
+ .env.*
7
+ npm-debug.log*
8
+ Dockerfile
9
+ .dockerignore
@@ -0,0 +1,53 @@
1
+ # syntax=docker/dockerfile:1
2
+
3
+ # Use slim (glibc) — Alpine musl sharp corrupts AVIF product images.
4
+ FROM node:24-slim AS builder
5
+
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ libvips42 \
8
+ libheif1 \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ WORKDIR /app
12
+
13
+ COPY package.json .npmrc ./
14
+ RUN npm install --prefer-offline --no-audit --legacy-peer-deps \
15
+ && npm rebuild sharp
16
+
17
+ COPY pages.config.json storefront.config.json theme-overrides.css ./
18
+ COPY public ./public/
19
+
20
+ RUN npm run storefront:build
21
+
22
+ WORKDIR /app/.generated-app
23
+
24
+ RUN npm install --prefer-offline --no-audit --legacy-peer-deps \
25
+ && npm rebuild sharp
26
+
27
+ RUN --mount=type=secret,id=frontend_defaults \
28
+ --mount=type=secret,id=app_env \
29
+ sh -c 'cat /run/secrets/frontend_defaults /run/secrets/app_env > .env.production' \
30
+ && npm run build \
31
+ && npm prune --omit=dev
32
+
33
+ FROM node:24-slim AS runner
34
+
35
+ RUN apt-get update && apt-get install -y --no-install-recommends \
36
+ libvips42 \
37
+ libheif1 \
38
+ && rm -rf /var/lib/apt/lists/*
39
+
40
+ WORKDIR /app
41
+
42
+ ENV NODE_ENV=production
43
+ ENV PORT=8000
44
+
45
+ COPY --from=builder /app/.generated-app/package.json ./package.json
46
+ COPY --from=builder /app/.generated-app/.next ./.next
47
+ COPY --from=builder /app/.generated-app/public ./public
48
+ COPY --from=builder /app/.generated-app/next.config.js ./next.config.js
49
+ COPY --from=builder /app/.generated-app/node_modules ./node_modules
50
+
51
+ EXPOSE 8000
52
+
53
+ CMD ["npm", "run", "start"]
@@ -0,0 +1,32 @@
1
+ # Docker dev
2
+
3
+ ## Full stack in Docker
4
+
5
+ ```bash
6
+ make up
7
+ make migrate
8
+ make seed
9
+ make admin-create
10
+ ```
11
+
12
+ ## Infra only + local Node
13
+
14
+ ```bash
15
+ make up-infra
16
+ npm run dev:backend # terminal 1
17
+ npm run dev:storefront # terminal 2
18
+ ```
19
+
20
+ ## After seed
21
+
22
+ Copy publishable API key into:
23
+
24
+ - `storefront/.env.local` (local dev)
25
+ - `docker/frontend.build.defaults` + rebuild storefront image (Docker)
26
+
27
+ ```bash
28
+ make build-storefront
29
+ make up-storefront
30
+ ```
31
+
32
+ Mailpit: http://localhost:8025
@@ -0,0 +1,55 @@
1
+ ---
2
+ description: Monorepo layout — backend + storefront dev workflow
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Project layout
7
+
8
+ ```
9
+ <project>/
10
+ backend/ Medusa v2 API + Admin
11
+ storefront/ Segment-based Next.js (config client)
12
+ ```
13
+
14
+ ## Dev (local Node)
15
+
16
+ ```bash
17
+ npm run dev:backend # terminal 1
18
+ npm run dev:storefront # terminal 2
19
+ ```
20
+
21
+ ## Dev (Docker)
22
+
23
+ ```bash
24
+ make up # full stack in containers
25
+ make up-infra # postgres + redis + mailpit only, then npm run dev:* locally
26
+ make migrate && make seed && make admin-create
27
+ ```
28
+
29
+ See `Makefile` and command `docker-dev`.
30
+
31
+ ## First-time backend
32
+
33
+ 1. Set `DATABASE_URL` in `backend/.env`
34
+ 2. `npm run dev:backend` (migrations)
35
+ 3. `npm run seed` (region, API key, sample product)
36
+ 4. Copy publishable key → `storefront/.env.local`
37
+
38
+ ## Build
39
+
40
+ ```bash
41
+ npm run build:backend
42
+ npm run build:storefront
43
+ ```
44
+
45
+ ## Where to edit
46
+
47
+ | Goal | Path |
48
+ |------|------|
49
+ | Medusa plugins / modules | `backend/medusa-config.ts` |
50
+ | Plugin npm versions | `backend/config/medusa-plugin-versions.json` |
51
+ | Homepage admin fields | `backend/config/homepage-config.json` (+ `npm run dynamic-config:defaults` in backend) |
52
+ | Storefront sections | `storefront/pages.config.json` |
53
+ | Brand colors | `storefront/theme-overrides.css` |
54
+
55
+ Cursor guides live in `backend/.cursor/` and `storefront/.cursor/`.
@@ -0,0 +1,28 @@
1
+ # Change theme, colors & fonts
2
+
3
+ ## Quick brand (no CSS)
4
+
5
+ 1. Edit `.env.local`:
6
+ - `NEXT_PUBLIC_SHOP_NAME`
7
+ - `NEXT_PUBLIC_HOME_PAGE_TITLE`
8
+ - `NEXT_PUBLIC_HOME_PAGE_DESCRIPTION`
9
+ 2. Add `public/logo.png` for nav/footer logo.
10
+ 3. `npm run storefront:build && npm run dev`
11
+
12
+ ## Colors & fonts (CSS variables)
13
+
14
+ 1. Open or create **`theme-overrides.css`** in the project root.
15
+ 2. Override `:root` variables (see `.cursor/rules/customize-theme.mdc`):
16
+ - Brand: `--color-brand-accent`, `--color-brand-accent-hover`, `--color-brand-pink`
17
+ - Text: `--color-text-heading`, `--color-text-body`, `--color-text-muted`
18
+ - Surfaces: `--color-page-bg`, `--color-footer-bg`, `--color-surface-muted`
19
+ - Fonts: `--font-sans`, `--font-heading`, `--font-display`
20
+ 3. Rebuild: `npm run storefront:build && npm run dev`
21
+
22
+ ## Hero & section content
23
+
24
+ Configure in **Medusa Admin** dynamic-config (`homepage-config`). Schema: `backend/config/homepage-config.json`.
25
+
26
+ ## Switch full theme preset (advanced)
27
+
28
+ Default build uses `impulse.css`. Switching to `valero.css` alone breaks hero/nav styling unless you fork `@pradip1995/segment-tokens`. Prefer `theme-overrides.css` for rebrand.
@@ -0,0 +1,56 @@
1
+ # Fix segment / UI issues
2
+
3
+ Work through this checklist before changing segment source code.
4
+
5
+ ## 1. Rebuild
6
+
7
+ ```bash
8
+ npm run storefront:build
9
+ npm run dev
10
+ ```
11
+
12
+ Never debug stale `.generated-app/` from an old build.
13
+
14
+ ## 2. Medusa connection
15
+
16
+ In `.env.local`:
17
+
18
+ - `NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY` must be a real `pk_...` key (not placeholder)
19
+ - `MEDUSA_BACKEND_URL` / `NEXT_PUBLIC_MEDUSA_BACKEND_URL` reachable
20
+ - `NEXT_PUBLIC_DEFAULT_REGION` matches a region in Medusa (e.g. `in`)
21
+
22
+ Symptoms of bad key: empty categories, "No new arrivals", generic "Store" fallback text, API 400 in terminal.
23
+
24
+ ## 3. Missing CSS / broken hero layout
25
+
26
+ Symptoms: hero is plain text, nav not transparent, sections unstyled.
27
+
28
+ - Confirm `.generated-app/app/layout.tsx` imports `themes/impulse.css`
29
+ - Add/fix `theme-overrides.css` only for colors — not layout
30
+ - Align package versions: `@pradip1995/framework-compiler@^0.2.2`, `@pradip1995/segment-tokens@^0.2.1`
31
+
32
+ ## 4. Missing images (404)
33
+
34
+ | Path | Fix |
35
+ |------|-----|
36
+ | `/theme-defaults/valero/logo.svg` | Add under `public/theme-defaults/valero/` |
37
+ | Hero images | Set in Medusa dynamic-config or env fallbacks |
38
+ | Product images | Medusa catalog / CDN allowlist in backend |
39
+
40
+ ## 5. Empty segment but API works
41
+
42
+ - Segment may need workflow data (e.g. new-arrivals needs products with tags)
43
+ - Check Medusa Admin dynamic-config for that section's fields
44
+ - Confirm `NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY` is set and backend `/store/dynamic-config` returns data
45
+
46
+ ## 6. Package version mismatch
47
+
48
+ ```bash
49
+ npm ls @pradip1995/framework-compiler @pradip1995/segment-tokens
50
+ ```
51
+
52
+ Bump to latest patch, reinstall, rebuild.
53
+
54
+ ## 7. Still broken
55
+
56
+ Inspect browser Network tab for 404/400. Check terminal Medusa SDK logs. Open issue on the specific `@pradip1995/segment-*` or `workflow-*` package — do not fork segment code into this client repo.
@@ -0,0 +1,19 @@
1
+ # Rebuild storefront
2
+
3
+ Run after any change to `pages.config.json`, `package.json`, `.env.local`, or `theme-overrides.css`.
4
+
5
+ ```bash
6
+ npm run storefront:build
7
+ npm run dev
8
+ ```
9
+
10
+ Or production:
11
+
12
+ ```bash
13
+ npm run build
14
+ npm run start
15
+ ```
16
+
17
+ **Do not** edit files inside `.generated-app/` — they are overwritten every build.
18
+
19
+ Verify build output lists your segments. Homepage content is loaded from Medusa Admin via `/store/dynamic-config`, not generated in the storefront build.
@@ -0,0 +1,50 @@
1
+ # Update home sections
2
+
3
+ ## Reorder or remove
4
+
5
+ Edit `pages.config.json` → route `/` → `segments` array.
6
+
7
+ ```json
8
+ "segments": [
9
+ "@pradip1995/segment-hero",
10
+ "@pradip1995/segment-new-arrivals",
11
+ "@pradip1995/segment-features"
12
+ ]
13
+ ```
14
+
15
+ Remove unused packages from `package.json`, then:
16
+
17
+ ```bash
18
+ npm install
19
+ npm run storefront:build
20
+ npm run dev
21
+ ```
22
+
23
+ ## Add a segment
24
+
25
+ 1. Pick package from `@pradip1995/segment-*` (npm).
26
+ 2. Add to `package.json` dependencies.
27
+ 3. Append to home `segments` in `pages.config.json`.
28
+ 4. `npm install && npm run storefront:build && npm run dev`
29
+
30
+ ## Available home segments (full preset)
31
+
32
+ - `segment-hero` — banner
33
+ - `segment-shop-by-category` — category grid
34
+ - `segment-new-arrivals` — product carousel
35
+ - `segment-promotional-banners` — promo tiles
36
+ - `segment-collections-showcase` — collection tabs
37
+ - `segment-why-choose-us` — feature icons
38
+ - `segment-bestsellers-carousel` — bestsellers
39
+ - `segment-reviews-marquee` — testimonials
40
+ - `segment-features` — trust strip
41
+
42
+ ## Metadata
43
+
44
+ Set page title/description on the home route:
45
+
46
+ ```json
47
+ "metadata": { "title": "Home", "description": "Welcome" }
48
+ ```
49
+
50
+ Rebuild to apply in `.generated-app`.
@@ -0,0 +1,49 @@
1
+ ---
2
+ description: Add, remove, or reorder homepage and page segments
3
+ globs: pages.config.json,package.json
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Customize sections
8
+
9
+ Sections are **npm segment packages** wired in `pages.config.json`.
10
+
11
+ ## Home page (`route: "/"`)
12
+
13
+ Each entry in `segments` renders top-to-bottom:
14
+
15
+ ```json
16
+ "segments": [
17
+ "@pradip1995/segment-hero",
18
+ "@pradip1995/segment-shop-by-category",
19
+ "@pradip1995/segment-new-arrivals"
20
+ ]
21
+ ```
22
+
23
+ **Reorder** — change array order, then `npm run storefront:build`.
24
+
25
+ **Remove** — delete the line and remove the package from `package.json` if unused elsewhere.
26
+
27
+ **Add** — see command `add-home-segment` or skill `update-storefront-sections`.
28
+
29
+ ## Other routes
30
+
31
+ | Route | Typical segments |
32
+ |-------|------------------|
33
+ | `/store` | mobile-filters, refinement-list, product-grid |
34
+ | `/products/[handle]` | product-gallery, product-info, product-actions, related-products |
35
+ | `/cart` | cart-item, cart-summary |
36
+ | `/checkout` | checkout-form, checkout-summary |
37
+
38
+ ## After changing segments
39
+
40
+ 1. Add dep to `package.json`: `"@pradip1995/segment-foo": "^0.2.2"`
41
+ 2. Run `npm install`
42
+ 3. Update `pages.config.json`
43
+ 4. Run `npm run storefront:build`
44
+
45
+ Build log lists segment count — verify your new segment appears.
46
+
47
+ ## Segment data
48
+
49
+ Each segment receives props from its route **workflow** (e.g. `workflow-home` loads hero, categories, products). If a segment renders empty, the workflow may not supply its data key — check Medusa backend + publishable key first.
@@ -0,0 +1,57 @@
1
+ ---
2
+ description: Change storefront colors, fonts, and theme CSS
3
+ globs: theme-overrides.css,public/**/*
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Customize theme, colors & fonts
8
+
9
+ ## Default stylesheet
10
+
11
+ Build imports `@pradip1995/segment-tokens/themes/impulse.css` (full segment UI: hero, nav, footer, carousels).
12
+
13
+ Alternate token presets (advanced — requires forking compiler import or publishing custom tokens):
14
+
15
+ - `themes/impulse.css` — burgundy/cream, Playfair + Montserrat (default)
16
+ - `themes/valero.css` — blue monochrome; **missing** many component class rules — not recommended alone
17
+
18
+ ## Brand colors & fonts (recommended)
19
+
20
+ Edit **`theme-overrides.css`** in the project root. Rebuild after changes.
21
+
22
+ ```css
23
+ :root {
24
+ --color-brand-accent: #5a2a43;
25
+ --color-brand-accent-hover: #723a56;
26
+ --color-brand-pink: #c68a8a;
27
+ --color-page-bg: #ffffff;
28
+ --color-footer-bg: #1a1a1a;
29
+ --color-text-heading: #1a1a1a;
30
+ --color-text-body: #4d4d4d;
31
+ --font-sans: "Montserrat", sans-serif;
32
+ --font-heading: "Playfair Display", serif;
33
+ --font-display: "Playfair Display", serif;
34
+ }
35
+ ```
36
+
37
+ Common variables: `--color-brand-*`, `--color-text-*`, `--color-surface-*`, `--color-promo-*`, `--font-sans`, `--font-heading`, `--header-height`, `--container-max`.
38
+
39
+ ## Logo & hero images
40
+
41
+ | Asset | Location |
42
+ |-------|----------|
43
+ | Logo | `public/logo.png` or Medusa dynamic-config logo field |
44
+ | Hero fallback | `public/theme-defaults/valero/hero-desktop.svg` (override same path) |
45
+ | Favicon | `public/favicon.ico` |
46
+
47
+ Env copy for hero when Medusa config is empty:
48
+
49
+ ```bash
50
+ NEXT_PUBLIC_SHOP_NAME=My Shop
51
+ NEXT_PUBLIC_HOME_PAGE_TITLE=Headline
52
+ NEXT_PUBLIC_HOME_PAGE_DESCRIPTION=Subtext
53
+ ```
54
+
55
+ ## Medusa admin content
56
+
57
+ Hero banners, promo text, testimonials, features → Medusa **dynamic-config** (`homepage-config`). Edit schema in `backend/config/homepage-config.json`; storefront loads values from `GET /store/dynamic-config`.
@@ -0,0 +1,41 @@
1
+ ---
2
+ description: Config-only Medusa storefront — structure, build flow, what not to edit
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Storefront architecture
7
+
8
+ This folder (`storefront/`) is a **config client**, not a hand-written Next.js app. The Medusa backend lives in `../backend/`.
9
+
10
+ ## You edit (client root)
11
+
12
+ | File | Purpose |
13
+ |------|---------|
14
+ | `pages.config.json` | Routes, workflows, layouts, home/product segments |
15
+ | `storefront.config.json` | Region, loader |
16
+ | `package.json` | npm deps on `@pradip1995/*` segments/workflows |
17
+ | `.env.local` | Medusa URL, publishable key, shop name, hero copy |
18
+ | `public/` | Logo, favicon, brand static files |
19
+ | `theme-overrides.css` | Brand colors & fonts (CSS variables) |
20
+
21
+ ## Generated (do not hand-edit)
22
+
23
+ | Path | Purpose |
24
+ |------|---------|
25
+ | `.generated-app/` | Full Next.js app from `storefront-build` |
26
+
27
+ Homepage content (hero, promo, logo, etc.) is **not** generated here — it comes from Medusa `GET /store/dynamic-config`. Schema lives in `../backend/config/homepage-config.json`.
28
+
29
+ After any change to config, deps, or `theme-overrides.css`:
30
+
31
+ ```bash
32
+ npm run storefront:build
33
+ npm run dev
34
+ ```
35
+
36
+ ## Rules
37
+
38
+ - Never commit secrets from `.env.local`
39
+ - Never edit `.generated-app/` — changes are overwritten on rebuild
40
+ - Segment logic lives in npm packages; fix bugs there + publish, not copy-paste into this repo
41
+ - URL pattern: `http://localhost:8000/<NEXT_PUBLIC_DEFAULT_REGION>/...`
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: customize-storefront-theme
3
+ description: Change storefront colors, fonts, logo, and hero branding in a config-only @pradip1995 create-storefront-app project. Use when the user asks to rebrand, change theme, update colors, fonts, logo, or hero styling.
4
+ ---
5
+
6
+ # Customize storefront theme
7
+
8
+ ## When to use
9
+
10
+ User wants to change look-and-feel of a scaffolded storefront (not the medusa-storefront-kit theme package).
11
+
12
+ ## Workflow
13
+
14
+ 1. Read `.cursor/rules/customize-theme.mdc` and `theme-overrides.css` if present.
15
+ 2. **Content/branding text** → `.env.local`:
16
+ - `NEXT_PUBLIC_SHOP_NAME`
17
+ - `NEXT_PUBLIC_HOME_PAGE_TITLE`
18
+ - `NEXT_PUBLIC_HOME_PAGE_DESCRIPTION`
19
+ 3. **Logo** → `public/logo.png` or Medusa dynamic-config logo.
20
+ 4. **Colors & fonts** → edit `theme-overrides.css` at project root:
21
+
22
+ ```css
23
+ :root {
24
+ --color-brand-accent: #YOUR_BRAND;
25
+ --color-brand-accent-hover: #YOUR_BRAND_DARK;
26
+ --color-text-heading: #1a1a1a;
27
+ --font-sans: "Your Font", sans-serif;
28
+ --font-heading: "Your Display Font", serif;
29
+ }
30
+ ```
31
+
32
+ 5. Always run after CSS/env changes:
33
+
34
+ ```bash
35
+ npm run storefront:build
36
+ npm run dev
37
+ ```
38
+
39
+ ## Do not
40
+
41
+ - Edit `.generated-app/` directly
42
+ - Switch to `valero.css` alone (breaks hero/nav component CSS)
43
+ - Put secrets in committed files
44
+
45
+ ## Medusa content
46
+
47
+ Hero images and promo copy often come from Medusa **dynamic-config** (`homepage-config`), not from this repo. Point user to Medusa Admin if content is wrong but styling is fine.
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: fix-segment-issues
3
+ description: Diagnose and fix broken storefront segments, missing CSS, empty sections, 404 assets, or Medusa API errors in a create-storefront-app project. Use when hero looks wrong, sections unstyled, or data not loading.
4
+ ---
5
+
6
+ # Fix segment issues
7
+
8
+ ## When to use
9
+
10
+ User reports: broken hero, no CSS, empty sections, 404 images, or storefront not matching demo-store.
11
+
12
+ ## Diagnosis order
13
+
14
+ ### 1. Stale build
15
+
16
+ ```bash
17
+ npm run storefront:build
18
+ npm run dev
19
+ ```
20
+
21
+ ### 2. API key / backend
22
+
23
+ Check `.env.local`:
24
+
25
+ - `NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY` is valid `pk_...`
26
+ - Backend URL correct and running
27
+ - `NEXT_PUBLIC_DEFAULT_REGION` exists in Medusa
28
+
29
+ Terminal symptom: repeated `Received response with status 400`.
30
+
31
+ ### 3. Missing CSS
32
+
33
+ Check `.generated-app/app/layout.tsx` imports:
34
+
35
+ ```tsx
36
+ import "@pradip1995/segment-tokens/themes/impulse.css"
37
+ ```
38
+
39
+ If it imports only `theme.css` without full impulse rules, upgrade `@pradip1995/framework-compiler` to `^0.2.2` and rebuild.
40
+
41
+ Symptom: hero shows raw text, nav not styled, shop-by-category flat.
42
+
43
+ ### 4. Missing static assets
44
+
45
+ 404 on `/theme-defaults/valero/*.svg` → add files under `public/theme-defaults/valero/` or upgrade `@pradip1995/segment-assets@^0.2.1`.
46
+
47
+ ### 5. Empty segment with working API
48
+
49
+ - Products needed for carousels (catalog + region)
50
+ - Dynamic-config in Medusa for hero/testimonials
51
+ - Confirm backend is running and `/store/dynamic-config` returns expected JSON
52
+
53
+ ### 6. Version drift
54
+
55
+ Align framework + components patch versions, reinstall, rebuild:
56
+
57
+ ```bash
58
+ npm install @pradip1995/framework-compiler@^0.2.2 @pradip1995/segment-tokens@^0.2.1
59
+ npm run storefront:build
60
+ ```
61
+
62
+ ## Fix in packages, not client
63
+
64
+ Logic bugs in `@pradip1995/segment-*` or `workflow-*` → fix upstream repo, publish npm, bump dep here.
65
+
66
+ ## Reference
67
+
68
+ See `.cursor/commands/fix-segment-issue.md` for full checklist.
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: update-storefront-sections
3
+ description: Add, remove, or reorder homepage and page segments in pages.config.json for a config-only Medusa storefront. Use when changing home sections, adding segments, or updating page composition.
4
+ ---
5
+
6
+ # Update storefront sections
7
+
8
+ ## When to use
9
+
10
+ User wants to change which blocks appear on home, store, PDP, cart, etc.
11
+
12
+ ## Workflow
13
+
14
+ 1. Read `pages.config.json` for the target route.
15
+ 2. Home sections = `segments` array on `"route": "/"`.
16
+ 3. To **reorder** — rearrange array entries.
17
+ 4. To **remove** — delete entry; remove unused dep from `package.json`.
18
+ 5. To **add**:
19
+ - Add `"@pradip1995/segment-<name>": "^0.2.2"` to `package.json`
20
+ - Append package name to route's `segments`
21
+ - `npm install`
22
+ 6. Rebuild:
23
+
24
+ ```bash
25
+ npm run storefront:build
26
+ npm run dev
27
+ ```
28
+
29
+ ## Common home segments
30
+
31
+ | Package | Purpose |
32
+ |---------|---------|
33
+ | segment-hero | Main banner |
34
+ | segment-shop-by-category | Category cards |
35
+ | segment-new-arrivals | New products carousel |
36
+ | segment-promotional-banners | Promo tiles |
37
+ | segment-collections-showcase | Collection slider |
38
+ | segment-why-choose-us | USP icons |
39
+ | segment-bestsellers-carousel | Bestsellers |
40
+ | segment-reviews-marquee | Testimonials |
41
+ | segment-features | Trust strip |
42
+
43
+ ## Verify
44
+
45
+ - Build log shows expected segment count
46
+ - Dev server home page renders new block
47
+ - If empty data, check workflow + Medusa (not just config)
48
+
49
+ ## Do not
50
+
51
+ - Copy segment source into this repo
52
+ - Edit `.generated-app/app/**/page.tsx` manually