@vendure-platform/create 0.5.1 → 1.0.0-major.202609160652.120.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.
Files changed (176) hide show
  1. package/README.md +48 -36
  2. package/dist/add-to-existing.d.ts +20 -14
  3. package/dist/add-to-existing.js +1 -1
  4. package/dist/assets/demo-data/assets/branding/logo.svg +4 -0
  5. package/dist/assets/demo-data/assets/images/absorbent-pad.webp +0 -0
  6. package/dist/assets/demo-data/assets/images/adjustable-wrench.webp +0 -0
  7. package/dist/assets/demo-data/assets/images/anchor-bolt.webp +0 -0
  8. package/dist/assets/demo-data/assets/images/angle-grinder.webp +0 -0
  9. package/dist/assets/demo-data/assets/images/barrier-tape.webp +0 -0
  10. package/dist/assets/demo-data/assets/images/bench-grinder.webp +0 -0
  11. package/dist/assets/demo-data/assets/images/bracket.webp +0 -0
  12. package/dist/assets/demo-data/assets/images/broom.webp +0 -0
  13. package/dist/assets/demo-data/assets/images/bucket.webp +0 -0
  14. package/dist/assets/demo-data/assets/images/cable-gland.webp +0 -0
  15. package/dist/assets/demo-data/assets/images/cable-tie.webp +0 -0
  16. package/dist/assets/demo-data/assets/images/cable-tray.webp +0 -0
  17. package/dist/assets/demo-data/assets/images/cable.webp +0 -0
  18. package/dist/assets/demo-data/assets/images/chimney-base-kit.webp +0 -0
  19. package/dist/assets/demo-data/assets/images/chimney-cowl-bird-guard.webp +0 -0
  20. package/dist/assets/demo-data/assets/images/chimney-cowl-open.webp +0 -0
  21. package/dist/assets/demo-data/assets/images/chimney-storm-collar.webp +0 -0
  22. package/dist/assets/demo-data/assets/images/chimney-wall-bracket.webp +0 -0
  23. package/dist/assets/demo-data/assets/images/circular-saw.webp +0 -0
  24. package/dist/assets/demo-data/assets/images/cleaning-spray.webp +0 -0
  25. package/dist/assets/demo-data/assets/images/conduit.webp +0 -0
  26. package/dist/assets/demo-data/assets/images/cordless-drill.webp +0 -0
  27. package/dist/assets/demo-data/assets/images/drill-bits.webp +0 -0
  28. package/dist/assets/demo-data/assets/images/dust-mask.webp +0 -0
  29. package/dist/assets/demo-data/assets/images/ear-defenders.webp +0 -0
  30. package/dist/assets/demo-data/assets/images/ear-plugs.webp +0 -0
  31. package/dist/assets/demo-data/assets/images/extension-lead.webp +0 -0
  32. package/dist/assets/demo-data/assets/images/eye-wash-station.webp +0 -0
  33. package/dist/assets/demo-data/assets/images/face-shield.webp +0 -0
  34. package/dist/assets/demo-data/assets/images/file-set.webp +0 -0
  35. package/dist/assets/demo-data/assets/images/first-aid-kit.webp +0 -0
  36. package/dist/assets/demo-data/assets/images/floor-sign.webp +0 -0
  37. package/dist/assets/demo-data/assets/images/flue-bend-45.webp +0 -0
  38. package/dist/assets/demo-data/assets/images/flue-bend-90.webp +0 -0
  39. package/dist/assets/demo-data/assets/images/flue-section-1000mm.webp +0 -0
  40. package/dist/assets/demo-data/assets/images/flue-section-250mm.webp +0 -0
  41. package/dist/assets/demo-data/assets/images/flue-section-500mm.webp +0 -0
  42. package/dist/assets/demo-data/assets/images/fuse.webp +0 -0
  43. package/dist/assets/demo-data/assets/images/glove-dispenser.webp +0 -0
  44. package/dist/assets/demo-data/assets/images/grinding-disc.webp +0 -0
  45. package/dist/assets/demo-data/assets/images/hacksaw.webp +0 -0
  46. package/dist/assets/demo-data/assets/images/hammer.webp +0 -0
  47. package/dist/assets/demo-data/assets/images/hand-sanitiser.webp +0 -0
  48. package/dist/assets/demo-data/assets/images/head-torch.webp +0 -0
  49. package/dist/assets/demo-data/assets/images/heat-gun.webp +0 -0
  50. package/dist/assets/demo-data/assets/images/hex-bolt.webp +0 -0
  51. package/dist/assets/demo-data/assets/images/hex-key-set.webp +0 -0
  52. package/dist/assets/demo-data/assets/images/hex-nut.webp +0 -0
  53. package/dist/assets/demo-data/assets/images/hi-vis-jacket.webp +0 -0
  54. package/dist/assets/demo-data/assets/images/hi-vis-vest.webp +0 -0
  55. package/dist/assets/demo-data/assets/images/hose-clamp.webp +0 -0
  56. package/dist/assets/demo-data/assets/images/impact-driver.webp +0 -0
  57. package/dist/assets/demo-data/assets/images/jigsaw.webp +0 -0
  58. package/dist/assets/demo-data/assets/images/junction-box.webp +0 -0
  59. package/dist/assets/demo-data/assets/images/knee-pads.webp +0 -0
  60. package/dist/assets/demo-data/assets/images/machine-screw.webp +0 -0
  61. package/dist/assets/demo-data/assets/images/made-to-order-configurable-chimney.webp +0 -0
  62. package/dist/assets/demo-data/assets/images/mallet.webp +0 -0
  63. package/dist/assets/demo-data/assets/images/mcb.webp +0 -0
  64. package/dist/assets/demo-data/assets/images/mop.webp +0 -0
  65. package/dist/assets/demo-data/assets/images/paper-towels.webp +0 -0
  66. package/dist/assets/demo-data/assets/images/pipe-wrench.webp +0 -0
  67. package/dist/assets/demo-data/assets/images/pliers-set.webp +0 -0
  68. package/dist/assets/demo-data/assets/images/pry-bar.webp +0 -0
  69. package/dist/assets/demo-data/assets/images/rcd.webp +0 -0
  70. package/dist/assets/demo-data/assets/images/reciprocating-saw.webp +0 -0
  71. package/dist/assets/demo-data/assets/images/rivet.webp +0 -0
  72. package/dist/assets/demo-data/assets/images/roof-flashing-high-pitch.webp +0 -0
  73. package/dist/assets/demo-data/assets/images/roof-flashing-low-pitch.webp +0 -0
  74. package/dist/assets/demo-data/assets/images/safety-boots.webp +0 -0
  75. package/dist/assets/demo-data/assets/images/safety-glasses.webp +0 -0
  76. package/dist/assets/demo-data/assets/images/safety-harness.webp +0 -0
  77. package/dist/assets/demo-data/assets/images/safety-helmet.webp +0 -0
  78. package/dist/assets/demo-data/assets/images/safety-sign.webp +0 -0
  79. package/dist/assets/demo-data/assets/images/sanding-disc.webp +0 -0
  80. package/dist/assets/demo-data/assets/images/saw-blade.webp +0 -0
  81. package/dist/assets/demo-data/assets/images/screwdriver-set.webp +0 -0
  82. package/dist/assets/demo-data/assets/images/screwdriver.webp +0 -0
  83. package/dist/assets/demo-data/assets/images/self-tapping-screw.webp +0 -0
  84. package/dist/assets/demo-data/assets/images/socket-set.webp +0 -0
  85. package/dist/assets/demo-data/assets/images/socket.webp +0 -0
  86. package/dist/assets/demo-data/assets/images/spanner-set.webp +0 -0
  87. package/dist/assets/demo-data/assets/images/spanner.webp +0 -0
  88. package/dist/assets/demo-data/assets/images/spill-kit.webp +0 -0
  89. package/dist/assets/demo-data/assets/images/spirit-level.webp +0 -0
  90. package/dist/assets/demo-data/assets/images/switch.webp +0 -0
  91. package/dist/assets/demo-data/assets/images/tape-measure.webp +0 -0
  92. package/dist/assets/demo-data/assets/images/terminal-block.webp +0 -0
  93. package/dist/assets/demo-data/assets/images/threaded-rod.webp +0 -0
  94. package/dist/assets/demo-data/assets/images/torque-wrench.webp +0 -0
  95. package/dist/assets/demo-data/assets/images/utility-knife.webp +0 -0
  96. package/dist/assets/demo-data/assets/images/wall-pass-sleeve.webp +0 -0
  97. package/dist/assets/demo-data/assets/images/wall-plug.webp +0 -0
  98. package/dist/assets/demo-data/assets/images/washer.webp +0 -0
  99. package/dist/assets/demo-data/assets/images/waste-bin.webp +0 -0
  100. package/dist/assets/demo-data/assets/images/wire-connector.webp +0 -0
  101. package/dist/assets/demo-data/assets/images/wire-cutters.webp +0 -0
  102. package/dist/assets/demo-data/assets/images/wood-screw.webp +0 -0
  103. package/dist/assets/demo-data/assets/images/work-gloves.webp +0 -0
  104. package/dist/assets/demo-data/assets/images/work-light.webp +0 -0
  105. package/dist/assets/demo-data/assets/initial-data.json +667 -0
  106. package/dist/assets/demo-data/assets/products.csv +779 -0
  107. package/dist/assets/storefront/.env.example +7 -0
  108. package/dist/assets/storefront/next-env.d.ts +2 -1
  109. package/dist/assets/storefront/next.config.ts +14 -13
  110. package/dist/assets/storefront/package.json +3 -2
  111. package/dist/assets/storefront/src/app/[locale]/account/addresses/page.tsx +2 -0
  112. package/dist/assets/storefront/src/app/[locale]/account/approvals/page.tsx +2 -0
  113. package/dist/assets/storefront/src/app/[locale]/account/company/business-units/page.tsx +2 -0
  114. package/dist/assets/storefront/src/app/[locale]/account/company/page.tsx +2 -0
  115. package/dist/assets/storefront/src/app/[locale]/account/company/payment-methods/page.tsx +2 -0
  116. package/dist/assets/storefront/src/app/[locale]/account/company/roles/page.tsx +2 -0
  117. package/dist/assets/storefront/src/app/[locale]/account/company/users/page.tsx +2 -0
  118. package/dist/assets/storefront/src/app/[locale]/account/profile/page.tsx +2 -0
  119. package/dist/assets/storefront/src/app/[locale]/account/quick-order/page.tsx +2 -0
  120. package/dist/assets/storefront/src/app/[locale]/account/quotes/[id]/page.tsx +10 -6
  121. package/dist/assets/storefront/src/app/[locale]/cart/order-summary.tsx +8 -5
  122. package/dist/assets/storefront/src/app/[locale]/cart/promotion-code.tsx +9 -6
  123. package/dist/assets/storefront/src/app/[locale]/checkout/page.tsx +2 -0
  124. package/dist/assets/storefront/src/app/[locale]/layout.tsx +3 -3
  125. package/dist/assets/storefront/src/app/[locale]/order-confirmation/[code]/order-confirmation.tsx +2 -60
  126. package/dist/assets/storefront/src/components/commerce/product-card-list.tsx +4 -2
  127. package/dist/assets/storefront/src/components/commerce/product-card.tsx +4 -2
  128. package/dist/assets/storefront/src/components/commerce/quote-action-buttons.tsx +31 -14
  129. package/dist/assets/storefront/src/config/capabilities.ts +49 -0
  130. package/dist/assets/storefront/src/config/scenario.ts +10 -0
  131. package/dist/assets/storefront/src/graphql-env.d.ts +47 -41
  132. package/dist/assets/storefront/src/i18n/server.ts +33 -5
  133. package/dist/assets/storefront/src/lib/backend-health.ts +11 -3
  134. package/dist/assets/storefront/src/lib/vendure/api.ts +7 -4
  135. package/dist/assets/storefront/src/lib/vendure/capability-documents.ts +252 -0
  136. package/dist/assets/storefront/src/lib/vendure/capability-drift.ts +187 -0
  137. package/dist/assets/storefront/src/lib/vendure/capability-schema.ts +358 -0
  138. package/dist/assets/storefront/src/lib/vendure/capability-ui.ts +15 -0
  139. package/dist/assets/storefront/src/lib/vendure/mutations.ts +835 -532
  140. package/dist/assets/storefront/src/lib/vendure/queries.ts +862 -519
  141. package/dist/assets/storefront/src/proxy.ts +11 -0
  142. package/dist/assets/storefront/src/schema.graphql +337 -243
  143. package/dist/assets/templates/CLAUDE.md.hbs +1 -0
  144. package/dist/assets/templates/README.md.hbs +24 -1
  145. package/dist/assets/templates/docker-compose.yml.hbs +4 -0
  146. package/dist/assets/templates/env.hbs +34 -9
  147. package/dist/assets/templates/environment.d.ts.hbs +3 -0
  148. package/dist/assets/templates/gitignore.hbs +7 -4
  149. package/dist/assets/templates/index.ts.hbs +1 -1
  150. package/dist/assets/templates/migrate.ts.hbs +55 -0
  151. package/dist/assets/templates/npmrc.hbs +7 -2
  152. package/dist/assets/templates/platform-edition.ts.hbs +23 -0
  153. package/dist/assets/templates/populate.ts.hbs +3 -3
  154. package/dist/assets/templates/server-package.json.hbs +15 -8
  155. package/dist/assets/templates/vendure-config.ts.hbs +25 -2
  156. package/dist/assets/templates/vite.config.mts.hbs +5 -0
  157. package/dist/bin/run.js +1 -1
  158. package/dist/cli.js +1 -1
  159. package/dist/console-onboarding.d.ts +44 -0
  160. package/dist/console-onboarding.js +1 -0
  161. package/dist/hub-projects.d.ts +48 -0
  162. package/dist/hub-projects.js +1 -0
  163. package/dist/plugin-registry.d.ts +65 -5
  164. package/dist/plugin-registry.js +1 -1
  165. package/dist/registry.d.ts +16 -13
  166. package/dist/registry.js +1 -1
  167. package/dist/scaffold-shared.js +1 -1
  168. package/dist/scaffold-storefront-only.js +1 -1
  169. package/dist/scaffolder.js +1 -1
  170. package/dist/storefront-copier.d.ts +9 -2
  171. package/dist/storefront-copier.js +1 -1
  172. package/dist/template-renderer.d.ts +31 -9
  173. package/dist/template-renderer.js +1 -1
  174. package/dist/types.d.ts +75 -24
  175. package/package.json +14 -2
  176. package/dist/assets/storefront/src/middleware.ts +0 -11
@@ -42,6 +42,7 @@ server/
42
42
  ├── vite.config.mts # Dashboard build config
43
43
  ├── src/
44
44
  │ ├── vendure-config.ts # Plugin configuration
45
+ │ ├── platform-edition.ts # Edition composer (maintained by the Vendure CLI)
45
46
  │ ├── populate.ts # Data population script
46
47
  │ ├── custom-populate.ts # Your custom demo data
47
48
  │ ├── index.ts # Server entry point
@@ -5,7 +5,7 @@ A Vendure e-commerce demo project for **{{companyName}}**, scaffolded with `@ven
5
5
  ## Prerequisites
6
6
 
7
7
  - Node.js >= 22
8
- - Docker & Docker Compose (for PostgreSQL and Typesense)
8
+ - Docker & Docker Compose (for PostgreSQL{{#if usesTypesense}} and Typesense{{/if}})
9
9
 
10
10
  ## Setup
11
11
 
@@ -35,6 +35,15 @@ The storefront will be available at `http://localhost:3001`.
35
35
  | `npm run dev` | Start all services in development mode |
36
36
  | `npm run build:dashboard` | Build the admin dashboard for production |
37
37
  | `npm run populate` | Seed the database with demo data |
38
+ | `npm run migration:generate -- <name>` | Diff the entities against the database and write a migration |
39
+ | `npm run migration:run` | Apply pending migrations |
40
+
41
+ Run from `server/`. The Vendure CLI is installed too, with the Vendure Platform
42
+ plugin enabled:
43
+
44
+ | Command | Description |
45
+ |---------|-------------|
46
+ | `npx vendure downgrade-impact` | After changing to a lower edition, report the tables the departed packages left behind |
38
47
 
39
48
  ## Installed Plugins
40
49
 
@@ -42,6 +51,20 @@ The storefront will be available at `http://localhost:3001`.
42
51
  - **{{this.displayName}}** (`{{this.packageName}}`)
43
52
  {{/each}}
44
53
 
54
+ ## Capability Profile
55
+
56
+ This project is scaffolded for the **{{profile}}** edition, which
57
+ `server/src/platform-edition.ts` names. The packages and configuration above
58
+ match these capability grants:
59
+
60
+ {{#each capabilityGrants}}
61
+ - `{{this}}`
62
+ {{/each}}
63
+
64
+ Grants are authorized at runtime by the signed license token in
65
+ `VENDURE_PLATFORM_LICENSE_TOKEN`, never by this list. A module configured
66
+ without its grant stops the server before it serves traffic.
67
+
45
68
  ## Demo Accounts
46
69
 
47
70
  | Account | Email | Password |
@@ -9,6 +9,7 @@ services:
9
9
  - '5432:5432'
10
10
  volumes:
11
11
  - postgres-data:/var/lib/postgresql/data
12
+ {{#if usesTypesense}}
12
13
 
13
14
  typesense:
14
15
  image: typesense/typesense:28.0
@@ -19,7 +20,10 @@ services:
19
20
  - '8110:8108'
20
21
  volumes:
21
22
  - typesense-data:/data
23
+ {{/if}}
22
24
 
23
25
  volumes:
24
26
  postgres-data:
27
+ {{#if usesTypesense}}
25
28
  typesense-data:
29
+ {{/if}}
@@ -14,26 +14,32 @@ SUPERADMIN_USERNAME=superadmin
14
14
  SUPERADMIN_PASSWORD=superadmin
15
15
 
16
16
  # Vendure Platform License
17
- # Get a license token from the Enterprise Portal: https://enterprise.vendure.io
18
- # NOTE: this is the SERVER license token, checked at boot by the License Guard
19
- # plugin. It is distinct from the npm registry auth token (which lives in
20
- # .npmrc) — the Enterprise Portal issues both as separate values.
21
- # Leave VENDURE_PLATFORM_LICENSE_TOKEN empty for local development; the
22
- # VENDURE_PLATFORM_LICENSE_GUARD_LOCAL_DEV=1 flag below enables the no-token
23
- # soft mode that lets you populate, run dev, and explore the platform without
24
- # enforcement. The flag is only ever read when no token is configured — once
25
- # you set a real token, the soft-mode code path is no longer reachable.
17
+ # Leave this empty in development. `vendure console link` writes this project's
18
+ # Environment Credential to .vendure/credentials.json, and `vendure dev` passes
19
+ # it to the server, so there is nothing to paste here and no secret sitting in
20
+ # a file your editor has open.
21
+ #
22
+ # In production, set this to that environment's Environment Credential from the
23
+ # Installations page in Vendure Console, through whatever holds your secrets.
26
24
  VENDURE_PLATFORM_LICENSE_TOKEN={{licenseToken}}
25
+ # Lets the server start with no credential at all, for a look around before you
26
+ # link. Read only when VENDURE_PLATFORM_LICENSE_TOKEN is empty and no credential
27
+ # was supplied, so a linked project never reaches it.
27
28
  VENDURE_PLATFORM_LICENSE_GUARD_LOCAL_DEV=1
28
29
 
30
+ {{#if usesTypesense}}
29
31
  # Advanced Search (Typesense)
30
32
  TYPESENSE_API_KEY=your-typesense-api-key
31
33
  TYPESENSE_HOST=localhost
32
34
  TYPESENSE_PORT=8110
33
35
  TYPESENSE_PROTOCOL=http
34
36
 
37
+ {{/if}}
35
38
  # Workflow Engine
36
39
  WORKFLOW_ENGINE_SCHEMA=dbos
40
+ # The docker-compose Postgres above does not speak SSL. Set this to `true`
41
+ # against a managed database that requires it.
42
+ WORKFLOW_ENGINE_SSL=false
37
43
 
38
44
  {{#ifPlugin "sso"}}
39
45
  # SSO (Google OIDC)
@@ -46,6 +52,25 @@ VENDURE_HOST=http://localhost:3500
46
52
  # Audit Trail
47
53
  AUDIT_LOG_SCHEMA=audit_trail
48
54
 
55
+ {{/ifPlugin}}
56
+ {{#ifPlugin "punchout"}}
57
+ # PunchOut
58
+ # Where a buyer's PunchOut session lands. The cXML setup response sends the
59
+ # buyer to this URL, so it must be the storefront the trading partner reaches.
60
+ PUNCHOUT_STOREFRONT_URL=http://localhost:3000
61
+
62
+ {{/ifPlugin}}
63
+ {{#ifPlugin "sso-federation"}}
64
+ # SAML SSO (sso.federation)
65
+ # A SAML provider is registered only when SAML_IDP_SSO_URL is set. Leave these
66
+ # empty until you have an identity provider: an unconfigured SAML provider
67
+ # cannot complete a login, and a second provider makes this configuration
68
+ # unloadable on any edition that does not grant sso.federation.
69
+ SAML_SP_ENTITY_ID=
70
+ SAML_IDP_ENTITY_ID=
71
+ SAML_IDP_SSO_URL=
72
+ SAML_IDP_CERTIFICATE=
73
+
49
74
  {{/ifPlugin}}
50
75
  {{#if includeStorefront}}
51
76
  # Storefront
@@ -12,11 +12,14 @@ declare namespace NodeJS {
12
12
  COOKIE_SECRET?: string;
13
13
  SUPERADMIN_USERNAME?: string;
14
14
  SUPERADMIN_PASSWORD?: string;
15
+ {{#if usesTypesense}}
15
16
  TYPESENSE_API_KEY?: string;
16
17
  TYPESENSE_HOST?: string;
17
18
  TYPESENSE_PORT?: string;
18
19
  TYPESENSE_PROTOCOL?: string;
20
+ {{/if}}
19
21
  WORKFLOW_ENGINE_SCHEMA?: string;
22
+ WORKFLOW_ENGINE_SSL?: string;
20
23
  VENDURE_PLATFORM_LICENSE_TOKEN?: string;
21
24
  VENDURE_PLATFORM_LICENSE_GUARD_LOCAL_DEV?: string;
22
25
  {{#ifPlugin "sso"}}
@@ -2,12 +2,15 @@ node_modules/
2
2
  dist/
3
3
  .next/
4
4
  .env
5
- # .npmrc may carry a literal Vendure private-registry npm auth token
6
- # (the registry token, NOT the runtime license token) — never commit it.
7
- # If you need a token-less version for CI, write a short script that strips
8
- # the `_authToken=` line at publish time.
5
+ # .npmrc carries the literal Registry Access Token, so it is never committed.
6
+ # For CI, write a fresh .npmrc at deploy time from a secret.
9
7
  .npmrc
10
8
  storefront/.npmrc
9
+ # .vendure holds the Project Link Manifest, which is identity metadata and is
10
+ # meant to be committed, next to the development credential, which is a secret
11
+ # and is not. Ignore the directory and un-ignore the one file.
12
+ .vendure/*
13
+ !.vendure/project.json
11
14
  *.tsbuildinfo
12
15
  static/assets/
13
16
  src/gql/
@@ -2,8 +2,8 @@ import * as dotenv from 'dotenv';
2
2
  import * as path from 'path';
3
3
  dotenv.config({ path: path.resolve(__dirname, '../../.env') });
4
4
 
5
- import { bootstrap } from '@vendure-platform/platform';
6
5
  import { JobQueueService } from '@vendure/core';
6
+ import { bootstrap } from './platform-edition';
7
7
  import { config } from './vendure-config';
8
8
 
9
9
  bootstrap(config)
@@ -0,0 +1,55 @@
1
+ import * as dotenv from 'dotenv';
2
+ import * as path from 'path';
3
+ dotenv.config({ path: path.resolve(__dirname, '../../.env') });
4
+
5
+ import { generateMigration, runMigrations } from '@vendure/core';
6
+
7
+ import { config } from './vendure-config';
8
+
9
+ /**
10
+ * Migration runner for this project.
11
+ *
12
+ * `vendure-config.ts` only enables TypeORM's `synchronize` in development.
13
+ * Every other environment applies schema changes through the migration files
14
+ * in `src/migrations`, so generate one whenever a plugin's entities change and
15
+ * run them before the server boots.
16
+ *
17
+ * npm run migration:generate -- <name> # diff against this database
18
+ * npm run migration:generate -- <name> --from-empty # full baseline schema
19
+ * npm run migration:run # apply pending migrations
20
+ *
21
+ * `--from-empty` diffs the entity metadata against a temporary empty database
22
+ * instead of this one, so it emits a complete "zero to current schema"
23
+ * migration. Use it for the first migration of a project whose schema was
24
+ * created by `synchronize`, where a plain diff would find nothing to write.
25
+ */
26
+ async function main(): Promise<void> {
27
+ const args = process.argv.slice(2);
28
+ const command = args[0];
29
+ const fromEmpty = args.includes('--from-empty');
30
+ const name = args.slice(1).find((arg) => !arg.startsWith('--'));
31
+
32
+ if (command === 'generate') {
33
+ if (!name) {
34
+ throw new Error('Usage: npm run migration:generate -- <name> [--from-empty]');
35
+ }
36
+ await generateMigration(config, {
37
+ name,
38
+ fromEmpty,
39
+ outputDir: path.join(__dirname, './migrations'),
40
+ });
41
+ return;
42
+ }
43
+
44
+ if (command === 'run') {
45
+ await runMigrations(config);
46
+ return;
47
+ }
48
+
49
+ throw new Error(`Unknown migration command "${command ?? ''}". Use "generate" or "run".`);
50
+ }
51
+
52
+ main().catch((err: unknown) => {
53
+ console.error(err);
54
+ process.exit(1);
55
+ });
@@ -1,3 +1,8 @@
1
1
  @vendure-platform:registry={{registryUrl}}
2
- {{#if registryToken}}//{{registryHost}}/:_authToken={{registryToken}}
3
- {{/if}}
2
+ {{#if registryToken}}{{registryAuthTokenKey}}{{registryToken}}
3
+ {{/if}}
4
+ ; The server depends on one edition facade, not on each capability package.
5
+ ; pnpm's strict layout would then hide those packages from `import
6
+ ; '@vendure-platform/quote-management'`, so hoist the whole scope into the
7
+ ; project's node_modules root. npm and bun hoist by default and ignore this.
8
+ public-hoist-pattern[]=@vendure-platform/*
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Vendure Platform edition configuration.
3
+ *
4
+ * The Vendure CLI maintains this file. `vendure edition prepare <edition>`
5
+ * replaces it in full, so an edit made here is lost at the next edition change.
6
+ * Put your own configuration in `vendure-config.ts` instead.
7
+ *
8
+ * @vendure-platform/cli:edition-config
9
+ */
10
+
11
+ /**
12
+ * The edition this deployment composes.
13
+ *
14
+ * `VendurePlatform` from the edition package supplies the composition profile
15
+ * and the option types for this edition. A composition hint, never an
16
+ * authorization source: License Guard compares the modules this composes
17
+ * against the signed Entitlement Grant while booting and fails closed when
18
+ * they disagree.
19
+ */
20
+ export { VendurePlatform } from '@vendure-platform/{{profile}}';
21
+ export type { VendurePlatformOptions } from '@vendure-platform/{{profile}}';
22
+ export { bootstrap, bootstrapWorker } from '@vendure-platform/{{profile}}';
23
+ export { dashboardPackageScanner } from '@vendure-platform/{{profile}}';
@@ -7,9 +7,9 @@ import {
7
7
  runPopulators,
8
8
  DataPopulator,
9
9
  } from '@vendure-platform/data-populator';
10
- import { bootstrap } from '@vendure-platform/platform';
11
10
  import { defaultScenario } from '@vendure-platform/scenario-default';
12
11
  import { customPopulator } from './custom-populate';
12
+ import { bootstrap } from './platform-edition';
13
13
  import { config } from './vendure-config';
14
14
 
15
15
  const defaultPopulators = defaultScenario.getPopulators([]) as DataPopulator[];
@@ -22,8 +22,8 @@ runPopulators({
22
22
  schemas: ['audit_trail'],
23
23
  {{/ifPlugin}}
24
24
  checkCoreDataExists,
25
- // Use Vendure Platform's bootstrap (not @vendure/core's) so platform
26
- // plugins initialise correctly during population.
25
+ // Use the edition's bootstrap (not @vendure/core's) so platform plugins
26
+ // initialise correctly during population.
27
27
  bootstrap,
28
28
  }).catch((err) => {
29
29
  console.error('Population failed:', err);
@@ -9,24 +9,31 @@
9
9
  "build": "tsc",
10
10
  "build:dashboard": "vite build",
11
11
  "start": "node dist/index.js",
12
- "populate": "node --require ts-node/register src/populate.ts"
12
+ "populate": "node --require ts-node/register src/populate.ts",
13
+ "migration:generate": "node --require ts-node/register src/migrate.ts generate",
14
+ "migration:run": "node --require ts-node/register src/migrate.ts run"
13
15
  },
14
16
  "dependencies": {
15
- "@vendure/core": "^3.6.2",
16
- "@vendure/dashboard": "^3.6.2",
17
- "@vendure/asset-server-plugin": "^3.6.2",
17
+ "@vendure/core": "^3.8.0-0",
18
+ "@vendure/dashboard": "^3.8.0-0",
19
+ "@vendure/asset-server-plugin": "^3.8.0-0",
18
20
  "typeorm": "^0.3.27",
19
21
  "@vendure-platform/data-populator": "{{pluginVersionSpec}}",
20
- "@vendure-platform/integration": "{{pluginVersionSpec}}",
21
22
  "@vendure-platform/scenario-default": "{{pluginVersionSpec}}",
22
- "@vendure-platform/platform": "{{pluginVersionSpec}}",
23
- "dotenv": "^16.4.7"{{pluginDependencies}}
23
+ "dotenv": "^16.4.7"{{platformDependencies}}
24
24
  },
25
25
  "devDependencies": {
26
26
  "vite": "^6.3.5",
27
27
  "ts-node": "^10.9.2",
28
28
  "typescript": "^5.9.3",
29
29
  "@types/node": "^22.0.0",
30
- "@vendure/testing": "^3.6.2"
30
+ "@vendure/cli": "^3.8.0-0",
31
+ "@vendure/testing": "^3.8.0-0",
32
+ "@vendure-platform/cli": "{{pluginVersionSpec}}"
33
+ },
34
+ "vendure": {
35
+ "cli": {
36
+ "plugins": ["@vendure-platform/cli"]
37
+ }
31
38
  }
32
39
  }
@@ -1,8 +1,8 @@
1
- {{platformPluginImports}}
2
- import { AssetServerPlugin } from '@vendure/asset-server-plugin';
1
+ {{platformPluginImports}}import { AssetServerPlugin } from '@vendure/asset-server-plugin';
3
2
  import {
4
3
  configureDefaultOrderProcess,
5
4
  DefaultJobQueuePlugin,
5
+ DefaultSchedulerPlugin,
6
6
  dummyPaymentHandler,
7
7
  NativeAuthenticationStrategy,
8
8
  VendureConfig,
@@ -10,8 +10,20 @@ import {
10
10
  import { DashboardPlugin } from '@vendure/dashboard/plugin';
11
11
  import * as path from 'path';
12
12
  import type { DataSourceOptions } from 'typeorm';
13
+ {{platformEditionImport}}
13
14
 
14
15
  const IS_DEV = process.env.APP_ENV === 'dev';
16
+ {{#ifPlugin "global-search"}}
17
+
18
+ /**
19
+ * True in the one-shot populate process: the `populate` script runs
20
+ * `src/populate.ts` through ts-node. `custom-populate.ts` is imported by it,
21
+ * never started on its own.
22
+ */
23
+ function isPopulateProcess(): boolean {
24
+ return /(^|[\\/])populate\.ts$/.test(process.argv[1] ?? '');
25
+ }
26
+ {{/ifPlugin}}
15
27
 
16
28
  export const dbOptions: DataSourceOptions = {
17
29
  type: 'postgres',
@@ -72,8 +84,19 @@ export const config: VendureConfig = {
72
84
  DefaultJobQueuePlugin.init({
73
85
  pollInterval: 2000,
74
86
  }),
87
+ // Without a scheduler plugin Vendure uses `NoopSchedulerStrategy`, and
88
+ // every scheduled task the platform plugins declare never runs.
89
+ DefaultSchedulerPlugin.init({}),
75
90
  ...VendurePlatform.init({
76
91
  {{platformPluginOptions}}
92
+ {{#ifPlugin "global-search"}}
93
+ globalSearch: {
94
+ // Populate writes thousands of records, and each one would queue
95
+ // its own Global Search update. The server builds the whole index
96
+ // when it starts, so the populate process skips those updates.
97
+ subscribeToEntityEvents: !isPopulateProcess(),
98
+ },
99
+ {{/ifPlugin}}
77
100
  }),
78
101
  DashboardPlugin.init({
79
102
  appDir: IS_DEV
@@ -2,6 +2,7 @@ import { vendureDashboardPlugin } from '@vendure/dashboard/vite';
2
2
  import { join, resolve } from 'path';
3
3
  import { pathToFileURL } from 'url';
4
4
  import { defineConfig } from 'vite';
5
+ import { dashboardPackageScanner } from './src/platform-edition';
5
6
 
6
7
  const vendurePort = process.env.VENDURE_PORT ? parseInt(process.env.VENDURE_PORT, 10) : 3500;
7
8
 
@@ -17,6 +18,10 @@ export default defineConfig({
17
18
  ? { host: 'auto', port: 'auto' }
18
19
  : { host: 'http://localhost', port: vendurePort },
19
20
  gqlOutputPath: './src/gql',
21
+ // The build finds Dashboard extensions by expanding the edition package's
22
+ // dependencies. The edition knows where those resolve from on every
23
+ // package-manager layout; the default guess only covers a hoisted install.
24
+ pluginPackageScanner: dashboardPackageScanner(),
20
25
  }),
21
26
  ],
22
27
  resolve: {
package/dist/bin/run.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(){var n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},n(e)};return function(o){if(o&&o.__esModule)return o;var r={};if(null!=o)for(var i=n(o),a=0;a<i.length;a++)"default"!==i[a]&&e(r,o,i[a]);return t(r,o),r}}();Object.defineProperty(exports,"__esModule",{value:!0});const o=require("commander"),r=n(require("fs")),i=n(require("path")),a=require("../add-to-existing"),s=require("../cli"),u=require("../scaffold-storefront-only"),l=require("../scaffolder");function c(){const e=i.join(__dirname,"..","..","package.json");return JSON.parse(r.readFileSync(e,"utf8")).version}const p=(new o.Command).name("create-vendure-platform").description("Scaffold a Vendure project with Vendure Platform plugins, or a standalone storefront").version(c(),"-v, --version").enablePositionalOptions();p.command("add").description("Add Vendure Platform to an existing Vendure project (run from the project root)").option("--plugins <list>","Comma-separated list of plugin keys to include (skips the interactive prompt)").option("--registry-token <token>","Vendure private-registry npm auth token (written to project .npmrc as _authToken)").option("--license-token <token>","Vendure Platform server-side license token (written to .env as VENDURE_PLATFORM_LICENSE_TOKEN)").option("--dry-run","Show what would be changed without writing files").action(async e=>{const t=await(0,a.runAddToExistingCli)({plugins:e.plugins,dryRun:e.dryRun,registryToken:e.registryToken,licenseToken:e.licenseToken});await(0,a.addToExisting)(t)}),p.argument("[project-name]","Name of the project to create").option("--plugins <list>","Comma-separated list of plugin keys to include").option("--company <name>","Company name for the demo project").option("--no-storefront","Skip the Next.js storefront").option("--github","Create a GitHub repository").option("--github-org <org>","GitHub organization (only used with --github)","vendurehq").option("--no-github","Do not create a GitHub repository").option("--no-install","Skip dependency install").option("--no-git","Skip git init").option("--dry-run","Show what would be created without writing files").option("--storefront-only","Scaffold just the Next.js storefront, no server or plugins").option("--api-url <url>","Vendure Shop API URL (storefront-only mode)").option("--scenario <name>","Storefront scenario (storefront-only mode; default: customer)").option("--pm <bun|npm|pnpm>","Package manager used for the install step (default: bun)").option("--registry-token <token>","Vendure private-registry npm auth token (written to project .npmrc as _authToken)").option("--license-token <token>","Vendure Platform server-side license token (written to .env as VENDURE_PLATFORM_LICENSE_TOKEN)").action(async(e,t)=>{const n={plugins:t.plugins,company:t.company,storefront:t.storefront,github:t.github,githubOrg:t.githubOrg,install:t.install,git:t.git,dryRun:t.dryRun,storefrontOnly:t.storefrontOnly,apiUrl:t.apiUrl,scenario:t.scenario,pm:t.pm,registryToken:t.registryToken,licenseToken:t.licenseToken};if(n.storefrontOnly){const t=await(0,s.runStorefrontOnlyCli)(e,n);return void await(0,u.scaffoldStorefrontOnly)(t)}const o=await(0,s.runCli)(e,n);await(0,l.scaffold)(o)}),p.parseAsync().catch(e=>{console.error("Error:",e.message),process.exit(1)});
2
+ "use strict";var e=this&&this.__createBinding||(Object.create?function(e,o,t,n){void 0===n&&(n=t);var r=Object.getOwnPropertyDescriptor(o,t);r&&!("get"in r?!o.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return o[t]}}),Object.defineProperty(e,n,r)}:function(e,o,t,n){void 0===n&&(n=t),e[n]=o[t]}),o=this&&this.__setModuleDefault||(Object.create?function(e,o){Object.defineProperty(e,"default",{enumerable:!0,value:o})}:function(e,o){e.default=o}),t=this&&this.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(e){var o=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o[o.length]=t);return o},t(e)};return function(n){if(n&&n.__esModule)return n;var r={};if(null!=n)for(var i=t(n),s=0;s<i.length;s++)"default"!==i[s]&&e(r,n,i[s]);return o(r,n),r}}();Object.defineProperty(exports,"__esModule",{value:!0});const n=require("commander"),r=t(require("fs")),i=t(require("path")),s=require("../add-to-existing"),a=require("../cli"),l=require("../scaffold-storefront-only"),c=require("../scaffolder");function u(){const e=i.join(__dirname,"..","..","package.json");return JSON.parse(r.readFileSync(e,"utf8")).version}const f=(new n.Command).name("create-vendure-platform").description("Scaffold a Vendure project with Vendure Platform plugins, or a standalone storefront").version(u(),"-v, --version").enablePositionalOptions();f.command("add").description("Add Vendure Platform to an existing Vendure project (run from the project root)").option("--plugins <list>","Comma-separated list of plugin keys to include (skips the interactive prompt)").option("--registry-token <token>","Registry Access Token for CI and offline scaffolds (written to project .npmrc as _authToken). The interactive flow gets one from Vendure Console instead").option("--license-token <token>","Environment Credential for CI and offline scaffolds (written to .env as VENDURE_PLATFORM_LICENSE_TOKEN). The interactive flow leaves this to vendure dev").option("--dry-run","Show what would be changed without writing files").action(async e=>{const o=await(0,s.runAddToExistingCli)({plugins:e.plugins,dryRun:e.dryRun,registryToken:e.registryToken,licenseToken:e.licenseToken});await(0,s.addToExisting)(o)}),f.argument("[project-name]","Name of the project to create").option("--profile <name>","Edition to scaffold (starter|growth|scale|enterprise). Resolves the plugin set, options, and services from the edition grants").option("--company <name>","Company name for the demo project").option("--no-storefront","Skip the Next.js storefront").option("--github","Create a GitHub repository").option("--github-org <org>","GitHub organization (only used with --github)","vendurehq").option("--no-github","Do not create a GitHub repository").option("--no-install","Skip dependency install").option("--no-git","Skip git init").option("--dry-run","Show what would be created without writing files").option("--storefront-only","Scaffold just the Next.js storefront, no server or plugins").option("--api-url <url>","Vendure Shop API URL (storefront-only mode)").option("--scenario <name>","Storefront scenario (storefront-only mode; default: customer)").option("--pm <bun|npm|pnpm>","Package manager used for the install step (default: bun)").option("--registry-token <token>","Registry Access Token for CI and offline scaffolds (written to project .npmrc as _authToken). The interactive flow gets one from Vendure Console instead").option("--license-token <token>","Environment Credential for CI and offline scaffolds (written to .env as VENDURE_PLATFORM_LICENSE_TOKEN). The interactive flow leaves this to vendure dev").option("--console-project <id>","Use this Vendure Console Project instead of asking which one this is. Needs a stored Console session, or VENDURE_HUB_PROJECTS naming a file that lists it").action(async(e,o)=>{const t={profile:o.profile,company:o.company,storefront:o.storefront,github:o.github,githubOrg:o.githubOrg,install:o.install,git:o.git,dryRun:o.dryRun,storefrontOnly:o.storefrontOnly,apiUrl:o.apiUrl,scenario:o.scenario,pm:o.pm,registryToken:o.registryToken,licenseToken:o.licenseToken,consoleProject:o.consoleProject};if(t.storefrontOnly){const o=await(0,a.runStorefrontOnlyCli)(e,t);return void await(0,l.scaffoldStorefrontOnly)(o)}const n=await(0,a.runCli)(e,t);await(0,c.scaffold)(n)}),f.parseAsync().catch(e=>{"ConsoleOnboardingCancelled"===(null==e?void 0:e.name)&&(console.log(e.message),process.exit(0)),console.error("Error:",e.message),process.exit(1)});
package/dist/cli.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=this&&this.__createBinding||(Object.create?function(e,n,r,t){void 0===t&&(t=r);var i=Object.getOwnPropertyDescriptor(n,r);i&&!("get"in i?!n.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return n[r]}}),Object.defineProperty(e,t,i)}:function(e,n,r,t){void 0===t&&(t=r),e[t]=n[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),r=this&&this.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(e){var n=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[n.length]=r);return n},r(e)};return function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var o=r(t),l=0;l<o.length;l++)"default"!==o[l]&&e(i,t,o[l]);return n(i,t),i}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.runStorefrontOnlyCli=p,exports.runCli=d;const t=r(require("@clack/prompts")),i=require("./plugin-registry"),o=["bun","npm","pnpm"];function l(e){if(!e)return"bun";if(o.includes(e))return e;throw new Error(`Invalid --pm value "${e}". Must be one of: ${o.join(", ")}`)}function a(e){if(e)try{return new URL(e),e}catch{throw new Error(`Invalid --api-url value "${e}": not a valid URL`)}}function s(e){return 0===e.trim().length?"Project name is required":/[^a-zA-Z0-9._-]/.test(e)?"Project name may only contain letters, numbers, dots, hyphens, and underscores":void 0}function c(){return i.pluginRegistry.filter(e=>"optional"===e.tier||"requires-config"===e.tier).sort((e,n)=>e.category!==n.category?e.category.localeCompare(n.category):e.displayName.localeCompare(n.displayName)).map(e=>({label:`${e.displayName} (${e.category})`,value:e.key,hint:"requires-config"===e.tier?"needs configuration":void 0}))}function u(){return i.pluginRegistry.filter(e=>"optional"===e.tier).map(e=>e.key)}async function p(e,n){var r,i,o;const c=l(null==n?void 0:n.pm),u=a(null==n?void 0:n.apiUrl),p=null!==(r=null==n?void 0:n.scenario)&&void 0!==r?r:"customer";if(e&&u){const r=s(e);return r&&(t.log.error(`Error: ${r}`),process.exit(1)),{projectName:e,apiUrl:u,scenario:p,packageManager:c,skipInstall:!1===(null==n?void 0:n.install),skipGit:!1===(null==n?void 0:n.git),dryRun:null!==(i=null==n?void 0:n.dryRun)&&void 0!==i&&i}}if(t.intro("create-vendure-platform (storefront-only)"),e){const n=s(e);n&&(t.cancel(n),process.exit(1))}const d=await t.group({projectName:()=>e?Promise.resolve(e):t.text({message:"Project name:",validate:s}),apiUrl:()=>u?Promise.resolve(u):t.text({message:"Vendure Shop API URL (leave blank to use http://localhost:3500/shop-api):",placeholder:"https://shop.example.com/shop-api",validate:e=>{if(e)try{new URL(e)}catch{return"Must be a valid URL"}}}),installDeps:()=>t.confirm({message:`Install dependencies with ${c}?`,initialValue:!0})},{onCancel:()=>{t.cancel("Setup cancelled."),process.exit(0)}});return{projectName:d.projectName,apiUrl:d.apiUrl||void 0,scenario:p,packageManager:c,skipInstall:!d.installDeps,skipGit:!1===(null==n?void 0:n.git),dryRun:null!==(o=null==n?void 0:n.dryRun)&&void 0!==o&&o}}async function d(e,n){var r,i,o,a,p,d,m,v,g;const f=l(null==n?void 0:n.pm);if(e&&(null==n?void 0:n.company)&&void 0!==(null==n?void 0:n.plugins)){const l=s(e);l&&(t.log.error(`Error: ${l}`),process.exit(1));const c=n.plugins?n.plugins.split(",").map(e=>e.trim()).filter(Boolean):[];return{projectName:e,companyName:n.company,selectedPlugins:c,includeStorefront:null===(r=n.storefront)||void 0===r||r,createGithubRepo:null!==(i=n.github)&&void 0!==i&&i,githubOrg:n.githubOrg,packageManager:f,skipInstall:!1===n.install,skipGit:!1===n.git,dryRun:null!==(o=n.dryRun)&&void 0!==o&&o,registryToken:(null===(a=n.registryToken)||void 0===a?void 0:a.trim())||void 0,licenseToken:(null===(p=n.licenseToken)||void 0===p?void 0:p.trim())||void 0}}if(t.intro("create-vendure-platform"),e){const n=s(e);n&&(t.cancel(n),process.exit(1))}const y=c(),h=u(),k=await t.group({projectName:()=>e?Promise.resolve(e):t.text({message:"Project name:",validate:s}),registryToken:()=>void 0!==(null==n?void 0:n.registryToken)?Promise.resolve(n.registryToken):t.password({message:`Vendure private-registry npm auth token (from https://enterprise.vendure.io). Used by \`${f} install\`. Leave blank to skip:`}),licenseToken:()=>void 0!==(null==n?void 0:n.licenseToken)?Promise.resolve(n.licenseToken):t.password({message:"Vendure Platform license token (server-side, written to .env). Leave blank to skip:"}),companyName:({results:e})=>{const n=e.projectName.replace(/^vendure-/,"").replace(/-demo$/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase());return t.text({message:"Company name (used in README and project branding):",defaultValue:n,placeholder:n})},selectedPlugins:()=>t.multiselect({message:"Optional plugins to include (core plugins are always installed):",options:y,initialValues:h,required:!1}),includeStorefront:()=>t.confirm({message:"Include the Next.js storefront?",initialValue:!0}),installDeps:()=>t.confirm({message:`Install dependencies with ${f}?`,initialValue:!0})},{onCancel:()=>{t.cancel("Setup cancelled."),process.exit(0)}}),b=null!==(m=null===(d=k.registryToken)||void 0===d?void 0:d.trim())&&void 0!==m?m:"",j=null!==(g=null===(v=k.licenseToken)||void 0===v?void 0:v.trim())&&void 0!==g?g:"";return{projectName:k.projectName,companyName:k.companyName,selectedPlugins:k.selectedPlugins,includeStorefront:k.includeStorefront,createGithubRepo:!1,githubOrg:void 0,packageManager:f,skipInstall:!k.installDeps,registryToken:""===b?void 0:b,licenseToken:""===j?void 0:j}}
1
+ "use strict";var e=this&&this.__createBinding||(Object.create?function(e,o,n,i){void 0===i&&(i=n);var t=Object.getOwnPropertyDescriptor(o,n);t&&!("get"in t?!o.__esModule:t.writable||t.configurable)||(t={enumerable:!0,get:function(){return o[n]}}),Object.defineProperty(e,i,t)}:function(e,o,n,i){void 0===i&&(i=n),e[i]=o[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,o){Object.defineProperty(e,"default",{enumerable:!0,value:o})}:function(e,o){e.default=o}),n=this&&this.__importStar||function(){var n=function(e){return n=Object.getOwnPropertyNames||function(e){var o=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(o[o.length]=n);return o},n(e)};return function(i){if(i&&i.__esModule)return i;var t={};if(null!=i)for(var r=n(i),l=0;l<r.length;l++)"default"!==r[l]&&e(t,i,r[l]);return o(t,i),t}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.runStorefrontOnlyCli=y,exports.runCli=b;const i=n(require("@clack/prompts")),t=require("@vendure-platform/plugin-meta"),r=n(require("path")),l=require("./console-onboarding"),a=require("./hub-projects"),s=require("./plugin-registry");function c(e){if(e){if(!(0,s.isCapabilityProfileName)(e))throw new Error(`Invalid --profile value "${e}". Must be one of: ${s.CAPABILITY_PROFILE_NAMES.join(", ")}`);return e}}function u(e){return e?[...t.CAPABILITY_PROFILES[e]]:void 0}const d=["bun","npm","pnpm"];function p(e){if(!e)return"bun";if(d.includes(e))return e;throw new Error(`Invalid --pm value "${e}". Must be one of: ${d.join(", ")}`)}function v(e){if(e)try{return new URL(e),e}catch{throw new Error(`Invalid --api-url value "${e}": not a valid URL`)}}function f(e){return 0===e.trim().length?"Project name is required":/[^a-zA-Z0-9._-]/.test(e)?"Project name may only contain letters, numbers, dots, hyphens, and underscores":void 0}function m(){return Boolean(process.stdin.isTTY&&process.stdout.isTTY)}function g(e){if(!m())throw new Error(`No interactive terminal is available and required values are missing: ${e.join(", ")}. Pass them as flags to scaffold non-interactively.`)}async function h(e){const o=(0,a.resolveHubProjectSource)();if(!o)return;const n=await(0,a.listHubProjects)(o,e=>i.log.warn(`Could not read your Vendure Console projects: ${e}`));if(0===n.length)return;if(e){const o=n.find(o=>o.id===e);if(!o)throw new Error(`--console-project ${e} is not in the project list. Available: ${n.map(e=>e.id).join(", ")}`);return o}const t=await i.select({message:"Which Vendure Console project is this?",options:[...n.map(e=>({label:e.name,value:e.id,hint:`${e.edition} edition`})),{label:"None of these (choose an edition myself)",value:""}]});return i.isCancel(t)&&(i.cancel("Setup cancelled."),process.exit(0)),n.find(e=>e.id===t)}async function y(e,o){var n,t,r;const l=p(null==o?void 0:o.pm),a=v(null==o?void 0:o.apiUrl),d=null!==(n=null==o?void 0:o.scenario)&&void 0!==n?n:"customer",m=c(null==o?void 0:o.profile);if(e&&a){const n=f(e);return n&&(i.log.error(`Error: ${n}`),process.exit(1)),{projectName:e,apiUrl:a,scenario:d,capabilities:u(m),packageManager:l,skipInstall:!1===(null==o?void 0:o.install),skipGit:!1===(null==o?void 0:o.git),dryRun:null!==(t=null==o?void 0:o.dryRun)&&void 0!==t&&t}}if(g([...e?[]:["<project-name>"],...a?[]:["--api-url"]]),i.intro("create-vendure-platform (storefront-only)"),e){const o=f(e);o&&(i.cancel(o),process.exit(1))}const h=await i.group({projectName:()=>e?Promise.resolve(e):i.text({message:"Project name:",validate:f}),apiUrl:()=>a?Promise.resolve(a):i.text({message:"Vendure Shop API URL (leave blank to use http://localhost:3500/shop-api):",placeholder:"https://shop.example.com/shop-api",validate:e=>{if(e)try{new URL(e)}catch{return"Must be a valid URL"}}}),profile:()=>m?Promise.resolve(m):i.select({message:"Capability profile of the Vendure server this storefront connects to:",options:[...s.CAPABILITY_PROFILE_NAMES.map(e=>({label:e,value:e})),{label:"Not known yet (set NEXT_PUBLIC_VENDURE_CAPABILITIES in .env.local later)",value:""}]}),installDeps:()=>i.confirm({message:`Install dependencies with ${l}?`,initialValue:!0})},{onCancel:()=>{i.cancel("Setup cancelled."),process.exit(0)}});return{projectName:h.projectName,apiUrl:h.apiUrl||void 0,scenario:d,capabilities:u(h.profile||void 0),packageManager:l,skipInstall:!h.installDeps,skipGit:!1===(null==o?void 0:o.git),dryRun:null!==(r=null==o?void 0:o.dryRun)&&void 0!==r&&r}}async function b(e,o){var n,t,a,u,d,v,m,y,b,P,w,k,I;const E=p(null==o?void 0:o.pm),R=c(null==o?void 0:o.profile);if((null==o?void 0:o.consoleProject)&&R)throw new Error("--console-project is mutually exclusive with --profile. The Project names the edition.");if(e&&(null==o?void 0:o.company)&&R){const r=f(e);return r&&(i.log.error(`Error: ${r}`),process.exit(1)),{projectName:e,companyName:o.company,selectedPlugins:(0,s.resolveProfilePluginKeys)(R),profile:R,includeStorefront:null===(n=o.storefront)||void 0===n||n,createGithubRepo:null!==(t=o.github)&&void 0!==t&&t,githubOrg:o.githubOrg,packageManager:E,skipInstall:!1===o.install,skipGit:!1===o.git,dryRun:null!==(a=o.dryRun)&&void 0!==a&&a,registryToken:(null===(u=o.registryToken)||void 0===u?void 0:u.trim())||void 0,licenseToken:(null===(d=o.licenseToken)||void 0===d?void 0:d.trim())||void 0}}if(e&&(null==o?void 0:o.company)&&(null==o?void 0:o.consoleProject)){const n=f(e);if(n)throw new Error(n);const i=await h(o.consoleProject);let t,a=null==i?void 0:i.edition;if(!i){if(t=await(0,l.startConsoleOnboarding)({projectDir:r.resolve(process.cwd(),e),interactive:!1,projectId:o.consoleProject}),!t)throw new Error("--console-project needs a stored Vendure Console session, or VENDURE_HUB_PROJECTS naming a file that lists it. Neither was usable, and this run has no terminal to sign in from.");a=t.edition}const u=c(a);if(!u)throw new Error(`Vendure Console reports no edition for project ${o.consoleProject}, so there is no package set to scaffold. Give the Project an edition, or scaffold with --profile instead.`);return{projectName:e,companyName:o.company,selectedPlugins:(0,s.resolveProfilePluginKeys)(u),profile:u,includeStorefront:null===(v=o.storefront)||void 0===v||v,createGithubRepo:null!==(m=o.github)&&void 0!==m&&m,githubOrg:o.githubOrg,packageManager:E,skipInstall:!1===o.install,skipGit:!1===o.git,dryRun:null!==(y=o.dryRun)&&void 0!==y&&y,registryToken:(null===(b=o.registryToken)||void 0===b?void 0:b.trim())||void 0,licenseToken:(null===(P=o.licenseToken)||void 0===P?void 0:P.trim())||void 0,consoleOnboarding:t}}if(g([...e?[]:["<project-name>"],...(null==o?void 0:o.company)?[]:["--company"],...R?[]:["--profile"]]),i.intro("create-vendure-platform"),e){const o=f(e);o&&(i.cancel(o),process.exit(1))}const O=null!=e?e:await j();let N,_=R;if(!R&&!(null==o?void 0:o.dryRun)){const e=await h(null==o?void 0:o.consoleProject);e?(_=e.edition,i.log.info(`${e.name} is on the ${e.edition} edition.`)):(N=await(0,l.startConsoleOnboarding)({projectDir:r.resolve(process.cwd(),O),interactive:!0,projectId:null==o?void 0:o.consoleProject}),_=null==N?void 0:N.edition)}const C=await i.group({companyName:()=>{const e=O.replace(/^vendure-/,"").replace(/-demo$/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase());return i.text({message:"Company name (used in README and project branding):",defaultValue:e,placeholder:e})},edition:()=>_?Promise.resolve(_):i.select({message:"Which Vendure Platform edition is this project on?",options:s.CAPABILITY_PROFILE_NAMES.map(e=>({label:e,value:e}))}),includeStorefront:()=>i.confirm({message:"Include the Next.js storefront?",initialValue:!0}),installDeps:()=>i.confirm({message:`Install dependencies with ${E}?`,initialValue:!0})},{onCancel:()=>{i.cancel("Setup cancelled."),process.exit(0)}}),T=C.edition;return{projectName:O,companyName:C.companyName,selectedPlugins:(0,s.resolveProfilePluginKeys)(T),profile:T,includeStorefront:C.includeStorefront,createGithubRepo:!1,githubOrg:void 0,packageManager:E,skipInstall:!C.installDeps,dryRun:null!==(w=null==o?void 0:o.dryRun)&&void 0!==w&&w,registryToken:(null===(k=null==o?void 0:o.registryToken)||void 0===k?void 0:k.trim())||void 0,licenseToken:(null===(I=null==o?void 0:o.licenseToken)||void 0===I?void 0:I.trim())||void 0,consoleOnboarding:N}}async function j(){const e=await i.text({message:"Project name:",validate:f});return i.isCancel(e)&&(i.cancel("Setup cancelled."),process.exit(0)),e}
@@ -0,0 +1,44 @@
1
+ import type { CapabilityProfileName } from '@vendure-platform/plugin-meta';
2
+ /**
3
+ * What a scaffold learned from Console before it wrote anything, and how to
4
+ * finish once there is a directory to write into.
5
+ */
6
+ export interface ConsoleOnboarding {
7
+ project: {
8
+ id: string;
9
+ name: string;
10
+ };
11
+ /** The edition the Project holds, which decides the facade and the options. */
12
+ edition: CapabilityProfileName | undefined;
13
+ /**
14
+ * Write the Project Link Manifest and acquire the Registry Access Token for
15
+ * `projectDir`. Called once the directory exists.
16
+ */
17
+ finish(projectDir: string): Promise<ConsoleOnboardingResult>;
18
+ }
19
+ export interface ConsoleOnboardingResult {
20
+ registryUrl: string;
21
+ scope: string;
22
+ /** Undefined when no token could be issued; `registryLogin` then says why. */
23
+ registryToken?: string;
24
+ registryLogin?: string;
25
+ }
26
+ /**
27
+ * Sign in to Console and decide which Project this scaffold is for.
28
+ *
29
+ * Returns `undefined` for every ordinary reason a scaffold carries on without
30
+ * Console: no terminal to ask in, a declined login, or a session another
31
+ * process holds the lock on. An offline scaffold is a supported flow, so none
32
+ * of those stop the run.
33
+ */
34
+ export declare function startConsoleOnboarding(options: {
35
+ /** The directory the scaffold will create. Anchors the create Idempotency-Key. */
36
+ projectDir: string;
37
+ interactive: boolean;
38
+ /**
39
+ * The Project to use, instead of asking. A Project the account does not
40
+ * hold is an error: creating one is a decision, and naming an id is a
41
+ * different one already taken.
42
+ */
43
+ projectId?: string;
44
+ }): Promise<ConsoleOnboarding | undefined>;
@@ -0,0 +1 @@
1
+ "use strict";var e=this&&this.__createBinding||(Object.create?function(e,n,t,o){void 0===o&&(o=t);var r=Object.getOwnPropertyDescriptor(n,t);r&&!("get"in r?!n.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,o,r)}:function(e,n,t,o){void 0===o&&(o=t),e[o]=n[t]}),n=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),t=this&&this.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(e){var n=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[n.length]=t);return n},t(e)};return function(o){if(o&&o.__esModule)return o;var r={};if(null!=o)for(var i=t(o),s=0;s<i.length;s++)"default"!==i[s]&&e(r,o,i[s]);return n(r,o),r}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.startConsoleOnboarding=a;const o=t(require("@clack/prompts")),r=require("@vendure-platform/console-auth"),i=require("./plugin-registry"),s=require("./registry");async function a(e){let n;try{n=(0,r.consoleOrigins)({apiOrigin:process.env.VENDURE_CONSOLE_API_URL,appOrigin:process.env.VENDURE_CONSOLE_APP_URL})}catch(e){return void o.log.warn(`${d(e)} Continuing without Vendure Console.`)}const t=await l(n,e.interactive);if(!t)return;let s=t;const a=new r.ConsoleApi({apiOrigin:n.apiOrigin,getAccessToken:()=>s,refreshAccessToken:async()=>{s=await(0,r.refreshStoredConsoleToken)(n)}});let g;try{g=await(0,r.selectConsoleProject)({api:a,interaction:u(e.projectId),projectRoot:e.projectDir})}catch(e){if(e instanceof r.ConsoleOnboardingCancelled)throw e;return void o.log.warn(`${d(e)} Continuing without a Vendure Console Project.`)}return{project:{id:g.project.id,name:g.project.name},edition:g.edition&&(0,i.isCapabilityProfileName)(g.edition)?g.edition:void 0,finish:e=>c(a,g.project,e)}}async function c(e,n,t){await(0,r.writeProjectLink)({api:e,interaction:u(),projectRoot:t,projectId:n.id}),o.log.success(`Linked ${t} to ${n.name}.`);const i=await(0,r.acquireRegistryAccess)({api:e,projectId:n.id,interaction:{confirmRotate:async e=>{const n=await o.confirm({message:`Replace the Registry Access Token "${e}"? Whatever installs with the current one stops working.`,initialValue:!1});if(o.isCancel(n))throw new r.ConsoleOnboardingCancelled;return n},report:e=>o.log.info(e),warn:e=>o.log.warn(e)},defaultRegistryUrl:(0,s.getRegistryUrl)(),defaultScope:s.REGISTRY_SCOPE});if("npm-login"===i.fallback){const e=`npm login --auth-type=web --registry=${(0,s.registryLoginUrl)(i.registryUrl)}`;return o.log.warn(`Your Console account cannot issue Registry Access Tokens for ${n.name}. Log in to the registry instead:\n ${e}`),{registryUrl:i.registryUrl,scope:i.scope,registryLogin:e}}return{registryUrl:i.registryUrl,scope:i.scope,registryToken:i.token}}async function l(e,n){try{const n=await(0,r.resolveStoredConsoleToken)(e);if(n)return n}catch(e){return void o.log.warn(`${d(e)} Continuing without Vendure Console.`)}if(!n)return;const t=await o.confirm({message:"Sign in to Vendure Console to set this project up?",initialValue:!0});if(o.isCancel(t))throw new r.ConsoleOnboardingCancelled;if(!t)return;const i=o.spinner();i.start("Waiting for you to finish signing in to Vendure Console");try{const n=await(0,r.loginAndStoreConsoleToken)({client:"create",...e,reportAuthorizationUrl:e=>o.log.info(`Open this URL to sign in: ${e}`)});return i.stop("Signed in to Vendure Console."),n}catch(e){return i.stop("Could not sign in to Vendure Console."),void o.log.warn(`${d(e)} Continuing without it.`)}}function u(e){return{chooseProject:async n=>{if(e){const t=n.find(n=>n.id===e);if(!t)throw new Error(`--console-project ${e} is not one of your Vendure Console Projects.`);return t}const t=await o.select({message:"Which Vendure Console Project is this?",options:[...n.map(e=>({label:e.name,value:e.id,hint:e.edition?`${e.edition} edition`:"no edition yet"})),{label:"Create a new Project",value:""}]});if(o.isCancel(t))throw new r.ConsoleOnboardingCancelled;return n.find(e=>e.id===t)},newProjectName:async()=>{const e=await o.text({message:"Name for the new Vendure Console Project:",validate:e=>e.trim()?void 0:"A name is required"});if(o.isCancel(e))throw new r.ConsoleOnboardingCancelled;return e},chooseEvaluation:async e=>{const n=await o.select({message:"This Project has no edition yet. Which one would you like to evaluate?",options:[...e.map(e=>({label:`${e} edition`,value:e})),{label:"Not now",value:""}]});if(o.isCancel(n))throw new r.ConsoleOnboardingCancelled;return e.find(e=>e===n)},report:e=>o.log.info(e),warn:e=>o.log.warn(e)}}function d(e){return e instanceof Error?e.message:String(e)}
@@ -0,0 +1,48 @@
1
+ import type { CapabilityProfileName } from '@vendure-platform/plugin-meta';
2
+ /**
3
+ * A project the authenticated account owns in the Vendure Console (Hub), with
4
+ * the edition it was sold. The edition decides which facade the scaffolded
5
+ * project installs, which options block it writes, and whether it receives
6
+ * storefront assets.
7
+ */
8
+ export interface HubProject {
9
+ id: string;
10
+ name: string;
11
+ edition: CapabilityProfileName;
12
+ }
13
+ /** Where `create` reads the account's projects from. */
14
+ export interface HubProjectSource {
15
+ listProjects(): Promise<HubProject[]>;
16
+ }
17
+ /**
18
+ * Environment variable naming a JSON file of `HubProject` records. Used by the
19
+ * create-flow harness and by demo scaffolds that must exercise the Console path
20
+ * offline.
21
+ */
22
+ export declare const HUB_PROJECTS_FIXTURE_ENV = "VENDURE_HUB_PROJECTS";
23
+ export declare const CONSOLE_ACCESS_TOKEN_ENV = "VENDURE_CONSOLE_ACCESS_TOKEN";
24
+ /** Reads projects from a JSON file. Throws when the file is missing or malformed. */
25
+ export declare function fileHubProjectSource(path: string): HubProjectSource;
26
+ /** Reads projects with the WorkOS bearer token issued by Vendure Console. */
27
+ export declare function httpHubProjectSource(accessToken: string, options?: {
28
+ apiOrigin?: string;
29
+ fetch?: typeof globalThis.fetch;
30
+ timeoutMs?: number;
31
+ }): HubProjectSource;
32
+ /**
33
+ * The source to use, or `undefined` when no Console credential is configured.
34
+ * A caller that gets `undefined` must fall back to a manual selection rather
35
+ * than blocking — an offline scaffold is a supported flow.
36
+ */
37
+ export declare function resolveHubProjectSource(env?: NodeJS.ProcessEnv): HubProjectSource | undefined;
38
+ /** Validates the wire shape. An unknown edition is a hard error, not a silent Starter. */
39
+ export declare function parseHubProjects(value: unknown): HubProject[];
40
+ /**
41
+ * The account's projects, or an empty list when no source is configured or the
42
+ * lookup fails.
43
+ *
44
+ * `onLookupFailed` fires only for the second case. Having no Console credential
45
+ * is the normal state of an offline scaffold, not something to report, and a
46
+ * caller that announced it would print a line on every interactive run.
47
+ */
48
+ export declare function listHubProjects(source: HubProjectSource | undefined, onLookupFailed?: (reason: string) => void): Promise<HubProject[]>;
@@ -0,0 +1 @@
1
+ "use strict";var e=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var n=Object.getOwnPropertyDescriptor(r,t);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,n)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),r=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),t=this&&this.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(e){var r=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[r.length]=t);return r},t(e)};return function(o){if(o&&o.__esModule)return o;var n={};if(null!=o)for(var i=t(o),s=0;s<i.length;s++)"default"!==i[s]&&e(n,o,i[s]);return r(n,o),n}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.CONSOLE_ACCESS_TOKEN_ENV=exports.HUB_PROJECTS_FIXTURE_ENV=void 0,exports.fileHubProjectSource=u,exports.httpHubProjectSource=c,exports.resolveHubProjectSource=l,exports.parseHubProjects=d,exports.listHubProjects=f;const o=require("@vendure-platform/console-auth"),n=t(require("fs-extra")),i=require("./plugin-registry");exports.HUB_PROJECTS_FIXTURE_ENV="VENDURE_HUB_PROJECTS",exports.CONSOLE_ACCESS_TOKEN_ENV="VENDURE_CONSOLE_ACCESS_TOKEN";const s="/v1/projects/editions",a=1e4;function u(e){return{listProjects:async()=>d(await n.readJson(e))}}function c(e,r={}){var t,n;const i=(0,o.consoleApiOrigin)(null!==(t=r.apiOrigin)&&void 0!==t?t:o.DEFAULT_CONSOLE_API_ORIGIN),u=null!==(n=r.fetch)&&void 0!==n?n:globalThis.fetch;return{listProjects:async()=>{var t;const o=new AbortController,n=setTimeout(()=>o.abort(),null!==(t=r.timeoutMs)&&void 0!==t?t:a);let c;try{c=await u(`${i}${s}`,{method:"GET",redirect:"error",signal:o.signal,headers:{Accept:"application/json",Authorization:`Bearer ${e}`}})}catch(e){if(e instanceof Error&&"AbortError"===e.name)throw new Error("The Vendure Console project lookup timed out.");throw new Error("Could not reach Vendure Console.")}finally{clearTimeout(n)}if(!c.ok)throw new Error(`Vendure Console returned HTTP ${c.status}.`);try{return d(await c.json())}catch(e){if(e instanceof SyntaxError)throw new Error("Vendure Console returned malformed JSON.");throw e}}}}function l(e=process.env){var r,t;const o=null===(r=e[exports.HUB_PROJECTS_FIXTURE_ENV])||void 0===r?void 0:r.trim();if(o)return u(o);const n=null===(t=e[exports.CONSOLE_ACCESS_TOKEN_ENV])||void 0===t?void 0:t.trim();return n?c(n):void 0}function d(e){if(!Array.isArray(e))throw new Error("Expected a JSON array of Vendure Console projects.");return e.map((e,r)=>{const t=e;if("string"!=typeof(null==t?void 0:t.id)||"string"!=typeof(null==t?void 0:t.name))throw new Error(`Console project at index ${r} has no id or name.`);if("string"!=typeof t.edition||!(0,i.isCapabilityProfileName)(t.edition))throw new Error(`Console project "${t.name}" has an unknown edition "${String(t.edition)}".`);return{id:t.id,name:t.name,edition:t.edition}})}async function f(e,r){if(!e)return[];try{return await e.listProjects()}catch(e){return null==r||r(e instanceof Error?e.message:String(e)),[]}}