@pradip1995/create-storefront-app 0.4.2 → 0.4.4

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.
@@ -52,5 +52,8 @@
52
52
  "medusa-export",
53
53
  "medusa-payment-provider",
54
54
  "@tsc_tech/medusa-plugin-smtp"
55
+ ],
56
+ "moduleOnlyPlugins": [
57
+ "@tsc_tech/medusa-plugin-smtp"
55
58
  ]
56
59
  }
@@ -104,7 +104,7 @@ export function scaffoldBackend(backendRoot, args) {
104
104
  "backend:build": "backend-build",
105
105
  "db:migrate":
106
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",
107
+ dev: "npm run backend:build && cd .generated-backend && npm install && npx medusa db:migrate && npm run dev",
108
108
  build:
109
109
  "npm run backend:build && cd .generated-backend && npm install && npm run build",
110
110
  start:
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.3.2"
4
+ export const FRAMEWORK_COMPILER_VERSION = "^0.4.0"
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@pradip1995/create-storefront-app",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Scaffold a segment-based Medusa storefront using @pradip1995/framework packages",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -6,14 +6,14 @@ Medusa source is **generated** into `.generated-backend/` — same pattern as `s
6
6
 
7
7
  | File | Edit when |
8
8
  |------|-----------|
9
- | `plugins.config.json` | Add/remove plugins or change npm versions |
9
+ | `plugins.config.json` | Add/remove plugins, change versions, or override plugin options |
10
10
  | `backend.config.json` | Change preset (`full`/`minimal`) or default region |
11
11
  | `.env` | Database URL, secrets, optional integrations |
12
12
 
13
13
  ## Commands
14
14
 
15
15
  ```bash
16
- npm run dev # backend-build → medusa develop
16
+ npm run dev # backend-build → migrate → medusa develop
17
17
  npm run db:migrate # first time (run twice on fresh DB if needed)
18
18
  npm run build # backend-build → medusa build
19
19
  npm run seed # seed demo data
@@ -22,6 +22,69 @@ npm run backend:build # regenerate .generated-backend/ only
22
22
 
23
23
  **Do not edit** `.generated-backend/` — changes are overwritten on the next build.
24
24
 
25
+ ## Plugin configuration
26
+
27
+ There are three layers:
28
+
29
+ ### 1. Secrets and integrations → `backend/.env`
30
+
31
+ Credentials and environment-specific values are read at runtime via `process.env`:
32
+
33
+ | Variable | Used by |
34
+ |----------|---------|
35
+ | `JWT_SECRET`, `COOKIE_SECRET` | Auth, invoice, order-management |
36
+ | `SMTP_*` | SMTP notification module (when `@tsc_tech/medusa-plugin-smtp` is enabled) |
37
+ | `CASHFREE_*` | Cashfree payment (when credentials are set) |
38
+ | `SHIPROCKET_*` | Shiprocket fulfillment (when email/password are set) |
39
+ | `AWS_*` | S3 file storage (falls back to local files when unset) |
40
+ | `GOOGLE_CLIENT_*` | Google OAuth on customer auth |
41
+
42
+ After changing `.env`, restart the backend — no rebuild needed.
43
+
44
+ ### 2. Business / plugin options → `plugins.config.json` → `pluginOptions`
45
+
46
+ Override framework defaults per plugin. Values are merged into generated `medusa-config.ts` on `npm run backend:build`.
47
+
48
+ ```json
49
+ {
50
+ "plugins": {
51
+ "stock-monitoring": "^0.0.5",
52
+ "medusa-review-rating": "^0.0.38"
53
+ },
54
+ "pluginOptions": {
55
+ "stock-monitoring": {
56
+ "low_stock_threshold": 5,
57
+ "slow_moving_days_threshold": 60
58
+ },
59
+ "medusa-review-rating": {
60
+ "autoApprove": false,
61
+ "requireVerifiedPurchase": true
62
+ },
63
+ "customer-registration": {
64
+ "registration": { "require_verification": false }
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ To reference an env var from generated config, use a string (same as framework defaults):
71
+
72
+ ```json
73
+ "medusa-shiprocket-fulfillment-sbl": {
74
+ "shiprocket": {
75
+ "pickupLocation": "process.env.SHIPROCKET_PICKUP_LOCATION || \"Warehouse A\""
76
+ }
77
+ }
78
+ ```
79
+
80
+ Run `npm run backend:build` (or `npm run dev`) after editing `pluginOptions`.
81
+
82
+ ### 3. Framework defaults
83
+
84
+ Sensible defaults for every supported plugin live in `@pradip1995/framework-compiler` (`plugin-definitions.cjs`). You only need `pluginOptions` when you want to change something from the default.
85
+
86
+ Unknown plugins must be added to the framework before they can be listed in `plugins.config.json`.
87
+
25
88
  ## Homepage admin schema
26
89
 
27
90
  Synced from storefront segments — see `storefront/pages.config.json` and run `npm run storefront:build` in the storefront folder.
@@ -4,6 +4,39 @@ set -euo pipefail
4
4
  DUMP_PATH="${DUMP_PATH:-/dump/dump.sql}"
5
5
  MIN_TABLES="${MIN_TABLES_FOR_DUMP:-1}"
6
6
 
7
+ table_count() {
8
+ psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -tAc \
9
+ "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public';" \
10
+ 2>/dev/null || echo "0"
11
+ }
12
+
13
+ restore_dump_if_empty() {
14
+ if [ -z "${POSTGRES_USER:-}" ] || [ -z "${POSTGRES_DB:-}" ]; then
15
+ return 0
16
+ fi
17
+
18
+ if ! pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB" >/dev/null 2>&1; then
19
+ return 0
20
+ fi
21
+
22
+ local count
23
+ count="$(table_count)"
24
+
25
+ if [ "${count:-0}" -ge "$MIN_TABLES" ]; then
26
+ return 0
27
+ fi
28
+
29
+ if [ ! -f "$DUMP_PATH" ] || [ ! -s "$DUMP_PATH" ]; then
30
+ echo "Database empty (${count:-0} tables) and no dump at ${DUMP_PATH} — run npm run migrate:backend"
31
+ return 0
32
+ fi
33
+
34
+ echo "Database empty (${count:-0} tables). Restoring from ${DUMP_PATH} ..."
35
+ psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -v ON_ERROR_STOP=1 -f "$DUMP_PATH"
36
+ count="$(table_count)"
37
+ echo "Database restore complete (${count} tables)."
38
+ }
39
+
7
40
  dump_database() {
8
41
  if [ -z "${POSTGRES_USER:-}" ] || [ -z "${POSTGRES_DB:-}" ]; then
9
42
  return 0
@@ -13,19 +46,15 @@ dump_database() {
13
46
  return 0
14
47
  fi
15
48
 
16
- local table_count
17
- table_count=$(
18
- psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -tAc \
19
- "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public';" \
20
- 2>/dev/null || echo "0"
21
- )
49
+ local count
50
+ count="$(table_count)"
22
51
 
23
- if [ "${table_count:-0}" -lt "$MIN_TABLES" ]; then
24
- echo "Skipping dump: public schema has ${table_count:-0} table(s)."
52
+ if [ "${count:-0}" -lt "$MIN_TABLES" ]; then
53
+ echo "Skipping dump: public schema has ${count:-0} table(s)."
25
54
  return 0
26
55
  fi
27
56
 
28
- echo "Saving database dump (${table_count} tables) to ${DUMP_PATH} ..."
57
+ echo "Saving database dump (${count} tables) to ${DUMP_PATH} ..."
29
58
  pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fp > "${DUMP_PATH}.tmp"
30
59
  mv "${DUMP_PATH}.tmp" "${DUMP_PATH}"
31
60
  echo "Database dump saved."
@@ -46,4 +75,11 @@ trap shutdown_postgres SIGTERM SIGINT
46
75
 
47
76
  /usr/local/bin/docker-entrypoint.sh "$@" &
48
77
  child_pid=$!
78
+
79
+ until pg_isready -U "${POSTGRES_USER:-postgres}" -d "${POSTGRES_DB:-postgres}" >/dev/null 2>&1; do
80
+ sleep 1
81
+ done
82
+
83
+ restore_dump_if_empty
84
+
49
85
  wait "$child_pid"