@faststore/cli 2.2.0-alpha.0 → 2.2.0-alpha.3
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 +12 -8
- package/dist/commands/generate-graphql.d.ts +2 -2
- package/dist/commands/generate-graphql.js +31 -8
- package/dist/commands/generate-graphql.js.map +1 -1
- package/dist/utils/runCommandSync.d.ts +7 -0
- package/dist/utils/runCommandSync.js +40 -0
- package/dist/utils/runCommandSync.js.map +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
FastStore CLI
|
|
2
|
-
=================
|
|
1
|
+
# FastStore CLI
|
|
3
2
|
|
|
4
3
|
<!-- toc -->
|
|
4
|
+
* [FastStore CLI](#faststore-cli)
|
|
5
5
|
* [Usage](#usage)
|
|
6
6
|
* [Commands](#commands)
|
|
7
7
|
<!-- tocstop -->
|
|
8
|
+
|
|
8
9
|
# Usage
|
|
10
|
+
|
|
9
11
|
<!-- usage -->
|
|
10
12
|
```sh-session
|
|
11
13
|
$ npm install -g @faststore/cli
|
|
12
14
|
$ faststore COMMAND
|
|
13
15
|
running command...
|
|
14
16
|
$ faststore (--version)
|
|
15
|
-
@faststore/cli/2.2.0-alpha.
|
|
17
|
+
@faststore/cli/2.2.0-alpha.3 linux-x64 node-v16.20.2
|
|
16
18
|
$ faststore --help [COMMAND]
|
|
17
19
|
USAGE
|
|
18
20
|
$ faststore COMMAND
|
|
19
21
|
...
|
|
20
22
|
```
|
|
21
23
|
<!-- usagestop -->
|
|
24
|
+
|
|
22
25
|
# Commands
|
|
26
|
+
|
|
23
27
|
<!-- commands -->
|
|
24
28
|
* [`faststore build`](#faststore-build)
|
|
25
29
|
* [`faststore cms-sync`](#faststore-cms-sync)
|
|
@@ -35,7 +39,7 @@ USAGE
|
|
|
35
39
|
$ faststore build
|
|
36
40
|
```
|
|
37
41
|
|
|
38
|
-
_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.
|
|
42
|
+
_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.3/dist/commands/build.ts)_
|
|
39
43
|
|
|
40
44
|
## `faststore cms-sync`
|
|
41
45
|
|
|
@@ -44,7 +48,7 @@ USAGE
|
|
|
44
48
|
$ faststore cms-sync
|
|
45
49
|
```
|
|
46
50
|
|
|
47
|
-
_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.
|
|
51
|
+
_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.3/dist/commands/cms-sync.ts)_
|
|
48
52
|
|
|
49
53
|
## `faststore dev`
|
|
50
54
|
|
|
@@ -53,7 +57,7 @@ USAGE
|
|
|
53
57
|
$ faststore dev
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.
|
|
60
|
+
_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.3/dist/commands/dev.ts)_
|
|
57
61
|
|
|
58
62
|
## `faststore generate-graphql`
|
|
59
63
|
|
|
@@ -65,7 +69,7 @@ FLAGS
|
|
|
65
69
|
-d, --debug
|
|
66
70
|
```
|
|
67
71
|
|
|
68
|
-
_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.
|
|
72
|
+
_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.3/dist/commands/generate-graphql.ts)_
|
|
69
73
|
|
|
70
74
|
## `faststore help [COMMAND]`
|
|
71
75
|
|
|
@@ -94,5 +98,5 @@ USAGE
|
|
|
94
98
|
$ faststore start
|
|
95
99
|
```
|
|
96
100
|
|
|
97
|
-
_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.
|
|
101
|
+
_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v2.2.0-alpha.3/dist/commands/start.ts)_
|
|
98
102
|
<!-- commandsstop -->
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Command } from '@oclif/core';
|
|
3
2
|
export default class GenerateGraphql extends Command {
|
|
4
3
|
static flags: {
|
|
5
4
|
debug: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
5
|
+
core: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
6
|
};
|
|
7
|
-
run(): Promise<
|
|
7
|
+
run(): Promise<void>;
|
|
8
8
|
}
|
|
@@ -1,23 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
3
4
|
const core_1 = require("@oclif/core");
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
5
|
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
7
|
const directory_1 = require("../utils/directory");
|
|
8
|
+
const runCommandSync_1 = require("../utils/runCommandSync");
|
|
7
9
|
class GenerateGraphql extends core_1.Command {
|
|
8
10
|
static flags = {
|
|
9
11
|
debug: core_1.Flags.boolean({ char: 'd' }),
|
|
12
|
+
core: core_1.Flags.boolean({ char: 'c', hidden: true }),
|
|
10
13
|
};
|
|
11
14
|
async run() {
|
|
12
|
-
if (!(0, fs_extra_1.existsSync)(directory_1.tmpDir)) {
|
|
13
|
-
throw Error('The ".faststore" directory could not be found. When running faststore dev or faststore build, the generate-graphql command is automatically executed.');
|
|
14
|
-
}
|
|
15
15
|
const { flags } = await this.parse(GenerateGraphql);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const debug = flags.debug ?? false;
|
|
17
|
+
const isCore = flags.core ?? false;
|
|
18
|
+
if (!isCore && !(0, fs_extra_1.existsSync)(directory_1.tmpDir)) {
|
|
19
|
+
console.log(`${chalk_1.default.red('error')} - The ".faststore" directory could not be found. When running faststore dev or faststore build, the generate-graphql command is automatically executed.`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
(0, runCommandSync_1.runCommandSync)({
|
|
23
|
+
cmd: 'yarn generate:schema',
|
|
24
|
+
errorMessage: "Failed to run 'yarn generate:schema'. Please check your setup.",
|
|
25
|
+
throws: 'error',
|
|
26
|
+
debug,
|
|
27
|
+
cwd: isCore ? undefined : directory_1.tmpDir,
|
|
28
|
+
});
|
|
29
|
+
(0, runCommandSync_1.runCommandSync)({
|
|
30
|
+
cmd: 'yarn generate:codegen',
|
|
31
|
+
errorMessage: 'GraphQL was not optimized and TS files were not updated. Changes in the GraphQL layer did not take effect',
|
|
32
|
+
throws: 'error',
|
|
33
|
+
debug,
|
|
34
|
+
cwd: isCore ? undefined : directory_1.tmpDir,
|
|
35
|
+
});
|
|
36
|
+
(0, runCommandSync_1.runCommandSync)({
|
|
37
|
+
cmd: 'yarn format:generated',
|
|
38
|
+
errorMessage: "Failed to format generated files. 'yarn format:generated' thrown errors",
|
|
39
|
+
throws: 'warning',
|
|
40
|
+
debug,
|
|
41
|
+
cwd: isCore ? undefined : directory_1.tmpDir,
|
|
20
42
|
});
|
|
43
|
+
console.log(`${chalk_1.default.green('success')} - GraphQL schema, types, and optimizations successfully generated 🎉`);
|
|
21
44
|
}
|
|
22
45
|
}
|
|
23
46
|
exports.default = GenerateGraphql;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-graphql.js","sourceRoot":"","sources":["../../src/commands/generate-graphql.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-graphql.js","sourceRoot":"","sources":["../../src/commands/generate-graphql.ts"],"names":[],"mappings":";;;AAAA,sCAA4C;AAC5C,uCAAqC;AACrC,0DAAyB;AAEzB,kDAA2C;AAC3C,4DAAwD;AAExD,MAAqB,eAAgB,SA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AAC,SAAS,CAAC,CAAC,CAAC,kBAAM;SACjC,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,KAAK,CACZ,SAAS,CACV,uEAAuE,CACzE,CAAA;IACH,CAAC;;AAtDH,kCAuDC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCommandSync = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const showError = ({ message, cmd, error, debug, }) => {
|
|
8
|
+
console.log(`${chalk_1.default.red('error')} - ${message}`);
|
|
9
|
+
if (debug && cmd && error) {
|
|
10
|
+
console.log(`${chalk_1.default.magenta('DEBUG')} - $ ${cmd} error root ↓`);
|
|
11
|
+
console.log(error.stdout?.toString());
|
|
12
|
+
}
|
|
13
|
+
process.exit(1);
|
|
14
|
+
};
|
|
15
|
+
const showWarning = ({ message, cmd, error, debug, }) => {
|
|
16
|
+
console.log(`${chalk_1.default.yellow('warn')} - ${message}`);
|
|
17
|
+
if (debug && cmd && error) {
|
|
18
|
+
console.log(`${chalk_1.default.magenta('DEBUG')} - $ ${cmd} warn root ↓`);
|
|
19
|
+
console.log(error.stdout?.toString());
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const runCommandSync = ({ cmd, errorMessage, throws, debug, cwd }) => {
|
|
23
|
+
try {
|
|
24
|
+
(0, child_process_1.execSync)(debug ? `${cmd} --debug --verbose 2>&1` : `${cmd} 2>&1`, {
|
|
25
|
+
stdio: 'pipe',
|
|
26
|
+
cwd,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const sanitizedError = debug ? error : undefined;
|
|
31
|
+
if (throws === 'warning') {
|
|
32
|
+
showWarning({ message: errorMessage, cmd, error: sanitizedError, debug });
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
showError({ message: errorMessage, cmd, error: sanitizedError, debug });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.runCommandSync = runCommandSync;
|
|
40
|
+
//# sourceMappingURL=runCommandSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCommandSync.js","sourceRoot":"","sources":["../../src/utils/runCommandSync.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AAEzB,iDAAwC;AAIxC,MAAM,SAAS,GAAG,CAAC,EACjB,OAAO,EACP,GAAG,EACH,KAAK,EACL,KAAK,GAMN,EAAE,EAAE;IACH,OAAO,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,OAAO,EAAE,CAAC,CAAA;IAEjD,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,EAAE;QACzB,OAAO,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,GAAG,eAAe,CAAC,CAAA;QAChE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;KACtC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,EACnB,OAAO,EACP,GAAG,EACH,KAAK,EACL,KAAK,GAMN,EAAE,EAAE;IACH,OAAO,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,EAAE,CAAC,CAAA;IAEnD,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,EAAE;QACzB,OAAO,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,GAAG,cAAc,CAAC,CAAA;QAC/D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;KACtC;AACH,CAAC,CAAA;AAEM,MAAM,cAAc,GAAG,CAAC,EAC7B,GAAG,EACH,YAAY,EACZ,MAAM,EACN,KAAK,EACL,GAAG,EAOJ,EAAE,EAAE;IACH,IAAI;QACF,IAAA,wBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,yBAAyB,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,EAAE;YAChE,KAAK,EAAE,MAAM;YACb,GAAG;SACJ,CAAC,CAAA;KACH;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAE,KAAuB,CAAC,CAAC,CAAC,SAAS,CAAA;QAEnE,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,WAAW,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAA;SAC1E;aAAM;YACL,SAAS,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAA;SACxE;KACF;AACH,CAAC,CAAA;AA3BY,QAAA,cAAc,kBA2B1B"}
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.2.0-alpha.
|
|
1
|
+
{"version":"2.2.0-alpha.3","commands":{"build":{"id":"build","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"cms-sync":{"id":"cms-sync","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"dev":{"id":"dev","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"generate-graphql":{"id":"generate-graphql","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{"debug":{"name":"debug","type":"boolean","char":"d","allowNo":false},"core":{"name":"core","type":"boolean","char":"c","hidden":true,"allowNo":false}},"args":[]},"start":{"id":"start","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/cli",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.3",
|
|
4
4
|
"description": "FastStore CLI",
|
|
5
5
|
"author": "Emerson Laurentino @emersonlaurentino",
|
|
6
6
|
"bin": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"stringify-object": "^3.3.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@faststore/eslint-config": "^2.2.0-alpha.
|
|
32
|
-
"@faststore/shared": "^2.2.0-alpha.
|
|
31
|
+
"@faststore/eslint-config": "^2.2.0-alpha.1",
|
|
32
|
+
"@faststore/shared": "^2.2.0-alpha.1",
|
|
33
33
|
"@types/chai": "^4",
|
|
34
34
|
"@types/fs-extra": "^9.0.13",
|
|
35
35
|
"@types/node": "^16.11.63",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"oclif"
|
|
70
70
|
],
|
|
71
71
|
"types": "dist/index.d.ts",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "3f6a1bf0ab1c6cc7804c4f8752bf82457e8aad67"
|
|
73
73
|
}
|