create-commandkit 1.0.2 → 1.1.1
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/package.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const gradient = require('gradient-string');
|
|
2
|
+
const colors = require('colors');
|
|
3
|
+
const fs = require('fs-extra');
|
|
2
4
|
|
|
3
5
|
exports.templates = {
|
|
4
6
|
js: {
|
|
@@ -35,4 +37,10 @@ exports.hints = {
|
|
|
35
37
|
typescript: gradient(exports.colors.ts)('TypeScript')
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
exports.commandkit = gradient(exports.colors.commandkit)('CommandKit');
|
|
40
|
+
exports.commandkit = gradient(exports.colors.commandkit)('CommandKit');
|
|
41
|
+
exports.outroMsg = `
|
|
42
|
+
${gradient(exports.colors.commandkit)('Thank you for choosing CommandKit!')}
|
|
43
|
+
|
|
44
|
+
• Documentation: ${colors.blue('https://commandkit.js.org')}
|
|
45
|
+
• Join us on Discord: ${colors.blue('https://ctrl.lol/discord')}
|
|
46
|
+
`;
|
package/src/functions/setup.js
CHANGED
package/src/index.js
CHANGED
|
@@ -1,55 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
console.clear();
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const prompts = require('@clack/prompts');
|
|
5
|
+
|
|
6
|
+
const { gray, cyan } = require('colors');
|
|
7
|
+
const { commandkit, hints, outroMsg } = require('./constants');
|
|
6
8
|
|
|
7
9
|
const setup = require('./functions/setup');
|
|
8
10
|
const installDeps = require('./functions/installDeps');
|
|
9
11
|
const copyTemplates = require('./functions/copyTemplates');
|
|
10
12
|
|
|
11
|
-
const prompts = require('@clack/prompts');
|
|
12
13
|
const path = require('path');
|
|
13
|
-
|
|
14
|
-
const gradient = require('gradient-string');
|
|
14
|
+
const fs = require('fs-extra');
|
|
15
15
|
|
|
16
16
|
(async () => {
|
|
17
17
|
prompts.intro(`Welcome to ${commandkit}!`);
|
|
18
18
|
|
|
19
|
-
const
|
|
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
|
-
await
|
|
19
|
+
const dir = path.resolve(process.cwd(), await prompts.text({
|
|
20
|
+
message: 'Enter a project directory:',
|
|
21
|
+
placeholder: 'Leave blank for current directory',
|
|
22
|
+
defaultValue: '.',
|
|
23
|
+
validate: (value) => {
|
|
24
|
+
value = path.resolve(process.cwd(), value);
|
|
25
|
+
let isEmpty;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const contents = fs.readdirSync(value);
|
|
29
|
+
isEmpty = contents.length === 0;
|
|
30
|
+
} catch { isEmpty = true }
|
|
31
|
+
|
|
32
|
+
return isEmpty ? undefined : 'Directory is not empty!';
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
const manager = await prompts.select({
|
|
37
|
+
message: 'Select a package manager:',
|
|
38
|
+
options: [{ value: 'npm' }, { value: 'pnpm' }, { value: 'yarn' }],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const type = await prompts.select({
|
|
42
|
+
message: 'Select a module type:',
|
|
43
|
+
options: [
|
|
44
|
+
{ label: 'CommonJS', value: 'cjs', hint: `${hints.require} & ${hints.module}` },
|
|
45
|
+
{ label: 'ES Modules', value: 'esm', hint: `${hints.import} & ${hints.export}` },
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const token = await prompts.password({
|
|
50
|
+
message: 'Enter your bot token:',
|
|
51
|
+
mask: gray('*')
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
prompts.outro(cyan('Setup complete.'));
|
|
55
|
+
|
|
56
|
+
await setup({ manager, dir, token, type });
|
|
50
57
|
await copyTemplates({ type, dir, lang: 'js' });
|
|
58
|
+
await installDeps({ manager, dir, stdio: 'inherit' });
|
|
51
59
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
prompts.outro(gradient.summer('Happy coding!'));
|
|
60
|
+
console.log(outroMsg);
|
|
55
61
|
})();
|