commandkit 0.1.10 → 0.1.11-dev.20240203230231
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/index.cjs +3 -0
- package/dist/CommandKit--SA9LcIq.d.mts +452 -0
- package/dist/CommandKit-GIHMEeqf.d.ts +452 -0
- package/dist/CommandKit.d.mts +5 -0
- package/dist/CommandKit.d.ts +5 -0
- package/dist/CommandKit.js +11 -0
- package/dist/CommandKit.js.map +1 -0
- package/dist/CommandKit.mjs +2 -0
- package/dist/CommandKit.mjs.map +1 -0
- package/dist/bootstrap/client.d.mts +13 -0
- package/dist/bootstrap/client.d.ts +13 -0
- package/dist/bootstrap/client.js +2 -0
- package/dist/bootstrap/client.js.map +1 -0
- package/dist/bootstrap/client.mjs +2 -0
- package/dist/bootstrap/client.mjs.map +1 -0
- package/dist/bootstrap/loadEnv.d.mts +3 -0
- package/dist/bootstrap/loadEnv.d.ts +3 -0
- package/dist/bootstrap/loadEnv.js +2 -0
- package/dist/bootstrap/loadEnv.js.map +1 -0
- package/dist/bootstrap/loadEnv.mjs +2 -0
- package/dist/bootstrap/loadEnv.mjs.map +1 -0
- package/dist/chunk-5AIBE2QR.mjs +2 -0
- package/dist/chunk-5AIBE2QR.mjs.map +1 -0
- package/dist/chunk-6CLMSPNA.mjs +2 -0
- package/dist/chunk-6CLMSPNA.mjs.map +1 -0
- package/dist/chunk-77LPS2WP.mjs +2 -0
- package/dist/chunk-77LPS2WP.mjs.map +1 -0
- package/dist/chunk-7KD7ZCH6.mjs +2 -0
- package/dist/chunk-7KD7ZCH6.mjs.map +1 -0
- package/dist/chunk-BCQP4DZP.mjs +2 -0
- package/dist/chunk-BCQP4DZP.mjs.map +1 -0
- package/dist/chunk-BJCWVCAY.mjs +2 -0
- package/dist/chunk-BJCWVCAY.mjs.map +1 -0
- package/dist/chunk-BXBLPEWT.mjs +7 -0
- package/dist/chunk-BXBLPEWT.mjs.map +1 -0
- package/dist/chunk-CHI4NRSH.mjs +2 -0
- package/dist/chunk-CHI4NRSH.mjs.map +1 -0
- package/dist/chunk-DEB7FLUS.mjs +2 -0
- package/dist/chunk-DEB7FLUS.mjs.map +1 -0
- package/dist/chunk-FQGSVSCT.mjs +2 -0
- package/dist/chunk-FQGSVSCT.mjs.map +1 -0
- package/dist/chunk-IFTUM7TS.mjs +2 -0
- package/dist/chunk-IFTUM7TS.mjs.map +1 -0
- package/dist/chunk-KATLDJ7Z.mjs +2 -0
- package/dist/chunk-KATLDJ7Z.mjs.map +1 -0
- package/dist/chunk-KUU3KDAE.mjs +2 -0
- package/dist/chunk-KUU3KDAE.mjs.map +1 -0
- package/dist/chunk-M5FMJETI.mjs +1 -0
- package/dist/chunk-M5FMJETI.mjs.map +1 -0
- package/dist/chunk-PFU3PH6M.mjs +1 -0
- package/dist/chunk-PFU3PH6M.mjs.map +1 -0
- package/dist/chunk-Q7UFCVZL.mjs +2 -0
- package/dist/chunk-Q7UFCVZL.mjs.map +1 -0
- package/dist/chunk-QC2F7O3S.mjs +2 -0
- package/dist/chunk-QC2F7O3S.mjs.map +1 -0
- package/dist/chunk-QYJ4DE3N.mjs +2 -0
- package/dist/chunk-QYJ4DE3N.mjs.map +1 -0
- package/dist/chunk-R6PIHRXD.mjs +2 -0
- package/dist/chunk-R6PIHRXD.mjs.map +1 -0
- package/dist/chunk-RQQKHSL6.mjs +4 -0
- package/dist/chunk-RQQKHSL6.mjs.map +1 -0
- package/dist/chunk-SB3FAFCD.mjs +2 -0
- package/dist/chunk-SB3FAFCD.mjs.map +1 -0
- package/dist/chunk-SXUJOOQY.mjs +4 -0
- package/dist/chunk-SXUJOOQY.mjs.map +1 -0
- package/dist/chunk-SYOEMO4R.mjs +2 -0
- package/dist/chunk-SYOEMO4R.mjs.map +1 -0
- package/dist/chunk-TZXZ3UZS.mjs +2 -0
- package/dist/chunk-TZXZ3UZS.mjs.map +1 -0
- package/dist/chunk-UV2LVAQV.mjs +2 -0
- package/dist/chunk-UV2LVAQV.mjs.map +1 -0
- package/dist/chunk-VURGPMLB.mjs +2 -0
- package/dist/chunk-VURGPMLB.mjs.map +1 -0
- package/dist/chunk-ZJRAI4W5.mjs +2 -0
- package/dist/chunk-ZJRAI4W5.mjs.map +1 -0
- package/dist/components/ButtonKit.d.mts +55 -0
- package/dist/components/ButtonKit.d.ts +55 -0
- package/dist/components/ButtonKit.js +2 -0
- package/dist/components/ButtonKit.js.map +1 -0
- package/dist/components/ButtonKit.mjs +2 -0
- package/dist/components/ButtonKit.mjs.map +1 -0
- package/dist/components/index.d.mts +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +2 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/config.d.mts +55 -0
- package/dist/config.d.ts +55 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +2 -0
- package/dist/config.mjs.map +1 -0
- package/dist/environment/actions/development.d.mts +8 -0
- package/dist/environment/actions/development.d.ts +8 -0
- package/dist/environment/actions/development.js +2 -0
- package/dist/environment/actions/development.js.map +1 -0
- package/dist/environment/actions/development.mjs +2 -0
- package/dist/environment/actions/development.mjs.map +1 -0
- package/dist/environment/bundler/bundle.d.mts +3 -0
- package/dist/environment/bundler/bundle.d.ts +3 -0
- package/dist/environment/bundler/bundle.js +2 -0
- package/dist/environment/bundler/bundle.js.map +1 -0
- package/dist/environment/bundler/bundle.mjs +2 -0
- package/dist/environment/bundler/bundle.mjs.map +1 -0
- package/dist/environment/bundler/shims.d.mts +3 -0
- package/dist/environment/bundler/shims.d.ts +3 -0
- package/dist/environment/bundler/shims.js +11 -0
- package/dist/environment/bundler/shims.js.map +1 -0
- package/dist/environment/bundler/shims.mjs +11 -0
- package/dist/environment/bundler/shims.mjs.map +1 -0
- package/dist/environment/cli.d.mts +2 -0
- package/dist/environment/cli.d.ts +2 -0
- package/dist/environment/cli.js +2 -0
- package/dist/environment/cli.js.map +1 -0
- package/dist/environment/cli.mjs +2 -0
- package/dist/environment/cli.mjs.map +1 -0
- package/dist/environment/common/config.d.mts +7 -0
- package/dist/environment/common/config.d.ts +7 -0
- package/dist/environment/common/config.js +2 -0
- package/dist/environment/common/config.js.map +1 -0
- package/dist/environment/common/config.mjs +2 -0
- package/dist/environment/common/config.mjs.map +1 -0
- package/dist/environment/common/logger.d.mts +9 -0
- package/dist/environment/common/logger.d.ts +9 -0
- package/dist/environment/common/logger.js +2 -0
- package/dist/environment/common/logger.js.map +1 -0
- package/dist/environment/common/logger.mjs +2 -0
- package/dist/environment/common/logger.mjs.map +1 -0
- package/dist/handlers/command-handler/CommandHandler.d.mts +5 -0
- package/dist/handlers/command-handler/CommandHandler.d.ts +5 -0
- package/dist/handlers/command-handler/CommandHandler.js +11 -0
- package/dist/handlers/command-handler/CommandHandler.js.map +1 -0
- package/dist/handlers/command-handler/CommandHandler.mjs +2 -0
- package/dist/handlers/command-handler/CommandHandler.mjs.map +1 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.mts +35 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.ts +35 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.js +4 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.js.map +1 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.mjs +2 -0
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.mjs.map +1 -0
- package/dist/handlers/command-handler/functions/registerCommands.d.mts +20 -0
- package/dist/handlers/command-handler/functions/registerCommands.d.ts +20 -0
- package/dist/handlers/command-handler/functions/registerCommands.js +7 -0
- package/dist/handlers/command-handler/functions/registerCommands.js.map +1 -0
- package/dist/handlers/command-handler/functions/registerCommands.mjs +2 -0
- package/dist/handlers/command-handler/functions/registerCommands.mjs.map +1 -0
- package/dist/handlers/command-handler/typings.d.mts +5 -0
- package/dist/handlers/command-handler/typings.d.ts +5 -0
- package/dist/handlers/command-handler/typings.js +2 -0
- package/dist/handlers/command-handler/typings.js.map +1 -0
- package/dist/handlers/command-handler/typings.mjs +1 -0
- package/dist/handlers/command-handler/typings.mjs.map +1 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.d.mts +9 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.d.ts +9 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.js +2 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.js.map +1 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.mjs +2 -0
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.mjs.map +1 -0
- package/dist/handlers/command-handler/validations/devOnly.d.mts +9 -0
- package/dist/handlers/command-handler/validations/devOnly.d.ts +9 -0
- package/dist/handlers/command-handler/validations/devOnly.js +2 -0
- package/dist/handlers/command-handler/validations/devOnly.js.map +1 -0
- package/dist/handlers/command-handler/validations/devOnly.mjs +2 -0
- package/dist/handlers/command-handler/validations/devOnly.mjs.map +1 -0
- package/dist/handlers/command-handler/validations/index.d.mts +10 -0
- package/dist/handlers/command-handler/validations/index.d.ts +10 -0
- package/dist/handlers/command-handler/validations/index.js +4 -0
- package/dist/handlers/command-handler/validations/index.js.map +1 -0
- package/dist/handlers/command-handler/validations/index.mjs +2 -0
- package/dist/handlers/command-handler/validations/index.mjs.map +1 -0
- package/dist/handlers/command-handler/validations/permissions.d.mts +9 -0
- package/dist/handlers/command-handler/validations/permissions.d.ts +9 -0
- package/dist/handlers/command-handler/validations/permissions.js +4 -0
- package/dist/handlers/command-handler/validations/permissions.js.map +1 -0
- package/dist/handlers/command-handler/validations/permissions.mjs +2 -0
- package/dist/handlers/command-handler/validations/permissions.mjs.map +1 -0
- package/dist/handlers/event-handler/EventHandler.d.mts +5 -0
- package/dist/handlers/event-handler/EventHandler.d.ts +5 -0
- package/dist/handlers/event-handler/EventHandler.js +2 -0
- package/dist/handlers/event-handler/EventHandler.js.map +1 -0
- package/dist/handlers/event-handler/EventHandler.mjs +2 -0
- package/dist/handlers/event-handler/EventHandler.mjs.map +1 -0
- package/dist/handlers/event-handler/typings.d.mts +5 -0
- package/dist/handlers/event-handler/typings.d.ts +5 -0
- package/dist/handlers/event-handler/typings.js +2 -0
- package/dist/handlers/event-handler/typings.js.map +1 -0
- package/dist/handlers/event-handler/typings.mjs +1 -0
- package/dist/handlers/event-handler/typings.mjs.map +1 -0
- package/dist/handlers/index.d.mts +5 -0
- package/dist/handlers/index.d.ts +5 -0
- package/dist/handlers/index.js +11 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/index.mjs +2 -0
- package/dist/handlers/index.mjs.map +1 -0
- package/dist/handlers/validation-handler/ValidationHandler.d.mts +14 -0
- package/dist/handlers/validation-handler/ValidationHandler.d.ts +14 -0
- package/dist/handlers/validation-handler/ValidationHandler.js +2 -0
- package/dist/handlers/validation-handler/ValidationHandler.js.map +1 -0
- package/dist/handlers/validation-handler/ValidationHandler.mjs +2 -0
- package/dist/handlers/validation-handler/ValidationHandler.mjs.map +1 -0
- package/dist/handlers/validation-handler/typings.d.mts +14 -0
- package/dist/handlers/validation-handler/typings.d.ts +14 -0
- package/dist/handlers/validation-handler/typings.js +2 -0
- package/dist/handlers/validation-handler/typings.js.map +1 -0
- package/dist/handlers/validation-handler/typings.mjs +1 -0
- package/dist/handlers/validation-handler/typings.mjs.map +1 -0
- package/dist/hooks/common.d.mts +12 -0
- package/dist/hooks/common.d.ts +12 -0
- package/dist/hooks/common.js +11 -0
- package/dist/hooks/common.js.map +1 -0
- package/dist/hooks/common.mjs +2 -0
- package/dist/hooks/common.mjs.map +1 -0
- package/dist/hooks/index.d.mts +14 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/response.d.mts +7 -0
- package/dist/hooks/response.d.ts +7 -0
- package/dist/hooks/response.js +11 -0
- package/dist/hooks/response.js.map +1 -0
- package/dist/hooks/response.mjs +2 -0
- package/dist/hooks/response.mjs.map +1 -0
- package/dist/hooks/useChannel.d.mts +5 -0
- package/dist/hooks/useChannel.d.ts +5 -0
- package/dist/hooks/useChannel.js +11 -0
- package/dist/hooks/useChannel.js.map +1 -0
- package/dist/hooks/useChannel.mjs +2 -0
- package/dist/hooks/useChannel.mjs.map +1 -0
- package/dist/hooks/useClient.d.mts +5 -0
- package/dist/hooks/useClient.d.ts +5 -0
- package/dist/hooks/useClient.js +11 -0
- package/dist/hooks/useClient.js.map +1 -0
- package/dist/hooks/useClient.mjs +2 -0
- package/dist/hooks/useClient.mjs.map +1 -0
- package/dist/hooks/useCommandData.d.mts +5 -0
- package/dist/hooks/useCommandData.d.ts +5 -0
- package/dist/hooks/useCommandData.js +11 -0
- package/dist/hooks/useCommandData.js.map +1 -0
- package/dist/hooks/useCommandData.mjs +2 -0
- package/dist/hooks/useCommandData.mjs.map +1 -0
- package/dist/hooks/useCommandKit.d.mts +9 -0
- package/dist/hooks/useCommandKit.d.ts +9 -0
- package/dist/hooks/useCommandKit.js +11 -0
- package/dist/hooks/useCommandKit.js.map +1 -0
- package/dist/hooks/useCommandKit.mjs +2 -0
- package/dist/hooks/useCommandKit.mjs.map +1 -0
- package/dist/hooks/useGuild.d.mts +5 -0
- package/dist/hooks/useGuild.d.ts +5 -0
- package/dist/hooks/useGuild.js +11 -0
- package/dist/hooks/useGuild.js.map +1 -0
- package/dist/hooks/useGuild.mjs +2 -0
- package/dist/hooks/useGuild.mjs.map +1 -0
- package/dist/hooks/useInteraction.d.mts +9 -0
- package/dist/hooks/useInteraction.d.ts +9 -0
- package/dist/hooks/useInteraction.js +11 -0
- package/dist/hooks/useInteraction.js.map +1 -0
- package/dist/hooks/useInteraction.mjs +2 -0
- package/dist/hooks/useInteraction.mjs.map +1 -0
- package/dist/hooks/useMember.d.mts +5 -0
- package/dist/hooks/useMember.d.ts +5 -0
- package/dist/hooks/useMember.js +11 -0
- package/dist/hooks/useMember.js.map +1 -0
- package/dist/hooks/useMember.mjs +2 -0
- package/dist/hooks/useMember.mjs.map +1 -0
- package/dist/hooks/useUser.d.mts +5 -0
- package/dist/hooks/useUser.d.ts +5 -0
- package/dist/hooks/useUser.js +11 -0
- package/dist/hooks/useUser.js.map +1 -0
- package/dist/hooks/useUser.mjs +2 -0
- package/dist/hooks/useUser.mjs.map +1 -0
- package/dist/index.d.mts +21 -375
- package/dist/index.d.ts +21 -375
- package/dist/index.js +11 -1122
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -1092
- package/dist/index.mjs.map +1 -0
- package/dist/types/index.d.mts +5 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/typings.d.mts +5 -0
- package/dist/typings.d.ts +5 -0
- package/dist/typings.js +2 -0
- package/dist/typings.js.map +1 -0
- package/dist/typings.mjs +1 -0
- package/dist/typings.mjs.map +1 -0
- package/dist/utils/clone.d.mts +3 -0
- package/dist/utils/clone.d.ts +3 -0
- package/dist/utils/clone.js +2 -0
- package/dist/utils/clone.js.map +1 -0
- package/dist/utils/clone.mjs +2 -0
- package/dist/utils/clone.mjs.map +1 -0
- package/dist/utils/colors.d.mts +27 -0
- package/dist/utils/colors.d.ts +27 -0
- package/dist/utils/colors.js +2 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/colors.mjs +2 -0
- package/dist/utils/colors.mjs.map +1 -0
- package/dist/utils/get-paths.d.mts +4 -0
- package/dist/utils/get-paths.d.ts +4 -0
- package/dist/utils/get-paths.js +2 -0
- package/dist/utils/get-paths.js.map +1 -0
- package/dist/utils/get-paths.mjs +2 -0
- package/dist/utils/get-paths.mjs.map +1 -0
- package/dist/utils/resolve-file-url.d.mts +8 -0
- package/dist/utils/resolve-file-url.d.ts +8 -0
- package/dist/utils/resolve-file-url.js +2 -0
- package/dist/utils/resolve-file-url.js.map +1 -0
- package/dist/utils/resolve-file-url.mjs +2 -0
- package/dist/utils/resolve-file-url.mjs.map +1 -0
- package/dist/utils/signal.d.mts +21 -0
- package/dist/utils/signal.d.ts +21 -0
- package/dist/utils/signal.js +2 -0
- package/dist/utils/signal.js.map +1 -0
- package/dist/utils/signal.mjs +2 -0
- package/dist/utils/signal.mjs.map +1 -0
- package/package.json +66 -55
- package/bin/build.mjs +0 -107
- package/bin/common.mjs +0 -102
- package/bin/development.mjs +0 -168
- package/bin/index.mjs +0 -39
- package/bin/parse-env.mjs +0 -61
- package/bin/production.mjs +0 -83
package/bin/common.mjs
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { rimrafSync } from 'rimraf';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import fs from 'node:fs';
|
|
6
|
-
|
|
7
|
-
const resetColor = '\x1b[0m';
|
|
8
|
-
|
|
9
|
-
export const Colors = {
|
|
10
|
-
reset: (text) => `${text}${resetColor}`,
|
|
11
|
-
bright: (text) => `\x1b[1m${text}${resetColor}`,
|
|
12
|
-
dim: (text) => `\x1b[2m${text}${resetColor}`,
|
|
13
|
-
underscore: (text) => `\x1b[4m${text}${resetColor}`,
|
|
14
|
-
blink: (text) => `\x1b[5m${text}${resetColor}`,
|
|
15
|
-
reverse: (text) => `\x1b[7m${text}${resetColor}`,
|
|
16
|
-
hidden: (text) => `\x1b[8m${text}${resetColor}`,
|
|
17
|
-
|
|
18
|
-
black: (text) => `\x1b[30m${text}${resetColor}`,
|
|
19
|
-
red: (text) => `\x1b[31m${text}${resetColor}`,
|
|
20
|
-
green: (text) => `\x1b[32m${text}${resetColor}`,
|
|
21
|
-
yellow: (text) => `\x1b[33m${text}${resetColor}`,
|
|
22
|
-
blue: (text) => `\x1b[34m${text}${resetColor}`,
|
|
23
|
-
magenta: (text) => `\x1b[35m${text}${resetColor}`,
|
|
24
|
-
cyan: (text) => `\x1b[36m${text}${resetColor}`,
|
|
25
|
-
white: (text) => `\x1b[37m${text}${resetColor}`,
|
|
26
|
-
|
|
27
|
-
bgBlack: (text) => `\x1b[40m${text}${resetColor}`,
|
|
28
|
-
bgRed: (text) => `\x1b[41m${text}${resetColor}`,
|
|
29
|
-
bgGreen: (text) => `\x1b[42m${text}${resetColor}`,
|
|
30
|
-
bgYellow: (text) => `\x1b[43m${text}${resetColor}`,
|
|
31
|
-
bgBlue: (text) => `\x1b[44m${text}${resetColor}`,
|
|
32
|
-
bgMagenta: (text) => `\x1b[45m${text}${resetColor}`,
|
|
33
|
-
bgCyan: (text) => `\x1b[46m${text}${resetColor}`,
|
|
34
|
-
bgWhite: (text) => `\x1b[47m${text}${resetColor}`,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export function write(message) {
|
|
38
|
-
process.stdout.write(message);
|
|
39
|
-
process.stdout.write('\n');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @returns {never}
|
|
44
|
-
*/
|
|
45
|
-
export function panic(message) {
|
|
46
|
-
write(Colors.red(`Error: ${message}`));
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function findPackageJSON() {
|
|
51
|
-
const cwd = process.cwd();
|
|
52
|
-
const target = join(cwd, 'package.json');
|
|
53
|
-
|
|
54
|
-
if (!fs.existsSync(target)) {
|
|
55
|
-
panic('Could not find package.json in current directory.');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return JSON.parse(fs.readFileSync(target, 'utf8'));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const possibleFileNames = [
|
|
62
|
-
'commandkit.json',
|
|
63
|
-
'commandkit.config.json',
|
|
64
|
-
'commandkit.js',
|
|
65
|
-
'commandkit.config.js',
|
|
66
|
-
'commandkit.mjs',
|
|
67
|
-
'commandkit.config.mjs',
|
|
68
|
-
'commandkit.cjs',
|
|
69
|
-
'commandkit.config.cjs',
|
|
70
|
-
];
|
|
71
|
-
|
|
72
|
-
export async function findCommandKitConfig(src) {
|
|
73
|
-
const cwd = process.cwd();
|
|
74
|
-
const locations = src ? [join(cwd, src)] : possibleFileNames.map((name) => join(cwd, name));
|
|
75
|
-
|
|
76
|
-
for (const location of locations) {
|
|
77
|
-
try {
|
|
78
|
-
return await loadConfigInner(location);
|
|
79
|
-
} catch (e) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
panic('Could not locate commandkit config.');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async function loadConfigInner(target) {
|
|
88
|
-
const isJSON = target.endsWith('.json');
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @type {import('..').CommandKitConfig}
|
|
92
|
-
*/
|
|
93
|
-
const config = await import(`file://${target}`, {
|
|
94
|
-
assert: isJSON ? { type: 'json' } : undefined,
|
|
95
|
-
}).then((conf) => conf.default || conf);
|
|
96
|
-
|
|
97
|
-
return config;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function erase(dir) {
|
|
101
|
-
rimrafSync(dir);
|
|
102
|
-
}
|
package/bin/development.mjs
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import { config as dotenv } from 'dotenv';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { build } from 'tsup';
|
|
5
|
-
import { Colors, erase, findCommandKitConfig, panic, write } from './common.mjs';
|
|
6
|
-
import { parseEnv } from './parse-env.mjs';
|
|
7
|
-
import child_process from 'node:child_process';
|
|
8
|
-
import ora from 'ora';
|
|
9
|
-
import { injectShims } from './build.mjs';
|
|
10
|
-
|
|
11
|
-
const RESTARTING_MSG_PATTERN = /^Restarting '|".+'|"\n?$/;
|
|
12
|
-
const FAILED_RUNNING_PATTERN = /^Failed running '.+'|"\n?$/;
|
|
13
|
-
|
|
14
|
-
export async function bootstrapDevelopmentServer(opts) {
|
|
15
|
-
const {
|
|
16
|
-
src,
|
|
17
|
-
main,
|
|
18
|
-
watch = Boolean(opts.noWatch),
|
|
19
|
-
nodeOptions = [],
|
|
20
|
-
envExtra = true,
|
|
21
|
-
clearRestartLogs = true,
|
|
22
|
-
outDir,
|
|
23
|
-
requirePolyfill,
|
|
24
|
-
} = await findCommandKitConfig(opts.config);
|
|
25
|
-
|
|
26
|
-
if (!src) {
|
|
27
|
-
panic('Could not find src in commandkit.json');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (!main) {
|
|
31
|
-
panic('Could not find main in commandkit.json');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const watchMode = watch;
|
|
35
|
-
const status = ora(Colors.green('Starting a development server...\n')).start();
|
|
36
|
-
const start = performance.now();
|
|
37
|
-
|
|
38
|
-
if (watchMode && !nodeOptions.includes('--watch')) {
|
|
39
|
-
nodeOptions.push('--watch');
|
|
40
|
-
} else if (!watchMode && nodeOptions.includes('--watch')) {
|
|
41
|
-
nodeOptions.splice(nodeOptions.indexOf('--watch'), 1);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!nodeOptions.includes('--enable-source-maps')) {
|
|
45
|
-
nodeOptions.push('--enable-source-maps');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
erase('.commandkit');
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
await build({
|
|
52
|
-
clean: true,
|
|
53
|
-
format: ['esm'],
|
|
54
|
-
dts: false,
|
|
55
|
-
skipNodeModulesBundle: true,
|
|
56
|
-
minify: false,
|
|
57
|
-
shims: true,
|
|
58
|
-
sourcemap: 'inline',
|
|
59
|
-
keepNames: true,
|
|
60
|
-
outDir: '.commandkit',
|
|
61
|
-
silent: true,
|
|
62
|
-
entry: [src, '!dist', '!.commandkit', `!${outDir}`].filter(Boolean),
|
|
63
|
-
watch: watchMode,
|
|
64
|
-
async onSuccess() {
|
|
65
|
-
return await injectShims('.commandkit', main, false, requirePolyfill);
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
status.succeed(
|
|
70
|
-
Colors.green(`Dev server started in ${(performance.now() - start).toFixed(2)}ms!\n`),
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
if (watchMode) write(Colors.cyan('Watching for file changes...\n'));
|
|
74
|
-
|
|
75
|
-
const processEnv = {};
|
|
76
|
-
|
|
77
|
-
const env = dotenv({
|
|
78
|
-
path: join(process.cwd(), '.env'),
|
|
79
|
-
// @ts-expect-error
|
|
80
|
-
processEnv,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
if (envExtra) {
|
|
84
|
-
parseEnv(processEnv);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (env.error) {
|
|
88
|
-
write(Colors.yellow(`[DOTENV] Warning: ${env.error.message}`));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (env.parsed) {
|
|
92
|
-
write(Colors.blue('[DOTENV] Loaded .env file!'));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @type {child_process.ChildProcessWithoutNullStreams}
|
|
97
|
-
*/
|
|
98
|
-
const ps = child_process.spawn(
|
|
99
|
-
'node',
|
|
100
|
-
[...nodeOptions, join(process.cwd(), '.commandkit', main)],
|
|
101
|
-
{
|
|
102
|
-
env: {
|
|
103
|
-
...process.env,
|
|
104
|
-
...processEnv,
|
|
105
|
-
NODE_ENV: 'development',
|
|
106
|
-
// @ts-expect-error
|
|
107
|
-
COMMANDKIT_DEV: true,
|
|
108
|
-
// @ts-expect-error
|
|
109
|
-
COMMANDKIT_PRODUCTION: false,
|
|
110
|
-
},
|
|
111
|
-
cwd: process.cwd(),
|
|
112
|
-
},
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
let isLastLogRestarting = false,
|
|
116
|
-
hasStarted = false;
|
|
117
|
-
|
|
118
|
-
ps.stdout.on('data', (data) => {
|
|
119
|
-
const message = data.toString();
|
|
120
|
-
|
|
121
|
-
if (FAILED_RUNNING_PATTERN.test(message)) {
|
|
122
|
-
write(Colors.cyan('Failed running the bot, waiting for changes...'));
|
|
123
|
-
isLastLogRestarting = false;
|
|
124
|
-
if (!hasStarted) hasStarted = true;
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (clearRestartLogs && !RESTARTING_MSG_PATTERN.test(message)) {
|
|
129
|
-
write(message);
|
|
130
|
-
isLastLogRestarting = false;
|
|
131
|
-
} else {
|
|
132
|
-
if (isLastLogRestarting || !hasStarted) {
|
|
133
|
-
if (!hasStarted) hasStarted = true;
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
write(Colors.cyan('⌀ Restarting the bot...'));
|
|
137
|
-
isLastLogRestarting = true;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (!hasStarted) hasStarted = true;
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
ps.stderr.on('data', (data) => {
|
|
144
|
-
const message = data.toString();
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
message.includes(
|
|
148
|
-
'ExperimentalWarning: Watch mode is an experimental feature and might change at any time',
|
|
149
|
-
)
|
|
150
|
-
)
|
|
151
|
-
return;
|
|
152
|
-
|
|
153
|
-
write(Colors.red(message));
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
ps.on('close', (code) => {
|
|
157
|
-
write('\n');
|
|
158
|
-
process.exit(code ?? 0);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
ps.on('error', (err) => {
|
|
162
|
-
panic(err);
|
|
163
|
-
});
|
|
164
|
-
} catch (e) {
|
|
165
|
-
status.fail(`Error occurred after ${(performance.now() - start).toFixed(2)}ms!\n`);
|
|
166
|
-
panic(e.stack ?? e);
|
|
167
|
-
}
|
|
168
|
-
}
|
package/bin/index.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// @ts-check
|
|
4
|
-
|
|
5
|
-
import { Command } from 'commander';
|
|
6
|
-
import { bootstrapDevelopmentServer } from './development.mjs';
|
|
7
|
-
import { bootstrapProductionServer } from './production.mjs';
|
|
8
|
-
import { bootstrapProductionBuild } from './build.mjs';
|
|
9
|
-
|
|
10
|
-
const program = new Command('commandkit');
|
|
11
|
-
|
|
12
|
-
program
|
|
13
|
-
.command('dev')
|
|
14
|
-
.description('Start your bot in development mode.')
|
|
15
|
-
.option('-c, --config <path>', 'Path to your commandkit config file.', './commandkit.js')
|
|
16
|
-
.action(() => {
|
|
17
|
-
const options = program.opts();
|
|
18
|
-
bootstrapDevelopmentServer(options);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
program
|
|
22
|
-
.command('start')
|
|
23
|
-
.description('Start your bot in production mode after running the build command.')
|
|
24
|
-
.option('-c, --config <path>', 'Path to your commandkit.json file.', './commandkit.js')
|
|
25
|
-
.action(() => {
|
|
26
|
-
const options = program.opts();
|
|
27
|
-
bootstrapProductionServer(options.config);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
program
|
|
31
|
-
.command('build')
|
|
32
|
-
.description('Build your project for production usage.')
|
|
33
|
-
.option('-c, --config <path>', 'Path to your commandkit.json file.', './commandkit.json')
|
|
34
|
-
.action(() => {
|
|
35
|
-
const options = program.opts();
|
|
36
|
-
bootstrapProductionBuild(options.config);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
program.parse();
|
package/bin/parse-env.mjs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
|
|
5
|
-
const valuesMap = {
|
|
6
|
-
true: true,
|
|
7
|
-
false: false,
|
|
8
|
-
null: null,
|
|
9
|
-
undefined: undefined,
|
|
10
|
-
__UUIDv4__: () => randomUUID(),
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const VALUE_PREFIXES = {
|
|
14
|
-
JSON: 'JSON::',
|
|
15
|
-
DATE: 'DATE::',
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function catcher(fn) {
|
|
19
|
-
try {
|
|
20
|
-
fn();
|
|
21
|
-
return true;
|
|
22
|
-
} catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function parseEnv(src) {
|
|
28
|
-
for (const key in src) {
|
|
29
|
-
const value = src[key];
|
|
30
|
-
|
|
31
|
-
if (typeof value !== 'string') continue;
|
|
32
|
-
|
|
33
|
-
if (value.startsWith(VALUE_PREFIXES.JSON)) {
|
|
34
|
-
catcher(() => (src[key] = JSON.parse(value.replace(VALUE_PREFIXES.JSON, ''))));
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (value.startsWith(VALUE_PREFIXES.DATE)) {
|
|
39
|
-
src[key] = new Date(value.replace(VALUE_PREFIXES.DATE, ''));
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (value.includes(',')) {
|
|
44
|
-
src[key] = value.split(',').map((v) => v.trim());
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (/^[0-9]+n$/.test(value)) {
|
|
49
|
-
src[key] = BigInt(value);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (value in valuesMap) {
|
|
54
|
-
src[key] =
|
|
55
|
-
typeof valuesMap[value] === 'function' ? valuesMap[value]() : valuesMap[value];
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return src;
|
|
61
|
-
}
|
package/bin/production.mjs
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import { config as dotenv } from 'dotenv';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { Colors, findCommandKitConfig, panic, write } from './common.mjs';
|
|
6
|
-
import { parseEnv } from './parse-env.mjs';
|
|
7
|
-
import child_process from 'node:child_process';
|
|
8
|
-
|
|
9
|
-
export async function bootstrapProductionServer(config) {
|
|
10
|
-
const {
|
|
11
|
-
main,
|
|
12
|
-
outDir = 'dist',
|
|
13
|
-
envExtra = true,
|
|
14
|
-
sourcemap,
|
|
15
|
-
} = await findCommandKitConfig(config);
|
|
16
|
-
|
|
17
|
-
if (!existsSync(join(process.cwd(), outDir, main))) {
|
|
18
|
-
panic('Could not find production build, maybe run `commandkit build` first?');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const processEnv = {};
|
|
23
|
-
|
|
24
|
-
const env = dotenv({
|
|
25
|
-
path: join(process.cwd(), '.env'),
|
|
26
|
-
// @ts-expect-error
|
|
27
|
-
processEnv,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
if (envExtra) {
|
|
31
|
-
parseEnv(processEnv);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (env.error) {
|
|
35
|
-
write(Colors.yellow(`[DOTENV] Warning: ${env.error.message}`));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (env.parsed) {
|
|
39
|
-
write(Colors.blue('[DOTENV] Loaded .env file!'));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @type {child_process.ChildProcessWithoutNullStreams}
|
|
44
|
-
*/
|
|
45
|
-
const ps = child_process.spawn(
|
|
46
|
-
'node',
|
|
47
|
-
[sourcemap ? '--enable-source-maps' : '', join(process.cwd(), outDir, main)].filter(
|
|
48
|
-
Boolean,
|
|
49
|
-
),
|
|
50
|
-
{
|
|
51
|
-
env: {
|
|
52
|
-
...process.env,
|
|
53
|
-
...processEnv,
|
|
54
|
-
NODE_ENV: 'production',
|
|
55
|
-
// @ts-expect-error
|
|
56
|
-
COMMANDKIT_DEV: false,
|
|
57
|
-
// @ts-expect-error
|
|
58
|
-
COMMANDKIT_PROD: true,
|
|
59
|
-
},
|
|
60
|
-
cwd: process.cwd(),
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
ps.stdout.on('data', (data) => {
|
|
65
|
-
write(data.toString());
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
ps.stderr.on('data', (data) => {
|
|
69
|
-
write(Colors.red(data.toString()));
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
ps.on('close', (code) => {
|
|
73
|
-
write('\n');
|
|
74
|
-
process.exit(code ?? 0);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
ps.on('error', (err) => {
|
|
78
|
-
panic(err);
|
|
79
|
-
});
|
|
80
|
-
} catch (e) {
|
|
81
|
-
panic(e);
|
|
82
|
-
}
|
|
83
|
-
}
|