@pradip1995/create-storefront-app 0.2.3 → 0.3.1
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/bin/create-storefront-app.js +147 -59
- package/lib/build-backend-package.js +54 -0
- package/lib/build-homepage-defaults.cjs +50 -0
- package/lib/deps.js +3 -1
- package/lib/docker-template-vars.js +32 -0
- package/lib/medusa-plugin-versions.json +55 -0
- package/lib/scaffold-backend.js +107 -0
- package/lib/scaffold-docker.js +82 -0
- package/lib/versions.js +4 -3
- package/package.json +3 -2
- package/templates/backend/.cursor/commands/seed-backend.md +21 -0
- package/templates/backend/.cursor/rules/medusa-backend.mdc +54 -0
- package/templates/backend/config/README.md +23 -0
- package/templates/backend/config/homepage-config.json +568 -0
- package/templates/backend/env.template +53 -0
- package/templates/backend/gitignore +8 -0
- package/templates/backend/medusa-config.full.ts +251 -0
- package/templates/backend/medusa-config.minimal.ts +141 -0
- package/templates/backend/scripts/build-dynamic-config-defaults.mjs +25 -0
- package/templates/backend/scripts/build-homepage-defaults.cjs +50 -0
- package/templates/backend/src/config/product-metadata-descriptors.ts +27 -0
- package/templates/backend/src/scripts/seed.ts +210 -0
- package/templates/backend/tsconfig.json +24 -0
- package/templates/docker/Makefile +88 -0
- package/templates/docker/backend/.dockerignore +8 -0
- package/templates/docker/backend/Dockerfile +30 -0
- package/templates/docker/data/README.md +12 -0
- package/templates/docker/data/dump.sql +3 -0
- package/templates/docker/docker/.env.example +36 -0
- package/templates/docker/docker/frontend.build.defaults +7 -0
- package/templates/docker/docker/gitignore +1 -0
- package/templates/docker/docker/postgres/01-create-postgres-role.sql +9 -0
- package/templates/docker/docker/postgres/docker-entrypoint-wrapper.sh +49 -0
- package/templates/docker/docker-compose.infra.yml +64 -0
- package/templates/docker/docker-compose.yml +138 -0
- package/templates/docker/storefront/.dockerignore +9 -0
- package/templates/docker/storefront/Dockerfile +53 -0
- package/templates/root/.cursor/commands/docker-dev.md +27 -0
- package/templates/root/.cursor/rules/monorepo-layout.mdc +55 -0
- package/templates/root/scripts/sync-publishable-key.mjs +108 -0
- package/templates/shared/.cursor/commands/change-theme-colors.md +1 -1
- package/templates/shared/.cursor/commands/fix-segment-issue.md +2 -2
- package/templates/shared/.cursor/commands/rebuild-storefront.md +1 -1
- package/templates/shared/.cursor/rules/customize-sections.mdc +7 -1
- package/templates/shared/.cursor/rules/customize-theme.mdc +1 -1
- package/templates/shared/.cursor/rules/storefront-architecture.mdc +3 -2
- package/templates/shared/.cursor/skills/fix-segment-issues/SKILL.md +1 -1
- package/templates/shared/README.md +100 -0
- package/templates/shared/root-gitignore +6 -0
- package/templates/shared/storefront-only-README.md +25 -0
|
@@ -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,27 @@
|
|
|
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
|
+
`make seed` runs Medusa seed unchanged, then `scripts/sync-publishable-key.mjs` reads the token from Postgres and updates:
|
|
23
|
+
|
|
24
|
+
- `storefront/.env.local`
|
|
25
|
+
- `docker/.env` and `docker/frontend.build.defaults` (when using Docker)
|
|
26
|
+
|
|
27
|
+
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. Run `npm run seed` from project root (syncs publishable key to `storefront/.env.local` via Postgres)
|
|
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,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Sync NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY into storefront/.env.local and docker env files.
|
|
4
|
+
* Does not modify Medusa backend — reads the token from Postgres after seed.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* node scripts/sync-publishable-key.mjs --from-db
|
|
8
|
+
* node scripts/sync-publishable-key.mjs pk_abc123...
|
|
9
|
+
* echo pk_abc... | node scripts/sync-publishable-key.mjs --stdin
|
|
10
|
+
*/
|
|
11
|
+
import { execSync } from "child_process"
|
|
12
|
+
import { existsSync, readFileSync, writeFileSync } from "fs"
|
|
13
|
+
import { dirname, join } from "path"
|
|
14
|
+
import { fileURLToPath } from "url"
|
|
15
|
+
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
17
|
+
const projectRoot = join(__dirname, "..")
|
|
18
|
+
const ENV_KEY = "NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY"
|
|
19
|
+
|
|
20
|
+
const SQL = `SELECT token FROM api_key WHERE type = 'publishable' AND deleted_at IS NULL AND revoked_at IS NULL ORDER BY created_at DESC LIMIT 1`
|
|
21
|
+
|
|
22
|
+
function upsertEnvLine(content, key, value) {
|
|
23
|
+
const line = `${key}=${value}`
|
|
24
|
+
const regex = new RegExp(`^${key}=.*$`, "m")
|
|
25
|
+
if (regex.test(content)) return content.replace(regex, line)
|
|
26
|
+
return `${content.replace(/\n?$/, "")}\n${line}\n`
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function updateEnvFile(filePath, token) {
|
|
30
|
+
if (!existsSync(filePath)) return false
|
|
31
|
+
writeFileSync(filePath, upsertEnvLine(readFileSync(filePath, "utf8"), ENV_KEY, token))
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseEnvFile(path) {
|
|
36
|
+
if (!existsSync(path)) return {}
|
|
37
|
+
const vars = {}
|
|
38
|
+
for (const line of readFileSync(path, "utf8").split("\n")) {
|
|
39
|
+
const m = line.match(/^([A-Z0-9_]+)=(.*)$/)
|
|
40
|
+
if (m) vars[m[1]] = m[2]
|
|
41
|
+
}
|
|
42
|
+
return vars
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function readDatabaseUrl() {
|
|
46
|
+
const backendEnv = join(projectRoot, "backend", ".env")
|
|
47
|
+
const vars = parseEnvFile(backendEnv)
|
|
48
|
+
return vars.DATABASE_URL || process.env.DATABASE_URL || null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function queryTokenViaPsql(databaseUrl) {
|
|
52
|
+
const out = execSync(`psql "${databaseUrl}" -tAc "${SQL}"`, {
|
|
53
|
+
encoding: "utf8",
|
|
54
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
55
|
+
})
|
|
56
|
+
return out.trim()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isValidToken(token) {
|
|
60
|
+
return typeof token === "string" && token.startsWith("pk_") && !token.includes("...")
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function resolveToken() {
|
|
64
|
+
const args = process.argv.slice(2)
|
|
65
|
+
|
|
66
|
+
if (args.includes("--stdin")) {
|
|
67
|
+
const fromStdin = readFileSync(0, "utf8").trim()
|
|
68
|
+
if (isValidToken(fromStdin)) return fromStdin
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const positional = args.filter((a) => !a.startsWith("--"))
|
|
72
|
+
if (positional[0] && isValidToken(positional[0])) return positional[0]
|
|
73
|
+
|
|
74
|
+
if (args.includes("--from-db") || args.length === 0) {
|
|
75
|
+
const databaseUrl = readDatabaseUrl()
|
|
76
|
+
if (!databaseUrl) {
|
|
77
|
+
throw new Error("DATABASE_URL not found in backend/.env")
|
|
78
|
+
}
|
|
79
|
+
const token = queryTokenViaPsql(databaseUrl)
|
|
80
|
+
if (isValidToken(token)) return token
|
|
81
|
+
throw new Error("No publishable API key in database — run seed first")
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
throw new Error("Pass pk_ token, --stdin, or --from-db")
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
const token = resolveToken()
|
|
89
|
+
const targets = [
|
|
90
|
+
join(projectRoot, "storefront", ".env.local"),
|
|
91
|
+
join(projectRoot, "docker", ".env"),
|
|
92
|
+
join(projectRoot, "docker", "frontend.build.defaults"),
|
|
93
|
+
]
|
|
94
|
+
const updated = targets.filter((p) => updateEnvFile(p, token))
|
|
95
|
+
|
|
96
|
+
if (updated.length === 0) {
|
|
97
|
+
console.error("sync-publishable-key: no env files updated (storefront/.env.local missing?)")
|
|
98
|
+
process.exit(1)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log("sync-publishable-key: set NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY in:")
|
|
102
|
+
for (const p of updated) {
|
|
103
|
+
console.log(` ${p.replace(`${projectRoot}/`, "")}`)
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error(`sync-publishable-key: ${error.message}`)
|
|
107
|
+
process.exit(1)
|
|
108
|
+
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
## Hero & section content
|
|
23
23
|
|
|
24
|
-
Configure in **Medusa Admin** dynamic-config (`homepage-config`)
|
|
24
|
+
Configure in **Medusa Admin** dynamic-config (`homepage-config`). Schema: `backend/config/homepage-config.json`.
|
|
25
25
|
|
|
26
26
|
## Switch full theme preset (advanced)
|
|
27
27
|
|
|
@@ -40,8 +40,8 @@ Symptoms: hero is plain text, nav not transparent, sections unstyled.
|
|
|
40
40
|
## 5. Empty segment but API works
|
|
41
41
|
|
|
42
42
|
- Segment may need workflow data (e.g. new-arrivals needs products with tags)
|
|
43
|
-
- Check Medusa dynamic-config for that section's fields
|
|
44
|
-
-
|
|
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
45
|
|
|
46
46
|
## 6. Package version mismatch
|
|
47
47
|
|
|
@@ -16,4 +16,4 @@ npm run start
|
|
|
16
16
|
|
|
17
17
|
**Do not** edit files inside `.generated-app/` — they are overwritten every build.
|
|
18
18
|
|
|
19
|
-
Verify build output
|
|
19
|
+
Verify build output lists your segments. Homepage content is loaded from Medusa Admin via `/store/dynamic-config`, not generated in the storefront build.
|
|
@@ -20,7 +20,13 @@ Each entry in `segments` renders top-to-bottom:
|
|
|
20
20
|
]
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
**Reorder
|
|
23
|
+
**Reorder / add / remove sections** — edit `pages.config.json`, then:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run storefront:build
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This regenerates the Next.js app **and** syncs `backend/config/homepage-config.json` (Admin fields for your active segments). Restart the backend after schema changes.
|
|
24
30
|
|
|
25
31
|
**Remove** — delete the line and remove the package from `package.json` if unused elsewhere.
|
|
26
32
|
|
|
@@ -54,4 +54,4 @@ NEXT_PUBLIC_HOME_PAGE_DESCRIPTION=Subtext
|
|
|
54
54
|
|
|
55
55
|
## Medusa admin content
|
|
56
56
|
|
|
57
|
-
Hero banners, promo text, testimonials, features → Medusa **dynamic-config** (`homepage-config`).
|
|
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`.
|
|
@@ -5,7 +5,7 @@ alwaysApply: true
|
|
|
5
5
|
|
|
6
6
|
# Storefront architecture
|
|
7
7
|
|
|
8
|
-
This
|
|
8
|
+
This folder (`storefront/`) is a **config client**, not a hand-written Next.js app. The Medusa backend lives in `../backend/`.
|
|
9
9
|
|
|
10
10
|
## You edit (client root)
|
|
11
11
|
|
|
@@ -23,7 +23,8 @@ This project is a **config client**, not a hand-written Next.js app.
|
|
|
23
23
|
| Path | Purpose |
|
|
24
24
|
|------|---------|
|
|
25
25
|
| `.generated-app/` | Full Next.js app from `storefront-build` |
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
Homepage content (hero, promo, logo, etc.) comes from Medusa `GET /store/dynamic-config`. The **schema** in `../backend/config/homepage-config.json` is updated automatically when you run `npm run storefront:build` after changing `pages.config.json`.
|
|
27
28
|
|
|
28
29
|
After any change to config, deps, or `theme-overrides.css`:
|
|
29
30
|
|
|
@@ -48,7 +48,7 @@ Symptom: hero shows raw text, nav not styled, shop-by-category flat.
|
|
|
48
48
|
|
|
49
49
|
- Products needed for carousels (catalog + region)
|
|
50
50
|
- Dynamic-config in Medusa for hero/testimonials
|
|
51
|
-
-
|
|
51
|
+
- Confirm backend is running and `/store/dynamic-config` returns expected JSON
|
|
52
52
|
|
|
53
53
|
### 6. Version drift
|
|
54
54
|
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# {{PROJECT_NAME}}
|
|
2
|
+
|
|
3
|
+
Full-stack Medusa shop: **backend** (Medusa v2) + **storefront** (segment-based Next.js).
|
|
4
|
+
|
|
5
|
+
Run **with Docker**, **Docker infra + local Node**, or **fully local** (PostgreSQL + Redis on host).
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- **Node.js 20+**
|
|
10
|
+
- **npm 9+**
|
|
11
|
+
- **Docker Desktop** (optional — for `make up` / `make up-infra`)
|
|
12
|
+
- **PostgreSQL + Redis** on host when running fully local without Docker infra
|
|
13
|
+
|
|
14
|
+
All `@pradip1995/*` packages and Medusa plugins resolve from the **public npm registry** — no monorepo or private registry required.
|
|
15
|
+
|
|
16
|
+
## Option A — Full stack in Docker
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
make env-init # docker/.env from example (already created on scaffold)
|
|
20
|
+
make up # build + start postgres, redis, mailpit, backend, storefront
|
|
21
|
+
make migrate # DB migrations (fresh DB may need two runs)
|
|
22
|
+
make seed # region, publishable key, sample product
|
|
23
|
+
make admin-create
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Service | URL |
|
|
27
|
+
|------------|-----|
|
|
28
|
+
| Storefront | {{BASE_URL}}/{{DEFAULT_REGION}} |
|
|
29
|
+
| Admin | {{BACKEND_URL}}/app |
|
|
30
|
+
| API | {{BACKEND_URL}} |
|
|
31
|
+
| Mailpit | http://localhost:8025 |
|
|
32
|
+
|
|
33
|
+
After `make seed` or `npm run seed`, the publishable key is read from Postgres and written to `storefront/.env.local` and `docker/` env files (no backend code changes).
|
|
34
|
+
|
|
35
|
+
Default admin: `make admin-create` (see `Makefile` for `ADMIN_EMAIL` / `ADMIN_PASSWORD`).
|
|
36
|
+
|
|
37
|
+
## Option B — Docker infra + local Node dev
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
make up-infra # postgres, redis, mailpit only
|
|
41
|
+
npm run dev:backend # terminal 1 — uses backend/.env DATABASE_URL
|
|
42
|
+
npm run seed # from project root, or cd backend && npm run seed
|
|
43
|
+
npm run dev:storefront # terminal 2
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`backend/.env` `DATABASE_URL` matches Docker postgres credentials from scaffold.
|
|
47
|
+
|
|
48
|
+
For OTP/email in local backend with infra Docker, set `SMTP_HOST=localhost` and `SMTP_PORT=1025` (Mailpit exposes SMTP when using `docker-compose.infra.yml`).
|
|
49
|
+
|
|
50
|
+
## Option C — Fully local (no Docker)
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cd backend && npm install
|
|
54
|
+
# Edit .env — PostgreSQL + Redis on localhost
|
|
55
|
+
npm run dev
|
|
56
|
+
npm run seed
|
|
57
|
+
|
|
58
|
+
cd ../storefront && npm install
|
|
59
|
+
# Edit .env.local — publishable key from Admin
|
|
60
|
+
npm run dev
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Daily dev (local Node)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm run dev:backend # terminal 1
|
|
67
|
+
npm run dev:storefront # terminal 2
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Build production
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm run build:backend
|
|
74
|
+
npm run build:storefront
|
|
75
|
+
# or
|
|
76
|
+
make build
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Docker commands
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
make help # all targets
|
|
83
|
+
make up-infra # postgres + redis + mailpit
|
|
84
|
+
make up-backend # infra + backend container
|
|
85
|
+
make logs # tail logs
|
|
86
|
+
make db-shell # psql
|
|
87
|
+
make clean # remove containers + volumes
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Customize
|
|
91
|
+
|
|
92
|
+
| Goal | Where |
|
|
93
|
+
|------|--------|
|
|
94
|
+
| Home sections | `storefront/pages.config.json` |
|
|
95
|
+
| Colors / fonts | `storefront/theme-overrides.css` |
|
|
96
|
+
| Medusa plugins | `backend/medusa-config.ts` + `backend/config/medusa-plugin-versions.json` |
|
|
97
|
+
| Homepage admin fields | `backend/config/homepage-config.json` (auto-synced on `storefront:build`) |
|
|
98
|
+
| Docker secrets | `docker/.env` |
|
|
99
|
+
|
|
100
|
+
Cursor guides: `.cursor/` in each folder.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# {{PROJECT_NAME}}
|
|
2
|
+
|
|
3
|
+
Segment-based Medusa storefront (config client).
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install
|
|
9
|
+
# Edit .env.local — Medusa URL + publishable key
|
|
10
|
+
npm run dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Storefront: {{BASE_URL}}/{{DEFAULT_REGION}}
|
|
14
|
+
|
|
15
|
+
## Customize
|
|
16
|
+
|
|
17
|
+
| Goal | File |
|
|
18
|
+
|------|------|
|
|
19
|
+
| Home sections | `pages.config.json` |
|
|
20
|
+
| Colors / fonts | `theme-overrides.css` |
|
|
21
|
+
| Brand assets | `public/` |
|
|
22
|
+
|
|
23
|
+
After config changes: `npm run storefront:build && npm run dev`
|
|
24
|
+
|
|
25
|
+
Cursor guides: `.cursor/`
|