@faststore/cli 1.12.20 → 1.12.26
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/CHANGELOG.md +17 -0
- package/dist/commands/dev.d.ts +1 -9
- package/dist/commands/dev.js +37 -25
- package/dist/commands/dev.js.map +1 -1
- package/dist/utils/contentFromPath.d.ts +10 -0
- package/dist/utils/contentFromPath.js +17 -0
- package/dist/utils/contentFromPath.js.map +1 -0
- package/dist/utils/directory.d.ts +23 -0
- package/dist/utils/directory.js +33 -0
- package/dist/utils/directory.js.map +1 -0
- package/dist/utils/generate.d.ts +5 -0
- package/dist/utils/generate.js +139 -0
- package/dist/utils/generate.js.map +1 -0
- package/package.json +6 -3
- package/dist/utils/root.d.ts +0 -1
- package/dist/utils/root.js +0 -11
- package/dist/utils/root.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.12.26](https://github.com/vtex/faststore/compare/v1.12.25...v1.12.26) (2022-11-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* adds develop command when running faststore dev ([#1500](https://github.com/vtex/faststore/issues/1500)) ([ff6bad5](https://github.com/vtex/faststore/commit/ff6bad5abfd674eec62aee5ad1f467dbcbaa51b0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.12.25](https://github.com/vtex/faststore/compare/v1.12.24...v1.12.25) (2022-11-09)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package @faststore/cli
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
## 1.12.20 (2022-10-26)
|
|
7
24
|
|
|
8
25
|
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
1
|
import { Command } from '@oclif/core';
|
|
5
|
-
import { Readable } from 'stream';
|
|
6
|
-
export interface ChangeToCopy {
|
|
7
|
-
path: string | null;
|
|
8
|
-
content: string | Readable | Buffer | NodeJS.ReadableStream;
|
|
9
|
-
}
|
|
10
2
|
export default class Dev extends Command {
|
|
11
|
-
run(): Promise<
|
|
3
|
+
run(): Promise<unknown>;
|
|
12
4
|
}
|
package/dist/commands/dev.js
CHANGED
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const path_1 = require("path");
|
|
7
5
|
const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
|
|
8
|
-
const
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const generate_1 = require("../utils/generate");
|
|
8
|
+
const directory_1 = require("../utils/directory");
|
|
9
|
+
/**
|
|
10
|
+
* Taken from toolbelt
|
|
11
|
+
*
|
|
12
|
+
* https://github.com/vtex/toolbelt/pull/442
|
|
13
|
+
*/
|
|
9
14
|
const stabilityThreshold = process.platform === 'darwin' ? 100 : 200;
|
|
10
15
|
const defaultPatterns = ['*/**', '**'];
|
|
11
16
|
const defaultIgnored = [
|
|
@@ -19,42 +24,49 @@ const defaultIgnored = [
|
|
|
19
24
|
'.faststore/**',
|
|
20
25
|
'**/.faststore/**',
|
|
21
26
|
];
|
|
27
|
+
const devAbortController = new AbortController();
|
|
28
|
+
async function storeDev() {
|
|
29
|
+
const devProcess = (0, child_process_1.spawn)('yarn develop', {
|
|
30
|
+
shell: true,
|
|
31
|
+
cwd: directory_1.tmpDir,
|
|
32
|
+
signal: devAbortController.signal,
|
|
33
|
+
stdio: 'inherit',
|
|
34
|
+
});
|
|
35
|
+
devProcess.on('close', () => {
|
|
36
|
+
devAbortController.abort();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
22
39
|
class Dev extends core_1.Command {
|
|
23
40
|
async run() {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
? ''
|
|
28
|
-
: (0, fs_1.readFileSync)((0, path_1.resolve)(root, path)).toString('base64');
|
|
29
|
-
return {
|
|
30
|
-
content,
|
|
31
|
-
path: path.split(path_1.sep).join('/'),
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
const queueChange = (path, remove) => {
|
|
35
|
-
pathToChange(path, remove);
|
|
36
|
-
copyChanges();
|
|
37
|
-
};
|
|
38
|
-
const copyChanges = () => {
|
|
39
|
-
/** copy changes to .faststore */
|
|
41
|
+
const queueChange = ( /* path: string, remove: boolean */) => {
|
|
42
|
+
// getContentFromPath(path, remove)
|
|
43
|
+
(0, generate_1.generate)();
|
|
40
44
|
};
|
|
41
45
|
const watcher = chokidar_1.default.watch([...defaultPatterns], {
|
|
42
46
|
atomic: stabilityThreshold,
|
|
43
47
|
awaitWriteFinish: {
|
|
44
48
|
stabilityThreshold,
|
|
45
49
|
},
|
|
46
|
-
cwd:
|
|
50
|
+
cwd: (0, directory_1.getRoot)(),
|
|
47
51
|
ignoreInitial: true,
|
|
48
52
|
ignored: defaultIgnored,
|
|
49
53
|
persistent: true,
|
|
50
54
|
usePolling: process.platform === 'win32',
|
|
51
55
|
});
|
|
52
|
-
|
|
56
|
+
devAbortController.signal.addEventListener('abort', () => {
|
|
57
|
+
watcher.close();
|
|
58
|
+
});
|
|
59
|
+
await (0, generate_1.generate)({ setup: true });
|
|
60
|
+
storeDev();
|
|
61
|
+
return await new Promise((resolve, reject) => {
|
|
53
62
|
watcher
|
|
54
|
-
.on('add', (file) => queueChange(file))
|
|
55
|
-
.on('change', (file) => queueChange(file))
|
|
56
|
-
.on('unlink', (file) => queueChange(file, true))
|
|
57
|
-
.on('error',
|
|
63
|
+
.on('add', ( /*file*/) => queueChange( /*file, false*/))
|
|
64
|
+
.on('change', ( /*file*/) => queueChange( /*file, false*/))
|
|
65
|
+
.on('unlink', ( /*file*/) => queueChange( /*file, true*/))
|
|
66
|
+
.on('error', () => {
|
|
67
|
+
devAbortController.abort();
|
|
68
|
+
reject();
|
|
69
|
+
})
|
|
58
70
|
.on('ready', resolve);
|
|
59
71
|
});
|
|
60
72
|
}
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":";;;AAAA,sCAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":";;;AAAA,sCAAqC;AACrC,gEAA+B;AAC/B,iDAAqC;AAErC,gDAA4C;AAC5C,kDAAoD;AAEpD;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;AAEpE,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAEtC,MAAM,cAAc,GAAG;IACrB,WAAW;IACX,WAAW;IACX,YAAY;IACZ,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,SAAS;IACT,eAAe;IACf,kBAAkB;CACnB,CAAA;AAED,MAAM,kBAAkB,GAAG,IAAI,eAAe,EAAE,CAAA;AAEhD,KAAK,UAAU,QAAQ;IACrB,MAAM,UAAU,GAAG,IAAA,qBAAK,EAAC,cAAc,EAAE;QACvC,KAAK,EAAE,IAAI;QACX,GAAG,EAAE,kBAAM;QACX,MAAM,EAAE,kBAAkB,CAAC,MAAM;QACjC,KAAK,EAAE,SAAS;KACjB,CAAC,CAAA;IAEF,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QAC1B,kBA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AAE,CAAA;gBAC1B,MAAM,EAAE,CAAA;YACV,CAAC,CAAC;iBACD,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAxCD,sBAwCC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import { Readable } from 'stream';
|
|
5
|
+
export interface ContentFromPath {
|
|
6
|
+
path: string | null;
|
|
7
|
+
content: string | Readable | Buffer | NodeJS.ReadableStream;
|
|
8
|
+
}
|
|
9
|
+
declare const getContentFromPath: (path: string, remove?: boolean) => ContentFromPath;
|
|
10
|
+
export { getContentFromPath };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getContentFromPath = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const directory_1 = require("./directory");
|
|
7
|
+
const getContentFromPath = (path, remove) => {
|
|
8
|
+
const content = remove
|
|
9
|
+
? ''
|
|
10
|
+
: (0, fs_extra_1.readFileSync)((0, path_1.resolve)((0, directory_1.getRoot)(), path)).toString('base64');
|
|
11
|
+
return {
|
|
12
|
+
content,
|
|
13
|
+
path: path.split(path_1.sep).join('/'),
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
exports.getContentFromPath = getContentFromPath;
|
|
17
|
+
//# sourceMappingURL=contentFromPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentFromPath.js","sourceRoot":"","sources":["../../src/utils/contentFromPath.ts"],"names":[],"mappings":";;;AAAA,+BAAkD;AAElD,uCAAuC;AACvC,2CAAqC;AAOrC,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,MAAgB,EAAmB,EAAE;IAC7E,MAAM,OAAO,GAAG,MAAM;QACpB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,IAAA,uBAAY,EAAC,IAAA,cAAW,EAAC,IAAA,mBAAO,GAAE,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAEjE,OAAO;QACL,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;KAChC,CAAA;AACH,CAAC,CAAA;AAEQ,gDAAkB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const getRoot: () => string;
|
|
2
|
+
export declare const userDir: string;
|
|
3
|
+
export declare const faststoreDir: string;
|
|
4
|
+
export declare const tmpFolderName = ".faststore";
|
|
5
|
+
export declare const tmpDir: string;
|
|
6
|
+
export declare const coreFolderName = "core";
|
|
7
|
+
export declare const coreDir: string;
|
|
8
|
+
export declare const srcFolderName = "src";
|
|
9
|
+
export declare const userSrcDir: string;
|
|
10
|
+
export declare const customizationsFolderName = "customizations";
|
|
11
|
+
export declare const tmpCustomizationsDir: string;
|
|
12
|
+
export declare const userThemesFileDir: string;
|
|
13
|
+
export declare const tmpThemesCustomizationsFileDir: string;
|
|
14
|
+
export declare const cmsFolderName = "cms";
|
|
15
|
+
export declare const tmpCMSDir: string;
|
|
16
|
+
export declare const coreCMSDir: string;
|
|
17
|
+
export declare const userCMSDir: string;
|
|
18
|
+
export declare const storeConfigFileName = "store.config.js";
|
|
19
|
+
export declare const userStoreConfigFileDir: string;
|
|
20
|
+
export declare const coreStoreConfigFileDir: string;
|
|
21
|
+
export declare const tmpStoreConfigFileDir: string;
|
|
22
|
+
export declare const userNodeModulesDir: string;
|
|
23
|
+
export declare const tmpNodeModulesDir: string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tmpNodeModulesDir = exports.userNodeModulesDir = exports.tmpStoreConfigFileDir = exports.coreStoreConfigFileDir = exports.userStoreConfigFileDir = exports.storeConfigFileName = exports.userCMSDir = exports.coreCMSDir = exports.tmpCMSDir = exports.cmsFolderName = exports.tmpThemesCustomizationsFileDir = exports.userThemesFileDir = exports.tmpCustomizationsDir = exports.customizationsFolderName = exports.userSrcDir = exports.srcFolderName = exports.coreDir = exports.coreFolderName = exports.tmpDir = exports.tmpFolderName = exports.faststoreDir = exports.userDir = exports.getRoot = void 0;
|
|
4
|
+
const getRoot = () => {
|
|
5
|
+
if (process.env.OCLIF_COMPILATION) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
return process.cwd();
|
|
9
|
+
};
|
|
10
|
+
exports.getRoot = getRoot;
|
|
11
|
+
exports.userDir = (0, exports.getRoot)();
|
|
12
|
+
exports.faststoreDir = `${exports.userDir}/node_modules/@faststore`;
|
|
13
|
+
exports.tmpFolderName = '.faststore';
|
|
14
|
+
exports.tmpDir = `${exports.userDir}/${exports.tmpFolderName}`;
|
|
15
|
+
exports.coreFolderName = 'core';
|
|
16
|
+
exports.coreDir = `${exports.faststoreDir}/${exports.coreFolderName}`;
|
|
17
|
+
exports.srcFolderName = 'src';
|
|
18
|
+
exports.userSrcDir = `${exports.userDir}/${exports.srcFolderName}`;
|
|
19
|
+
exports.customizationsFolderName = 'customizations';
|
|
20
|
+
exports.tmpCustomizationsDir = `${exports.tmpDir}/src/${exports.customizationsFolderName}`;
|
|
21
|
+
exports.userThemesFileDir = `${exports.userSrcDir}/themes`;
|
|
22
|
+
exports.tmpThemesCustomizationsFileDir = `${exports.tmpCustomizationsDir}/themes/index.scss`;
|
|
23
|
+
exports.cmsFolderName = 'cms';
|
|
24
|
+
exports.tmpCMSDir = `${exports.tmpDir}/${exports.cmsFolderName}`;
|
|
25
|
+
exports.coreCMSDir = `${exports.coreDir}/${exports.cmsFolderName}`;
|
|
26
|
+
exports.userCMSDir = `${exports.userDir}/${exports.cmsFolderName}`;
|
|
27
|
+
exports.storeConfigFileName = 'store.config.js';
|
|
28
|
+
exports.userStoreConfigFileDir = `${exports.userDir}/${exports.storeConfigFileName}`;
|
|
29
|
+
exports.coreStoreConfigFileDir = `${exports.coreDir}/${exports.storeConfigFileName}`;
|
|
30
|
+
exports.tmpStoreConfigFileDir = `${exports.tmpDir}/${exports.storeConfigFileName}`;
|
|
31
|
+
exports.userNodeModulesDir = `${exports.userDir}/node_modules`;
|
|
32
|
+
exports.tmpNodeModulesDir = `${exports.tmpDir}/node_modules`;
|
|
33
|
+
//# sourceMappingURL=directory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/utils/directory.ts"],"names":[],"mappings":";;;AAAO,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;QACjC,OAAO,EAAE,CAAA;KACV;IAED,OAAO,OAAO,CAAC,GAAG,EAAE,CAAA;AACtB,CAAC,CAAA;AANY,QAAA,OAAO,WAMnB;AAEY,QAAA,OAAO,GAAG,IAAA,eAAO,GAAE,CAAA;AACnB,QAAA,YAAY,GAAG,GAAG,eAAO,0BAA0B,CAAA;AAEnD,QAAA,aAAa,GAAG,YAAY,CAAA;AAC5B,QAAA,MAAM,GAAG,GAAG,eAAO,IAAI,qBAAa,EAAE,CAAA;AAEtC,QAAA,cAAc,GAAG,MAAM,CAAA;AACvB,QAAA,OAAO,GAAG,GAAG,oBAAY,IAAI,sBAAc,EAAE,CAAA;AAE7C,QAAA,aAAa,GAAG,KAAK,CAAA;AACrB,QAAA,UAAU,GAAG,GAAG,eAAO,IAAI,qBAAa,EAAE,CAAA;AAE1C,QAAA,wBAAwB,GAAG,gBAAgB,CAAA;AAC3C,QAAA,oBAAoB,GAAG,GAAG,cAAM,QAAQ,gCAAwB,EAAE,CAAA;AAElE,QAAA,iBAAiB,GAAG,GAAG,kBAAU,SAAS,CAAA;AAC1C,QAAA,8BAA8B,GAAG,GAAG,4BAAoB,oBAAoB,CAAA;AAE5E,QAAA,aAAa,GAAG,KAAK,CAAA;AACrB,QAAA,SAAS,GAAG,GAAG,cAAM,IAAI,qBAAa,EAAE,CAAA;AACxC,QAAA,UAAU,GAAG,GAAG,eAAO,IAAI,qBAAa,EAAE,CAAA;AAC1C,QAAA,UAAU,GAAG,GAAG,eAAO,IAAI,qBAAa,EAAE,CAAA;AAE1C,QAAA,mBAAmB,GAAG,iBAAiB,CAAA;AACvC,QAAA,sBAAsB,GAAG,GAAG,eAAO,IAAI,2BAAmB,EAAE,CAAA;AAC5D,QAAA,sBAAsB,GAAG,GAAG,eAAO,IAAI,2BAAmB,EAAE,CAAA;AAC5D,QAAA,qBAAqB,GAAG,GAAG,cAAM,IAAI,2BAAmB,EAAE,CAAA;AAE1D,QAAA,kBAAkB,GAAG,GAAG,eAAO,eAAe,CAAA;AAC9C,QAAA,iBAAiB,GAAG,GAAG,cAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
|
|
7
|
+
const directory_1 = require("./directory");
|
|
8
|
+
const ignorePaths = ['node_modules'];
|
|
9
|
+
function createTmpFolder() {
|
|
10
|
+
try {
|
|
11
|
+
if ((0, fs_extra_1.existsSync)(directory_1.tmpDir)) {
|
|
12
|
+
(0, fs_extra_1.removeSync)(directory_1.tmpDir);
|
|
13
|
+
}
|
|
14
|
+
(0, fs_extra_1.mkdirsSync)(directory_1.tmpDir);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
console.error(err);
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
console.log(`Temporary folder ${directory_1.tmpFolderName} created`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function copyCoreFiles() {
|
|
24
|
+
try {
|
|
25
|
+
(0, fs_extra_1.copySync)(directory_1.coreDir, directory_1.tmpDir, {
|
|
26
|
+
filter(src) {
|
|
27
|
+
const fileOrDirName = src.split('/').pop();
|
|
28
|
+
const shouldCopy = fileOrDirName
|
|
29
|
+
? !ignorePaths.includes(fileOrDirName)
|
|
30
|
+
: true;
|
|
31
|
+
return shouldCopy;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
console.error(e);
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
console.log(`Core files copied`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function copyUserSrcToCustomizations() {
|
|
43
|
+
try {
|
|
44
|
+
(0, fs_extra_1.copySync)(directory_1.userSrcDir, directory_1.tmpCustomizationsDir);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
console.error(err);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
console.log('Copied custom files');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function copyTheme() {
|
|
54
|
+
const storeConfig = await Promise.resolve().then(() => tslib_1.__importStar(require(directory_1.userStoreConfigFileDir)));
|
|
55
|
+
try {
|
|
56
|
+
(0, fs_extra_1.copyFileSync)(`${directory_1.userThemesFileDir}/${storeConfig.theme}.scss`, directory_1.tmpThemesCustomizationsFileDir);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.error(err);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
console.log('Copied custom styles');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function mergeCMSFile(fileName) {
|
|
66
|
+
const coreContentTypes = (0, fs_extra_1.readFileSync)(`${directory_1.coreCMSDir}/${fileName}`, 'utf8');
|
|
67
|
+
const customContentTypes = (0, fs_extra_1.readFileSync)(`${directory_1.userCMSDir}/${fileName}`, 'utf8');
|
|
68
|
+
const coreContentTypesJSON = JSON.parse(coreContentTypes);
|
|
69
|
+
const customContentTypesJSON = JSON.parse(customContentTypes);
|
|
70
|
+
const mergeContentTypes = [...coreContentTypesJSON, ...customContentTypesJSON];
|
|
71
|
+
try {
|
|
72
|
+
(0, fs_extra_1.writeFileSync)(`${directory_1.tmpCMSDir}/${fileName}`, JSON.stringify(mergeContentTypes));
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
console.error(err);
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
console.log(`CMS file ${fileName} created`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function generateStoreConfigFile(content) {
|
|
82
|
+
return `module.exports = ${JSON.stringify(content, null, 2)}\n`;
|
|
83
|
+
}
|
|
84
|
+
async function copyStoreConfig() {
|
|
85
|
+
try {
|
|
86
|
+
const storeConfigFromStore = await Promise.resolve().then(() => tslib_1.__importStar(require(directory_1.userStoreConfigFileDir)));
|
|
87
|
+
const storeConfigFromCore = await Promise.resolve().then(() => tslib_1.__importStar(require(directory_1.coreStoreConfigFileDir)));
|
|
88
|
+
const mergedStoreConfig = (0, deepmerge_1.default)(storeConfigFromCore, storeConfigFromStore);
|
|
89
|
+
(0, fs_extra_1.writeFileSync)(directory_1.tmpStoreConfigFileDir, generateStoreConfigFile(mergedStoreConfig));
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
console.error(err);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
console.log(`File store.config.js copied`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function mergeCMSFiles() {
|
|
99
|
+
try {
|
|
100
|
+
(0, fs_extra_1.mkdirsSync)(`${directory_1.tmpDir}/cms`);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
console.error(err);
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
console.log(`CMS file created`);
|
|
107
|
+
}
|
|
108
|
+
mergeCMSFile('content-types.json');
|
|
109
|
+
mergeCMSFile('sections.json');
|
|
110
|
+
}
|
|
111
|
+
function createNodeModulesSymbolicLink() {
|
|
112
|
+
try {
|
|
113
|
+
(0, fs_extra_1.symlinkSync)(directory_1.userNodeModulesDir, directory_1.tmpNodeModulesDir);
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
console.error(err);
|
|
117
|
+
}
|
|
118
|
+
console.log(`node_modules symbolic link created from ${directory_1.userNodeModulesDir} to ${directory_1.tmpNodeModulesDir}`);
|
|
119
|
+
}
|
|
120
|
+
async function generate(options) {
|
|
121
|
+
const { setup = false } = options ?? {};
|
|
122
|
+
let setupPromise = null;
|
|
123
|
+
if (setup) {
|
|
124
|
+
setupPromise = Promise.all([
|
|
125
|
+
createTmpFolder(),
|
|
126
|
+
copyCoreFiles(),
|
|
127
|
+
createNodeModulesSymbolicLink(),
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
await Promise.all([
|
|
131
|
+
setupPromise,
|
|
132
|
+
copyUserSrcToCustomizations(),
|
|
133
|
+
copyTheme(),
|
|
134
|
+
mergeCMSFiles(),
|
|
135
|
+
copyStoreConfig(),
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
exports.generate = generate;
|
|
139
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/utils/generate.ts"],"names":[],"mappings":";;;;AAAA,uCASiB;AACjB,kEAAiC;AAEjC,2CAgBoB;AAMpB,MAAM,WAAW,GAAG,CAAC,cAAc,CAAC,CAAA;AAEpC,SAAS,eAAe;IACtB,IAAI;QACF,IAAI,IAAA,qBAAU,EAAC,kBAAM,CAAC,EAAE;YACtB,IAAA,qBAAU,EAAC,kBAAM,CAAC,CAAA;SACnB;QAED,IAAA,qBAAU,EAAC,kBAAM,CAAC,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
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/cli",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.26",
|
|
4
4
|
"description": "FastStore CLI",
|
|
5
5
|
"author": "Emerson Laurentino @emersonlaurentino",
|
|
6
6
|
"bin": {
|
|
@@ -21,11 +21,14 @@
|
|
|
21
21
|
"@oclif/plugin-help": "^5",
|
|
22
22
|
"@oclif/plugin-not-found": "^2.3.3",
|
|
23
23
|
"chokidar": "^3.5.3",
|
|
24
|
+
"deepmerge": "^4.2.2",
|
|
25
|
+
"fs-extra": "^10.1.0",
|
|
24
26
|
"path": "^0.12.7"
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|
|
27
29
|
"@faststore/shared": "^1.12.20",
|
|
28
30
|
"@types/chai": "^4",
|
|
31
|
+
"@types/fs-extra": "^9.0.13",
|
|
29
32
|
"@types/node": "^16.11.63",
|
|
30
33
|
"chai": "^4",
|
|
31
34
|
"oclif": "^3",
|
|
@@ -53,12 +56,12 @@
|
|
|
53
56
|
"version": "oclif readme && git add README.md"
|
|
54
57
|
},
|
|
55
58
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
59
|
+
"node": ">=16.0.0"
|
|
57
60
|
},
|
|
58
61
|
"bugs": "https://github.com/vtex/faststore/issues",
|
|
59
62
|
"keywords": [
|
|
60
63
|
"oclif"
|
|
61
64
|
],
|
|
62
65
|
"types": "dist/index.d.ts",
|
|
63
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "32cff5b4951e5139209736e012a2dadadf1349cd"
|
|
64
67
|
}
|
package/dist/utils/root.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getRoot: () => string;
|
package/dist/utils/root.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRoot = void 0;
|
|
4
|
-
const getRoot = () => {
|
|
5
|
-
if (process.env.OCLIF_COMPILATION) {
|
|
6
|
-
return '';
|
|
7
|
-
}
|
|
8
|
-
return process.cwd();
|
|
9
|
-
};
|
|
10
|
-
exports.getRoot = getRoot;
|
|
11
|
-
//# sourceMappingURL=root.js.map
|
package/dist/utils/root.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/utils/root.ts"],"names":[],"mappings":";;;AAAO,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;QACjC,OAAO,EAAE,CAAA;KACV;IAED,OAAO,OAAO,CAAC,GAAG,EAAE,CAAA;AACtB,CAAC,CAAA;AANY,QAAA,OAAO,WAMnB"}
|