create-commandkit 1.1.4-dev.20250701022249 → 1.1.4-dev.20250701125344
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/dist/functions/installDeps.js +16 -3
- package/dist/functions/setup.js +19 -13
- package/dist/index.js +21 -5
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +2 -3
- package/dist/utils.js +15 -4
- package/package.json +2 -2
|
@@ -8,22 +8,35 @@ const baseDependencies = [
|
|
|
8
8
|
const dependencies = {
|
|
9
9
|
js: {
|
|
10
10
|
dependencies: baseDependencies,
|
|
11
|
-
devDependencies: ['@types/node'],
|
|
11
|
+
devDependencies: ['@types/node', 'typescript'],
|
|
12
12
|
},
|
|
13
13
|
ts: {
|
|
14
14
|
dependencies: baseDependencies,
|
|
15
15
|
devDependencies: ['@types/node', 'typescript'],
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
|
+
function getInstallCommand(manager, deps, dev = false) {
|
|
19
|
+
switch (manager) {
|
|
20
|
+
case 'npm':
|
|
21
|
+
case 'pnpm':
|
|
22
|
+
case 'yarn':
|
|
23
|
+
case 'bun':
|
|
24
|
+
return `${manager} add ${dev ? '-D' : ''} ${deps.join(' ')}`;
|
|
25
|
+
case 'deno':
|
|
26
|
+
return `deno add ${dev ? '--dev' : ''} ${deps.map((d) => `npm:${d}`).join(' ')}`;
|
|
27
|
+
default:
|
|
28
|
+
return manager;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
18
31
|
export function installDeps({ manager, dir, lang, stdio = 'inherit', }) {
|
|
19
32
|
const spinner = ora('Installing dependencies...').start();
|
|
20
33
|
try {
|
|
21
34
|
if (dependencies[lang].dependencies.length) {
|
|
22
|
-
const depsCommand =
|
|
35
|
+
const depsCommand = getInstallCommand(manager, dependencies[lang].dependencies);
|
|
23
36
|
execSync(depsCommand, { cwd: dir, stdio });
|
|
24
37
|
}
|
|
25
38
|
if (dependencies[lang].devDependencies.length) {
|
|
26
|
-
const devDepsCommand =
|
|
39
|
+
const devDepsCommand = getInstallCommand(manager, dependencies[lang].devDependencies, true);
|
|
27
40
|
execSync(devDepsCommand, { cwd: dir, stdio });
|
|
28
41
|
}
|
|
29
42
|
spinner.succeed('Dependencies installed successfully!');
|
package/dist/functions/setup.js
CHANGED
|
@@ -4,20 +4,26 @@ import path from 'node:path';
|
|
|
4
4
|
import { commands } from '../utils.js';
|
|
5
5
|
export async function setup({ manager, token, dir, stdio = 'pipe', }) {
|
|
6
6
|
await fs.emptyDir(dir);
|
|
7
|
-
|
|
7
|
+
if (manager === 'yarn') {
|
|
8
|
+
execSync(commands.init.yarn, { cwd: dir, stdio });
|
|
9
|
+
}
|
|
8
10
|
const packageJsonPath = path.join(dir, 'package.json');
|
|
9
|
-
const packageJson =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const packageJson = {
|
|
12
|
+
name: dir.replaceAll('\\', '/').split('/').pop()?.toLowerCase() ||
|
|
13
|
+
'commandkit-project',
|
|
14
|
+
description: 'A CommandKit project',
|
|
15
|
+
version: '0.1.0',
|
|
16
|
+
type: 'module',
|
|
17
|
+
private: true,
|
|
18
|
+
main: 'dist/index.js',
|
|
19
|
+
scripts: {
|
|
20
|
+
dev: 'commandkit dev',
|
|
21
|
+
build: 'commandkit build',
|
|
22
|
+
start: 'commandkit start',
|
|
23
|
+
},
|
|
24
|
+
devDependencies: {},
|
|
25
|
+
dependencies: {},
|
|
20
26
|
};
|
|
21
27
|
await fs.writeJSON(packageJsonPath, packageJson, { spaces: 2 });
|
|
22
|
-
await fs.writeFile(`${dir}/.env`, `DISCORD_TOKEN="${token}"`);
|
|
28
|
+
await fs.writeFile(`${dir}/.env`, `DISCORD_TOKEN="${token || ''}"`);
|
|
23
29
|
}
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import colors from 'picocolors';
|
|
|
9
9
|
import { copyTemplates } from './functions/copyTemplates.js';
|
|
10
10
|
import { installDeps } from './functions/installDeps.js';
|
|
11
11
|
import { setup } from './functions/setup.js';
|
|
12
|
-
import { textColors } from './utils.js';
|
|
12
|
+
import { detectPackageManager, textColors } from './utils.js';
|
|
13
13
|
const commandkitGradient = gradient(textColors.commandkit)('CommandKit');
|
|
14
14
|
intro(`Welcome to ${commandkitGradient}!`);
|
|
15
15
|
const dir = path.resolve(process.cwd(), (await text({
|
|
@@ -31,12 +31,13 @@ const dir = path.resolve(process.cwd(), (await text({
|
|
|
31
31
|
})));
|
|
32
32
|
const manager = (await select({
|
|
33
33
|
message: 'Select a package manager:',
|
|
34
|
-
initialValue:
|
|
34
|
+
initialValue: detectPackageManager(),
|
|
35
35
|
options: [
|
|
36
36
|
{ label: 'npm', value: 'npm' },
|
|
37
37
|
{ label: 'pnpm', value: 'pnpm' },
|
|
38
38
|
{ label: 'yarn', value: 'yarn' },
|
|
39
39
|
{ label: 'bun', value: 'bun' },
|
|
40
|
+
{ label: 'deno', value: 'deno' },
|
|
40
41
|
],
|
|
41
42
|
}));
|
|
42
43
|
const lang = (await select({
|
|
@@ -76,12 +77,27 @@ installDeps({
|
|
|
76
77
|
lang,
|
|
77
78
|
stdio: 'pipe',
|
|
78
79
|
});
|
|
80
|
+
const command = (cmd) => {
|
|
81
|
+
switch (manager) {
|
|
82
|
+
case 'npm':
|
|
83
|
+
// bun build runs bundler instead of the build script
|
|
84
|
+
case 'bun':
|
|
85
|
+
return `${manager} run ${cmd}`;
|
|
86
|
+
case 'pnpm':
|
|
87
|
+
case 'yarn':
|
|
88
|
+
return `${manager} ${cmd}`;
|
|
89
|
+
case 'deno':
|
|
90
|
+
return `deno task ${cmd}`;
|
|
91
|
+
default:
|
|
92
|
+
return manager;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
79
95
|
console.log(`${gradient(textColors.commandkit)('Thank you for choosing CommandKit!')}
|
|
80
96
|
|
|
81
97
|
To start your bot, use the following commands:
|
|
82
|
-
${colors.magenta(
|
|
83
|
-
${colors.magenta(
|
|
84
|
-
${colors.magenta(
|
|
98
|
+
${colors.magenta(command('dev'))} - Run your bot in development mode
|
|
99
|
+
${colors.magenta(command('build'))} - Build your bot for production
|
|
100
|
+
${colors.magenta(command('start'))} - Run your bot in production mode
|
|
85
101
|
|
|
86
102
|
• Documentation: ${colors.blue('https://commandkit.dev')}
|
|
87
103
|
• GitHub: ${colors.blue('https://github.com/underctrl-io/commandkit')}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type Language = 'js' | 'ts';
|
|
2
|
-
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
2
|
+
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun' | 'deno';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PackageManager } from './types';
|
|
1
2
|
export declare const textColors: {
|
|
2
3
|
commandkit: string[];
|
|
3
4
|
js: string[];
|
|
@@ -5,9 +6,7 @@ export declare const textColors: {
|
|
|
5
6
|
};
|
|
6
7
|
export declare const commands: {
|
|
7
8
|
init: {
|
|
8
|
-
npm: string;
|
|
9
9
|
yarn: string;
|
|
10
|
-
pnpm: string;
|
|
11
|
-
bun: string;
|
|
12
10
|
};
|
|
13
11
|
};
|
|
12
|
+
export declare function detectPackageManager(): PackageManager;
|
package/dist/utils.js
CHANGED
|
@@ -5,9 +5,20 @@ export const textColors = {
|
|
|
5
5
|
};
|
|
6
6
|
export const commands = {
|
|
7
7
|
init: {
|
|
8
|
-
|
|
9
|
-
yarn: 'yarn init -y; yarn set version stable; yarn config set nodeLinker node-modules;',
|
|
10
|
-
pnpm: 'pnpm init',
|
|
11
|
-
bun: 'bun init -y -m',
|
|
8
|
+
yarn: 'yarn set version stable; yarn config set nodeLinker node-modules;',
|
|
12
9
|
},
|
|
13
10
|
};
|
|
11
|
+
export function detectPackageManager() {
|
|
12
|
+
const packageManager = process.env.npm_config_user_agent;
|
|
13
|
+
if (packageManager?.includes('pnpm'))
|
|
14
|
+
return 'pnpm';
|
|
15
|
+
if (packageManager?.includes('yarn'))
|
|
16
|
+
return 'yarn';
|
|
17
|
+
if (packageManager?.includes('bun'))
|
|
18
|
+
return 'bun';
|
|
19
|
+
if (packageManager?.includes('npm'))
|
|
20
|
+
return 'npm';
|
|
21
|
+
if (packageManager?.includes('deno'))
|
|
22
|
+
return 'deno';
|
|
23
|
+
return 'npm';
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-commandkit",
|
|
3
3
|
"description": "Effortlessly create a CommandKit project",
|
|
4
|
-
"version": "1.1.4-dev.
|
|
4
|
+
"version": "1.1.4-dev.20250701125344",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"bin": "./dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/gradient-string": "^1.1.5",
|
|
40
40
|
"@types/node": "^22.0.0",
|
|
41
41
|
"typescript": "^5.3.3",
|
|
42
|
-
"tsconfig": "0.0.0-dev.
|
|
42
|
+
"tsconfig": "0.0.0-dev.20250701125344"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"lint": "tsc --noEmit",
|