@faststore/cli 4.5.0-dev.6 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +312 -91
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -315,7 +315,7 @@ async function checkDeps(basePath) {
|
|
|
315
315
|
|
|
316
316
|
// src/commands/cms-sync.ts
|
|
317
317
|
import { Args as Args2, Command as Command2, Flags as Flags2 } from "@oclif/core";
|
|
318
|
-
import
|
|
318
|
+
import chalk10 from "chalk";
|
|
319
319
|
import { spawn } from "child_process";
|
|
320
320
|
import { existsSync as existsSync9 } from "fs";
|
|
321
321
|
import path9 from "path";
|
|
@@ -539,15 +539,127 @@ function generateAndUploadSchema({
|
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
// src/utils/generate.ts
|
|
542
|
-
import
|
|
542
|
+
import chalk7 from "chalk";
|
|
543
543
|
import fsExtra4 from "fs-extra";
|
|
544
544
|
import path7 from "path";
|
|
545
545
|
import ora from "ora";
|
|
546
546
|
import { pathToFileURL as pathToFileURL5 } from "url";
|
|
547
547
|
|
|
548
548
|
// src/utils/createNextjsPages.ts
|
|
549
|
-
import
|
|
549
|
+
import fs2 from "fs";
|
|
550
550
|
import path5 from "path";
|
|
551
|
+
import chalk6 from "chalk";
|
|
552
|
+
|
|
553
|
+
// src/utils/readMyAccountCmsRoutes.ts
|
|
554
|
+
import fs from "fs";
|
|
555
|
+
function readStringProp(objectLiteral, propName) {
|
|
556
|
+
const pattern = new RegExp(
|
|
557
|
+
`${propName}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1).)*)\\1`,
|
|
558
|
+
"m"
|
|
559
|
+
);
|
|
560
|
+
const match = pattern.exec(objectLiteral);
|
|
561
|
+
return match?.[2];
|
|
562
|
+
}
|
|
563
|
+
function readMyAccountCmsRoutes(navigationFilePath) {
|
|
564
|
+
if (!fs.existsSync(navigationFilePath)) {
|
|
565
|
+
return [];
|
|
566
|
+
}
|
|
567
|
+
let sourceText;
|
|
568
|
+
try {
|
|
569
|
+
sourceText = fs.readFileSync(navigationFilePath, "utf8");
|
|
570
|
+
} catch {
|
|
571
|
+
logger.warn(
|
|
572
|
+
`[my-account-cms] Could not read navigation file at ${navigationFilePath}`
|
|
573
|
+
);
|
|
574
|
+
return [];
|
|
575
|
+
}
|
|
576
|
+
const withoutLineComments = sourceText.replaceAll(/^\s*\/\/.*$/gm, "");
|
|
577
|
+
const routesMatch = /getMyAccountRoutes\s*\(\s*\{[\s\S]*?routes\s*:\s*\[([\s\S]*?)\]/.exec(
|
|
578
|
+
withoutLineComments
|
|
579
|
+
);
|
|
580
|
+
if (!routesMatch) {
|
|
581
|
+
logger.warn(
|
|
582
|
+
`[my-account-cms] Could not statically parse routes in ${navigationFilePath}; skipping CMS page generation`
|
|
583
|
+
);
|
|
584
|
+
return [];
|
|
585
|
+
}
|
|
586
|
+
const routesBody = routesMatch[1];
|
|
587
|
+
const objectLiterals = routesBody.match(/\{[^{}]*\}/g) ?? [];
|
|
588
|
+
const routes = [];
|
|
589
|
+
for (const literal of objectLiterals) {
|
|
590
|
+
const contentType = readStringProp(literal, "contentType");
|
|
591
|
+
if (!contentType) {
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
const route = readStringProp(literal, "route");
|
|
595
|
+
const title = readStringProp(literal, "title");
|
|
596
|
+
if (!route || !title) {
|
|
597
|
+
logger.warn(
|
|
598
|
+
`[my-account-cms] Skipping CMS route entry missing route/title in ${navigationFilePath}`
|
|
599
|
+
);
|
|
600
|
+
continue;
|
|
601
|
+
}
|
|
602
|
+
routes.push({ route, title, contentType });
|
|
603
|
+
}
|
|
604
|
+
return routes;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/utils/templates/myAccountCmsPage.ts
|
|
608
|
+
var myAccountCmsPageTemplate = ({
|
|
609
|
+
contentType,
|
|
610
|
+
routePath,
|
|
611
|
+
pagePath,
|
|
612
|
+
beforePath,
|
|
613
|
+
afterPath
|
|
614
|
+
}) => `
|
|
615
|
+
import RenderSections, { RenderSectionsBase } from 'src/components/cms/RenderSections'
|
|
616
|
+
import ACCOUNT_COMPONENTS from 'src/components/cms/account/Components'
|
|
617
|
+
import { Layout } from 'src/components/account'
|
|
618
|
+
import {
|
|
619
|
+
myAccountCmsServerSideProps,
|
|
620
|
+
type MyAccountCmsPageProps,
|
|
621
|
+
} from 'src/experimental/myAccountCmsServerSideProps'
|
|
622
|
+
import PageProvider from 'src/sdk/overrides/PageProvider'
|
|
623
|
+
${pagePath ? `import DynamicPage from '${pagePath}'` : ""}
|
|
624
|
+
${beforePath ? `import { default as BeforeSection } from '${beforePath}'` : ""}
|
|
625
|
+
${afterPath ? `import { default as AfterSection } from '${afterPath}'` : ""}
|
|
626
|
+
|
|
627
|
+
export const getServerSideProps = myAccountCmsServerSideProps('${contentType}', '${routePath}')
|
|
628
|
+
|
|
629
|
+
export default function Page({
|
|
630
|
+
globalSections: globalSectionsProp,
|
|
631
|
+
pageSections,
|
|
632
|
+
navigationLabels,
|
|
633
|
+
accountName,
|
|
634
|
+
isRepresentative,
|
|
635
|
+
}: MyAccountCmsPageProps) {
|
|
636
|
+
const { sections: globalSections, settings: globalSettings } =
|
|
637
|
+
globalSectionsProp ?? {}
|
|
638
|
+
|
|
639
|
+
return (
|
|
640
|
+
<PageProvider context={{ globalSettings, navigationLabels }}>
|
|
641
|
+
<RenderSections
|
|
642
|
+
globalSections={globalSections}
|
|
643
|
+
components={ACCOUNT_COMPONENTS}
|
|
644
|
+
>
|
|
645
|
+
<Layout
|
|
646
|
+
accountName={accountName}
|
|
647
|
+
isRepresentative={isRepresentative}
|
|
648
|
+
navigationLabels={navigationLabels}
|
|
649
|
+
>
|
|
650
|
+
${beforePath ? "<BeforeSection />" : ""}
|
|
651
|
+
<RenderSectionsBase
|
|
652
|
+
sections={pageSections}
|
|
653
|
+
components={ACCOUNT_COMPONENTS}
|
|
654
|
+
/>
|
|
655
|
+
${pagePath ? "<DynamicPage />" : ""}
|
|
656
|
+
${afterPath ? "<AfterSection />" : ""}
|
|
657
|
+
</Layout>
|
|
658
|
+
</RenderSections>
|
|
659
|
+
</PageProvider>
|
|
660
|
+
)
|
|
661
|
+
}
|
|
662
|
+
`;
|
|
551
663
|
|
|
552
664
|
// src/utils/templates/myAccountPage.ts
|
|
553
665
|
var myAccountPageTemplate = (pagePath) => `
|
|
@@ -592,37 +704,133 @@ var myAccountPageTemplate = (pagePath) => `
|
|
|
592
704
|
|
|
593
705
|
// src/utils/createNextjsPages.ts
|
|
594
706
|
var ALLOWED_PREFIX_PAGES = ["/pvt/account"];
|
|
707
|
+
var ACCOUNT_ROUTE_PREFIX = "/pvt/account";
|
|
595
708
|
var createExternalPages = ({
|
|
596
709
|
customizationPagesDir,
|
|
597
710
|
corePagesDir,
|
|
598
|
-
baseCustomizationPagesDir
|
|
711
|
+
baseCustomizationPagesDir,
|
|
712
|
+
cmsHandledRoutes
|
|
599
713
|
}) => {
|
|
600
|
-
|
|
714
|
+
fs2.readdirSync(customizationPagesDir).forEach((file) => {
|
|
601
715
|
const filePath = path5.join(customizationPagesDir, file);
|
|
602
716
|
const destinationPath = path5.join(corePagesDir, file);
|
|
603
|
-
if (
|
|
604
|
-
if (!
|
|
605
|
-
|
|
717
|
+
if (fs2.statSync(filePath).isDirectory()) {
|
|
718
|
+
if (!fs2.existsSync(destinationPath)) {
|
|
719
|
+
fs2.mkdirSync(destinationPath, { recursive: true });
|
|
606
720
|
}
|
|
607
721
|
return createExternalPages({
|
|
608
722
|
customizationPagesDir: filePath,
|
|
609
723
|
corePagesDir: destinationPath,
|
|
610
|
-
baseCustomizationPagesDir
|
|
724
|
+
baseCustomizationPagesDir,
|
|
725
|
+
cmsHandledRoutes
|
|
611
726
|
});
|
|
612
727
|
}
|
|
613
728
|
const isReactFile = filePath.endsWith(".tsx");
|
|
614
|
-
const isDestinationAvailable = !
|
|
729
|
+
const isDestinationAvailable = !fs2.existsSync(destinationPath) && !fs2.existsSync(
|
|
615
730
|
path5.join(destinationPath.replace(".tsx", ""), "index.tsx")
|
|
616
731
|
);
|
|
617
732
|
if (isReactFile && isDestinationAvailable) {
|
|
618
|
-
const
|
|
733
|
+
const relativePagePath = filePath.replace(baseCustomizationPagesDir, "").replaceAll(/\\/g, "/").replace(/\.tsx$/, "");
|
|
734
|
+
const normalizedRoute = normalizeAccountRoute(relativePagePath);
|
|
735
|
+
if (cmsHandledRoutes.has(normalizedRoute)) {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
const externalPagePath = `src/customizations/src/pages${relativePagePath}`;
|
|
619
739
|
const content = myAccountPageTemplate(externalPagePath);
|
|
620
|
-
|
|
740
|
+
fs2.writeFileSync(destinationPath, content);
|
|
621
741
|
}
|
|
622
742
|
});
|
|
623
743
|
};
|
|
624
744
|
function isAllowedPrefixPage(file) {
|
|
625
|
-
return ALLOWED_PREFIX_PAGES.some(
|
|
745
|
+
return ALLOWED_PREFIX_PAGES.some(
|
|
746
|
+
(prefix) => file === prefix || file.startsWith(`${prefix}/`)
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
function normalizeAccountRoute(routeOrRelativePath) {
|
|
750
|
+
const withSlash = routeOrRelativePath.startsWith("/") ? routeOrRelativePath : `/${routeOrRelativePath}`;
|
|
751
|
+
const withPvt = withSlash.startsWith("/pvt") ? withSlash : `/pvt${withSlash}`;
|
|
752
|
+
return withPvt.replace(/\/index$/, "") || withPvt;
|
|
753
|
+
}
|
|
754
|
+
function routeToPageFilePath(corePagesDir, route) {
|
|
755
|
+
const relative = route.replace(/^\//, "");
|
|
756
|
+
return path5.join(corePagesDir, `${relative}.tsx`);
|
|
757
|
+
}
|
|
758
|
+
function routeToCustomizationPagePath(customizationPagesDir, route) {
|
|
759
|
+
const relative = route.replace(/^\//, "");
|
|
760
|
+
if (!relative) return null;
|
|
761
|
+
const asFile = path5.join(customizationPagesDir, `${relative}.tsx`);
|
|
762
|
+
if (fs2.existsSync(asFile)) return asFile;
|
|
763
|
+
const asIndex = path5.join(customizationPagesDir, relative, "index.tsx");
|
|
764
|
+
if (fs2.existsSync(asIndex)) return asIndex;
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
function routeToExtensionImportBase(route) {
|
|
768
|
+
return route.replace(ACCOUNT_ROUTE_PREFIX, "").replace(/^\//, "");
|
|
769
|
+
}
|
|
770
|
+
function resolveExtensionPaths(tmpDir, route) {
|
|
771
|
+
const relative = routeToExtensionImportBase(route);
|
|
772
|
+
if (!relative) return {};
|
|
773
|
+
const extensionsDir = path5.join(
|
|
774
|
+
tmpDir,
|
|
775
|
+
"src/customizations/src/myAccount/extensions",
|
|
776
|
+
relative
|
|
777
|
+
);
|
|
778
|
+
const beforeFile = path5.join(extensionsDir, "before.tsx");
|
|
779
|
+
const afterFile = path5.join(extensionsDir, "after.tsx");
|
|
780
|
+
const importBase = `src/customizations/src/myAccount/extensions/${relative}`;
|
|
781
|
+
return {
|
|
782
|
+
...fs2.existsSync(beforeFile) ? { beforePath: `${importBase}/before` } : {},
|
|
783
|
+
...fs2.existsSync(afterFile) ? { afterPath: `${importBase}/after` } : {}
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
function destinationExists(destinationPath) {
|
|
787
|
+
if (fs2.existsSync(destinationPath)) return true;
|
|
788
|
+
const asIndex = path5.join(destinationPath.replace(/\.tsx$/, ""), "index.tsx");
|
|
789
|
+
return fs2.existsSync(asIndex);
|
|
790
|
+
}
|
|
791
|
+
function generateCmsPages({
|
|
792
|
+
routes,
|
|
793
|
+
corePagesDir,
|
|
794
|
+
customizationPagesDir,
|
|
795
|
+
tmpDir
|
|
796
|
+
}) {
|
|
797
|
+
const handled = /* @__PURE__ */ new Set();
|
|
798
|
+
for (const { route, contentType } of routes) {
|
|
799
|
+
const normalizedRoute = normalizeAccountRoute(route);
|
|
800
|
+
if (!isAllowedPrefixPage(normalizedRoute)) {
|
|
801
|
+
logger.warn(
|
|
802
|
+
`${chalk6.yellow("warning")} - Skipping CMS route ${normalizedRoute}: only ${ALLOWED_PREFIX_PAGES.join(", ")} prefixes are allowed`
|
|
803
|
+
);
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
const destinationPath = routeToPageFilePath(corePagesDir, normalizedRoute);
|
|
807
|
+
if (destinationExists(destinationPath)) {
|
|
808
|
+
logger.warn(
|
|
809
|
+
`${chalk6.yellow("warning")} - Skipping CMS route ${normalizedRoute}: native page takes precedence`
|
|
810
|
+
);
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
const customizationTsx = fs2.existsSync(customizationPagesDir) ? routeToCustomizationPagePath(customizationPagesDir, normalizedRoute) : null;
|
|
814
|
+
const pagePath = customizationTsx ? `src/customizations/src/pages${customizationTsx.replace(customizationPagesDir, "").replaceAll(/\\/g, "/").replace(/\.tsx$/, "")}` : void 0;
|
|
815
|
+
const { beforePath, afterPath } = resolveExtensionPaths(
|
|
816
|
+
tmpDir,
|
|
817
|
+
normalizedRoute
|
|
818
|
+
);
|
|
819
|
+
const content = myAccountCmsPageTemplate({
|
|
820
|
+
contentType,
|
|
821
|
+
routePath: normalizedRoute,
|
|
822
|
+
pagePath,
|
|
823
|
+
beforePath,
|
|
824
|
+
afterPath
|
|
825
|
+
});
|
|
826
|
+
fs2.mkdirSync(path5.dirname(destinationPath), { recursive: true });
|
|
827
|
+
fs2.writeFileSync(destinationPath, content);
|
|
828
|
+
handled.add(normalizedRoute);
|
|
829
|
+
logger.log(
|
|
830
|
+
`${chalk6.green("success")} - Generated CMS My Account page for ${normalizedRoute} (${contentType}${pagePath ? ", hybrid" : ""})`
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
return handled;
|
|
626
834
|
}
|
|
627
835
|
function createNextJsPages(basePath) {
|
|
628
836
|
const { tmpDir } = withBasePath(basePath);
|
|
@@ -631,18 +839,30 @@ function createNextJsPages(basePath) {
|
|
|
631
839
|
tmpDir,
|
|
632
840
|
"src/customizations/src/pages"
|
|
633
841
|
);
|
|
634
|
-
|
|
842
|
+
const navigationFilePath = path5.join(
|
|
843
|
+
tmpDir,
|
|
844
|
+
"src/customizations/src/myAccount/navigation.ts"
|
|
845
|
+
);
|
|
846
|
+
const cmsRoutes = readMyAccountCmsRoutes(navigationFilePath);
|
|
847
|
+
const cmsHandledRoutes = generateCmsPages({
|
|
848
|
+
routes: cmsRoutes,
|
|
849
|
+
corePagesDir,
|
|
850
|
+
customizationPagesDir,
|
|
851
|
+
tmpDir
|
|
852
|
+
});
|
|
853
|
+
if (!fs2.existsSync(customizationPagesDir)) {
|
|
635
854
|
return;
|
|
636
855
|
}
|
|
637
856
|
const allPagesAreAllowed = ({
|
|
638
|
-
basePath:
|
|
857
|
+
basePath: pagesBase,
|
|
639
858
|
dirPath
|
|
640
859
|
}) => {
|
|
641
|
-
const items =
|
|
860
|
+
const items = fs2.readdirSync(dirPath, { withFileTypes: true });
|
|
861
|
+
if (items.length === 0) return true;
|
|
642
862
|
return items.every((item) => {
|
|
643
863
|
const itemPath = path5.join(dirPath, item.name);
|
|
644
864
|
if (item.isDirectory()) {
|
|
645
|
-
return allPagesAreAllowed({ basePath:
|
|
865
|
+
return allPagesAreAllowed({ basePath: pagesBase, dirPath: itemPath });
|
|
646
866
|
}
|
|
647
867
|
if (!item.isFile()) {
|
|
648
868
|
return false;
|
|
@@ -651,7 +871,7 @@ function createNextJsPages(basePath) {
|
|
|
651
871
|
if (!isNextPage) {
|
|
652
872
|
return false;
|
|
653
873
|
}
|
|
654
|
-
const relativePath = path5.relative(
|
|
874
|
+
const relativePath = path5.relative(pagesBase, itemPath);
|
|
655
875
|
const normalizedPath = "/" + relativePath.replace(/\\/g, "/").replace(/\.(js|jsx|ts|tsx)$/, "");
|
|
656
876
|
return isAllowedPrefixPage(normalizedPath);
|
|
657
877
|
});
|
|
@@ -668,7 +888,8 @@ function createNextJsPages(basePath) {
|
|
|
668
888
|
createExternalPages({
|
|
669
889
|
customizationPagesDir,
|
|
670
890
|
corePagesDir,
|
|
671
|
-
baseCustomizationPagesDir: customizationPagesDir
|
|
891
|
+
baseCustomizationPagesDir: customizationPagesDir,
|
|
892
|
+
cmsHandledRoutes
|
|
672
893
|
});
|
|
673
894
|
}
|
|
674
895
|
|
|
@@ -965,12 +1186,12 @@ function createTmpFolder(basePath) {
|
|
|
965
1186
|
}
|
|
966
1187
|
mkdirsSync(tmpDir);
|
|
967
1188
|
logger.log(
|
|
968
|
-
`${
|
|
1189
|
+
`${chalk7.green("success")} - Temporary folder ${chalk7.dim(
|
|
969
1190
|
tmpFolderName
|
|
970
1191
|
)} created`
|
|
971
1192
|
);
|
|
972
1193
|
} catch (err) {
|
|
973
|
-
logger.error(`${
|
|
1194
|
+
logger.error(`${chalk7.red("error")} - ${err}`);
|
|
974
1195
|
}
|
|
975
1196
|
}
|
|
976
1197
|
function buildFaststorePackageJson(coreManifest, voltaConfig) {
|
|
@@ -1048,7 +1269,7 @@ function copyCoreFiles(basePath) {
|
|
|
1048
1269
|
});
|
|
1049
1270
|
filterAndCopyPackageJson(basePath);
|
|
1050
1271
|
disableTsConfigStrictRules(basePath);
|
|
1051
|
-
logger.log(`${
|
|
1272
|
+
logger.log(`${chalk7.green("success")} - Core files copied`);
|
|
1052
1273
|
} catch (e) {
|
|
1053
1274
|
logger.error(e);
|
|
1054
1275
|
}
|
|
@@ -1088,7 +1309,7 @@ function copyPublicFiles(basePath) {
|
|
|
1088
1309
|
}
|
|
1089
1310
|
}
|
|
1090
1311
|
});
|
|
1091
|
-
logger.log(`${
|
|
1312
|
+
logger.log(`${chalk7.green("success")} - Public files copied`);
|
|
1092
1313
|
}
|
|
1093
1314
|
} catch (e) {
|
|
1094
1315
|
logger.error(e);
|
|
@@ -1114,7 +1335,7 @@ async function copyCypressFiles(basePath) {
|
|
|
1114
1335
|
userStoreConfig = (await import(pathToFileURL5(path7.resolve(userLegacyStoreConfigFile)).href))?.default;
|
|
1115
1336
|
} else {
|
|
1116
1337
|
logger.info(
|
|
1117
|
-
`${
|
|
1338
|
+
`${chalk7.blue(
|
|
1118
1339
|
"info"
|
|
1119
1340
|
)} - No store config file was found in the root directory`
|
|
1120
1341
|
);
|
|
@@ -1124,7 +1345,7 @@ async function copyCypressFiles(basePath) {
|
|
|
1124
1345
|
overwrite: true,
|
|
1125
1346
|
dereference: true
|
|
1126
1347
|
});
|
|
1127
|
-
logger.log(`${
|
|
1348
|
+
logger.log(`${chalk7.green("success")} - Cypress test files copied`);
|
|
1128
1349
|
}
|
|
1129
1350
|
if (userStoreConfig?.experimental?.cypressVersion > 9) {
|
|
1130
1351
|
copySync3(
|
|
@@ -1151,7 +1372,7 @@ function copyUserStarterToCustomizations(basePath) {
|
|
|
1151
1372
|
createNextJsPages(basePath);
|
|
1152
1373
|
}
|
|
1153
1374
|
} catch (err) {
|
|
1154
|
-
logger.error(`${
|
|
1375
|
+
logger.error(`${chalk7.red("error")} - ${err}`);
|
|
1155
1376
|
}
|
|
1156
1377
|
if (existsSync7(userStoreConfigFile)) {
|
|
1157
1378
|
copySync3(userStoreConfigFile, tmpStoreConfigFile, { dereference: true });
|
|
@@ -1161,12 +1382,12 @@ function copyUserStarterToCustomizations(basePath) {
|
|
|
1161
1382
|
});
|
|
1162
1383
|
} else {
|
|
1163
1384
|
logger.info(
|
|
1164
|
-
`${
|
|
1385
|
+
`${chalk7.blue(
|
|
1165
1386
|
"info"
|
|
1166
1387
|
)} - No store config file was found in the root directory`
|
|
1167
1388
|
);
|
|
1168
1389
|
}
|
|
1169
|
-
logger.log(`${
|
|
1390
|
+
logger.log(`${chalk7.green("success")} - Starter files copied`);
|
|
1170
1391
|
}
|
|
1171
1392
|
async function createCmsWebhookUrlsJsonFile(basePath) {
|
|
1172
1393
|
const {
|
|
@@ -1181,7 +1402,7 @@ async function createCmsWebhookUrlsJsonFile(basePath) {
|
|
|
1181
1402
|
userStoreConfig = (await import(pathToFileURL5(path7.resolve(userLegacyStoreConfigFile)).href))?.default;
|
|
1182
1403
|
} else {
|
|
1183
1404
|
logger.info(
|
|
1184
|
-
`${
|
|
1405
|
+
`${chalk7.blue(
|
|
1185
1406
|
"info"
|
|
1186
1407
|
)} - No store config file was found in the root directory`
|
|
1187
1408
|
);
|
|
@@ -1190,12 +1411,12 @@ async function createCmsWebhookUrlsJsonFile(basePath) {
|
|
|
1190
1411
|
const { webhookUrls } = userStoreConfig?.vtexHeadlessCms;
|
|
1191
1412
|
try {
|
|
1192
1413
|
writeJsonSync(tmpCMSWebhookUrlsFile, { urls: webhookUrls }, { spaces: 2 });
|
|
1193
|
-
logger.log(`${
|
|
1414
|
+
logger.log(`${chalk7.green("success")} - CMS webhook URLs file created`);
|
|
1194
1415
|
} catch (err) {
|
|
1195
|
-
logger.error(`${
|
|
1416
|
+
logger.error(`${chalk7.red("error")} - ${err}`);
|
|
1196
1417
|
}
|
|
1197
1418
|
} else {
|
|
1198
|
-
logger.info(`${
|
|
1419
|
+
logger.info(`${chalk7.blue("info")} - No CMS webhook URLs were provided`);
|
|
1199
1420
|
}
|
|
1200
1421
|
}
|
|
1201
1422
|
async function copyTheme(basePath) {
|
|
@@ -1211,7 +1432,7 @@ async function copyTheme(basePath) {
|
|
|
1211
1432
|
const storeConfig = userStoreConfigFilePath && (importedStoreConfig?.default || importedStoreConfig);
|
|
1212
1433
|
if (!storeConfig)
|
|
1213
1434
|
logger.info(
|
|
1214
|
-
`${
|
|
1435
|
+
`${chalk7.blue(
|
|
1215
1436
|
"info"
|
|
1216
1437
|
)} - No store config file was found in the root directory`
|
|
1217
1438
|
);
|
|
@@ -1224,19 +1445,19 @@ async function copyTheme(basePath) {
|
|
|
1224
1445
|
try {
|
|
1225
1446
|
copyFileSync(customTheme, tmpThemesCustomizationsFile);
|
|
1226
1447
|
logger.log(
|
|
1227
|
-
`${
|
|
1448
|
+
`${chalk7.green("success")} - ${storeConfig.theme} theme has been applied`
|
|
1228
1449
|
);
|
|
1229
1450
|
} catch (err) {
|
|
1230
|
-
logger.error(`${
|
|
1451
|
+
logger.error(`${chalk7.red("error")} - ${err}`);
|
|
1231
1452
|
}
|
|
1232
1453
|
} else {
|
|
1233
1454
|
logger.info(
|
|
1234
|
-
`${
|
|
1455
|
+
`${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`
|
|
1235
1456
|
);
|
|
1236
1457
|
}
|
|
1237
1458
|
} else if (existsSync7(userThemesFileDir) && readdirSync3(userThemesFileDir).length > 0) {
|
|
1238
1459
|
logger.info(
|
|
1239
|
-
`${
|
|
1460
|
+
`${chalk7.blue(
|
|
1240
1461
|
"info"
|
|
1241
1462
|
)} - The theme needs to be added to the config file to be applied. Read more: https://www.faststore.dev/docs/themes/overview`
|
|
1242
1463
|
);
|
|
@@ -1252,9 +1473,9 @@ function updateBuildTime(basePath) {
|
|
|
1252
1473
|
`const buildTime = '${newBuildTime}';`
|
|
1253
1474
|
);
|
|
1254
1475
|
writeFileSync2(tmpSeoConfig, config);
|
|
1255
|
-
logger.log(`${
|
|
1476
|
+
logger.log(`${chalk7.green("success")} - Build time updated`, newBuildTime);
|
|
1256
1477
|
} catch (error) {
|
|
1257
|
-
logger.error(`${
|
|
1478
|
+
logger.error(`${chalk7.red("error")} - Updating build time:`, error);
|
|
1258
1479
|
}
|
|
1259
1480
|
}
|
|
1260
1481
|
async function checkDependencies(basePath, packagesToCheck) {
|
|
@@ -1272,13 +1493,13 @@ async function checkDependencies(basePath, packagesToCheck) {
|
|
|
1272
1493
|
const rootVersion = rootPackageJson.devDependencies[packageName] || rootPackageJson.dependencies[packageName];
|
|
1273
1494
|
if (!coreVersion || !rootVersion) {
|
|
1274
1495
|
logger.warn(
|
|
1275
|
-
`${
|
|
1496
|
+
`${chalk7.yellow(
|
|
1276
1497
|
"warning"
|
|
1277
1498
|
)} - Package ${packageName} not found in both core or root dependencies.`
|
|
1278
1499
|
);
|
|
1279
1500
|
} else if (coreVersion !== rootVersion) {
|
|
1280
1501
|
logger.warn(
|
|
1281
|
-
`${
|
|
1502
|
+
`${chalk7.yellow(
|
|
1282
1503
|
"warning"
|
|
1283
1504
|
)} - Version mismatch detected for ${packageName}.
|
|
1284
1505
|
Core: ${coreVersion}, Customization: ${rootVersion}. Please align both versions to prevent issues`
|
|
@@ -1386,7 +1607,7 @@ async function generate(options) {
|
|
|
1386
1607
|
}
|
|
1387
1608
|
|
|
1388
1609
|
// src/utils/hcms.ts
|
|
1389
|
-
import
|
|
1610
|
+
import chalk8 from "chalk";
|
|
1390
1611
|
import path8 from "path";
|
|
1391
1612
|
import { confirm } from "@inquirer/prompts";
|
|
1392
1613
|
import fsExtra5 from "fs-extra";
|
|
@@ -1497,7 +1718,7 @@ async function mergeCMSFile(fileName, basePath) {
|
|
|
1497
1718
|
} catch (err) {
|
|
1498
1719
|
if (err instanceof SyntaxError) {
|
|
1499
1720
|
console.info(
|
|
1500
|
-
`${
|
|
1721
|
+
`${chalk8.red(
|
|
1501
1722
|
"error"
|
|
1502
1723
|
)} - ${fileName} is a malformed JSON file, ignoring its contents.`
|
|
1503
1724
|
);
|
|
@@ -1515,10 +1736,10 @@ async function mergeCMSFile(fileName, basePath) {
|
|
|
1515
1736
|
JSON.stringify(output)
|
|
1516
1737
|
);
|
|
1517
1738
|
console.log(
|
|
1518
|
-
`${
|
|
1739
|
+
`${chalk8.green("success")} - CMS file ${chalk8.dim(fileName)} created`
|
|
1519
1740
|
);
|
|
1520
1741
|
} catch (err) {
|
|
1521
|
-
console.error(`${
|
|
1742
|
+
console.error(`${chalk8.red("error")} - ${err}`);
|
|
1522
1743
|
}
|
|
1523
1744
|
}
|
|
1524
1745
|
async function mergeCMSFiles(basePath) {
|
|
@@ -1526,13 +1747,13 @@ async function mergeCMSFiles(basePath) {
|
|
|
1526
1747
|
await mergeCMSFile("content-types.json", basePath);
|
|
1527
1748
|
await mergeCMSFile("sections.json", basePath);
|
|
1528
1749
|
} catch (err) {
|
|
1529
|
-
console.error(`${
|
|
1750
|
+
console.error(`${chalk8.red("error")} - ${err}`);
|
|
1530
1751
|
}
|
|
1531
1752
|
}
|
|
1532
1753
|
|
|
1533
1754
|
// src/utils/vtex.ts
|
|
1534
1755
|
import { execSync as execSync2 } from "child_process";
|
|
1535
|
-
import
|
|
1756
|
+
import chalk9 from "chalk";
|
|
1536
1757
|
function runCapture(cmd) {
|
|
1537
1758
|
try {
|
|
1538
1759
|
return execSync2(`${cmd} 2>&1`, { stdio: "pipe" }).toString();
|
|
@@ -1573,8 +1794,8 @@ function getLoggedVtexAccount() {
|
|
|
1573
1794
|
function assertVtexReadyForAccount(account) {
|
|
1574
1795
|
if (!isVtexCliInstalled()) {
|
|
1575
1796
|
logger.error(
|
|
1576
|
-
`${
|
|
1577
|
-
${
|
|
1797
|
+
`${chalk9.red("[Error]")} - The VTEX toolbelt (\`vtex\`) was not found. Install it with ${chalk9.bold("npm i -g vtex")} and try again.
|
|
1798
|
+
${chalk9.dim("Docs: https://developers.vtex.com/docs/guides/vtex-io-documentation-vtex-io-cli-installation-and-command-reference")}`
|
|
1578
1799
|
);
|
|
1579
1800
|
process.exit(1);
|
|
1580
1801
|
return;
|
|
@@ -1583,16 +1804,16 @@ ${chalk8.dim("Docs: https://developers.vtex.com/docs/guides/vtex-io-documentatio
|
|
|
1583
1804
|
const loginHint = account ? `vtex login ${account}` : "vtex login <account>";
|
|
1584
1805
|
if (!loggedAccount) {
|
|
1585
1806
|
logger.error(
|
|
1586
|
-
`${
|
|
1587
|
-
${
|
|
1807
|
+
`${chalk9.red("[Error]")} - You are not logged into the VTEX toolbelt.
|
|
1808
|
+
${chalk9.cyan("Required Action:")} log into the store account by running ${chalk9.bold(loginHint)}.`
|
|
1588
1809
|
);
|
|
1589
1810
|
process.exit(1);
|
|
1590
1811
|
return;
|
|
1591
1812
|
}
|
|
1592
1813
|
if (account && loggedAccount.toLowerCase() !== account.toLowerCase()) {
|
|
1593
1814
|
logger.error(
|
|
1594
|
-
`${
|
|
1595
|
-
${
|
|
1815
|
+
`${chalk9.red("[Error]")} - You are logged into ${chalk9.bold(loggedAccount)}, but this store targets ${chalk9.bold(account)} (\`api.storeId\` in discovery.config.js).
|
|
1816
|
+
${chalk9.cyan("Required Action:")} switch accounts with ${chalk9.bold(`vtex switch ${account}`)} or ${chalk9.bold(loginHint)}.`
|
|
1596
1817
|
);
|
|
1597
1818
|
process.exit(1);
|
|
1598
1819
|
}
|
|
@@ -1620,7 +1841,7 @@ var CmsSync = class _CmsSync extends Command2 {
|
|
|
1620
1841
|
const storeConfig = existsSync9(userStoreConfigFile) ? (await import(pathToFileURL7(path9.resolve(userStoreConfigFile)).href)).default : null;
|
|
1621
1842
|
const source = resolveContentSource(storeConfig?.contentSource?.type);
|
|
1622
1843
|
logger.info(
|
|
1623
|
-
`${
|
|
1844
|
+
`${chalk10.blue("[Info]")} - Detected contentSource "${source}" \u2014 ${CONTENT_SOURCE_ACTION[source]}`
|
|
1624
1845
|
);
|
|
1625
1846
|
switch (source) {
|
|
1626
1847
|
case "CMS":
|
|
@@ -1667,7 +1888,7 @@ var CmsSync = class _CmsSync extends Command2 {
|
|
|
1667
1888
|
let merge;
|
|
1668
1889
|
if (isMyAccountEnabled(storeConfig)) {
|
|
1669
1890
|
logger.info(
|
|
1670
|
-
`${
|
|
1891
|
+
`${chalk10.blue("[Info]")} - Merging My Account sections and content-types into the schema`
|
|
1671
1892
|
);
|
|
1672
1893
|
merge = prepareMyAccountMergeDir(basePath);
|
|
1673
1894
|
}
|
|
@@ -1699,7 +1920,7 @@ var CmsSync = class _CmsSync extends Command2 {
|
|
|
1699
1920
|
};
|
|
1700
1921
|
|
|
1701
1922
|
// src/commands/create.ts
|
|
1702
|
-
import
|
|
1923
|
+
import fs3 from "fs";
|
|
1703
1924
|
import degit from "degit";
|
|
1704
1925
|
import { Args as Args3, Command as Command3 } from "@oclif/core";
|
|
1705
1926
|
import { confirm as confirm2 } from "@inquirer/prompts";
|
|
@@ -1715,7 +1936,7 @@ var Create = class _Create extends Command3 {
|
|
|
1715
1936
|
async run() {
|
|
1716
1937
|
const { args } = await this.parse(_Create);
|
|
1717
1938
|
const discoveryPath = args.path ?? "./discovery";
|
|
1718
|
-
const discoveryFolderExists =
|
|
1939
|
+
const discoveryFolderExists = fs3.existsSync(discoveryPath);
|
|
1719
1940
|
if (discoveryFolderExists) {
|
|
1720
1941
|
const confirmOverride = await confirm2({
|
|
1721
1942
|
message: `It looks like you already have a discovery folder named "${discoveryPath}" in your store. Do you want to override it?`
|
|
@@ -1737,7 +1958,7 @@ var Create = class _Create extends Command3 {
|
|
|
1737
1958
|
|
|
1738
1959
|
// src/commands/dev.ts
|
|
1739
1960
|
import { Args as Args4, Command as Command4, Flags as Flags3 } from "@oclif/core";
|
|
1740
|
-
import
|
|
1961
|
+
import chalk11 from "chalk";
|
|
1741
1962
|
import { spawn as spawn2, spawnSync as spawnSync3 } from "child_process";
|
|
1742
1963
|
import chokidar from "chokidar";
|
|
1743
1964
|
import dotenv from "dotenv";
|
|
@@ -1768,7 +1989,7 @@ async function storeDev(rootDir, tmpDir, coreDir, port) {
|
|
|
1768
1989
|
envVars = dotenv.parse(readFileSync3(vtexEnvPath));
|
|
1769
1990
|
} catch (err) {
|
|
1770
1991
|
logger.log(
|
|
1771
|
-
`${
|
|
1992
|
+
`${chalk11.yellow("warn")} - Error parsing vtex.env file: ${err}`
|
|
1772
1993
|
);
|
|
1773
1994
|
}
|
|
1774
1995
|
}
|
|
@@ -1785,7 +2006,7 @@ async function storeDev(rootDir, tmpDir, coreDir, port) {
|
|
|
1785
2006
|
);
|
|
1786
2007
|
if (!success) {
|
|
1787
2008
|
logger.log(
|
|
1788
|
-
`${
|
|
2009
|
+
`${chalk11.yellow("warn")} - Failed to copy @generated schema back to node_modules, autocomplete and DX might be impacted.`
|
|
1789
2010
|
);
|
|
1790
2011
|
logger.log(
|
|
1791
2012
|
`Attempted to copy from ${path10.join(tmpDir, "@generated")} to ${path10.join(coreDir, "@generated")}`
|
|
@@ -1905,15 +2126,15 @@ var Dev = class _Dev extends Command4 {
|
|
|
1905
2126
|
|
|
1906
2127
|
// src/commands/generate.ts
|
|
1907
2128
|
import { Args as Args5, Command as Command5 } from "@oclif/core";
|
|
1908
|
-
import
|
|
2129
|
+
import chalk12 from "chalk";
|
|
1909
2130
|
|
|
1910
2131
|
// src/utils/file.ts
|
|
1911
|
-
import
|
|
2132
|
+
import fs4 from "fs";
|
|
1912
2133
|
import path11 from "path";
|
|
1913
2134
|
function saveFile(fileLocation) {
|
|
1914
|
-
|
|
2135
|
+
fs4.mkdirSync(path11.dirname(fileLocation), { recursive: true });
|
|
1915
2136
|
return (content) => {
|
|
1916
|
-
|
|
2137
|
+
fs4.writeFileSync(fileLocation, content);
|
|
1917
2138
|
};
|
|
1918
2139
|
}
|
|
1919
2140
|
|
|
@@ -1925,7 +2146,7 @@ import {
|
|
|
1925
2146
|
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
1926
2147
|
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
1927
2148
|
import { buildASTSchema, Kind, parse } from "graphql";
|
|
1928
|
-
import
|
|
2149
|
+
import fs5, { existsSync as existsSync11 } from "fs";
|
|
1929
2150
|
import path12 from "path";
|
|
1930
2151
|
var schemaFileName = "schema.graphql";
|
|
1931
2152
|
async function genTsTypes(at) {
|
|
@@ -2036,7 +2257,7 @@ async function getTypeDefsFromFolder(root, customPath) {
|
|
|
2036
2257
|
extensions: ["graphql"]
|
|
2037
2258
|
}
|
|
2038
2259
|
}).map(
|
|
2039
|
-
(typeDef) => parse(
|
|
2260
|
+
(typeDef) => parse(fs5.readFileSync(typeDef, { encoding: "utf-8" }))
|
|
2040
2261
|
);
|
|
2041
2262
|
}
|
|
2042
2263
|
|
|
@@ -2057,7 +2278,7 @@ var Generate = class _Generate extends Command5 {
|
|
|
2057
2278
|
await generate({ setup: true, basePath });
|
|
2058
2279
|
genTsTypes(args.path ?? tmpDir);
|
|
2059
2280
|
logger.log(
|
|
2060
|
-
`${
|
|
2281
|
+
`${chalk12.green(
|
|
2061
2282
|
"success"
|
|
2062
2283
|
)} - GraphQL schema, types, and optimizations successfully generated \u{1F389}`
|
|
2063
2284
|
);
|
|
@@ -2066,7 +2287,7 @@ var Generate = class _Generate extends Command5 {
|
|
|
2066
2287
|
|
|
2067
2288
|
// src/commands/prepare.ts
|
|
2068
2289
|
import { Args as Args6, Command as Command6 } from "@oclif/core";
|
|
2069
|
-
import
|
|
2290
|
+
import fs6 from "fs";
|
|
2070
2291
|
import path13 from "path";
|
|
2071
2292
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
2072
2293
|
var Prepare = class _Prepare extends Command6 {
|
|
@@ -2093,16 +2314,16 @@ var Prepare = class _Prepare extends Command6 {
|
|
|
2093
2314
|
}
|
|
2094
2315
|
};
|
|
2095
2316
|
function copyFolder(sourceDir, targetDir) {
|
|
2096
|
-
if (!
|
|
2097
|
-
|
|
2317
|
+
if (!fs6.existsSync(targetDir)) {
|
|
2318
|
+
fs6.mkdirSync(targetDir, { recursive: true });
|
|
2098
2319
|
}
|
|
2099
|
-
const files =
|
|
2320
|
+
const files = fs6.readdirSync(sourceDir);
|
|
2100
2321
|
for (const file of files) {
|
|
2101
2322
|
const sourcePath = path13.join(sourceDir, file);
|
|
2102
2323
|
const targetPath = path13.join(targetDir, file);
|
|
2103
|
-
const stat =
|
|
2324
|
+
const stat = fs6.statSync(sourcePath);
|
|
2104
2325
|
if (stat.isFile()) {
|
|
2105
|
-
|
|
2326
|
+
fs6.copyFileSync(sourcePath, targetPath);
|
|
2106
2327
|
console.log(`Copied file: ${sourcePath} -> ${targetPath}`);
|
|
2107
2328
|
} else if (stat.isDirectory()) {
|
|
2108
2329
|
copyFolder(sourcePath, targetPath);
|
|
@@ -2219,7 +2440,7 @@ var Test = class _Test extends Command8 {
|
|
|
2219
2440
|
// src/commands/generate-types.ts
|
|
2220
2441
|
import path15 from "path";
|
|
2221
2442
|
import { Args as Args9, Command as Command9 } from "@oclif/core";
|
|
2222
|
-
import
|
|
2443
|
+
import chalk13 from "chalk";
|
|
2223
2444
|
var Generate2 = class _Generate extends Command9 {
|
|
2224
2445
|
static hidden = true;
|
|
2225
2446
|
static flags = {};
|
|
@@ -2236,7 +2457,7 @@ var Generate2 = class _Generate extends Command9 {
|
|
|
2236
2457
|
path15.isAbsolute(args.path) ? args.path : path15.resolve(process.env.PWD ?? process.cwd(), args.path)
|
|
2237
2458
|
);
|
|
2238
2459
|
logger.log(
|
|
2239
|
-
`${
|
|
2460
|
+
`${chalk13.green(
|
|
2240
2461
|
"success"
|
|
2241
2462
|
)} - GraphQL schema, types, and optimizations successfully generated \u{1F389}`
|
|
2242
2463
|
);
|
|
@@ -2245,7 +2466,7 @@ var Generate2 = class _Generate extends Command9 {
|
|
|
2245
2466
|
|
|
2246
2467
|
// src/commands/cache-graphql.ts
|
|
2247
2468
|
import { Args as Args10, Command as Command10, Flags as Flags4 } from "@oclif/core";
|
|
2248
|
-
import
|
|
2469
|
+
import chalk14 from "chalk";
|
|
2249
2470
|
import fsExtra7 from "fs-extra";
|
|
2250
2471
|
import graphql from "graphql";
|
|
2251
2472
|
import path16 from "path";
|
|
@@ -2300,13 +2521,13 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
|
|
|
2300
2521
|
);
|
|
2301
2522
|
const saveCachedOperationsFile = saveFile(cachedOperationsPath);
|
|
2302
2523
|
if (fsExtra7.pathExistsSync(tmpDir))
|
|
2303
|
-
logger.info(`${
|
|
2304
|
-
logger.info(`${
|
|
2524
|
+
logger.info(`${chalk14.blue("[Info]")} - .faststore Path at: ${tmpDir}`);
|
|
2525
|
+
logger.info(`${chalk14.blue("[Info]")} - Config file location: ${configPath}`);
|
|
2305
2526
|
logger.info(
|
|
2306
|
-
`${
|
|
2527
|
+
`${chalk14.blue("[Info]")} - Persisted documents at: ${persistedDocumentsPath}`
|
|
2307
2528
|
);
|
|
2308
2529
|
logger.info(
|
|
2309
|
-
`${
|
|
2530
|
+
`${chalk14.blue("[Info]")} - Cached operations output: ${cachedOperationsPath}`
|
|
2310
2531
|
);
|
|
2311
2532
|
const { default: persistedDocuments } = await import(pathToFileURL8(persistedDocumentsPath).href, { with: { type: "json" } });
|
|
2312
2533
|
const cachedQueries = getQueries(persistedDocuments);
|
|
@@ -2315,7 +2536,7 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
|
|
|
2315
2536
|
`
|
|
2316
2537
|
);
|
|
2317
2538
|
logger.info(
|
|
2318
|
-
`${
|
|
2539
|
+
`${chalk14.green("[Success]")} - GraphQL queries cached with success: \u{1F389}
|
|
2319
2540
|
Queries: ${cachedQueries.join(", ")}`
|
|
2320
2541
|
);
|
|
2321
2542
|
}
|
|
@@ -2352,7 +2573,7 @@ var CacheGraphql = class _CacheGraphql extends Command10 {
|
|
|
2352
2573
|
}
|
|
2353
2574
|
errorFileNotFound(fileName, rootDir) {
|
|
2354
2575
|
logger.error(
|
|
2355
|
-
`${
|
|
2576
|
+
`${chalk14.red("[Error]")} - Couldn't find ${fileName} at ${rootDir}`
|
|
2356
2577
|
);
|
|
2357
2578
|
process.exit(1);
|
|
2358
2579
|
}
|
|
@@ -2383,7 +2604,7 @@ var getQueries = (persistedDocuments) => {
|
|
|
2383
2604
|
// src/commands/generate-i18n.ts
|
|
2384
2605
|
import { Args as Args11, Command as Command11, Flags as Flags5 } from "@oclif/core";
|
|
2385
2606
|
import { FastStoreSDK } from "@vtex/faststore-sdk";
|
|
2386
|
-
import
|
|
2607
|
+
import chalk15 from "chalk";
|
|
2387
2608
|
import dotenv2 from "dotenv";
|
|
2388
2609
|
import fsExtra8 from "fs-extra";
|
|
2389
2610
|
import { existsSync as existsSync13 } from "fs";
|
|
@@ -2432,7 +2653,7 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
|
|
|
2432
2653
|
}
|
|
2433
2654
|
errorFileNotFound(fileName, rootDir) {
|
|
2434
2655
|
logger.error(
|
|
2435
|
-
`${
|
|
2656
|
+
`${chalk15.red("[Error]")} - Couldn't find ${fileName} at ${rootDir}`
|
|
2436
2657
|
);
|
|
2437
2658
|
process.exit(1);
|
|
2438
2659
|
}
|
|
@@ -2451,13 +2672,13 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
|
|
|
2451
2672
|
const { VTEX_ACCOUNT, FS_DISCOVERY_APP_KEY, FS_DISCOVERY_APP_TOKEN } = process.env;
|
|
2452
2673
|
const hasCredentials = VTEX_ACCOUNT && FS_DISCOVERY_APP_KEY && FS_DISCOVERY_APP_TOKEN;
|
|
2453
2674
|
if (!hasCredentials) {
|
|
2454
|
-
logger.error(`${
|
|
2675
|
+
logger.error(`${chalk15.red("[Error]")} - Missing VTEX credentials.
|
|
2455
2676
|
|
|
2456
|
-
${
|
|
2677
|
+
${chalk15.cyan("Required Action:")}
|
|
2457
2678
|
|
|
2458
|
-
Check your FastStore WebOps Settings page - to work in production, it should contain the following variables: ${
|
|
2679
|
+
Check your FastStore WebOps Settings page - to work in production, it should contain the following variables: ${chalk15.cyan("VTEX_ACCOUNT")}, ${chalk15.cyan("FS_DISCOVERY_APP_KEY")}, ${chalk15.cyan("FS_DISCOVERY_APP_TOKEN")}.
|
|
2459
2680
|
|
|
2460
|
-
If running locally, please check your ${
|
|
2681
|
+
If running locally, please check your ${chalk15.bold("vtex.env")} file, it should also contain those variables.
|
|
2461
2682
|
`);
|
|
2462
2683
|
process.exit(1);
|
|
2463
2684
|
}
|
|
@@ -2473,8 +2694,8 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
|
|
|
2473
2694
|
}
|
|
2474
2695
|
const saveConfigFile = saveFile(configPath);
|
|
2475
2696
|
if (fsExtra8.pathExistsSync(tmpDir))
|
|
2476
|
-
logger.info(`${
|
|
2477
|
-
logger.info(`${
|
|
2697
|
+
logger.info(`${chalk15.blue("[Info]")} - .faststore Path at: ${tmpDir}`);
|
|
2698
|
+
logger.info(`${chalk15.blue("[Info]")} - Config file location: ${configPath}`);
|
|
2478
2699
|
const discoveryConfig = await import(pathToFileURL9(configPath).href);
|
|
2479
2700
|
const faststore = new FastStoreSDK({
|
|
2480
2701
|
account: VTEX_ACCOUNT,
|
|
@@ -2503,7 +2724,7 @@ var GenerateI18n = class _GenerateI18n extends Command11 {
|
|
|
2503
2724
|
)
|
|
2504
2725
|
);
|
|
2505
2726
|
logger.info(
|
|
2506
|
-
`${
|
|
2727
|
+
`${chalk15.green("success")} - i18n configuration successfully generated \u{1F389}`
|
|
2507
2728
|
);
|
|
2508
2729
|
}
|
|
2509
2730
|
};
|