commandkit 1.0.0-dev.20250530135418 → 1.0.0-dev.20250530151225
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-DSm40c6Y.js → build-B5TuLOa-.js} +5 -2
- package/dist/build-B5TuLOa-.js.map +1 -0
- package/dist/cli/app-process.d.ts +2 -2
- package/dist/cli/build.js +1 -1
- package/dist/cli/common.d.ts +2 -2
- package/dist/cli/development.js +1 -1
- package/dist/cli/information.js +1 -1
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/production.d.ts +2 -2
- package/dist/cli/production.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{init-_e3eZTUb.d.ts → init-CT348Okf.d.ts} +3 -3
- package/dist/utils/colors.d.ts +2 -2
- package/dist/{version-BDY5RKTk.js → version-EnexmO7x.js} +2 -2
- package/dist/{version-BDY5RKTk.js.map → version-EnexmO7x.js.map} +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/dist/build-DSm40c6Y.js.map +0 -1
|
@@ -34,7 +34,10 @@ async function buildApplication({ plugins, rolldownPlugins, isDev, configPath })
|
|
|
34
34
|
runtime: "automatic",
|
|
35
35
|
importSource: "commandkit"
|
|
36
36
|
} },
|
|
37
|
-
moduleTypes: {
|
|
37
|
+
moduleTypes: {
|
|
38
|
+
".json": "js",
|
|
39
|
+
".node": "binary"
|
|
40
|
+
}
|
|
38
41
|
},
|
|
39
42
|
plugins: rolldownPlugins,
|
|
40
43
|
platform: "node",
|
|
@@ -119,4 +122,4 @@ Object.defineProperty(exports, 'buildApplication', {
|
|
|
119
122
|
return buildApplication;
|
|
120
123
|
}
|
|
121
124
|
});
|
|
122
|
-
//# sourceMappingURL=build-
|
|
125
|
+
//# sourceMappingURL=build-B5TuLOa-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-B5TuLOa-.js","names":[],"sources":["../src/cli/build.ts"],"sourcesContent":["import { build } 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';\n\nexport interface ApplicationBuildOptions {\n plugins?: MaybeArray<CompilerPlugin>[] | Array<CompilerPlugin>;\n rolldownPlugins?: any[];\n isDev?: boolean;\n configPath?: string;\n}\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 || process.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 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 moduleTypes: {\n '.json': 'js',\n '.node': 'binary',\n },\n },\n plugins: rolldownPlugins,\n platform: 'node',\n skipNodeModulesBundle: true,\n name: 'CommandKit',\n sourcemap: true,\n target: 'node16',\n outDir: dest,\n env: (isDev ? DevEnv(true) : ProdEnv(true)) as Record<string, string>,\n entry: [\n 'src',\n `!${config.distDir}`,\n '!.commandkit',\n '!**/*.test.*',\n '!**/*.spec.*',\n ],\n unbundle: false,\n });\n\n await copyLocaleFiles('src', dest);\n await injectEntryFile(configPath || process.cwd(), !!isDev, config.distDir);\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 distDir?: string,\n) {\n const code = `/* Entrypoint File Generated By CommandKit */\n${isDev ? `\\n\\n// Injected for development\\n${wrapInAsyncIIFE([envScript(isDev), antiCrashScript])}\\n\\n` : wrapInAsyncIIFE([envScript(isDev)])}\n\nimport { CommandKit } from 'commandkit';\n\nasync function bootstrap() {\n const app = await import('./app.js').then((m) => m.default ?? m);\n const commandkit = new CommandKit({\n client: app,\n });\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 const dist = isDev ? '.commandkit' : distDir || 'dist';\n\n await writeFile(join(configPath, dist, 'index.js'), code);\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,eAAsB,iBAAiB,EACrC,SACA,iBACA,OACA,YACwB,EAAE;;CAC1B,MAAM,SAAS,MAAM,kCAAe,WAAW;AAE/C,MAAK,yEAAU,OAAQ,oFAAY,mBACjC,OAAM,sCAAiB,cAAc,QAAQ,KAAK,CAAC;CAGrD,MAAM,gBAAgB,IAAI,oDACvB,WAAW,CAAE;AAGhB,qBAAoB,CAAE;AAEtB,iBAAgB,KAAK,cAAc,QAAQ,CAAC;AAE5C,KAAI;EACF,MAAM,OAAO,QAAQ,gBAAgB,OAAO;AAG5C,QAAM,mBAAO,KAAK;AAElB,QAAM,cAAc,MAAM;AAE1B,QAAM,kBAAM;GACV,OAAO;GACP,KAAK;GACL,OAAO;GACP,QAAQ,CAAC,KAAM;GACf,OAAO;GACP,QAAQ;GACR,UAAU;GACV,cAAc;IACZ,WAAW,EACT,KAAK;KACH,SAAS;KACT,cAAc;IACf,EACF;IACD,aAAa;KACX,SAAS;KACT,SAAS;IACV;GACF;GACD,SAAS;GACT,UAAU;GACV,uBAAuB;GACvB,MAAM;GACN,WAAW;GACX,QAAQ;GACR,QAAQ;GACR,KAAM,QAAQ,mBAAO,KAAK,GAAG,oBAAQ,KAAK;GAC1C,OAAO;IACP;KACC,GAAG,OAAO,QAAQ;IACnB;IACA;IACA;GAAe;GAEf,UAAU;EACX,EAAC;AAEF,QAAM,+BAAgB,OAAO,KAAK;AAClC,QAAM,gBAAgB,cAAc,QAAQ,KAAK,IAAI,OAAO,OAAO,QAAQ;CAC5E,SAAQ,OAAO;AACd,UAAQ,MAAM,iBAAiB,MAAM;AACrC,MAAI,iBAAiB,MACnB,SAAQ,MAAM,kBAAkB,MAAM,MAAM;AAE9C,UAAQ,KAAK,EAAE;CAChB,UAAS;AAER,QAAM,cAAc,SAAS;CAC/B;AACF;AAEA,MAAM,YAAY,CAAC,SAAkB;gBACrB,CAAC,MAAM,6BAAiB,6BAAiB,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,CAAC,KAAK,KAAK,CAAC;;;;;;;;AASzF,MAAM,kBAAkB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAA2C,EAC3C,KAAK,KAAK;AAEV,MAAM,kBAAkB,CAAC,UACxB,yBAAyB,KAAK,KAAK,OAAO,CAAC;AAE5C,eAAe,gBACf,YACA,OACA,SACA;CACE,MAAM,QAAQ;EACd,SAAS,mCAAmC,gBAAgB,CAAC,UAAU,MAAM,EAAE,eAAgB,EAAC,CAAC,QAAQ,gBAAgB,CAAC,UAAU,MAAM,AAAC,EAAC,CAAA;;;;;;;;;;;;;;;;;CAkB5I,MAAM,OAAO,QAAQ,gBAAgB,WAAW;AAEhD,OAAM,gCAAU,oBAAK,YAAY,MAAM,WAAW,EAAE,KAAK;AAC3D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as child_process9 from "child_process";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/app-process.d.ts
|
|
4
|
-
declare function createAppProcess(fileName: string, cwd: string, isDev: boolean):
|
|
4
|
+
declare function createAppProcess(fileName: string, cwd: string, isDev: boolean): child_process9.ChildProcess;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { createAppProcess };
|
|
7
7
|
//# sourceMappingURL=app-process.d.ts.map
|
package/dist/cli/build.js
CHANGED
|
@@ -35,6 +35,6 @@ require('../CommandKitEventsChannel-BnSPcFdq.js');
|
|
|
35
35
|
require('../store-B9bo6On8.js');
|
|
36
36
|
require('../env-DXL8PZiG.js');
|
|
37
37
|
require('../type-checker-DodpF2I2.js');
|
|
38
|
-
const require_build = require('../build-
|
|
38
|
+
const require_build = require('../build-B5TuLOa-.js');
|
|
39
39
|
|
|
40
40
|
exports.buildApplication = require_build.buildApplication;
|
package/dist/cli/common.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ import "../index-CUPkUUOR.js";
|
|
|
31
31
|
import "../constants-Ce6w4OFe.js";
|
|
32
32
|
import "../types-w2bWHUve.js";
|
|
33
33
|
import { ResolvedCommandKitConfig } from "../utils-Dprjd7Oz.js";
|
|
34
|
-
import * as
|
|
34
|
+
import * as typescript1 from "typescript";
|
|
35
35
|
|
|
36
36
|
//#region src/cli/common.d.ts
|
|
37
37
|
declare function write(message: any): void;
|
|
@@ -41,7 +41,7 @@ declare function findEntrypoint(dir: string): string;
|
|
|
41
41
|
*/
|
|
42
42
|
declare function panic(message: any): never;
|
|
43
43
|
declare function findPackageJSON(): any;
|
|
44
|
-
declare function loadTypeScript(e?: string): Promise<typeof
|
|
44
|
+
declare function loadTypeScript(e?: string): Promise<typeof typescript1>;
|
|
45
45
|
declare function loadConfigFileFromPath(target: string): Promise<ResolvedCommandKitConfig>;
|
|
46
46
|
declare function erase(dir: string): void;
|
|
47
47
|
declare function copyLocaleFiles(_from: string, _to: string): Promise<void>;
|
package/dist/cli/development.js
CHANGED
|
@@ -37,7 +37,7 @@ require('../store-B9bo6On8.js');
|
|
|
37
37
|
require('../env-DXL8PZiG.js');
|
|
38
38
|
const require_app_process = require('../app-process-juzsCZp9.js');
|
|
39
39
|
require('../type-checker-DodpF2I2.js');
|
|
40
|
-
const require_build = require('../build-
|
|
40
|
+
const require_build = require('../build-B5TuLOa-.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,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('../chunk-nOFOJqeH.js');
|
|
2
|
-
const require_version = require('../version-
|
|
2
|
+
const require_version = require('../version-EnexmO7x.js');
|
|
3
3
|
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
4
4
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
5
|
const node_child_process = require_chunk.__toESM(require("node:child_process"));
|
package/dist/cli/init.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { bootstrapCommandkitCLI } from "../init-
|
|
1
|
+
import { bootstrapCommandkitCLI } from "../init-CT348Okf.js";
|
|
2
2
|
export { bootstrapCommandkitCLI };
|
package/dist/cli/production.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as child_process3 from "child_process";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/production.d.ts
|
|
4
|
-
declare function bootstrapProductionServer(configPath?: string): Promise<
|
|
4
|
+
declare function bootstrapProductionServer(configPath?: string): Promise<child_process3.ChildProcess>;
|
|
5
5
|
declare function createProductionBuild(configPath?: string): Promise<void>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { bootstrapProductionServer, createProductionBuild };
|
package/dist/cli/production.js
CHANGED
|
@@ -37,7 +37,7 @@ require('../store-B9bo6On8.js');
|
|
|
37
37
|
require('../env-DXL8PZiG.js');
|
|
38
38
|
const require_app_process = require('../app-process-juzsCZp9.js');
|
|
39
39
|
require('../type-checker-DodpF2I2.js');
|
|
40
|
-
const require_build = require('../build-
|
|
40
|
+
const require_build = require('../build-B5TuLOa-.js');
|
|
41
41
|
const require_utils = require('../utils-CU2bkxji.js');
|
|
42
42
|
const fs = require_chunk.__toESM(require("fs"));
|
|
43
43
|
|
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ import { COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COM
|
|
|
32
32
|
import { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext } from "./EventWorkerContext-CjU5wt-a.js";
|
|
33
33
|
import "./types-w2bWHUve.js";
|
|
34
34
|
import "./utils-Dprjd7Oz.js";
|
|
35
|
-
import { bootstrapCommandkitCLI } from "./init-
|
|
35
|
+
import { bootstrapCommandkitCLI } from "./init-CT348Okf.js";
|
|
36
36
|
import { defineConfig, getConfig } from "./config-LPxTebft.js";
|
|
37
37
|
import { ILogger } from "./ILogger-kqwb2kUu.js";
|
|
38
38
|
import { DefaultLogger } from "./DefaultLogger-CcW-Fuq5.js";
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ require('./store-B9bo6On8.js');
|
|
|
37
37
|
const require_helpers = require('./helpers-blGYXnUH.js');
|
|
38
38
|
require('./app-HN1cVg8J.js');
|
|
39
39
|
require('./ILogger-dQ7Y9X1f.js');
|
|
40
|
-
const require_version = require('./version-
|
|
40
|
+
const require_version = require('./version-EnexmO7x.js');
|
|
41
41
|
const require_feature_flags = require('./feature-flags-BtOkZJxW.js');
|
|
42
42
|
const require_init = require('./init-CakfOuYm.js');
|
|
43
43
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as commander2 from "commander";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/init.d.ts
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ import * as commander3 from "commander";
|
|
|
7
7
|
* @param argv The arguments passed to the CLI.
|
|
8
8
|
* @param options The options passed to the CLI.
|
|
9
9
|
*/
|
|
10
|
-
declare function bootstrapCommandkitCLI(argv: string[], options?:
|
|
10
|
+
declare function bootstrapCommandkitCLI(argv: string[], options?: commander2.ParseOptions | undefined): Promise<void>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { bootstrapCommandkitCLI };
|
|
13
|
-
//# sourceMappingURL=init-
|
|
13
|
+
//# sourceMappingURL=init-CT348Okf.d.ts.map
|
package/dist/utils/colors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as picocolors_types6 from "picocolors/types";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/colors.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: picocolors_types6.Colors;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
7
7
|
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* The current version of CommandKit.
|
|
5
5
|
*/
|
|
6
|
-
const version = "1.0.0-dev.
|
|
6
|
+
const version = "1.0.0-dev.20250530151225";
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
Object.defineProperty(exports, 'version', {
|
|
@@ -12,4 +12,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
12
12
|
return version;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
//# sourceMappingURL=version-
|
|
15
|
+
//# sourceMappingURL=version-EnexmO7x.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-
|
|
1
|
+
{"version":3,"file":"version-EnexmO7x.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["function $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":";;;;;AAQA,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.20250530151225",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"tsx": "^4.19.2",
|
|
123
123
|
"typescript": "^5.7.3",
|
|
124
124
|
"vitest": "^3.0.5",
|
|
125
|
-
"tsconfig": "0.0.0-dev.
|
|
125
|
+
"tsconfig": "0.0.0-dev.20250530151225"
|
|
126
126
|
},
|
|
127
127
|
"peerDependencies": {
|
|
128
128
|
"discord.js": "^14"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-DSm40c6Y.js","names":[],"sources":["../src/cli/build.ts"],"sourcesContent":["import { build } 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';\n\nexport interface ApplicationBuildOptions {\n plugins?: MaybeArray<CompilerPlugin>[] | Array<CompilerPlugin>;\n rolldownPlugins?: any[];\n isDev?: boolean;\n configPath?: string;\n}\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 || process.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 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 moduleTypes: {\n '.json': 'js',\n },\n },\n plugins: rolldownPlugins,\n platform: 'node',\n skipNodeModulesBundle: true,\n name: 'CommandKit',\n sourcemap: true,\n target: 'node16',\n outDir: dest,\n env: (isDev ? DevEnv(true) : ProdEnv(true)) as Record<string, string>,\n entry: [\n 'src',\n `!${config.distDir}`,\n '!.commandkit',\n '!**/*.test.*',\n '!**/*.spec.*',\n ],\n unbundle: false,\n });\n\n await copyLocaleFiles('src', dest);\n await injectEntryFile(configPath || process.cwd(), !!isDev, config.distDir);\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 distDir?: string,\n) {\n const code = `/* Entrypoint File Generated By CommandKit */\n${isDev ? `\\n\\n// Injected for development\\n${wrapInAsyncIIFE([envScript(isDev), antiCrashScript])}\\n\\n` : wrapInAsyncIIFE([envScript(isDev)])}\n\nimport { CommandKit } from 'commandkit';\n\nasync function bootstrap() {\n const app = await import('./app.js').then((m) => m.default ?? m);\n const commandkit = new CommandKit({\n client: app,\n });\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 const dist = isDev ? '.commandkit' : distDir || 'dist';\n\n await writeFile(join(configPath, dist, 'index.js'), code);\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,eAAsB,iBAAiB,EACrC,SACA,iBACA,OACA,YACwB,EAAE;;CAC1B,MAAM,SAAS,MAAM,kCAAe,WAAW;AAE/C,MAAK,yEAAU,OAAQ,oFAAY,mBACjC,OAAM,sCAAiB,cAAc,QAAQ,KAAK,CAAC;CAGrD,MAAM,gBAAgB,IAAI,oDACvB,WAAW,CAAE;AAGhB,qBAAoB,CAAE;AAEtB,iBAAgB,KAAK,cAAc,QAAQ,CAAC;AAE5C,KAAI;EACF,MAAM,OAAO,QAAQ,gBAAgB,OAAO;AAG5C,QAAM,mBAAO,KAAK;AAElB,QAAM,cAAc,MAAM;AAE1B,QAAM,kBAAM;GACV,OAAO;GACP,KAAK;GACL,OAAO;GACP,QAAQ,CAAC,KAAM;GACf,OAAO;GACP,QAAQ;GACR,UAAU;GACV,cAAc;IACZ,WAAW,EACT,KAAK;KACH,SAAS;KACT,cAAc;IACf,EACF;IACD,aAAa,EACX,SAAS,KACV;GACF;GACD,SAAS;GACT,UAAU;GACV,uBAAuB;GACvB,MAAM;GACN,WAAW;GACX,QAAQ;GACR,QAAQ;GACR,KAAM,QAAQ,mBAAO,KAAK,GAAG,oBAAQ,KAAK;GAC1C,OAAO;IACP;KACC,GAAG,OAAO,QAAQ;IACnB;IACA;IACA;GAAe;GAEf,UAAU;EACX,EAAC;AAEF,QAAM,+BAAgB,OAAO,KAAK;AAClC,QAAM,gBAAgB,cAAc,QAAQ,KAAK,IAAI,OAAO,OAAO,QAAQ;CAC5E,SAAQ,OAAO;AACd,UAAQ,MAAM,iBAAiB,MAAM;AACrC,MAAI,iBAAiB,MACnB,SAAQ,MAAM,kBAAkB,MAAM,MAAM;AAE9C,UAAQ,KAAK,EAAE;CAChB,UAAS;AAER,QAAM,cAAc,SAAS;CAC/B;AACF;AAEA,MAAM,YAAY,CAAC,SAAkB;gBACrB,CAAC,MAAM,6BAAiB,6BAAiB,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,CAAC,KAAK,KAAK,CAAC;;;;;;;;AASzF,MAAM,kBAAkB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAA2C,EAC3C,KAAK,KAAK;AAEV,MAAM,kBAAkB,CAAC,UACxB,yBAAyB,KAAK,KAAK,OAAO,CAAC;AAE5C,eAAe,gBACf,YACA,OACA,SACA;CACE,MAAM,QAAQ;EACd,SAAS,mCAAmC,gBAAgB,CAAC,UAAU,MAAM,EAAE,eAAgB,EAAC,CAAC,QAAQ,gBAAgB,CAAC,UAAU,MAAM,AAAC,EAAC,CAAA;;;;;;;;;;;;;;;;;CAkB5I,MAAM,OAAO,QAAQ,gBAAgB,WAAW;AAEhD,OAAM,gCAAU,oBAAK,YAAY,MAAM,WAAW,EAAE,KAAK;AAC3D"}
|