commandkit 1.0.0-dev.20250514131945 → 1.0.0-dev.20250514140214
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/index.js +22 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5045,6 +5045,11 @@ function write(message) {
|
|
|
5045
5045
|
process.stdout.write(message);
|
|
5046
5046
|
process.stdout.write("\n");
|
|
5047
5047
|
}
|
|
5048
|
+
function findEntrypoint(dir) {
|
|
5049
|
+
const target = (0, import_node_path5.join)(dir, "sharding-manager.js");
|
|
5050
|
+
if (import_node_fs5.default.existsSync(target)) return target;
|
|
5051
|
+
return (0, import_node_path5.join)(dir, "index.js");
|
|
5052
|
+
}
|
|
5048
5053
|
function panic(message) {
|
|
5049
5054
|
write(colors_default.red(`Error: ${message}`));
|
|
5050
5055
|
process.exit(1);
|
|
@@ -5167,6 +5172,7 @@ var init_common3 = __esm({
|
|
|
5167
5172
|
init_types_package();
|
|
5168
5173
|
import_node_child_process = require("child_process");
|
|
5169
5174
|
__name(write, "write");
|
|
5175
|
+
__name(findEntrypoint, "findEntrypoint");
|
|
5170
5176
|
__name(panic, "panic");
|
|
5171
5177
|
__name(ensureTypeScript, "ensureTypeScript");
|
|
5172
5178
|
__name(detectPackageManager, "detectPackageManager");
|
|
@@ -5631,7 +5637,7 @@ var init_version = __esm({
|
|
|
5631
5637
|
"use strict";
|
|
5632
5638
|
init_cjs_shims();
|
|
5633
5639
|
version = /* @__MACRO__ $version */
|
|
5634
|
-
"1.0.0-dev.
|
|
5640
|
+
"1.0.0-dev.20250514140214";
|
|
5635
5641
|
}
|
|
5636
5642
|
});
|
|
5637
5643
|
|
|
@@ -5989,7 +5995,7 @@ __export(development_exports, {
|
|
|
5989
5995
|
});
|
|
5990
5996
|
async function buildAndStart(configPath, skipStart = false) {
|
|
5991
5997
|
const config = await loadConfigFile(configPath);
|
|
5992
|
-
const mainFile = (
|
|
5998
|
+
const mainFile = findEntrypoint(".commandkit");
|
|
5993
5999
|
await buildApplication({
|
|
5994
6000
|
configPath,
|
|
5995
6001
|
isDev: true,
|
|
@@ -6166,6 +6172,7 @@ var init_development = __esm({
|
|
|
6166
6172
|
import_promises6 = require("timers/promises");
|
|
6167
6173
|
import_node_crypto3 = require("crypto");
|
|
6168
6174
|
init_constants();
|
|
6175
|
+
init_common3();
|
|
6169
6176
|
__name(buildAndStart, "buildAndStart");
|
|
6170
6177
|
isCommandSource = /* @__PURE__ */ __name((p) => p.replaceAll("\\", "/").includes("src/app/commands"), "isCommandSource");
|
|
6171
6178
|
isEventSource = /* @__PURE__ */ __name((p) => p.replaceAll("\\", "/").includes("src/app/events"), "isEventSource");
|
|
@@ -6202,7 +6209,7 @@ async function bootstrapProductionServer(configPath) {
|
|
|
6202
6209
|
process.env.COMMANDKIT_BOOTSTRAP_MODE = "production";
|
|
6203
6210
|
const cwd = configPath || process.cwd();
|
|
6204
6211
|
const config = await loadConfigFile(cwd);
|
|
6205
|
-
const mainFile = (
|
|
6212
|
+
const mainFile = findEntrypoint(config.distDir);
|
|
6206
6213
|
if (!(0, import_fs.existsSync)(mainFile)) {
|
|
6207
6214
|
panic(
|
|
6208
6215
|
`Could not locate the entrypoint. Did you forget to build the application? Run 'commandkit build' to build the application first.`
|
|
@@ -6228,12 +6235,11 @@ async function createProductionBuild(configPath) {
|
|
|
6228
6235
|
});
|
|
6229
6236
|
spinner.succeed("Production build completed!");
|
|
6230
6237
|
}
|
|
6231
|
-
var
|
|
6238
|
+
var import_fs;
|
|
6232
6239
|
var init_production = __esm({
|
|
6233
6240
|
"src/cli/production.ts"() {
|
|
6234
6241
|
"use strict";
|
|
6235
6242
|
init_cjs_shims();
|
|
6236
|
-
import_path3 = require("path");
|
|
6237
6243
|
init_loader();
|
|
6238
6244
|
init_app_process();
|
|
6239
6245
|
import_fs = require("fs");
|
|
@@ -6253,7 +6259,7 @@ __export(generators_exports, {
|
|
|
6253
6259
|
generateEvent: () => generateEvent
|
|
6254
6260
|
});
|
|
6255
6261
|
function determineExtension() {
|
|
6256
|
-
return (0, import_fs2.existsSync)((0,
|
|
6262
|
+
return (0, import_fs2.existsSync)((0, import_path3.join)(BASE_PATH, "tsconfig.json")) ? "ts" : "js";
|
|
6257
6263
|
}
|
|
6258
6264
|
function TS_COMMAND_SOURCE(name) {
|
|
6259
6265
|
return `import type { CommandData, ChatInputCommand, MessageCommand } from 'commandkit';
|
|
@@ -6297,16 +6303,16 @@ export const message = async (ctx) => {
|
|
|
6297
6303
|
`;
|
|
6298
6304
|
}
|
|
6299
6305
|
async function generateCommand(name, customPath) {
|
|
6300
|
-
const cmdPath = (0,
|
|
6306
|
+
const cmdPath = (0, import_path3.join)(customPath || COMMANDS_DIR);
|
|
6301
6307
|
if (!(0, import_fs2.existsSync)(cmdPath)) await (0, import_promises7.mkdir)(cmdPath, { recursive: true });
|
|
6302
6308
|
const ext = determineExtension();
|
|
6303
6309
|
const isTypeScript = ext === "ts";
|
|
6304
6310
|
const fileName = `${name}.${ext}`;
|
|
6305
|
-
if ((0, import_fs2.existsSync)((0,
|
|
6311
|
+
if ((0, import_fs2.existsSync)((0, import_path3.join)(cmdPath, fileName))) {
|
|
6306
6312
|
panic(`Command ${name} already exists.`);
|
|
6307
6313
|
}
|
|
6308
6314
|
const commandFile = isTypeScript ? TS_COMMAND_SOURCE(name) : JS_COMMAND_SOURCE(name);
|
|
6309
|
-
await (0, import_promises7.writeFile)((0,
|
|
6315
|
+
await (0, import_promises7.writeFile)((0, import_path3.join)(cmdPath, fileName), commandFile);
|
|
6310
6316
|
console.log(
|
|
6311
6317
|
colors_default.green(
|
|
6312
6318
|
`Command ${colors_default.magenta(name)} created at ${colors_default.blue(formatPath(`${cmdPath}/${fileName}`))}`
|
|
@@ -6314,11 +6320,11 @@ async function generateCommand(name, customPath) {
|
|
|
6314
6320
|
);
|
|
6315
6321
|
}
|
|
6316
6322
|
async function generateEvent(name, customPath) {
|
|
6317
|
-
const eventPath = (0,
|
|
6323
|
+
const eventPath = (0, import_path3.join)(customPath || EVENTS_DIR, name);
|
|
6318
6324
|
if (!(0, import_fs2.existsSync)(eventPath)) await (0, import_promises7.mkdir)(eventPath, { recursive: true });
|
|
6319
6325
|
const ext = determineExtension();
|
|
6320
6326
|
let filename = `event.${ext}`;
|
|
6321
|
-
if ((0, import_fs2.existsSync)((0,
|
|
6327
|
+
if ((0, import_fs2.existsSync)((0, import_path3.join)(eventPath, filename))) {
|
|
6322
6328
|
const count = (await (0, import_promises7.readdir)(eventPath)).length;
|
|
6323
6329
|
filename = `${String(count).padStart(2, "0")}_${filename}`;
|
|
6324
6330
|
}
|
|
@@ -6327,26 +6333,26 @@ export default async function on${name[0].toUpperCase() + name.slice(1)}() {
|
|
|
6327
6333
|
console.log('${name} event fired!');
|
|
6328
6334
|
};
|
|
6329
6335
|
`.trim();
|
|
6330
|
-
await (0, import_promises7.writeFile)((0,
|
|
6336
|
+
await (0, import_promises7.writeFile)((0, import_path3.join)(eventPath, filename), eventFile);
|
|
6331
6337
|
console.log(
|
|
6332
6338
|
colors_default.green(
|
|
6333
6339
|
`Event ${colors_default.magenta(name)} created at ${colors_default.blue(formatPath(eventPath))}/${colors_default.magenta(filename)}`
|
|
6334
6340
|
)
|
|
6335
6341
|
);
|
|
6336
6342
|
}
|
|
6337
|
-
var import_promises7,
|
|
6343
|
+
var import_promises7, import_path3, import_fs2, BASE_PATH, COMMANDS_DIR, EVENTS_DIR, formatPath;
|
|
6338
6344
|
var init_generators = __esm({
|
|
6339
6345
|
"src/cli/generators.ts"() {
|
|
6340
6346
|
"use strict";
|
|
6341
6347
|
init_cjs_shims();
|
|
6342
6348
|
import_promises7 = require("fs/promises");
|
|
6343
|
-
|
|
6349
|
+
import_path3 = require("path");
|
|
6344
6350
|
init_common3();
|
|
6345
6351
|
import_fs2 = require("fs");
|
|
6346
6352
|
init_colors();
|
|
6347
6353
|
BASE_PATH = process.cwd();
|
|
6348
|
-
COMMANDS_DIR = (0,
|
|
6349
|
-
EVENTS_DIR = (0,
|
|
6354
|
+
COMMANDS_DIR = (0, import_path3.join)(BASE_PATH, "src/app/commands");
|
|
6355
|
+
EVENTS_DIR = (0, import_path3.join)(BASE_PATH, "src/app/events");
|
|
6350
6356
|
formatPath = /* @__PURE__ */ __name((path3) => path3.replace(process.cwd(), ".").replace(/\\/g, "/"), "formatPath");
|
|
6351
6357
|
__name(determineExtension, "determineExtension");
|
|
6352
6358
|
__name(TS_COMMAND_SOURCE, "TS_COMMAND_SOURCE");
|