@faststore/cli 4.6.0-dev.4 → 4.6.0-dev.6

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
@@ -5,25 +5,62 @@ import { run } from "@oclif/core";
5
5
  import { Args, Command, Flags } from "@oclif/core";
6
6
  import chalk2 from "chalk";
7
7
  import { spawnSync as spawnSync2 } from "child_process";
8
- import { existsSync as existsSync3 } from "fs";
9
- import fsExtra2 from "fs-extra";
10
- import path2 from "path";
8
+ import { existsSync as existsSync4 } from "fs";
9
+ import fsExtra3 from "fs-extra";
10
+ import path3 from "path";
11
11
  import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
12
12
 
13
- // src/utils/commands.ts
13
+ // src/utils/binPaths.ts
14
14
  import fsExtra from "fs-extra";
15
+ import path from "path";
16
+ var { existsSync } = fsExtra;
17
+ function collectBinDirs(fromDir) {
18
+ const binDirs = [];
19
+ let currentDir = path.resolve(fromDir);
20
+ while (true) {
21
+ const binDir = path.join(currentDir, "node_modules", ".bin");
22
+ if (existsSync(binDir)) {
23
+ binDirs.push(binDir);
24
+ }
25
+ const parentDir = path.dirname(currentDir);
26
+ if (parentDir === currentDir) {
27
+ return binDirs;
28
+ }
29
+ currentDir = parentDir;
30
+ }
31
+ }
32
+ function getPathKey(env) {
33
+ return Object.keys(env).find((key) => key.toUpperCase() === "PATH") ?? "PATH";
34
+ }
35
+ function withNodeModulesBins(fromDir, env = process.env) {
36
+ const binDirs = collectBinDirs(fromDir);
37
+ if (binDirs.length === 0) {
38
+ return { ...env };
39
+ }
40
+ const pathKey = getPathKey(env);
41
+ const currentEntries = env[pathKey]?.split(path.delimiter) ?? [];
42
+ const binDirSet = new Set(binDirs);
43
+ const otherEntries = currentEntries.filter((entry) => !binDirSet.has(entry));
44
+ return {
45
+ ...env,
46
+ [pathKey]: [...binDirs, ...otherEntries].join(path.delimiter)
47
+ };
48
+ }
49
+
50
+ // src/utils/commands.ts
51
+ import fsExtra2 from "fs-extra";
15
52
  import { spawnSync } from "child_process";
16
53
  import { join } from "path";
17
54
  import { pathToFileURL } from "url";
18
55
  import resolvePackage from "resolve-pkg";
19
- var { existsSync } = fsExtra;
56
+ var { existsSync: existsSync2 } = fsExtra2;
20
57
  async function getPreferredPackageManager() {
21
58
  let agent = "yarn";
22
59
  const binNA = join(
23
60
  await getPackageRootDir("@antfu/ni"),
24
61
  (await getDepPackageJSON("@antfu/ni"))?.bin?.["na"] ?? ""
25
62
  );
26
- if (!binNA || fsExtra.existsSync(binNA) == false) return agent;
63
+ if (!binNA || fsExtra2.existsSync(binNA) == false) return agent;
27
64
  agent = spawnSync("node", [binNA, "?"], { encoding: "utf-8" })?.stdout.trim();
28
65
  return agent;
29
66
  }
@@ -43,7 +80,7 @@ async function loadPackageJsonAt(at) {
43
80
  const file = "package.json", location = at?.endsWith(file) && at || at && join(at, file) || false;
44
81
  if (location === false)
45
82
  throw new Error(`Invalid searching of ${file} at ${at}`);
46
- if (!existsSync(location)) return;
83
+ if (!existsSync2(location)) return;
47
84
  const content = await import(pathToFileURL(location).href, {
48
85
  with: { type: "json" }
49
86
  });
@@ -54,7 +91,7 @@ async function getDepPackageJSON(pkg) {
54
91
  }
55
92
 
56
93
  // src/utils/deprecations.ts
57
- import { existsSync as existsSync2 } from "fs";
94
+ import { existsSync as existsSync3 } from "fs";
58
95
  import chalk from "chalk";
59
96
 
60
97
  // src/utils/logger.ts
@@ -75,8 +112,8 @@ var logger = new Proxy(console, {
75
112
  function checkDeprecatedSecretFiles(basePath) {
76
113
  const secretsFilePath = `${basePath}/secrets.hidden.json`;
77
114
  const vtexEnvFilePath = `${basePath}/vtex.env`;
78
- const secretsFileExists = existsSync2(secretsFilePath);
79
- const vtexEnvFileExists = existsSync2(vtexEnvFilePath);
115
+ const secretsFileExists = existsSync3(secretsFilePath);
116
+ const vtexEnvFileExists = existsSync3(vtexEnvFilePath);
80
117
  if (secretsFileExists || vtexEnvFileExists) {
81
118
  const filesFound = [
82
119
  secretsFileExists ? "secrets.hidden.json" : null,
@@ -92,41 +129,41 @@ For production environments, please configure your secrets directly in the FastS
92
129
  }
93
130
 
94
131
  // src/utils/directory.ts
95
- import path from "path";
132
+ import path2 from "path";
96
133
  import { fileURLToPath } from "url";
97
134
  var getBasePath = (basePath) => {
98
135
  if (basePath) {
99
- return path.resolve(basePath);
136
+ return path2.resolve(basePath);
100
137
  }
101
138
  return process.cwd();
102
139
  };
103
140
  var withBasePath = (basepath) => {
104
141
  const tmpFolderName = ".faststore";
105
142
  const getRoot = () => basepath;
106
- const getCorePackagePath = () => path.dirname(
143
+ const getCorePackagePath = () => path2.dirname(
107
144
  fileURLToPath(import.meta.resolve("@faststore/core", import.meta.url))
108
145
  );
109
146
  const customizationsDir = getRoot();
110
- const tmpDir = path.join(getRoot(), tmpFolderName);
111
- const userSrcDir = path.join(customizationsDir, "src");
112
- const getPackagePath = (...packagePath) => path.join(customizationsDir, "node_modules", ...packagePath);
147
+ const tmpDir = path2.join(getRoot(), tmpFolderName);
148
+ const userSrcDir = path2.join(customizationsDir, "src");
149
+ const getPackagePath = (...packagePath) => path2.join(customizationsDir, "node_modules", ...packagePath);
113
150
  return {
114
151
  getRoot,
115
152
  getPackagePath,
116
153
  userDir: customizationsDir,
117
154
  userSrcDir,
118
- userThemesFileDir: path.join(userSrcDir, "themes"),
119
- userCMSDir: path.join(customizationsDir, "cms", "faststore"),
120
- userLegacyStoreConfigFile: path.join(
155
+ userThemesFileDir: path2.join(userSrcDir, "themes"),
156
+ userCMSDir: path2.join(customizationsDir, "cms", "faststore"),
157
+ userLegacyStoreConfigFile: path2.join(
121
158
  customizationsDir,
122
159
  "faststore.config.js"
123
160
  ),
124
- userStoreConfigFile: path.join(customizationsDir, "discovery.config.js"),
125
- tmpSeoConfig: path.join(tmpDir, "next-seo.config.ts"),
161
+ userStoreConfigFile: path2.join(customizationsDir, "discovery.config.js"),
162
+ tmpSeoConfig: path2.join(tmpDir, "next-seo.config.ts"),
126
163
  tmpFolderName,
127
164
  tmpDir,
128
- tmpCustomizationsSrcDir: path.join(tmpDir, "src", "customizations", "src"),
129
- tmpThemesCustomizationsFile: path.join(
165
+ tmpCustomizationsSrcDir: path2.join(tmpDir, "src", "customizations", "src"),
166
+ tmpThemesCustomizationsFile: path2.join(
130
167
  tmpDir,
131
168
  "src",
132
169
  "customizations",
@@ -134,25 +171,25 @@ var withBasePath = (basepath) => {
134
171
  "themes",
135
172
  "index.scss"
136
173
  ),
137
- tmpThemesPluginsFile: path.join(tmpDir, "src", "plugins", "index.scss"),
138
- tmpCMSDir: (projectName = "faststore") => path.join(tmpDir, "cms", projectName),
139
- tmpCMSWebhookUrlsFile: path.join(tmpDir, "cms-webhook-urls.json"),
140
- tmpPagesDir: path.join(tmpDir, "src", "pages"),
141
- tmpApiDir: path.join(tmpDir, "src", "pages", "api"),
142
- tmpPluginsDir: path.join(tmpDir, "src", "plugins"),
143
- tmpStoreConfigFile: path.join(
174
+ tmpThemesPluginsFile: path2.join(tmpDir, "src", "plugins", "index.scss"),
175
+ tmpCMSDir: (projectName = "faststore") => path2.join(tmpDir, "cms", projectName),
176
+ tmpCMSWebhookUrlsFile: path2.join(tmpDir, "cms-webhook-urls.json"),
177
+ tmpPagesDir: path2.join(tmpDir, "src", "pages"),
178
+ tmpApiDir: path2.join(tmpDir, "src", "pages", "api"),
179
+ tmpPluginsDir: path2.join(tmpDir, "src", "plugins"),
180
+ tmpStoreConfigFile: path2.join(
144
181
  tmpDir,
145
182
  "src",
146
183
  "customizations",
147
184
  "discovery.config.js"
148
185
  ),
149
186
  coreDir: getCorePackagePath(),
150
- coreCMSDir: path.join(getCorePackagePath(), "cms", "faststore")
187
+ coreCMSDir: path2.join(getCorePackagePath(), "cms", "faststore")
151
188
  };
152
189
  };
153
190
 
154
191
  // src/commands/build.ts
155
- var { copySync, moveSync, readdirSync, removeSync } = fsExtra2;
192
+ var { copySync, moveSync, readdirSync, removeSync } = fsExtra3;
156
193
  var Build = class _Build extends Command {
157
194
  static args = {
158
195
  account: Args.string({
@@ -183,7 +220,7 @@ var Build = class _Build extends Command {
183
220
  }
184
221
  const { tmpDir } = withBasePath(basePath);
185
222
  const packageManager = await getPreferredPackageManager();
186
- const binCli = path2.join(
223
+ const binCli = path3.join(
187
224
  fileURLToPath2(
188
225
  import.meta.resolve("@faststore/cli/runner", import.meta.url)
189
226
  )
@@ -209,7 +246,8 @@ var Build = class _Build extends Command {
209
246
  scriptResult = spawnSync2(`${packageManager} run build`, {
210
247
  shell: true,
211
248
  cwd: tmpDir,
212
- stdio: "inherit"
249
+ stdio: "inherit",
250
+ env: withNodeModulesBins(tmpDir)
213
251
  });
214
252
  if (scriptResult.status && scriptResult.status !== 0) {
215
253
  process.exit(scriptResult.status);
@@ -220,7 +258,7 @@ var Build = class _Build extends Command {
220
258
  };
221
259
  async function copyResource(from, to) {
222
260
  try {
223
- if (existsSync3(to)) {
261
+ if (existsSync4(to)) {
224
262
  removeSync(to);
225
263
  }
226
264
  copySync(from, to);
@@ -236,8 +274,8 @@ async function copyResource(from, to) {
236
274
  async function normalizeStandaloneBuildDir(basePath) {
237
275
  const { tmpDir } = withBasePath(basePath);
238
276
  const isRunningFromMonorepo = process.cwd() !== basePath;
239
- const prefix = isRunningFromMonorepo ? `${path2.relative(process.cwd(), basePath).replace(/\\/g, "/")}/` : "";
240
- if (existsSync3(`${tmpDir}/.next/standalone/${prefix}.faststore`)) {
277
+ const prefix = isRunningFromMonorepo ? `${path3.relative(process.cwd(), basePath).replace(/\\/g, "/")}/` : "";
278
+ if (existsSync4(`${tmpDir}/.next/standalone/${prefix}.faststore`)) {
241
279
  const standaloneBuildFiles = readdirSync(
242
280
  `${tmpDir}/.next/standalone/${prefix}.faststore`
243
281
  );
@@ -274,7 +312,7 @@ async function copyResources(basePath) {
274
312
  }
275
313
  async function checkDeps(basePath) {
276
314
  const packageJsonPath = `${basePath}/package.json`;
277
- if (!existsSync3(packageJsonPath)) {
315
+ if (!existsSync4(packageJsonPath)) {
278
316
  console.log(
279
317
  `${chalk2.yellow(
280
318
  "warning"
@@ -317,14 +355,14 @@ async function checkDeps(basePath) {
317
355
  import { Args as Args2, Command as Command2, Flags as Flags2 } from "@oclif/core";
318
356
  import chalk10 from "chalk";
319
357
  import { spawn } from "child_process";
320
- import { existsSync as existsSync9 } from "fs";
321
- import path9 from "path";
358
+ import { existsSync as existsSync10 } from "fs";
359
+ import path10 from "path";
322
360
  import { pathToFileURL as pathToFileURL7 } from "url";
323
361
 
324
362
  // src/utils/config.ts
325
363
  import chalk3 from "chalk";
326
- import { existsSync as existsSync4 } from "fs";
327
- import path3 from "path";
364
+ import { existsSync as existsSync5 } from "fs";
365
+ import path4 from "path";
328
366
  import { pathToFileURL as pathToFileURL3 } from "url";
329
367
  var configFileName = "discovery.config.js";
330
368
  function isMyAccountEnabled(config) {
@@ -349,11 +387,11 @@ function resolveContentSource(rawType) {
349
387
  async function getDiscoveryConfig(basePath) {
350
388
  const { tmpDir } = withBasePath(basePath);
351
389
  const configPaths = [
352
- path3.join(tmpDir, configFileName),
353
- path3.join(basePath, configFileName)
390
+ path4.join(tmpDir, configFileName),
391
+ path4.join(basePath, configFileName)
354
392
  ];
355
393
  for (const configPath of configPaths) {
356
- if (existsSync4(configPath)) {
394
+ if (existsSync5(configPath)) {
357
395
  try {
358
396
  const discoveryConfig = await import(pathToFileURL3(configPath).href);
359
397
  return discoveryConfig?.default ?? discoveryConfig;
@@ -403,8 +441,8 @@ async function checkAndValidateLocalization(basePath) {
403
441
 
404
442
  // src/utils/cp-schema.ts
405
443
  import chalk5 from "chalk";
406
- import { cpSync, existsSync as existsSync5, mkdirSync, mkdtempSync, rmSync } from "fs";
407
- import path4 from "path";
444
+ import { cpSync, existsSync as existsSync6, mkdirSync, mkdtempSync, rmSync } from "fs";
445
+ import path5 from "path";
408
446
 
409
447
  // src/utils/runCommandSync.ts
410
448
  import chalk4 from "chalk";
@@ -437,13 +475,15 @@ var runCommandSync = ({
437
475
  errorMessage,
438
476
  throws,
439
477
  cwd,
478
+ env,
440
479
  interactive = false
441
480
  }) => {
442
481
  try {
443
482
  logger.log(`[STARTED] ${cmd}`);
444
483
  const res = execSync(interactive ? cmd : `${cmd} 2>&1`, {
445
484
  stdio: interactive ? "inherit" : "pipe",
446
- cwd
485
+ cwd,
486
+ env
447
487
  });
448
488
  logger.log(`[STATUS] ${res?.toString() ?? "Unknown"}`);
449
489
  logger.log(`[FINISHED] ${cmd}`);
@@ -462,9 +502,9 @@ var runCommandSync = ({
462
502
  var MY_ACCOUNT_SUBDIRS = ["components", "pages"];
463
503
  function getExistingCpDirs(basePath) {
464
504
  const { userCMSDir } = withBasePath(basePath);
465
- const componentsDir = path4.join(userCMSDir, "components");
466
- const pagesDir = path4.join(userCMSDir, "pages");
467
- return [componentsDir, pagesDir].filter((dir) => existsSync5(dir)).map((dir) => path4.relative(basePath, dir));
505
+ const componentsDir = path5.join(userCMSDir, "components");
506
+ const pagesDir = path5.join(userCMSDir, "pages");
507
+ return [componentsDir, pagesDir].filter((dir) => existsSync6(dir)).map((dir) => path5.relative(basePath, dir));
468
508
  }
469
509
  function errorNoCustomization() {
470
510
  logger.error(
@@ -473,36 +513,36 @@ function errorNoCustomization() {
473
513
  process.exit(1);
474
514
  }
475
515
  function getCpSchemaOutputPath(basePath) {
476
- return path4.relative(
516
+ return path5.relative(
477
517
  basePath,
478
- path4.join(withBasePath(basePath).userCMSDir, "schema.json")
518
+ path5.join(withBasePath(basePath).userCMSDir, "schema.json")
479
519
  );
480
520
  }
481
521
  function prepareMyAccountMergeDir(basePath) {
482
522
  const { coreCMSDir, userCMSDir, tmpDir } = withBasePath(basePath);
483
- const coreMyAccountDir = path4.join(coreCMSDir, "my-account");
484
- if (!existsSync5(coreMyAccountDir)) {
523
+ const coreMyAccountDir = path5.join(coreCMSDir, "my-account");
524
+ if (!existsSync6(coreMyAccountDir)) {
485
525
  logger.error(
486
526
  `${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.`
487
527
  );
488
528
  process.exit(1);
489
529
  }
490
530
  mkdirSync(tmpDir, { recursive: true });
491
- const mergeDir = mkdtempSync(path4.join(tmpDir, "cms-myaccount-"));
531
+ const mergeDir = mkdtempSync(path5.join(tmpDir, "cms-myaccount-"));
492
532
  try {
493
533
  const dirs = [];
494
534
  for (const subdir of MY_ACCOUNT_SUBDIRS) {
495
- const dest = path4.join(mergeDir, subdir);
535
+ const dest = path5.join(mergeDir, subdir);
496
536
  mkdirSync(dest, { recursive: true });
497
- const coreSource = path4.join(coreMyAccountDir, subdir);
498
- if (existsSync5(coreSource)) {
537
+ const coreSource = path5.join(coreMyAccountDir, subdir);
538
+ if (existsSync6(coreSource)) {
499
539
  cpSync(coreSource, dest, { recursive: true });
500
540
  }
501
- const storeSource = path4.join(userCMSDir, subdir);
502
- if (existsSync5(storeSource)) {
541
+ const storeSource = path5.join(userCMSDir, subdir);
542
+ if (existsSync6(storeSource)) {
503
543
  cpSync(storeSource, dest, { recursive: true });
504
544
  }
505
- dirs.push(path4.relative(basePath, dest));
545
+ dirs.push(path5.relative(basePath, dest));
506
546
  }
507
547
  return { mergeDir, dirs };
508
548
  } catch (error) {
@@ -540,14 +580,14 @@ function generateAndUploadSchema({
540
580
 
541
581
  // src/utils/generate.ts
542
582
  import chalk7 from "chalk";
543
- import fsExtra4 from "fs-extra";
544
- import path7 from "path";
583
+ import fsExtra5 from "fs-extra";
584
+ import path8 from "path";
545
585
  import ora from "ora";
546
586
  import { pathToFileURL as pathToFileURL5 } from "url";
547
587
 
548
588
  // src/utils/createNextjsPages.ts
549
589
  import fs2 from "fs";
550
- import path5 from "path";
590
+ import path6 from "path";
551
591
  import chalk6 from "chalk";
552
592
 
553
593
  // src/utils/readMyAccountCmsRoutes.ts
@@ -712,8 +752,8 @@ var createExternalPages = ({
712
752
  cmsHandledRoutes
713
753
  }) => {
714
754
  fs2.readdirSync(customizationPagesDir).forEach((file) => {
715
- const filePath = path5.join(customizationPagesDir, file);
716
- const destinationPath = path5.join(corePagesDir, file);
755
+ const filePath = path6.join(customizationPagesDir, file);
756
+ const destinationPath = path6.join(corePagesDir, file);
717
757
  if (fs2.statSync(filePath).isDirectory()) {
718
758
  if (!fs2.existsSync(destinationPath)) {
719
759
  fs2.mkdirSync(destinationPath, { recursive: true });
@@ -727,7 +767,7 @@ var createExternalPages = ({
727
767
  }
728
768
  const isReactFile = filePath.endsWith(".tsx");
729
769
  const isDestinationAvailable = !fs2.existsSync(destinationPath) && !fs2.existsSync(
730
- path5.join(destinationPath.replace(".tsx", ""), "index.tsx")
770
+ path6.join(destinationPath.replace(".tsx", ""), "index.tsx")
731
771
  );
732
772
  if (isReactFile && isDestinationAvailable) {
733
773
  const relativePagePath = filePath.replace(baseCustomizationPagesDir, "").replaceAll(/\\/g, "/").replace(/\.tsx$/, "");
@@ -753,14 +793,14 @@ function normalizeAccountRoute(routeOrRelativePath) {
753
793
  }
754
794
  function routeToPageFilePath(corePagesDir, route) {
755
795
  const relative = route.replace(/^\//, "");
756
- return path5.join(corePagesDir, `${relative}.tsx`);
796
+ return path6.join(corePagesDir, `${relative}.tsx`);
757
797
  }
758
798
  function routeToCustomizationPagePath(customizationPagesDir, route) {
759
799
  const relative = route.replace(/^\//, "");
760
800
  if (!relative) return null;
761
- const asFile = path5.join(customizationPagesDir, `${relative}.tsx`);
801
+ const asFile = path6.join(customizationPagesDir, `${relative}.tsx`);
762
802
  if (fs2.existsSync(asFile)) return asFile;
763
- const asIndex = path5.join(customizationPagesDir, relative, "index.tsx");
803
+ const asIndex = path6.join(customizationPagesDir, relative, "index.tsx");
764
804
  if (fs2.existsSync(asIndex)) return asIndex;
765
805
  return null;
766
806
  }
@@ -770,13 +810,13 @@ function routeToExtensionImportBase(route) {
770
810
  function resolveExtensionPaths(tmpDir, route) {
771
811
  const relative = routeToExtensionImportBase(route);
772
812
  if (!relative) return {};
773
- const extensionsDir = path5.join(
813
+ const extensionsDir = path6.join(
774
814
  tmpDir,
775
815
  "src/customizations/src/myAccount/extensions",
776
816
  relative
777
817
  );
778
- const beforeFile = path5.join(extensionsDir, "before.tsx");
779
- const afterFile = path5.join(extensionsDir, "after.tsx");
818
+ const beforeFile = path6.join(extensionsDir, "before.tsx");
819
+ const afterFile = path6.join(extensionsDir, "after.tsx");
780
820
  const importBase = `src/customizations/src/myAccount/extensions/${relative}`;
781
821
  return {
782
822
  ...fs2.existsSync(beforeFile) ? { beforePath: `${importBase}/before` } : {},
@@ -785,7 +825,7 @@ function resolveExtensionPaths(tmpDir, route) {
785
825
  }
786
826
  function destinationExists(destinationPath) {
787
827
  if (fs2.existsSync(destinationPath)) return true;
788
- const asIndex = path5.join(destinationPath.replace(/\.tsx$/, ""), "index.tsx");
828
+ const asIndex = path6.join(destinationPath.replace(/\.tsx$/, ""), "index.tsx");
789
829
  return fs2.existsSync(asIndex);
790
830
  }
791
831
  function generateCmsPages({
@@ -823,7 +863,7 @@ function generateCmsPages({
823
863
  beforePath,
824
864
  afterPath
825
865
  });
826
- fs2.mkdirSync(path5.dirname(destinationPath), { recursive: true });
866
+ fs2.mkdirSync(path6.dirname(destinationPath), { recursive: true });
827
867
  fs2.writeFileSync(destinationPath, content);
828
868
  handled.add(normalizedRoute);
829
869
  logger.log(
@@ -834,12 +874,12 @@ function generateCmsPages({
834
874
  }
835
875
  function createNextJsPages(basePath) {
836
876
  const { tmpDir } = withBasePath(basePath);
837
- const corePagesDir = path5.join(tmpDir, "src/pages");
838
- const customizationPagesDir = path5.join(
877
+ const corePagesDir = path6.join(tmpDir, "src/pages");
878
+ const customizationPagesDir = path6.join(
839
879
  tmpDir,
840
880
  "src/customizations/src/pages"
841
881
  );
842
- const navigationFilePath = path5.join(
882
+ const navigationFilePath = path6.join(
843
883
  tmpDir,
844
884
  "src/customizations/src/myAccount/navigation.ts"
845
885
  );
@@ -860,7 +900,7 @@ function createNextJsPages(basePath) {
860
900
  const items = fs2.readdirSync(dirPath, { withFileTypes: true });
861
901
  if (items.length === 0) return true;
862
902
  return items.every((item) => {
863
- const itemPath = path5.join(dirPath, item.name);
903
+ const itemPath = path6.join(dirPath, item.name);
864
904
  if (item.isDirectory()) {
865
905
  return allPagesAreAllowed({ basePath: pagesBase, dirPath: itemPath });
866
906
  }
@@ -871,7 +911,7 @@ function createNextJsPages(basePath) {
871
911
  if (!isNextPage) {
872
912
  return false;
873
913
  }
874
- const relativePath = path5.relative(pagesBase, itemPath);
914
+ const relativePath = path6.relative(pagesBase, itemPath);
875
915
  const normalizedPath = "/" + relativePath.replace(/\\/g, "/").replace(/\.(js|jsx|ts|tsx)$/, "");
876
916
  return isAllowedPrefixPage(normalizedPath);
877
917
  });
@@ -910,10 +950,10 @@ async function installDependencies({
910
950
  }
911
951
 
912
952
  // src/utils/plugins.ts
913
- import fsExtra3 from "fs-extra";
914
- import path6 from "path";
953
+ import fsExtra4 from "fs-extra";
954
+ import path7 from "path";
915
955
  import { pathToFileURL as pathToFileURL4 } from "url";
916
- var { copySync: copySync2, existsSync: existsSync6, mkdirSync: mkdirSync2, readdirSync: readdirSync2, writeFileSync } = fsExtra3;
956
+ var { copySync: copySync2, existsSync: existsSync7, mkdirSync: mkdirSync2, readdirSync: readdirSync2, writeFileSync } = fsExtra4;
917
957
  var PLUGIN_CONFIG_FILE = "plugin.config.js";
918
958
  var sanitizePluginName = (pluginName, pascalCase = false) => {
919
959
  const sanitized = pluginName.split("/")[1];
@@ -959,7 +999,7 @@ var copyPluginsSrc = async (basePath, plugins) => {
959
999
  basePath,
960
1000
  getPluginName(pluginName)
961
1001
  );
962
- const pluginDestPath = path6.join(
1002
+ const pluginDestPath = path7.join(
963
1003
  tmpPluginsDir,
964
1004
  sanitizePluginName(pluginName)
965
1005
  );
@@ -974,7 +1014,7 @@ var copyPluginPublicFiles = async (basePath, plugins) => {
974
1014
  const pluginName = getPluginName(plugin);
975
1015
  const pluginPath = getPackagePath(getPluginName(pluginName));
976
1016
  try {
977
- if (existsSync6(`${pluginPath}/public`)) {
1017
+ if (existsSync7(`${pluginPath}/public`)) {
978
1018
  copySync2(`${pluginPath}/public`, `${tmpDir}/public`, {
979
1019
  dereference: true,
980
1020
  overwrite: true
@@ -1031,13 +1071,13 @@ var generatePluginPages = async (basePath, plugins) => {
1031
1071
  const paths = pagesConfig[pageName].path.split("/");
1032
1072
  const pageFile = paths.pop();
1033
1073
  const pagePaths = paths;
1034
- const pagePath = path6.join(tmpPagesDir, ...pagePaths, pageFile + ".tsx");
1074
+ const pagePath = path7.join(tmpPagesDir, ...pagePaths, pageFile + ".tsx");
1035
1075
  const fileContent = getPluginPageFileContent(
1036
1076
  sanitizePluginName(pluginName),
1037
1077
  pageName,
1038
1078
  pagesConfig[pageName].appLayout
1039
1079
  );
1040
- mkdirSync2(path6.dirname(pagePath), { recursive: true });
1080
+ mkdirSync2(path7.dirname(pagePath), { recursive: true });
1041
1081
  writeFileSync(pagePath, fileContent);
1042
1082
  });
1043
1083
  });
@@ -1046,7 +1086,7 @@ async function addPluginsSections(basePath, plugins) {
1046
1086
  const { tmpPluginsDir, getPackagePath } = withBasePath(basePath);
1047
1087
  logger.log("Adding plugin sections");
1048
1088
  const indexPluginsOverrides = plugins.filter(
1049
- (plugin) => existsSync6(
1089
+ (plugin) => existsSync7(
1050
1090
  getPackagePath(getPluginName(plugin), "src", "components", "index.ts")
1051
1091
  )
1052
1092
  ).map((plugin) => {
@@ -1063,7 +1103,7 @@ async function addPluginsSections(basePath, plugins) {
1063
1103
  ${indexPluginsOverrides.map((plugin) => `...${plugin.pluginReference}`).join(",\n")}
1064
1104
  }
1065
1105
  `;
1066
- const sectionPath = path6.join(tmpPluginsDir, "index.ts");
1106
+ const sectionPath = path7.join(tmpPluginsDir, "index.ts");
1067
1107
  writeFileSync(sectionPath, pluginsImportFileContent);
1068
1108
  logger.log("Writing plugins overrides");
1069
1109
  logger.log(sectionPath);
@@ -1080,14 +1120,14 @@ async function addPluginsOverrides(basePath, plugins) {
1080
1120
  "components",
1081
1121
  "overrides"
1082
1122
  )
1083
- })).filter(({ pluginOverridesPath }) => existsSync6(pluginOverridesPath)).reverse().forEach(({ pluginName, pluginOverridesPath }) => {
1123
+ })).filter(({ pluginOverridesPath }) => existsSync7(pluginOverridesPath)).reverse().forEach(({ pluginName, pluginOverridesPath }) => {
1084
1124
  const overrideFilesAlreadyCopied = [];
1085
1125
  const sanitizedPluginName = sanitizePluginName(pluginName);
1086
1126
  const overrideFiles = readdirSync2(pluginOverridesPath);
1087
1127
  overrideFiles.filter((file) => !overrideFilesAlreadyCopied.includes(file)).forEach((overrideFileName) => {
1088
1128
  const overrideFileContent = `export { override } from 'src/plugins/${sanitizedPluginName}/components/overrides/${overrideFileName.split(".")[0]}'`;
1089
1129
  writeFileSync(
1090
- path6.join(tmpPluginsDir, "overrides", overrideFileName),
1130
+ path7.join(tmpPluginsDir, "overrides", overrideFileName),
1091
1131
  overrideFileContent
1092
1132
  );
1093
1133
  overrideFilesAlreadyCopied.push(overrideFileName);
@@ -1097,7 +1137,7 @@ async function addPluginsOverrides(basePath, plugins) {
1097
1137
  var addPluginsTheme = async (basePath, plugins) => {
1098
1138
  const { getPackagePath, tmpThemesPluginsFile } = withBasePath(basePath);
1099
1139
  const pluginImportsContent = plugins.filter(
1100
- (plugin) => existsSync6(
1140
+ (plugin) => existsSync7(
1101
1141
  getPackagePath(getPluginName(plugin), "src", "themes", "index.scss")
1102
1142
  )
1103
1143
  ).map(
@@ -1132,7 +1172,7 @@ var generatePluginApis = async (basePath, plugins) => {
1132
1172
  const paths = apisConfig[apiName].path.split("/");
1133
1173
  const apiFile = paths.pop();
1134
1174
  const apiPaths = paths;
1135
- const apiPath = path6.join(
1175
+ const apiPath = path7.join(
1136
1176
  tmpApiDir,
1137
1177
  "plugins",
1138
1178
  ...apiPaths,
@@ -1142,7 +1182,7 @@ var generatePluginApis = async (basePath, plugins) => {
1142
1182
  sanitizePluginName(pluginName),
1143
1183
  apiName
1144
1184
  );
1145
- mkdirSync2(path6.dirname(apiPath), { recursive: true });
1185
+ mkdirSync2(path7.dirname(apiPath), { recursive: true });
1146
1186
  writeFileSync(apiPath, fileContent);
1147
1187
  });
1148
1188
  });
@@ -1162,7 +1202,7 @@ var installPlugins = async (basePath) => {
1162
1202
  var {
1163
1203
  copyFileSync,
1164
1204
  copySync: copySync3,
1165
- existsSync: existsSync7,
1205
+ existsSync: existsSync8,
1166
1206
  mkdirsSync,
1167
1207
  readFileSync,
1168
1208
  readdirSync: readdirSync3,
@@ -1170,7 +1210,7 @@ var {
1170
1210
  statSync,
1171
1211
  writeFileSync: writeFileSync2,
1172
1212
  writeJsonSync
1173
- } = fsExtra4;
1213
+ } = fsExtra5;
1174
1214
  var ignorePaths = [
1175
1215
  "package.json",
1176
1216
  "node_modules",
@@ -1181,7 +1221,7 @@ var ignorePaths = [
1181
1221
  function createTmpFolder(basePath) {
1182
1222
  const { tmpDir, tmpFolderName } = withBasePath(basePath);
1183
1223
  try {
1184
- if (existsSync7(tmpDir)) {
1224
+ if (existsSync8(tmpDir)) {
1185
1225
  removeSync2(tmpDir);
1186
1226
  }
1187
1227
  mkdirsSync(tmpDir);
@@ -1219,8 +1259,8 @@ function buildFaststorePackageJson(coreManifest, voltaConfig) {
1219
1259
  }
1220
1260
  function readRootVoltaConfig(rootDir) {
1221
1261
  try {
1222
- const rootManifestPath = path7.join(rootDir, "package.json");
1223
- if (!existsSync7(rootManifestPath)) {
1262
+ const rootManifestPath = path8.join(rootDir, "package.json");
1263
+ if (!existsSync8(rootManifestPath)) {
1224
1264
  return void 0;
1225
1265
  }
1226
1266
  const rootManifest = JSON.parse(readFileSync(rootManifestPath, "utf8"));
@@ -1232,27 +1272,27 @@ function readRootVoltaConfig(rootDir) {
1232
1272
  function filterAndCopyPackageJson(basePath) {
1233
1273
  const { coreDir, tmpDir, getRoot } = withBasePath(basePath);
1234
1274
  const coreManifest = JSON.parse(
1235
- readFileSync(path7.join(coreDir, "package.json"), "utf8")
1275
+ readFileSync(path8.join(coreDir, "package.json"), "utf8")
1236
1276
  );
1237
1277
  const voltaConfig = readRootVoltaConfig(getRoot());
1238
1278
  const filteredFileContent = buildFaststorePackageJson(
1239
1279
  coreManifest,
1240
1280
  voltaConfig
1241
1281
  );
1242
- writeJsonSync(path7.join(tmpDir, "package.json"), filteredFileContent, {
1282
+ writeJsonSync(path8.join(tmpDir, "package.json"), filteredFileContent, {
1243
1283
  spaces: 2
1244
1284
  });
1245
1285
  }
1246
1286
  var TS_CONFIG_STRICT_RULES_ENABLED = ["noImplicitAny"];
1247
1287
  function disableTsConfigStrictRules(basePath) {
1248
1288
  const { coreDir, tmpDir } = withBasePath(basePath);
1249
- const coreTsConfigPath = path7.join(coreDir, "tsconfig.json");
1289
+ const coreTsConfigPath = path8.join(coreDir, "tsconfig.json");
1250
1290
  const coreTsConfigFile = readFileSync(coreTsConfigPath, "utf8");
1251
1291
  const tsConfig = JSON.parse(coreTsConfigFile);
1252
1292
  TS_CONFIG_STRICT_RULES_ENABLED.forEach((strictRule) => {
1253
1293
  tsConfig.compilerOptions[strictRule] = false;
1254
1294
  });
1255
- writeJsonSync(path7.join(tmpDir, "tsconfig.json"), tsConfig, {
1295
+ writeJsonSync(path8.join(tmpDir, "tsconfig.json"), tsConfig, {
1256
1296
  spaces: 2
1257
1297
  });
1258
1298
  }
@@ -1262,7 +1302,7 @@ function copyCoreFiles(basePath) {
1262
1302
  copySync3(coreDir, tmpDir, {
1263
1303
  dereference: true,
1264
1304
  filter(src) {
1265
- const fileOrDirName = path7.basename(src);
1305
+ const fileOrDirName = path8.basename(src);
1266
1306
  const shouldCopy = fileOrDirName ? !ignorePaths.includes(fileOrDirName) : true;
1267
1307
  return shouldCopy;
1268
1308
  }
@@ -1291,13 +1331,13 @@ function isPublicFileAllowed(src, isDirectory) {
1291
1331
  return true;
1292
1332
  }
1293
1333
  return PUBLIC_FILES_ALLOWED_EXTENSIONS.includes(
1294
- path7.extname(src).toLowerCase()
1334
+ path8.extname(src).toLowerCase()
1295
1335
  );
1296
1336
  }
1297
1337
  function copyPublicFiles(basePath) {
1298
1338
  const { userDir, tmpDir } = withBasePath(basePath);
1299
1339
  try {
1300
- if (existsSync7(`${userDir}/public`)) {
1340
+ if (existsSync8(`${userDir}/public`)) {
1301
1341
  copySync3(`${userDir}/public`, `${tmpDir}/public`, {
1302
1342
  dereference: true,
1303
1343
  overwrite: true,
@@ -1318,21 +1358,21 @@ function copyPublicFiles(basePath) {
1318
1358
  async function copyCypressFiles(basePath) {
1319
1359
  const { userDir, userStoreConfigFile, userLegacyStoreConfigFile, tmpDir } = withBasePath(basePath);
1320
1360
  try {
1321
- if (existsSync7(`${userDir}/cypress.json`)) {
1361
+ if (existsSync8(`${userDir}/cypress.json`)) {
1322
1362
  copySync3(`${userDir}/cypress.json`, `${tmpDir}/cypress.json`, {
1323
1363
  dereference: true
1324
1364
  });
1325
1365
  }
1326
- if (existsSync7(`${userDir}/cypress.config.ts`)) {
1366
+ if (existsSync8(`${userDir}/cypress.config.ts`)) {
1327
1367
  copySync3(`${userDir}/cypress.config.ts`, `${tmpDir}/cypress.config.ts`, {
1328
1368
  dereference: true
1329
1369
  });
1330
1370
  }
1331
1371
  let userStoreConfig;
1332
- if (existsSync7(userStoreConfigFile)) {
1333
- userStoreConfig = (await import(pathToFileURL5(path7.resolve(userStoreConfigFile)).href))?.default;
1334
- } else if (existsSync7(userLegacyStoreConfigFile)) {
1335
- userStoreConfig = (await import(pathToFileURL5(path7.resolve(userLegacyStoreConfigFile)).href))?.default;
1372
+ if (existsSync8(userStoreConfigFile)) {
1373
+ userStoreConfig = (await import(pathToFileURL5(path8.resolve(userStoreConfigFile)).href))?.default;
1374
+ } else if (existsSync8(userLegacyStoreConfigFile)) {
1375
+ userStoreConfig = (await import(pathToFileURL5(path8.resolve(userLegacyStoreConfigFile)).href))?.default;
1336
1376
  } else {
1337
1377
  logger.info(
1338
1378
  `${chalk7.blue(
@@ -1340,7 +1380,7 @@ async function copyCypressFiles(basePath) {
1340
1380
  )} - No store config file was found in the root directory`
1341
1381
  );
1342
1382
  }
1343
- if (existsSync7(`${userDir}/cypress`) && userStoreConfig?.experimental?.enableCypressExtension) {
1383
+ if (existsSync8(`${userDir}/cypress`) && userStoreConfig?.experimental?.enableCypressExtension) {
1344
1384
  copySync3(`${userDir}/cypress`, `${tmpDir}/cypress`, {
1345
1385
  overwrite: true,
1346
1386
  dereference: true
@@ -1367,16 +1407,16 @@ function copyUserStarterToCustomizations(basePath) {
1367
1407
  tmpStoreConfigFile
1368
1408
  } = withBasePath(basePath);
1369
1409
  try {
1370
- if (existsSync7(userSrcDir) && readdirSync3(userSrcDir).length > 0) {
1410
+ if (existsSync8(userSrcDir) && readdirSync3(userSrcDir).length > 0) {
1371
1411
  copySync3(userSrcDir, tmpCustomizationsSrcDir, { dereference: true });
1372
1412
  createNextJsPages(basePath);
1373
1413
  }
1374
1414
  } catch (err) {
1375
1415
  logger.error(`${chalk7.red("error")} - ${err}`);
1376
1416
  }
1377
- if (existsSync7(userStoreConfigFile)) {
1417
+ if (existsSync8(userStoreConfigFile)) {
1378
1418
  copySync3(userStoreConfigFile, tmpStoreConfigFile, { dereference: true });
1379
- } else if (existsSync7(userLegacyStoreConfigFile)) {
1419
+ } else if (existsSync8(userLegacyStoreConfigFile)) {
1380
1420
  copySync3(userLegacyStoreConfigFile, tmpStoreConfigFile, {
1381
1421
  dereference: true
1382
1422
  });
@@ -1396,10 +1436,10 @@ async function createCmsWebhookUrlsJsonFile(basePath) {
1396
1436
  tmpCMSWebhookUrlsFile
1397
1437
  } = withBasePath(basePath);
1398
1438
  let userStoreConfig;
1399
- if (existsSync7(userStoreConfigFile)) {
1400
- userStoreConfig = (await import(pathToFileURL5(path7.resolve(userStoreConfigFile)).href))?.default;
1401
- } else if (existsSync7(userLegacyStoreConfigFile)) {
1402
- userStoreConfig = (await import(pathToFileURL5(path7.resolve(userLegacyStoreConfigFile)).href))?.default;
1439
+ if (existsSync8(userStoreConfigFile)) {
1440
+ userStoreConfig = (await import(pathToFileURL5(path8.resolve(userStoreConfigFile)).href))?.default;
1441
+ } else if (existsSync8(userLegacyStoreConfigFile)) {
1442
+ userStoreConfig = (await import(pathToFileURL5(path8.resolve(userLegacyStoreConfigFile)).href))?.default;
1403
1443
  } else {
1404
1444
  logger.info(
1405
1445
  `${chalk7.blue(
@@ -1426,8 +1466,8 @@ async function copyTheme(basePath) {
1426
1466
  tmpThemesCustomizationsFile,
1427
1467
  userLegacyStoreConfigFile
1428
1468
  } = withBasePath(basePath);
1429
- const storeConfigFile = existsSync7(userStoreConfigFile) && userStoreConfigFile || existsSync7(userLegacyStoreConfigFile) && userLegacyStoreConfigFile;
1430
- const userStoreConfigFilePath = storeConfigFile && path7.resolve(storeConfigFile);
1469
+ const storeConfigFile = existsSync8(userStoreConfigFile) && userStoreConfigFile || existsSync8(userLegacyStoreConfigFile) && userLegacyStoreConfigFile;
1470
+ const userStoreConfigFilePath = storeConfigFile && path8.resolve(storeConfigFile);
1431
1471
  const importedStoreConfig = userStoreConfigFilePath && await import(pathToFileURL5(userStoreConfigFilePath).href);
1432
1472
  const storeConfig = userStoreConfigFilePath && (importedStoreConfig?.default || importedStoreConfig);
1433
1473
  if (!storeConfig)
@@ -1437,11 +1477,11 @@ async function copyTheme(basePath) {
1437
1477
  )} - No store config file was found in the root directory`
1438
1478
  );
1439
1479
  if (storeConfig.theme) {
1440
- const customTheme = path7.join(
1480
+ const customTheme = path8.join(
1441
1481
  userThemesFileDir,
1442
1482
  `${storeConfig.theme}.scss`
1443
1483
  );
1444
- if (existsSync7(customTheme)) {
1484
+ if (existsSync8(customTheme)) {
1445
1485
  try {
1446
1486
  copyFileSync(customTheme, tmpThemesCustomizationsFile);
1447
1487
  logger.log(
@@ -1455,7 +1495,7 @@ async function copyTheme(basePath) {
1455
1495
  `${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`
1456
1496
  );
1457
1497
  }
1458
- } else if (existsSync7(userThemesFileDir) && readdirSync3(userThemesFileDir).length > 0) {
1498
+ } else if (existsSync8(userThemesFileDir) && readdirSync3(userThemesFileDir).length > 0) {
1459
1499
  logger.info(
1460
1500
  `${chalk7.blue(
1461
1501
  "info"
@@ -1480,8 +1520,8 @@ function updateBuildTime(basePath) {
1480
1520
  }
1481
1521
  async function checkDependencies(basePath, packagesToCheck) {
1482
1522
  const { coreDir, getRoot } = withBasePath(basePath);
1483
- const corePackageJsonPath = path7.join(coreDir, "package.json");
1484
- const rootPackageJsonPath = path7.join(getRoot(), "package.json");
1523
+ const corePackageJsonPath = path8.join(coreDir, "package.json");
1524
+ const rootPackageJsonPath = path8.join(getRoot(), "package.json");
1485
1525
  const { default: corePackageJson } = await import(pathToFileURL5(corePackageJsonPath).href, {
1486
1526
  with: { type: "json" }
1487
1527
  });
@@ -1509,7 +1549,7 @@ async function checkDependencies(basePath, packagesToCheck) {
1509
1549
  }
1510
1550
  function updateNextConfig(basePath) {
1511
1551
  const { tmpDir } = withBasePath(basePath);
1512
- const nextConfigPath = path7.join(tmpDir, "next.config.js");
1552
+ const nextConfigPath = path8.join(tmpDir, "next.config.js");
1513
1553
  let nextConfigData = String(readFileSync(nextConfigPath));
1514
1554
  nextConfigData = nextConfigData.replace(
1515
1555
  /outputFileTracingRoot\:\s+(.*),/,
@@ -1519,10 +1559,10 @@ function updateNextConfig(basePath) {
1519
1559
  }
1520
1560
  function getCurrentUserStoreConfigFile(basePath) {
1521
1561
  const { userStoreConfigFile, userLegacyStoreConfigFile } = withBasePath(basePath);
1522
- if (existsSync7(userStoreConfigFile)) {
1562
+ if (existsSync8(userStoreConfigFile)) {
1523
1563
  return userStoreConfigFile;
1524
1564
  }
1525
- if (existsSync7(userLegacyStoreConfigFile)) {
1565
+ if (existsSync8(userLegacyStoreConfigFile)) {
1526
1566
  return userLegacyStoreConfigFile;
1527
1567
  }
1528
1568
  return null;
@@ -1534,7 +1574,7 @@ async function validateAndInstallMissingDependencies(basePath) {
1534
1574
  return;
1535
1575
  }
1536
1576
  const { default: userStoreConfig } = await import(pathToFileURL5(currentUserStoreConfigFile).href);
1537
- const { default: userPackageJson } = await import(pathToFileURL5(path7.join(userDir, "package.json")).href, {
1577
+ const { default: userPackageJson } = await import(pathToFileURL5(path8.join(userDir, "package.json")).href, {
1538
1578
  with: { type: "json" }
1539
1579
  });
1540
1580
  const missingDependencies = [];
@@ -1573,7 +1613,7 @@ async function enableSearchSSR(basePath) {
1573
1613
  return;
1574
1614
  }
1575
1615
  const { tmpDir } = withBasePath(basePath);
1576
- const searchPagePath = path7.join(tmpDir, "src", "pages", "s.tsx");
1616
+ const searchPagePath = path8.join(tmpDir, "src", "pages", "s.tsx");
1577
1617
  const searchPageData = String(readFileSync(searchPagePath));
1578
1618
  const searchPageWithSSR = searchPageData.replaceAll(
1579
1619
  "getStaticProps",
@@ -1608,11 +1648,11 @@ async function generate(options) {
1608
1648
 
1609
1649
  // src/utils/hcms.ts
1610
1650
  import chalk8 from "chalk";
1611
- import path8 from "path";
1651
+ import path9 from "path";
1612
1652
  import { confirm } from "@inquirer/prompts";
1613
- import fsExtra5 from "fs-extra";
1653
+ import fsExtra6 from "fs-extra";
1614
1654
  import { pathToFileURL as pathToFileURL6 } from "url";
1615
- var { readFileSync: readFileSync2, existsSync: existsSync8, writeFileSync: writeFileSync3, mkdirSync: mkdirSync3 } = fsExtra5;
1655
+ var { readFileSync: readFileSync2, existsSync: existsSync9, writeFileSync: writeFileSync3, mkdirSync: mkdirSync3 } = fsExtra6;
1616
1656
  function splitCustomDefinitions(coreDefinitions, customDefinitions, primaryIdentifier) {
1617
1657
  const coreDefinitionIdentifiers = new Set(
1618
1658
  coreDefinitions.map((definition) => definition[primaryIdentifier] ?? "")
@@ -1676,10 +1716,10 @@ async function mergeCMSFile(fileName, basePath) {
1676
1716
  getPackagePath,
1677
1717
  userStoreConfigFile
1678
1718
  } = withBasePath(basePath);
1679
- const { default: userStoreConfig } = await import(pathToFileURL6(path8.resolve(userStoreConfigFile)).href);
1719
+ const { default: userStoreConfig } = await import(pathToFileURL6(path9.resolve(userStoreConfigFile)).href);
1680
1720
  const cmsProjectName = userStoreConfig.contentSource?.project ?? "faststore";
1681
- const coreFilePath = path8.join(coreCMSDir, fileName);
1682
- const customFilePath = path8.join(userCMSDir, fileName);
1721
+ const coreFilePath = path9.join(coreCMSDir, fileName);
1722
+ const customFilePath = path9.join(userCMSDir, fileName);
1683
1723
  const coreFile = readFileSync2(coreFilePath, "utf8");
1684
1724
  const coreDefinitions = JSON.parse(coreFile);
1685
1725
  const primaryIdentifierForDefinitions = fileName === "content-types.json" ? "id" : "name";
@@ -1689,7 +1729,7 @@ async function mergeCMSFile(fileName, basePath) {
1689
1729
  (plugin) => getPackagePath(getPluginName(plugin), "cms", "faststore", fileName)
1690
1730
  );
1691
1731
  const customizations = [...pluginCMSFilePaths, customFilePath].filter(
1692
- (pluginCMSFilePath) => existsSync8(pluginCMSFilePath)
1732
+ (pluginCMSFilePath) => existsSync9(pluginCMSFilePath)
1693
1733
  );
1694
1734
  for (const newFilePath of customizations) {
1695
1735
  const customFile = readFileSync2(newFilePath, "utf8");
@@ -1728,11 +1768,11 @@ async function mergeCMSFile(fileName, basePath) {
1728
1768
  }
1729
1769
  }
1730
1770
  try {
1731
- if (!existsSync8(tmpCMSDir(cmsProjectName))) {
1771
+ if (!existsSync9(tmpCMSDir(cmsProjectName))) {
1732
1772
  mkdirSync3(tmpCMSDir(cmsProjectName));
1733
1773
  }
1734
1774
  writeFileSync3(
1735
- path8.join(tmpCMSDir(cmsProjectName), fileName),
1775
+ path9.join(tmpCMSDir(cmsProjectName), fileName),
1736
1776
  JSON.stringify(output)
1737
1777
  );
1738
1778
  console.log(
@@ -1838,7 +1878,7 @@ var CmsSync = class _CmsSync extends Command2 {
1838
1878
  const { flags, args } = await this.parse(_CmsSync);
1839
1879
  const basePath = getBasePath(args.path);
1840
1880
  const { userStoreConfigFile } = withBasePath(basePath);
1841
- const storeConfig = existsSync9(userStoreConfigFile) ? (await import(pathToFileURL7(path9.resolve(userStoreConfigFile)).href)).default : null;
1881
+ const storeConfig = existsSync10(userStoreConfigFile) ? (await import(pathToFileURL7(path10.resolve(userStoreConfigFile)).href)).default : null;
1842
1882
  const source = resolveContentSource(storeConfig?.contentSource?.type);
1843
1883
  logger.info(
1844
1884
  `${chalk10.blue("[Info]")} - Detected contentSource "${source}" \u2014 ${CONTENT_SOURCE_ACTION[source]}`
@@ -1962,8 +2002,8 @@ import chalk11 from "chalk";
1962
2002
  import { spawn as spawn2, spawnSync as spawnSync3 } from "child_process";
1963
2003
  import chokidar from "chokidar";
1964
2004
  import dotenv from "dotenv";
1965
- import { cpSync as cpSync2, existsSync as existsSync10, readFileSync as readFileSync3 } from "fs";
1966
- import path10 from "path";
2005
+ import { cpSync as cpSync2, existsSync as existsSync11, readFileSync as readFileSync3 } from "fs";
2006
+ import path11 from "path";
1967
2007
  import { fileURLToPath as fileURLToPath3 } from "url";
1968
2008
  var stabilityThreshold = process.platform === "darwin" ? 100 : 200;
1969
2009
  var defaultPatterns = ["*/**", "**"];
@@ -1983,8 +2023,8 @@ var defaultNodeModulesIgnoredExceptVtexPackages = [
1983
2023
  var devAbortController = new AbortController();
1984
2024
  async function storeDev(rootDir, tmpDir, coreDir, port) {
1985
2025
  let envVars = {};
1986
- const vtexEnvPath = path10.join(rootDir, "vtex.env");
1987
- if (existsSync10(vtexEnvPath)) {
2026
+ const vtexEnvPath = path11.join(rootDir, "vtex.env");
2027
+ if (existsSync11(vtexEnvPath)) {
1988
2028
  try {
1989
2029
  envVars = dotenv.parse(readFileSync3(vtexEnvPath));
1990
2030
  } catch (err) {
@@ -1998,18 +2038,19 @@ async function storeDev(rootDir, tmpDir, coreDir, port) {
1998
2038
  cmd: `${packageManager} predev`,
1999
2039
  errorMessage: `The "predev" step ("${packageManager} predev") failed inside the ".faststore" directory. See the error output below for details.`,
2000
2040
  throws: "error",
2001
- cwd: tmpDir
2041
+ cwd: tmpDir,
2042
+ env: withNodeModulesBins(tmpDir)
2002
2043
  });
2003
2044
  const { success } = copyGenerated(
2004
- path10.join(tmpDir, "@generated"),
2005
- path10.join(coreDir, "@generated")
2045
+ path11.join(tmpDir, "@generated"),
2046
+ path11.join(coreDir, "@generated")
2006
2047
  );
2007
2048
  if (!success) {
2008
2049
  logger.log(
2009
2050
  `${chalk11.yellow("warn")} - Failed to copy @generated schema back to node_modules, autocomplete and DX might be impacted.`
2010
2051
  );
2011
2052
  logger.log(
2012
- `Attempted to copy from ${path10.join(tmpDir, "@generated")} to ${path10.join(coreDir, "@generated")}`
2053
+ `Attempted to copy from ${path11.join(tmpDir, "@generated")} to ${path11.join(coreDir, "@generated")}`
2013
2054
  );
2014
2055
  }
2015
2056
  const devProcess = spawn2(`${packageManager} dev-only --port ${port}`, {
@@ -2017,10 +2058,10 @@ async function storeDev(rootDir, tmpDir, coreDir, port) {
2017
2058
  cwd: tmpDir,
2018
2059
  signal: devAbortController.signal,
2019
2060
  stdio: ["inherit", "pipe", "inherit"],
2020
- env: {
2061
+ env: withNodeModulesBins(tmpDir, {
2021
2062
  ...process.env,
2022
2063
  ...envVars
2023
- }
2064
+ })
2024
2065
  });
2025
2066
  let nextStdout = "";
2026
2067
  devProcess.stdout.on("data", (chunk) => {
@@ -2130,9 +2171,9 @@ import chalk12 from "chalk";
2130
2171
 
2131
2172
  // src/utils/file.ts
2132
2173
  import fs4 from "fs";
2133
- import path11 from "path";
2174
+ import path12 from "path";
2134
2175
  function saveFile(fileLocation) {
2135
- fs4.mkdirSync(path11.dirname(fileLocation), { recursive: true });
2176
+ fs4.mkdirSync(path12.dirname(fileLocation), { recursive: true });
2136
2177
  return (content) => {
2137
2178
  fs4.writeFileSync(fileLocation, content);
2138
2179
  };
@@ -2146,17 +2187,17 @@ import {
2146
2187
  import { mergeTypeDefs } from "@graphql-tools/merge";
2147
2188
  import { printSchemaWithDirectives } from "@graphql-tools/utils";
2148
2189
  import { buildASTSchema, Kind, parse } from "graphql";
2149
- import fs5, { existsSync as existsSync11 } from "fs";
2150
- import path12 from "path";
2190
+ import fs5, { existsSync as existsSync12 } from "fs";
2191
+ import path13 from "path";
2151
2192
  var schemaFileName = "schema.graphql";
2152
2193
  async function genTsTypes(at) {
2153
2194
  await generateSchemaFile(at);
2154
2195
  generateSchemaTSTypes(at);
2155
2196
  }
2156
2197
  function generateSchemaTSTypes(root) {
2157
- let finalRootPath = path12.resolve(root);
2158
- if (existsSync11(path12.resolve(root, ".faststore"))) {
2159
- finalRootPath = path12.resolve(root, ".faststore");
2198
+ let finalRootPath = path13.resolve(root);
2199
+ if (existsSync12(path13.resolve(root, ".faststore"))) {
2200
+ finalRootPath = path13.resolve(root, ".faststore");
2160
2201
  }
2161
2202
  const documents = [`${finalRootPath}/src/**/*.{ts,tsx}`];
2162
2203
  const config = {
@@ -2165,7 +2206,7 @@ function generateSchemaTSTypes(root) {
2165
2206
  errorsOnly: false,
2166
2207
  debug: false,
2167
2208
  verbose: true,
2168
- schema: path12.resolve(finalRootPath, "@generated", schemaFileName),
2209
+ schema: path13.resolve(finalRootPath, "@generated", schemaFileName),
2169
2210
  generates: {
2170
2211
  [`${finalRootPath}/@generated/`]: {
2171
2212
  preset: "client",
@@ -2216,7 +2257,7 @@ function getOperationName(document) {
2216
2257
  async function generateSchemaFile(rootPath) {
2217
2258
  const faststoreSchema = printSchemaWithDirectives(GraphqlVtexSchema());
2218
2259
  const getMergedSchema = async () => {
2219
- const root = path12.join(
2260
+ const root = path13.join(
2220
2261
  rootPath.endsWith(".faststore") ? [rootPath, ".."].join("/") : rootPath
2221
2262
  );
2222
2263
  const customizations = [
@@ -2235,9 +2276,9 @@ async function generateSchemaFile(rootPath) {
2235
2276
  throw e;
2236
2277
  }
2237
2278
  };
2238
- let pathToSave = path12.resolve(rootPath, "@generated", schemaFileName);
2239
- if (existsSync11(path12.resolve(rootPath, ".faststore"))) {
2240
- pathToSave = path12.resolve(
2279
+ let pathToSave = path13.resolve(rootPath, "@generated", schemaFileName);
2280
+ if (existsSync12(path13.resolve(rootPath, ".faststore"))) {
2281
+ pathToSave = path13.resolve(
2241
2282
  rootPath,
2242
2283
  ".faststore",
2243
2284
  "@generated",
@@ -2254,7 +2295,7 @@ async function getTypeDefsFromFolder(root, customPath) {
2254
2295
  const basePath = [root, "src", "graphql"];
2255
2296
  const pathArray = Array.isArray(customPath) ? customPath : [customPath];
2256
2297
  const pattern = globbyModule.convertPathToPattern(
2257
- path12.join(...basePath, ...pathArray)
2298
+ path13.join(...basePath, ...pathArray)
2258
2299
  );
2259
2300
  return globbyModule.globbySync(`${pattern}/**/*.graphql`).map(
2260
2301
  (typeDef) => parse(fs5.readFileSync(typeDef, { encoding: "utf-8" }))
@@ -2288,7 +2329,7 @@ var Generate = class _Generate extends Command5 {
2288
2329
  // src/commands/prepare.ts
2289
2330
  import { Args as Args6, Command as Command6 } from "@oclif/core";
2290
2331
  import fs6 from "fs";
2291
- import path13 from "path";
2332
+ import path14 from "path";
2292
2333
  import { fileURLToPath as fileURLToPath4 } from "url";
2293
2334
  var Prepare = class _Prepare extends Command6 {
2294
2335
  static args = {
@@ -2300,10 +2341,10 @@ var Prepare = class _Prepare extends Command6 {
2300
2341
  async run() {
2301
2342
  const { args } = await this.parse(_Prepare);
2302
2343
  const basePath = getBasePath(args.path);
2303
- const clientPublicDir = path13.join(basePath, "public/");
2304
- const corePublicDir = path13.resolve(
2344
+ const clientPublicDir = path14.join(basePath, "public/");
2345
+ const corePublicDir = path14.resolve(
2305
2346
  fileURLToPath4(
2306
- path13.dirname(import.meta.resolve("@faststore/core", import.meta.url))
2347
+ path14.dirname(import.meta.resolve("@faststore/core", import.meta.url))
2307
2348
  ),
2308
2349
  "public"
2309
2350
  );
@@ -2319,8 +2360,8 @@ function copyFolder(sourceDir, targetDir) {
2319
2360
  }
2320
2361
  const files = fs6.readdirSync(sourceDir);
2321
2362
  for (const file of files) {
2322
- const sourcePath = path13.join(sourceDir, file);
2323
- const targetPath = path13.join(targetDir, file);
2363
+ const sourcePath = path14.join(sourceDir, file);
2364
+ const targetPath = path14.join(targetDir, file);
2324
2365
  const stat = fs6.statSync(sourcePath);
2325
2366
  if (stat.isFile()) {
2326
2367
  fs6.copyFileSync(sourcePath, targetPath);
@@ -2334,9 +2375,9 @@ function copyFolder(sourceDir, targetDir) {
2334
2375
  // src/commands/start.ts
2335
2376
  import { Args as Args7, Command as Command7 } from "@oclif/core";
2336
2377
  import { spawn as spawn3, spawnSync as spawnSync4 } from "child_process";
2337
- import fsExtra6 from "fs-extra";
2338
- import path14 from "path";
2339
- var { existsSync: existsSync12 } = fsExtra6;
2378
+ import fsExtra7 from "fs-extra";
2379
+ import path15 from "path";
2380
+ var { existsSync: existsSync13 } = fsExtra7;
2340
2381
  var Start = class _Start extends Command7 {
2341
2382
  static args = {
2342
2383
  account: Args7.string({
@@ -2355,7 +2396,7 @@ var Start = class _Start extends Command7 {
2355
2396
  const port = args.port ?? 3e3;
2356
2397
  const { getRoot, tmpDir } = withBasePath(basePath);
2357
2398
  const packageManager = await getPreferredPackageManager();
2358
- if (!existsSync12(path14.join(getRoot(), ".next"))) {
2399
+ if (!existsSync13(path15.join(getRoot(), ".next"))) {
2359
2400
  spawnSync4(`${packageManager} faststore build`, {
2360
2401
  shell: true,
2361
2402
  stdio: "inherit"
@@ -2395,7 +2436,8 @@ async function storeTest(tmpDir) {
2395
2436
  shell: true,
2396
2437
  cwd: tmpDir,
2397
2438
  signal: testAbortController.signal,
2398
- stdio: "inherit"
2439
+ stdio: "inherit",
2440
+ env: withNodeModulesBins(tmpDir)
2399
2441
  });
2400
2442
  testProcess.on("close", () => {
2401
2443
  testAbortController.abort();
@@ -2438,7 +2480,7 @@ var Test = class _Test extends Command8 {
2438
2480
  };
2439
2481
 
2440
2482
  // src/commands/generate-types.ts
2441
- import path15 from "path";
2483
+ import path16 from "path";
2442
2484
  import { Args as Args9, Command as Command9 } from "@oclif/core";
2443
2485
  import chalk13 from "chalk";
2444
2486
  var Generate2 = class _Generate extends Command9 {
@@ -2454,7 +2496,7 @@ var Generate2 = class _Generate extends Command9 {
2454
2496
  async run() {
2455
2497
  const { args } = await this.parse(_Generate);
2456
2498
  await genTsTypes(
2457
- path15.isAbsolute(args.path) ? args.path : path15.resolve(process.env.PWD ?? process.cwd(), args.path)
2499
+ path16.isAbsolute(args.path) ? args.path : path16.resolve(process.env.PWD ?? process.cwd(), args.path)
2458
2500
  );
2459
2501
  logger.log(
2460
2502
  `${chalk13.green(
@@ -2467,9 +2509,9 @@ var Generate2 = class _Generate extends Command9 {
2467
2509
  // src/commands/cache-graphql.ts
2468
2510
  import { Args as Args10, Command as Command10, Flags as Flags4 } from "@oclif/core";
2469
2511
  import chalk14 from "chalk";
2470
- import fsExtra7 from "fs-extra";
2512
+ import fsExtra8 from "fs-extra";
2471
2513
  import graphql from "graphql";
2472
- import path16 from "path";
2514
+ import path17 from "path";
2473
2515
  import { pathToFileURL as pathToFileURL8 } from "url";
2474
2516
  var { Kind: Kind2, OperationTypeNode, parse: parseGraphql } = graphql;
2475
2517
  var persistedDocumentsName = "persisted-documents.json";
@@ -2495,11 +2537,11 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2495
2537
  async run() {
2496
2538
  const { args, flags } = await this.parse(_CacheGraphql);
2497
2539
  const rootPath = getBasePath();
2498
- const argPath = args?.store && path16.resolve(rootPath, args.store) || rootPath;
2540
+ const argPath = args?.store && path17.resolve(rootPath, args.store) || rootPath;
2499
2541
  const { tmpDir } = withBasePath(argPath);
2500
- const configPath = this.getConfigFile(flags.config && path16.resolve(argPath, flags.config)) || this.getConfigFile(tmpDir) || this.getConfigFile(argPath);
2542
+ const configPath = this.getConfigFile(flags.config && path17.resolve(argPath, flags.config)) || this.getConfigFile(tmpDir) || this.getConfigFile(argPath);
2501
2543
  const persistedDocumentsPath = this.getPersistedDocument(
2502
- flags?.queries && path16.resolve(argPath, flags?.queries) || argPath
2544
+ flags?.queries && path17.resolve(argPath, flags?.queries) || argPath
2503
2545
  ) || this.getPersistedDocument(tmpDir);
2504
2546
  if (!configPath) {
2505
2547
  return this.errorFileNotFound(
@@ -2515,12 +2557,12 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2515
2557
  flags?.queries ?? argPath
2516
2558
  );
2517
2559
  }
2518
- const cachedOperationsPath = path16.join(
2519
- path16.dirname(persistedDocumentsPath),
2560
+ const cachedOperationsPath = path17.join(
2561
+ path17.dirname(persistedDocumentsPath),
2520
2562
  cachedOperationsFileName
2521
2563
  );
2522
2564
  const saveCachedOperationsFile = saveFile(cachedOperationsPath);
2523
- if (fsExtra7.pathExistsSync(tmpDir))
2565
+ if (fsExtra8.pathExistsSync(tmpDir))
2524
2566
  logger.info(`${chalk14.blue("[Info]")} - .faststore Path at: ${tmpDir}`);
2525
2567
  logger.info(`${chalk14.blue("[Info]")} - Config file location: ${configPath}`);
2526
2568
  logger.info(
@@ -2554,17 +2596,17 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2554
2596
  switch (true) {
2555
2597
  case !rootPath:
2556
2598
  return;
2557
- case (rootPath?.endsWith(fileName) && fsExtra7.existsSync(rootPath)):
2599
+ case (rootPath?.endsWith(fileName) && fsExtra8.existsSync(rootPath)):
2558
2600
  return rootPath;
2559
- case fsExtra7.existsSync(path16.join(rootPath ?? "", fileName)):
2560
- return path16.join(rootPath, fileName);
2601
+ case fsExtra8.existsSync(path17.join(rootPath ?? "", fileName)):
2602
+ return path17.join(rootPath, fileName);
2561
2603
  default:
2562
2604
  if (!pathFromRoot) return;
2563
- const filePath = path16.join(
2605
+ const filePath = path17.join(
2564
2606
  rootPath,
2565
2607
  ...Array.isArray(pathFromRoot) ? pathFromRoot : [pathFromRoot]
2566
2608
  );
2567
- if (fsExtra7.existsSync(filePath)) {
2609
+ if (fsExtra8.existsSync(filePath)) {
2568
2610
  return filePath;
2569
2611
  }
2570
2612
  return;
@@ -2606,9 +2648,9 @@ import { Args as Args11, Command as Command11, Flags as Flags5 } from "@oclif/co
2606
2648
  import { FastStoreSDK } from "@vtex/faststore-sdk";
2607
2649
  import chalk15 from "chalk";
2608
2650
  import dotenv2 from "dotenv";
2609
- import fsExtra8 from "fs-extra";
2610
- import { existsSync as existsSync13 } from "fs";
2611
- import path17 from "path";
2651
+ import fsExtra9 from "fs-extra";
2652
+ import { existsSync as existsSync14 } from "fs";
2653
+ import path18 from "path";
2612
2654
  import { format } from "prettier";
2613
2655
  import { pathToFileURL as pathToFileURL9 } from "url";
2614
2656
  var configFileName3 = "discovery.config.default.js";
@@ -2634,17 +2676,17 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2634
2676
  switch (true) {
2635
2677
  case !rootPath:
2636
2678
  return;
2637
- case (rootPath?.endsWith(fileName) && fsExtra8.existsSync(rootPath)):
2679
+ case (rootPath?.endsWith(fileName) && fsExtra9.existsSync(rootPath)):
2638
2680
  return rootPath;
2639
- case fsExtra8.existsSync(path17.join(rootPath ?? "", fileName)):
2640
- return path17.join(rootPath, fileName);
2681
+ case fsExtra9.existsSync(path18.join(rootPath ?? "", fileName)):
2682
+ return path18.join(rootPath, fileName);
2641
2683
  default:
2642
2684
  if (!pathFromRoot) return;
2643
- const filePath = path17.join(
2685
+ const filePath = path18.join(
2644
2686
  rootPath,
2645
2687
  ...Array.isArray(pathFromRoot) ? pathFromRoot : [pathFromRoot]
2646
2688
  );
2647
- if (fsExtra8.existsSync(filePath)) {
2689
+ if (fsExtra9.existsSync(filePath)) {
2648
2690
  return filePath;
2649
2691
  }
2650
2692
  return;
@@ -2660,13 +2702,13 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2660
2702
  async run() {
2661
2703
  const { args, flags } = await this.parse(_GenerateI18n);
2662
2704
  const rootPath = getBasePath();
2663
- const argPath = args?.path && path17.resolve(rootPath, args.path) || rootPath;
2705
+ const argPath = args?.path && path18.resolve(rootPath, args.path) || rootPath;
2664
2706
  const localizationEnabled = await checkAndValidateLocalization(argPath);
2665
2707
  if (!localizationEnabled) {
2666
2708
  return;
2667
2709
  }
2668
- const vtexEnvPath = path17.join(argPath, "vtex.env");
2669
- if (existsSync13(vtexEnvPath)) {
2710
+ const vtexEnvPath = path18.join(argPath, "vtex.env");
2711
+ if (existsSync14(vtexEnvPath)) {
2670
2712
  dotenv2.config({ path: vtexEnvPath });
2671
2713
  }
2672
2714
  const { VTEX_ACCOUNT, FS_DISCOVERY_APP_KEY, FS_DISCOVERY_APP_TOKEN } = process.env;
@@ -2683,7 +2725,7 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2683
2725
  process.exit(1);
2684
2726
  }
2685
2727
  const { tmpDir } = withBasePath(argPath);
2686
- const configPath = this.getConfigFile(flags.config && path17.resolve(argPath, flags.config)) || this.getConfigFile(tmpDir) || this.getConfigFile(argPath);
2728
+ const configPath = this.getConfigFile(flags.config && path18.resolve(argPath, flags.config)) || this.getConfigFile(tmpDir) || this.getConfigFile(argPath);
2687
2729
  if (!configPath) {
2688
2730
  return this.errorFileNotFound(
2689
2731
  configFileName3,
@@ -2693,7 +2735,7 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2693
2735
  );
2694
2736
  }
2695
2737
  const saveConfigFile = saveFile(configPath);
2696
- if (fsExtra8.pathExistsSync(tmpDir))
2738
+ if (fsExtra9.pathExistsSync(tmpDir))
2697
2739
  logger.info(`${chalk15.blue("[Info]")} - .faststore Path at: ${tmpDir}`);
2698
2740
  logger.info(`${chalk15.blue("[Info]")} - Config file location: ${configPath}`);
2699
2741
  const discoveryConfig = await import(pathToFileURL9(configPath).href);