commandkit 1.0.0-dev.20250809133202 → 1.0.0-dev.20250809133459
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/{build-Bgk8Y78-.js → build-MoW8POlr.js} +4 -4
- package/dist/build-MoW8POlr.js.map +1 -0
- package/dist/cli/build.js +1 -1
- package/dist/cli/development.js +1 -1
- package/dist/cli/information.js +1 -1
- package/dist/cli/production.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{version-DrtNWmx0.js → version-D0RuJixw.js} +2 -2
- package/dist/{version-DrtNWmx0.js.map → version-D0RuJixw.js.map} +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/dist/build-Bgk8Y78-.js.map +0 -1
|
@@ -46,7 +46,7 @@ async function buildApplication({ plugins, rolldownPlugins, isDev, configPath })
|
|
|
46
46
|
rolldownPlugins ??= [];
|
|
47
47
|
rolldownPlugins.push(pluginRuntime.toJSON());
|
|
48
48
|
try {
|
|
49
|
-
var _config$sourceMap, _config$compilerOptio, _config$antiCrashScri;
|
|
49
|
+
var _config$sourceMap, _config$compilerOptio, _config$compilerOptio2, _config$antiCrashScri;
|
|
50
50
|
const dest = isDev ? ".commandkit" : config.distDir;
|
|
51
51
|
await (0, rimraf.rimraf)(dest);
|
|
52
52
|
await pluginRuntime.init();
|
|
@@ -93,8 +93,8 @@ async function buildApplication({ plugins, rolldownPlugins, isDev, configPath })
|
|
|
93
93
|
"!**/*.spec.*",
|
|
94
94
|
...config.entrypoints ?? []
|
|
95
95
|
])),
|
|
96
|
-
unbundle:
|
|
97
|
-
}, (_config$
|
|
96
|
+
unbundle: isDev ? true : ((_config$compilerOptio = config.compilerOptions) === null || _config$compilerOptio === void 0 ? void 0 : _config$compilerOptio.disableChunking) ?? false
|
|
97
|
+
}, (_config$compilerOptio2 = config.compilerOptions) === null || _config$compilerOptio2 === void 0 ? void 0 : _config$compilerOptio2.tsdown));
|
|
98
98
|
await require_common.copyLocaleFiles("src", dest);
|
|
99
99
|
await injectEntryFile(configPath || require_constants.COMMANDKIT_CWD, !!isDev, !!(((_config$antiCrashScri = config.antiCrashScript) === null || _config$antiCrashScri === void 0 ? void 0 : _config$antiCrashScri[isDev ? "development" : "production"]) ?? (isDev ? true : false)), config.distDir);
|
|
100
100
|
} catch (error) {
|
|
@@ -167,4 +167,4 @@ Object.defineProperty(exports, 'buildApplication', {
|
|
|
167
167
|
return buildApplication;
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
|
-
//# sourceMappingURL=build-
|
|
170
|
+
//# sourceMappingURL=build-MoW8POlr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-MoW8POlr.js","names":[],"sources":["../src/cli/build.ts"],"sourcesContent":["import { build, Options } from 'tsdown';\nimport { CompilerPlugin, CompilerPluginRuntime } from '../plugins';\nimport { loadConfigFile } from '../config/loader';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { DevEnv, devEnvFileArgs, ProdEnv, prodEnvFileArgs } from './env';\nimport { rimraf } from 'rimraf';\nimport { performTypeCheck } from './type-checker';\nimport { copyLocaleFiles } from './common';\nimport { MaybeArray } from '../components';\nimport { COMMANDKIT_CWD } from '../utils/constants';\nimport { mergeDeep } from '../config/utils';\nimport { existsSync } from 'node:fs';\n\n/**\n * @private\n * @internal\n */\nexport interface ApplicationBuildOptions {\n plugins?: MaybeArray<CompilerPlugin>[] | Array<CompilerPlugin>;\n rolldownPlugins?: any[];\n isDev?: boolean;\n configPath?: string;\n}\n\n// emit public env variables and given env variables\n/**\n * @private\n * @internal\n */\nfunction mergeDefinitionsIfNeeded(env: Record<string, string>, isDev: boolean) {\n const values = Object.fromEntries(\n Object.entries(process.env).filter(\n ([k]) => !(k in env) && k.startsWith('COMMANDKIT_PUBLIC_'),\n ),\n );\n\n return {\n ...env,\n ...values,\n ...(isDev\n ? {\n NODE_ENV: 'development',\n COMMANDKIT_BOOTSTRAP_MODE: 'development',\n COMMANDKIT_IS_DEV: 'true',\n COMMANDKIT_IS_TEST: 'false',\n }\n : {\n NODE_ENV: 'production',\n COMMANDKIT_BOOTSTRAP_MODE: 'production',\n COMMANDKIT_IS_DEV: 'false',\n COMMANDKIT_IS_TEST: 'false',\n }),\n };\n}\n\n/**\n * @private\n * @internal\n */\nexport async function buildApplication({\n plugins,\n rolldownPlugins,\n isDev,\n configPath,\n}: ApplicationBuildOptions) {\n const config = await loadConfigFile(configPath);\n\n if (!isDev && !config?.typescript?.ignoreBuildErrors) {\n await performTypeCheck(configPath || COMMANDKIT_CWD);\n }\n\n const pluginRuntime = new CompilerPluginRuntime(\n (plugins || []) as CompilerPlugin[],\n );\n\n rolldownPlugins ??= [];\n\n rolldownPlugins.push(pluginRuntime.toJSON());\n\n try {\n const dest = isDev ? '.commandkit' : config.distDir;\n\n // Clean the destination directory\n await rimraf(dest);\n\n await pluginRuntime.init();\n\n await build(\n mergeDeep(\n {\n watch: false,\n dts: false,\n clean: true,\n format: ['esm'],\n shims: true,\n minify: false,\n silent: !!isDev,\n inputOptions: {\n transform: {\n jsx: {\n runtime: 'automatic',\n importSource: 'commandkit',\n },\n },\n checks: {\n circularDependency: true,\n },\n onwarn: (warning, defaultWarn) => {\n if (warning?.message?.includes('compilerOptions.jsx')) return;\n\n return defaultWarn(warning);\n },\n onLog: (level, log, defaultLog) => {\n if (isDev) return;\n\n return defaultLog(level, log);\n },\n moduleTypes: {\n '.json': 'js',\n '.node': 'binary',\n },\n },\n plugins: rolldownPlugins,\n platform: 'node',\n skipNodeModulesBundle: true,\n sourcemap:\n config.sourceMap?.[isDev ? 'development' : 'production'] ?? true,\n target: 'node16',\n outDir: dest,\n env: mergeDefinitionsIfNeeded(config.env || {}, !!isDev),\n entry: Array.from(\n new Set([\n 'src',\n `!${config.distDir}`,\n '!.commandkit',\n '!**/*.test.*',\n '!**/*.spec.*',\n ...(config.entrypoints ?? []),\n ]),\n ),\n unbundle: isDev\n ? true\n : (config.compilerOptions?.disableChunking ?? false),\n } satisfies Options,\n config.compilerOptions?.tsdown,\n ),\n );\n\n await copyLocaleFiles('src', dest);\n await injectEntryFile(\n configPath || COMMANDKIT_CWD,\n !!isDev,\n !!(\n config.antiCrashScript?.[isDev ? 'development' : 'production'] ??\n (isDev ? true : false)\n ),\n config.distDir,\n );\n } catch (error) {\n console.error('Build failed:', error);\n if (error instanceof Error) {\n console.error('Error details:', error.stack);\n }\n process.exit(1); // Force exit on error\n } finally {\n // Ensure plugins are cleaned up\n await pluginRuntime.destroy();\n }\n}\n\nconst envScript = (dev: boolean) => `// --- Environment Variables Loader ---\nconst $env = [${(dev ? devEnvFileArgs : prodEnvFileArgs).map((p) => `\"${p}\"`).join(', ')}];\nfor (const file of $env) {\n try {\n process.loadEnvFile(file);\n console.log('\\\\x1b[36m✔ Loaded \\\\x1b[0m\\\\x1b[33m%s\\\\x1b[0m', file);\n } catch {}\n}\n`;\n\nconst antiCrashScript = [\n '// --- CommandKit Anti-Crash Monitor ---',\n \" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process\",\n ' // instead of using it as a means to resume operation.',\n ' // But it exists here due to compatibility reasons with discord bot ecosystem.',\n \" const p = (t) => `\\\\x1b[31m${t}\\\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';\",\n ' if (!process.eventNames().includes(e1)) // skip if it is already handled',\n ' process.on(e1, (e) => {',\n ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',\n ' })',\n ' if (!process.eventNames().includes(e2)) // skip if it is already handled',\n ' process.on(e2, (r) => {',\n ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',\n ' });',\n '// --- CommandKit Anti-Crash Monitor ---',\n].join('\\n');\n\nconst wrapInAsyncIIFE = (code: string[]) =>\n `;await (async () => {\\n${code.join('\\n\\n')}\\n})();`;\n\nasync function injectEntryFile(\n configPath: string,\n isDev: boolean,\n emitAntiCrashScript: boolean,\n distDir?: string,\n) {\n const dist = isDev ? '.commandkit' : distDir || 'dist';\n const entryFilePath = join(configPath, dist, 'index.js');\n\n // skip if the entry file already exists\n if (existsSync(entryFilePath)) return;\n\n const code = `/* Entrypoint File Generated By CommandKit */\n${isDev ? `\\n\\n// Injected for development\\n${wrapInAsyncIIFE([envScript(isDev), emitAntiCrashScript ? antiCrashScript : ''])}\\n\\n` : wrapInAsyncIIFE([envScript(isDev)])}\n\nimport { commandkit } from 'commandkit';\nimport { Client } from 'discord.js';\n\nasync function bootstrap() {\n const app = await import('./app.js').then((m) => m.default ?? m);\n\n if (!app || !(app instanceof Client)) {\n throw new Error('The app file must default export the discord.js client instance');\n }\n\n commandkit.setClient(app);\n\n await commandkit.start();\n}\n\nawait bootstrap().catch((e) => {\n console.error('Failed to bootstrap CommandKit application:\\\\n', e.stack);\n})\n`;\n\n await writeFile(entryFilePath, code);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA,SAAS,yBAAyB,KAA6B,OAAgB;CAC7E,MAAM,SAAS,OAAO,YACpB,OAAO,QAAQ,QAAQ,IAAI,CAAC,OAC1B,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,WAAW,qBAAqB,CAC3D,CACF;AAED,QAAO;EACL,GAAG;EACH,GAAG;EACH,GAAI,QACJ;GACE,UAAU;GACV,2BAA2B;GAC3B,mBAAmB;GACnB,oBAAoB;EACrB,IACD;GACE,UAAU;GACV,2BAA2B;GAC3B,mBAAmB;GACnB,oBAAoB;EACrB;CACF;AACH;;;;;AAMA,eAAsB,iBAAiB,EACrC,SACA,iBACA,OACA,YACwB,EAAE;;CAC1B,MAAM,SAAS,MAAM,kCAAe,WAAW;AAE/C,KAAI,CAAC,SAAS,gEAAC,OAAQ,oFAAY,oBACjC,MAAM,sCAAiB,cAAc,iCAAe;CAGtD,MAAM,gBAAgB,IAAI,yCACvB,WAAW,CAAE;CAGhB,oBAAoB,CAAE;CAEtB,gBAAg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kB,MAAM,MAAM;EAE9C,QAAQ,KAAK,EAAE;CAChB,UAAS;EAER,MAAM,cAAc,SAAS;CAC/B;AACF;AAEA,MAAM,YAAY,CAAC,QAAiB,CAAC;cACvB,GAAG,MAAM,6BAAiB,6BAAiB,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC;;;;;;;AAOzF,CAAC;AAED,MAAM,kBAAkB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAA2C,EAC3C,KAAK,KAAK;AAEV,MAAM,kBAAkB,CAAC,SACzB,CAAC,uBAAuB,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC;AAEpD,eAAe,gBACf,YACA,OACA,qBACA,SACA;CACE,MAAM,OAAO,QAAQ,gBAAgB,WAAW;CAChD,MAAM,oCAAqB,YAAY,MAAM,WAAW;AAGxD,6BAAe,cAAc,CAAE;CAE/B,MAAM,OAAO,CAAC;AAChB,EAAE,QAAQ,CAAC,iCAAiC,EAAE,gBAAgB,CAAC,UAAU,MAAM,EAAE,sBAAsB,kBAAkB,EAAG,EAAC,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,UAAU,MAAM,AAAC,EAAC,CAAA;;;;;;;;;;;;;;;;;;;;AAoBzK,CAAC;CAEC,sCAAgB,eAAe,KAAK;AACtC"}
|
package/dist/cli/build.js
CHANGED
|
@@ -35,6 +35,6 @@ require('../CommandKitEventsChannel-Bgw0XCOl.js');
|
|
|
35
35
|
require('../store-CiqLHedg.js');
|
|
36
36
|
require('../env-_68PRRoA.js');
|
|
37
37
|
require('../type-checker-1Iu1jJcy.js');
|
|
38
|
-
const require_build = require('../build-
|
|
38
|
+
const require_build = require('../build-MoW8POlr.js');
|
|
39
39
|
|
|
40
40
|
exports.buildApplication = require_build.buildApplication;
|
package/dist/cli/development.js
CHANGED
|
@@ -37,7 +37,7 @@ require('../store-CiqLHedg.js');
|
|
|
37
37
|
require('../env-_68PRRoA.js');
|
|
38
38
|
const require_app_process = require('../app-process-CjMovpoZ.js');
|
|
39
39
|
require('../type-checker-1Iu1jJcy.js');
|
|
40
|
-
const require_build = require('../build-
|
|
40
|
+
const require_build = require('../build-MoW8POlr.js');
|
|
41
41
|
const node_crypto = require_chunk.__toESM(require("node:crypto"));
|
|
42
42
|
const path = require_chunk.__toESM(require("path"));
|
|
43
43
|
const chokidar = require_chunk.__toESM(require("chokidar"));
|
package/dist/cli/information.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('../chunk-nOFOJqeH.js');
|
|
2
2
|
const require_constants = require('../constants-B5_Ta7PR.js');
|
|
3
|
-
const require_version = require('../version-
|
|
3
|
+
const require_version = require('../version-D0RuJixw.js');
|
|
4
4
|
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
5
5
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
6
6
|
const node_child_process = require_chunk.__toESM(require("node:child_process"));
|
package/dist/cli/production.js
CHANGED
|
@@ -37,7 +37,7 @@ require('../store-CiqLHedg.js');
|
|
|
37
37
|
require('../env-_68PRRoA.js');
|
|
38
38
|
const require_app_process = require('../app-process-CjMovpoZ.js');
|
|
39
39
|
require('../type-checker-1Iu1jJcy.js');
|
|
40
|
-
const require_build = require('../build-
|
|
40
|
+
const require_build = require('../build-MoW8POlr.js');
|
|
41
41
|
const require_utils$1 = require('../utils-DCSnVAZ6.js');
|
|
42
42
|
const fs = require_chunk.__toESM(require("fs"));
|
|
43
43
|
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ require('./store-CiqLHedg.js');
|
|
|
38
38
|
const require_helpers = require('./helpers-BUlN3lIz.js');
|
|
39
39
|
require('./app-HN1cVg8J.js');
|
|
40
40
|
require('./ILogger-dQ7Y9X1f.js');
|
|
41
|
-
const require_version = require('./version-
|
|
41
|
+
const require_version = require('./version-D0RuJixw.js');
|
|
42
42
|
const require_feature_flags = require('./feature-flags-Rel_00Fx.js');
|
|
43
43
|
const require_init = require('./init-CoNEUBBr.js');
|
|
44
44
|
const discord_js = require_chunk.__toESM(require("discord.js"));
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* The current version of CommandKit.
|
|
8
8
|
*/
|
|
9
|
-
const version = "1.0.0-dev.
|
|
9
|
+
const version = "1.0.0-dev.20250809133459";
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
12
|
Object.defineProperty(exports, 'version', {
|
|
@@ -15,4 +15,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
15
15
|
return version;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
//# sourceMappingURL=version-
|
|
18
|
+
//# sourceMappingURL=version-D0RuJixw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-
|
|
1
|
+
{"version":3,"file":"version-D0RuJixw.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["/**\n * @private\n */\nfunction $version(): string {\n 'use macro';\n return require('../package.json').version;\n}\n\n/**\n * The current version of CommandKit.\n */\nexport const version: string = $version();\n"],"mappings":";;;;;;;;AAWA,MAAa,UAA4B"}
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commandkit",
|
|
3
3
|
"description": "Beginner friendly command & event handler for Discord.js",
|
|
4
|
-
"version": "1.0.0-dev.
|
|
4
|
+
"version": "1.0.0-dev.20250809133459",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
"tsx": "^4.19.2",
|
|
179
179
|
"typescript": "^5.7.3",
|
|
180
180
|
"vitest": "^3.0.5",
|
|
181
|
-
"tsconfig": "0.0.0-dev.
|
|
181
|
+
"tsconfig": "0.0.0-dev.20250809133459"
|
|
182
182
|
},
|
|
183
183
|
"engines": {
|
|
184
184
|
"node": ">=24"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-Bgk8Y78-.js","names":[],"sources":["../src/cli/build.ts"],"sourcesContent":["import { build, Options } from 'tsdown';\nimport { CompilerPlugin, CompilerPluginRuntime } from '../plugins';\nimport { loadConfigFile } from '../config/loader';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { DevEnv, devEnvFileArgs, ProdEnv, prodEnvFileArgs } from './env';\nimport { rimraf } from 'rimraf';\nimport { performTypeCheck } from './type-checker';\nimport { copyLocaleFiles } from './common';\nimport { MaybeArray } from '../components';\nimport { COMMANDKIT_CWD } from '../utils/constants';\nimport { mergeDeep } from '../config/utils';\nimport { existsSync } from 'node:fs';\n\n/**\n * @private\n * @internal\n */\nexport interface ApplicationBuildOptions {\n plugins?: MaybeArray<CompilerPlugin>[] | Array<CompilerPlugin>;\n rolldownPlugins?: any[];\n isDev?: boolean;\n configPath?: string;\n}\n\n// emit public env variables and given env variables\n/**\n * @private\n * @internal\n */\nfunction mergeDefinitionsIfNeeded(env: Record<string, string>, isDev: boolean) {\n const values = Object.fromEntries(\n Object.entries(process.env).filter(\n ([k]) => !(k in env) && k.startsWith('COMMANDKIT_PUBLIC_'),\n ),\n );\n\n return {\n ...env,\n ...values,\n ...(isDev\n ? {\n NODE_ENV: 'development',\n COMMANDKIT_BOOTSTRAP_MODE: 'development',\n COMMANDKIT_IS_DEV: 'true',\n COMMANDKIT_IS_TEST: 'false',\n }\n : {\n NODE_ENV: 'production',\n COMMANDKIT_BOOTSTRAP_MODE: 'production',\n COMMANDKIT_IS_DEV: 'false',\n COMMANDKIT_IS_TEST: 'false',\n }),\n };\n}\n\n/**\n * @private\n * @internal\n */\nexport async function buildApplication({\n plugins,\n rolldownPlugins,\n isDev,\n configPath,\n}: ApplicationBuildOptions) {\n const config = await loadConfigFile(configPath);\n\n if (!isDev && !config?.typescript?.ignoreBuildErrors) {\n await performTypeCheck(configPath || COMMANDKIT_CWD);\n }\n\n const pluginRuntime = new CompilerPluginRuntime(\n (plugins || []) as CompilerPlugin[],\n );\n\n rolldownPlugins ??= [];\n\n rolldownPlugins.push(pluginRuntime.toJSON());\n\n try {\n const dest = isDev ? '.commandkit' : config.distDir;\n\n // Clean the destination directory\n await rimraf(dest);\n\n await pluginRuntime.init();\n\n await build(\n mergeDeep(\n {\n watch: false,\n dts: false,\n clean: true,\n format: ['esm'],\n shims: true,\n minify: false,\n silent: !!isDev,\n inputOptions: {\n transform: {\n jsx: {\n runtime: 'automatic',\n importSource: 'commandkit',\n },\n },\n checks: {\n circularDependency: true,\n },\n onwarn: (warning, defaultWarn) => {\n if (warning?.message?.includes('compilerOptions.jsx')) return;\n\n return defaultWarn(warning);\n },\n onLog: (level, log, defaultLog) => {\n if (isDev) return;\n\n return defaultLog(level, log);\n },\n moduleTypes: {\n '.json': 'js',\n '.node': 'binary',\n },\n },\n plugins: rolldownPlugins,\n platform: 'node',\n skipNodeModulesBundle: true,\n sourcemap:\n config.sourceMap?.[isDev ? 'development' : 'production'] ?? true,\n target: 'node16',\n outDir: dest,\n env: mergeDefinitionsIfNeeded(config.env || {}, !!isDev),\n entry: Array.from(\n new Set([\n 'src',\n `!${config.distDir}`,\n '!.commandkit',\n '!**/*.test.*',\n '!**/*.spec.*',\n ...(config.entrypoints ?? []),\n ]),\n ),\n unbundle: !!isDev,\n } satisfies Options,\n config.compilerOptions?.tsdown,\n ),\n );\n\n await copyLocaleFiles('src', dest);\n await injectEntryFile(\n configPath || COMMANDKIT_CWD,\n !!isDev,\n !!(\n config.antiCrashScript?.[isDev ? 'development' : 'production'] ??\n (isDev ? true : false)\n ),\n config.distDir,\n );\n } catch (error) {\n console.error('Build failed:', error);\n if (error instanceof Error) {\n console.error('Error details:', error.stack);\n }\n process.exit(1); // Force exit on error\n } finally {\n // Ensure plugins are cleaned up\n await pluginRuntime.destroy();\n }\n}\n\nconst envScript = (dev: boolean) => `// --- Environment Variables Loader ---\nconst $env = [${(dev ? devEnvFileArgs : prodEnvFileArgs).map((p) => `\"${p}\"`).join(', ')}];\nfor (const file of $env) {\n try {\n process.loadEnvFile(file);\n console.log('\\\\x1b[36m✔ Loaded \\\\x1b[0m\\\\x1b[33m%s\\\\x1b[0m', file);\n } catch {}\n}\n`;\n\nconst antiCrashScript = [\n '// --- CommandKit Anti-Crash Monitor ---',\n \" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process\",\n ' // instead of using it as a means to resume operation.',\n ' // But it exists here due to compatibility reasons with discord bot ecosystem.',\n \" const p = (t) => `\\\\x1b[31m${t}\\\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';\",\n ' if (!process.eventNames().includes(e1)) // skip if it is already handled',\n ' process.on(e1, (e) => {',\n ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',\n ' })',\n ' if (!process.eventNames().includes(e2)) // skip if it is already handled',\n ' process.on(e2, (r) => {',\n ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',\n ' });',\n '// --- CommandKit Anti-Crash Monitor ---',\n].join('\\n');\n\nconst wrapInAsyncIIFE = (code: string[]) =>\n `;await (async () => {\\n${code.join('\\n\\n')}\\n})();`;\n\nasync function injectEntryFile(\n configPath: string,\n isDev: boolean,\n emitAntiCrashScript: boolean,\n distDir?: string,\n) {\n const dist = isDev ? '.commandkit' : distDir || 'dist';\n const entryFilePath = join(configPath, dist, 'index.js');\n\n // skip if the entry file already exists\n if (existsSync(entryFilePath)) return;\n\n const code = `/* Entrypoint File Generated By CommandKit */\n${isDev ? `\\n\\n// Injected for development\\n${wrapInAsyncIIFE([envScript(isDev), emitAntiCrashScript ? antiCrashScript : ''])}\\n\\n` : wrapInAsyncIIFE([envScript(isDev)])}\n\nimport { commandkit } from 'commandkit';\nimport { Client } from 'discord.js';\n\nasync function bootstrap() {\n const app = await import('./app.js').then((m) => m.default ?? m);\n\n if (!app || !(app instanceof Client)) {\n throw new Error('The app file must default export the discord.js client instance');\n }\n\n commandkit.setClient(app);\n\n await commandkit.start();\n}\n\nawait bootstrap().catch((e) => {\n console.error('Failed to bootstrap CommandKit application:\\\\n', e.stack);\n})\n`;\n\n await writeFile(entryFilePath, code);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA,SAAS,yBAAyB,KAA6B,OAAgB;CAC7E,MAAM,SAAS,OAAO,YACpB,OAAO,QAAQ,QAAQ,IAAI,CAAC,OAC1B,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,WAAW,qBAAqB,CAC3D,CACF;AAED,QAAO;EACL,GAAG;EACH,GAAG;EACH,GAAI,QACJ;GACE,UAAU;GACV,2BAA2B;GAC3B,mBAAmB;GACnB,oBAAoB;EACrB,IACD;GACE,UAAU;GACV,2BAA2B;GAC3B,mBAAmB;GACnB,oBAAoB;EACrB;CACF;AACH;;;;;AAMA,eAAsB,iBAAiB,EACrC,SACA,iBACA,OACA,YACwB,EAAE;;CAC1B,MAAM,SAAS,MAAM,kCAAe,WAAW;AAE/C,KAAI,CAAC,SAAS,gEAAC,OAAQ,oFAAY,oBACjC,MAAM,sCAAiB,cAAc,iCAAe;CAGtD,MAAM,gBAAgB,IAAI,yCACvB,WAAW,CAAE;CAGhB,oBAAoB,CAAE;CAEtB,gBAAgB,KAAK,cAAc,QAAQ,CAAC;AAE5C,KAAI;;EACF,MAAM,OAAO,QAAQ,gBAAgB,OAAO;EAG5C,yBAAa,KAAK;EAElB,MAAM,cAAc,MAAM;EAE1B,wBACE,wBACE;GACE,OAAO;GACP,KAAK;GACL,OAAO;GACP,QAAQ,CAAC,KAAM;GACf,OAAO;GACP,QAAQ;GACR,QAAQ,CAAC,CAAC;GACV,cAAc;IACZ,WAAW,EACT,KAAK;KACH,SAAS;KACT,cAAc;IACf,EACF;IACD,QAAQ,EACN,oBAAoB,KACrB;IACD,QAAQ,CAAC,SAAS,gBAAg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