@faststore/cli 4.7.0-dev.6 → 4.7.0-dev.8

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
@@ -364,7 +364,7 @@ import { Args as Args2, Command as Command2, Flags as Flags2 } from "@oclif/core
364
364
  import chalk10 from "chalk";
365
365
  import { spawn } from "child_process";
366
366
  import { existsSync as existsSync10 } from "fs";
367
- import path10 from "path";
367
+ import path11 from "path";
368
368
  import { pathToFileURL as pathToFileURL7 } from "url";
369
369
 
370
370
  // src/utils/config.ts
@@ -589,7 +589,7 @@ function generateAndUploadSchema({
589
589
  // src/utils/generate.ts
590
590
  import chalk7 from "chalk";
591
591
  import fsExtra5 from "fs-extra";
592
- import path8 from "path";
592
+ import path9 from "path";
593
593
  import ora from "ora";
594
594
  import { pathToFileURL as pathToFileURL5 } from "url";
595
595
 
@@ -959,8 +959,57 @@ async function installDependencies({
959
959
 
960
960
  // src/utils/plugins.ts
961
961
  import fsExtra4 from "fs-extra";
962
- import path7 from "path";
962
+ import path8 from "path";
963
963
  import { pathToFileURL as pathToFileURL4 } from "url";
964
+
965
+ // src/utils/storefrontCopy.ts
966
+ import path7 from "path";
967
+ var IGNORED_STOREFRONT_BASENAMES = /* @__PURE__ */ new Set([
968
+ "package.json",
969
+ "node_modules",
970
+ "cypress.config.ts",
971
+ "base.jsonc",
972
+ // CP special file, it must not be copied to the merchants' temp dir
973
+ "test",
974
+ "__tests__"
975
+ ]);
976
+ var TEST_FILE_RE = /\.(?:test|spec|browser\.test)\.(?:js|jsx|ts|tsx)$/;
977
+ function shouldCopyToStorefront(src) {
978
+ const name = path7.basename(src);
979
+ if (!name) {
980
+ return true;
981
+ }
982
+ if (IGNORED_STOREFRONT_BASENAMES.has(name)) {
983
+ return false;
984
+ }
985
+ if (TEST_FILE_RE.test(name)) {
986
+ return false;
987
+ }
988
+ return true;
989
+ }
990
+ var STOREFRONT_TEST_EXCLUDE_GLOBS = [
991
+ "test",
992
+ "**/*.test.ts",
993
+ "**/*.test.tsx",
994
+ "**/*.spec.ts",
995
+ "**/*.spec.tsx",
996
+ "**/__tests__/**"
997
+ ];
998
+ function prepareStorefrontTsConfig(tsConfig) {
999
+ const include = (tsConfig.include ?? []).filter(
1000
+ (pattern) => !String(pattern).startsWith("test/")
1001
+ );
1002
+ const exclude = Array.from(
1003
+ /* @__PURE__ */ new Set([...tsConfig.exclude ?? [], ...STOREFRONT_TEST_EXCLUDE_GLOBS])
1004
+ );
1005
+ return {
1006
+ ...tsConfig,
1007
+ include,
1008
+ exclude
1009
+ };
1010
+ }
1011
+
1012
+ // src/utils/plugins.ts
964
1013
  var { copySync: copySync2, existsSync: existsSync7, mkdirSync: mkdirSync2, readdirSync: readdirSync2, writeFileSync } = fsExtra4;
965
1014
  var PLUGIN_CONFIG_FILE = "plugin.config.js";
966
1015
  var sanitizePluginName = (pluginName, pascalCase = false) => {
@@ -1001,19 +1050,21 @@ var getPluginsList = async (basePath) => {
1001
1050
  var copyPluginsSrc = async (basePath, plugins) => {
1002
1051
  const { tmpPluginsDir } = withBasePath(basePath);
1003
1052
  logger.log("Copying plugins files");
1004
- plugins.forEach(async (plugin) => {
1053
+ for (const plugin of plugins) {
1005
1054
  const pluginName = getPluginName(plugin);
1006
1055
  const pluginSrcPath = await getPluginSrcPath(
1007
1056
  basePath,
1008
1057
  getPluginName(pluginName)
1009
1058
  );
1010
- const pluginDestPath = path7.join(
1059
+ const pluginDestPath = path8.join(
1011
1060
  tmpPluginsDir,
1012
1061
  sanitizePluginName(pluginName)
1013
1062
  );
1014
- copySync2(pluginSrcPath, pluginDestPath);
1063
+ copySync2(pluginSrcPath, pluginDestPath, {
1064
+ filter: shouldCopyToStorefront
1065
+ });
1015
1066
  logger.log(`Copied ${pluginName} files`);
1016
- });
1067
+ }
1017
1068
  };
1018
1069
  var copyPluginPublicFiles = async (basePath, plugins) => {
1019
1070
  const { tmpDir, getPackagePath } = withBasePath(basePath);
@@ -1079,13 +1130,13 @@ var generatePluginPages = async (basePath, plugins) => {
1079
1130
  const paths = pagesConfig[pageName].path.split("/");
1080
1131
  const pageFile = paths.pop();
1081
1132
  const pagePaths = paths;
1082
- const pagePath = path7.join(tmpPagesDir, ...pagePaths, pageFile + ".tsx");
1133
+ const pagePath = path8.join(tmpPagesDir, ...pagePaths, pageFile + ".tsx");
1083
1134
  const fileContent = getPluginPageFileContent(
1084
1135
  sanitizePluginName(pluginName),
1085
1136
  pageName,
1086
1137
  pagesConfig[pageName].appLayout
1087
1138
  );
1088
- mkdirSync2(path7.dirname(pagePath), { recursive: true });
1139
+ mkdirSync2(path8.dirname(pagePath), { recursive: true });
1089
1140
  writeFileSync(pagePath, fileContent);
1090
1141
  });
1091
1142
  });
@@ -1111,7 +1162,7 @@ async function addPluginsSections(basePath, plugins) {
1111
1162
  ${indexPluginsOverrides.map((plugin) => `...${plugin.pluginReference}`).join(",\n")}
1112
1163
  }
1113
1164
  `;
1114
- const sectionPath = path7.join(tmpPluginsDir, "index.ts");
1165
+ const sectionPath = path8.join(tmpPluginsDir, "index.ts");
1115
1166
  writeFileSync(sectionPath, pluginsImportFileContent);
1116
1167
  logger.log("Writing plugins overrides");
1117
1168
  logger.log(sectionPath);
@@ -1135,7 +1186,7 @@ async function addPluginsOverrides(basePath, plugins) {
1135
1186
  overrideFiles.filter((file) => !overrideFilesAlreadyCopied.includes(file)).forEach((overrideFileName) => {
1136
1187
  const overrideFileContent = `export { override } from 'src/plugins/${sanitizedPluginName}/components/overrides/${overrideFileName.split(".")[0]}'`;
1137
1188
  writeFileSync(
1138
- path7.join(tmpPluginsDir, "overrides", overrideFileName),
1189
+ path8.join(tmpPluginsDir, "overrides", overrideFileName),
1139
1190
  overrideFileContent
1140
1191
  );
1141
1192
  overrideFilesAlreadyCopied.push(overrideFileName);
@@ -1180,7 +1231,7 @@ var generatePluginApis = async (basePath, plugins) => {
1180
1231
  const paths = apisConfig[apiName].path.split("/");
1181
1232
  const apiFile = paths.pop();
1182
1233
  const apiPaths = paths;
1183
- const apiPath = path7.join(
1234
+ const apiPath = path8.join(
1184
1235
  tmpApiDir,
1185
1236
  "plugins",
1186
1237
  ...apiPaths,
@@ -1190,14 +1241,14 @@ var generatePluginApis = async (basePath, plugins) => {
1190
1241
  sanitizePluginName(pluginName),
1191
1242
  apiName
1192
1243
  );
1193
- mkdirSync2(path7.dirname(apiPath), { recursive: true });
1244
+ mkdirSync2(path8.dirname(apiPath), { recursive: true });
1194
1245
  writeFileSync(apiPath, fileContent);
1195
1246
  });
1196
1247
  });
1197
1248
  };
1198
1249
  var installPlugins = async (basePath) => {
1199
1250
  const plugins = await getPluginsList(basePath);
1200
- copyPluginsSrc(basePath, plugins);
1251
+ await copyPluginsSrc(basePath, plugins);
1201
1252
  copyPluginPublicFiles(basePath, plugins);
1202
1253
  generatePluginPages(basePath, plugins);
1203
1254
  generatePluginApis(basePath, plugins);
@@ -1219,13 +1270,6 @@ var {
1219
1270
  writeFileSync: writeFileSync2,
1220
1271
  writeJsonSync
1221
1272
  } = fsExtra5;
1222
- var ignorePaths = [
1223
- "package.json",
1224
- "node_modules",
1225
- "cypress.config.ts",
1226
- "base.jsonc"
1227
- // CP special file, it must not be copied to the merchants' temp dir
1228
- ];
1229
1273
  function createTmpFolder(basePath) {
1230
1274
  const { tmpDir, tmpFolderName } = withBasePath(basePath);
1231
1275
  try {
@@ -1271,12 +1315,12 @@ function relativeNextBin(coreDir, tmpDir) {
1271
1315
  if (!nextBin) {
1272
1316
  return void 0;
1273
1317
  }
1274
- const relative = path8.relative(tmpDir, nextBin).replaceAll("\\", "/");
1275
- return relative && !path8.isAbsolute(relative) ? relative : void 0;
1318
+ const relative = path9.relative(tmpDir, nextBin).replaceAll("\\", "/");
1319
+ return relative && !path9.isAbsolute(relative) ? relative : void 0;
1276
1320
  }
1277
1321
  function readRootVoltaConfig(rootDir) {
1278
1322
  try {
1279
- const rootManifestPath = path8.join(rootDir, "package.json");
1323
+ const rootManifestPath = path9.join(rootDir, "package.json");
1280
1324
  if (!existsSync8(rootManifestPath)) {
1281
1325
  return void 0;
1282
1326
  }
@@ -1289,7 +1333,7 @@ function readRootVoltaConfig(rootDir) {
1289
1333
  function filterAndCopyPackageJson(basePath) {
1290
1334
  const { coreDir, tmpDir, getRoot } = withBasePath(basePath);
1291
1335
  const coreManifest = JSON.parse(
1292
- readFileSync(path8.join(coreDir, "package.json"), "utf8")
1336
+ readFileSync(path9.join(coreDir, "package.json"), "utf8")
1293
1337
  );
1294
1338
  const voltaConfig = readRootVoltaConfig(getRoot());
1295
1339
  const filteredFileContent = buildFaststorePackageJson(
@@ -1297,22 +1341,26 @@ function filterAndCopyPackageJson(basePath) {
1297
1341
  voltaConfig,
1298
1342
  relativeNextBin(coreDir, tmpDir)
1299
1343
  );
1300
- writeJsonSync(path8.join(tmpDir, "package.json"), filteredFileContent, {
1344
+ writeJsonSync(path9.join(tmpDir, "package.json"), filteredFileContent, {
1301
1345
  spaces: 2
1302
1346
  });
1303
1347
  }
1304
1348
  var TS_CONFIG_STRICT_RULES_ENABLED = ["noImplicitAny"];
1305
1349
  function disableTsConfigStrictRules(basePath) {
1306
1350
  const { coreDir, tmpDir } = withBasePath(basePath);
1307
- const coreTsConfigPath = path8.join(coreDir, "tsconfig.json");
1351
+ const coreTsConfigPath = path9.join(coreDir, "tsconfig.json");
1308
1352
  const coreTsConfigFile = readFileSync(coreTsConfigPath, "utf8");
1309
1353
  const tsConfig = JSON.parse(coreTsConfigFile);
1310
1354
  TS_CONFIG_STRICT_RULES_ENABLED.forEach((strictRule) => {
1311
1355
  tsConfig.compilerOptions[strictRule] = false;
1312
1356
  });
1313
- writeJsonSync(path8.join(tmpDir, "tsconfig.json"), tsConfig, {
1314
- spaces: 2
1315
- });
1357
+ writeJsonSync(
1358
+ path9.join(tmpDir, "tsconfig.json"),
1359
+ prepareStorefrontTsConfig(tsConfig),
1360
+ {
1361
+ spaces: 2
1362
+ }
1363
+ );
1316
1364
  }
1317
1365
  function copyCoreFiles(basePath) {
1318
1366
  const { coreDir, tmpDir } = withBasePath(basePath);
@@ -1320,9 +1368,7 @@ function copyCoreFiles(basePath) {
1320
1368
  copySync3(coreDir, tmpDir, {
1321
1369
  dereference: true,
1322
1370
  filter(src) {
1323
- const fileOrDirName = path8.basename(src);
1324
- const shouldCopy = fileOrDirName ? !ignorePaths.includes(fileOrDirName) : true;
1325
- return shouldCopy;
1371
+ return shouldCopyToStorefront(src);
1326
1372
  }
1327
1373
  });
1328
1374
  filterAndCopyPackageJson(basePath);
@@ -1349,7 +1395,7 @@ function isPublicFileAllowed(src, isDirectory) {
1349
1395
  return true;
1350
1396
  }
1351
1397
  return PUBLIC_FILES_ALLOWED_EXTENSIONS.includes(
1352
- path8.extname(src).toLowerCase()
1398
+ path9.extname(src).toLowerCase()
1353
1399
  );
1354
1400
  }
1355
1401
  function copyPublicFiles(basePath) {
@@ -1388,9 +1434,9 @@ async function copyCypressFiles(basePath) {
1388
1434
  }
1389
1435
  let userStoreConfig;
1390
1436
  if (existsSync8(userStoreConfigFile)) {
1391
- userStoreConfig = (await import(pathToFileURL5(path8.resolve(userStoreConfigFile)).href))?.default;
1437
+ userStoreConfig = (await import(pathToFileURL5(path9.resolve(userStoreConfigFile)).href))?.default;
1392
1438
  } else if (existsSync8(userLegacyStoreConfigFile)) {
1393
- userStoreConfig = (await import(pathToFileURL5(path8.resolve(userLegacyStoreConfigFile)).href))?.default;
1439
+ userStoreConfig = (await import(pathToFileURL5(path9.resolve(userLegacyStoreConfigFile)).href))?.default;
1394
1440
  } else {
1395
1441
  logger.info(
1396
1442
  `${chalk7.blue(
@@ -1455,9 +1501,9 @@ async function createCmsWebhookUrlsJsonFile(basePath) {
1455
1501
  } = withBasePath(basePath);
1456
1502
  let userStoreConfig;
1457
1503
  if (existsSync8(userStoreConfigFile)) {
1458
- userStoreConfig = (await import(pathToFileURL5(path8.resolve(userStoreConfigFile)).href))?.default;
1504
+ userStoreConfig = (await import(pathToFileURL5(path9.resolve(userStoreConfigFile)).href))?.default;
1459
1505
  } else if (existsSync8(userLegacyStoreConfigFile)) {
1460
- userStoreConfig = (await import(pathToFileURL5(path8.resolve(userLegacyStoreConfigFile)).href))?.default;
1506
+ userStoreConfig = (await import(pathToFileURL5(path9.resolve(userLegacyStoreConfigFile)).href))?.default;
1461
1507
  } else {
1462
1508
  logger.info(
1463
1509
  `${chalk7.blue(
@@ -1485,7 +1531,7 @@ async function copyTheme(basePath) {
1485
1531
  userLegacyStoreConfigFile
1486
1532
  } = withBasePath(basePath);
1487
1533
  const storeConfigFile = existsSync8(userStoreConfigFile) && userStoreConfigFile || existsSync8(userLegacyStoreConfigFile) && userLegacyStoreConfigFile;
1488
- const userStoreConfigFilePath = storeConfigFile && path8.resolve(storeConfigFile);
1534
+ const userStoreConfigFilePath = storeConfigFile && path9.resolve(storeConfigFile);
1489
1535
  const importedStoreConfig = userStoreConfigFilePath && await import(pathToFileURL5(userStoreConfigFilePath).href);
1490
1536
  const storeConfig = userStoreConfigFilePath && (importedStoreConfig?.default || importedStoreConfig);
1491
1537
  if (!storeConfig)
@@ -1495,7 +1541,7 @@ async function copyTheme(basePath) {
1495
1541
  )} - No store config file was found in the root directory`
1496
1542
  );
1497
1543
  if (storeConfig.theme) {
1498
- const customTheme = path8.join(
1544
+ const customTheme = path9.join(
1499
1545
  userThemesFileDir,
1500
1546
  `${storeConfig.theme}.scss`
1501
1547
  );
@@ -1538,8 +1584,8 @@ function updateBuildTime(basePath) {
1538
1584
  }
1539
1585
  async function checkDependencies(basePath, packagesToCheck) {
1540
1586
  const { coreDir, getRoot } = withBasePath(basePath);
1541
- const corePackageJsonPath = path8.join(coreDir, "package.json");
1542
- const rootPackageJsonPath = path8.join(getRoot(), "package.json");
1587
+ const corePackageJsonPath = path9.join(coreDir, "package.json");
1588
+ const rootPackageJsonPath = path9.join(getRoot(), "package.json");
1543
1589
  const { default: corePackageJson } = await import(pathToFileURL5(corePackageJsonPath).href, {
1544
1590
  with: { type: "json" }
1545
1591
  });
@@ -1567,7 +1613,7 @@ async function checkDependencies(basePath, packagesToCheck) {
1567
1613
  }
1568
1614
  function updateNextConfig(basePath) {
1569
1615
  const { tmpDir } = withBasePath(basePath);
1570
- const nextConfigPath = path8.join(tmpDir, "next.config.js");
1616
+ const nextConfigPath = path9.join(tmpDir, "next.config.js");
1571
1617
  let nextConfigData = String(readFileSync(nextConfigPath));
1572
1618
  nextConfigData = nextConfigData.replace(
1573
1619
  /outputFileTracingRoot\:\s+(.*),/,
@@ -1592,7 +1638,7 @@ async function validateAndInstallMissingDependencies(basePath) {
1592
1638
  return;
1593
1639
  }
1594
1640
  const { default: userStoreConfig } = await import(pathToFileURL5(currentUserStoreConfigFile).href);
1595
- const { default: userPackageJson } = await import(pathToFileURL5(path8.join(userDir, "package.json")).href, {
1641
+ const { default: userPackageJson } = await import(pathToFileURL5(path9.join(userDir, "package.json")).href, {
1596
1642
  with: { type: "json" }
1597
1643
  });
1598
1644
  const missingDependencies = [];
@@ -1631,7 +1677,7 @@ async function enableSearchSSR(basePath) {
1631
1677
  return;
1632
1678
  }
1633
1679
  const { tmpDir } = withBasePath(basePath);
1634
- const searchPagePath = path8.join(tmpDir, "src", "pages", "s.tsx");
1680
+ const searchPagePath = path9.join(tmpDir, "src", "pages", "s.tsx");
1635
1681
  const searchPageData = String(readFileSync(searchPagePath));
1636
1682
  const searchPageWithSSR = searchPageData.replaceAll(
1637
1683
  "getStaticProps",
@@ -1666,7 +1712,7 @@ async function generate(options) {
1666
1712
 
1667
1713
  // src/utils/hcms.ts
1668
1714
  import chalk8 from "chalk";
1669
- import path9 from "path";
1715
+ import path10 from "path";
1670
1716
  import { confirm } from "@inquirer/prompts";
1671
1717
  import fsExtra6 from "fs-extra";
1672
1718
  import { pathToFileURL as pathToFileURL6 } from "url";
@@ -1734,10 +1780,10 @@ async function mergeCMSFile(fileName, basePath) {
1734
1780
  getPackagePath,
1735
1781
  userStoreConfigFile
1736
1782
  } = withBasePath(basePath);
1737
- const { default: userStoreConfig } = await import(pathToFileURL6(path9.resolve(userStoreConfigFile)).href);
1783
+ const { default: userStoreConfig } = await import(pathToFileURL6(path10.resolve(userStoreConfigFile)).href);
1738
1784
  const cmsProjectName = userStoreConfig.contentSource?.project ?? "faststore";
1739
- const coreFilePath = path9.join(coreCMSDir, fileName);
1740
- const customFilePath = path9.join(userCMSDir, fileName);
1785
+ const coreFilePath = path10.join(coreCMSDir, fileName);
1786
+ const customFilePath = path10.join(userCMSDir, fileName);
1741
1787
  const coreFile = readFileSync2(coreFilePath, "utf8");
1742
1788
  const coreDefinitions = JSON.parse(coreFile);
1743
1789
  const primaryIdentifierForDefinitions = fileName === "content-types.json" ? "id" : "name";
@@ -1790,7 +1836,7 @@ async function mergeCMSFile(fileName, basePath) {
1790
1836
  mkdirSync3(tmpCMSDir(cmsProjectName));
1791
1837
  }
1792
1838
  writeFileSync3(
1793
- path9.join(tmpCMSDir(cmsProjectName), fileName),
1839
+ path10.join(tmpCMSDir(cmsProjectName), fileName),
1794
1840
  JSON.stringify(output)
1795
1841
  );
1796
1842
  console.log(
@@ -1896,7 +1942,7 @@ var CmsSync = class _CmsSync extends Command2 {
1896
1942
  const { flags, args } = await this.parse(_CmsSync);
1897
1943
  const basePath = getBasePath(args.path);
1898
1944
  const { userStoreConfigFile } = withBasePath(basePath);
1899
- const storeConfig = existsSync10(userStoreConfigFile) ? (await import(pathToFileURL7(path10.resolve(userStoreConfigFile)).href)).default : null;
1945
+ const storeConfig = existsSync10(userStoreConfigFile) ? (await import(pathToFileURL7(path11.resolve(userStoreConfigFile)).href)).default : null;
1900
1946
  const source = resolveContentSource(storeConfig?.contentSource?.type);
1901
1947
  logger.info(
1902
1948
  `${chalk10.blue("[Info]")} - Detected contentSource "${source}" \u2014 ${CONTENT_SOURCE_ACTION[source]}`
@@ -2021,7 +2067,7 @@ import { spawn as spawn2, spawnSync as spawnSync3 } from "child_process";
2021
2067
  import chokidar from "chokidar";
2022
2068
  import dotenv from "dotenv";
2023
2069
  import { cpSync as cpSync2, existsSync as existsSync11, readFileSync as readFileSync3 } from "fs";
2024
- import path11 from "path";
2070
+ import path12 from "path";
2025
2071
  import { fileURLToPath as fileURLToPath3 } from "url";
2026
2072
  var stabilityThreshold = process.platform === "darwin" ? 100 : 200;
2027
2073
  var defaultPatterns = ["*/**", "**"];
@@ -2041,7 +2087,7 @@ var defaultNodeModulesIgnoredExceptVtexPackages = [
2041
2087
  var devAbortController = new AbortController();
2042
2088
  async function storeDev(rootDir, tmpDir, coreDir, port) {
2043
2089
  let envVars = {};
2044
- const vtexEnvPath = path11.join(rootDir, "vtex.env");
2090
+ const vtexEnvPath = path12.join(rootDir, "vtex.env");
2045
2091
  if (existsSync11(vtexEnvPath)) {
2046
2092
  try {
2047
2093
  envVars = dotenv.parse(readFileSync3(vtexEnvPath));
@@ -2060,15 +2106,15 @@ async function storeDev(rootDir, tmpDir, coreDir, port) {
2060
2106
  env: withNodeModulesBins(tmpDir)
2061
2107
  });
2062
2108
  const { success } = copyGenerated(
2063
- path11.join(tmpDir, "@generated"),
2064
- path11.join(coreDir, "@generated")
2109
+ path12.join(tmpDir, "@generated"),
2110
+ path12.join(coreDir, "@generated")
2065
2111
  );
2066
2112
  if (!success) {
2067
2113
  logger.log(
2068
2114
  `${chalk11.yellow("warn")} - Failed to copy @generated schema back to node_modules, autocomplete and DX might be impacted.`
2069
2115
  );
2070
2116
  logger.log(
2071
- `Attempted to copy from ${path11.join(tmpDir, "@generated")} to ${path11.join(coreDir, "@generated")}`
2117
+ `Attempted to copy from ${path12.join(tmpDir, "@generated")} to ${path12.join(coreDir, "@generated")}`
2072
2118
  );
2073
2119
  }
2074
2120
  const devProcess = spawn2(`${packageManager} dev-only --port ${port}`, {
@@ -2189,9 +2235,9 @@ import chalk12 from "chalk";
2189
2235
 
2190
2236
  // src/utils/file.ts
2191
2237
  import fs4 from "fs";
2192
- import path12 from "path";
2238
+ import path13 from "path";
2193
2239
  function saveFile(fileLocation) {
2194
- fs4.mkdirSync(path12.dirname(fileLocation), { recursive: true });
2240
+ fs4.mkdirSync(path13.dirname(fileLocation), { recursive: true });
2195
2241
  return (content) => {
2196
2242
  fs4.writeFileSync(fileLocation, content);
2197
2243
  };
@@ -2206,16 +2252,16 @@ import { mergeTypeDefs } from "@graphql-tools/merge";
2206
2252
  import { printSchemaWithDirectives } from "@graphql-tools/utils";
2207
2253
  import { buildASTSchema, Kind, parse } from "graphql";
2208
2254
  import fs5, { existsSync as existsSync12 } from "fs";
2209
- import path13 from "path";
2255
+ import path14 from "path";
2210
2256
  var schemaFileName = "schema.graphql";
2211
2257
  async function genTsTypes(at) {
2212
2258
  await generateSchemaFile(at);
2213
2259
  generateSchemaTSTypes(at);
2214
2260
  }
2215
2261
  function generateSchemaTSTypes(root) {
2216
- let finalRootPath = path13.resolve(root);
2217
- if (existsSync12(path13.resolve(root, ".faststore"))) {
2218
- finalRootPath = path13.resolve(root, ".faststore");
2262
+ let finalRootPath = path14.resolve(root);
2263
+ if (existsSync12(path14.resolve(root, ".faststore"))) {
2264
+ finalRootPath = path14.resolve(root, ".faststore");
2219
2265
  }
2220
2266
  const documents = [`${finalRootPath}/src/**/*.{ts,tsx}`];
2221
2267
  const config = {
@@ -2224,7 +2270,7 @@ function generateSchemaTSTypes(root) {
2224
2270
  errorsOnly: false,
2225
2271
  debug: false,
2226
2272
  verbose: true,
2227
- schema: path13.resolve(finalRootPath, "@generated", schemaFileName),
2273
+ schema: path14.resolve(finalRootPath, "@generated", schemaFileName),
2228
2274
  generates: {
2229
2275
  [`${finalRootPath}/@generated/`]: {
2230
2276
  preset: "client",
@@ -2275,7 +2321,7 @@ function getOperationName(document) {
2275
2321
  async function generateSchemaFile(rootPath) {
2276
2322
  const faststoreSchema = printSchemaWithDirectives(GraphqlVtexSchema());
2277
2323
  const getMergedSchema = async () => {
2278
- const root = path13.join(
2324
+ const root = path14.join(
2279
2325
  rootPath.endsWith(".faststore") ? [rootPath, ".."].join("/") : rootPath
2280
2326
  );
2281
2327
  const customizations = [
@@ -2294,9 +2340,9 @@ async function generateSchemaFile(rootPath) {
2294
2340
  throw e;
2295
2341
  }
2296
2342
  };
2297
- let pathToSave = path13.resolve(rootPath, "@generated", schemaFileName);
2298
- if (existsSync12(path13.resolve(rootPath, ".faststore"))) {
2299
- pathToSave = path13.resolve(
2343
+ let pathToSave = path14.resolve(rootPath, "@generated", schemaFileName);
2344
+ if (existsSync12(path14.resolve(rootPath, ".faststore"))) {
2345
+ pathToSave = path14.resolve(
2300
2346
  rootPath,
2301
2347
  ".faststore",
2302
2348
  "@generated",
@@ -2313,7 +2359,7 @@ async function getTypeDefsFromFolder(root, customPath) {
2313
2359
  const basePath = [root, "src", "graphql"];
2314
2360
  const pathArray = Array.isArray(customPath) ? customPath : [customPath];
2315
2361
  const pattern = globbyModule.convertPathToPattern(
2316
- path13.join(...basePath, ...pathArray)
2362
+ path14.join(...basePath, ...pathArray)
2317
2363
  );
2318
2364
  return globbyModule.globbySync(`${pattern}/**/*.graphql`).map(
2319
2365
  (typeDef) => parse(fs5.readFileSync(typeDef, { encoding: "utf-8" }))
@@ -2347,7 +2393,7 @@ var Generate = class _Generate extends Command5 {
2347
2393
  // src/commands/prepare.ts
2348
2394
  import { Args as Args6, Command as Command6 } from "@oclif/core";
2349
2395
  import fs6 from "fs";
2350
- import path14 from "path";
2396
+ import path15 from "path";
2351
2397
  import { fileURLToPath as fileURLToPath4 } from "url";
2352
2398
  var Prepare = class _Prepare extends Command6 {
2353
2399
  static args = {
@@ -2359,10 +2405,10 @@ var Prepare = class _Prepare extends Command6 {
2359
2405
  async run() {
2360
2406
  const { args } = await this.parse(_Prepare);
2361
2407
  const basePath = getBasePath(args.path);
2362
- const clientPublicDir = path14.join(basePath, "public/");
2363
- const corePublicDir = path14.resolve(
2408
+ const clientPublicDir = path15.join(basePath, "public/");
2409
+ const corePublicDir = path15.resolve(
2364
2410
  fileURLToPath4(
2365
- path14.dirname(import.meta.resolve("@faststore/core", import.meta.url))
2411
+ path15.dirname(import.meta.resolve("@faststore/core", import.meta.url))
2366
2412
  ),
2367
2413
  "public"
2368
2414
  );
@@ -2378,8 +2424,8 @@ function copyFolder(sourceDir, targetDir) {
2378
2424
  }
2379
2425
  const files = fs6.readdirSync(sourceDir);
2380
2426
  for (const file of files) {
2381
- const sourcePath = path14.join(sourceDir, file);
2382
- const targetPath = path14.join(targetDir, file);
2427
+ const sourcePath = path15.join(sourceDir, file);
2428
+ const targetPath = path15.join(targetDir, file);
2383
2429
  const stat = fs6.statSync(sourcePath);
2384
2430
  if (stat.isFile()) {
2385
2431
  fs6.copyFileSync(sourcePath, targetPath);
@@ -2394,7 +2440,7 @@ function copyFolder(sourceDir, targetDir) {
2394
2440
  import { Args as Args7, Command as Command7 } from "@oclif/core";
2395
2441
  import { spawn as spawn3, spawnSync as spawnSync4 } from "child_process";
2396
2442
  import fsExtra7 from "fs-extra";
2397
- import path15 from "path";
2443
+ import path16 from "path";
2398
2444
  var { existsSync: existsSync13 } = fsExtra7;
2399
2445
  var Start = class _Start extends Command7 {
2400
2446
  static args = {
@@ -2414,7 +2460,7 @@ var Start = class _Start extends Command7 {
2414
2460
  const port = args.port ?? 3e3;
2415
2461
  const { getRoot, tmpDir } = withBasePath(basePath);
2416
2462
  const packageManager = await getPreferredPackageManager();
2417
- if (!existsSync13(path15.join(getRoot(), ".next"))) {
2463
+ if (!existsSync13(path16.join(getRoot(), ".next"))) {
2418
2464
  spawnSync4(`${packageManager} faststore build`, {
2419
2465
  shell: true,
2420
2466
  stdio: "inherit"
@@ -2498,7 +2544,7 @@ var Test = class _Test extends Command8 {
2498
2544
  };
2499
2545
 
2500
2546
  // src/commands/generate-types.ts
2501
- import path16 from "path";
2547
+ import path17 from "path";
2502
2548
  import { Args as Args9, Command as Command9 } from "@oclif/core";
2503
2549
  import chalk13 from "chalk";
2504
2550
  var Generate2 = class _Generate extends Command9 {
@@ -2514,7 +2560,7 @@ var Generate2 = class _Generate extends Command9 {
2514
2560
  async run() {
2515
2561
  const { args } = await this.parse(_Generate);
2516
2562
  await genTsTypes(
2517
- path16.isAbsolute(args.path) ? args.path : path16.resolve(process.env.PWD ?? process.cwd(), args.path)
2563
+ path17.isAbsolute(args.path) ? args.path : path17.resolve(process.env.PWD ?? process.cwd(), args.path)
2518
2564
  );
2519
2565
  logger.log(
2520
2566
  `${chalk13.green(
@@ -2529,7 +2575,7 @@ import { Args as Args10, Command as Command10, Flags as Flags4 } from "@oclif/co
2529
2575
  import chalk14 from "chalk";
2530
2576
  import fsExtra8 from "fs-extra";
2531
2577
  import graphql from "graphql";
2532
- import path17 from "path";
2578
+ import path18 from "path";
2533
2579
  import { pathToFileURL as pathToFileURL8 } from "url";
2534
2580
  var { Kind: Kind2, OperationTypeNode, parse: parseGraphql } = graphql;
2535
2581
  var persistedDocumentsName = "persisted-documents.json";
@@ -2555,11 +2601,11 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2555
2601
  async run() {
2556
2602
  const { args, flags } = await this.parse(_CacheGraphql);
2557
2603
  const rootPath = getBasePath();
2558
- const argPath = args?.store && path17.resolve(rootPath, args.store) || rootPath;
2604
+ const argPath = args?.store && path18.resolve(rootPath, args.store) || rootPath;
2559
2605
  const { tmpDir } = withBasePath(argPath);
2560
- const configPath = this.getConfigFile(flags.config && path17.resolve(argPath, flags.config)) || this.getConfigFile(tmpDir) || this.getConfigFile(argPath);
2606
+ const configPath = this.getConfigFile(flags.config && path18.resolve(argPath, flags.config)) || this.getConfigFile(tmpDir) || this.getConfigFile(argPath);
2561
2607
  const persistedDocumentsPath = this.getPersistedDocument(
2562
- flags?.queries && path17.resolve(argPath, flags?.queries) || argPath
2608
+ flags?.queries && path18.resolve(argPath, flags?.queries) || argPath
2563
2609
  ) || this.getPersistedDocument(tmpDir);
2564
2610
  if (!configPath) {
2565
2611
  return this.errorFileNotFound(
@@ -2575,8 +2621,8 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2575
2621
  flags?.queries ?? argPath
2576
2622
  );
2577
2623
  }
2578
- const cachedOperationsPath = path17.join(
2579
- path17.dirname(persistedDocumentsPath),
2624
+ const cachedOperationsPath = path18.join(
2625
+ path18.dirname(persistedDocumentsPath),
2580
2626
  cachedOperationsFileName
2581
2627
  );
2582
2628
  const saveCachedOperationsFile = saveFile(cachedOperationsPath);
@@ -2616,11 +2662,11 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
2616
2662
  return;
2617
2663
  case (rootPath?.endsWith(fileName) && fsExtra8.existsSync(rootPath)):
2618
2664
  return rootPath;
2619
- case fsExtra8.existsSync(path17.join(rootPath ?? "", fileName)):
2620
- return path17.join(rootPath, fileName);
2665
+ case fsExtra8.existsSync(path18.join(rootPath ?? "", fileName)):
2666
+ return path18.join(rootPath, fileName);
2621
2667
  default:
2622
2668
  if (!pathFromRoot) return;
2623
- const filePath = path17.join(
2669
+ const filePath = path18.join(
2624
2670
  rootPath,
2625
2671
  ...Array.isArray(pathFromRoot) ? pathFromRoot : [pathFromRoot]
2626
2672
  );
@@ -2668,7 +2714,7 @@ import chalk15 from "chalk";
2668
2714
  import dotenv2 from "dotenv";
2669
2715
  import fsExtra9 from "fs-extra";
2670
2716
  import { existsSync as existsSync14 } from "fs";
2671
- import path18 from "path";
2717
+ import path19 from "path";
2672
2718
  import { format } from "prettier";
2673
2719
  import { pathToFileURL as pathToFileURL9 } from "url";
2674
2720
  var configFileName3 = "discovery.config.default.js";
@@ -2696,11 +2742,11 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2696
2742
  return;
2697
2743
  case (rootPath?.endsWith(fileName) && fsExtra9.existsSync(rootPath)):
2698
2744
  return rootPath;
2699
- case fsExtra9.existsSync(path18.join(rootPath ?? "", fileName)):
2700
- return path18.join(rootPath, fileName);
2745
+ case fsExtra9.existsSync(path19.join(rootPath ?? "", fileName)):
2746
+ return path19.join(rootPath, fileName);
2701
2747
  default:
2702
2748
  if (!pathFromRoot) return;
2703
- const filePath = path18.join(
2749
+ const filePath = path19.join(
2704
2750
  rootPath,
2705
2751
  ...Array.isArray(pathFromRoot) ? pathFromRoot : [pathFromRoot]
2706
2752
  );
@@ -2720,12 +2766,12 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2720
2766
  async run() {
2721
2767
  const { args, flags } = await this.parse(_GenerateI18n);
2722
2768
  const rootPath = getBasePath();
2723
- const argPath = args?.path && path18.resolve(rootPath, args.path) || rootPath;
2769
+ const argPath = args?.path && path19.resolve(rootPath, args.path) || rootPath;
2724
2770
  const localizationEnabled = await checkAndValidateLocalization(argPath);
2725
2771
  if (!localizationEnabled) {
2726
2772
  return;
2727
2773
  }
2728
- const vtexEnvPath = path18.join(argPath, "vtex.env");
2774
+ const vtexEnvPath = path19.join(argPath, "vtex.env");
2729
2775
  if (existsSync14(vtexEnvPath)) {
2730
2776
  dotenv2.config({ path: vtexEnvPath });
2731
2777
  }
@@ -2743,7 +2789,7 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
2743
2789
  process.exit(1);
2744
2790
  }
2745
2791
  const { tmpDir } = withBasePath(argPath);
2746
- const configPath = this.getConfigFile(flags.config && path18.resolve(argPath, flags.config)) || this.getConfigFile(tmpDir) || this.getConfigFile(argPath);
2792
+ const configPath = this.getConfigFile(flags.config && path19.resolve(argPath, flags.config)) || this.getConfigFile(tmpDir) || this.getConfigFile(argPath);
2747
2793
  if (!configPath) {
2748
2794
  return this.errorFileNotFound(
2749
2795
  configFileName3,