@sapphire/cli 1.2.0 → 1.2.1-next.00d2a50.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/CHANGELOG.md +81 -0
- package/dist/cli.js +0 -0
- package/dist/commands/generate.js +12 -11
- package/dist/commands/new.js +24 -31
- package/dist/functions/CommandExists.js +13 -13
- package/dist/functions/FileExists.js +3 -3
- package/package.json +120 -115
- package/dist/functions/Spinner.js +0 -122
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.2.0](https://github.com/sapphiredev/cli/compare/v1.1.0...v1.2.0) (2022-02-26)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- add yarn v3 support ([#84](https://github.com/sapphiredev/cli/issues/84)) ([4c47d1a](https://github.com/sapphiredev/cli/commit/4c47d1aef07b600c0727106bd8d008213f3c2d04))
|
|
10
|
+
|
|
11
|
+
## [1.1.0](https://github.com/sapphiredev/cli/compare/v1.0.2...v1.1.0) (2022-01-31)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- add tsup and swc template options ([#71](https://github.com/sapphiredev/cli/issues/71)) ([625dd8e](https://github.com/sapphiredev/cli/commit/625dd8ea9d43f7005c72212fb5a65bf0b8aa7492))
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- **deps:** update dependency commander to v9 ([#76](https://github.com/sapphiredev/cli/issues/76)) ([d75ea1b](https://github.com/sapphiredev/cli/commit/d75ea1b1542490fd67a14630ee67e3223dc3b6e7))
|
|
20
|
+
- Generated command comportnent code has error ([#67](https://github.com/sapphiredev/cli/issues/67)) ([9901517](https://github.com/sapphiredev/cli/commit/990151771e3d1da09dee34c9995d70abc241a769))
|
|
21
|
+
|
|
22
|
+
### [1.0.2](https://github.com/sapphiredev/cli/compare/v1.0.1...v1.0.2) (2021-11-08)
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
- update URL for guide ([0b7e402](https://github.com/sapphiredev/cli/commit/0b7e402e3db26af818824f423059c643374ed920))
|
|
27
|
+
|
|
28
|
+
### [1.0.1](https://github.com/sapphiredev/cli/compare/v1.0.0...v1.0.1) (2021-11-06)
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
- allow more node & npm versions in engines field ([ce6c97f](https://github.com/sapphiredev/cli/commit/ce6c97f8c2934796e9d6ab159195f2c0fa05188a))
|
|
33
|
+
- **deps:** update all non-major dependencies ([#36](https://github.com/sapphiredev/cli/issues/36)) ([1a9e791](https://github.com/sapphiredev/cli/commit/1a9e791768ebbe5edd11875ac07c31b9d3cec50e))
|
|
34
|
+
- typo `msg` -> `message` ([#39](https://github.com/sapphiredev/cli/issues/39)) ([0f8933b](https://github.com/sapphiredev/cli/commit/0f8933b1af3927c96a79a1f4d9b1bcc46727dd24))
|
|
35
|
+
|
|
36
|
+
## [1.0.0](https://github.com/sapphiredev/cli/compare/v0.0.3...v1.0.0) (2021-10-16)
|
|
37
|
+
|
|
38
|
+
### [0.0.3](https://github.com/sapphiredev/cli/compare/v0.0.2...v0.0.3) (2021-10-16)
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
- **templates:** Overridden run method to messageRun ([#30](https://github.com/sapphiredev/cli/issues/30)) ([07fc1d5](https://github.com/sapphiredev/cli/commit/07fc1d5516f057cd346340de853ded314741335f))
|
|
43
|
+
|
|
44
|
+
### [0.0.2](https://github.com/sapphiredev/cli/compare/v0.0.1...v0.0.2) (2021-10-16)
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
- add `init` command ([588e956](https://github.com/sapphiredev/cli/commit/588e956eeb9867be1e16db9bcd962fd72864d8fc))
|
|
49
|
+
- add JSON scheme for CLI config ([1ca569b](https://github.com/sapphiredev/cli/commit/1ca569b8ed89a869af3d5e39c6f1f4cc988edf08))
|
|
50
|
+
- add prompt for `init` command ([67d5a10](https://github.com/sapphiredev/cli/commit/67d5a106c66df3235260810ac6770234a7e7f2fc))
|
|
51
|
+
- category support ([0498b31](https://github.com/sapphiredev/cli/commit/0498b3125767b1b37614e50795402dbb8d72627e))
|
|
52
|
+
- switch to commander ([#15](https://github.com/sapphiredev/cli/issues/15)) ([8f34fa8](https://github.com/sapphiredev/cli/commit/8f34fa8323a6dfdb79abf2ebaf7fdd4d17f3df4b))
|
|
53
|
+
- YAML support ([#17](https://github.com/sapphiredev/cli/issues/17)) ([f69ae95](https://github.com/sapphiredev/cli/commit/f69ae959b664a3aa4342cf67c27802e197505c08))
|
|
54
|
+
|
|
55
|
+
### Bug Fixes
|
|
56
|
+
|
|
57
|
+
- add timeout when finding the config file ([46e3e21](https://github.com/sapphiredev/cli/commit/46e3e21e2b3e0d431e1eeea612a5da9b636ed34a))
|
|
58
|
+
- create the config file on project root instead of the current folder ([aa3b352](https://github.com/sapphiredev/cli/commit/aa3b352aa22b7cecb2117ced37f8e33202fa492b))
|
|
59
|
+
- include `templates` directory in the npm package ([c85406f](https://github.com/sapphiredev/cli/commit/c85406f9e9ba764a8063f5b7af458eb8b8f23924))
|
|
60
|
+
- path and executable issues on Windows ([f317d7f](https://github.com/sapphiredev/cli/commit/f317d7f35d39d388798e6250d79915e7cfdfa23a))
|
|
61
|
+
- **templates:** typescript types ([3812b34](https://github.com/sapphiredev/cli/commit/3812b34f7467e30624c7993a64366d2cb0821ac9))
|
|
62
|
+
|
|
63
|
+
### 0.0.1 (2021-09-23)
|
|
64
|
+
|
|
65
|
+
### Features
|
|
66
|
+
|
|
67
|
+
- add a function to check if a command exists ([107ccee](https://github.com/sapphiredev/cli/commit/107ccee0b55b3ddf6261d177d6b0b5730512811c))
|
|
68
|
+
- add command: `generate` ([b14a965](https://github.com/sapphiredev/cli/commit/b14a965548f5548ce7ac5e0e53d23c85ca827da2))
|
|
69
|
+
- add command: `new` ([4afa8cd](https://github.com/sapphiredev/cli/commit/4afa8cdaf122bac4bc7b16a8f18a9bda40663d4c))
|
|
70
|
+
- add command: `new` ([ffe5a69](https://github.com/sapphiredev/cli/commit/ffe5a695c0126523a4c9e79ea4817542023de193))
|
|
71
|
+
- add function to create files using templates ([e95db50](https://github.com/sapphiredev/cli/commit/e95db50555a9f02e241bea9753506e12a14b0395))
|
|
72
|
+
- add path aliases ([1b65110](https://github.com/sapphiredev/cli/commit/1b65110d0135f4ee9a064d8ac6f130f06ec8ab4c))
|
|
73
|
+
- add PWSH script for Windows ([c69c55f](https://github.com/sapphiredev/cli/commit/c69c55f44f39b6d1984adaded486e29759118375))
|
|
74
|
+
- add templates for `generate` command ([be6f535](https://github.com/sapphiredev/cli/commit/be6f53583ecba3d959a76a12310ff3d80cbd52dd))
|
|
75
|
+
- update batch file for Windows Command Prompt ([746ab83](https://github.com/sapphiredev/cli/commit/746ab838bc668c863a8fc6b2d9632e4c5790acdc))
|
|
76
|
+
- update config template ([65c47a0](https://github.com/sapphiredev/cli/commit/65c47a0728f4652b725b37ebcf758fb60155de7c))
|
|
77
|
+
- use new template format ([1adcbeb](https://github.com/sapphiredev/cli/commit/1adcbeb39678fbbfe6ea119dd9586d3a022cbc11))
|
|
78
|
+
|
|
79
|
+
### Bug Fixes
|
|
80
|
+
|
|
81
|
+
- language value was not getting replaced when creating the `.sapphirerc.json` file from template ([946a40a](https://github.com/sapphiredev/cli/commit/946a40a4365411c2f20a1ed8806e0057c0afbc56))
|
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { componentsFolder } from '#constants';
|
|
2
2
|
import { CreateFileFromTemplate } from '#functions/CreateFileFromTemplate';
|
|
3
3
|
import { fileExists } from '#functions/FileExists';
|
|
4
|
-
import { Spinner } from '
|
|
5
|
-
import {
|
|
4
|
+
import { Spinner } from '@favware/colorette-spinner';
|
|
5
|
+
import { Result } from '@sapphire/result';
|
|
6
6
|
import { blueBright, red } from 'colorette';
|
|
7
7
|
import findUp from 'find-up';
|
|
8
8
|
import { load } from 'js-yaml';
|
|
@@ -38,8 +38,7 @@ export default async (component, name) => {
|
|
|
38
38
|
const spinner = new Spinner(`Creating a ${component.toLowerCase()}`).start();
|
|
39
39
|
const fail = (error, additionalExecution) => {
|
|
40
40
|
spinner.error({ text: error });
|
|
41
|
-
|
|
42
|
-
additionalExecution();
|
|
41
|
+
additionalExecution?.();
|
|
43
42
|
process.exit(1);
|
|
44
43
|
};
|
|
45
44
|
const configLoc = await fetchConfig();
|
|
@@ -50,12 +49,14 @@ export default async (component, name) => {
|
|
|
50
49
|
if (!config) {
|
|
51
50
|
return fail("Can't parse the Sapphire CLI config.");
|
|
52
51
|
}
|
|
53
|
-
const result = await fromAsync(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
const result = await Result.fromAsync(() => createComponent(component, name, config, configLoc.replace(/.sapphirerc.(json|yml)/g, '')));
|
|
53
|
+
return result.match({
|
|
54
|
+
ok: () => {
|
|
55
|
+
spinner.success();
|
|
56
|
+
console.log(blueBright('Done!'));
|
|
57
|
+
process.exit(0);
|
|
58
|
+
},
|
|
59
|
+
err: (error) => fail(error.message, () => console.log(red(error.message)))
|
|
60
|
+
});
|
|
60
61
|
};
|
|
61
62
|
//# sourceMappingURL=generate.js.map
|
package/dist/commands/new.js
CHANGED
|
@@ -2,9 +2,9 @@ import { repoUrl } from '#constants';
|
|
|
2
2
|
import { CommandExists } from '#functions/CommandExists';
|
|
3
3
|
import { CreateFileFromTemplate } from '#functions/CreateFileFromTemplate';
|
|
4
4
|
import { fileExists } from '#functions/FileExists';
|
|
5
|
-
import { Spinner } from '#functions/Spinner';
|
|
6
5
|
import { PromptNew } from '#prompts/PromptNew';
|
|
7
|
-
import {
|
|
6
|
+
import { Spinner } from '@favware/colorette-spinner';
|
|
7
|
+
import { Result } from '@sapphire/result';
|
|
8
8
|
import { blueBright, red } from 'colorette';
|
|
9
9
|
import { execa } from 'execa';
|
|
10
10
|
import { cp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
@@ -16,18 +16,15 @@ async function editPackageJson(location, name) {
|
|
|
16
16
|
if (!output)
|
|
17
17
|
throw new Error("Can't read file.");
|
|
18
18
|
output.name = name;
|
|
19
|
-
const result = await fromAsync(() => writeFile(pjLocation, JSON.stringify(output, null, 2)));
|
|
20
|
-
return isOk(
|
|
19
|
+
const result = await Result.fromAsync(() => writeFile(pjLocation, JSON.stringify(output, null, 2)));
|
|
20
|
+
return result.isOk();
|
|
21
21
|
}
|
|
22
22
|
async function installDeps(location, pm, verbose) {
|
|
23
|
-
const
|
|
23
|
+
const value = await execa(pm.toLowerCase(), ['install'], {
|
|
24
24
|
stdio: verbose ? 'inherit' : undefined,
|
|
25
25
|
cwd: `./${location}/`
|
|
26
|
-
})
|
|
27
|
-
if (
|
|
28
|
-
throw result.error;
|
|
29
|
-
}
|
|
30
|
-
if (result.value.exitCode !== 0) {
|
|
26
|
+
});
|
|
27
|
+
if (value.exitCode !== 0) {
|
|
31
28
|
throw new Error('An unknown error occurred while installing the dependencies. Try running Sapphire CLI with "--verbose" flag.');
|
|
32
29
|
}
|
|
33
30
|
const oppositeLockfile = `./${location}/${pm === 'npm' ? 'yarn.lock' : 'package-lock.json'}`;
|
|
@@ -41,14 +38,11 @@ async function configureYarnRc(location, name, value) {
|
|
|
41
38
|
return true;
|
|
42
39
|
}
|
|
43
40
|
async function installYarnV3(location, verbose) {
|
|
44
|
-
const
|
|
41
|
+
const value = await execa('yarn', ['set', 'version', 'berry'], {
|
|
45
42
|
stdio: verbose ? 'inherit' : undefined,
|
|
46
43
|
cwd: `./${location}/`
|
|
47
|
-
})
|
|
48
|
-
if (
|
|
49
|
-
throw result.error;
|
|
50
|
-
}
|
|
51
|
-
if (result.value.exitCode !== 0) {
|
|
44
|
+
});
|
|
45
|
+
if (value.exitCode !== 0) {
|
|
52
46
|
throw new Error('An unknown error occurred while installing Yarn v3. Try running Sapphire CLI with "--verbose" flag.');
|
|
53
47
|
}
|
|
54
48
|
await Promise.all([
|
|
@@ -68,23 +62,22 @@ async function initializeGitRepo(location) {
|
|
|
68
62
|
}
|
|
69
63
|
async function runJob(job, name) {
|
|
70
64
|
const spinner = new Spinner(name).start();
|
|
71
|
-
const result = await fromAsync(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
const result = await Result.fromAsync(() => job());
|
|
66
|
+
return result.match({
|
|
67
|
+
ok: () => {
|
|
68
|
+
spinner.success();
|
|
69
|
+
return true;
|
|
70
|
+
},
|
|
71
|
+
err: (error) => {
|
|
72
|
+
spinner.error({ text: red(error.message) });
|
|
73
|
+
console.error(red(error.message));
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
79
77
|
}
|
|
80
78
|
async function cloneRepo(location, verbose) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
}));
|
|
84
|
-
if (isErr(result)) {
|
|
85
|
-
throw result.error;
|
|
86
|
-
}
|
|
87
|
-
if (result.value.exitCode !== 0) {
|
|
79
|
+
const value = await execa('git', ['clone', repoUrl, `${location}/ghr`], { stdio: verbose ? 'inherit' : undefined });
|
|
80
|
+
if (value.exitCode !== 0) {
|
|
88
81
|
throw new Error('An unknown error occurred while cloning the repository. Try running Sapphire CLI with "--verbose" flag.');
|
|
89
82
|
}
|
|
90
83
|
return true;
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import { fileExists } from '#functions/FileExists';
|
|
25
|
-
import {
|
|
25
|
+
import { Result } from '@sapphire/result';
|
|
26
26
|
import { execa } from 'execa';
|
|
27
27
|
import { constants } from 'node:fs';
|
|
28
28
|
import { access } from 'node:fs/promises';
|
|
29
29
|
const windows = process.platform === 'win32';
|
|
30
30
|
async function isExecutable(command) {
|
|
31
|
-
const result = await fromAsync(() => access(command, constants.X_OK));
|
|
32
|
-
return isErr(
|
|
31
|
+
const result = await Result.fromAsync(() => access(command, constants.X_OK));
|
|
32
|
+
return result.isErr();
|
|
33
33
|
}
|
|
34
34
|
function cleanWindowsCommand(input) {
|
|
35
35
|
if (/[^A-Za-z0-9_\/:=-]/.test(input)) {
|
|
@@ -44,22 +44,22 @@ async function commandExistsUnix(command) {
|
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const result = await fromAsync(() => execa('which', [command]));
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const result = await Result.fromAsync(() => execa('which', [command]));
|
|
48
|
+
return result.match({
|
|
49
|
+
err: () => false,
|
|
50
|
+
ok: (value) => Boolean(value.stdout)
|
|
51
|
+
});
|
|
52
52
|
}
|
|
53
53
|
const invalidWindowsCommandNameRegex = /[\x00-\x1f<>:"|?*]/;
|
|
54
54
|
async function commandExistsWindows(command) {
|
|
55
55
|
if (invalidWindowsCommandNameRegex.test(command)) {
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
|
-
const result = await fromAsync(async () => execa('where', [cleanWindowsCommand(command)]));
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
const result = await Result.fromAsync(async () => execa('where', [cleanWindowsCommand(command)]));
|
|
59
|
+
return result.match({
|
|
60
|
+
err: () => fileExists(command),
|
|
61
|
+
ok: () => true
|
|
62
|
+
});
|
|
63
63
|
}
|
|
64
64
|
export async function CommandExists(command) {
|
|
65
65
|
return windows ? commandExistsWindows(command) : commandExistsUnix(command);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Result } from '@sapphire/result';
|
|
2
2
|
import { access } from 'node:fs/promises';
|
|
3
3
|
export async function fileExists(filePath) {
|
|
4
|
-
const result = await fromAsync(() => access(filePath));
|
|
5
|
-
return isOk(
|
|
4
|
+
const result = await Result.fromAsync(() => access(filePath));
|
|
5
|
+
return result.isOk();
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=FileExists.js.map
|
package/package.json
CHANGED
|
@@ -1,116 +1,121 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
2
|
+
"name": "@sapphire/cli",
|
|
3
|
+
"version": "1.2.1-next.00d2a50.0",
|
|
4
|
+
"description": "CLI for Sapphire Framework",
|
|
5
|
+
"author": "@sapphire",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/cli.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"sapphire": "./dist/cli.js"
|
|
11
|
+
},
|
|
12
|
+
"imports": {
|
|
13
|
+
"#prompts/*": "./dist/prompts/*.js",
|
|
14
|
+
"#functions/*": "./dist/functions/*.js",
|
|
15
|
+
"#commands/*": "./dist/commands/*.js",
|
|
16
|
+
"#constants": "./dist/constants.js"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": "false",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"!dist/*.tsbuildinfo",
|
|
22
|
+
"!dist/**/*.js.map",
|
|
23
|
+
"!dist/**/*.d.ts",
|
|
24
|
+
"!dist/**/*.d.ts.map",
|
|
25
|
+
"templates"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"lint": "eslint src --ext ts --fix",
|
|
29
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
30
|
+
"update": "yarn upgrade-interactive",
|
|
31
|
+
"build": "tsc -b src",
|
|
32
|
+
"clean": "tsc -b src --clean",
|
|
33
|
+
"watch": "tsc -b src -w",
|
|
34
|
+
"bump": "cliff-jumper",
|
|
35
|
+
"check-update": "cliff-jumper --dry-run",
|
|
36
|
+
"_postinstall": "husky install .github/husky",
|
|
37
|
+
"prepack": "yarn build && pinst --disable",
|
|
38
|
+
"postpack": "pinst --enable"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@favware/colorette-spinner": "^1.0.0",
|
|
42
|
+
"@sapphire/result": "^2.0.1",
|
|
43
|
+
"colorette": "^2.0.19",
|
|
44
|
+
"commander": "^9.4.0",
|
|
45
|
+
"execa": "^6.1.0",
|
|
46
|
+
"find-up": "^5.0.0",
|
|
47
|
+
"js-yaml": "^4.1.0",
|
|
48
|
+
"prompts": "^2.4.2",
|
|
49
|
+
"tslib": "^2.4.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@commitlint/cli": "^17.0.3",
|
|
53
|
+
"@commitlint/config-conventional": "^17.0.3",
|
|
54
|
+
"@favware/cliff-jumper": "^1.8.5",
|
|
55
|
+
"@favware/npm-deprecate": "^1.0.4",
|
|
56
|
+
"@sapphire/eslint-config": "^4.3.7",
|
|
57
|
+
"@sapphire/prettier-config": "^1.4.3",
|
|
58
|
+
"@sapphire/ts-config": "^3.3.4",
|
|
59
|
+
"@types/js-yaml": "^4.0.5",
|
|
60
|
+
"@types/node": "^18.0.1",
|
|
61
|
+
"@types/prompts": "^2.4.0",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
63
|
+
"@typescript-eslint/parser": "^5.30.6",
|
|
64
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
65
|
+
"eslint": "^8.20.0",
|
|
66
|
+
"eslint-config-prettier": "^8.5.0",
|
|
67
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
68
|
+
"globby": "^13.1.2",
|
|
69
|
+
"husky": "^8.0.1",
|
|
70
|
+
"lint-staged": "^13.0.3",
|
|
71
|
+
"pinst": "^3.0.0",
|
|
72
|
+
"prettier": "^2.7.1",
|
|
73
|
+
"pretty-quick": "^3.1.3",
|
|
74
|
+
"ts-node": "^10.9.1",
|
|
75
|
+
"typescript": "^4.7.4"
|
|
76
|
+
},
|
|
77
|
+
"resolutions": {
|
|
78
|
+
"ansi-regex": "^5.0.1",
|
|
79
|
+
"minimist": "^1.2.6"
|
|
80
|
+
},
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=v16.6.0",
|
|
83
|
+
"npm": ">=7.0.0"
|
|
84
|
+
},
|
|
85
|
+
"keywords": [
|
|
86
|
+
"@sapphire/cli",
|
|
87
|
+
"bot",
|
|
88
|
+
"typescript",
|
|
89
|
+
"ts",
|
|
90
|
+
"yarn",
|
|
91
|
+
"discord",
|
|
92
|
+
"sapphire",
|
|
93
|
+
"discordjs"
|
|
94
|
+
],
|
|
95
|
+
"repository": {
|
|
96
|
+
"type": "git",
|
|
97
|
+
"url": "git+https://github.com/sapphiredev/cli.git"
|
|
98
|
+
},
|
|
99
|
+
"bugs": {
|
|
100
|
+
"url": "https://github.com/sapphiredev/cli/issues"
|
|
101
|
+
},
|
|
102
|
+
"homepage": "https://www.sapphirejs.dev",
|
|
103
|
+
"commitlint": {
|
|
104
|
+
"extends": [
|
|
105
|
+
"@commitlint/config-conventional"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"lint-staged": {
|
|
109
|
+
"*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts"
|
|
110
|
+
},
|
|
111
|
+
"config": {
|
|
112
|
+
"commitizen": {
|
|
113
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"publishConfig": {
|
|
117
|
+
"access": "public"
|
|
118
|
+
},
|
|
119
|
+
"prettier": "@sapphire/prettier-config",
|
|
120
|
+
"packageManager": "yarn@3.2.1"
|
|
121
|
+
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as colorette from 'colorette';
|
|
2
|
-
import tty from 'node:tty';
|
|
3
|
-
/**
|
|
4
|
-
* A very minimal terminal spinner
|
|
5
|
-
*
|
|
6
|
-
* @license ISC
|
|
7
|
-
* @copyright 2021 Usman Yunusov <usman.iunusov@gmail.com>
|
|
8
|
-
* @see https://github.com/usmanyunusov/nanospinner/blob/master/index.js
|
|
9
|
-
*/
|
|
10
|
-
export class Spinner {
|
|
11
|
-
#isCI = process.env.CI ||
|
|
12
|
-
process.env.WT_SESSION ||
|
|
13
|
-
process.env.ConEmuTask === '{cmd::Cmder}' ||
|
|
14
|
-
process.env.TERM_PROGRAM === 'vscode' ||
|
|
15
|
-
process.env.TERM === 'xterm-256color' ||
|
|
16
|
-
process.env.TERM === 'alacritty';
|
|
17
|
-
#isTTY = tty.isatty(1) && process.env.TERM !== 'dumb' && !('CI' in process.env);
|
|
18
|
-
#supportUnicode = process.platform === 'win32' ? this.#isCI : process.env.TERM !== 'linux';
|
|
19
|
-
#symbols = {
|
|
20
|
-
frames: this.#isTTY ? (this.#supportUnicode ? ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] : ['-', '\\', '|', '/']) : ['-'],
|
|
21
|
-
tick: this.#supportUnicode ? '✔' : '√',
|
|
22
|
-
cross: this.#supportUnicode ? '✖' : '×'
|
|
23
|
-
};
|
|
24
|
-
#text = '';
|
|
25
|
-
#current = 0;
|
|
26
|
-
#interval = 50;
|
|
27
|
-
#stream = process.stderr;
|
|
28
|
-
#frames = this.#symbols.frames;
|
|
29
|
-
#color = 'greenBright';
|
|
30
|
-
#lines = 0;
|
|
31
|
-
#timer;
|
|
32
|
-
constructor(text, options) {
|
|
33
|
-
this.#text = text ?? this.#text;
|
|
34
|
-
this.#interval = options?.interval ?? this.#interval;
|
|
35
|
-
this.#stream = options?.stream ?? this.#stream;
|
|
36
|
-
if (options?.frames && options?.frames.length) {
|
|
37
|
-
this.#frames = options.frames;
|
|
38
|
-
}
|
|
39
|
-
this.#color = options?.color ?? this.#color;
|
|
40
|
-
}
|
|
41
|
-
clear() {
|
|
42
|
-
this.write('\x1b[1G');
|
|
43
|
-
for (let i = 0; i < this.#lines; i++) {
|
|
44
|
-
i > 0 && this.write('\x1b[1A');
|
|
45
|
-
this.write('\x1b[2K\x1b[1G');
|
|
46
|
-
}
|
|
47
|
-
this.#lines = 0;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
error(options) {
|
|
51
|
-
const mark = colorette.red(this.#symbols.cross);
|
|
52
|
-
return this.stop({ mark, ...options });
|
|
53
|
-
}
|
|
54
|
-
reset() {
|
|
55
|
-
this.#current = 0;
|
|
56
|
-
this.#lines = 0;
|
|
57
|
-
if (this.#timer) {
|
|
58
|
-
clearTimeout(this.#timer);
|
|
59
|
-
}
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
spin() {
|
|
63
|
-
this.render();
|
|
64
|
-
this.#current = ++this.#current % this.#frames.length;
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
start(opts = {}) {
|
|
68
|
-
this.#timer && this.reset();
|
|
69
|
-
return this.update({ text: opts.text, color: opts.color }).loop();
|
|
70
|
-
}
|
|
71
|
-
stop(opts = {}) {
|
|
72
|
-
if (this.#timer) {
|
|
73
|
-
clearTimeout(this.#timer);
|
|
74
|
-
}
|
|
75
|
-
const mark = colorette[opts.color || this.#color](this.#frames[this.#current]);
|
|
76
|
-
const optsMark = opts.mark && opts.color ? colorette[opts.color](opts.mark) : opts.mark;
|
|
77
|
-
this.write(`${optsMark || mark} ${opts.text || this.#text}\n`, true);
|
|
78
|
-
return this.#isTTY ? this.write(`\x1b[?25h`) : this;
|
|
79
|
-
}
|
|
80
|
-
success(opts = {}) {
|
|
81
|
-
const mark = colorette.green(this.#symbols.tick);
|
|
82
|
-
return this.stop({ mark, ...opts });
|
|
83
|
-
}
|
|
84
|
-
update(opts = {}) {
|
|
85
|
-
this.#text = opts.text || this.#text;
|
|
86
|
-
this.#interval = opts?.interval ?? this.#interval;
|
|
87
|
-
this.#stream = opts?.stream ?? this.#stream;
|
|
88
|
-
if (opts?.frames && opts?.frames.length) {
|
|
89
|
-
this.#frames = opts.frames;
|
|
90
|
-
}
|
|
91
|
-
this.#color = opts?.color ?? this.#color;
|
|
92
|
-
if (this.#frames.length - 1 < this.#current) {
|
|
93
|
-
this.#current = 0;
|
|
94
|
-
}
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
loop() {
|
|
98
|
-
this.#isTTY && (this.#timer = setTimeout(() => this.loop(), this.#interval));
|
|
99
|
-
return this.spin();
|
|
100
|
-
}
|
|
101
|
-
write(str, clear = false) {
|
|
102
|
-
if (clear && this.#isTTY) {
|
|
103
|
-
this.clear();
|
|
104
|
-
}
|
|
105
|
-
this.#stream.write(str);
|
|
106
|
-
return this;
|
|
107
|
-
}
|
|
108
|
-
render() {
|
|
109
|
-
const mark = colorette[this.#color](this.#frames[this.#current]);
|
|
110
|
-
let str = `${mark} ${this.#text}`;
|
|
111
|
-
this.#isTTY ? this.write(`\x1b[?25l`) : (str += '\n');
|
|
112
|
-
this.write(str, true);
|
|
113
|
-
this.#isTTY && (this.#lines = this.getLines(str, this.#stream.columns));
|
|
114
|
-
}
|
|
115
|
-
getLines(str = '', width = 80) {
|
|
116
|
-
return str
|
|
117
|
-
.replace(/\u001b[^m]*?m/g, '')
|
|
118
|
-
.split('\n')
|
|
119
|
-
.reduce((col, line) => (col += Math.max(1, Math.ceil(line.length / width))), 0);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
//# sourceMappingURL=Spinner.js.map
|