@sapphire/cli 0.0.2-next.0498b31.0 → 0.0.2-next.05ce8a2.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/README.md +0 -1
- package/dist/commands/generate.js +22 -3
- package/oclif.manifest.json +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://github.com/sapphiredev/cli/blob/main/LICENSE.md)
|
|
10
10
|
[](https://www.npmjs.com/package/@sapphire/cli)
|
|
11
|
-
[](https://depfu.com/github/sapphiredev/cli?project_id=31779)
|
|
12
11
|
|
|
13
12
|
</div>
|
|
14
13
|
|
|
@@ -9,16 +9,21 @@ const fs_1 = require("fs");
|
|
|
9
9
|
const promises_1 = require("fs/promises");
|
|
10
10
|
const ora_1 = (0, tslib_1.__importDefault)(require("ora"));
|
|
11
11
|
const path_1 = require("path");
|
|
12
|
+
const promises_2 = require("timers/promises");
|
|
12
13
|
class Generate extends command_1.Command {
|
|
13
14
|
async run() {
|
|
14
15
|
const { args } = this.parse(Generate);
|
|
15
16
|
const spinner = (0, ora_1.default)(`Creating a ${args.component.toLowerCase()}`).start();
|
|
16
|
-
const
|
|
17
|
+
const fail = (error) => {
|
|
18
|
+
spinner.fail(error);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
};
|
|
21
|
+
const configLoc = await this.fetchConfig();
|
|
17
22
|
if (!configLoc)
|
|
18
|
-
return;
|
|
23
|
+
return fail("Can't find the Sapphire CLI config.");
|
|
19
24
|
const config = JSON.parse(await (0, promises_1.readFile)(configLoc, 'utf8'));
|
|
20
25
|
if (!config)
|
|
21
|
-
return;
|
|
26
|
+
return fail("Can't parse the Sapphire CLI config.");
|
|
22
27
|
await this.createComponent(args.component, args.name, config, configLoc.replace('.sapphirerc.json', '')).catch((err) => {
|
|
23
28
|
spinner.fail();
|
|
24
29
|
console.log((0, chalk_1.red)(err.message));
|
|
@@ -46,6 +51,20 @@ class Generate extends command_1.Command {
|
|
|
46
51
|
return reject(new Error("Can't find the template."));
|
|
47
52
|
});
|
|
48
53
|
}
|
|
54
|
+
timeout(ms) {
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
// false positive
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
58
|
+
return (0, promises_2.setTimeout)(ms)
|
|
59
|
+
.then(() => {
|
|
60
|
+
resolve(null);
|
|
61
|
+
})
|
|
62
|
+
.catch(reject);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
fetchConfig() {
|
|
66
|
+
return Promise.race([(0, find_up_1.default)('.sapphirerc.json', { cwd: '.' }), this.timeout(5000)]);
|
|
67
|
+
}
|
|
49
68
|
}
|
|
50
69
|
exports.default = Generate;
|
|
51
70
|
Object.defineProperty(Generate, "description", {
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.0.2-next.
|
|
1
|
+
{"version":"0.0.2-next.05ce8a2.0","commands":{"generate":{"id":"generate","description":"generate a component (command, listener, etc.)","pluginName":"@sapphire/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"component","required":true},{"name":"name","required":true}]},"new":{"id":"new","description":"create a new Sapphire project","pluginName":"@sapphire/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"verbose":{"name":"verbose","type":"boolean","char":"v","allowNo":false}},"args":[{"name":"ProjectName","default":"NewSapphireProject"}]}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/cli",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.05ce8a2.0",
|
|
4
4
|
"description": "CLI for Sapphire Framework",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"@sapphire/eslint-config": "^3.2.3",
|
|
56
56
|
"@sapphire/prettier-config": "^1.1.6",
|
|
57
57
|
"@sapphire/ts-config": "^3.0.0",
|
|
58
|
-
"@types/node": "^16.
|
|
58
|
+
"@types/node": "^16.10.1",
|
|
59
59
|
"@types/prompts": "^2.0.14",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
61
|
-
"@typescript-eslint/parser": "^4.
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
|
61
|
+
"@typescript-eslint/parser": "^4.32.0",
|
|
62
62
|
"cz-conventional-changelog": "^3.3.0",
|
|
63
63
|
"eslint": "^7.32.0",
|
|
64
64
|
"eslint-config-prettier": "^8.3.0",
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"prettier": "^2.4.1",
|
|
70
70
|
"pretty-quick": "^3.1.1",
|
|
71
71
|
"standard-version": "^9.3.1",
|
|
72
|
-
"ts-node": "^10.2.
|
|
73
|
-
"typescript": "^4.4.
|
|
72
|
+
"ts-node": "^10.2.1",
|
|
73
|
+
"typescript": "^4.4.3"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=16.7.0",
|
|
77
|
-
"npm": ">=7"
|
|
77
|
+
"npm": ">=7.24.1"
|
|
78
78
|
},
|
|
79
79
|
"keywords": [
|
|
80
80
|
"@sapphire/cli",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"kind-of": "^6.0.3",
|
|
117
117
|
"dot-prop": "^6.0.1",
|
|
118
118
|
"lodash": "^4.17.21",
|
|
119
|
-
"marked": "^2.
|
|
119
|
+
"marked": "^2.1.3",
|
|
120
120
|
"merge": "^2.1.1",
|
|
121
121
|
"trim": "^1.0.1",
|
|
122
122
|
"trim-newlines": "^3.0.1"
|