create-brainerce-store 1.24.0 → 1.25.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.
Files changed (2) hide show
  1. package/dist/index.js +61 -24
  2. package/package.json +1 -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.24.0",
34
+ version: "1.25.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"
@@ -174,6 +174,17 @@ async function runInteractive(defaults) {
174
174
  return error || true;
175
175
  }
176
176
  });
177
+ } else {
178
+ questions.push({
179
+ type: "text",
180
+ name: "projectName",
181
+ message: "Project name:",
182
+ initial: defaults.projectName,
183
+ validate: (value) => {
184
+ const error = validateProjectName(value);
185
+ return error || true;
186
+ }
187
+ });
177
188
  }
178
189
  if (!defaults.connectionId) {
179
190
  questions.push({
@@ -583,11 +594,40 @@ program.name("create-brainerce-store").description("Scaffold a production-ready
583
594
  let pkgManager = options.pkgManager;
584
595
  const skipGit = options.git === false;
585
596
  const skipInstall = options.install === false;
597
+ let storeInfo = null;
598
+ let resolvedApiUrl = candidateApiUrls[0];
599
+ if (connectionId) {
600
+ const connError2 = validateConnectionId(connectionId);
601
+ if (connError2) {
602
+ logger.error(connError2);
603
+ process.exit(1);
604
+ }
605
+ const prefetchSpinner = createSpinner("Fetching store info...");
606
+ prefetchSpinner.start();
607
+ try {
608
+ const resolved = await resolveStoreInfo(connectionId, candidateApiUrls);
609
+ storeInfo = resolved.info;
610
+ resolvedApiUrl = resolved.apiBaseUrl;
611
+ const envLabel = resolved.apiBaseUrl === KNOWN_API_URLS.staging ? " [staging]" : resolved.apiBaseUrl === KNOWN_API_URLS.production ? "" : ` [${resolved.apiBaseUrl}]`;
612
+ const i18nStatus = storeInfo.i18n?.enabled && storeInfo.i18n.supportedLocales.length > 1 ? ` | i18n: ${storeInfo.i18n.supportedLocales.join(", ")}` : "";
613
+ prefetchSpinner.succeed(
614
+ `Store: "${storeInfo.name}" | ${storeInfo.currency} | ${storeInfo.language}${i18nStatus}${envLabel}`
615
+ );
616
+ } catch (err) {
617
+ prefetchSpinner.fail("Could not fetch store info");
618
+ logger.warn(
619
+ err instanceof Error ? err.message : "Using defaults. Make sure the connection ID is correct and the Brainerce API is reachable."
620
+ );
621
+ }
622
+ }
623
+ const slugify = (s) => s.toLowerCase().trim().replace(/[^a-z0-9\u0590-\u05FF]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 50);
624
+ const projectNameDefault = projectName || (storeInfo ? slugify(storeInfo.name) : void 0);
625
+ const languageDefault = language || storeInfo?.language;
586
626
  if (!projectName || !connectionId || !language) {
587
627
  const answers = await runInteractive({
588
- projectName,
628
+ projectName: projectNameDefault,
589
629
  connectionId,
590
- language,
630
+ language: languageDefault,
591
631
  framework,
592
632
  theme,
593
633
  pkgManager
@@ -609,28 +649,25 @@ program.name("create-brainerce-store").description("Scaffold a production-ready
609
649
  logger.error(connError);
610
650
  process.exit(1);
611
651
  }
612
- const spinner = createSpinner("Fetching store info...");
613
- spinner.start();
614
- let storeInfo;
615
- let resolvedApiUrl = candidateApiUrls[0];
616
- try {
617
- const resolved = await resolveStoreInfo(connectionId, candidateApiUrls);
618
- storeInfo = resolved.info;
619
- resolvedApiUrl = resolved.apiBaseUrl;
620
- const envLabel = resolved.apiBaseUrl === KNOWN_API_URLS.staging ? " [staging]" : resolved.apiBaseUrl === KNOWN_API_URLS.production ? "" : ` [${resolved.apiBaseUrl}]`;
621
- const i18nStatus = storeInfo.i18n?.enabled && storeInfo.i18n.supportedLocales.length > 1 ? ` | i18n: ${storeInfo.i18n.supportedLocales.join(", ")}` : "";
622
- spinner.succeed(
623
- `Store: "${storeInfo.name}" | ${storeInfo.currency} | ${storeInfo.language}${i18nStatus}${envLabel}`
624
- );
625
- if (resolved.fellBack) {
626
- logger.info(` Detected ${envLabel.trim() || "alternate"} environment \u2014 using ${resolved.apiBaseUrl}`);
652
+ if (!storeInfo) {
653
+ const spinner = createSpinner("Fetching store info...");
654
+ spinner.start();
655
+ try {
656
+ const resolved = await resolveStoreInfo(connectionId, candidateApiUrls);
657
+ storeInfo = resolved.info;
658
+ resolvedApiUrl = resolved.apiBaseUrl;
659
+ const envLabel = resolved.apiBaseUrl === KNOWN_API_URLS.staging ? " [staging]" : resolved.apiBaseUrl === KNOWN_API_URLS.production ? "" : ` [${resolved.apiBaseUrl}]`;
660
+ const i18nStatus = storeInfo.i18n?.enabled && storeInfo.i18n.supportedLocales.length > 1 ? ` | i18n: ${storeInfo.i18n.supportedLocales.join(", ")}` : "";
661
+ spinner.succeed(
662
+ `Store: "${storeInfo.name}" | ${storeInfo.currency} | ${storeInfo.language}${i18nStatus}${envLabel}`
663
+ );
664
+ } catch (err) {
665
+ spinner.fail("Could not fetch store info");
666
+ logger.warn(
667
+ err instanceof Error ? err.message : "Using defaults. Make sure the connection ID is correct and the Brainerce API is reachable."
668
+ );
669
+ storeInfo = { name: projectName, currency: "USD", language: "en" };
627
670
  }
628
- } catch (err) {
629
- spinner.fail("Could not fetch store info");
630
- logger.warn(
631
- err instanceof Error ? err.message : "Using defaults. Make sure the connection ID is correct and the Brainerce API is reachable."
632
- );
633
- storeInfo = { name: projectName, currency: "USD", language: "en" };
634
671
  }
635
672
  if (!pkgManager) {
636
673
  pkgManager = detectPackageManager();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-brainerce-store",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "Scaffold a production-ready e-commerce storefront connected to Brainerce",
5
5
  "bin": {
6
6
  "create-brainerce-store": "dist/index.js"