@faststore/cli 3.0.79 → 3.0.82
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/README.md +43 -25
- package/dist/commands/build.d.ts +4 -0
- package/dist/commands/build.js +24 -13
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/cms-sync.d.ts +4 -0
- package/dist/commands/cms-sync.js +12 -4
- package/dist/commands/cms-sync.js.map +1 -1
- package/dist/commands/dev.d.ts +4 -0
- package/dist/commands/dev.js +16 -8
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/generate-graphql.d.ts +4 -0
- package/dist/commands/generate-graphql.js +15 -7
- package/dist/commands/generate-graphql.js.map +1 -1
- package/dist/commands/start.d.ts +4 -0
- package/dist/commands/start.js +11 -2
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/test.d.ts +4 -0
- package/dist/commands/test.js +14 -5
- package/dist/commands/test.js.map +1 -1
- package/dist/utils/directory.d.ts +17 -25
- package/dist/utils/directory.js +54 -59
- package/dist/utils/directory.js.map +1 -1
- package/dist/utils/directory.test.d.ts +1 -0
- package/dist/utils/directory.test.js +155 -0
- package/dist/utils/directory.test.js.map +1 -0
- package/dist/utils/generate.d.ts +2 -1
- package/dist/utils/generate.js +53 -45
- package/dist/utils/generate.js.map +1 -1
- package/dist/utils/hcms.d.ts +2 -2
- package/dist/utils/hcms.js +8 -7
- package/dist/utils/hcms.js.map +1 -1
- package/dist/utils/hcms.test.js +5 -4
- package/dist/utils/hcms.test.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/dist/utils/contentFromPath.d.ts +0 -10
- package/dist/utils/contentFromPath.js +0 -17
- package/dist/utils/contentFromPath.js.map +0 -1
package/dist/utils/directory.js
CHANGED
|
@@ -1,65 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.withBasePath = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const getRoot = () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
7
|
+
const withBasePath = (basepath) => {
|
|
8
|
+
const tmpFolderName = '.faststore';
|
|
9
|
+
const getRoot = () => {
|
|
10
|
+
if (process.env.OCLIF_COMPILATION) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
if (basepath.endsWith(tmpFolderName)) {
|
|
14
|
+
// if the current working directory is the build folder (tmp folder), return the starter root
|
|
15
|
+
// this makes sure the semantics of the starter root are consistent with the directories declared below
|
|
16
|
+
return path_1.default.join(basepath, '..');
|
|
17
|
+
}
|
|
18
|
+
return basepath;
|
|
19
|
+
};
|
|
20
|
+
/*
|
|
21
|
+
* This will loop from the basepath until the process.cwd() looking for node_modules/@faststore/core
|
|
22
|
+
*
|
|
23
|
+
* If it reaches process.cwd() (or /, as a safeguard), without finding it, it will throw an exception
|
|
24
|
+
*/
|
|
25
|
+
const getCorePackagePath = () => {
|
|
26
|
+
const coreFromNodeModules = path_1.default.join('node_modules', '@faststore', 'core');
|
|
27
|
+
const resolvedCwd = path_1.default.resolve(process.cwd());
|
|
28
|
+
const parents = [];
|
|
29
|
+
let attemptedPath;
|
|
30
|
+
do {
|
|
31
|
+
attemptedPath = path_1.default.join(basepath, ...parents, coreFromNodeModules);
|
|
32
|
+
if (node_fs_1.default.existsSync(attemptedPath)) {
|
|
33
|
+
return attemptedPath;
|
|
34
|
+
}
|
|
35
|
+
parents.push('..');
|
|
36
|
+
} while (path_1.default.resolve(attemptedPath) !== resolvedCwd || path_1.default.resolve(attemptedPath) !== '/');
|
|
37
|
+
throw `Could not find @node_modules on ${basepath} or any of its parents until ${attemptedPath}`;
|
|
38
|
+
};
|
|
39
|
+
const tmpDir = path_1.default.join(getRoot(), tmpFolderName);
|
|
40
|
+
const userSrcDir = path_1.default.join(getRoot(), 'src');
|
|
41
|
+
return {
|
|
42
|
+
getRoot,
|
|
43
|
+
userDir: getRoot(),
|
|
44
|
+
userSrcDir,
|
|
45
|
+
userThemesFileDir: path_1.default.join(userSrcDir, 'themes'),
|
|
46
|
+
userCMSDir: path_1.default.join(getRoot(), 'cms', 'faststore'),
|
|
47
|
+
userStoreConfigFile: path_1.default.join(getRoot(), 'faststore.config.js'),
|
|
48
|
+
tmpFolderName,
|
|
49
|
+
tmpDir,
|
|
50
|
+
tmpCustomizationsSrcDir: path_1.default.join(tmpDir, 'src', 'customizations', 'src'),
|
|
51
|
+
tmpThemesCustomizationsFile: path_1.default.join(tmpDir, 'src', 'customizations', 'src', 'themes', 'index.scss'),
|
|
52
|
+
tmpCMSDir: path_1.default.join(tmpDir, 'cms', 'faststore'),
|
|
53
|
+
tmpCMSWebhookUrlsFile: path_1.default.join(tmpDir, 'cms-webhook-urls.json'),
|
|
54
|
+
tmpStoreConfigFile: path_1.default.join(tmpDir, 'src', 'customizations', 'faststore.config.js'),
|
|
55
|
+
coreDir: getCorePackagePath(),
|
|
56
|
+
coreCMSDir: path_1.default.join(getCorePackagePath(), 'cms', 'faststore'),
|
|
57
|
+
};
|
|
19
58
|
};
|
|
20
|
-
exports.
|
|
21
|
-
// starter root
|
|
22
|
-
exports.userDir = (0, exports.getRoot)();
|
|
23
|
-
// node_modules folder for faststorer packages
|
|
24
|
-
exports.faststoreDir = path_1.default.join(exports.userDir, 'node_modules', '@faststore');
|
|
25
|
-
// build folder dir
|
|
26
|
-
exports.tmpDir = path_1.default.join(exports.userDir, exports.tmpFolderName);
|
|
27
|
-
// node_modules folder for @faststore/core
|
|
28
|
-
exports.coreFolderName = 'core';
|
|
29
|
-
exports.coreDir = path_1.default.join(exports.faststoreDir, exports.coreFolderName);
|
|
30
|
-
// starter src/ folder
|
|
31
|
-
exports.srcFolderName = 'src';
|
|
32
|
-
exports.userSrcDir = path_1.default.join(exports.userDir, exports.srcFolderName);
|
|
33
|
-
// build folder's folder to which starter files should always be copied
|
|
34
|
-
exports.customizationsFolderName = 'customizations';
|
|
35
|
-
// build folder's root folder for starter files
|
|
36
|
-
exports.tmpCustomizationsDir = path_1.default.join(exports.tmpDir, 'src', exports.customizationsFolderName);
|
|
37
|
-
// build folder's starter src files
|
|
38
|
-
exports.tmpCustomizationsSrcDir = path_1.default.join(exports.tmpCustomizationsDir, exports.srcFolderName);
|
|
39
|
-
// starter's folder for themes
|
|
40
|
-
exports.userThemesFileDir = path_1.default.join(exports.userSrcDir, 'themes');
|
|
41
|
-
// build folder's dir for theme
|
|
42
|
-
exports.tmpThemesCustomizationsFileDir = path_1.default.join(exports.tmpCustomizationsSrcDir, 'themes', 'index.scss');
|
|
43
|
-
// path segment of cms files for faststore
|
|
44
|
-
exports.cmsFolderName = path_1.default.join('cms', 'faststore');
|
|
45
|
-
// build folder's cms folder
|
|
46
|
-
exports.tmpCMSDir = path_1.default.join(exports.tmpDir, exports.cmsFolderName);
|
|
47
|
-
// node_modules folder for @faststore/core's cms folder
|
|
48
|
-
exports.coreCMSDir = path_1.default.join(exports.coreDir, exports.cmsFolderName);
|
|
49
|
-
// starter folder's cms folder
|
|
50
|
-
exports.userCMSDir = path_1.default.join(exports.userDir, exports.cmsFolderName);
|
|
51
|
-
// file name for faststore configs
|
|
52
|
-
exports.configFileName = 'faststore.config.js';
|
|
53
|
-
// starter's config file dir
|
|
54
|
-
exports.userStoreConfigFileDir = path_1.default.join(exports.userDir, exports.configFileName);
|
|
55
|
-
// build folder's config file dir
|
|
56
|
-
exports.tmpStoreConfigFileDir = path_1.default.join(exports.tmpCustomizationsDir, exports.configFileName);
|
|
57
|
-
// starter's node_modules
|
|
58
|
-
exports.userNodeModulesDir = path_1.default.join(exports.userDir, 'node_modules');
|
|
59
|
-
// build folder's node_modules
|
|
60
|
-
exports.tmpNodeModulesDir = path_1.default.join(exports.tmpDir, 'node_modules');
|
|
61
|
-
// cms webhook config file name
|
|
62
|
-
exports.cmsWebhookUrlsFileName = 'cms-webhook-urls.json';
|
|
63
|
-
// build folder's dir for webhook config
|
|
64
|
-
exports.tmpCmsWebhookUrlsFileDir = path_1.default.join(exports.tmpDir, exports.cmsWebhookUrlsFileName);
|
|
59
|
+
exports.withBasePath = withBasePath;
|
|
65
60
|
//# sourceMappingURL=directory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/utils/directory.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/utils/directory.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AACvB,8DAAwB;AAEjB,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC/C,MAAM,aAAa,GAAG,YAAY,CAAA;IAElC,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;YACjC,OAAO,EAAE,CAAA;SACV;QAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;YACpC,6FAA6F;YAC7F,uGAAuG;YACvG,OAAO,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;SACjC;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAA;IAED;;;;OAIG;IACH,MAAM,kBAAkB,GAAG,GAAG,EAAE;QAC9B,MAAM,mBAAmB,GAAG,cAAI,CAAC,IAAI,CAAC,cAAc,EAAE,YAAY,EAAE,MAAM,CAAC,CAAA;QAC3E,MAAM,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QAE/C,MAAM,OAAO,GAAa,EAAE,CAAA;QAE5B,IA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ChD,qBAAqB,EAAE,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,uBAAuB,CAAC;QACjE,kBAAkB,EAAE,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,CAAC;QAErF,OAAO,EAAE,kBAAkB,EAAE;QAC7B,UAAU,EAAE,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC;KAChE,CAAA;AACH,CAAC,CAAA;AAhEY,QAAA,YAAY,gBAgExB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
+
const directory_1 = require("./directory");
|
|
6
|
+
const pathsToMatch = (expected, desired) => {
|
|
7
|
+
const expectedResolved = path_1.default.resolve(expected);
|
|
8
|
+
const desiredResolved = path_1.default.resolve(desired);
|
|
9
|
+
return expectedResolved === desiredResolved;
|
|
10
|
+
};
|
|
11
|
+
describe('withBasePath as the current dir `.`', () => {
|
|
12
|
+
const basePath = '.';
|
|
13
|
+
describe('tmpDir', () => {
|
|
14
|
+
it('is the basePath + .faststore', () => {
|
|
15
|
+
const { tmpDir: tmpDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
16
|
+
expect(pathsToMatch(tmpDirWithBase, './.faststore')).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('userDir', () => {
|
|
20
|
+
it("returns the directory of the starter's package.json", () => {
|
|
21
|
+
const { userSrcDir: userSrcDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
22
|
+
expect(pathsToMatch(userSrcDirWithBase, './src')).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('tmpCustomizationsSrcDir', () => {
|
|
26
|
+
it('returns the directory of customizations directory on the tmp dir', () => {
|
|
27
|
+
const { tmpCustomizationsSrcDir: tmpCustomizationsSrcDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
28
|
+
expect(pathsToMatch(tmpCustomizationsSrcDirWithBase, './.faststore/src/customizations/src')).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('userThemesFileDir', () => {
|
|
32
|
+
it("returns the directory of the starter's theme directory", () => {
|
|
33
|
+
const { userThemesFileDir: userThemesFileDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
34
|
+
expect(pathsToMatch(userThemesFileDirWithBase, './src/themes')).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('tmpThemesCustomizationsFile', () => {
|
|
38
|
+
it('returns the path of the theme file on the .faststore dir', () => {
|
|
39
|
+
const { tmpThemesCustomizationsFile: tmpThemesCustomizationsFileWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
40
|
+
expect(pathsToMatch(tmpThemesCustomizationsFileWithBase, './.faststore/src/customizations/src/themes/index.scss')).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe('tmpCMSDir', () => {
|
|
44
|
+
it('returns the path of the CMS dir on the .faststore dir', () => {
|
|
45
|
+
const { tmpCMSDir: tmpCMSDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
46
|
+
expect(pathsToMatch(tmpCMSDirWithBase, './.faststore/cms/faststore')).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe('userCMSDir', () => {
|
|
50
|
+
it('returns the path of the CMS dir on the user dir', () => {
|
|
51
|
+
const { userCMSDir: userCMSDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
52
|
+
expect(pathsToMatch(userCMSDirWithBase, './cms/faststore')).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('tmpCMSWebhookUrlsFile', () => {
|
|
56
|
+
it('returns the path of the CMS webhooks file on the .faststore dir', () => {
|
|
57
|
+
const { tmpCMSWebhookUrlsFile: tmpCMSWebhookUrlsFileWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
58
|
+
expect(pathsToMatch(tmpCMSWebhookUrlsFileWithBase, './.faststore/cms-webhook-urls.json')).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
describe('userStoreConfigFile', () => {
|
|
62
|
+
it('returns the path of the user faststore.config file', () => {
|
|
63
|
+
const { userStoreConfigFile: userStoreConfigFileWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
64
|
+
expect(pathsToMatch(userStoreConfigFileWithBase, './faststore.config.js')).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('tmpStoreConfigFile', () => {
|
|
68
|
+
it('returns the path of the faststore.config file in the customizations dir', () => {
|
|
69
|
+
const { tmpStoreConfigFile: tmpStoreConfigFileWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
70
|
+
expect(pathsToMatch(tmpStoreConfigFileWithBase, './.faststore/src/customizations/faststore.config.js')).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('withBasePath as an arbitrary dir', () => {
|
|
75
|
+
const basePath = path_1.default.join(__dirname, '..', '__mocks__', 'store');
|
|
76
|
+
describe('coreDir', () => {
|
|
77
|
+
it('is the faststoreDir + core', () => {
|
|
78
|
+
const { coreDir: coreDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
79
|
+
expect(pathsToMatch(coreDirWithBase, './src/__mocks__/store/node_modules/@faststore/core')).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
describe('when is in a monorepo', () => {
|
|
82
|
+
it('can look at its parent until it reaches the monorepo directory', () => {
|
|
83
|
+
const { coreDir: coreDirWithBase } = (0, directory_1.withBasePath)(path_1.default.join(__dirname, '..', '__mocks__', 'monorepo', 'discovery'));
|
|
84
|
+
expect(pathsToMatch(coreDirWithBase, './src/__mocks__/monorepo/node_modules/@faststore/core')).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
describe('tmpDir', () => {
|
|
89
|
+
it('is the basePath + .faststore', () => {
|
|
90
|
+
const { tmpDir: tmpDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
91
|
+
expect(pathsToMatch(tmpDirWithBase, './src/__mocks__/store/.faststore')).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe('userDir', () => {
|
|
95
|
+
it("returns the directory of the starter's package.json", () => {
|
|
96
|
+
const { userSrcDir: userSrcDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
97
|
+
expect(pathsToMatch(userSrcDirWithBase, './src/__mocks__/store/src')).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
describe('tmpCustomizationsSrcDir', () => {
|
|
101
|
+
it('returns the directory of customizations directory on the tmp dir', () => {
|
|
102
|
+
const { tmpCustomizationsSrcDir: tmpCustomizationsSrcDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
103
|
+
expect(pathsToMatch(tmpCustomizationsSrcDirWithBase, './src/__mocks__/store/.faststore/src/customizations/src')).toBe(true);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe('userThemesFileDir', () => {
|
|
107
|
+
it("returns the directory of the starter's theme directory", () => {
|
|
108
|
+
const { userThemesFileDir: userThemesFileDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
109
|
+
expect(pathsToMatch(userThemesFileDirWithBase, './src/__mocks__/store/src/themes')).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
describe('tmpThemesCustomizationsFile', () => {
|
|
113
|
+
it('returns the path of the theme file on the .faststore dir', () => {
|
|
114
|
+
const { tmpThemesCustomizationsFile: tmpThemesCustomizationsFileWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
115
|
+
expect(pathsToMatch(tmpThemesCustomizationsFileWithBase, './src/__mocks__/store/.faststore/src/customizations/src/themes/index.scss')).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('tmpCMSDir', () => {
|
|
119
|
+
it('returns the path of the CMS dir on the .faststore dir', () => {
|
|
120
|
+
const { tmpCMSDir: tmpCMSDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
121
|
+
expect(pathsToMatch(tmpCMSDirWithBase, './src/__mocks__/store/.faststore/cms/faststore')).toBe(true);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe('userCMSDir', () => {
|
|
125
|
+
it('returns the path of the CMS dir on the user dir', () => {
|
|
126
|
+
const { userCMSDir: userCMSDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
127
|
+
expect(pathsToMatch(userCMSDirWithBase, './src/__mocks__/store/cms/faststore')).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
describe('coreCMSDir', () => {
|
|
131
|
+
it('returns the path of the CMS dir on @faststore/core package', () => {
|
|
132
|
+
const { coreCMSDir: coreCMSDirWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
133
|
+
expect(pathsToMatch(coreCMSDirWithBase, './src/__mocks__/store/node_modules/@faststore/core/cms/faststore')).toBe(true);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
describe('tmpCMSWebhookUrlsFile', () => {
|
|
137
|
+
it('returns the path of the CMS webhooks file on the .faststore dir', () => {
|
|
138
|
+
const { tmpCMSWebhookUrlsFile: tmpCMSWebhookUrlsFileWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
139
|
+
expect(pathsToMatch(tmpCMSWebhookUrlsFileWithBase, './src/__mocks__/store/.faststore/cms-webhook-urls.json')).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe('userStoreConfigFile', () => {
|
|
143
|
+
it('returns the path of the user faststore.config file', () => {
|
|
144
|
+
const { userStoreConfigFile: userStoreConfigFileWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
145
|
+
expect(pathsToMatch(userStoreConfigFileWithBase, './src/__mocks__/store/faststore.config.js')).toBe(true);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
describe('tmpStoreConfigFile', () => {
|
|
149
|
+
it('returns the path of the faststore.config file in the customizations dir', () => {
|
|
150
|
+
const { tmpStoreConfigFile: tmpStoreConfigFileWithBase } = (0, directory_1.withBasePath)(basePath);
|
|
151
|
+
expect(pathsToMatch(tmpStoreConfigFileWithBase, './src/__mocks__/store/.faststore/src/customizations/faststore.config.js')).toBe(true);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
//# sourceMappingURL=directory.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.test.js","sourceRoot":"","sources":["../../src/utils/directory.test.ts"],"names":[],"mappings":";;;AAAA,wDAAuB;AACvB,2CAA0C;AAE1C,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAE,EAAE;IACzD,MAAM,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAE7C,OAAO,gBAAgB,KAAK,eAAe,CAAA;AAC7C,CAAC,CAAA;AAED,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,MAAM,QAAQ,GAAG,GAAG,CAAA;IAEpB,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;QACtB,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACtC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,IAAA,wBAAY,EAAC,QAAQ,CAAC,CAAA;YAEzD,MAAM,CAAC,YAAY,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,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AAC,0BAA0B,EAAE,yEAAyE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxI,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/utils/generate.d.ts
CHANGED
package/dist/utils/generate.js
CHANGED
|
@@ -8,13 +8,14 @@ const path_1 = tslib_1.__importDefault(require("path"));
|
|
|
8
8
|
const directory_1 = require("./directory");
|
|
9
9
|
// package.json is copied manually after filtering its content
|
|
10
10
|
const ignorePaths = ['package.json', 'node_modules', 'cypress.config.ts'];
|
|
11
|
-
function createTmpFolder() {
|
|
11
|
+
function createTmpFolder(basePath) {
|
|
12
|
+
const { tmpDir, tmpFolderName } = (0, directory_1.withBasePath)(basePath);
|
|
12
13
|
try {
|
|
13
|
-
if ((0, fs_extra_1.existsSync)(
|
|
14
|
-
(0, fs_extra_1.removeSync)(
|
|
14
|
+
if ((0, fs_extra_1.existsSync)(tmpDir)) {
|
|
15
|
+
(0, fs_extra_1.removeSync)(tmpDir);
|
|
15
16
|
}
|
|
16
|
-
(0, fs_extra_1.mkdirsSync)(
|
|
17
|
-
console.log(`${chalk_1.default.green('success')} - Temporary folder ${chalk_1.default.dim(
|
|
17
|
+
(0, fs_extra_1.mkdirsSync)(tmpDir);
|
|
18
|
+
console.log(`${chalk_1.default.green('success')} - Temporary folder ${chalk_1.default.dim(tmpFolderName)} created`);
|
|
18
19
|
}
|
|
19
20
|
catch (err) {
|
|
20
21
|
console.error(`${chalk_1.default.red('error')} - ${err}`);
|
|
@@ -25,18 +26,20 @@ function createTmpFolder() {
|
|
|
25
26
|
* where sometimes the package.json from the .faststore folder
|
|
26
27
|
* took precedence over @faststore/core's package.json.
|
|
27
28
|
*/
|
|
28
|
-
function filterAndCopyPackageJson() {
|
|
29
|
-
const
|
|
29
|
+
function filterAndCopyPackageJson(basePath) {
|
|
30
|
+
const { coreDir, tmpDir } = (0, directory_1.withBasePath)(basePath);
|
|
31
|
+
const corePackageJsonPath = path_1.default.join(coreDir, 'package.json');
|
|
30
32
|
const corePackageJsonFile = (0, fs_extra_1.readFileSync)(corePackageJsonPath, 'utf8');
|
|
31
33
|
let { exports: _, ...filteredFileContent } = JSON.parse(corePackageJsonFile);
|
|
32
34
|
filteredFileContent.name = 'dot-faststore';
|
|
33
|
-
(0, fs_extra_1.writeJsonSync)(path_1.default.join(
|
|
35
|
+
(0, fs_extra_1.writeJsonSync)(path_1.default.join(tmpDir, 'package.json'), filteredFileContent, {
|
|
34
36
|
spaces: 2,
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
|
-
function copyCoreFiles() {
|
|
39
|
+
function copyCoreFiles(basePath) {
|
|
40
|
+
const { coreDir, tmpDir } = (0, directory_1.withBasePath)(basePath);
|
|
38
41
|
try {
|
|
39
|
-
(0, fs_extra_1.copySync)(
|
|
42
|
+
(0, fs_extra_1.copySync)(coreDir, tmpDir, {
|
|
40
43
|
filter(src) {
|
|
41
44
|
const fileOrDirName = path_1.default.basename(src);
|
|
42
45
|
const shouldCopy = fileOrDirName
|
|
@@ -45,18 +48,19 @@ function copyCoreFiles() {
|
|
|
45
48
|
return shouldCopy;
|
|
46
49
|
},
|
|
47
50
|
});
|
|
48
|
-
filterAndCopyPackageJson();
|
|
51
|
+
filterAndCopyPackageJson(basePath);
|
|
49
52
|
console.log(`${chalk_1.default.green('success')} - Core files copied`);
|
|
50
53
|
}
|
|
51
54
|
catch (e) {
|
|
52
55
|
console.error(e);
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
|
-
function copyPublicFiles() {
|
|
58
|
+
function copyPublicFiles(basePath) {
|
|
59
|
+
const { userDir, tmpDir } = (0, directory_1.withBasePath)(basePath);
|
|
56
60
|
const allowList = ['json', 'txt', 'xml', 'ico', 'public'];
|
|
57
61
|
try {
|
|
58
|
-
if ((0, fs_extra_1.existsSync)(`${
|
|
59
|
-
(0, fs_extra_1.copySync)(`${
|
|
62
|
+
if ((0, fs_extra_1.existsSync)(`${userDir}/public`)) {
|
|
63
|
+
(0, fs_extra_1.copySync)(`${userDir}/public`, `${tmpDir}/public`, {
|
|
60
64
|
overwrite: true,
|
|
61
65
|
filter: (src) => {
|
|
62
66
|
const allow = allowList.some((ext) => src.endsWith(ext));
|
|
@@ -70,42 +74,44 @@ function copyPublicFiles() {
|
|
|
70
74
|
console.error(e);
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
|
-
async function copyCypressFiles() {
|
|
77
|
+
async function copyCypressFiles(basePath) {
|
|
74
78
|
var _a;
|
|
79
|
+
const { userDir, userStoreConfigFile, tmpDir } = (0, directory_1.withBasePath)(basePath);
|
|
75
80
|
try {
|
|
76
81
|
// Cypress 9.x config file
|
|
77
|
-
if ((0, fs_extra_1.existsSync)(`${
|
|
78
|
-
(0, fs_extra_1.copySync)(`${
|
|
82
|
+
if ((0, fs_extra_1.existsSync)(`${userDir}/cypress.json`)) {
|
|
83
|
+
(0, fs_extra_1.copySync)(`${userDir}/cypress.json`, `${tmpDir}/cypress.json`);
|
|
79
84
|
}
|
|
80
85
|
// Cypress 12.x config file
|
|
81
|
-
if ((0, fs_extra_1.existsSync)(`${
|
|
82
|
-
(0, fs_extra_1.copySync)(`${
|
|
86
|
+
if ((0, fs_extra_1.existsSync)(`${userDir}/cypress.config.ts`)) {
|
|
87
|
+
(0, fs_extra_1.copySync)(`${userDir}/cypress.config.ts`, `${tmpDir}/cypress.config.ts`);
|
|
83
88
|
}
|
|
84
|
-
const userStoreConfig = await (_a =
|
|
89
|
+
const userStoreConfig = await (_a = path_1.default.resolve(userStoreConfigFile), Promise.resolve().then(() => tslib_1.__importStar(require(_a))));
|
|
85
90
|
// Copy custom Cypress folder and files
|
|
86
|
-
if ((0, fs_extra_1.existsSync)(`${
|
|
91
|
+
if ((0, fs_extra_1.existsSync)(`${userDir}/cypress`) &&
|
|
87
92
|
userStoreConfig?.experimental?.enableCypressExtension) {
|
|
88
|
-
(0, fs_extra_1.copySync)(`${
|
|
93
|
+
(0, fs_extra_1.copySync)(`${userDir}/cypress`, `${tmpDir}/cypress`, {
|
|
89
94
|
overwrite: true,
|
|
90
95
|
});
|
|
91
96
|
console.log(`${chalk_1.default.green('success')} - Cypress test files copied`);
|
|
92
97
|
}
|
|
93
98
|
// Create default Cypress 12.x (or superior) support file
|
|
94
99
|
if (userStoreConfig?.experimental?.cypressVersion > 9) {
|
|
95
|
-
(0, fs_extra_1.copySync)(`${
|
|
100
|
+
(0, fs_extra_1.copySync)(`${tmpDir}/cypress/support/index.js`, `${tmpDir}/cypress/support/e2e.js`, { overwrite: false });
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
catch (e) {
|
|
99
104
|
console.error(e);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
|
-
function copyUserStarterToCustomizations() {
|
|
107
|
+
function copyUserStarterToCustomizations(basePath) {
|
|
108
|
+
const { userSrcDir, tmpCustomizationsSrcDir, userStoreConfigFile, tmpStoreConfigFile } = (0, directory_1.withBasePath)(basePath);
|
|
103
109
|
try {
|
|
104
|
-
if ((0, fs_extra_1.existsSync)(
|
|
105
|
-
(0, fs_extra_1.copySync)(
|
|
110
|
+
if ((0, fs_extra_1.existsSync)(userSrcDir) && (0, fs_extra_1.readdirSync)(userSrcDir).length > 0) {
|
|
111
|
+
(0, fs_extra_1.copySync)(userSrcDir, tmpCustomizationsSrcDir);
|
|
106
112
|
}
|
|
107
|
-
if ((0, fs_extra_1.existsSync)(
|
|
108
|
-
(0, fs_extra_1.copySync)(
|
|
113
|
+
if ((0, fs_extra_1.existsSync)(userStoreConfigFile)) {
|
|
114
|
+
(0, fs_extra_1.copySync)(userStoreConfigFile, tmpStoreConfigFile);
|
|
109
115
|
}
|
|
110
116
|
console.log(`${chalk_1.default.green('success')} - Starter files copied`);
|
|
111
117
|
}
|
|
@@ -113,14 +119,15 @@ function copyUserStarterToCustomizations() {
|
|
|
113
119
|
console.error(`${chalk_1.default.red('error')} - ${err}`);
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
|
-
async function createCmsWebhookUrlsJsonFile() {
|
|
122
|
+
async function createCmsWebhookUrlsJsonFile(basePath) {
|
|
117
123
|
var _a;
|
|
118
|
-
const
|
|
124
|
+
const { userStoreConfigFile, tmpCMSWebhookUrlsFile } = (0, directory_1.withBasePath)(basePath);
|
|
125
|
+
const userStoreConfig = await (_a = path_1.default.resolve(userStoreConfigFile), Promise.resolve().then(() => tslib_1.__importStar(require(_a))));
|
|
119
126
|
if (userStoreConfig?.vtexHeadlessCms &&
|
|
120
127
|
userStoreConfig.vtexHeadlessCms?.webhookUrls) {
|
|
121
128
|
const { webhookUrls } = userStoreConfig?.vtexHeadlessCms;
|
|
122
129
|
try {
|
|
123
|
-
(0, fs_extra_1.writeJsonSync)(
|
|
130
|
+
(0, fs_extra_1.writeJsonSync)(tmpCMSWebhookUrlsFile, { urls: webhookUrls }, { spaces: 2 });
|
|
124
131
|
console.log(`${chalk_1.default.green('success')} - CMS webhook URLs file created`);
|
|
125
132
|
}
|
|
126
133
|
catch (err) {
|
|
@@ -131,14 +138,15 @@ async function createCmsWebhookUrlsJsonFile() {
|
|
|
131
138
|
console.info(`${chalk_1.default.blue('info')} - No CMS webhook URLs were provided`);
|
|
132
139
|
}
|
|
133
140
|
}
|
|
134
|
-
async function copyTheme() {
|
|
141
|
+
async function copyTheme(basePath) {
|
|
135
142
|
var _a;
|
|
136
|
-
const
|
|
143
|
+
const { userStoreConfigFile, userThemesFileDir, tmpThemesCustomizationsFile } = (0, directory_1.withBasePath)(basePath);
|
|
144
|
+
const storeConfig = await (_a = path_1.default.resolve(userStoreConfigFile), Promise.resolve().then(() => tslib_1.__importStar(require(_a))));
|
|
137
145
|
if (storeConfig.theme) {
|
|
138
|
-
const customTheme = path_1.default.join(
|
|
146
|
+
const customTheme = path_1.default.join(userThemesFileDir, `${storeConfig.theme}.scss`);
|
|
139
147
|
if ((0, fs_extra_1.existsSync)(customTheme)) {
|
|
140
148
|
try {
|
|
141
|
-
(0, fs_extra_1.copyFileSync)(customTheme,
|
|
149
|
+
(0, fs_extra_1.copyFileSync)(customTheme, tmpThemesCustomizationsFile);
|
|
142
150
|
console.log(`${chalk_1.default.green('success')} - ${storeConfig.theme} theme has been applied`);
|
|
143
151
|
}
|
|
144
152
|
catch (err) {
|
|
@@ -149,27 +157,27 @@ async function copyTheme() {
|
|
|
149
157
|
console.info(`${chalk_1.default.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://www.faststore.dev/docs/themes/overview`);
|
|
150
158
|
}
|
|
151
159
|
}
|
|
152
|
-
else if ((0, fs_extra_1.existsSync)(
|
|
153
|
-
(0, fs_extra_1.readdirSync)(
|
|
160
|
+
else if ((0, fs_extra_1.existsSync)(userThemesFileDir) &&
|
|
161
|
+
(0, fs_extra_1.readdirSync)(userThemesFileDir).length > 0) {
|
|
154
162
|
console.info(`${chalk_1.default.blue('info')} - The theme needs to be added to the config file to be applied. Read more: https://www.faststore.dev/docs/themes/overview`);
|
|
155
163
|
}
|
|
156
164
|
}
|
|
157
165
|
async function generate(options) {
|
|
158
|
-
const { setup = false } = options
|
|
166
|
+
const { basePath, setup = false } = options;
|
|
159
167
|
let setupPromise = null;
|
|
160
168
|
if (setup) {
|
|
161
169
|
setupPromise = Promise.all([
|
|
162
|
-
createTmpFolder(),
|
|
163
|
-
copyCoreFiles(),
|
|
164
|
-
copyCypressFiles(),
|
|
165
|
-
copyPublicFiles(),
|
|
170
|
+
createTmpFolder(basePath),
|
|
171
|
+
copyCoreFiles(basePath),
|
|
172
|
+
copyCypressFiles(basePath),
|
|
173
|
+
copyPublicFiles(basePath),
|
|
166
174
|
]);
|
|
167
175
|
}
|
|
168
176
|
await Promise.all([
|
|
169
177
|
setupPromise,
|
|
170
|
-
copyUserStarterToCustomizations(),
|
|
171
|
-
copyTheme(),
|
|
172
|
-
createCmsWebhookUrlsJsonFile(),
|
|
178
|
+
copyUserStarterToCustomizations(basePath),
|
|
179
|
+
copyTheme(basePath),
|
|
180
|
+
createCmsWebhookUrlsJsonFile(basePath),
|
|
173
181
|
]);
|
|
174
182
|
}
|
|
175
183
|
exports.generate = generate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/utils/generate.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AACzB,uCASiB;AACjB,wDAAuB;AAEvB,
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/utils/generate.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AACzB,uCASiB;AACjB,wDAAuB;AAEvB,2CAA0C;AAO1C,8DAA8D;AAC9D,MAAM,WAAW,GAAG,CAAC,cAAc,EAAE,cAAc,EAAE,mBAAmB,CAAC,CAAA;AAEzE,SAAS,eAAe,CAAC,QAAgB;IACvC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,wBAAY,EAAC,QAAQ,CAAC,CAAA;IAExD,IAAI;QACF,IAAI,IAAA,qBAAU,EAAC,MAAM,CAAC,EAAE;YACtB,IAAA,qBAAU,EAAC,MAAM,CAAC,CAAA;SACnB;QAED,IAAA,qBAAU,EAAC,MAAM,CAAC,CAAA;QAClB,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,KAAK,CAAC,SAAS,CAAC,uBAAuB,eAAK,CAAC,GAAG,CACvD,aAAa,CACd,UAAU,CACZ,CAAA;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,GAAG,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;KAChD;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,wBAAwB,CAAC,QAAgB;IAChD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,wBAAY,EAAC,QAAQ,CAAC,CAAA;IAElD,MAAM,mBAAmB,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,c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QAAQ,CAAC;QACzC,SAAS,CAAC,QAAQ,CAAC;QACnB,4BAA4B,CAAC,QAAQ,CAAC;KACvC,CAAC,CAAA;AACJ,CAAC;AApBD,4BAoBC"}
|
package/dist/utils/hcms.d.ts
CHANGED
|
@@ -20,5 +20,5 @@ export declare function splitCustomDefinitions(coreDefinitions: ContentTypeOrSec
|
|
|
20
20
|
newDefinitions: ContentTypeOrSectionDefinition[];
|
|
21
21
|
};
|
|
22
22
|
export declare function dedupeAndMergeDefinitions(coreDefinitions: ContentTypeOrSectionDefinition[], duplicates: ContentTypeOrSectionDefinition[], primaryIdentifier: 'id' | 'name'): ContentTypeOrSectionDefinition[];
|
|
23
|
-
export declare function mergeCMSFile(fileName: string): Promise<void>;
|
|
24
|
-
export declare function mergeCMSFiles(): Promise<void>;
|
|
23
|
+
export declare function mergeCMSFile(fileName: string, basePath: string): Promise<void>;
|
|
24
|
+
export declare function mergeCMSFiles(basePath: string): Promise<void>;
|
package/dist/utils/hcms.js
CHANGED
|
@@ -51,9 +51,10 @@ async function confirmUserChoice(duplicates, fileName) {
|
|
|
51
51
|
}
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
async function mergeCMSFile(fileName) {
|
|
55
|
-
const
|
|
56
|
-
const
|
|
54
|
+
async function mergeCMSFile(fileName, basePath) {
|
|
55
|
+
const { coreCMSDir, userCMSDir, tmpCMSDir } = (0, directory_1.withBasePath)(basePath);
|
|
56
|
+
const coreFilePath = path_1.default.join(coreCMSDir, fileName);
|
|
57
|
+
const customFilePath = path_1.default.join(userCMSDir, fileName);
|
|
57
58
|
const coreFile = (0, fs_extra_1.readFileSync)(coreFilePath, 'utf8');
|
|
58
59
|
const coreDefinitions = JSON.parse(coreFile);
|
|
59
60
|
const primaryIdentifierForDefinitions = fileName === 'content-types.json' ? 'id' : 'name';
|
|
@@ -85,7 +86,7 @@ async function mergeCMSFile(fileName) {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
try {
|
|
88
|
-
(0, fs_extra_1.writeFileSync)(path_1.default.join(
|
|
89
|
+
(0, fs_extra_1.writeFileSync)(path_1.default.join(tmpCMSDir, fileName), JSON.stringify(output));
|
|
89
90
|
console.log(`${chalk_1.default.green('success')} - CMS file ${chalk_1.default.dim(fileName)} created`);
|
|
90
91
|
}
|
|
91
92
|
catch (err) {
|
|
@@ -93,10 +94,10 @@ async function mergeCMSFile(fileName) {
|
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
exports.mergeCMSFile = mergeCMSFile;
|
|
96
|
-
async function mergeCMSFiles() {
|
|
97
|
+
async function mergeCMSFiles(basePath) {
|
|
97
98
|
try {
|
|
98
|
-
await mergeCMSFile('content-types.json');
|
|
99
|
-
await mergeCMSFile('sections.json');
|
|
99
|
+
await mergeCMSFile('content-types.json', basePath);
|
|
100
|
+
await mergeCMSFile('sections.json', basePath);
|
|
100
101
|
}
|
|
101
102
|
catch (err) {
|
|
102
103
|
console.error(`${chalk_1.default.red('error')} - ${err}`);
|