@faststore/cli 4.7.1-dev.1 → 4.7.1-dev.2

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 CHANGED
@@ -3,12 +3,12 @@ import { run } from "@oclif/core";
3
3
 
4
4
  // src/commands/build.ts
5
5
  import { Args, Command, Flags } from "@oclif/core";
6
- import chalk2 from "chalk";
7
- import { spawnSync as spawnSync2 } from "child_process";
6
+ import chalk3 from "chalk";
7
+ import { spawnSync } from "child_process";
8
8
  import { existsSync as existsSync4 } from "fs";
9
- import fsExtra3 from "fs-extra";
9
+ import fsExtra2 from "fs-extra";
10
10
  import path3 from "path";
11
- import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
11
+ import { fileURLToPath as fileURLToPath2, pathToFileURL } from "url";
12
12
 
13
13
  // src/utils/binPaths.ts
14
14
  import fsExtra from "fs-extra";
@@ -56,51 +56,17 @@ function withNodeModulesBins(fromDir, env = process.env) {
56
56
  }
57
57
 
58
58
  // src/utils/commands.ts
59
- import fsExtra2 from "fs-extra";
60
- import { spawnSync } from "child_process";
61
- import { join } from "path";
62
- import { pathToFileURL } from "url";
63
- import resolvePackage from "resolve-pkg";
64
- var { existsSync: existsSync2 } = fsExtra2;
65
- async function getPreferredPackageManager() {
66
- let agent = "yarn";
67
- const binNA = join(
68
- await getPackageRootDir("@antfu/ni"),
69
- (await getDepPackageJSON("@antfu/ni"))?.bin?.["na"] ?? ""
70
- );
71
- if (!binNA || fsExtra2.existsSync(binNA) == false) return agent;
72
- agent = spawnSync("node", [binNA, "?"], { encoding: "utf-8" })?.stdout.trim();
73
- return agent;
74
- }
75
- async function getPackageRootDir(pkg, cwd = process.cwd(), depth = 30) {
76
- let pkgPath = resolvePackage(pkg, { cwd });
77
- if (!pkgPath) throw new Error(`Couldn't resolve package ${pkg}`);
78
- let pkgJson = await loadPackageJsonAt(pkgPath);
79
- while (pkgJson?.name !== pkg && --depth > 0) {
80
- pkgPath = join(pkgPath, "..");
81
- pkgJson = await loadPackageJsonAt(join(pkgPath, ".."));
82
- }
83
- if (pkgJson?.name !== pkg)
84
- throw new Error(`Maximum depth search for package ${pkg} root exceed`);
85
- return pkgPath;
86
- }
87
- async function loadPackageJsonAt(at) {
88
- const file = "package.json", location = at?.endsWith(file) && at || at && join(at, file) || false;
89
- if (location === false)
90
- throw new Error(`Invalid searching of ${file} at ${at}`);
91
- if (!existsSync2(location)) return;
92
- const content = await import(pathToFileURL(location).href, {
93
- with: { type: "json" }
94
- });
95
- return content.default ?? content ?? {};
96
- }
97
- async function getDepPackageJSON(pkg) {
98
- return await loadPackageJsonAt(await getPackageRootDir(pkg));
99
- }
100
-
101
- // src/utils/deprecations.ts
102
- import { existsSync as existsSync3 } from "fs";
59
+ import {
60
+ LOCKS,
61
+ agents,
62
+ cmdExists,
63
+ detect,
64
+ getCommand,
65
+ getVoltaPrefix
66
+ } from "@antfu/ni";
103
67
  import chalk from "chalk";
68
+ import { existsSync as existsSync2 } from "fs";
69
+ import { join } from "path";
104
70
 
105
71
  // src/utils/logger.ts
106
72
  var logger = new Proxy(console, {
@@ -116,7 +82,73 @@ var logger = new Proxy(console, {
116
82
  }
117
83
  });
118
84
 
85
+ // src/utils/commands.ts
86
+ var UnknownAgentError = class extends Error {
87
+ };
88
+ var NoAvailablePackageManagerError = class extends Error {
89
+ };
90
+ var DEFAULT_AGENT = "yarn";
91
+ var FALLBACK_AGENTS = ["yarn", "npm", "pnpm", "bun"];
92
+ async function resolvePackageManager(cwd = process.cwd(), { substitute = true } = {}) {
93
+ const detected = await detect({ programmatic: true, cwd }) ?? DEFAULT_AGENT;
94
+ if (!agents.includes(detected)) {
95
+ throw new UnknownAgentError(
96
+ `"${detected}" is not a known package manager. Expected one of: ${agents.join(
97
+ ", "
98
+ )}.`
99
+ );
100
+ }
101
+ let agent = detected;
102
+ if (!cmdExists(binOf(detected))) {
103
+ if (!substitute) {
104
+ throw new NoAvailablePackageManagerError(
105
+ `Detected "${detected}", which is not installed in this environment. This operation writes a lockfile, so no other package manager can stand in for it. Install "${detected}", or remove the lockfile or "packageManager" field that selects it.`
106
+ );
107
+ }
108
+ agent = substituteAgent(detected, cwd);
109
+ }
110
+ const argv = [binOf(agent)];
111
+ const voltaPrefix = getVoltaPrefix();
112
+ if (voltaPrefix) {
113
+ argv.unshift(...voltaPrefix.split(" "));
114
+ }
115
+ return { agent, command: argv.join(" "), argv };
116
+ }
117
+ async function getPreferredPackageManager(cwd) {
118
+ const { command } = await resolvePackageManager(cwd);
119
+ return command;
120
+ }
121
+ function binOf(agent) {
122
+ return getCommand(agent, "agent");
123
+ }
124
+ function substituteAgent(detected, cwd) {
125
+ const available = FALLBACK_AGENTS.find(
126
+ (candidate) => cmdExists(binOf(candidate))
127
+ );
128
+ if (!available) {
129
+ throw new NoAvailablePackageManagerError(
130
+ `Detected "${detected}", which is not installed, and none of ${FALLBACK_AGENTS.join(
131
+ ", "
132
+ )} is available either.`
133
+ );
134
+ }
135
+ const lockfiles = Object.keys(LOCKS).filter(
136
+ (lockfile) => existsSync2(join(cwd, lockfile))
137
+ );
138
+ logger.warn(
139
+ `${chalk.yellow(
140
+ "warning"
141
+ )} - Detected "${detected}" but it is not installed in this environment. Using "${available}" instead.` + (lockfiles.length > 1 ? `
142
+ More than one lockfile is committed (${lockfiles.join(
143
+ ", "
144
+ )}). Keep a single one so the package manager is unambiguous.` : "")
145
+ );
146
+ return available;
147
+ }
148
+
119
149
  // src/utils/deprecations.ts
150
+ import { existsSync as existsSync3 } from "fs";
151
+ import chalk2 from "chalk";
120
152
  function checkDeprecatedSecretFiles(basePath) {
121
153
  const secretsFilePath = `${basePath}/secrets.hidden.json`;
122
154
  const vtexEnvFilePath = `${basePath}/vtex.env`;
@@ -128,7 +160,7 @@ function checkDeprecatedSecretFiles(basePath) {
128
160
  vtexEnvFileExists ? "vtex.env" : null
129
161
  ].filter(Boolean).join(" and ");
130
162
  logger.warn(
131
- `${chalk.yellow("warning")} - Deprecated secret files detected: ${chalk.bold(filesFound)}
163
+ `${chalk2.yellow("warning")} - Deprecated secret files detected: ${chalk2.bold(filesFound)}
132
164
  Note: 'vtex.env' should only be used for local development and not in production.
133
165
  For production environments, please configure your secrets directly in the FastStore WebOps Settings page.`
134
166
  );
@@ -197,7 +229,7 @@ var withBasePath = (basepath) => {
197
229
  };
198
230
 
199
231
  // src/commands/build.ts
200
- var { copySync, moveSync, readdirSync, removeSync } = fsExtra3;
232
+ var { copySync, moveSync, readdirSync, removeSync } = fsExtra2;
201
233
  var Build = class _Build extends Command {
202
234
  static args = {
203
235
  account: Args.string({
@@ -220,7 +252,7 @@ var Build = class _Build extends Command {
220
252
  const invalidPackages = await checkDeps(basePath);
221
253
  invalidPackages.forEach(
222
254
  (pkg) => logger.warn(
223
- `${chalk2.yellow(
255
+ `${chalk3.yellow(
224
256
  "warning"
225
257
  )} - Dependency ${pkg} has invalid version signature. Please use a semver like ^1.0.0 (check the official releases on https://github.com/vtex/faststore)`
226
258
  )
@@ -233,25 +265,25 @@ var Build = class _Build extends Command {
233
265
  import.meta.resolve("@faststore/cli/runner", import.meta.url)
234
266
  )
235
267
  );
236
- let scriptResult = spawnSync2("node", [binCli, "generate", basePath], {
268
+ let scriptResult = spawnSync("node", [binCli, "generate", basePath], {
237
269
  stdio: "inherit"
238
270
  });
239
271
  if (scriptResult.error || scriptResult.status !== 0) {
240
272
  throw "Error: Cant run generate" + (scriptResult.error?.message ?? "");
241
273
  }
242
- scriptResult = spawnSync2("node", [binCli, "cache-graphql", basePath], {
274
+ scriptResult = spawnSync("node", [binCli, "cache-graphql", basePath], {
243
275
  stdio: "inherit"
244
276
  });
245
277
  if (scriptResult.error || scriptResult.status !== 0) {
246
278
  throw "Error: Unable to run cache-graphql" + (scriptResult.error?.message ?? "");
247
279
  }
248
- scriptResult = spawnSync2("node", [binCli, "generate-i18n", basePath], {
280
+ scriptResult = spawnSync("node", [binCli, "generate-i18n", basePath], {
249
281
  stdio: "inherit"
250
282
  });
251
283
  if (scriptResult.error || scriptResult.status !== 0) {
252
284
  throw "Error: Unable to run generate-i18n" + (scriptResult.error?.message ?? "");
253
285
  }
254
- scriptResult = spawnSync2(`${packageManager} run build`, {
286
+ scriptResult = spawnSync(`${packageManager} run build`, {
255
287
  shell: true,
256
288
  cwd: tmpDir,
257
289
  stdio: "inherit",
@@ -271,12 +303,12 @@ async function copyResource(from, to) {
271
303
  }
272
304
  copySync(from, to);
273
305
  console.log(
274
- `${chalk2.green("success")} - ${chalk2.dim(from)} copied to ${chalk2.dim(
306
+ `${chalk3.green("success")} - ${chalk3.dim(from)} copied to ${chalk3.dim(
275
307
  to
276
308
  )}`
277
309
  );
278
310
  } catch (err) {
279
- console.error(`${chalk2.red("error")} - ${err}`);
311
+ console.error(`${chalk3.red("error")} - ${err}`);
280
312
  }
281
313
  }
282
314
  async function normalizeStandaloneBuildDir(basePath) {
@@ -322,13 +354,13 @@ async function checkDeps(basePath) {
322
354
  const packageJsonPath = `${basePath}/package.json`;
323
355
  if (!existsSync4(packageJsonPath)) {
324
356
  console.log(
325
- `${chalk2.yellow(
357
+ `${chalk3.yellow(
326
358
  "warning"
327
359
  )} - package.json not found at ${packageJsonPath}`
328
360
  );
329
361
  }
330
362
  try {
331
- const mod = await import(pathToFileURL2(packageJsonPath).href, {
363
+ const mod = await import(pathToFileURL(packageJsonPath).href, {
332
364
  with: { type: "json" }
333
365
  });
334
366
  const pkg = mod.default ?? mod;
@@ -353,7 +385,7 @@ async function checkDeps(basePath) {
353
385
  return invalidPackages;
354
386
  } catch (err) {
355
387
  console.log(
356
- `${chalk2.yellow("warning")} - unable to check @faststore dependencies: ${err}`
388
+ `${chalk3.yellow("warning")} - unable to check @faststore dependencies: ${err}`
357
389
  );
358
390
  return [];
359
391
  }
@@ -361,17 +393,17 @@ async function checkDeps(basePath) {
361
393
 
362
394
  // src/commands/cms-sync.ts
363
395
  import { Args as Args2, Command as Command2, Flags as Flags2 } from "@oclif/core";
364
- import chalk10 from "chalk";
396
+ import chalk12 from "chalk";
365
397
  import { spawn } from "child_process";
366
398
  import { existsSync as existsSync10 } from "fs";
367
399
  import path11 from "path";
368
- import { pathToFileURL as pathToFileURL7 } from "url";
400
+ import { pathToFileURL as pathToFileURL6 } from "url";
369
401
 
370
402
  // src/utils/config.ts
371
- import chalk3 from "chalk";
403
+ import chalk4 from "chalk";
372
404
  import { existsSync as existsSync5 } from "fs";
373
405
  import path4 from "path";
374
- import { pathToFileURL as pathToFileURL3 } from "url";
406
+ import { pathToFileURL as pathToFileURL2 } from "url";
375
407
  var configFileName = "discovery.config.js";
376
408
  function isMyAccountEnabled(config) {
377
409
  return config?.experimental?.enableFaststoreMyAccount === true;
@@ -386,7 +418,7 @@ function resolveContentSource(rawType) {
386
418
  return "CP";
387
419
  default: {
388
420
  logger.error(
389
- `${chalk3.red("[Error]")} - Unsupported contentSource.type "${rawType}". Expected "CMS" or "CP".`
421
+ `${chalk4.red("[Error]")} - Unsupported contentSource.type "${rawType}". Expected "CMS" or "CP".`
390
422
  );
391
423
  process.exit(1);
392
424
  }
@@ -401,11 +433,11 @@ async function getDiscoveryConfig(basePath) {
401
433
  for (const configPath of configPaths) {
402
434
  if (existsSync5(configPath)) {
403
435
  try {
404
- const discoveryConfig = await import(pathToFileURL3(configPath).href);
436
+ const discoveryConfig = await import(pathToFileURL2(configPath).href);
405
437
  return discoveryConfig?.default ?? discoveryConfig;
406
438
  } catch (error) {
407
439
  logger.warn(
408
- `${chalk3.yellow("warning")} - Could not read config file: ${configPath}.`
440
+ `${chalk4.yellow("warning")} - Could not read config file: ${configPath}.`
409
441
  );
410
442
  }
411
443
  }
@@ -423,16 +455,16 @@ function validateContentSourceForLocalization(config) {
423
455
  if (currentContentSourceType !== "CP") {
424
456
  logger.error(
425
457
  `
426
- ${chalk3.red("[Error]")} - Localization is enabled but contentSource is set to "${currentContentSourceType}".
458
+ ${chalk4.red("[Error]")} - Localization is enabled but contentSource is set to "${currentContentSourceType}".
427
459
 
428
- ${chalk3.cyan("Required Action:")}
429
- Update your ${chalk3.bold("discovery.config.js")} file:
460
+ ${chalk4.cyan("Required Action:")}
461
+ Update your ${chalk4.bold("discovery.config.js")} file:
430
462
 
431
463
  contentSource: {
432
- type: ${chalk3.green('"CP"')}
464
+ type: ${chalk4.green('"CP"')}
433
465
  },
434
466
 
435
- ${chalk3.dim("When localization is enabled, Content Platform (CP) is required.")}
467
+ ${chalk4.dim("When localization is enabled, Content Platform (CP) is required.")}
436
468
  `
437
469
  );
438
470
  process.exit(1);
@@ -448,21 +480,21 @@ async function checkAndValidateLocalization(basePath) {
448
480
  }
449
481
 
450
482
  // src/utils/cp-schema.ts
451
- import chalk5 from "chalk";
483
+ import chalk6 from "chalk";
452
484
  import { cpSync, existsSync as existsSync6, mkdirSync, mkdtempSync, rmSync } from "fs";
453
485
  import path5 from "path";
454
486
 
455
487
  // src/utils/runCommandSync.ts
456
- import chalk4 from "chalk";
488
+ import chalk5 from "chalk";
457
489
  import { execSync } from "child_process";
458
490
  var showError = ({
459
491
  message,
460
492
  cmd,
461
493
  output
462
494
  }) => {
463
- logger.error(`${chalk4.red("error")} - ${message}`);
495
+ logger.error(`${chalk5.red("error")} - ${message}`);
464
496
  if (cmd && output) {
465
- logger.error(`${chalk4.magenta("$")} ${cmd}`);
497
+ logger.error(`${chalk5.magenta("$")} ${cmd}`);
466
498
  logger.error(output);
467
499
  }
468
500
  process.exit(1);
@@ -472,9 +504,9 @@ var showWarning = ({
472
504
  cmd,
473
505
  output
474
506
  }) => {
475
- logger.warn(`${chalk4.yellow("warn")} - ${message}`);
507
+ logger.warn(`${chalk5.yellow("warn")} - ${message}`);
476
508
  if (cmd && output) {
477
- logger.warn(`${chalk4.magenta("$")} ${cmd}`);
509
+ logger.warn(`${chalk5.magenta("$")} ${cmd}`);
478
510
  logger.warn(output);
479
511
  }
480
512
  };
@@ -516,7 +548,7 @@ function getExistingCpDirs(basePath) {
516
548
  }
517
549
  function errorNoCustomization() {
518
550
  logger.error(
519
- `${chalk5.red("[Error]")} - No CMS customization found. Expected cms/faststore/components and/or cms/faststore/pages.`
551
+ `${chalk6.red("[Error]")} - No CMS customization found. Expected cms/faststore/components and/or cms/faststore/pages.`
520
552
  );
521
553
  process.exit(1);
522
554
  }
@@ -531,7 +563,7 @@ function prepareMyAccountMergeDir(basePath) {
531
563
  const coreMyAccountDir = path5.join(coreCMSDir, "my-account");
532
564
  if (!existsSync6(coreMyAccountDir)) {
533
565
  logger.error(
534
- `${chalk5.red("[Error]")} - My Account is enabled but the core My Account schemas were not found at ${coreMyAccountDir}. Update @faststore/core or disable experimental.enableFaststoreMyAccount.`
566
+ `${chalk6.red("[Error]")} - My Account is enabled but the core My Account schemas were not found at ${coreMyAccountDir}. Update @faststore/core or disable experimental.enableFaststoreMyAccount.`
535
567
  );
536
568
  process.exit(1);
537
569
  }
@@ -587,16 +619,16 @@ function generateAndUploadSchema({
587
619
  }
588
620
 
589
621
  // src/utils/generate.ts
590
- import chalk7 from "chalk";
591
- import fsExtra5 from "fs-extra";
622
+ import chalk9 from "chalk";
623
+ import fsExtra4 from "fs-extra";
592
624
  import path9 from "path";
593
625
  import ora from "ora";
594
- import { pathToFileURL as pathToFileURL5 } from "url";
626
+ import { pathToFileURL as pathToFileURL4 } from "url";
595
627
 
596
628
  // src/utils/createNextjsPages.ts
597
629
  import fs2 from "fs";
598
630
  import path6 from "path";
599
- import chalk6 from "chalk";
631
+ import chalk7 from "chalk";
600
632
 
601
633
  // src/utils/readMyAccountCmsRoutes.ts
602
634
  import fs from "fs";
@@ -847,14 +879,14 @@ function generateCmsPages({
847
879
  const normalizedRoute = normalizeAccountRoute(route);
848
880
  if (!isAllowedPrefixPage(normalizedRoute)) {
849
881
  logger.warn(
850
- `${chalk6.yellow("warning")} - Skipping CMS route ${normalizedRoute}: only ${ALLOWED_PREFIX_PAGES.join(", ")} prefixes are allowed`
882
+ `${chalk7.yellow("warning")} - Skipping CMS route ${normalizedRoute}: only ${ALLOWED_PREFIX_PAGES.join(", ")} prefixes are allowed`
851
883
  );
852
884
  continue;
853
885
  }
854
886
  const destinationPath = routeToPageFilePath(corePagesDir, normalizedRoute);
855
887
  if (destinationExists(destinationPath)) {
856
888
  logger.warn(
857
- `${chalk6.yellow("warning")} - Skipping CMS route ${normalizedRoute}: native page takes precedence`
889
+ `${chalk7.yellow("warning")} - Skipping CMS route ${normalizedRoute}: native page takes precedence`
858
890
  );
859
891
  continue;
860
892
  }
@@ -875,7 +907,7 @@ function generateCmsPages({
875
907
  fs2.writeFileSync(destinationPath, content);
876
908
  handled.add(normalizedRoute);
877
909
  logger.log(
878
- `${chalk6.green("success")} - Generated CMS My Account page for ${normalizedRoute} (${contentType}${pagePath ? ", hybrid" : ""})`
910
+ `${chalk7.green("success")} - Generated CMS My Account page for ${normalizedRoute} (${contentType}${pagePath ? ", hybrid" : ""})`
879
911
  );
880
912
  }
881
913
  return handled;
@@ -942,15 +974,26 @@ function createNextJsPages(basePath) {
942
974
  }
943
975
 
944
976
  // src/utils/dependencies.ts
977
+ import chalk8 from "chalk";
945
978
  async function installDependencies({
946
979
  dependencies,
947
980
  cwd,
948
981
  errorMessage
949
982
  }) {
950
- const packageManager = await getPreferredPackageManager();
951
- const installCommand = packageManager === "npm" ? "install" : "add";
983
+ const { agent, command } = await resolvePackageManager(cwd, {
984
+ substitute: false
985
+ }).catch((error) => {
986
+ if (error instanceof NoAvailablePackageManagerError || error instanceof UnknownAgentError) {
987
+ logger.error(`${chalk8.red("error")} - ${error.message}`);
988
+ process.exit(1);
989
+ }
990
+ throw error;
991
+ });
992
+ const installCommand = agent === "npm" ? "install" : "add";
952
993
  runCommandSync({
953
- cmd: `${packageManager} ${installCommand} ${dependencies.join(" ")}`,
994
+ // command is a validated package-manager invocation from resolvePackageManager
995
+ cmd: `${command} ${installCommand} ${dependencies.join(" ")}`,
996
+ // NOSONAR
954
997
  errorMessage,
955
998
  throws: "error",
956
999
  cwd
@@ -958,9 +1001,9 @@ async function installDependencies({
958
1001
  }
959
1002
 
960
1003
  // src/utils/plugins.ts
961
- import fsExtra4 from "fs-extra";
1004
+ import fsExtra3 from "fs-extra";
962
1005
  import path8 from "path";
963
- import { pathToFileURL as pathToFileURL4 } from "url";
1006
+ import { pathToFileURL as pathToFileURL3 } from "url";
964
1007
 
965
1008
  // src/utils/storefrontCopy.ts
966
1009
  import path7 from "path";
@@ -1010,7 +1053,7 @@ function prepareStorefrontTsConfig(tsConfig) {
1010
1053
  }
1011
1054
 
1012
1055
  // src/utils/plugins.ts
1013
- var { copySync: copySync2, existsSync: existsSync7, mkdirSync: mkdirSync2, readdirSync: readdirSync2, writeFileSync } = fsExtra4;
1056
+ var { copySync: copySync2, existsSync: existsSync7, mkdirSync: mkdirSync2, readdirSync: readdirSync2, writeFileSync } = fsExtra3;
1014
1057
  var PLUGIN_CONFIG_FILE = "plugin.config.js";
1015
1058
  var sanitizePluginName = (pluginName, pascalCase = false) => {
1016
1059
  const sanitized = pluginName.split("/")[1];
@@ -1040,7 +1083,7 @@ var getPluginsList = async (basePath) => {
1040
1083
  try {
1041
1084
  const {
1042
1085
  default: { plugins = [] }
1043
- } = await import(pathToFileURL4(tmpStoreConfigFile).href);
1086
+ } = await import(pathToFileURL3(tmpStoreConfigFile).href);
1044
1087
  return plugins;
1045
1088
  } catch (error) {
1046
1089
  logger.error(`Could not load plugins from store config`);
@@ -1119,7 +1162,7 @@ var generatePluginPages = async (basePath, plugins) => {
1119
1162
  plugins.forEach(async (plugin) => {
1120
1163
  const pluginName = getPluginName(plugin);
1121
1164
  const pluginConfigPath = getPackagePath(pluginName, PLUGIN_CONFIG_FILE);
1122
- const { default: pluginConfig } = await import(pathToFileURL4(pluginConfigPath).href);
1165
+ const { default: pluginConfig } = await import(pathToFileURL3(pluginConfigPath).href);
1123
1166
  const { pages: pagesCustom } = getPluginCustomConfig(plugin);
1124
1167
  const pagesConfig = {
1125
1168
  ...pluginConfig.pages ?? {},
@@ -1220,7 +1263,7 @@ var generatePluginApis = async (basePath, plugins) => {
1220
1263
  plugins.forEach(async (plugin) => {
1221
1264
  const pluginName = getPluginName(plugin);
1222
1265
  const pluginConfigPath = getPackagePath(pluginName, PLUGIN_CONFIG_FILE);
1223
- const { default: pluginConfig } = await import(pathToFileURL4(pluginConfigPath).href);
1266
+ const { default: pluginConfig } = await import(pathToFileURL3(pluginConfigPath).href);
1224
1267
  const { apis: apisCustom } = getPluginCustomConfig(plugin);
1225
1268
  const apisConfig = {
1226
1269
  ...pluginConfig.apis ?? {},
@@ -1269,7 +1312,7 @@ var {
1269
1312
  statSync,
1270
1313
  writeFileSync: writeFileSync2,
1271
1314
  writeJsonSync
1272
- } = fsExtra5;
1315
+ } = fsExtra4;
1273
1316
  function createTmpFolder(basePath) {
1274
1317
  const { tmpDir, tmpFolderName } = withBasePath(basePath);
1275
1318
  try {
@@ -1278,12 +1321,12 @@ function createTmpFolder(basePath) {
1278
1321
  }
1279
1322
  mkdirsSync(tmpDir);
1280
1323
  logger.log(
1281
- `${chalk7.green("success")} - Temporary folder ${chalk7.dim(
1324
+ `${chalk9.green("success")} - Temporary folder ${chalk9.dim(
1282
1325
  tmpFolderName
1283
1326
  )} created`
1284
1327
  );
1285
1328
  } catch (err) {
1286
- logger.error(`${chalk7.red("error")} - ${err}`);
1329
+ logger.error(`${chalk9.red("error")} - ${err}`);
1287
1330
  }
1288
1331
  }
1289
1332
  function buildFaststorePackageJson(coreManifest, voltaConfig, nextBin) {
@@ -1373,7 +1416,7 @@ function copyCoreFiles(basePath) {
1373
1416
  });
1374
1417
  filterAndCopyPackageJson(basePath);
1375
1418
  disableTsConfigStrictRules(basePath);
1376
- logger.log(`${chalk7.green("success")} - Core files copied`);
1419
+ logger.log(`${chalk9.green("success")} - Core files copied`);
1377
1420
  } catch (e) {
1378
1421
  logger.error(e);
1379
1422
  }
@@ -1413,7 +1456,7 @@ function copyPublicFiles(basePath) {
1413
1456
  }
1414
1457
  }
1415
1458
  });
1416
- logger.log(`${chalk7.green("success")} - Public files copied`);
1459
+ logger.log(`${chalk9.green("success")} - Public files copied`);
1417
1460
  }
1418
1461
  } catch (e) {
1419
1462
  logger.error(e);
@@ -1434,12 +1477,12 @@ async function copyCypressFiles(basePath) {
1434
1477
  }
1435
1478
  let userStoreConfig;
1436
1479
  if (existsSync8(userStoreConfigFile)) {
1437
- userStoreConfig = (await import(pathToFileURL5(path9.resolve(userStoreConfigFile)).href))?.default;
1480
+ userStoreConfig = (await import(pathToFileURL4(path9.resolve(userStoreConfigFile)).href))?.default;
1438
1481
  } else if (existsSync8(userLegacyStoreConfigFile)) {
1439
- userStoreConfig = (await import(pathToFileURL5(path9.resolve(userLegacyStoreConfigFile)).href))?.default;
1482
+ userStoreConfig = (await import(pathToFileURL4(path9.resolve(userLegacyStoreConfigFile)).href))?.default;
1440
1483
  } else {
1441
1484
  logger.info(
1442
- `${chalk7.blue(
1485
+ `${chalk9.blue(
1443
1486
  "info"
1444
1487
  )} - No store config file was found in the root directory`
1445
1488
  );
@@ -1449,7 +1492,7 @@ async function copyCypressFiles(basePath) {
1449
1492
  overwrite: true,
1450
1493
  dereference: true
1451
1494
  });
1452
- logger.log(`${chalk7.green("success")} - Cypress test files copied`);
1495
+ logger.log(`${chalk9.green("success")} - Cypress test files copied`);
1453
1496
  }
1454
1497
  if (userStoreConfig?.experimental?.cypressVersion > 9) {
1455
1498
  copySync3(
@@ -1476,7 +1519,7 @@ function copyUserStarterToCustomizations(basePath) {
1476
1519
  createNextJsPages(basePath);
1477
1520
  }
1478
1521
  } catch (err) {
1479
- logger.error(`${chalk7.red("error")} - ${err}`);
1522
+ logger.error(`${chalk9.red("error")} - ${err}`);
1480
1523
  }
1481
1524
  if (existsSync8(userStoreConfigFile)) {
1482
1525
  copySync3(userStoreConfigFile, tmpStoreConfigFile, { dereference: true });
@@ -1486,12 +1529,12 @@ function copyUserStarterToCustomizations(basePath) {
1486
1529
  });
1487
1530
  } else {
1488
1531
  logger.info(
1489
- `${chalk7.blue(
1532
+ `${chalk9.blue(
1490
1533
  "info"
1491
1534
  )} - No store config file was found in the root directory`
1492
1535
  );
1493
1536
  }
1494
- logger.log(`${chalk7.green("success")} - Starter files copied`);
1537
+ logger.log(`${chalk9.green("success")} - Starter files copied`);
1495
1538
  }
1496
1539
  async function createCmsWebhookUrlsJsonFile(basePath) {
1497
1540
  const {
@@ -1501,12 +1544,12 @@ async function createCmsWebhookUrlsJsonFile(basePath) {
1501
1544
  } = withBasePath(basePath);
1502
1545
  let userStoreConfig;
1503
1546
  if (existsSync8(userStoreConfigFile)) {
1504
- userStoreConfig = (await import(pathToFileURL5(path9.resolve(userStoreConfigFile)).href))?.default;
1547
+ userStoreConfig = (await import(pathToFileURL4(path9.resolve(userStoreConfigFile)).href))?.default;
1505
1548
  } else if (existsSync8(userLegacyStoreConfigFile)) {
1506
- userStoreConfig = (await import(pathToFileURL5(path9.resolve(userLegacyStoreConfigFile)).href))?.default;
1549
+ userStoreConfig = (await import(pathToFileURL4(path9.resolve(userLegacyStoreConfigFile)).href))?.default;
1507
1550
  } else {
1508
1551
  logger.info(
1509
- `${chalk7.blue(
1552
+ `${chalk9.blue(
1510
1553
  "info"
1511
1554
  )} - No store config file was found in the root directory`
1512
1555
  );
@@ -1515,12 +1558,12 @@ async function createCmsWebhookUrlsJsonFile(basePath) {
1515
1558
  const { webhookUrls } = userStoreConfig?.vtexHeadlessCms;
1516
1559
  try {
1517
1560
  writeJsonSync(tmpCMSWebhookUrlsFile, { urls: webhookUrls }, { spaces: 2 });
1518
- logger.log(`${chalk7.green("success")} - CMS webhook URLs file created`);
1561
+ logger.log(`${chalk9.green("success")} - CMS webhook URLs file created`);
1519
1562
  } catch (err) {
1520
- logger.error(`${chalk7.red("error")} - ${err}`);
1563
+ logger.error(`${chalk9.red("error")} - ${err}`);
1521
1564
  }
1522
1565
  } else {
1523
- logger.info(`${chalk7.blue("info")} - No CMS webhook URLs were provided`);
1566
+ logger.info(`${chalk9.blue("info")} - No CMS webhook URLs were provided`);
1524
1567
  }
1525
1568
  }
1526
1569
  async function copyTheme(basePath) {
@@ -1532,11 +1575,11 @@ async function copyTheme(basePath) {
1532
1575
  } = withBasePath(basePath);
1533
1576
  const storeConfigFile = existsSync8(userStoreConfigFile) && userStoreConfigFile || existsSync8(userLegacyStoreConfigFile) && userLegacyStoreConfigFile;
1534
1577
  const userStoreConfigFilePath = storeConfigFile && path9.resolve(storeConfigFile);
1535
- const importedStoreConfig = userStoreConfigFilePath && await import(pathToFileURL5(userStoreConfigFilePath).href);
1578
+ const importedStoreConfig = userStoreConfigFilePath && await import(pathToFileURL4(userStoreConfigFilePath).href);
1536
1579
  const storeConfig = userStoreConfigFilePath && (importedStoreConfig?.default || importedStoreConfig);
1537
1580
  if (!storeConfig)
1538
1581
  logger.info(
1539
- `${chalk7.blue(
1582
+ `${chalk9.blue(
1540
1583
  "info"
1541
1584
  )} - No store config file was found in the root directory`
1542
1585
  );
@@ -1549,19 +1592,19 @@ async function copyTheme(basePath) {
1549
1592
  try {
1550
1593
  copyFileSync(customTheme, tmpThemesCustomizationsFile);
1551
1594
  logger.log(
1552
- `${chalk7.green("success")} - ${storeConfig.theme} theme has been applied`
1595
+ `${chalk9.green("success")} - ${storeConfig.theme} theme has been applied`
1553
1596
  );
1554
1597
  } catch (err) {
1555
- logger.error(`${chalk7.red("error")} - ${err}`);
1598
+ logger.error(`${chalk9.red("error")} - ${err}`);
1556
1599
  }
1557
1600
  } else {
1558
1601
  logger.info(
1559
- `${chalk7.blue("info")} - The ${storeConfig.theme} theme was added to the config file but the ${storeConfig.theme}.scss file does not exist in the themes folder. Read more: https://developers.vtex.com/docs/guides/faststore/themes-overview`
1602
+ `${chalk9.blue("info")} - The ${storeConfig.theme} theme was added to the config file but the ${storeConfig.theme}.scss file does not exist in the themes folder. Read more: https://developers.vtex.com/docs/guides/faststore/themes-overview`
1560
1603
  );
1561
1604
  }
1562
1605
  } else if (existsSync8(userThemesFileDir) && readdirSync3(userThemesFileDir).length > 0) {
1563
1606
  logger.info(
1564
- `${chalk7.blue(
1607
+ `${chalk9.blue(
1565
1608
  "info"
1566
1609
  )} - The theme needs to be added to the config file to be applied. Read more: https://www.faststore.dev/docs/themes/overview`
1567
1610
  );
@@ -1577,19 +1620,19 @@ function updateBuildTime(basePath) {
1577
1620
  `const buildTime = '${newBuildTime}';`
1578
1621
  );
1579
1622
  writeFileSync2(tmpSeoConfig, config);
1580
- logger.log(`${chalk7.green("success")} - Build time updated`, newBuildTime);
1623
+ logger.log(`${chalk9.green("success")} - Build time updated`, newBuildTime);
1581
1624
  } catch (error) {
1582
- logger.error(`${chalk7.red("error")} - Updating build time:`, error);
1625
+ logger.error(`${chalk9.red("error")} - Updating build time:`, error);
1583
1626
  }
1584
1627
  }
1585
1628
  async function checkDependencies(basePath, packagesToCheck) {
1586
1629
  const { coreDir, getRoot } = withBasePath(basePath);
1587
1630
  const corePackageJsonPath = path9.join(coreDir, "package.json");
1588
1631
  const rootPackageJsonPath = path9.join(getRoot(), "package.json");
1589
- const { default: corePackageJson } = await import(pathToFileURL5(corePackageJsonPath).href, {
1632
+ const { default: corePackageJson } = await import(pathToFileURL4(corePackageJsonPath).href, {
1590
1633
  with: { type: "json" }
1591
1634
  });
1592
- const { default: rootPackageJson } = await import(pathToFileURL5(rootPackageJsonPath).href, {
1635
+ const { default: rootPackageJson } = await import(pathToFileURL4(rootPackageJsonPath).href, {
1593
1636
  with: { type: "json" }
1594
1637
  });
1595
1638
  packagesToCheck.forEach((packageName) => {
@@ -1597,13 +1640,13 @@ async function checkDependencies(basePath, packagesToCheck) {
1597
1640
  const rootVersion = rootPackageJson.devDependencies[packageName] || rootPackageJson.dependencies[packageName];
1598
1641
  if (!coreVersion || !rootVersion) {
1599
1642
  logger.warn(
1600
- `${chalk7.yellow(
1643
+ `${chalk9.yellow(
1601
1644
  "warning"
1602
1645
  )} - Package ${packageName} not found in both core or root dependencies.`
1603
1646
  );
1604
1647
  } else if (coreVersion !== rootVersion) {
1605
1648
  logger.warn(
1606
- `${chalk7.yellow(
1649
+ `${chalk9.yellow(
1607
1650
  "warning"
1608
1651
  )} - Version mismatch detected for ${packageName}.
1609
1652
  Core: ${coreVersion}, Customization: ${rootVersion}. Please align both versions to prevent issues`
@@ -1637,8 +1680,8 @@ async function validateAndInstallMissingDependencies(basePath) {
1637
1680
  if (!currentUserStoreConfigFile) {
1638
1681
  return;
1639
1682
  }
1640
- const { default: userStoreConfig } = await import(pathToFileURL5(currentUserStoreConfigFile).href);
1641
- const { default: userPackageJson } = await import(pathToFileURL5(path9.join(userDir, "package.json")).href, {
1683
+ const { default: userStoreConfig } = await import(pathToFileURL4(currentUserStoreConfigFile).href);
1684
+ const { default: userPackageJson } = await import(pathToFileURL4(path9.join(userDir, "package.json")).href, {
1642
1685
  with: { type: "json" }
1643
1686
  });
1644
1687
  const missingDependencies = [];
@@ -1672,7 +1715,7 @@ async function enableSearchSSR(basePath) {
1672
1715
  if (!storeConfigPath) {
1673
1716
  return;
1674
1717
  }
1675
- const { default: storeConfig } = await import(pathToFileURL5(storeConfigPath).href);
1718
+ const { default: storeConfig } = await import(pathToFileURL4(storeConfigPath).href);
1676
1719
  if (!storeConfig.experimental.enableSearchSSR) {
1677
1720
  return;
1678
1721
  }
@@ -1711,12 +1754,12 @@ async function generate(options) {
1711
1754
  }
1712
1755
 
1713
1756
  // src/utils/hcms.ts
1714
- import chalk8 from "chalk";
1757
+ import chalk10 from "chalk";
1715
1758
  import path10 from "path";
1716
1759
  import { confirm } from "@inquirer/prompts";
1717
- import fsExtra6 from "fs-extra";
1718
- import { pathToFileURL as pathToFileURL6 } from "url";
1719
- var { readFileSync: readFileSync2, existsSync: existsSync9, writeFileSync: writeFileSync3, mkdirSync: mkdirSync3 } = fsExtra6;
1760
+ import fsExtra5 from "fs-extra";
1761
+ import { pathToFileURL as pathToFileURL5 } from "url";
1762
+ var { readFileSync: readFileSync2, existsSync: existsSync9, writeFileSync: writeFileSync3, mkdirSync: mkdirSync3 } = fsExtra5;
1720
1763
  function splitCustomDefinitions(coreDefinitions, customDefinitions, primaryIdentifier) {
1721
1764
  const coreDefinitionIdentifiers = new Set(
1722
1765
  coreDefinitions.map((definition) => definition[primaryIdentifier] ?? "")
@@ -1780,7 +1823,7 @@ async function mergeCMSFile(fileName, basePath) {
1780
1823
  getPackagePath,
1781
1824
  userStoreConfigFile
1782
1825
  } = withBasePath(basePath);
1783
- const { default: userStoreConfig } = await import(pathToFileURL6(path10.resolve(userStoreConfigFile)).href);
1826
+ const { default: userStoreConfig } = await import(pathToFileURL5(path10.resolve(userStoreConfigFile)).href);
1784
1827
  const cmsProjectName = userStoreConfig.contentSource?.project ?? "faststore";
1785
1828
  const coreFilePath = path10.join(coreCMSDir, fileName);
1786
1829
  const customFilePath = path10.join(userCMSDir, fileName);
@@ -1822,7 +1865,7 @@ async function mergeCMSFile(fileName, basePath) {
1822
1865
  } catch (err) {
1823
1866
  if (err instanceof SyntaxError) {
1824
1867
  console.info(
1825
- `${chalk8.red(
1868
+ `${chalk10.red(
1826
1869
  "error"
1827
1870
  )} - ${fileName} is a malformed JSON file, ignoring its contents.`
1828
1871
  );
@@ -1840,10 +1883,10 @@ async function mergeCMSFile(fileName, basePath) {
1840
1883
  JSON.stringify(output)
1841
1884
  );
1842
1885
  console.log(
1843
- `${chalk8.green("success")} - CMS file ${chalk8.dim(fileName)} created`
1886
+ `${chalk10.green("success")} - CMS file ${chalk10.dim(fileName)} created`
1844
1887
  );
1845
1888
  } catch (err) {
1846
- console.error(`${chalk8.red("error")} - ${err}`);
1889
+ console.error(`${chalk10.red("error")} - ${err}`);
1847
1890
  }
1848
1891
  }
1849
1892
  async function mergeCMSFiles(basePath) {
@@ -1851,13 +1894,13 @@ async function mergeCMSFiles(basePath) {
1851
1894
  await mergeCMSFile("content-types.json", basePath);
1852
1895
  await mergeCMSFile("sections.json", basePath);
1853
1896
  } catch (err) {
1854
- console.error(`${chalk8.red("error")} - ${err}`);
1897
+ console.error(`${chalk10.red("error")} - ${err}`);
1855
1898
  }
1856
1899
  }
1857
1900
 
1858
1901
  // src/utils/vtex.ts
1859
1902
  import { execSync as execSync2 } from "child_process";
1860
- import chalk9 from "chalk";
1903
+ import chalk11 from "chalk";
1861
1904
  function runCapture(cmd) {
1862
1905
  try {
1863
1906
  return execSync2(`${cmd} 2>&1`, { stdio: "pipe" }).toString();
@@ -1898,8 +1941,8 @@ function getLoggedVtexAccount() {
1898
1941
  function assertVtexReadyForAccount(account) {
1899
1942
  if (!isVtexCliInstalled()) {
1900
1943
  logger.error(
1901
- `${chalk9.red("[Error]")} - The VTEX toolbelt (\`vtex\`) was not found. Install it with ${chalk9.bold("npm i -g vtex")} and try again.
1902
- ${chalk9.dim("Docs: https://developers.vtex.com/docs/guides/vtex-io-documentation-vtex-io-cli-installation-and-command-reference")}`
1944
+ `${chalk11.red("[Error]")} - The VTEX toolbelt (\`vtex\`) was not found. Install it with ${chalk11.bold("npm i -g vtex")} and try again.
1945
+ ${chalk11.dim("Docs: https://developers.vtex.com/docs/guides/vtex-io-documentation-vtex-io-cli-installation-and-command-reference")}`
1903
1946
  );
1904
1947
  process.exit(1);
1905
1948
  return;
@@ -1908,16 +1951,16 @@ ${chalk9.dim("Docs: https://developers.vtex.com/docs/guides/vtex-io-documentatio
1908
1951
  const loginHint = account ? `vtex login ${account}` : "vtex login <account>";
1909
1952
  if (!loggedAccount) {
1910
1953
  logger.error(
1911
- `${chalk9.red("[Error]")} - You are not logged into the VTEX toolbelt.
1912
- ${chalk9.cyan("Required Action:")} log into the store account by running ${chalk9.bold(loginHint)}.`
1954
+ `${chalk11.red("[Error]")} - You are not logged into the VTEX toolbelt.
1955
+ ${chalk11.cyan("Required Action:")} log into the store account by running ${chalk11.bold(loginHint)}.`
1913
1956
  );
1914
1957
  process.exit(1);
1915
1958
  return;
1916
1959
  }
1917
1960
  if (account && loggedAccount.toLowerCase() !== account.toLowerCase()) {
1918
1961
  logger.error(
1919
- `${chalk9.red("[Error]")} - You are logged into ${chalk9.bold(loggedAccount)}, but this store targets ${chalk9.bold(account)} (\`api.storeId\` in discovery.config.js).
1920
- ${chalk9.cyan("Required Action:")} switch accounts with ${chalk9.bold(`vtex switch ${account}`)} or ${chalk9.bold(loginHint)}.`
1962
+ `${chalk11.red("[Error]")} - You are logged into ${chalk11.bold(loggedAccount)}, but this store targets ${chalk11.bold(account)} (\`api.storeId\` in discovery.config.js).
1963
+ ${chalk11.cyan("Required Action:")} switch accounts with ${chalk11.bold(`vtex switch ${account}`)} or ${chalk11.bold(loginHint)}.`
1921
1964
  );
1922
1965
  process.exit(1);
1923
1966
  }
@@ -1942,10 +1985,10 @@ var CmsSync = class _CmsSync extends Command2 {
1942
1985
  const { flags, args } = await this.parse(_CmsSync);
1943
1986
  const basePath = getBasePath(args.path);
1944
1987
  const { userStoreConfigFile } = withBasePath(basePath);
1945
- const storeConfig = existsSync10(userStoreConfigFile) ? (await import(pathToFileURL7(path11.resolve(userStoreConfigFile)).href)).default : null;
1988
+ const storeConfig = existsSync10(userStoreConfigFile) ? (await import(pathToFileURL6(path11.resolve(userStoreConfigFile)).href)).default : null;
1946
1989
  const source = resolveContentSource(storeConfig?.contentSource?.type);
1947
1990
  logger.info(
1948
- `${chalk10.blue("[Info]")} - Detected contentSource "${source}" \u2014 ${CONTENT_SOURCE_ACTION[source]}`
1991
+ `${chalk12.blue("[Info]")} - Detected contentSource "${source}" \u2014 ${CONTENT_SOURCE_ACTION[source]}`
1949
1992
  );
1950
1993
  switch (source) {
1951
1994
  case "CMS":
@@ -1992,7 +2035,7 @@ var CmsSync = class _CmsSync extends Command2 {
1992
2035
  let merge;
1993
2036
  if (isMyAccountEnabled(storeConfig)) {
1994
2037
  logger.info(
1995
- `${chalk10.blue("[Info]")} - Merging My Account sections and content-types into the schema`
2038
+ `${chalk12.blue("[Info]")} - Merging My Account sections and content-types into the schema`
1996
2039
  );
1997
2040
  merge = prepareMyAccountMergeDir(basePath);
1998
2041
  }
@@ -2062,8 +2105,8 @@ var Create = class _Create extends Command3 {
2062
2105
 
2063
2106
  // src/commands/dev.ts
2064
2107
  import { Args as Args4, Command as Command4, Flags as Flags3 } from "@oclif/core";
2065
- import chalk11 from "chalk";
2066
- import { spawn as spawn2, spawnSync as spawnSync3 } from "child_process";
2108
+ import chalk13 from "chalk";
2109
+ import { spawn as spawn2, spawnSync as spawnSync2 } from "child_process";
2067
2110
  import chokidar from "chokidar";
2068
2111
  import dotenv from "dotenv";
2069
2112
  import { cpSync as cpSync2, existsSync as existsSync11, readFileSync as readFileSync3 } from "fs";
@@ -2093,7 +2136,7 @@ async function storeDev(rootDir, tmpDir, coreDir, port) {
2093
2136
  envVars = dotenv.parse(readFileSync3(vtexEnvPath));
2094
2137
  } catch (err) {
2095
2138
  logger.log(
2096
- `${chalk11.yellow("warn")} - Error parsing vtex.env file: ${err}`
2139
+ `${chalk13.yellow("warn")} - Error parsing vtex.env file: ${err}`
2097
2140
  );
2098
2141
  }
2099
2142
  }
@@ -2111,7 +2154,7 @@ async function storeDev(rootDir, tmpDir, coreDir, port) {
2111
2154
  );
2112
2155
  if (!success) {
2113
2156
  logger.log(
2114
- `${chalk11.yellow("warn")} - Failed to copy @generated schema back to node_modules, autocomplete and DX might be impacted.`
2157
+ `${chalk13.yellow("warn")} - Failed to copy @generated schema back to node_modules, autocomplete and DX might be impacted.`
2115
2158
  );
2116
2159
  logger.log(
2117
2160
  `Attempted to copy from ${path12.join(tmpDir, "@generated")} to ${path12.join(coreDir, "@generated")}`
@@ -2204,13 +2247,13 @@ var Dev = class _Dev extends Command4 {
2204
2247
  const cliPath = fileURLToPath3(
2205
2248
  import.meta.resolve("@faststore/cli/runner", import.meta.url)
2206
2249
  );
2207
- spawnSync3("node", [cliPath, "generate-types", tmpDir], {
2250
+ spawnSync2("node", [cliPath, "generate-types", tmpDir], {
2208
2251
  stdio: "inherit"
2209
2252
  });
2210
- spawnSync3("node", [cliPath, "cache-graphql", basePath], {
2253
+ spawnSync2("node", [cliPath, "cache-graphql", basePath], {
2211
2254
  stdio: "inherit"
2212
2255
  });
2213
- spawnSync3("node", [cliPath, "generate-i18n", basePath], {
2256
+ spawnSync2("node", [cliPath, "generate-i18n", basePath], {
2214
2257
  stdio: "inherit"
2215
2258
  });
2216
2259
  storeDev(getRoot(), tmpDir, coreDir, port);
@@ -2231,7 +2274,7 @@ var Dev = class _Dev extends Command4 {
2231
2274
 
2232
2275
  // src/commands/generate.ts
2233
2276
  import { Args as Args5, Command as Command5 } from "@oclif/core";
2234
- import chalk12 from "chalk";
2277
+ import chalk14 from "chalk";
2235
2278
 
2236
2279
  // src/utils/file.ts
2237
2280
  import fs4 from "fs";
@@ -2383,7 +2426,7 @@ var Generate = class _Generate extends Command5 {
2383
2426
  await generate({ setup: true, basePath });
2384
2427
  genTsTypes(args.path ?? tmpDir);
2385
2428
  logger.log(
2386
- `${chalk12.green(
2429
+ `${chalk14.green(
2387
2430
  "success"
2388
2431
  )} - GraphQL schema, types, and optimizations successfully generated \u{1F389}`
2389
2432
  );
@@ -2438,10 +2481,16 @@ function copyFolder(sourceDir, targetDir) {
2438
2481
 
2439
2482
  // src/commands/start.ts
2440
2483
  import { Args as Args7, Command as Command7 } from "@oclif/core";
2441
- import { spawn as spawn3, spawnSync as spawnSync4 } from "child_process";
2442
- import fsExtra7 from "fs-extra";
2484
+ import { spawn as spawn3, spawnSync as spawnSync3 } from "child_process";
2485
+ import fsExtra6 from "fs-extra";
2443
2486
  import path16 from "path";
2444
- var { existsSync: existsSync13 } = fsExtra7;
2487
+ var { existsSync: existsSync13 } = fsExtra6;
2488
+ function spawnPackageManagerSync(bin, args) {
2489
+ return spawnSync3(bin, args, { stdio: "inherit" });
2490
+ }
2491
+ function spawnPackageManager(bin, args) {
2492
+ return spawn3(bin, args, { stdio: "inherit" });
2493
+ }
2445
2494
  var Start = class _Start extends Command7 {
2446
2495
  static args = {
2447
2496
  account: Args7.string({
@@ -2459,20 +2508,28 @@ var Start = class _Start extends Command7 {
2459
2508
  const basePath = getBasePath(args.path);
2460
2509
  const port = args.port ?? 3e3;
2461
2510
  const { getRoot, tmpDir } = withBasePath(basePath);
2462
- const packageManager = await getPreferredPackageManager();
2511
+ const { argv } = await resolvePackageManager(basePath);
2512
+ const [bin, ...runnerArgs] = argv;
2463
2513
  if (!existsSync13(path16.join(getRoot(), ".next"))) {
2464
- spawnSync4(`${packageManager} faststore build`, {
2465
- shell: true,
2466
- stdio: "inherit"
2467
- });
2468
- }
2469
- return spawn3(
2470
- packageManager,
2471
- ["next", "start", tmpDir, "-p", String(port)],
2472
- {
2473
- stdio: "inherit"
2514
+ const build = spawnPackageManagerSync(bin, [
2515
+ ...runnerArgs,
2516
+ "faststore",
2517
+ "build"
2518
+ ]);
2519
+ if (build.status !== 0) {
2520
+ throw new Error(
2521
+ `"${[bin, ...runnerArgs].join(" ")} faststore build" failed, so there is no build to serve.`
2522
+ );
2474
2523
  }
2475
- );
2524
+ }
2525
+ return spawnPackageManager(bin, [
2526
+ ...runnerArgs,
2527
+ "next",
2528
+ "start",
2529
+ tmpDir,
2530
+ "-p",
2531
+ String(port)
2532
+ ]);
2476
2533
  }
2477
2534
  };
2478
2535
 
@@ -2546,7 +2603,7 @@ var Test = class _Test extends Command8 {
2546
2603
  // src/commands/generate-types.ts
2547
2604
  import path17 from "path";
2548
2605
  import { Args as Args9, Command as Command9 } from "@oclif/core";
2549
- import chalk13 from "chalk";
2606
+ import chalk15 from "chalk";
2550
2607
  var Generate2 = class _Generate extends Command9 {
2551
2608
  static hidden = true;
2552
2609
  static flags = {};
@@ -2563,7 +2620,7 @@ var Generate2 = class _Generate extends Command9 {
2563
2620
  path17.isAbsolute(args.path) ? args.path : path17.resolve(process.env.PWD ?? process.cwd(), args.path)
2564
2621
  );
2565
2622
  logger.log(
2566
- `${chalk13.green(
2623
+ `${chalk15.green(
2567
2624
  "success"
2568
2625
  )} - GraphQL schema, types, and optimizations successfully generated \u{1F389}`
2569
2626
  );
@@ -2572,11 +2629,11 @@ var Generate2 = class _Generate extends Command9 {
2572
2629
 
2573
2630
  // src/commands/cache-graphql.ts
2574
2631
  import { Args as Args10, Command as Command10, Flags as Flags4 } from "@oclif/core";
2575
- import chalk14 from "chalk";
2576
- import fsExtra8 from "fs-extra";
2632
+ import chalk16 from "chalk";
2633
+ import fsExtra7 from "fs-extra";
2577
2634
  import graphql from "graphql";
2578
2635
  import path18 from "path";
2579
- import { pathToFileURL as pathToFileURL8 } from "url";
2636
+ import { pathToFileURL as pathToFileURL7 } from "url";
2580
2637
  var { Kind: Kind2, OperationTypeNode, parse: parseGraphql } = graphql;
2581
2638
  var persistedDocumentsName = "persisted-documents.json";
2582
2639
  var configFileName2 = "discovery.config.default.js";
@@ -2626,23 +2683,23 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2626
2683
  cachedOperationsFileName
2627
2684
  );
2628
2685
  const saveCachedOperationsFile = saveFile(cachedOperationsPath);
2629
- if (fsExtra8.pathExistsSync(tmpDir))
2630
- logger.info(`${chalk14.blue("[Info]")} - .faststore Path at: ${tmpDir}`);
2631
- logger.info(`${chalk14.blue("[Info]")} - Config file location: ${configPath}`);
2686
+ if (fsExtra7.pathExistsSync(tmpDir))
2687
+ logger.info(`${chalk16.blue("[Info]")} - .faststore Path at: ${tmpDir}`);
2688
+ logger.info(`${chalk16.blue("[Info]")} - Config file location: ${configPath}`);
2632
2689
  logger.info(
2633
- `${chalk14.blue("[Info]")} - Persisted documents at: ${persistedDocumentsPath}`
2690
+ `${chalk16.blue("[Info]")} - Persisted documents at: ${persistedDocumentsPath}`
2634
2691
  );
2635
2692
  logger.info(
2636
- `${chalk14.blue("[Info]")} - Cached operations output: ${cachedOperationsPath}`
2693
+ `${chalk16.blue("[Info]")} - Cached operations output: ${cachedOperationsPath}`
2637
2694
  );
2638
- const { default: persistedDocuments } = await import(pathToFileURL8(persistedDocumentsPath).href, { with: { type: "json" } });
2695
+ const { default: persistedDocuments } = await import(pathToFileURL7(persistedDocumentsPath).href, { with: { type: "json" } });
2639
2696
  const cachedQueries = getQueries(persistedDocuments);
2640
2697
  saveCachedOperationsFile(
2641
2698
  `${JSON.stringify(cachedQueries ?? [], null, 2)}
2642
2699
  `
2643
2700
  );
2644
2701
  logger.info(
2645
- `${chalk14.green("[Success]")} - GraphQL queries cached with success: \u{1F389}
2702
+ `${chalk16.green("[Success]")} - GraphQL queries cached with success: \u{1F389}
2646
2703
  Queries: ${cachedQueries.join(", ")}`
2647
2704
  );
2648
2705
  }
@@ -2660,9 +2717,9 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2660
2717
  switch (true) {
2661
2718
  case !rootPath:
2662
2719
  return;
2663
- case (rootPath?.endsWith(fileName) && fsExtra8.existsSync(rootPath)):
2720
+ case (rootPath?.endsWith(fileName) && fsExtra7.existsSync(rootPath)):
2664
2721
  return rootPath;
2665
- case fsExtra8.existsSync(path18.join(rootPath ?? "", fileName)):
2722
+ case fsExtra7.existsSync(path18.join(rootPath ?? "", fileName)):
2666
2723
  return path18.join(rootPath, fileName);
2667
2724
  default:
2668
2725
  if (!pathFromRoot) return;
@@ -2670,7 +2727,7 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2670
2727
  rootPath,
2671
2728
  ...Array.isArray(pathFromRoot) ? pathFromRoot : [pathFromRoot]
2672
2729
  );
2673
- if (fsExtra8.existsSync(filePath)) {
2730
+ if (fsExtra7.existsSync(filePath)) {
2674
2731
  return filePath;
2675
2732
  }
2676
2733
  return;
@@ -2679,7 +2736,7 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2679
2736
  }
2680
2737
  errorFileNotFound(fileName, rootDir) {
2681
2738
  logger.error(
2682
- `${chalk14.red("[Error]")} - Couldn't find ${fileName} at ${rootDir}`
2739
+ `${chalk16.red("[Error]")} - Couldn't find ${fileName} at ${rootDir}`
2683
2740
  );
2684
2741
  process.exit(1);
2685
2742
  }
@@ -2710,13 +2767,13 @@ var getQueries = (persistedDocuments) => {
2710
2767
  // src/commands/generate-i18n.ts
2711
2768
  import { Args as Args11, Command as Command11, Flags as Flags5 } from "@oclif/core";
2712
2769
  import { FastStoreSDK } from "@vtex/faststore-sdk";
2713
- import chalk15 from "chalk";
2770
+ import chalk17 from "chalk";
2714
2771
  import dotenv2 from "dotenv";
2715
- import fsExtra9 from "fs-extra";
2772
+ import fsExtra8 from "fs-extra";
2716
2773
  import { existsSync as existsSync14 } from "fs";
2717
2774
  import path19 from "path";
2718
2775
  import { format } from "prettier";
2719
- import { pathToFileURL as pathToFileURL9 } from "url";
2776
+ import { pathToFileURL as pathToFileURL8 } from "url";
2720
2777
  var configFileName3 = "discovery.config.default.js";
2721
2778
  var GenerateI18n = class _GenerateI18n extends Command11 {
2722
2779
  static hidden = true;
@@ -2740,9 +2797,9 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2740
2797
  switch (true) {
2741
2798
  case !rootPath:
2742
2799
  return;
2743
- case (rootPath?.endsWith(fileName) && fsExtra9.existsSync(rootPath)):
2800
+ case (rootPath?.endsWith(fileName) && fsExtra8.existsSync(rootPath)):
2744
2801
  return rootPath;
2745
- case fsExtra9.existsSync(path19.join(rootPath ?? "", fileName)):
2802
+ case fsExtra8.existsSync(path19.join(rootPath ?? "", fileName)):
2746
2803
  return path19.join(rootPath, fileName);
2747
2804
  default:
2748
2805
  if (!pathFromRoot) return;
@@ -2750,7 +2807,7 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2750
2807
  rootPath,
2751
2808
  ...Array.isArray(pathFromRoot) ? pathFromRoot : [pathFromRoot]
2752
2809
  );
2753
- if (fsExtra9.existsSync(filePath)) {
2810
+ if (fsExtra8.existsSync(filePath)) {
2754
2811
  return filePath;
2755
2812
  }
2756
2813
  return;
@@ -2759,7 +2816,7 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2759
2816
  }
2760
2817
  errorFileNotFound(fileName, rootDir) {
2761
2818
  logger.error(
2762
- `${chalk15.red("[Error]")} - Couldn't find ${fileName} at ${rootDir}`
2819
+ `${chalk17.red("[Error]")} - Couldn't find ${fileName} at ${rootDir}`
2763
2820
  );
2764
2821
  process.exit(1);
2765
2822
  }
@@ -2778,13 +2835,13 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2778
2835
  const { VTEX_ACCOUNT, FS_DISCOVERY_APP_KEY, FS_DISCOVERY_APP_TOKEN } = process.env;
2779
2836
  const hasCredentials = VTEX_ACCOUNT && FS_DISCOVERY_APP_KEY && FS_DISCOVERY_APP_TOKEN;
2780
2837
  if (!hasCredentials) {
2781
- logger.error(`${chalk15.red("[Error]")} - Missing VTEX credentials.
2838
+ logger.error(`${chalk17.red("[Error]")} - Missing VTEX credentials.
2782
2839
 
2783
- ${chalk15.cyan("Required Action:")}
2840
+ ${chalk17.cyan("Required Action:")}
2784
2841
 
2785
- Check your FastStore WebOps Settings page - to work in production, it should contain the following variables: ${chalk15.cyan("VTEX_ACCOUNT")}, ${chalk15.cyan("FS_DISCOVERY_APP_KEY")}, ${chalk15.cyan("FS_DISCOVERY_APP_TOKEN")}.
2842
+ Check your FastStore WebOps Settings page - to work in production, it should contain the following variables: ${chalk17.cyan("VTEX_ACCOUNT")}, ${chalk17.cyan("FS_DISCOVERY_APP_KEY")}, ${chalk17.cyan("FS_DISCOVERY_APP_TOKEN")}.
2786
2843
 
2787
- If running locally, please check your ${chalk15.bold("vtex.env")} file, it should also contain those variables.
2844
+ If running locally, please check your ${chalk17.bold("vtex.env")} file, it should also contain those variables.
2788
2845
  `);
2789
2846
  process.exit(1);
2790
2847
  }
@@ -2799,10 +2856,10 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2799
2856
  );
2800
2857
  }
2801
2858
  const saveConfigFile = saveFile(configPath);
2802
- if (fsExtra9.pathExistsSync(tmpDir))
2803
- logger.info(`${chalk15.blue("[Info]")} - .faststore Path at: ${tmpDir}`);
2804
- logger.info(`${chalk15.blue("[Info]")} - Config file location: ${configPath}`);
2805
- const discoveryConfig = await import(pathToFileURL9(configPath).href);
2859
+ if (fsExtra8.pathExistsSync(tmpDir))
2860
+ logger.info(`${chalk17.blue("[Info]")} - .faststore Path at: ${tmpDir}`);
2861
+ logger.info(`${chalk17.blue("[Info]")} - Config file location: ${configPath}`);
2862
+ const discoveryConfig = await import(pathToFileURL8(configPath).href);
2806
2863
  const faststore = new FastStoreSDK({
2807
2864
  account: VTEX_ACCOUNT,
2808
2865
  appKey: FS_DISCOVERY_APP_KEY,
@@ -2830,7 +2887,7 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2830
2887
  )
2831
2888
  );
2832
2889
  logger.info(
2833
- `${chalk15.green("success")} - i18n configuration successfully generated \u{1F389}`
2890
+ `${chalk17.green("success")} - i18n configuration successfully generated \u{1F389}`
2834
2891
  );
2835
2892
  }
2836
2893
  };