create-brainerce-store 1.28.20 → 1.29.0
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/dist/index.js +65 -33
- package/messages/en.json +406 -390
- package/messages/he.json +406 -390
- package/package.json +4 -3
- package/templates/nextjs/base/package.json.ejs +2 -2
- package/templates/nextjs/base/src/app/cart/page.tsx +178 -178
- package/templates/nextjs/base/src/app/products/[slug]/product-client-section.tsx +566 -529
- package/templates/nextjs/base/src/components/checkout/payment-step.tsx +730 -656
- package/templates/nextjs/base/src/components/products/customization-fields.tsx +478 -0
- package/templates/nextjs/base/src/lib/safe-redirect.ts +60 -45
- package/templates/nextjs/base/src/middleware.ts.ejs +2 -2
- package/dist/index.d.ts +0 -1
- package/templates/nextjs/base/tsconfig.tsbuildinfo +0 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var require_package = __commonJS({
|
|
|
31
31
|
"package.json"(exports2, module2) {
|
|
32
32
|
module2.exports = {
|
|
33
33
|
name: "create-brainerce-store",
|
|
34
|
-
version: "1.
|
|
34
|
+
version: "1.29.0",
|
|
35
35
|
description: "Scaffold a production-ready e-commerce storefront connected to Brainerce",
|
|
36
36
|
bin: {
|
|
37
37
|
"create-brainerce-store": "dist/index.js"
|
|
@@ -42,12 +42,13 @@ var require_package = __commonJS({
|
|
|
42
42
|
"messages"
|
|
43
43
|
],
|
|
44
44
|
scripts: {
|
|
45
|
-
build: "tsup
|
|
46
|
-
dev: "tsup
|
|
45
|
+
build: "tsup",
|
|
46
|
+
dev: "tsup --watch",
|
|
47
47
|
clean: "rimraf dist",
|
|
48
48
|
prepublishOnly: "npm run build"
|
|
49
49
|
},
|
|
50
50
|
dependencies: {
|
|
51
|
+
"@brainerce/cli-shared": "workspace:*",
|
|
51
52
|
chalk: "^4.1.2",
|
|
52
53
|
commander: "^12.1.0",
|
|
53
54
|
ejs: "^3.1.10",
|
|
@@ -140,37 +141,36 @@ function validateApiUrl(url) {
|
|
|
140
141
|
return null;
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
// src/
|
|
144
|
+
// ../cli-shared/src/deps.ts
|
|
144
145
|
var import_child_process = require("child_process");
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
var ALLOWED_PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
|
|
162
|
-
async function installDependencies(projectDir, pkgManager) {
|
|
146
|
+
|
|
147
|
+
// ../cli-shared/src/versions.ts
|
|
148
|
+
var ALLOWED_PACKAGE_MANAGERS = [
|
|
149
|
+
"npm",
|
|
150
|
+
"pnpm",
|
|
151
|
+
"yarn",
|
|
152
|
+
"bun"
|
|
153
|
+
];
|
|
154
|
+
var BRAINERCE_RUNTIME_DEPS = Object.freeze({
|
|
155
|
+
brainerce: "^1.18.0",
|
|
156
|
+
"isomorphic-dompurify": "^3.8.0"
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// ../cli-shared/src/deps.ts
|
|
160
|
+
async function installDependencies(projectDir, pkgManager, opts = {}) {
|
|
163
161
|
if (!ALLOWED_PACKAGE_MANAGERS.includes(pkgManager)) {
|
|
164
162
|
throw new Error(`Unsupported package manager: ${pkgManager}`);
|
|
165
163
|
}
|
|
164
|
+
const subcommand = opts.subcommand ?? (pkgManager === "yarn" ? "" : "install");
|
|
165
|
+
const extraArgs = opts.args ?? [];
|
|
166
166
|
return new Promise((resolve, reject) => {
|
|
167
167
|
const isWindows = process.platform === "win32";
|
|
168
|
-
const
|
|
169
|
-
const child = isWindows ? (0, import_child_process.spawn)(`${pkgManager} ${
|
|
168
|
+
const argTokens = [subcommand, ...extraArgs].filter((t) => t !== "");
|
|
169
|
+
const child = isWindows ? (0, import_child_process.spawn)(`${pkgManager} ${argTokens.join(" ")}`.trim(), {
|
|
170
170
|
cwd: projectDir,
|
|
171
171
|
stdio: ["ignore", "ignore", "pipe"],
|
|
172
172
|
shell: true
|
|
173
|
-
}) : (0, import_child_process.spawn)(pkgManager,
|
|
173
|
+
}) : (0, import_child_process.spawn)(pkgManager, argTokens, {
|
|
174
174
|
cwd: projectDir,
|
|
175
175
|
stdio: ["ignore", "ignore", "pipe"]
|
|
176
176
|
});
|
|
@@ -197,6 +197,24 @@ ${tail}` : "";
|
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
// ../cli-shared/src/package-manager.ts
|
|
201
|
+
var import_child_process2 = require("child_process");
|
|
202
|
+
function detectInvokingPackageManager() {
|
|
203
|
+
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
204
|
+
if (userAgent.startsWith("pnpm")) return "pnpm";
|
|
205
|
+
if (userAgent.startsWith("yarn")) return "yarn";
|
|
206
|
+
if (userAgent.startsWith("bun")) return "bun";
|
|
207
|
+
if (userAgent.startsWith("npm")) return "npm";
|
|
208
|
+
for (const manager of ALLOWED_PACKAGE_MANAGERS) {
|
|
209
|
+
try {
|
|
210
|
+
(0, import_child_process2.execSync)(`${manager} --version`, { stdio: "ignore" });
|
|
211
|
+
return manager;
|
|
212
|
+
} catch {
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return "npm";
|
|
216
|
+
}
|
|
217
|
+
|
|
200
218
|
// src/cli.ts
|
|
201
219
|
async function runInteractive(defaults) {
|
|
202
220
|
const questions = [];
|
|
@@ -274,12 +292,24 @@ async function runInteractive(defaults) {
|
|
|
274
292
|
name: "pkgManager",
|
|
275
293
|
message: "Package manager:",
|
|
276
294
|
choices: [
|
|
277
|
-
{
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
295
|
+
{
|
|
296
|
+
title: `pnpm${detectInvokingPackageManager() === "pnpm" ? " (detected)" : ""}`,
|
|
297
|
+
value: "pnpm"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
title: `npm${detectInvokingPackageManager() === "npm" ? " (detected)" : ""}`,
|
|
301
|
+
value: "npm"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
title: `yarn${detectInvokingPackageManager() === "yarn" ? " (detected)" : ""}`,
|
|
305
|
+
value: "yarn"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
title: `bun${detectInvokingPackageManager() === "bun" ? " (detected)" : ""}`,
|
|
309
|
+
value: "bun"
|
|
310
|
+
}
|
|
281
311
|
],
|
|
282
|
-
initial: ["pnpm", "npm", "yarn", "bun"].indexOf(
|
|
312
|
+
initial: ["pnpm", "npm", "yarn", "bun"].indexOf(detectInvokingPackageManager())
|
|
283
313
|
}
|
|
284
314
|
);
|
|
285
315
|
const response = await (0, import_prompts.default)(questions, {
|
|
@@ -293,7 +323,7 @@ async function runInteractive(defaults) {
|
|
|
293
323
|
language: response.language || defaults.language || "en",
|
|
294
324
|
framework: response.framework || defaults.framework || "nextjs",
|
|
295
325
|
theme: response.theme || defaults.theme || "minimal",
|
|
296
|
-
pkgManager: response.pkgManager || defaults.pkgManager ||
|
|
326
|
+
pkgManager: response.pkgManager || defaults.pkgManager || detectInvokingPackageManager()
|
|
297
327
|
};
|
|
298
328
|
}
|
|
299
329
|
|
|
@@ -388,7 +418,9 @@ async function scaffold(options) {
|
|
|
388
418
|
ogLocale,
|
|
389
419
|
i18nEnabled: isMultiLocale,
|
|
390
420
|
supportedLocales: JSON.stringify(supportedLocales),
|
|
391
|
-
defaultLocale
|
|
421
|
+
defaultLocale,
|
|
422
|
+
brainerceVersion: BRAINERCE_RUNTIME_DEPS.brainerce,
|
|
423
|
+
isomorphicDompurifyVersion: BRAINERCE_RUNTIME_DEPS["isomorphic-dompurify"]
|
|
392
424
|
};
|
|
393
425
|
await copyWithEjs(baseDir, targetDir, templateVars);
|
|
394
426
|
const messagesRoot = findMessagesDir(__dirname);
|
|
@@ -776,7 +808,7 @@ program.name("create-brainerce-store").description("Scaffold a production-ready
|
|
|
776
808
|
}
|
|
777
809
|
}
|
|
778
810
|
if (!pkgManager) {
|
|
779
|
-
pkgManager =
|
|
811
|
+
pkgManager = detectInvokingPackageManager();
|
|
780
812
|
}
|
|
781
813
|
const scaffoldSpinner = createSpinner("Scaffolding project...");
|
|
782
814
|
scaffoldSpinner.start();
|