@vendure-platform/create 1.0.0 → 1.0.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/CHANGELOG.md +10 -0
- package/dist/add-to-existing.d.ts +4 -3
- package/dist/add-to-existing.js +1 -1
- package/dist/assets/storefront/package.json +1 -1
- package/dist/assets/templates/AGENTS.md.hbs +12 -10
- package/dist/assets/templates/README.md.hbs +37 -29
- package/dist/assets/templates/bunfig.toml.hbs +9 -5
- package/dist/assets/templates/migrate.ts.hbs +5 -5
- package/dist/assets/templates/root-package.json.hbs +3 -3
- package/dist/assets/templates/server-package.json.hbs +1 -1
- package/dist/console-onboarding.d.ts +7 -5
- package/dist/console-onboarding.js +1 -1
- package/dist/docs-url.d.ts +2 -0
- package/dist/docs-url.js +1 -0
- package/dist/env-file.d.ts +7 -0
- package/dist/env-file.js +1 -0
- package/dist/registry.d.ts +9 -0
- package/dist/registry.js +1 -1
- package/dist/scaffold-shared.js +1 -1
- package/dist/scaffolder.js +1 -1
- package/dist/template-renderer.d.ts +5 -0
- package/dist/template-renderer.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 1.0.1 (2026-10-13)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- use the selected package manager in production commands ([#772](https://github.com/vendurehq/vendure-ee/pull/772))
|
|
6
|
+
- use working registry token recovery steps after scaffolding ([#771](https://github.com/vendurehq/vendure-ee/pull/771))
|
|
7
|
+
- exempt Vendure Core packages from the Bun release-age rule ([#770](https://github.com/vendurehq/vendure-ee/pull/770))
|
|
8
|
+
- stop create add when core is not installed and its range is below 3.8.0 ([#769](https://github.com/vendurehq/vendure-ee/pull/769))
|
|
9
|
+
- recover from a console permission denial instead of falling back to offline setup ([#768](https://github.com/vendurehq/vendure-ee/pull/768))
|
|
10
|
+
|
|
1
11
|
## 1.0.0 (2026-10-12)
|
|
2
12
|
|
|
3
13
|
### ⚠️ Breaking Changes
|
|
@@ -79,9 +79,10 @@ interface DetectedProject {
|
|
|
79
79
|
export declare function detectExistingProject(projectDir: string): Promise<DetectedProject>;
|
|
80
80
|
/**
|
|
81
81
|
* Throw when the project cannot run Vendure Platform: Core older than 3.8.0
|
|
82
|
-
* (a 3.8.0 prerelease is older)
|
|
83
|
-
*
|
|
84
|
-
*
|
|
82
|
+
* (a 3.8.0 prerelease is older), a `package.json` range that starts below
|
|
83
|
+
* 3.8.0 with no installed Core to check it against, or a database other than
|
|
84
|
+
* PostgreSQL. Call it before anything links the project, issues a token or
|
|
85
|
+
* writes a file. Returns warnings for facts it cannot read.
|
|
85
86
|
*/
|
|
86
87
|
export declare function assertSupportedProject(detected: DetectedProject): string[];
|
|
87
88
|
/**
|
package/dist/add-to-existing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,n,t,r){void 0===r&&(r=t);var o=Object.getOwnPropertyDescriptor(n,t);o&&!("get"in o?!n.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,r,o)}:function(e,n,t,r){void 0===r&&(r=t),e[r]=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(r){if(r&&r.__esModule)return r;var o={};if(null!=r)for(var i=t(r),s=0;s<i.length;s++)"default"!==i[s]&&e(o,r,i[s]);return n(o,r),o}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.detectExistingProject=m,exports.assertSupportedProject=k,exports.applyAddToExisting=x,exports.runAddToExistingCli=V,exports.addToExisting=I,exports.formatChecklist=N;const r=t(require("@clack/prompts")),o=require("@vendure-platform/console-auth"),i=require("@vendure-platform/plugin-meta"),s=t(require("fs-extra")),a=require("node:os"),d=t(require("path")),l=require("./console-onboarding"),u=require("./plugin-registry"),c=require("./template-renderer"),p="vendure-platform-installation-guide.md",h="@vendure-platform/cli",f="3.8.0",g='After the first boot, reindex search once, or storefront search returns nothing. See "Rebuild the search index" in the installation guide.',v=["postgres","mysql","mariadb","better-sqlite3","sqljs","sqlite","mssql","oracle","cockroachdb"];async function m(e){var n,t;const r=d.join(e,"package.json");if(!await s.pathExists(r))throw new Error(`No package.json found at ${r}. Run this from your Vendure project root.`);const o=await s.readJson(r),i={...null!==(n=o.dependencies)&&void 0!==n?n:{},...null!==(t=o.devDependencies)&&void 0!==t?t:{}},a="@vendure/core"in i,l=[d.join(e,"src","vendure-config.ts"),d.join(e,"server","src","vendure-config.ts"),d.join(e,"src","vendure-config.js")];let u=null;for(const e of l)if(await s.pathExists(e)){u=e;break}const c=w(u?await s.readFile(u,"utf8"):""),p=await y(e,i["@vendure/core"]);return{projectDir:e,packageJsonPath:r,vendureConfigPath:u,hasVendureCore:a,coreVersion:p.version,coreVersionIsRangeFloor:p.isRangeFloor,databaseType:b(c),hasDefaultSearchPlugin:c.includes("DefaultSearchPlugin.init"),envPath:d.join(e,".env"),npmrcPath:d.join(e,".npmrc"),gitignorePath:d.join(e,".gitignore")}}async function y(e,n){var t,r;const o=d.join(e,"node_modules","@vendure","core","package.json");if(await s.pathExists(o)){const e=(await s.readJson(o)).version;if("string"==typeof e)return{version:e,isRangeFloor:!1}}if("string"!=typeof n)return{version:null,isRangeFloor:!1};const i=null!==(r=null===(t=n.match(/\d+\.\d+\.\d+(?:-[\w.-]+)?/))||void 0===t?void 0:t[0])&&void 0!==r?r:null,a=n.trim();return{version:i,isRangeFloor:!(/^[=v]?\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(a)||/^~\d+\.\d+\.\d+$/.test(a))}}function w(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:'"`])\/\/.*$/gm,"$1")}function b(e){var n,t;const r=e.match(/dbConnectionOptions\s*:\s*\{/);if(!r||void 0===r.index)return null;let o=0,i=e.length;for(let n=r.index+r[0].length-1;n<e.length;n++)if("{"===e[n])o++;else if("}"===e[n]&&0===--o){i=n;break}const s=new RegExp(`\\btype:\\s*['"\`](${v.join("|")})['"\`]`);return null!==(t=null===(n=e.slice(r.index,i).match(s))||void 0===n?void 0:n[1])&&void 0!==t?t:null}function k(e){const n=[],t=null===e.coreVersion?null:P(e.coreVersion);if(null===t)n.push(`Could not read the @vendure/core version. Vendure Platform needs ${f} or later.`);else if(t){if(e.coreVersionIsRangeFloor)return n.push(`package.json allows @vendure/core ${e.coreVersion} or later, and Vendure Platform needs ${f} or later. Install dependencies and run this command again to check the installed version.`),n.concat(j(e));throw new Error(`This project uses @vendure/core ${e.coreVersion}. Vendure Platform needs ${f} or later, so the install would fail. Nothing was changed. Upgrade @vendure/core to ${f} or later, then run this command again.`)}return n.concat(j(e))}function P(e){const n=/^(\d+)\.(\d+)\.(\d+)(-)?/.exec(e);if(!n)return null;const t=f.split(".").map(Number);for(let e=0;e<3;e++){const r=Number(n[e+1]);if(r!==t[e])return r<t[e]}return void 0!==n[4]}function j(e){if(null===e.databaseType)return["Could not read dbConnectionOptions.type from vendure-config.ts. Vendure Platform needs PostgreSQL."];if("postgres"!==e.databaseType)throw new Error(`This project uses the "${e.databaseType}" database. Vendure Platform needs PostgreSQL, because its entities use column types other databases do not support. Nothing was changed. Move the project to PostgreSQL, then run this command again.`);return[]}async function x(e,n){const{profile:t,dryRun:r,licenseToken:f,consoleOnboarding:v}=n,m=(0,u.resolveProfilePluginKeys)(t).map(e=>(0,u.getPlugin)(e)),y=(0,c.resolvePluginVersionSpec)(),w=[],b=await(0,l.finishConsoleOnboarding)(r?void 0:v,n.projectDir,n.registryToken);b.registryLogin&&w.push(`Log in to the registry: ${b.registryLogin}`);const{token:k,projectId:P}=(0,l.resolveRegistryToken)(n.registryToken,b);b.registryAccessDenied&&!k?w.push("Ask a member with the Credential manager, Project admin or Admin role for a Registry Access Token, then run this command again with --registry-token."):k||b.registryLogin||w.push((0,l.registryTokenStep)(n.projectDir));const j=m.map(e=>e.packageName),{added:x,cliPluginRegistered:R}=await S(e.packageJsonPath,y,t,j,r);if(x.length>0){const e=1===x.length?x[0]:`${x.length} packages (${x[0]}, \u2026)`;w.push(`Added ${e} at ${y} to package.json \u2014 run \`npm install\` (or your package manager equivalent).`)}R&&w.push(`Registered ${h} under vendure.cli.plugins in package.json.`),w.push(...await $(e.packageJsonPath,(0,c.resolveMcpSdkVersion)(),r));const{context:T,hbs:V}=(0,c.buildTemplateContext)("","",!1,{profile:t,licenseToken:f,existingProject:!0}),I=(0,c.renderTemplate)((0,c.getTemplatePath)("env.hbs"),T,V),N=await C(e.envPath,I,r);if(N>0&&w.push(`Appended ${N} env var(s) to .env \u2014 fill in real values before booting.`),f&&await D(e.envPath,f,r)&&w.push("Filled in the empty VENDURE_PLATFORM_LICENSE_TOKEN value in .env."),r)w.push("Update .npmrc (registry scope, auth token, pnpm hoist line).");else{const n=!v||Boolean(k)||Boolean(b.registryLogin)||await(0,o.hasRegistryAuthToken)(e.projectDir,b.registryUrl)||await(0,o.hasRegistryAuthToken)((0,a.homedir)(),b.registryUrl);"written"===(await(0,o.ensureRegistryNpmrc)(e.projectDir,{registryUrl:b.registryUrl,scope:b.scope,token:k,projectId:P,routeScope:n})).kind&&w.push("Updated .npmrc."),n||w.push(`Left the ${b.scope} registry line out of .npmrc, because it fails every install without a token. Add it with a Registry Access Token: https://docs.platform.vendure.io/getting-started/registry-access`)}await A(e.gitignorePath,".npmrc",r)&&w.push("Added .npmrc to .gitignore so any future registry token never gets committed.");const O=E(m,t),_=d.join(e.projectDir,p);r||await s.writeFile(_,O),w.push(`Wrote ${d.relative(e.projectDir,_)} \u2014 follow it to wire up your vendure-config.ts.`);const q=d.join(e.vendureConfigPath?d.dirname(e.vendureConfigPath):d.join(e.projectDir,"src"),"platform-edition.ts"),F=await s.pathExists(q);r||F||(await s.ensureDir(d.dirname(q)),await s.writeFile(q,(0,i.renderEditionConfig)(t)));const W=d.relative(e.projectDir,q);return w.push(F?`Kept existing ${W}. Confirm that it exports the ${t} edition.`:`Wrote ${W} for the ${t} edition.`),w.push("Swap `import { bootstrap } from '@vendure/core'` for `'./platform-edition'` in your server entry file (and `bootstrapWorker` if you have a worker). See the installation guide's \"Bootstrap import\" section."),e.hasDefaultSearchPlugin&&w.push('Remove `DefaultSearchPlugin` from vendure-config.ts. Advanced Search replaces it, and the server fails to start with both. See the installation guide\'s "Remove DefaultSearchPlugin" section.'),w.push("Generate and run a migration for the new platform entities."),w.push("Rebuild the dashboard if you serve a pre-built artefact."),w.push("Grant new permissions to existing admin roles via Settings \u2192 Roles."),w.push(g),w}async function S(e,n,t,r,o){var a,d,l,u,c,p;const f=await s.readJson(e);null!==(a=f.dependencies)&&void 0!==a||(f.dependencies={});const g=[(0,i.facadePackageName)(t),...r].filter((e,n,t)=>t.indexOf(e)===n),v=[];for(const e of g)f.dependencies[e]||(f.dependencies[e]=n,v.push(e));null!==(d=f.devDependencies)&&void 0!==d||(f.devDependencies={}),f.dependencies[h]||f.devDependencies[h]||(f.devDependencies[h]=n,v.push(h));const m=null!==(c=null===(u=null===(l=f.vendure)||void 0===l?void 0:l.cli)||void 0===u?void 0:u.plugins)&&void 0!==c?c:[],y=!m.includes(h);return y&&(f.vendure={...f.vendure,cli:{...null===(p=f.vendure)||void 0===p?void 0:p.cli,plugins:[...m,h]}}),(v.length>0||y)&&!o&&await s.writeJson(e,f,{spaces:2}),{added:v,cliPluginRegistered:y}}async function $(e,n,t){var r,o;const i=await s.readJson(e),a=[];let d=!1;const l=null===(r=i.overrides)||void 0===r?void 0:r["@vendure/mcp-sdk"];if(void 0===l?(i.overrides={...i.overrides,"@vendure/mcp-sdk":n},d=!0,a.push(`Added an "overrides" entry for @vendure/mcp-sdk ${n} to package.json, so every package uses one copy of the MCP SDK. With pnpm, put the same entry under "overrides" in pnpm-workspace.yaml instead.`)):"string"!=typeof l||l.startsWith("$")?a.push(`package.json already overrides @vendure/mcp-sdk. Check that it resolves to ${n}, the version the Vendure Platform packages need.`):l!==n&&a.push(`package.json overrides @vendure/mcp-sdk to ${l}, but the Vendure Platform packages need ${n}. Set it to ${n}, or the MCP server lists none of their tools.`),i.overrides["@vendure/mcp-sdk"]===n)for(const e of["dependencies","devDependencies"]){const t=null===(o=i[e])||void 0===o?void 0:o["@vendure/mcp-sdk"];void 0!==t&&t!==n&&(i[e]["@vendure/mcp-sdk"]=n,d=!0,a.push(`Changed @vendure/mcp-sdk in package.json ${e} from ${t} to ${n}, the version of the override. npm refuses an override that differs from a direct dependency.`))}return d&&!t&&await s.writeJson(e,i,{spaces:2}),a}async function D(e,n,t){if(!await s.pathExists(e))return!1;const r=(await s.readFile(e,"utf8")).split("\n");let o=!1;const i="VENDURE_PLATFORM_LICENSE_TOKEN";for(let e=0;e<r.length;e++){const t=r[e].trim();if(!t.startsWith("#")&&t===`${i}=`){r[e]=`${i}=${n}`,o=!0;break}}return o&&!t&&await s.writeFile(e,r.join("\n")),o}async function C(e,n,t){const r=await s.pathExists(e)?await s.readFile(e,"utf8"):"",o=new Set(r.split("\n").map(T).filter(Boolean)),i=[];let a=0;for(const e of n.split(/\n{2,}/)){const n=R(e.split("\n"),o),t=n.filter(e=>T(e)).length;0!==t&&(a+=t,i.push(n.join("\n")))}if(0===a||t)return a;if(""===r.trim())await s.writeFile(e,n);else{const n=r.endsWith("\n")?"":"\n",t=`\n# Added by @vendure-platform/create add\n${i.join("\n\n")}\n`;await s.writeFile(e,r+n+t)}return a}function R(e,n){const t=[];for(const r of e)if(n.has(T(r)))for(;t.length>1&&t[t.length-1].trim().startsWith("#");)t.pop();else t.push(r);return t}function T(e){var n,t;const r=e.trim();return r.startsWith("#")?"":null!==(t=null===(n=r.split("=")[0])||void 0===n?void 0:n.trim())&&void 0!==t?t:""}async function A(e,n,t){let r="";await s.pathExists(e)&&(r=await s.readFile(e,"utf8"));const o=r.split("\n").map(e=>e.trim());if(o.includes(n)||o.includes(`/${n}`))return!1;const i=""===r||r.endsWith("\n")?"":"\n";return t||await s.writeFile(e,r+i+n+"\n"),!0}function E(e,n){const t=(0,i.facadePackageName)(n),r=["import { VendurePlatform } from './platform-edition';"],{context:o,hbs:s}=(0,c.buildTemplateContext)("","",!1,{profile:n});for(const n of e)n.platformImports&&r.push(...n.platformImports);return`# Vendure Platform installation guide\n\nPaste these changes into your existing project. Step 1 is the most important \u2014\nwithout it, every Vendure Platform plugin refuses to start with\n\`LICENSE_GUARD_NONCE_MISMATCH\`.\n\n## 1. Bootstrap import (server entry point)\n\nIn your server entry file (typically \`src/index.ts\` or wherever you call\n\`bootstrap()\`), swap the bootstrap import from \`@vendure/core\` to\n\`./platform-edition\`:\n\n\`\`\`ts\n// before\nimport { bootstrap } from '@vendure/core';\n\n// after\nimport { bootstrap } from './platform-edition';\n\`\`\`\n\nIf you also run a separate worker process, swap \`bootstrapWorker\` too:\n\n\`\`\`ts\nimport { bootstrapWorker } from './platform-edition';\n\`\`\`\n\nThe \`./platform-edition\` bootstrap re-exports the \`${t}\`\ndrop-in wrapper around \`@vendure/core\`'s \`bootstrap\`. It primes the runtime license guard before\nNest builds the DI container. Without this swap, plugins like \`OrgAccountsPlugin\`\nfail at startup with \`LICENSE_GUARD_NONCE_MISMATCH\`.\n\n## 2. Imports in vendure-config.ts\n\nAdd to the top of the file (after your existing imports):\n\n\`\`\`ts\n${r.join("\n")}\n\`\`\`\n\n## 3. Plugins array\n\nSpread \`VendurePlatform.init({...})\` into the \`plugins\` array \u2014 typically\nbetween \`DefaultJobQueuePlugin\` and \`DashboardPlugin\`:\n\n\`\`\`ts\n...VendurePlatform.init({\n${s.compile("{{platformPluginOptions}}")(o)}\n}),\n\`\`\`\n\n## 4. Remove DefaultSearchPlugin\n\nAdvanced Search replaces Vendure's default search. If your config has it, delete \`DefaultSearchPlugin.init({...})\`\nfrom the \`plugins\` array and its import from \`@vendure/core\`. Projects from \`@vendure/create\`\nhave it. With both plugins the server stops at startup with\n\`Field "SearchResult.inStock" can only be defined once\`.\n\n## 5. Order process\n\nIf \`approvalWorkflows\` is selected, VendurePlatform will append\n\`approvalOrderProcess\` to your order process chain and override\n\`arrangingPaymentRequiresContents\` and \`checkAllItemsBeforeCancel\`. If you\nhave custom order process handlers they are preserved; the flags above are\nnot.\n\n## 6. Rebuild the search index\n\nAdvanced Search starts with an empty index and nothing fills it from your existing catalog. Until you rebuild it,\n\`search\` on the Shop API returns \`totalItems: 0\` even though \`products\` lists every product. Do this once per\nenvironment, after the server and a worker are running.\n\nUse a role with the \`UpdateCatalog\` permission. \`Superadmin\` has it. In the Dashboard, open **Search** and use the\n**Reindex** button, or call the Admin API:\n\n\`\`\`graphql\nmutation {\n reindex {\n id\n }\n}\n\`\`\`\n\nThe work runs on the worker, so a project with no running worker never finishes it. Watch the job under\n**System** \u2192 **Job queue**. The time grows with the number of product variants. A sample catalog of a few dozen\nproducts is quick, and a large catalog takes noticeably longer. When the\njob is completed, \`search(input: {}) { totalItems }\` returns your variants. New and changed products reach the\nindex by themselves from then on.\n\nSee https://docs.vendure.io/current/platform/getting-started/introduction for the full reference.\n`}async function V(e){var n,t,o,i;const s=process.cwd(),a=await m(s);a.hasVendureCore||r.log.warn("No @vendure/core dependency found in package.json. Continuing anyway \u2014 make sure this is the right directory."),a.vendureConfigPath?r.log.info(`Detected vendure-config.ts at ${d.relative(s,a.vendureConfigPath)}`):r.log.warn("No vendure-config.ts found under src/ or server/src/. The installation guide will still be written to the project root.");for(const e of k(a))r.log.warn(e);a.hasDefaultSearchPlugin&&r.log.warn("vendure-config.ts uses DefaultSearchPlugin. Remove it when you apply the installation guide: Advanced Search replaces it, and the server fails to start with both."),(void 0===e.profile||void 0===e.registryToken)&&r.intro("Add Vendure Platform to existing project");const c=null===(n=e.profile)||void 0===n?void 0:n.trim();let p;if(void 0!==c){if(!(0,u.isCapabilityProfileName)(c))throw new Error(`Unknown edition "${c}". Use starter, growth, scale, or enterprise.`);p=c}const h=void 0!==p||void 0!==e.registryToken||e.dryRun?void 0:await(0,l.startConsoleOnboarding)({projectDir:s,interactive:(0,l.isInteractive)()}),f=null!=p?p:null==h?void 0:h.edition;if(!f){if(void 0!==e.registryToken||e.dryRun)throw new Error("--profile is required when Console onboarding is skipped.");throw new Error("Could not determine the project edition. Link a Console Project with an edition or pass --profile.")}return{projectDir:s,profile:f,dryRun:null!==(t=e.dryRun)&&void 0!==t&&t,registryToken:(null===(o=e.registryToken)||void 0===o?void 0:o.trim())||void 0,licenseToken:(null===(i=e.licenseToken)||void 0===i?void 0:i.trim())||void 0,consoleOnboarding:h}}async function I(e){const n=await m(e.projectDir),t=u.ALWAYS_ACTIVE_KEYS.map(e=>(0,u.getPlugin)(e).displayName);t.length>0&&r.log.info(`Always-on core plugins: ${t.join(", ")}`);const o=N(await x(n,e));r.note(o,e.dryRun?"Dry run \u2014 would do:":"Next steps"),r.outro(e.dryRun?"Dry run complete \u2014 no files written.":"Done.")}function N(e){const n=Math.max(40,Math.min(process.stdout.columns||80,100)-6);return e.map((e,t)=>{const r=`${t+1}. `,o=" ".repeat(r.length);return O(e,n-r.length).map((e,n)=>(0===n?r:o)+e).join("\n")}).join("\n")}function O(e,n){const t=[];let r="";for(const o of e.split(/\s+/))""===r?r=o:r.length+1+o.length<=n?r+=" "+o:(t.push(r),r=o);return""!==r&&t.push(r),t.length>0?t:[""]}
|
|
1
|
+
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,n,t,r){void 0===r&&(r=t);var o=Object.getOwnPropertyDescriptor(n,t);o&&!("get"in o?!n.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,r,o)}:function(e,n,t,r){void 0===r&&(r=t),e[r]=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(r){if(r&&r.__esModule)return r;var o={};if(null!=r)for(var i=t(r),s=0;s<i.length;s++)"default"!==i[s]&&e(o,r,i[s]);return n(o,r),o}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.detectExistingProject=b,exports.assertSupportedProject=S,exports.applyAddToExisting=D,exports.runAddToExistingCli=_,exports.addToExisting=I,exports.formatChecklist=q;const r=t(require("@clack/prompts")),o=require("@vendure-platform/console-auth"),i=require("@vendure-platform/plugin-meta"),s=t(require("fs-extra")),a=require("node:os"),d=t(require("path")),l=require("./console-onboarding"),u=require("./docs-url"),c=require("./env-file"),p=require("./plugin-registry"),h=require("./registry"),f=require("./template-renderer"),g="vendure-platform-installation-guide.md",v="@vendure-platform/cli",m="3.8.0",y='After the first boot, reindex search once, or storefront search returns nothing. See "Rebuild the search index" in the installation guide.',w=["postgres","mysql","mariadb","better-sqlite3","sqljs","sqlite","mssql","oracle","cockroachdb"];async function b(e){var n,t;const r=d.join(e,"package.json");if(!await s.pathExists(r))throw new Error(`No package.json found at ${r}. Run this from your Vendure project root.`);const o=await s.readJson(r),i={...null!==(n=o.dependencies)&&void 0!==n?n:{},...null!==(t=o.devDependencies)&&void 0!==t?t:{}},a="@vendure/core"in i,l=[d.join(e,"src","vendure-config.ts"),d.join(e,"server","src","vendure-config.ts"),d.join(e,"src","vendure-config.js")];let u=null;for(const e of l)if(await s.pathExists(e)){u=e;break}const c=P(u?await s.readFile(u,"utf8"):""),p=await k(e,i["@vendure/core"]);return{projectDir:e,packageJsonPath:r,vendureConfigPath:u,hasVendureCore:a,coreVersion:p.version,coreVersionIsRangeFloor:p.isRangeFloor,databaseType:j(c),hasDefaultSearchPlugin:c.includes("DefaultSearchPlugin.init"),envPath:d.join(e,".env"),npmrcPath:d.join(e,".npmrc"),gitignorePath:d.join(e,".gitignore")}}async function k(e,n){var t,r;for(let n=e;;n=d.dirname(n)){const e=d.join(n,"node_modules","@vendure","core","package.json");if(await s.pathExists(e)){const n=(await s.readJson(e)).version;if("string"==typeof n)return{version:n,isRangeFloor:!1};break}if(d.dirname(n)===n)break}if("string"!=typeof n)return{version:null,isRangeFloor:!1};const o=null!==(r=null===(t=n.match(/\d+\.\d+\.\d+(?:-[\w.-]+)?/))||void 0===t?void 0:t[0])&&void 0!==r?r:null,i=n.trim();return{version:o,isRangeFloor:!(/^[=v]?\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(i)||/^~\d+\.\d+\.\d+$/.test(i))}}function P(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:'"`])\/\/.*$/gm,"$1")}function j(e){var n,t;const r=e.match(/dbConnectionOptions\s*:\s*\{/);if(!r||void 0===r.index)return null;let o=0,i=e.length;for(let n=r.index+r[0].length-1;n<e.length;n++)if("{"===e[n])o++;else if("}"===e[n]&&0===--o){i=n;break}const s=new RegExp(`\\btype:\\s*['"\`](${w.join("|")})['"\`]`);return null!==(t=null===(n=e.slice(r.index,i).match(s))||void 0===n?void 0:n[1])&&void 0!==t?t:null}function S(e){const n=[],t=null===e.coreVersion?null:$(e.coreVersion);if(null===t)n.push(`Could not read the @vendure/core version. Vendure Platform needs ${m} or later.`);else if(t){if(e.coreVersionIsRangeFloor)throw x(e),new Error(`package.json allows @vendure/core ${e.coreVersion} or later, and no installed @vendure/core was found to check the version. Vendure Platform needs ${m} or later. Nothing was changed. Run \`npm install\` (or \`pnpm install\`, \`yarn install\` or \`bun install\`) in this directory, then run this command again.`);throw new Error(`This project uses @vendure/core ${e.coreVersion}. Vendure Platform needs ${m} or later, so the install would fail. Nothing was changed. Upgrade @vendure/core to ${m} or later, then run this command again.`)}return n.concat(x(e))}function $(e){const n=/^(\d+)\.(\d+)\.(\d+)(-)?/.exec(e);if(!n)return null;const t=m.split(".").map(Number);for(let e=0;e<3;e++){const r=Number(n[e+1]);if(r!==t[e])return r<t[e]}return void 0!==n[4]}function x(e){if(null===e.databaseType)return["Could not read dbConnectionOptions.type from vendure-config.ts. Vendure Platform needs PostgreSQL."];if("postgres"!==e.databaseType)throw new Error(`This project uses the "${e.databaseType}" database. Vendure Platform needs PostgreSQL, because its entities use column types other databases do not support. Nothing was changed. Move the project to PostgreSQL, then run this command again.`);return[]}async function D(e,n){const{profile:t,dryRun:r,licenseToken:c,consoleOnboarding:m}=n,w=(0,p.resolveProfilePluginKeys)(t).map(e=>(0,p.getPlugin)(e)),b=(0,f.resolvePluginVersionSpec)(),k=[],P=await(0,l.finishConsoleOnboarding)(r?void 0:m,n.projectDir,n.registryToken);P.registryLogin&&k.push(`Log in to the registry: ${P.registryLogin}`);const{token:j,projectId:S}=(0,l.resolveRegistryToken)(n.registryToken,P);P.registryAccessDenied&&!j?k.push(`Ask a member with the Credential manager, Project admin or Admin role to create an access token on the Registry access page of the Project in Vendure Console. ${(0,h.setRegistryTokenStep)(P.registryUrl,e.npmrcPath)}`):j||P.registryLogin||k.push((0,l.registryTokenStep)(n.projectDir));const $=w.map(e=>e.packageName),{added:x,cliPluginRegistered:D}=await R(e.packageJsonPath,b,t,$,r);if(x.length>0){const e=1===x.length?x[0]:`${x.length} packages (${x[0]}, \u2026)`;k.push(`Added ${e} at ${b} to package.json \u2014 run \`npm install\` (or your package manager equivalent).`)}D&&k.push(`Registered ${v} under vendure.cli.plugins in package.json.`),k.push(...await C(e.packageJsonPath,(0,f.resolveMcpSdkVersion)(),r));const{context:A,hbs:V}=(0,f.buildTemplateContext)("","",!1,{profile:t,licenseToken:c,existingProject:!0}),_=(0,f.renderTemplate)((0,f.getTemplatePath)("env.hbs"),A,V),I=await E(e.envPath,_,r);if(I>0&&k.push(`Appended ${I} env var(s) to .env \u2014 fill in real values before booting.`),c&&await T(e.envPath,c,r)&&k.push("Filled in the empty VENDURE_PLATFORM_LICENSE_TOKEN value in .env."),r)k.push("Update .npmrc (registry scope, auth token, pnpm hoist line).");else{const n=!m||Boolean(j)||Boolean(P.registryLogin)||await(0,o.hasRegistryAuthToken)(e.projectDir,P.registryUrl)||await(0,o.hasRegistryAuthToken)((0,a.homedir)(),P.registryUrl);"written"===(await(0,o.ensureRegistryNpmrc)(e.projectDir,{registryUrl:P.registryUrl,scope:P.scope,token:j,projectId:S,routeScope:n})).kind&&k.push("Updated .npmrc."),n||k.push(`Left the ${P.scope} registry line out of .npmrc, because it fails every install without a token. Add it with a Registry Access Token: ${u.PLATFORM_DOCS_URL}/getting-started/registry-access`)}await N(e.gitignorePath,".npmrc",r)&&k.push("Added .npmrc to .gitignore so any future registry token never gets committed.");const q=O(w,t),F=d.join(e.projectDir,g);r||await s.writeFile(F,q),k.push(`Wrote ${d.relative(e.projectDir,F)} \u2014 follow it to wire up your vendure-config.ts.`);const L=d.join(e.vendureConfigPath?d.dirname(e.vendureConfigPath):d.join(e.projectDir,"src"),"platform-edition.ts"),U=await s.pathExists(L);r||U||(await s.ensureDir(d.dirname(L)),await s.writeFile(L,(0,i.renderEditionConfig)(t)));const W=d.relative(e.projectDir,L);return k.push(U?`Kept existing ${W}. Confirm that it exports the ${t} edition.`:`Wrote ${W} for the ${t} edition.`),k.push("Swap `import { bootstrap } from '@vendure/core'` for `'./platform-edition'` in your server entry file (and `bootstrapWorker` if you have a worker). See the installation guide's \"Bootstrap import\" section."),e.hasDefaultSearchPlugin&&k.push('Remove `DefaultSearchPlugin` from vendure-config.ts. Advanced Search replaces it, and the server fails to start with both. See the installation guide\'s "Remove DefaultSearchPlugin" section.'),k.push("Generate and run a migration for the new platform entities."),k.push("Rebuild the dashboard if you serve a pre-built artefact."),k.push("Grant new permissions to existing admin roles via Settings \u2192 Roles."),k.push(y),k}async function R(e,n,t,r,o){var a,d,l,u,c,p;const h=await s.readJson(e);null!==(a=h.dependencies)&&void 0!==a||(h.dependencies={});const f=[(0,i.facadePackageName)(t),...r].filter((e,n,t)=>t.indexOf(e)===n),g=[];for(const e of f)h.dependencies[e]||(h.dependencies[e]=n,g.push(e));null!==(d=h.devDependencies)&&void 0!==d||(h.devDependencies={}),h.dependencies[v]||h.devDependencies[v]||(h.devDependencies[v]=n,g.push(v));const m=null!==(c=null===(u=null===(l=h.vendure)||void 0===l?void 0:l.cli)||void 0===u?void 0:u.plugins)&&void 0!==c?c:[],y=!m.includes(v);return y&&(h.vendure={...h.vendure,cli:{...null===(p=h.vendure)||void 0===p?void 0:p.cli,plugins:[...m,v]}}),(g.length>0||y)&&!o&&await s.writeJson(e,h,{spaces:2}),{added:g,cliPluginRegistered:y}}async function C(e,n,t){var r,o;const i=await s.readJson(e),a=[];let d=!1;const l=null===(r=i.overrides)||void 0===r?void 0:r["@vendure/mcp-sdk"];if(void 0===l?(i.overrides={...i.overrides,"@vendure/mcp-sdk":n},d=!0,a.push(`Added an "overrides" entry for @vendure/mcp-sdk ${n} to package.json, so every package uses one copy of the MCP SDK. With pnpm, put the same entry under "overrides" in pnpm-workspace.yaml instead.`)):"string"!=typeof l||l.startsWith("$")?a.push(`package.json already overrides @vendure/mcp-sdk. Check that it resolves to ${n}, the version the Vendure Platform packages need.`):l!==n&&a.push(`package.json overrides @vendure/mcp-sdk to ${l}, but the Vendure Platform packages need ${n}. Set it to ${n}, or the MCP server lists none of their tools.`),i.overrides["@vendure/mcp-sdk"]===n)for(const e of["dependencies","devDependencies"]){const t=null===(o=i[e])||void 0===o?void 0:o["@vendure/mcp-sdk"];void 0!==t&&t!==n&&(i[e]["@vendure/mcp-sdk"]=n,d=!0,a.push(`Changed @vendure/mcp-sdk in package.json ${e} from ${t} to ${n}, the version of the override. npm refuses an override that differs from a direct dependency.`))}return d&&!t&&await s.writeJson(e,i,{spaces:2}),a}async function T(e,n,t){if(!await s.pathExists(e))return!1;const r=(await s.readFile(e,"utf8")).split("\n");let o=!1;const i="VENDURE_PLATFORM_LICENSE_TOKEN";for(let e=0;e<r.length;e++){const t=r[e].trim();if(!t.startsWith("#")&&t===`${i}=`){r[e]=`${i}=${n}`,o=!0;break}}return o&&!t&&await(0,c.writeEnvFile)(e,r.join("\n")),o}async function E(e,n,t){const r=await s.pathExists(e)?await s.readFile(e,"utf8"):"",o=new Set(r.split("\n").map(V).filter(Boolean)),i=[];let a=0;for(const e of n.split(/\n{2,}/)){const n=A(e.split("\n"),o),t=n.filter(e=>V(e)).length;0!==t&&(a+=t,i.push(n.join("\n")))}if(0===a||t)return a;if(""===r.trim())await(0,c.writeEnvFile)(e,n);else{const n=r.endsWith("\n")?"":"\n",t=`\n# Added by @vendure-platform/create add\n${i.join("\n\n")}\n`;await(0,c.writeEnvFile)(e,r+n+t)}return a}function A(e,n){const t=[];for(const r of e)if(n.has(V(r)))for(;t.length>1&&t[t.length-1].trim().startsWith("#");)t.pop();else t.push(r);return t}function V(e){var n,t;const r=e.trim();return r.startsWith("#")?"":null!==(t=null===(n=r.split("=")[0])||void 0===n?void 0:n.trim())&&void 0!==t?t:""}async function N(e,n,t){let r="";await s.pathExists(e)&&(r=await s.readFile(e,"utf8"));const o=r.split("\n").map(e=>e.trim());if(o.includes(n)||o.includes(`/${n}`))return!1;const i=""===r||r.endsWith("\n")?"":"\n";return t||await s.writeFile(e,r+i+n+"\n"),!0}function O(e,n){const t=(0,i.facadePackageName)(n),r=["import { VendurePlatform } from './platform-edition';"],{context:o,hbs:s}=(0,f.buildTemplateContext)("","",!1,{profile:n});for(const n of e)n.platformImports&&r.push(...n.platformImports);return`# Vendure Platform installation guide\n\nPaste these changes into your existing project. Step 1 is the most important \u2014\nwithout it, every Vendure Platform plugin refuses to start with\n\`LICENSE_GUARD_NONCE_MISMATCH\`.\n\n## 1. Bootstrap import (server entry point)\n\nIn your server entry file (typically \`src/index.ts\` or wherever you call\n\`bootstrap()\`), swap the bootstrap import from \`@vendure/core\` to\n\`./platform-edition\`:\n\n\`\`\`ts\n// before\nimport { bootstrap } from '@vendure/core';\n\n// after\nimport { bootstrap } from './platform-edition';\n\`\`\`\n\nIf you also run a separate worker process, swap \`bootstrapWorker\` too:\n\n\`\`\`ts\nimport { bootstrapWorker } from './platform-edition';\n\`\`\`\n\nThe \`./platform-edition\` bootstrap re-exports the \`${t}\`\ndrop-in wrapper around \`@vendure/core\`'s \`bootstrap\`. It primes the runtime license guard before\nNest builds the DI container. Without this swap, plugins like \`OrgAccountsPlugin\`\nfail at startup with \`LICENSE_GUARD_NONCE_MISMATCH\`.\n\n## 2. Imports in vendure-config.ts\n\nAdd to the top of the file (after your existing imports):\n\n\`\`\`ts\n${r.join("\n")}\n\`\`\`\n\n## 3. Plugins array\n\nSpread \`VendurePlatform.init({...})\` into the \`plugins\` array \u2014 typically\nbetween \`DefaultJobQueuePlugin\` and \`DashboardPlugin\`:\n\n\`\`\`ts\n...VendurePlatform.init({\n${s.compile("{{platformPluginOptions}}")(o)}\n}),\n\`\`\`\n\n## 4. Remove DefaultSearchPlugin\n\nAdvanced Search replaces Vendure's default search. If your config has it, delete \`DefaultSearchPlugin.init({...})\`\nfrom the \`plugins\` array and its import from \`@vendure/core\`. Projects from \`@vendure/create\`\nhave it. With both plugins the server stops at startup with\n\`Field "SearchResult.inStock" can only be defined once\`.\n\n## 5. Order process\n\nIf \`approvalWorkflows\` is selected, VendurePlatform will append\n\`approvalOrderProcess\` to your order process chain and override\n\`arrangingPaymentRequiresContents\` and \`checkAllItemsBeforeCancel\`. If you\nhave custom order process handlers they are preserved; the flags above are\nnot.\n\n## 6. Rebuild the search index\n\nAdvanced Search starts with an empty index and nothing fills it from your existing catalog. Until you rebuild it,\n\`search\` on the Shop API returns \`totalItems: 0\` even though \`products\` lists every product. Do this once per\nenvironment, after the server and a worker are running.\n\nUse a role with the \`UpdateCatalog\` permission. \`Superadmin\` has it. In the Dashboard, open **Search** and use the\n**Reindex** button, or call the Admin API:\n\n\`\`\`graphql\nmutation {\n reindex {\n id\n }\n}\n\`\`\`\n\nThe work runs on the worker, so a project with no running worker never finishes it. Watch the job under\n**System** \u2192 **Job queue**. The time grows with the number of product variants. A sample catalog of a few dozen\nproducts is quick, and a large catalog takes noticeably longer. When the\njob is completed, \`search(input: {}) { totalItems }\` returns your variants. New and changed products reach the\nindex by themselves from then on.\n\nSee https://docs.vendure.io/current/platform/getting-started/introduction for the full reference.\n`}async function _(e){var n,t,o,i;const s=process.cwd(),a=await b(s);a.hasVendureCore||r.log.warn("No @vendure/core dependency found in package.json. Continuing anyway \u2014 make sure this is the right directory."),a.vendureConfigPath?r.log.info(`Detected vendure-config.ts at ${d.relative(s,a.vendureConfigPath)}`):r.log.warn("No vendure-config.ts found under src/ or server/src/. The installation guide will still be written to the project root.");for(const e of S(a))r.log.warn(e);a.hasDefaultSearchPlugin&&r.log.warn("vendure-config.ts uses DefaultSearchPlugin. Remove it when you apply the installation guide: Advanced Search replaces it, and the server fails to start with both."),(void 0===e.profile||void 0===e.registryToken)&&r.intro("Add Vendure Platform to existing project");const u=null===(n=e.profile)||void 0===n?void 0:n.trim();let c;if(void 0!==u){if(!(0,p.isCapabilityProfileName)(u))throw new Error(`Unknown edition "${u}". Use starter, growth, scale, or enterprise.`);c=u}const h=void 0!==c||void 0!==e.registryToken||e.dryRun?void 0:await(0,l.startConsoleOnboarding)({projectDir:s,interactive:(0,l.isInteractive)()}),f=null!=c?c:null==h?void 0:h.edition;if(!f){if(void 0!==e.registryToken||e.dryRun)throw new Error("--profile is required when Console onboarding is skipped.");throw new Error("Could not determine the project edition. Link a Console Project with an edition or pass --profile.")}return{projectDir:s,profile:f,dryRun:null!==(t=e.dryRun)&&void 0!==t&&t,registryToken:(null===(o=e.registryToken)||void 0===o?void 0:o.trim())||void 0,licenseToken:(null===(i=e.licenseToken)||void 0===i?void 0:i.trim())||void 0,consoleOnboarding:h}}async function I(e){const n=await b(e.projectDir),t=p.ALWAYS_ACTIVE_KEYS.map(e=>(0,p.getPlugin)(e).displayName);t.length>0&&r.log.info(`Always-on core plugins: ${t.join(", ")}`);const o=q(await D(n,e));r.note(o,e.dryRun?"Dry run \u2014 would do:":"Next steps"),r.outro(e.dryRun?"Dry run complete \u2014 no files written.":"Done.")}function q(e){const n=Math.max(40,Math.min(process.stdout.columns||80,100)-6);return e.map((e,t)=>{const r=`${t+1}. `,o=" ".repeat(r.length);return F(e,n-r.length).map((e,n)=>(0===n?r:o)+e).join("\n")}).join("\n")}function F(e,n){const t=[];let r="";for(const o of e.split(/\s+/))""===r?r=o:r.length+1+o.length<=n?r+=" "+o:(t.push(r),r=o);return""!==r&&t.push(r),t.length>0?t:[""]}
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@radix-ui/react-toggle": "^1.1.10",
|
|
38
38
|
"@radix-ui/react-toggle-group": "^1.1.11",
|
|
39
39
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
40
|
-
"@vendure-platform/storefront-client": "^1.0.
|
|
40
|
+
"@vendure-platform/storefront-client": "^1.0.1",
|
|
41
41
|
"class-variance-authority": "^0.7.1",
|
|
42
42
|
"clsx": "^2.1.1",
|
|
43
43
|
"cmdk": "^1.1.1",
|
|
@@ -26,13 +26,13 @@ This is a Vendure e-commerce project scaffolded for **{{companyName}}** using `@
|
|
|
26
26
|
docker compose up -d
|
|
27
27
|
|
|
28
28
|
# Install dependencies
|
|
29
|
-
|
|
29
|
+
{{packageManager}} install
|
|
30
30
|
|
|
31
31
|
# Seed the database{{#if includeDemoData}} with the demo data{{/if}}
|
|
32
|
-
|
|
32
|
+
{{packageManager}} run populate
|
|
33
33
|
|
|
34
34
|
# Start the server, worker, and dashboard through the Vendure CLI
|
|
35
|
-
|
|
35
|
+
{{packageManager}} run dev
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Run `npx vendure dev` or `bunx vendure dev` from the workspace root or inside
|
|
@@ -44,19 +44,21 @@ Core loads the Platform CLI plugin from `server/package.json`.
|
|
|
44
44
|
|
|
45
45
|
Build the server before you remove development dependencies. Get the production
|
|
46
46
|
Environment Credential from the Installations page in Vendure Console, and set
|
|
47
|
-
it as `VENDURE_PLATFORM_LICENSE_TOKEN` in the deployment secret store.
|
|
47
|
+
it as `VENDURE_PLATFORM_LICENSE_TOKEN` in the deployment secret store. Run these
|
|
48
|
+
commands from `server/`. The root `package.json` has no `build`,
|
|
49
|
+
`migration:run:prod`, `start:server` or `start:worker` script.
|
|
48
50
|
|
|
49
51
|
```bash
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
{{packageManager}} run build
|
|
53
|
+
{{packageManager}} run build:dashboard
|
|
54
|
+
{{packageManager}} run migration:run:prod
|
|
53
55
|
|
|
54
56
|
# Run these as separate processes against the same database.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
{{packageManager}} run start:server
|
|
58
|
+
{{packageManager}} run start:worker
|
|
57
59
|
```
|
|
58
60
|
|
|
59
|
-
Do not run `
|
|
61
|
+
Do not run `{{packageManager}} run populate` against a deployment. It is a development command
|
|
60
62
|
that clears the database when it finds no core data. The scaffold includes a
|
|
61
63
|
`Dockerfile` and a `.dockerignore`. Build with
|
|
62
64
|
`docker build --secret id=npmrc,src=.npmrc .`. Keep `.npmrc`, `.env*` and
|
|
@@ -14,13 +14,13 @@ A Vendure e-commerce demo project for **{{companyName}}**, scaffolded with `@ven
|
|
|
14
14
|
docker compose up -d
|
|
15
15
|
|
|
16
16
|
# Install dependencies
|
|
17
|
-
|
|
17
|
+
{{packageManager}} install
|
|
18
18
|
|
|
19
19
|
# Seed the database{{#if includeDemoData}} with the demo data{{/if}}
|
|
20
|
-
|
|
20
|
+
{{packageManager}} run populate
|
|
21
21
|
|
|
22
22
|
# Start the server, worker, and dashboard
|
|
23
|
-
|
|
23
|
+
{{packageManager}} run dev
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
The admin dashboard will be available at `http://localhost:3500/dashboard`.
|
|
@@ -54,16 +54,28 @@ for older scaffolds and verification steps.
|
|
|
54
54
|
|
|
55
55
|
## Available Scripts
|
|
56
56
|
|
|
57
|
+
Run these from the workspace root, next to the root `package.json`. Each one
|
|
58
|
+
forwards to the script of the same name in `server/`:
|
|
59
|
+
|
|
60
|
+
| Script | Description |
|
|
61
|
+
|--------|-------------|
|
|
62
|
+
| `{{packageManager}} run dev` | Start the server, worker, and dashboard through `vendure dev` |
|
|
63
|
+
| `{{packageManager}} run build:dashboard` | Build the admin dashboard for production |
|
|
64
|
+
| `{{packageManager}} run populate` | Seed a linked development database |
|
|
65
|
+
|
|
66
|
+
The root scripts do not pass flags on with npm. Run `populate -- --reset` from
|
|
67
|
+
`server/`.
|
|
68
|
+
|
|
69
|
+
Run these from `server/`. The root `package.json` has no script for them:
|
|
70
|
+
|
|
57
71
|
| Script | Description |
|
|
58
72
|
|--------|-------------|
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `npm run start:server` | Start the compiled server with Node.js |
|
|
66
|
-
| `npm run start:worker` | Start the compiled worker with Node.js |
|
|
73
|
+
| `{{packageManager}} run build` | Compile the server and the worker to `server/dist` |
|
|
74
|
+
| `{{packageManager}} run migration:generate -- <name>` | Diff the entities against the database and write a migration. Add `--from-empty` for the first one |
|
|
75
|
+
| `{{packageManager}} run migration:run` | Apply pending migrations in a linked development environment |
|
|
76
|
+
| `{{packageManager}} run migration:run:prod` | Apply compiled migrations with the explicit production credential |
|
|
77
|
+
| `{{packageManager}} run start:server` | Start the compiled server with Node.js |
|
|
78
|
+
| `{{packageManager}} run start:worker` | Start the compiled worker with Node.js |
|
|
67
79
|
|
|
68
80
|
Run from `server/`. The Vendure CLI is installed too, with the Vendure Platform
|
|
69
81
|
plugin enabled:
|
|
@@ -97,13 +109,7 @@ nothing, because your development database already has the tables. Start
|
|
|
97
109
|
PostgreSQL with `docker compose up -d`, then run this from `server/`:
|
|
98
110
|
|
|
99
111
|
```bash
|
|
100
|
-
{{
|
|
101
|
-
bun run migration:generate -- initial --from-empty
|
|
102
|
-
{{else if usesPnpm}}
|
|
103
|
-
pnpm run migration:generate -- initial --from-empty
|
|
104
|
-
{{else}}
|
|
105
|
-
npm run migration:generate -- initial --from-empty
|
|
106
|
-
{{/if}}
|
|
112
|
+
{{packageManager}} run migration:generate -- initial --from-empty
|
|
107
113
|
```
|
|
108
114
|
|
|
109
115
|
Review the SQL in `server/src/migrations/` and commit the file. The build and
|
|
@@ -111,15 +117,16 @@ the image include it. Later entity changes, such as a new plugin or a new custom
|
|
|
111
117
|
field, need a plain `migration:generate -- <name>` without `--from-empty`.
|
|
112
118
|
|
|
113
119
|
Build before you remove development dependencies. Run these commands from
|
|
114
|
-
`server
|
|
120
|
+
`server/`. The root `package.json` has no `build`, `migration:run:prod`,
|
|
121
|
+
`start:server` or `start:worker` script:
|
|
115
122
|
|
|
116
123
|
```bash
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
{{packageManager}} run build
|
|
125
|
+
{{packageManager}} run build:dashboard
|
|
126
|
+
{{packageManager}} run migration:run:prod
|
|
120
127
|
```
|
|
121
128
|
|
|
122
|
-
Run `
|
|
129
|
+
Run `{{packageManager}} run start:server` and `{{packageManager}} run start:worker` as separate processes
|
|
123
130
|
against the same database. A production installation can run one or more of
|
|
124
131
|
each process. License Guard keeps one Runtime Binding row for the database, so
|
|
125
132
|
all replicas share that binding. `populate` is a development command: it clears
|
|
@@ -176,7 +183,7 @@ variables in your platform. The image stores uploaded assets in
|
|
|
176
183
|
{{#if includeDemoData}}
|
|
177
184
|
## Demo data
|
|
178
185
|
|
|
179
|
-
`
|
|
186
|
+
`{{packageManager}} run populate` seeds sample data for a trial: the companies Acme Industrial
|
|
180
187
|
Supply, Globex Manufacturing, and Initech Solutions, their users, a product
|
|
181
188
|
catalog, price lists, approval policies, quotes, and orders. It comes from
|
|
182
189
|
`@vendure-platform/scenario-default`, a development dependency, and from the
|
|
@@ -184,7 +191,7 @@ files in `server/src/demo-data/`. Do not seed it into a production database.
|
|
|
184
191
|
|
|
185
192
|
To remove the demo data:
|
|
186
193
|
|
|
187
|
-
1. In `server/`, run `npm uninstall @vendure-platform/scenario-default`.
|
|
194
|
+
1. In `server/`, run `{{#if usesBun}}bun remove{{else if usesPnpm}}pnpm remove{{else}}npm uninstall{{/if}} @vendure-platform/scenario-default`.
|
|
188
195
|
2. In `server/src/populate.ts`, delete the `defaultScenario` import, the
|
|
189
196
|
`demoPopulators` constant, and the product check in `coreDataExists`. Import
|
|
190
197
|
`createTaxRateCorrectorPopulator` from `@vendure-platform/data-populator`
|
|
@@ -193,13 +200,13 @@ To remove the demo data:
|
|
|
193
200
|
`products.csv` except the header, and delete `collections` and `roles` from
|
|
194
201
|
`initial-data.json`. Keep the countries, tax rates, shipping methods, and
|
|
195
202
|
payment method. A shop needs them.
|
|
196
|
-
4.
|
|
197
|
-
without the demo data.
|
|
203
|
+
4. In `server/`, run `{{packageManager}} run populate -- --reset`. It clears the
|
|
204
|
+
database and seeds it again without the demo data.
|
|
198
205
|
|
|
199
206
|
{{else}}
|
|
200
207
|
## Initial data
|
|
201
208
|
|
|
202
|
-
`
|
|
209
|
+
`{{packageManager}} run populate` seeds the data in `server/src/initial-data/`: countries and
|
|
203
210
|
zones, tax rates, shipping methods, and a payment method. It sets the tax rates
|
|
204
211
|
to the VAT rates of each country, and then it runs
|
|
205
212
|
`server/src/custom-populate.ts`. Before you take orders, check the tax rates
|
|
@@ -209,7 +216,8 @@ payment handler.
|
|
|
209
216
|
To import a product catalog, add rows to `server/src/initial-data/products.csv`
|
|
210
217
|
in the Vendure product import format, put the image files that the `assets`
|
|
211
218
|
columns name in `server/src/initial-data/images/`, and run
|
|
212
|
-
`
|
|
219
|
+
`{{packageManager}} run populate -- --reset` in `server/`. This clears the
|
|
220
|
+
database first.
|
|
213
221
|
|
|
214
222
|
{{/if}}
|
|
215
223
|
## Installed Plugins
|
|
@@ -5,13 +5,17 @@
|
|
|
5
5
|
# seconds ago. The default `0` is fine for most projects, but if you (or your
|
|
6
6
|
# org's global `~/.bunfig.toml`) sets it to e.g. `604800` (7 days), then
|
|
7
7
|
# `@vendure-platform/*` releases would be blocked for a week after each
|
|
8
|
-
# Vendure Platform ship.
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
8
|
+
# Vendure Platform ship. A Platform release can also pin a Core release of
|
|
9
|
+
# the same day. The excludes list below bypasses the check for every
|
|
10
|
+
# Vendure Platform and Vendure Core package this scaffold consumes
|
|
11
|
+
# (directly or transitively), so a fresh `bun install` works immediately
|
|
12
|
+
# after a release. Core means `@vendure/*` plus the `@vendure-io/*`
|
|
13
|
+
# packages of the Dashboard. Bun 1.4.2 matches each entry by exact package
|
|
14
|
+
# name and does not expand `@vendure/*`, so add a new Core package here by
|
|
15
|
+
# name. The age rule still applies to every other package.
|
|
12
16
|
#
|
|
13
17
|
# See https://bun.com/docs/runtime/bunfig#install-minimumreleaseage
|
|
14
18
|
[install]
|
|
15
19
|
minimumReleaseAgeExcludes = [
|
|
16
|
-
{{
|
|
20
|
+
{{releaseAgeExcludes}}
|
|
17
21
|
]
|
|
@@ -14,10 +14,10 @@ import { config } from './vendure-config';
|
|
|
14
14
|
* in `src/migrations`, so generate one whenever a plugin's entities change and
|
|
15
15
|
* run them before the server boots.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* {{packageManager}} run migration:generate -- <name> # diff against this database
|
|
18
|
+
* {{packageManager}} run migration:generate -- <name> --from-empty # full baseline schema
|
|
19
|
+
* {{packageManager}} run migration:run # linked development environment
|
|
20
|
+
* {{packageManager}} run migration:run:prod # compiled production runner
|
|
21
21
|
*
|
|
22
22
|
* `--from-empty` diffs the entity metadata against a temporary empty database
|
|
23
23
|
* instead of this one, so it emits a complete "zero to current schema"
|
|
@@ -32,7 +32,7 @@ async function main(): Promise<void> {
|
|
|
32
32
|
|
|
33
33
|
if (command === 'generate') {
|
|
34
34
|
if (!name) {
|
|
35
|
-
throw new Error('Usage:
|
|
35
|
+
throw new Error('Usage: {{packageManager}} run migration:generate -- <name> [--from-empty]');
|
|
36
36
|
}
|
|
37
37
|
await generateMigration(config, {
|
|
38
38
|
name,
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
"storefront"{{/if}}
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
|
-
"dev": "{{#if includeStorefront}}concurrently \"cd server &&
|
|
11
|
-
"build:dashboard": "cd server &&
|
|
12
|
-
"populate": "cd server &&
|
|
10
|
+
"dev": "{{#if includeStorefront}}concurrently \"cd server && {{packageManager}} run dev\" \"cd storefront && {{packageManager}} run dev\"{{else}}cd server && {{packageManager}} run dev{{/if}}",
|
|
11
|
+
"build:dashboard": "cd server && {{packageManager}} run build:dashboard",
|
|
12
|
+
"populate": "cd server && {{packageManager}} run populate"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@vendure/cli": "{{coreVersion}}",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dev:dashboard": "vendure dev dashboard",
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"build:dashboard": "vite build",
|
|
12
|
-
"start": "concurrently --kill-others
|
|
12
|
+
"start": "concurrently --kill-others {{packageManager}}:start:*",
|
|
13
13
|
"start:server": "node dist/index.js",
|
|
14
14
|
"start:worker": "node dist/index-worker.js",
|
|
15
15
|
"populate": "vendure run-with-credential -- node --require ts-node/register src/populate.ts",
|
|
@@ -56,9 +56,10 @@ export declare function resolveRegistryToken(flagToken: string | undefined, regi
|
|
|
56
56
|
* process holds the lock on. An offline scaffold is a supported flow, so none
|
|
57
57
|
* of those stop the run.
|
|
58
58
|
*
|
|
59
|
-
* A run
|
|
60
|
-
*
|
|
61
|
-
* no stored session
|
|
59
|
+
* A run that names a `projectId` is the exception. It cannot scaffold without
|
|
60
|
+
* that Project, so it throws the reason that stopped it, before any file
|
|
61
|
+
* exists. A run with no terminal and no stored session has no reason to throw,
|
|
62
|
+
* and it returns `undefined`.
|
|
62
63
|
*
|
|
63
64
|
* A login that has no Customer Account, or one this run cannot choose, also
|
|
64
65
|
* throws: Console refuses it, so an offline scaffold would not install.
|
|
@@ -72,8 +73,9 @@ export declare function startConsoleOnboarding(options: {
|
|
|
72
73
|
* hold is an error: creating one is a decision, and naming an id is a
|
|
73
74
|
* different one already taken. The session is scoped to one Customer
|
|
74
75
|
* Account, so an interactive run offers a sign-in with another account
|
|
75
|
-
*
|
|
76
|
-
* the
|
|
76
|
+
* when the account does not hold the Project or Console denies access in
|
|
77
|
+
* it. Without the other account the run stops with the message that
|
|
78
|
+
* names the account.
|
|
77
79
|
*/
|
|
78
80
|
projectId?: string;
|
|
79
81
|
}): Promise<ConsoleOnboarding | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,n,o,t){void 0===t&&(t=o);var r=Object.getOwnPropertyDescriptor(n,o);r&&!("get"in r?!n.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return n[o]}}),Object.defineProperty(e,t,r)}:function(e,n,o,t){void 0===t&&(t=o),e[t]=n[o]}),n=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),o=this&&this.__importStar||function(){var o=function(e){return o=Object.getOwnPropertyNames||function(e){var n=[];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[n.length]=o);return n},o(e)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var i=o(t),s=0;s<i.length;s++)"default"!==i[s]&&e(r,t,i[s]);return n(r,t),r}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveRegistryToken=
|
|
1
|
+
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,n,o,t){void 0===t&&(t=o);var r=Object.getOwnPropertyDescriptor(n,o);r&&!("get"in r?!n.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return n[o]}}),Object.defineProperty(e,t,r)}:function(e,n,o,t){void 0===t&&(t=o),e[t]=n[o]}),n=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),o=this&&this.__importStar||function(){var o=function(e){return o=Object.getOwnPropertyNames||function(e){var n=[];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[n.length]=o);return n},o(e)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var i=o(t),s=0;s<i.length;s++)"default"!==i[s]&&e(r,t,i[s]);return n(r,t),r}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveRegistryToken=d,exports.startConsoleOnboarding=g,exports.isInteractive=f,exports.finishConsoleOnboarding=p,exports.registryTokenStep=v;const t=o(require("@clack/prompts")),r=require("@vendure-platform/console-auth"),i=require("node:fs"),s=require("node:path"),c=require("./docs-url"),a=require("./plugin-registry"),l=require("./registry");class ProjectHasNoPlan extends Error{constructor(){super(...arguments),this.name="ProjectHasNoPlan"}}const u="Continuing without a Vendure Console Project.";function d(e,n){return e?{token:e,projectId:void 0}:{token:n.registryToken,projectId:n.registryProjectId}}async function g(e){const n=Boolean(e.projectId);let o;try{o=(0,r.resolveConsoleOrigins)(process.env)}catch(e){if(n)throw e;return void t.log.warn(`${V(e)} Continuing without Vendure Console.`)}const i=await b(o,e.interactive,e.projectId);if(!i)return;let s=i;const c=new r.ConsoleApi({apiOrigin:o.apiOrigin,getAccessToken:()=>s,refreshAccessToken:async()=>{s=await(0,r.refreshStoredConsoleToken)({...o,failedAccessToken:s})}});let l;for(;!l;)try{l=await(0,r.selectConsoleProject)({api:c,interaction:O(e.projectId),origins:o,projectRoot:e.projectDir})}catch(i){if(i instanceof r.ConsoleOnboardingCancelled)throw i;if(i instanceof r.ConsoleApiError&&"auth.organization_missing"===i.code)throw new r.ConsoleCustomerAccountRequired(`Your Vendure Console login is not scoped to a Customer Account. Run "${(0,r.accountLoginCommand)(o.apiOrigin)}", then run this command again.`);const a=await R(c,i);if(!a){if(n)throw i;return void t.log.warn(`${V(i)} ${u}`)}const l=()=>new Error(`${a} No files were created. To use another account, run "${(0,r.accountLoginCommand)(o.apiOrigin)}", then run this command again.`);if(!e.interactive){if(n)throw l();return void t.log.warn(`${a} ${u}`)}t.log.warn(a);const d=await t.confirm({message:"Sign in with another Vendure Console account?",initialValue:!0});if(t.isCancel(d))throw new r.ConsoleOnboardingCancelled;if(!d){if(n)throw l();return void t.log.warn(u)}const g=await k(o,n);if(!g)return;s=g}const{project:d,edition:g}=l,f=(0,r.projectSubscriptionUrl)(o.appOrigin,d.id);if(!g)throw t.note(`Choose a plan: ${f}\nThen retry this command and select ${d.name}.`,"Next steps"),new ProjectHasNoPlan(`The Console Project ${d.name} is kept. No files or Registry Access Token were created.`);return{project:{id:d.id,name:d.name},edition:g&&(0,a.isCapabilityProfileName)(g)?g:void 0,subscriptionUrl:f,finish:async n=>({...await $(c,d,n,o,e.projectDir),subscriptionUrl:f})}}function f(){return Boolean(process.stdin.isTTY&&process.stdout.isTTY)}async function p(e,n,o){if(!e)return(0,l.offlineRegistry)();try{const r=await e.finish(n);return r.registryAccessDenied&&!o&&t.log.warn(`Your Console role cannot issue Registry Access Tokens for ${e.project.name}, so this project cannot install Platform packages yet. Ask a member with the Credential manager, Project admin or Admin role to create an access token on the Registry access page of ${e.project.name} in Vendure Console. ${(0,l.setRegistryTokenStep)(r.registryUrl)}`),r}catch(o){return t.log.warn(`Could not finish linking to Vendure Console. ${V(o)} ${j(n)}`),{...(0,l.offlineRegistry)(),subscriptionUrl:e.subscriptionUrl}}}const h=[3,8],w=`${c.PLATFORM_DOCS_URL}/getting-started/registry-access`;function C(e){for(let n=e;;n=(0,s.dirname)(n)){try{const e=JSON.parse((0,i.readFileSync)((0,s.join)(n,"node_modules","@vendure","cli","package.json"),"utf8"));if("string"==typeof e.version)return e.version}catch{}if((0,s.dirname)(n)===n)return}}function m(e){const n=C(e);if(void 0===n)return;const[o,t]=n.split(".").map(e=>Number.parseInt(e,10)),[r,i]=h;return o>r||o===r&&t>=i?void 0:n}function y(e,n){const[o,t]=h;return`@vendure/cli ${n} has no "console link" command. Update it to ${o}.${t} or later and run "npx vendure console link" in ${e}, or create a Registry Access Token for the Project in Vendure Console and add it to ${(0,s.join)(e,".npmrc")} by hand. Steps: ${w}`}function j(e){const n=m(e);return void 0===n?`Run "npx vendure console link" in ${e} to finish.`:y(e,n)}function v(e){const n=m(e);return void 0===n?"Run `vendure console link` to link this project and get a Registry Access Token.":y(e,n)}async function $(e,n,o,i,s){await(0,r.writeProjectLink)({api:e,interaction:O(),projectRoot:o,projectId:n.id,origins:i}),t.log.success(`Linked ${o} to ${n.name}.`);const c=await(0,r.acquireRegistryAccess)({api:e,projectId:n.id,projectRoot:s,interaction:{confirmRotate:async e=>{const n=await t.confirm({message:`Replace the Registry Access Token "${e}"? Whatever installs with the current one stops working.`,initialValue:!1});if(t.isCancel(n))throw new r.ConsoleOnboardingCancelled;return n},report:e=>t.log.info(e),warn:e=>t.log.warn(e)},defaultRegistryUrl:(0,r.registryUrlFor)(i.apiOrigin),defaultScope:l.REGISTRY_SCOPE});if("permission-denied"===c.reason)return{registryUrl:c.registryUrl,scope:c.scope,registryAccessDenied:!0};if("npm-login"===c.fallback){const e=`npm login --auth-type=web --registry=${(0,l.registryLoginUrl)(c.registryUrl)}`,n="rotation-declined"===c.reason?"You kept the existing Registry Access Token. Its secret was not written to this directory.":"The named Registry Access Token is inactive. Replace it in Vendure Console.";return t.log.warn(`${n} Log in to the registry before installing:\n ${e}`),{registryUrl:c.registryUrl,scope:c.scope,registryLogin:e}}return{registryUrl:c.registryUrl,scope:c.scope,registryToken:c.token,registryProjectId:n.id}}async function b(e,n,o){let i;try{i=await(0,r.resolveStoredConsoleToken)(e)}catch(e){if(o)throw e;return void t.log.warn(`${V(e)} Continuing without Vendure Console.`)}if(i)return(0,r.scopeStoredConsoleSession)({...e,accessToken:i,...n?{chooseCustomerAccount:P}:{}});if(!n)return;const s=await t.confirm({message:"Sign in to Vendure Console to set this project up?",initialValue:!0});if(t.isCancel(s))throw new r.ConsoleOnboardingCancelled;if(s)return A(e,n,Boolean(o));if(o)throw new Error(`--console-project ${o} needs a Vendure Console sign-in. No files were created. Run this command again and sign in.`)}async function k(e,n){try{const o=await(0,r.otherConsoleCustomerAccounts)(e);if(0===o.length)return A(e,!0,n);const i=1===o.length?o[0]:await P(o),s=await(0,r.switchConsoleCustomerAccount)(i,e);return t.log.info(`This session now uses the Vendure Console account "${i.name}".`),s}catch(e){if(n||e instanceof r.ConsoleOnboardingCancelled)throw e;return void t.log.warn(`${V(e)} ${u}`)}}async function A(e,n,o=!1){const i=t.spinner();i.start("Waiting for you to finish signing in to Vendure Console");let s=!0;const c=e=>{s&&i.stop(e),s=!1};try{const o=await(0,r.loginAndStoreConsoleToken)({...e,onDeviceAuthorization:e=>t.log.info(`Open ${e.verificationUriComplete} and enter code ${e.userCode} to sign in.`),...n?{chooseCustomerAccount:e=>(c("Signed in to Vendure Console."),P(e))}:{}});return c("Signed in to Vendure Console."),o}catch(e){if(e instanceof r.ConsoleCustomerAccountRequired||e instanceof r.ConsoleOnboardingCancelled)throw c("Signed in to Vendure Console."),e;if(c("Could not sign in to Vendure Console."),o)throw e;return void t.log.warn(`${V(e)} Continuing without it.`)}}const P=async e=>{const n=await t.select({message:"Which Vendure Console Customer Account is this project for?",options:e.map(e=>({label:e.name,value:e.customerAccountId,hint:`Account identifier ${e.customerAccountId}`}))});if(t.isCancel(n))throw new r.ConsoleOnboardingCancelled;const o=e.find(e=>e.customerAccountId===n);if(!o)throw new r.ConsoleOnboardingCancelled;return o};function O(e){return{chooseProject:async n=>{if(e){const o=n.find(n=>n.id===e);if(!o)throw new ProjectNotInSessionAccount(e);return o}const o=await t.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(t.isCancel(o))throw new r.ConsoleOnboardingCancelled;return n.find(e=>e.id===o)},newProjectName:async()=>{if(e)throw new ProjectNotInSessionAccount(e);const n=await t.text({message:"Name for the new Vendure Console Project:",validate:e=>e.trim()?void 0:"A name is required"});if(t.isCancel(n))throw new r.ConsoleOnboardingCancelled;return n},report:e=>t.log.info(e),warn:e=>t.log.warn(e)}}class ProjectNotInSessionAccount extends Error{constructor(e){super(),this.projectId=e}}async function T(e,n){const o=await(0,r.readViewerAccount)(e).catch(()=>{}),t=`--console-project ${n.projectId}`;return o?`${t} is not a Project of the account "${o.name}" that this session uses.`:`${t} is not one of your Vendure Console Projects.`}async function R(e,n){if(n instanceof ProjectNotInSessionAccount)return T(e,n);if(!(0,r.isPermissionDenied)(n))return;const o=await(0,r.readViewerAccount)(e).catch(()=>{});return o?`${V(n)} This session uses the Vendure Console account "${o.name}".`:V(n)}function V(e){return e instanceof Error?e.message:String(e)}
|
package/dist/docs-url.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PLATFORM_DOCS_URL=void 0,exports.PLATFORM_DOCS_URL="https://docs.vendure.io/vendure-platform";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes a `.env` file readable only by its owner. The file holds the Console
|
|
3
|
+
* Environment Credential, so it gets the 0600 mode of the other credential
|
|
4
|
+
* files. The mode argument applies only to a new file, so an existing file is
|
|
5
|
+
* also changed with `chmod`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function writeEnvFile(envPath: string, content: string): Promise<void>;
|
package/dist/env-file.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(){var r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},r(e)};return function(n){if(n&&n.__esModule)return n;var i={};if(null!=n)for(var o=r(n),u=0;u<o.length;u++)"default"!==o[u]&&e(i,n,o[u]);return t(i,n),i}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeEnvFile=i;const n=r(require("fs-extra"));async function i(e,t){await n.writeFile(e,t,{encoding:"utf8",mode:384}),await n.chmod(e,384).catch(()=>{})}
|
package/dist/registry.d.ts
CHANGED
|
@@ -20,3 +20,12 @@ export declare function offlineRegistry(): {
|
|
|
20
20
|
registryUrl: string;
|
|
21
21
|
scope: string;
|
|
22
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* The step that gives an existing project a Registry Access Token.
|
|
25
|
+
*
|
|
26
|
+
* Running `create` again cannot do this, because the project directory is no
|
|
27
|
+
* longer empty. The token goes into `.npmrc` as a literal `_authToken`, which
|
|
28
|
+
* npm, pnpm and Bun all read. pnpm 11 ignores a `${VAR}` value there, so the
|
|
29
|
+
* step does not use one. The placeholder keeps the secret out of the output.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setRegistryTokenStep(registryUrl: string, npmrc?: string, install?: string): string;
|
package/dist/registry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.REGISTRY_SCOPE=exports.registryLoginUrl=exports.DEFAULT_REGISTRY_URL=void 0,exports.getRegistryUrl=t,exports.getRegistryHostname=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.REGISTRY_SCOPE=exports.registryLoginUrl=exports.DEFAULT_REGISTRY_URL=void 0,exports.getRegistryUrl=t,exports.getRegistryHostname=n,exports.offlineRegistry=o,exports.setRegistryTokenStep=i;const e=require("@vendure-platform/console-auth");Object.defineProperty(exports,"REGISTRY_SCOPE",{enumerable:!0,get:function(){return e.REGISTRY_SCOPE}});var r=require("@vendure-platform/console-auth");function t(){return(0,e.registryUrl)()}function n(){return new URL(t()).hostname}function o(){var r;let t;try{t=(0,e.consoleApiOrigin)((null===(r=process.env.VENDURE_CONSOLE_API_URL)||void 0===r?void 0:r.trim())||void 0)}catch{return{registryUrl:(0,e.registryUrl)(),scope:e.REGISTRY_SCOPE}}return{registryUrl:(0,e.registryUrlFor)(t),scope:e.REGISTRY_SCOPE}}function i(r,t="the project's .npmrc",n="your package manager's install command in the project"){return`Set \`${(0,e.registryAuthTokenKey)(r)}<token>\` in ${t}, replacing the line if it is there, then run ${n}.`}Object.defineProperty(exports,"DEFAULT_REGISTRY_URL",{enumerable:!0,get:function(){return r.DEFAULT_REGISTRY_URL}}),Object.defineProperty(exports,"registryLoginUrl",{enumerable:!0,get:function(){return r.registryLoginUrl}});
|
package/dist/scaffold-shared.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,n,
|
|
1
|
+
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=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(r){if(r&&r.__esModule)return r;var i={};if(null!=r)for(var s=n(r),o=0;o<s.length;o++)"default"!==s[o]&&e(i,r,s[o]);return t(i,r),i}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.installDependencies=h,exports.initRepository=f;const r=n(require("@clack/prompts")),i=require("child_process"),s=n(require("path")),o=require("util"),a=require("./docs-url"),c=require("./git-init"),l=require("./registry"),u=(0,o.promisify)(i.exec),d=`Docs: ${a.PLATFORM_DOCS_URL}/getting-started/registry-access`;async function h(e,t,n,i={}){var s;n.message(`Installing dependencies with ${t} (this may take a few minutes)...`);try{return await u(`${t} install`,{cwd:e}),!0}catch(o){n.stop(`${t} install failed.`);const a=o instanceof Error&&"stderr"in o?null===(s=o.stderr)||void 0===s?void 0:s.trim():void 0;return a&&r.log.error(a.split("\n").slice(-5).join("\n")),a&&p(a)?r.log.warn(g(t,e,i.registryUrl,i.subscriptionUrl,i.accessDenied)):a&&a.split("\n").some(e=>/\b404\b|Not Found/i.test(e)&&/\bGET\s+\S*@vendure-platform(?:%2f|\/)/i.test(e))?r.log.warn(i.subscriptionUrl?`The Project may have no plan, or its plan does not include this package. A missing package version can also return 404. Check the plan at ${i.subscriptionUrl}. Then retry ${t} install.`:`The registry could not find this Platform package or grant access to it. Check the package version and registry access, then retry ${t} install.`):r.log.warn(`Dependency install failed \u2014 run \`${t} install\` manually in the project directory.`),n.start("Continuing..."),!1}}function p(e){return/\bE(?:401|403)\b|\bERR_PNPM_FETCH_40[13]\b|\b(?:401 Unauthorized|403 Forbidden)\b|\s-\s40[13]\b/i.test(e)}function g(e,t,n,r,i){const o=s.join(t,".npmrc"),a=`\`${e} install\` in ${t}`;return i?["Install failed: your Console role cannot issue Registry Access Tokens for this Project.","Ask a member with the Credential manager, Project admin or Admin role to create an access token","on the Registry access page of the Project in Vendure Console. Then:",` ${(0,l.setRegistryTokenStep)(null!=n?n:(0,l.getRegistryUrl)(),o,a)}`,"",d].join("\n"):["Install failed: the registry refused this project's Registry Access Token.","The token may be missing, expired or revoked.",...r?[`The Project may also have no plan, or its plan does not include this package. Check the plan at ${r}.`]:[],"","To fix it:"," 1. In Vendure Console, open the Registry access page of the Project. Create an access token,"," or use Rotate on the one this project uses. Console shows the secret once.",` 2. ${(0,l.setRegistryTokenStep)(null!=n?n:(0,l.getRegistryUrl)(),o,a)}`,"In CI, store the token as the VENDURE_REGISTRY_TOKEN secret and write .npmrc from it.","",d].join("\n")}async function f(e,t,n,i){i.message("Initializing git...");try{await(0,c.initGit)(e,t,n)}catch(e){i.stop("Git setup had issues.");const n=e instanceof Error?e.message:String(e);r.log.warn(t?`Git/GitHub setup had issues \u2014 make sure the gh CLI is installed and authenticated. (${n})`:`Git init had issues \u2014 initialise the repo manually if needed. (${n})`),i.start("Continuing...")}}
|
package/dist/scaffolder.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var n=Object.getOwnPropertyDescriptor(t,o);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,n)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(){var o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[t.length]=o);return t},o(e)};return function(r){if(r&&r.__esModule)return r;var n={};if(null!=r)for(var s=o(r),i=0;i<s.length;i++)"default"!==s[i]&&e(n,r,s[i]);return t(n,r),n}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.SHARED_FILES=exports.TEMPLATE_FILES=void 0,exports.scaffold=
|
|
1
|
+
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var n=Object.getOwnPropertyDescriptor(t,o);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,n)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(){var o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[t.length]=o);return t},o(e)};return function(r){if(r&&r.__esModule)return r;var n={};if(null!=r)for(var s=o(r),i=0;i<s.length;i++)"default"!==s[i]&&e(n,r,s[i]);return t(n,r),n}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.SHARED_FILES=exports.TEMPLATE_FILES=void 0,exports.scaffold=v,exports.consoleLinkRoot=j;const r=o(require("@clack/prompts")),n=require("@vendure-platform/console-auth"),s=require("@vendure-platform/plugin-meta"),i=o(require("fs-extra")),a=o(require("path")),p=require("./console-onboarding"),c=require("./env-file"),l=require("./plugin-registry"),u=require("./pnpm-build-approvals"),d=require("./scaffold-shared"),m=require("./storefront-copier"),g=require("./template-renderer"),f=require("./types");async function v(e){var t;const{projectName:o,companyName:v,profile:h,includeStorefront:w,includeDemoData:E=!0,createGithubRepo:k,githubOrg:_,packageManager:S=f.DEFAULT_PACKAGE_MANAGER,skipInstall:T,skipGit:$,dryRun:A,registryToken:D,licenseToken:x,consoleOnboarding:P}=e,I=a.resolve(process.cwd(),o),L=(0,l.resolveProfilePluginKeys)(h);r.log.info(`Edition: ${h}`);const O=l.ALWAYS_ACTIVE_KEYS.map(e=>(0,l.getPlugin)(e).displayName);O.length>0&&r.log.info(`Always-on core plugins: ${O.join(", ")}`);const R=[...s.CAPABILITY_PROFILES[h]],F=(0,l.grantsIncludeStorefront)(R),M=w&&F;if(w&&!F&&r.log.warn(`The ${h} profile does not grant "${l.STOREFRONT_CAPABILITY}", so no storefront was emitted. The storefront ships with Scale and Enterprise.`),await i.pathExists(I)&&(await i.readdir(I)).length>0&&(r.log.error(`Directory "${I}" already exists and is not empty.`),process.exit(1)),A){const e=L.map(e=>(0,l.getPlugin)(e).displayName),t=[`Project: ${o} \u2192 ${I}`,`Edition: ${h}`,"","Files to generate:",[...[...exports.TEMPLATE_FILES.map(e=>e.output),...exports.SHARED_FILES].map(e=>` ${e}`),..."pnpm"===S?[" pnpm-workspace.yaml"]:[]].join("\n"),(E?[" server/src/demo-data/products.csv"," server/src/demo-data/initial-data.json"," server/src/demo-data/images/"]:[" server/src/initial-data/products.csv"," server/src/initial-data/initial-data.json"]).join("\n")," server/src/migrations/ (empty dir)","",`Plugins (${e.length}):`,` ${e.join(", ")}`,"","Demo data: "+(E?"yes":"no"),"Storefront: "+(M?"yes":F?"no":`no (needs ${l.STOREFRONT_CAPABILITY})`),`Install deps with ${S}: ${T?"no":"yes"}`,"Git init: "+($?"no":"yes"),"GitHub repo: "+(k?"yes":"no")].join("\n");return r.note(t,"Dry run"),void r.outro("Dry run complete \u2014 no files written.")}const N="pnpm"===S?(0,u.getBuildApprovals)(await i.readJson(a.join(__dirname,"..","dist","assets","build-dependencies.json")),h,E,M):[],C=r.spinner();C.start("Creating project directory..."),await i.ensureDir(I),C.stop("Created the project directory.");const q=await(0,p.finishConsoleOnboarding)(P,j(I),D),{context:G,hbs:B}=(0,g.buildTemplateContext)(o,v,M,{licenseToken:x,profile:h,includeDemoData:E,packageManager:S});C.start("Generating server files...");const H=a.join(I,"server"),J=a.join(H,"src");await i.ensureDir(J);for(const{template:e,output:t}of exports.TEMPLATE_FILES){const o=(0,g.getTemplatePath)(e),r=(0,g.renderTemplate)(o,G,B),n=a.join(I,t);await i.ensureDir(a.dirname(n)),".env"===t?await(0,c.writeEnvFile)(n,r):await i.writeFile(n,r)}await i.writeFile(a.join(J,"platform-edition.ts"),(0,s.renderEditionConfig)(h));const U=(0,p.resolveRegistryToken)(D,q);if(await(0,n.ensureRegistryNpmrc)(I,{registryUrl:q.registryUrl,scope:q.scope,token:U.token,projectId:U.projectId}),"pnpm"===S){const e=["server",...M?["storefront"]:[]];await i.writeFile(a.join(I,"pnpm-workspace.yaml"),`packages:\n${e.map(e=>` - ${e}`).join("\n")}\nallowBuilds:\n${N.map(e=>` ${JSON.stringify(e)}: true`).join("\n")}\npublicHoistPattern:\n - "@vendure-platform/*"\nminimumReleaseAgeExclude:\n - "@vendure-platform/*"\n - "@vendure/*"\noverrides:\n "@vendure/mcp-sdk": ${JSON.stringify(G.mcpSdkVersion)}\n`)}if(E?(C.message("Copying demo data..."),await y(J)):await b(J),await i.ensureDir(a.join(J,"migrations")),M){C.message("Copying storefront...");try{await(0,m.copyStorefront)(I,{mode:"full-project",scenario:"customer",packageName:`${o}-storefront`,capabilities:R,registryUrl:q.registryUrl,registryToken:U.token,registryProjectId:U.projectId})}catch(e){C.stop("Storefront copy failed.");const t=e instanceof Error?e.message:String(e);r.log.warn(`Storefront copy failed \u2014 you can set it up manually later. (${t})`),C.start("Continuing...")}}const Y=!!T||await(0,d.installDependencies)(I,S,C,{...q,accessDenied:q.registryAccessDenied&&!U.token});$||await(0,d.initRepository)(I,k,_,C),C.stop(Y?`Project "${o}" created successfully!`:`Project "${o}" created, but dependency installation failed.`);const K="npm"===S?"npm run":`${S} run`,V=[`cd ${o}`,null!==(t=q.registryLogin)&&void 0!==t?t:"",!Y||T?`${S} install`:"",await i.pathExists(a.join(j(I),".vendure","project.json"))?"":"cd server && npx vendure console link && cd ..","docker compose up -d",`${K} populate`,`${K} dev`,"","Dashboard: http://localhost:3500/dashboard",M?"Storefront: http://localhost:3001":""].filter(Boolean).join("\n");r.note(V,"Next steps"),r.outro(Y?"Happy building!":"Install dependencies to continue.")}function j(e){return a.join(e,"server")}function h(){const e=[a.join(__dirname,"..","..","scenario-default","assets"),a.join(__dirname,"assets","demo-data")];for(const t of e)if(i.pathExistsSync(t))return t;throw new Error("Could not find scenario-default assets. Tried:\n"+e.map(e=>` - ${e}`).join("\n"))}async function y(e){const t=h(),o=a.join(e,"demo-data");await i.ensureDir(o),await i.copy(a.join(t,"initial-data.json"),a.join(o,"initial-data.json")),await i.copy(a.join(t,"products.csv"),a.join(o,"products.csv")),await i.copy(a.join(t,"images"),a.join(o,"images"))}async function b(e){const t=h(),o=await i.readJson(a.join(t,"initial-data.json")),r=a.join(e,"initial-data");await i.ensureDir(r),await i.writeJson(a.join(r,"initial-data.json"),{defaultLanguage:o.defaultLanguage,defaultZone:o.defaultZone,countries:o.countries,taxRates:o.taxRates,shippingMethods:o.shippingMethods,paymentMethods:o.paymentMethods,collections:[]},{spaces:4});const[n]=(await i.readFile(a.join(t,"products.csv"),"utf8")).split("\n");await i.writeFile(a.join(r,"products.csv"),`${n}\n`)}exports.TEMPLATE_FILES=[{template:"vendure-config.ts.hbs",output:"server/src/vendure-config.ts"},{template:"populate.ts.hbs",output:"server/src/populate.ts"},{template:"migrate.ts.hbs",output:"server/src/migrate.ts"},{template:"custom-populate.ts.hbs",output:"server/src/custom-populate.ts"},{template:"load-env.ts.hbs",output:"server/src/load-env.ts"},{template:"index.ts.hbs",output:"server/src/index.ts"},{template:"index-worker.ts.hbs",output:"server/src/index-worker.ts"},{template:"server-package.json.hbs",output:"server/package.json"},{template:"root-package.json.hbs",output:"package.json"},{template:"env.hbs",output:".env"},{template:"docker-compose.yml.hbs",output:"docker-compose.yml"},{template:"AGENTS.md.hbs",output:"AGENTS.md"},{template:"README.md.hbs",output:"README.md"},{template:"tsconfig.root.json.hbs",output:"tsconfig.json"},{template:"tsconfig.server.json.hbs",output:"server/tsconfig.json"},{template:"vite.config.mts.hbs",output:"server/vite.config.mts"},{template:"tsconfig.dashboard.json.hbs",output:"server/tsconfig.dashboard.json"},{template:"environment.d.ts.hbs",output:"server/src/environment.d.ts"},{template:"gitignore.hbs",output:".gitignore"},{template:"dockerignore.hbs",output:".dockerignore"},{template:"Dockerfile.hbs",output:"Dockerfile"},{template:"bunfig.toml.hbs",output:"bunfig.toml"}],exports.SHARED_FILES=["server/src/platform-edition.ts",".npmrc"];
|
|
@@ -92,6 +92,11 @@ export interface TemplateContext {
|
|
|
92
92
|
usesPnpm: boolean;
|
|
93
93
|
/** Whether the project is installed with Bun. The scaffold Dockerfile picks its install commands from this and `usesPnpm`. */
|
|
94
94
|
usesBun: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* The package manager that installs the project. Its name starts every documented command (`bun run build`,
|
|
97
|
+
* `bun remove`) and the `concurrently` shortcut of the `start` script (`bun:start:*`).
|
|
98
|
+
*/
|
|
99
|
+
packageManager: PackageManager;
|
|
95
100
|
/**
|
|
96
101
|
* Server-side license token, when supplied. Baked into `.env` as
|
|
97
102
|
* `VENDURE_PLATFORM_LICENSE_TOKEN` and read by the License Guard plugin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,n,r,t){void 0===t&&(t=r);var o=Object.getOwnPropertyDescriptor(n,r);o&&!("get"in o?!n.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return n[r]}}),Object.defineProperty(e,t,o)}: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 o={};if(null!=t)for(var i=r(t),a=0;a<i.length;a++)"default"!==i[a]&&e(o,t,i[a]);return n(o,t),o}}(),t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolvePluginVersionSpec=p,exports.resolveMcpSdkVersion=f,exports.buildTemplateContext=v,exports.renderTemplate=_,exports.getTemplatePath=
|
|
1
|
+
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,n,r,t){void 0===t&&(t=r);var o=Object.getOwnPropertyDescriptor(n,r);o&&!("get"in o?!n.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return n[r]}}),Object.defineProperty(e,t,o)}: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 o={};if(null!=t)for(var i=r(t),a=0;a<i.length;a++)"default"!==i[a]&&e(o,t,i[a]);return n(o,t),o}}(),t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolvePluginVersionSpec=p,exports.resolveMcpSdkVersion=f,exports.buildTemplateContext=v,exports.renderTemplate=_,exports.getTemplatePath=h;const o=require("@vendure-platform/plugin-meta"),i=r(require("fs")),a=t(require("handlebars")),s=r(require("path")),u=require("./plugin-registry"),l=require("./sort-package-json"),c=require("./types");function p(e){const n=null!=e?e:m().version;if(!n.includes("-"))return`^${n}`;const r=n.slice(n.indexOf("-")+1).split(".")[0];return"minor"===r||"major"===r?r:"nightly"}function f(){return m().devDependencies["@vendure/mcp-sdk"]}function d(e){var n,r;return null!==(r=null===(n=e.match(/from '([^']+)'/))||void 0===n?void 0:n[1])&&void 0!==r?r:e}function m(){return JSON.parse(i.readFileSync(s.join(__dirname,"..","package.json"),"utf8"))}function g(e,n,r){const t=a.default.create(),i=new Set(e);return t.registerHelper("ifPlugin",function(e,n){return i.has(e)?n.fn(this):n.inverse(this)}),t.registerHelper("platformDependencies",function(){const e=[` "${(0,o.facadePackageName)(r)}": "${n}"`];return new t.SafeString(",\n"+e.join(",\n"))}),t.registerHelper("releaseAgeExcludes",function(){const e=["@vendure-platform/cli","@vendure-platform/data-populator","@vendure-platform/integration","@vendure-platform/platform","@vendure-platform/scenario-default","@vendure-platform/storefront-client",...o.EDITION_ORDER.map(o.facadePackageName)],n=u.pluginRegistry.map(e=>e.packageName),r=Array.from(new Set([...e,"@vendure-io/design-tokens","@vendure-io/ui","@vendure/asset-server-plugin","@vendure/cli","@vendure/common","@vendure/core","@vendure/dashboard","@vendure/mcp-sdk","@vendure/testing",...n])).sort().map(e=>` "${e}",`);return new t.SafeString(r.join("\n"))}),t.registerHelper("platformPluginImports",function(){const n=[];for(const r of e){const e=(0,u.getPlugin)(r).platformImports;e&&n.push(...e)}return n.sort((e,n)=>d(e).localeCompare(d(n))),new t.SafeString(n.map(e=>`${e}\n`).join(""))}),t.registerHelper("platformEditionImport",function(){return new t.SafeString("import { VendurePlatform } from './platform-edition';")}),t.registerHelper("platformPluginOptions",function(){const n=[];for(const r of e){const e=(0,u.getPlugin)(r).platformOptionsBlock;e&&n.push(` ${t.compile(e)(this)},`)}return new t.SafeString(n.join("\n"))}),t}function v(e,n,r,t){var i,a,s,l;const d=t.profile,v=null!==(i=t.packageManager)&&void 0!==i?i:c.DEFAULT_PACKAGE_MANAGER,_=(0,u.resolveProfilePluginKeys)(d),h=_.map(e=>(0,u.getPlugin)(e)),P=p(t.versionOverride),S=[...o.CAPABILITY_PROFILES[d]],j=S.includes("search.engine.typesense");return{context:{projectName:e,companyName:n,resolvedPluginKeys:_,resolvedPlugins:h,includeStorefront:r,includeDemoData:null===(a=t.includeDemoData)||void 0===a||a,existingProject:null!==(s=t.existingProject)&&void 0!==s&&s,pluginVersionSpec:P,coreVersion:m().dependencies["@vendure/cli"],mcpSdkVersion:f(),usesPnpm:"pnpm"===t.packageManager,usesBun:"bun"===v,packageManager:v,licenseToken:null!==(l=t.licenseToken)&&void 0!==l?l:"",profile:d,capabilityGrants:S,usesTypesense:j},hbs:g(_,P,d)}}function _(e,n,r){const t=i.readFileSync(e,"utf8"),o=r.compile(t,{noEscape:!0})(n);return s.basename(e).endsWith("package.json.hbs")?(0,l.sortPackageJson)(o):o}function h(e){const n=[s.join(__dirname,"assets","templates",e),s.join(__dirname,"..","assets","templates",e)];for(const e of n)if(i.existsSync(e))return e;throw new Error(`Template not found: ${e}\n __dirname: ${__dirname}\n Searched:\n${n.map(e=>` - ${e} (exists: ${i.existsSync(s.dirname(e))})`).join("\n")}`)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure-platform/create",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "CLI tool to scaffold a Vendure demo project with Vendure Platform plugins",
|
|
5
5
|
"vendurePlugin": {
|
|
6
6
|
"slug": "create",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@clack/prompts": "^0.10.0",
|
|
52
52
|
"@vendure/cli": "3.8.0",
|
|
53
|
-
"@vendure-platform/console-auth": "1.0.
|
|
54
|
-
"@vendure-platform/plugin-meta": "1.0.
|
|
53
|
+
"@vendure-platform/console-auth": "1.0.1",
|
|
54
|
+
"@vendure-platform/plugin-meta": "1.0.1",
|
|
55
55
|
"commander": "^13.1.0",
|
|
56
56
|
"fs-extra": "^11.3.0",
|
|
57
57
|
"handlebars": "^4.7.8",
|