@pradip1995/create-storefront-app 0.3.1 → 0.4.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 +1 -0
- package/lib/docker-template-vars.js +1 -1
- package/lib/medusa-plugin-versions.json +2 -1
- package/lib/scaffold-backend.js +61 -42
- package/lib/versions.js +1 -1
- package/package.json +1 -1
- package/templates/backend/.cursor/rules/medusa-backend.mdc +20 -25
- package/templates/backend/README.md +27 -0
- package/templates/backend/config/README.md +20 -14
- package/templates/backend/env.template +2 -2
- package/templates/backend/gitignore +1 -0
- package/templates/docker/backend/Dockerfile +12 -7
- package/templates/docker/docker-compose.infra.yml +1 -1
- package/templates/docker/docker-compose.yml +1 -1
- package/templates/root/.cursor/rules/monorepo-layout.mdc +16 -11
- package/templates/shared/.cursor/rules/customize-sections.mdc +1 -1
- package/templates/shared/.cursor/rules/customize-theme.mdc +1 -1
- package/templates/shared/.cursor/rules/storefront-architecture.mdc +1 -1
- package/templates/shared/README.md +8 -6
- package/templates/shared/root-gitignore +2 -0
|
@@ -195,6 +195,7 @@ function scaffoldProject(args) {
|
|
|
195
195
|
"storefront:build": "npm run storefront:build --prefix storefront",
|
|
196
196
|
"dev:backend": "npm run dev --prefix backend",
|
|
197
197
|
"build:backend": "npm run build --prefix backend",
|
|
198
|
+
"migrate:backend": "npm run db:migrate --prefix backend",
|
|
198
199
|
seed: "npm run seed --prefix backend && node scripts/sync-publishable-key.mjs --from-db",
|
|
199
200
|
},
|
|
200
201
|
}
|
|
@@ -23,7 +23,7 @@ export function buildDockerTemplateVars(args) {
|
|
|
23
23
|
BACKEND_URL: args.backendUrl,
|
|
24
24
|
BASE_URL: args.baseUrl,
|
|
25
25
|
DEFAULT_REGION: args.defaultRegion,
|
|
26
|
-
DATABASE_URL: `postgres://${postgresUser}:${postgresPassword}@localhost:
|
|
26
|
+
DATABASE_URL: `postgres://${postgresUser}:${postgresPassword}@localhost:5433/${postgresDb}?sslmode=disable`,
|
|
27
27
|
DATABASE_URL_DOCKER: `postgres://${postgresUser}:${postgresPassword}@postgres:5432/${postgresDb}?sslmode=disable`,
|
|
28
28
|
PUBLISHABLE_KEY: args.publishableKey || "pk_test",
|
|
29
29
|
ADMIN_EMAIL: `admin@${slug}.local`,
|
package/lib/scaffold-backend.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs"
|
|
2
2
|
import { join, dirname } from "path"
|
|
3
3
|
import { fileURLToPath } from "url"
|
|
4
|
-
import {
|
|
4
|
+
import { buildBackendDependencies, VERSIONS } from "./build-backend-package.js"
|
|
5
5
|
import { buildDockerTemplateVars } from "./docker-template-vars.js"
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const require = createRequire(import.meta.url)
|
|
9
|
-
const { buildHomepageConfigDefaults } = require("./build-homepage-defaults.cjs")
|
|
6
|
+
import { FRAMEWORK_COMPILER_VERSION } from "./versions.js"
|
|
10
7
|
|
|
11
8
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
12
9
|
const PKG_ROOT = join(__dirname, "..")
|
|
13
|
-
const
|
|
10
|
+
const BACKEND_CURSOR = join(PKG_ROOT, "templates", "backend", ".cursor")
|
|
14
11
|
|
|
15
12
|
const REGION_CURRENCY = {
|
|
16
13
|
in: { currency: "inr", name: "India" },
|
|
@@ -32,6 +29,16 @@ function regionMeta(defaultRegion) {
|
|
|
32
29
|
)
|
|
33
30
|
}
|
|
34
31
|
|
|
32
|
+
function buildPluginsConfig(preset) {
|
|
33
|
+
const { medusa, plugins } = buildBackendDependencies(preset)
|
|
34
|
+
return { medusa, plugins }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function writeJson(path, data) {
|
|
38
|
+
writeFileSync(path, `${JSON.stringify(data, null, 2)}\n`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Scaffold config-only backend/ — Medusa source is generated by backend-build. */
|
|
35
42
|
export function scaffoldBackend(backendRoot, args) {
|
|
36
43
|
const { preset, name, backendUrl, baseUrl, defaultRegion } = args
|
|
37
44
|
const meta = regionMeta(defaultRegion)
|
|
@@ -51,56 +58,68 @@ export function scaffoldBackend(backendRoot, args) {
|
|
|
51
58
|
|
|
52
59
|
mkdirSync(backendRoot, { recursive: true })
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
preset
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
cpSync(join(BACKEND_TEMPLATE, "gitignore"), join(backendRoot, ".gitignore"))
|
|
62
|
-
cpSync(join(PKG_ROOT, "templates/shared/npmrc"), join(backendRoot, ".npmrc"))
|
|
63
|
-
cpSync(join(BACKEND_TEMPLATE, "config"), join(backendRoot, "config"), { recursive: true })
|
|
64
|
-
cpSync(join(BACKEND_TEMPLATE, "src"), join(backendRoot, "src"), { recursive: true })
|
|
65
|
-
cpSync(join(BACKEND_TEMPLATE, "scripts"), join(backendRoot, "scripts"), { recursive: true })
|
|
66
|
-
|
|
67
|
-
const homepageSchema = JSON.parse(
|
|
68
|
-
readFileSync(join(backendRoot, "config/homepage-config.json"), "utf8")
|
|
69
|
-
)
|
|
70
|
-
writeFileSync(
|
|
71
|
-
join(backendRoot, "config/homepage-config.defaults.json"),
|
|
72
|
-
`${JSON.stringify(buildHomepageConfigDefaults(homepageSchema), null, 2)}\n`
|
|
73
|
-
)
|
|
61
|
+
writeJson(join(backendRoot, "backend.config.json"), {
|
|
62
|
+
preset,
|
|
63
|
+
projectName: name,
|
|
64
|
+
defaultRegion,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
writeJson(join(backendRoot, "plugins.config.json"), buildPluginsConfig(preset))
|
|
74
68
|
|
|
75
69
|
writeFileSync(
|
|
76
|
-
join(backendRoot, "
|
|
77
|
-
|
|
70
|
+
join(backendRoot, ".gitignore"),
|
|
71
|
+
readFileSync(join(PKG_ROOT, "templates/backend/gitignore"), "utf8")
|
|
78
72
|
)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
readFileSync(join(
|
|
82
|
-
templateVars
|
|
73
|
+
writeFileSync(
|
|
74
|
+
join(backendRoot, ".npmrc"),
|
|
75
|
+
readFileSync(join(PKG_ROOT, "templates/shared/npmrc"), "utf8")
|
|
83
76
|
)
|
|
84
|
-
mkdirSync(join(backendRoot, "src/scripts"), { recursive: true })
|
|
85
|
-
writeFileSync(join(backendRoot, "src/scripts/seed.ts"), seedContent)
|
|
86
77
|
|
|
78
|
+
const envTemplate = join(PKG_ROOT, "templates/backend/env.template")
|
|
87
79
|
writeFileSync(
|
|
88
80
|
join(backendRoot, ".env.template"),
|
|
89
|
-
applyTemplate(readFileSync(
|
|
81
|
+
applyTemplate(readFileSync(envTemplate, "utf8"), templateVars)
|
|
90
82
|
)
|
|
91
83
|
writeFileSync(
|
|
92
84
|
join(backendRoot, ".env"),
|
|
93
|
-
applyTemplate(readFileSync(
|
|
85
|
+
applyTemplate(readFileSync(envTemplate, "utf8"), templateVars)
|
|
94
86
|
)
|
|
95
|
-
|
|
96
87
|
writeFileSync(
|
|
97
|
-
join(backendRoot, "
|
|
98
|
-
|
|
88
|
+
join(backendRoot, ".env.example"),
|
|
89
|
+
applyTemplate(readFileSync(envTemplate, "utf8"), {
|
|
90
|
+
...templateVars,
|
|
91
|
+
DATABASE_URL: "postgres://user:pass@localhost:5433/medusa",
|
|
92
|
+
})
|
|
99
93
|
)
|
|
100
94
|
|
|
101
|
-
const
|
|
102
|
-
if (existsSync(
|
|
103
|
-
|
|
95
|
+
const backendReadme = join(PKG_ROOT, "templates/backend/README.md")
|
|
96
|
+
if (existsSync(backendReadme)) {
|
|
97
|
+
writeFileSync(join(backendRoot, "README.md"), readFileSync(backendReadme, "utf8"))
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
writeJson(join(backendRoot, "package.json"), {
|
|
101
|
+
name: `${name}-backend`,
|
|
102
|
+
private: true,
|
|
103
|
+
scripts: {
|
|
104
|
+
"backend:build": "backend-build",
|
|
105
|
+
"db:migrate":
|
|
106
|
+
"npm run backend:build && cd .generated-backend && npm install && npx medusa db:migrate",
|
|
107
|
+
dev: "npm run backend:build && cd .generated-backend && npm install && npm run dev",
|
|
108
|
+
build:
|
|
109
|
+
"npm run backend:build && cd .generated-backend && npm install && npm run build",
|
|
110
|
+
start:
|
|
111
|
+
"npm run backend:build && cd .generated-backend && npm install && npm run start",
|
|
112
|
+
seed: "npm run backend:build && cd .generated-backend && npm install && npm run seed",
|
|
113
|
+
"dynamic-config:defaults":
|
|
114
|
+
"npm run backend:build && cd .generated-backend && npm run dynamic-config:defaults",
|
|
115
|
+
},
|
|
116
|
+
dependencies: {
|
|
117
|
+
"@pradip1995/framework-compiler": FRAMEWORK_COMPILER_VERSION,
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
if (existsSync(BACKEND_CURSOR)) {
|
|
122
|
+
cpSync(BACKEND_CURSOR, join(backendRoot, ".cursor"), { recursive: true })
|
|
104
123
|
}
|
|
105
124
|
|
|
106
125
|
return backendRoot
|
package/lib/versions.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Published package semver ranges — bump when releasing framework/components. */
|
|
2
2
|
export const COMMERCE_CORE_VERSION = "^4.0.2"
|
|
3
3
|
export const FRAMEWORK_VERSION = "^0.2.1"
|
|
4
|
-
export const FRAMEWORK_COMPILER_VERSION = "^0.
|
|
4
|
+
export const FRAMEWORK_COMPILER_VERSION = "^0.3.1"
|
|
5
5
|
export const COMPONENTS_VERSION = ">=0.2.0 <0.4.0"
|
|
6
6
|
|
|
7
7
|
export const FRAMEWORK_PACKAGES = [
|
package/package.json
CHANGED
|
@@ -1,54 +1,49 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Medusa backend — config
|
|
2
|
+
description: Medusa backend — config-only client, generated on dev/build
|
|
3
3
|
globs: backend/**/*
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# Medusa backend
|
|
7
|
+
# Medusa backend (config client)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Generated Medusa source lives in `.generated-backend/` (gitignored). Same pattern as `storefront/.generated-app/`.
|
|
10
|
+
|
|
11
|
+
## Committed source
|
|
10
12
|
|
|
11
13
|
| File | Purpose |
|
|
12
14
|
|------|---------|
|
|
13
|
-
| `
|
|
14
|
-
| `config
|
|
15
|
-
| `config/homepage-config.json` | Dynamic-config schema — **synced from storefront build** when sections change |
|
|
15
|
+
| `plugins.config.json` | Medusa core + plugin npm versions; optional `enabled` array |
|
|
16
|
+
| `backend.config.json` | Preset (`full`/`minimal`), default region |
|
|
16
17
|
| `.env` | Database, CORS, secrets, integrations |
|
|
17
|
-
| `src/scripts/seed.ts` | Region, sales channel, publishable API key, sample product |
|
|
18
18
|
|
|
19
19
|
## Commands
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
cd backend
|
|
23
|
-
npm run dev
|
|
24
|
-
npm run build
|
|
25
|
-
npm run seed
|
|
23
|
+
npm run dev # backend-build → medusa develop
|
|
24
|
+
npm run build # backend-build → medusa build
|
|
25
|
+
npm run seed # seed region, API key, sample product
|
|
26
|
+
npm run backend:build # regenerate .generated-backend/ only
|
|
26
27
|
```
|
|
27
28
|
|
|
29
|
+
**Do not edit** `.generated-backend/` — overwritten every build.
|
|
30
|
+
|
|
28
31
|
## Docker
|
|
29
32
|
|
|
30
|
-
From project root: `make up-infra` then local `npm run dev`, or `make up` for full
|
|
33
|
+
From project root: `make up-infra` then local `npm run dev:backend`, or `make up` for full stack. See `Makefile`.
|
|
31
34
|
|
|
32
35
|
## After seed
|
|
33
36
|
|
|
34
|
-
From project root, `npm run seed` or `make seed` syncs the publishable key into `storefront/.env.local` (via `scripts/sync-publishable-key.mjs
|
|
37
|
+
From project root, `npm run seed` or `make seed` syncs the publishable key into `storefront/.env.local` (via `scripts/sync-publishable-key.mjs`).
|
|
35
38
|
|
|
36
|
-
##
|
|
39
|
+
## Plugins
|
|
37
40
|
|
|
38
|
-
Edit `config
|
|
41
|
+
Edit `plugins.config.json` — add/remove plugin keys or change versions, then run `npm run dev` or `backend:build`.
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
`STORE_CORS` and `AUTH_CORS` must include the storefront URL (`STOREFRONT_URL`).
|
|
43
|
+
`medusa-config.ts` is generated from the enabled plugin list.
|
|
43
44
|
|
|
44
45
|
## Dynamic config
|
|
45
46
|
|
|
46
|
-
Homepage fields
|
|
47
|
-
|
|
48
|
-
After editing the schema, run:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
npm run dynamic-config:defaults
|
|
52
|
-
```
|
|
47
|
+
Homepage admin fields sync from `storefront/pages.config.json` on `storefront:build` into `.generated-backend/config/homepage-config.json`.
|
|
53
48
|
|
|
54
|
-
|
|
49
|
+
Restart backend after schema changes. Storefront reads runtime values from `GET /store/dynamic-config`.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Backend (config-only)
|
|
2
|
+
|
|
3
|
+
Medusa source is **generated** into `.generated-backend/` — same pattern as `storefront/.generated-app/`.
|
|
4
|
+
|
|
5
|
+
## Committed source
|
|
6
|
+
|
|
7
|
+
| File | Edit when |
|
|
8
|
+
|------|-----------|
|
|
9
|
+
| `plugins.config.json` | Add/remove plugins or change npm versions |
|
|
10
|
+
| `backend.config.json` | Change preset (`full`/`minimal`) or default region |
|
|
11
|
+
| `.env` | Database URL, secrets, optional integrations |
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run dev # backend-build → medusa develop
|
|
17
|
+
npm run db:migrate # first time (run twice on fresh DB if needed)
|
|
18
|
+
npm run build # backend-build → medusa build
|
|
19
|
+
npm run seed # seed demo data
|
|
20
|
+
npm run backend:build # regenerate .generated-backend/ only
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Do not edit** `.generated-backend/` — changes are overwritten on the next build.
|
|
24
|
+
|
|
25
|
+
## Homepage admin schema
|
|
26
|
+
|
|
27
|
+
Synced from storefront segments — see `storefront/pages.config.json` and run `npm run storefront:build` in the storefront folder.
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Backend config (committed)
|
|
2
|
+
|
|
3
|
+
This folder is **config-only**. Medusa source is generated into `.generated-backend/` on `npm run dev` or `npm run build` — do not commit that folder.
|
|
4
|
+
|
|
5
|
+
## Source files
|
|
2
6
|
|
|
3
7
|
| File | Purpose |
|
|
4
8
|
|------|---------|
|
|
5
|
-
| `
|
|
6
|
-
| `
|
|
9
|
+
| `plugins.config.json` | Medusa core + plugin npm versions; optional `enabled` array to override preset |
|
|
10
|
+
| `backend.config.json` | Preset (`full` \| `minimal`), default region, project name |
|
|
11
|
+
| `.env` / `.env.template` | Secrets and service URLs (DATABASE_URL, CORS, optional integrations) |
|
|
12
|
+
|
|
13
|
+
## Generated (gitignored)
|
|
7
14
|
|
|
8
|
-
|
|
15
|
+
Running `npm run backend:build` (or `dev` / `build`) writes:
|
|
9
16
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
4. Restart Medusa backend so Admin picks up schema changes.
|
|
17
|
+
- `.generated-backend/medusa-config.ts` — assembled from `plugins.config.json`
|
|
18
|
+
- `.generated-backend/package.json` — Medusa dependencies
|
|
19
|
+
- `.generated-backend/src/`, `scripts/`, `config/`
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
## Dynamic homepage schema
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
cd backend && npm run dynamic-config:defaults
|
|
19
|
-
```
|
|
23
|
+
Homepage admin fields are **not** edited here manually. They sync from the storefront:
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
1. Edit `storefront/pages.config.json` (segments/workflows).
|
|
26
|
+
2. Run `npm run storefront:build` in `storefront/` — writes filtered schema to `backend/.generated-backend/config/homepage-config.json`.
|
|
27
|
+
3. Run `npm run backend:build` or `dev:backend` — preserves synced schema when regenerating.
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
Restart the backend after schema changes.
|
|
@@ -19,8 +19,8 @@ GOOGLE_CLIENT_ID=
|
|
|
19
19
|
GOOGLE_CLIENT_SECRET=
|
|
20
20
|
GOOGLE_CALLBACK_URL={{BASE_URL}}/auth/customer/google/callback
|
|
21
21
|
|
|
22
|
-
# Email (optional —
|
|
23
|
-
SMTP_HOST=
|
|
22
|
+
# Email (optional — use Mailpit with make up-infra: SMTP_HOST=localhost SMTP_PORT=1025 SMTP_SECURE=false)
|
|
23
|
+
SMTP_HOST=
|
|
24
24
|
SMTP_PORT=465
|
|
25
25
|
SMTP_SECURE=true
|
|
26
26
|
SMTP_USER=
|
|
@@ -2,10 +2,14 @@ FROM node:24-alpine AS builder
|
|
|
2
2
|
|
|
3
3
|
WORKDIR /app
|
|
4
4
|
|
|
5
|
-
COPY package.json
|
|
5
|
+
COPY package.json .npmrc plugins.config.json backend.config.json ./
|
|
6
6
|
RUN npm install --prefer-offline --no-audit --legacy-peer-deps
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
RUN npm run backend:build
|
|
9
|
+
|
|
10
|
+
WORKDIR /app/.generated-backend
|
|
11
|
+
|
|
12
|
+
RUN npm install --prefer-offline --no-audit --legacy-peer-deps
|
|
9
13
|
RUN npm run build
|
|
10
14
|
|
|
11
15
|
RUN if [ -d templates ]; then cp -r templates .medusa/server/; fi
|
|
@@ -16,11 +20,12 @@ WORKDIR /app
|
|
|
16
20
|
|
|
17
21
|
ENV NODE_ENV=production
|
|
18
22
|
|
|
19
|
-
COPY --from=builder /app/.medusa/server ./
|
|
20
|
-
COPY --from=builder /app/medusa-config.ts ./medusa-config.ts
|
|
21
|
-
COPY --from=builder /app/config ./config
|
|
22
|
-
COPY --from=builder /app/
|
|
23
|
-
COPY --from=builder /app/package
|
|
23
|
+
COPY --from=builder /app/.generated-backend/.medusa/server ./
|
|
24
|
+
COPY --from=builder /app/.generated-backend/medusa-config.ts ./medusa-config.ts
|
|
25
|
+
COPY --from=builder /app/.generated-backend/config ./config
|
|
26
|
+
COPY --from=builder /app/.generated-backend/src ./src
|
|
27
|
+
COPY --from=builder /app/.generated-backend/package.json ./package.json
|
|
28
|
+
COPY --from=builder /app/.generated-backend/package-lock.json* ./
|
|
24
29
|
|
|
25
30
|
RUN npm install --omit=dev --prefer-offline --no-audit --legacy-peer-deps \
|
|
26
31
|
&& npm install --save-prod ts-node typescript --prefer-offline --no-audit --legacy-peer-deps
|
|
@@ -7,15 +7,17 @@ alwaysApply: true
|
|
|
7
7
|
|
|
8
8
|
```
|
|
9
9
|
<project>/
|
|
10
|
-
backend/ Medusa
|
|
11
|
-
storefront/
|
|
10
|
+
backend/ Config-only Medusa client → .generated-backend/
|
|
11
|
+
storefront/ Config-only Next.js client → .generated-app/
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
Both folders are **config clients**. Generated code is gitignored.
|
|
15
|
+
|
|
14
16
|
## Dev (local Node)
|
|
15
17
|
|
|
16
18
|
```bash
|
|
17
|
-
npm run dev:backend # terminal 1
|
|
18
|
-
npm run dev:storefront # terminal 2
|
|
19
|
+
npm run dev:backend # terminal 1 — backend-build + medusa develop
|
|
20
|
+
npm run dev:storefront # terminal 2 — storefront-build + next dev
|
|
19
21
|
```
|
|
20
22
|
|
|
21
23
|
## Dev (Docker)
|
|
@@ -30,9 +32,10 @@ See `Makefile` and command `docker-dev`.
|
|
|
30
32
|
|
|
31
33
|
## First-time backend
|
|
32
34
|
|
|
33
|
-
1. Set `DATABASE_URL` in `backend/.env`
|
|
34
|
-
2. `npm run
|
|
35
|
-
3. `npm run
|
|
35
|
+
1. Set `DATABASE_URL` in `backend/.env` (port **5433** when using `make up-infra`)
|
|
36
|
+
2. `npm run migrate:backend` (may need two runs on fresh DB)
|
|
37
|
+
3. `npm run dev:backend` (generates backend + migrations on start)
|
|
38
|
+
4. `npm run seed` (region, API key, sample product)
|
|
36
39
|
4. Run `npm run seed` from project root (syncs publishable key to `storefront/.env.local` via Postgres)
|
|
37
40
|
|
|
38
41
|
## Build
|
|
@@ -42,14 +45,16 @@ npm run build:backend
|
|
|
42
45
|
npm run build:storefront
|
|
43
46
|
```
|
|
44
47
|
|
|
45
|
-
## Where to edit
|
|
48
|
+
## Where to edit (committed source only)
|
|
46
49
|
|
|
47
50
|
| Goal | Path |
|
|
48
51
|
|------|------|
|
|
49
|
-
| Medusa plugins
|
|
50
|
-
|
|
|
51
|
-
| Homepage admin fields | `
|
|
52
|
+
| Medusa plugins + versions | `backend/plugins.config.json` |
|
|
53
|
+
| Backend preset / region | `backend/backend.config.json` |
|
|
54
|
+
| Homepage admin fields | driven by `storefront/pages.config.json` → synced on `storefront:build` |
|
|
52
55
|
| Storefront sections | `storefront/pages.config.json` |
|
|
53
56
|
| Brand colors | `storefront/theme-overrides.css` |
|
|
54
57
|
|
|
58
|
+
**Never edit** `backend/.generated-backend/` or `storefront/.generated-app/` — regenerated every dev/build.
|
|
59
|
+
|
|
55
60
|
Cursor guides live in `backend/.cursor/` and `storefront/.cursor/`.
|
|
@@ -26,7 +26,7 @@ Each entry in `segments` renders top-to-bottom:
|
|
|
26
26
|
npm run storefront:build
|
|
27
27
|
```
|
|
28
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.
|
|
29
|
+
This regenerates the Next.js app **and** syncs `backend/.generated-backend/config/homepage-config.json` (Admin fields for your active segments). Restart the backend after schema changes.
|
|
30
30
|
|
|
31
31
|
**Remove** — delete the line and remove the package from `package.json` if unused elsewhere.
|
|
32
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`). Schema syncs to `backend/.generated-backend/config/` on `storefront:build`; storefront loads values from `GET /store/dynamic-config`.
|
|
@@ -24,7 +24,7 @@ This folder (`storefront/`) is a **config client**, not a hand-written Next.js a
|
|
|
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
|
+
Homepage content (hero, promo, logo, etc.) comes from Medusa `GET /store/dynamic-config`. The **schema** in `../backend/.generated-backend/config/homepage-config.json` is updated automatically when you run `npm run storefront:build` after changing `pages.config.json`.
|
|
28
28
|
|
|
29
29
|
After any change to config, deps, or `theme-overrides.css`:
|
|
30
30
|
|
|
@@ -37,13 +37,14 @@ Default admin: `make admin-create` (see `Makefile` for `ADMIN_EMAIL` / `ADMIN_PA
|
|
|
37
37
|
## Option B — Docker infra + local Node dev
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
make up-infra # postgres, redis, mailpit
|
|
41
|
-
npm run
|
|
42
|
-
npm run
|
|
40
|
+
make up-infra # postgres (host :5433), redis, mailpit
|
|
41
|
+
npm run migrate:backend # first time — run twice if needed on fresh DB
|
|
42
|
+
npm run dev:backend # terminal 1
|
|
43
|
+
npm run seed # from project root
|
|
43
44
|
npm run dev:storefront # terminal 2
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
`backend/.env` `DATABASE_URL`
|
|
47
|
+
`backend/.env` `DATABASE_URL` uses port **5433** (Docker maps `5433→5432` to avoid conflict with a local Postgres on 5432).
|
|
47
48
|
|
|
48
49
|
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
|
|
|
@@ -93,8 +94,9 @@ make clean # remove containers + volumes
|
|
|
93
94
|
|------|--------|
|
|
94
95
|
| Home sections | `storefront/pages.config.json` |
|
|
95
96
|
| Colors / fonts | `storefront/theme-overrides.css` |
|
|
96
|
-
| Medusa plugins | `backend/
|
|
97
|
-
|
|
|
97
|
+
| Medusa plugins | `backend/plugins.config.json` |
|
|
98
|
+
| Plugin preset / region | `backend/backend.config.json` |
|
|
99
|
+
| Homepage admin fields | auto-synced to `backend/.generated-backend/config/` on `storefront:build` |
|
|
98
100
|
| Docker secrets | `docker/.env` |
|
|
99
101
|
|
|
100
102
|
Cursor guides: `.cursor/` in each folder.
|