commandkit 0.1.6-dev.20231112142450 → 0.1.6-dev.20231112143016
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/bin/build.mjs +14 -11
- package/bin/common.mjs +3 -3
- package/bin/dev-server.mjs +21 -19
- package/bin/index.mjs +7 -5
- package/package.json +1 -1
package/bin/build.mjs
CHANGED
|
@@ -5,12 +5,7 @@ import ora from 'ora';
|
|
|
5
5
|
import { Colors, erase, findCommandKitJSON, panic, write } from './common.mjs';
|
|
6
6
|
|
|
7
7
|
export async function bootstrapProductionBuild(config) {
|
|
8
|
-
const {
|
|
9
|
-
minify = false,
|
|
10
|
-
outDir = 'dist',
|
|
11
|
-
main,
|
|
12
|
-
src,
|
|
13
|
-
} = findCommandKitJSON(config);
|
|
8
|
+
const { minify = false, outDir = 'dist', main, src } = findCommandKitJSON(config);
|
|
14
9
|
|
|
15
10
|
const status = ora('Creating optimized production build...\n').start();
|
|
16
11
|
const start = performance.now();
|
|
@@ -26,7 +21,7 @@ export async function bootstrapProductionBuild(config) {
|
|
|
26
21
|
minify,
|
|
27
22
|
shims: true,
|
|
28
23
|
banner: {
|
|
29
|
-
js: '/* Optimized production build of your project, generated by CommandKit */'
|
|
24
|
+
js: '/* Optimized production build of your project, generated by CommandKit */',
|
|
30
25
|
},
|
|
31
26
|
sourcemap: false,
|
|
32
27
|
keepNames: true,
|
|
@@ -35,10 +30,18 @@ export async function bootstrapProductionBuild(config) {
|
|
|
35
30
|
entry: [src, '!dist', '!.commandkit'],
|
|
36
31
|
});
|
|
37
32
|
|
|
38
|
-
status.succeed(
|
|
39
|
-
|
|
33
|
+
status.succeed(
|
|
34
|
+
Colors.green(`Build completed in ${(performance.now() - start).toFixed(2)}ms!`),
|
|
35
|
+
);
|
|
36
|
+
write(
|
|
37
|
+
Colors.green(
|
|
38
|
+
`\nRun ${Colors.magenta(`node ${outDir}/${main}`)} ${Colors.green(
|
|
39
|
+
'to start your bot.',
|
|
40
|
+
)}`,
|
|
41
|
+
),
|
|
42
|
+
);
|
|
40
43
|
} catch (e) {
|
|
41
|
-
status.fail(`Build failed after ${(performance.now() - start).toFixed(2)}ms!`)
|
|
44
|
+
status.fail(`Build failed after ${(performance.now() - start).toFixed(2)}ms!`);
|
|
42
45
|
panic(e);
|
|
43
46
|
}
|
|
44
|
-
}
|
|
47
|
+
}
|
package/bin/common.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import { join } from 'node:path'
|
|
3
|
+
import { join } from 'node:path';
|
|
4
4
|
import fs from 'node:fs';
|
|
5
|
-
import { rimrafSync } from 'rimraf'
|
|
5
|
+
import { rimrafSync } from 'rimraf';
|
|
6
6
|
|
|
7
7
|
const resetColor = '\x1b[0m';
|
|
8
8
|
|
|
@@ -71,4 +71,4 @@ export function findCommandKitJSON(src) {
|
|
|
71
71
|
|
|
72
72
|
export function erase(dir) {
|
|
73
73
|
rimrafSync(dir);
|
|
74
|
-
}
|
|
74
|
+
}
|
package/bin/dev-server.mjs
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { config as dotenv } from 'dotenv'
|
|
2
|
+
import { config as dotenv } from 'dotenv';
|
|
3
3
|
import { build } from 'tsup';
|
|
4
|
-
import child_process from 'node:child_process'
|
|
4
|
+
import child_process from 'node:child_process';
|
|
5
5
|
import ora from 'ora';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { Colors, erase, findCommandKitJSON, panic, write } from './common.mjs';
|
|
8
8
|
|
|
9
9
|
export async function bootstrapDevelopmentServer(config) {
|
|
10
|
-
const {
|
|
11
|
-
src,
|
|
12
|
-
main = 'index.mjs',
|
|
13
|
-
nodeOptions = ['--watch']
|
|
14
|
-
} = findCommandKitJSON(config);
|
|
10
|
+
const { src, main = 'index.mjs', nodeOptions = ['--watch'] } = findCommandKitJSON(config);
|
|
15
11
|
|
|
16
12
|
if (!src) {
|
|
17
13
|
panic('Could not find src in commandkit.json');
|
|
@@ -38,14 +34,16 @@ export async function bootstrapDevelopmentServer(config) {
|
|
|
38
34
|
watch: nodeOptions.includes('--watch'),
|
|
39
35
|
});
|
|
40
36
|
|
|
41
|
-
status.succeed(
|
|
37
|
+
status.succeed(
|
|
38
|
+
Colors.green(`Server started in ${(performance.now() - start).toFixed(2)}ms!\n`),
|
|
39
|
+
);
|
|
42
40
|
|
|
43
41
|
const processEnv = {};
|
|
44
42
|
|
|
45
43
|
const env = dotenv({
|
|
46
44
|
path: join(process.cwd(), '.env'),
|
|
47
45
|
// @ts-expect-error
|
|
48
|
-
processEnv
|
|
46
|
+
processEnv,
|
|
49
47
|
});
|
|
50
48
|
|
|
51
49
|
if (env.error) {
|
|
@@ -56,15 +54,19 @@ export async function bootstrapDevelopmentServer(config) {
|
|
|
56
54
|
write(Colors.blue('[DOTENV] Loaded .env file!'));
|
|
57
55
|
}
|
|
58
56
|
|
|
59
|
-
const ps = child_process.spawn(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
const ps = child_process.spawn(
|
|
58
|
+
'node',
|
|
59
|
+
[...nodeOptions, join(process.cwd(), '.commandkit', main)],
|
|
60
|
+
{
|
|
61
|
+
env: {
|
|
62
|
+
...process.env,
|
|
63
|
+
...processEnv,
|
|
64
|
+
NODE_ENV: 'development',
|
|
65
|
+
COMMANDKIT_DEV: 'true',
|
|
66
|
+
},
|
|
67
|
+
cwd: process.cwd(),
|
|
65
68
|
},
|
|
66
|
-
|
|
67
|
-
});
|
|
69
|
+
);
|
|
68
70
|
|
|
69
71
|
ps.stdout.on('data', (data) => {
|
|
70
72
|
write(data.toString());
|
|
@@ -83,7 +85,7 @@ export async function bootstrapDevelopmentServer(config) {
|
|
|
83
85
|
panic(err);
|
|
84
86
|
});
|
|
85
87
|
} catch (e) {
|
|
86
|
-
status.fail(`Error occurred after ${(performance.now() - start).toFixed(2)}ms!\n`)
|
|
88
|
+
status.fail(`Error occurred after ${(performance.now() - start).toFixed(2)}ms!\n`);
|
|
87
89
|
panic(e);
|
|
88
90
|
}
|
|
89
|
-
}
|
|
91
|
+
}
|
package/bin/index.mjs
CHANGED
|
@@ -8,20 +8,22 @@ import { bootstrapProductionBuild } from './build.mjs';
|
|
|
8
8
|
|
|
9
9
|
const program = new Command('commandkit');
|
|
10
10
|
|
|
11
|
-
program
|
|
11
|
+
program
|
|
12
|
+
.command('dev')
|
|
12
13
|
.description('Start your bot in development mode.')
|
|
13
14
|
.option('-c, --config <path>', 'Path to your commandkit.json file.', './commandkit.json')
|
|
14
15
|
.action(() => {
|
|
15
16
|
const options = program.opts();
|
|
16
|
-
bootstrapDevelopmentServer(options.config)
|
|
17
|
+
bootstrapDevelopmentServer(options.config);
|
|
17
18
|
});
|
|
18
19
|
|
|
19
|
-
program
|
|
20
|
+
program
|
|
21
|
+
.command('build')
|
|
20
22
|
.description('Build your project for production usage.')
|
|
21
23
|
.option('-c, --config <path>', 'Path to your commandkit.json file.', './commandkit.json')
|
|
22
24
|
.action(() => {
|
|
23
25
|
const options = program.opts();
|
|
24
|
-
bootstrapProductionBuild(options.config)
|
|
26
|
+
bootstrapProductionBuild(options.config);
|
|
25
27
|
});
|
|
26
28
|
|
|
27
|
-
program.parse();
|
|
29
|
+
program.parse();
|
package/package.json
CHANGED