create-commandkit 1.0.1 → 1.1.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 CHANGED
@@ -3,7 +3,7 @@
3
3
  <br />
4
4
  <a href="https://ctrl.lol/discord"><img src="https://img.shields.io/discord/1055188344188973066?color=5865F2&logo=discord&logoColor=white" alt="support server" /></a>
5
5
  <a href="https://www.npmjs.com/package/commandkit"><img src="https://img.shields.io/npm/v/commandkit?maxAge=3600&label=commandkit" alt="commandkit version" /></a>
6
- <a href="https://www.npmjs.com/package/commandkit"><img src="https://img.shields.io/npm/v/create-commandkit?maxAge=3600&label=create-commandkit" alt="create-commandkit version" /></a>
6
+ <a href="https://www.npmjs.com/package/create-commandkit"><img src="https://img.shields.io/npm/v/create-commandkit?maxAge=3600&label=create-commandkit" alt="create-commandkit version" /></a>
7
7
  <a href="https://www.npmjs.com/package/commandkit"><img src="https://img.shields.io/npm/dt/commandkit?maxAge=3600" alt="npm downloads" /></a>
8
8
  </div>
9
9
 
@@ -13,12 +13,10 @@ A command-line interface (CLI) to quickly generate a discord.js bot using Comman
13
13
 
14
14
  ## Usage
15
15
 
16
- Run one of the following commands:
16
+ Run the following command in your terminal:
17
17
 
18
18
  ```sh
19
- npm create commandkit
20
- pnpm create commandkit
21
- yarn create commandkit
19
+ npm create commandkit@latest
22
20
  ```
23
21
 
24
22
  ## Setup Options
@@ -28,7 +26,8 @@ yarn create commandkit
28
26
  - Module type (ESM/CommonJS)
29
27
  - Bot token (written to .env)
30
28
 
31
- ## Repositories
29
+ ## Links
32
30
 
33
- - [CommandKit](https://github.com/underctrl-io/commandkit)
34
- - [create-commandkit](https://github.com/m1-dev/create-commandkit)
31
+ - [GitHub](https://github.com/m1-dev/create-commandkit)
32
+ - [Discord](https://ctrl.lol/discord)
33
+ - [npm](https://npmjs.com/package/create-commandkit)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-commandkit",
3
3
  "description": "Start a new CommandKit project with ease.",
4
- "version": "1.0.1",
4
+ "version": "1.1.0",
5
5
  "main": "src/index.js",
6
6
  "bin": "src/index.js",
7
7
  "type": "commonjs",
@@ -13,8 +13,8 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "@clack/prompts": "^0.7.0",
16
- "gradient-string": "^2.0.2",
16
+ "colors": "^1.4.0",
17
17
  "fs-extra": "^11.1.1",
18
- "colors": "^1.4.0"
18
+ "gradient-string": "^2.0.2"
19
19
  }
20
- }
20
+ }
@@ -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
+ `;
@@ -1,4 +1,4 @@
1
- const { templates } = require('../config');
1
+ const { templates } = require('../constants');
2
2
  const fs = require('fs-extra');
3
3
 
4
4
  module.exports = async ({ type, dir, lang }) => {
@@ -1,4 +1,4 @@
1
- const { commands } = require('../config');
1
+ const { commands } = require('../constants');
2
2
  const { execSync: ex } = require('child_process');
3
3
 
4
4
  module.exports = async ({ manager, dir, stdio = 'pipe' }) => {
@@ -1,5 +1,5 @@
1
1
  const { execSync: ex } = require('child_process');
2
- const { commands } = require('../config');
2
+ const { commands } = require('../constants');
3
3
 
4
4
  const fs = require('fs-extra');
5
5
  const path = require('path');
package/src/index.js CHANGED
@@ -1,55 +1,60 @@
1
1
  #!/usr/bin/env node
2
2
  console.clear();
3
3
 
4
- const { gray } = require('colors');
5
- const { commandkit, hints } = require('./config');
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 { dir, manager, type, token } = {
20
- dir: path.resolve(process.cwd(), await prompts.text({
21
- message: 'Enter a project directory:',
22
- placeholder: 'Leave blank for current directory',
23
- defaultValue: '.',
24
- })),
25
-
26
- manager: await prompts.select({
27
- message: 'Select a package manager:',
28
- options: [{ value: 'npm' }, { value: 'pnpm' }, { value: 'yarn' }],
29
- }),
30
-
31
- type: await prompts.select({
32
- message: 'Select a module type:',
33
- options: [
34
- { label: 'CommonJS', value: 'cjs', hint: `${hints.require} & ${hints.module}` },
35
- { label: 'ES Modules', value: 'esm', hint: `${hints.import} & ${hints.export}` },
36
- ]
37
- }),
38
-
39
- token: await prompts.password({
40
- message: 'Enter your bot token:',
41
- mask: gray('*')
42
- })
43
- }
44
-
45
- const spinner = prompts.spinner();
46
- spinner.start('Setting up project');
47
-
48
- await setup({ manager, token, dir, type });
49
- await installDeps({ manager, dir });
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
+ let isEmpty;
25
+
26
+ try {
27
+ const contents = fs.readdirSync(value);
28
+ isEmpty = contents.length === 0;
29
+ } catch { isEmpty = true }
30
+
31
+ return isEmpty ? undefined : 'Directory is not empty!';
32
+ }
33
+ }));
34
+
35
+ const manager = await prompts.select({
36
+ message: 'Select a package manager:',
37
+ options: [{ value: 'npm' }, { value: 'pnpm' }, { value: 'yarn' }],
38
+ });
39
+
40
+ const type = await prompts.select({
41
+ message: 'Select a module type:',
42
+ options: [
43
+ { label: 'CommonJS', value: 'cjs', hint: `${hints.require} & ${hints.module}` },
44
+ { label: 'ES Modules', value: 'esm', hint: `${hints.import} & ${hints.export}` },
45
+ ]
46
+ });
47
+
48
+ const token = await prompts.password({
49
+ message: 'Enter your bot token:',
50
+ mask: gray('*')
51
+ });
52
+
53
+ prompts.outro(cyan('Setup complete.'));
54
+
55
+ await setup({ manager, dir, token, type });
50
56
  await copyTemplates({ type, dir, lang: 'js' });
57
+ await installDeps({ manager, dir, stdio: 'inherit' });
51
58
 
52
- spinner.stop('Setup done.');
53
-
54
- prompts.outro(gradient.summer('Happy coding!'));
59
+ console.log(outroMsg);
55
60
  })();
@@ -0,0 +1,5 @@
1
+ Thank you for using CommandKit!
2
+
3
+ Helpful resources:
4
+ • Documentation — https://commandkit.js.org
5
+ • Join us on Discord — https://ctrl.lol/discord