commandkit 0.1.11-dev.20250331145527 → 0.1.11-dev.20250402134128

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 CHANGED
@@ -2021,6 +2021,13 @@ var init_RuntimePlugin = __esm({
2021
2021
  */
2022
2022
  async onCommandsRouterInit(ctx) {
2023
2023
  }
2024
+ /**
2025
+ * Called when HMR event is received
2026
+ * @param ctx The context
2027
+ * @param event The event
2028
+ */
2029
+ async performHMR(ctx, event) {
2030
+ }
2024
2031
  };
2025
2032
  __name(_RuntimePlugin, "RuntimePlugin");
2026
2033
  RuntimePlugin = _RuntimePlugin;
@@ -2521,7 +2528,7 @@ var init_UseCacheTransformer = __esm({
2521
2528
  generate = import_generator.default.default || import_generator.default;
2522
2529
  IMPORT_PATH = "commandkit";
2523
2530
  DIRECTIVE = "use cache";
2524
- CACHE_IDENTIFIER = "super_duper_secret_internal_for_use_cache_directive_of_commandkit_cli_do_not_use_it_directly_or_you_will_be_fired_from_your_job_kthxbai";
2531
+ CACHE_IDENTIFIER = "zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired";
2525
2532
  generateRandomString = /* @__PURE__ */ __name((length = 6) => {
2526
2533
  const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2527
2534
  return Array.from(
@@ -2543,22 +2550,22 @@ var init_UseCacheTransformer = __esm({
2543
2550
  };
2544
2551
  traverse(ast, {
2545
2552
  Program: {
2546
- enter(path2) {
2547
- const binding = path2.scope.getBinding(CACHE_IDENTIFIER);
2553
+ enter(path3) {
2554
+ const binding = path3.scope.getBinding(CACHE_IDENTIFIER);
2548
2555
  if (binding) {
2549
2556
  state.cacheIdentifierName = `${CACHE_IDENTIFIER}_${generateRandomString()}`;
2550
2557
  }
2551
2558
  }
2552
2559
  },
2553
- ImportDeclaration(path2) {
2554
- if (path2.node.source.value === IMPORT_PATH && path2.node.specifiers.some(
2560
+ ImportDeclaration(path3) {
2561
+ if (path3.node.source.value === IMPORT_PATH && path3.node.specifiers.some(
2555
2562
  (spec) => t.isImportSpecifier(spec) && // @ts-ignore
2556
2563
  spec.imported.name === CACHE_IDENTIFIER
2557
2564
  )) {
2558
2565
  state.hasExistingImport = true;
2559
2566
  if (state.cacheIdentifierName !== CACHE_IDENTIFIER) {
2560
2567
  state.modifications.push(() => {
2561
- path2.node.specifiers.forEach((spec) => {
2568
+ path3.node.specifiers.forEach((spec) => {
2562
2569
  if (t.isImportSpecifier(spec) && // @ts-ignore
2563
2570
  spec.imported.name === CACHE_IDENTIFIER) {
2564
2571
  spec.local.name = state.cacheIdentifierName;
@@ -2568,14 +2575,14 @@ var init_UseCacheTransformer = __esm({
2568
2575
  }
2569
2576
  }
2570
2577
  },
2571
- "FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod"(path2) {
2578
+ "FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod"(path3) {
2572
2579
  var _a2, _b, _c;
2573
- const body = t.isBlockStatement(path2.node.body) ? path2.node.body : null;
2580
+ const body = t.isBlockStatement(path3.node.body) ? path3.node.body : null;
2574
2581
  const hasUseCache = (_a2 = body == null ? void 0 : body.directives) == null ? void 0 : _a2.some(
2575
2582
  (d) => d.value.value === DIRECTIVE
2576
2583
  );
2577
- if (!hasUseCache && !t.isBlockStatement(path2.node.body)) {
2578
- const parentFunction = path2.findParent(
2584
+ if (!hasUseCache && !t.isBlockStatement(path3.node.body)) {
2585
+ const parentFunction = path3.findParent(
2579
2586
  (p) => (p.isFunction() || p.isProgram()) && "directives" in p.node
2580
2587
  );
2581
2588
  if (!((_b = parentFunction == null ? void 0 : parentFunction.node.directives) == null ? void 0 : _b.some(
@@ -2584,35 +2591,35 @@ var init_UseCacheTransformer = __esm({
2584
2591
  return;
2585
2592
  }
2586
2593
  }
2587
- if (hasUseCache || !t.isBlockStatement(path2.node.body)) {
2588
- if (!path2.node.async) {
2594
+ if (hasUseCache || !t.isBlockStatement(path3.node.body)) {
2595
+ if (!path3.node.async) {
2589
2596
  throw new Error(
2590
2597
  `"${DIRECTIVE}" directive may only be used in async functions at ${args.path}
2591
2598
 
2592
- ${path2.toString()}
2599
+ ${path3.toString()}
2593
2600
  ^^^^${"-".repeat(6)} This function must be async`
2594
2601
  );
2595
2602
  }
2596
2603
  state.needsImport = true;
2597
- const isDeclaration = t.isFunctionDeclaration(path2.node);
2598
- const name = isDeclaration ? (_c = path2.node.id) == null ? void 0 : _c.name : void 0;
2599
- const newBody = t.isBlockStatement(path2.node.body) ? t.blockStatement(
2600
- path2.node.body.body,
2601
- path2.node.body.directives.filter(
2604
+ const isDeclaration = t.isFunctionDeclaration(path3.node);
2605
+ const name = isDeclaration ? (_c = path3.node.id) == null ? void 0 : _c.name : void 0;
2606
+ const newBody = t.isBlockStatement(path3.node.body) ? t.blockStatement(
2607
+ path3.node.body.body,
2608
+ path3.node.body.directives.filter(
2602
2609
  (d) => d.value.value !== DIRECTIVE
2603
2610
  )
2604
- ) : path2.node.body;
2611
+ ) : path3.node.body;
2605
2612
  const wrapped = t.callExpression(
2606
2613
  t.identifier(state.cacheIdentifierName),
2607
- [t.arrowFunctionExpression(path2.node.params, newBody, true)]
2614
+ [t.arrowFunctionExpression(path3.node.params, newBody, true)]
2608
2615
  );
2609
2616
  state.modifications.push(() => {
2610
- if (t.isObjectMethod(path2.node)) {
2611
- path2.replaceWith(
2612
- t.objectProperty(t.identifier(path2.node.key.name), wrapped)
2617
+ if (t.isObjectMethod(path3.node)) {
2618
+ path3.replaceWith(
2619
+ t.objectProperty(t.identifier(path3.node.key.name), wrapped)
2613
2620
  );
2614
2621
  } else if (name) {
2615
- path2.replaceWith(
2622
+ path3.replaceWith(
2616
2623
  t.variableDeclaration(
2617
2624
  "const",
2618
2625
  [
@@ -2620,10 +2627,10 @@ ${path2.toString()}
2620
2627
  ]
2621
2628
  )
2622
2629
  );
2623
- } else if (!t.isVariableDeclarator(path2.parent)) {
2624
- path2.replaceWith(wrapped);
2630
+ } else if (!t.isVariableDeclarator(path3.parent)) {
2631
+ path3.replaceWith(wrapped);
2625
2632
  } else {
2626
- path2.parent.init = wrapped;
2633
+ path3.parent.init = wrapped;
2627
2634
  }
2628
2635
  });
2629
2636
  }
@@ -2807,7 +2814,7 @@ var init_config = __esm({
2807
2814
  });
2808
2815
 
2809
2816
  // src/utils/constants.ts
2810
- var COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST;
2817
+ var COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, HMREventType;
2811
2818
  var init_constants = __esm({
2812
2819
  "src/utils/constants.ts"() {
2813
2820
  "use strict";
@@ -2815,6 +2822,12 @@ var init_constants = __esm({
2815
2822
  COMMANDKIT_CACHE_TAG = Symbol("kCommandKitCacheTag");
2816
2823
  COMMANDKIT_IS_DEV = !!process.env.COMMANDKIT_IS_DEV;
2817
2824
  COMMANDKIT_IS_TEST = process.env.COMMANDKIT_IS_TEST === "true";
2825
+ HMREventType = {
2826
+ ReloadCommands: "reload-commands",
2827
+ ReloadEvents: "reload-events",
2828
+ ReloadLocales: "reload-locales",
2829
+ Unknown: "unknown"
2830
+ };
2818
2831
  }
2819
2832
  });
2820
2833
 
@@ -2840,18 +2853,18 @@ var init_DefaultLocalizationStrategy = __esm({
2840
2853
  const paths = [".js", ".json", ".mjs", ".cjs"].map(
2841
2854
  (e) => (0, import_node_path.join)(localesPath, locale, scope) + e
2842
2855
  );
2843
- for (const path2 of paths) {
2844
- if (!(0, import_node_fs.existsSync)(path2)) {
2856
+ for (const path3 of paths) {
2857
+ if (!(0, import_node_fs.existsSync)(path3)) {
2845
2858
  continue;
2846
2859
  }
2847
2860
  try {
2848
2861
  let localeData;
2849
2862
  try {
2850
- if (path2.endsWith(".json")) {
2851
- const data = await (0, import_promises2.readFile)(path2, "utf-8");
2863
+ if (path3.endsWith(".json")) {
2864
+ const data = await (0, import_promises2.readFile)(path3, "utf-8");
2852
2865
  localeData = JSON.parse(data);
2853
2866
  } else {
2854
- const { default: data } = await import(`file://${path2}`);
2867
+ const { default: data } = await import(`file://${path3}`);
2855
2868
  localeData = data;
2856
2869
  }
2857
2870
  } catch {
@@ -2882,8 +2895,8 @@ export {};
2882
2895
  declare module 'commandkit' {
2883
2896
  export interface CommandLocalizationTypeData {
2884
2897
  `;
2885
- const footer = ` type TranslatableCommandName = keyof CommandLocalizationTypeData
2886
- }
2898
+ const footer = ` }
2899
+ type TranslatableCommandName = keyof CommandLocalizationTypeData
2887
2900
  }`;
2888
2901
  const generateType = /* @__PURE__ */ __name((locale) => {
2889
2902
  const commandName = locale.command.name;
@@ -2982,6 +2995,13 @@ function getCurrentDirectory() {
2982
2995
  currentDir = root;
2983
2996
  return root;
2984
2997
  }
2998
+ function getSourceDirectories() {
2999
+ const dist = getConfig().distDir;
3000
+ const locations = ["src", ".commandkit", dist].map(
3001
+ (dir) => (0, import_node_path2.join)(process.cwd(), dir)
3002
+ );
3003
+ return locations;
3004
+ }
2985
3005
  function findAppDirectory() {
2986
3006
  if (appDir) return appDir;
2987
3007
  let root = (0, import_node_path2.join)(
@@ -3031,6 +3051,7 @@ var init_utilities = __esm({
3031
3051
  appDir = null;
3032
3052
  currentDir = null;
3033
3053
  __name(getCurrentDirectory, "getCurrentDirectory");
3054
+ __name(getSourceDirectories, "getSourceDirectories");
3034
3055
  __name(findAppDirectory, "findAppDirectory");
3035
3056
  __name(debounce, "debounce");
3036
3057
  }
@@ -3444,9 +3465,24 @@ var init_environment = __esm({
3444
3465
  deferredFunctions: /* @__PURE__ */ new Map(),
3445
3466
  marker: "",
3446
3467
  markStart: 0,
3447
- markEnd: 0
3468
+ markEnd: 0,
3469
+ context: null
3448
3470
  });
3449
3471
  }
3472
+ /**
3473
+ * Set the context.
3474
+ * @param context - The context to set.
3475
+ */
3476
+ setContext(context2) {
3477
+ __privateGet(this, _data).context = context2;
3478
+ }
3479
+ /**
3480
+ * Get the context. `null` if not set.
3481
+ * @internal
3482
+ */
3483
+ get context() {
3484
+ return __privateGet(this, _data).context;
3485
+ }
3450
3486
  /**
3451
3487
  * Get the execution error.
3452
3488
  * @internal
@@ -3769,7 +3805,7 @@ async function revalidate(tag, ...args) {
3769
3805
  function isCachedFunction(fn) {
3770
3806
  return Object.prototype.hasOwnProperty.call(fn, CACHED_FN_SYMBOL);
3771
3807
  }
3772
- var import_node_async_hooks2, import_node_crypto2, import_ms, cacheContext, fnStore, DEFAULT_TTL, CACHE_FN_ID, CACHED_FN_SYMBOL;
3808
+ var import_node_async_hooks2, import_node_crypto2, import_ms, cacheContext, fnStore, DEFAULT_TTL, CACHE_FN_ID, CACHED_FN_SYMBOL, zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired;
3773
3809
  var init_cache = __esm({
3774
3810
  "src/cache/cache.ts"() {
3775
3811
  "use strict";
@@ -3792,6 +3828,7 @@ var init_cache = __esm({
3792
3828
  __name(invalidate, "invalidate");
3793
3829
  __name(revalidate, "revalidate");
3794
3830
  __name(isCachedFunction, "isCachedFunction");
3831
+ zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired = useCache;
3795
3832
  }
3796
3833
  });
3797
3834
 
@@ -3856,6 +3893,9 @@ var init_Context = __esm({
3856
3893
  this.client = commandkit2.client;
3857
3894
  __privateSet(this, _store, config.store ?? /* @__PURE__ */ new Map());
3858
3895
  this.command = config.command;
3896
+ if (this.config.environment) {
3897
+ this.config.environment.setContext(this);
3898
+ }
3859
3899
  }
3860
3900
  /**
3861
3901
  * The shared key-value store for this context. This can be used to store data that needs to be shared between middlewares or commands.
@@ -4876,8 +4916,8 @@ var init_CommandsRouter = __esm({
4876
4916
  middlewares: Object.fromEntries(this.middlewares.entries())
4877
4917
  };
4878
4918
  }
4879
- async traverse(path2, category) {
4880
- const entries = await (0, import_promises4.readdir)(path2, {
4919
+ async traverse(path3, category) {
4920
+ const entries = await (0, import_promises4.readdir)(path3, {
4881
4921
  withFileTypes: true
4882
4922
  });
4883
4923
  for (const entry of entries) {
@@ -4891,24 +4931,24 @@ var init_CommandsRouter = __esm({
4891
4931
  }
4892
4932
  async handle(entry, category = null) {
4893
4933
  const name = entry.name;
4894
- const path2 = (0, import_node_path4.join)(entry.parentPath, entry.name);
4934
+ const path3 = (0, import_node_path4.join)(entry.parentPath, entry.name);
4895
4935
  if (this.isCommand(name)) {
4896
4936
  const command = {
4897
4937
  id: crypto.randomUUID(),
4898
- name: (0, import_node_path4.basename)(path2, (0, import_node_path4.extname)(path2)),
4899
- path: path2,
4938
+ name: (0, import_node_path4.basename)(path3, (0, import_node_path4.extname)(path3)),
4939
+ path: path3,
4900
4940
  category,
4901
4941
  parentPath: entry.parentPath,
4902
- relativePath: this.replaceEntrypoint(path2),
4942
+ relativePath: this.replaceEntrypoint(path3),
4903
4943
  middlewares: []
4904
4944
  };
4905
4945
  this.commands.set(command.id, command);
4906
4946
  } else if (this.isMiddleware(name)) {
4907
4947
  const middleware = {
4908
4948
  id: crypto.randomUUID(),
4909
- name: (0, import_node_path4.basename)(path2, (0, import_node_path4.extname)(path2)),
4910
- path: path2,
4911
- relativePath: this.replaceEntrypoint(path2),
4949
+ name: (0, import_node_path4.basename)(path3, (0, import_node_path4.extname)(path3)),
4950
+ path: path3,
4951
+ relativePath: this.replaceEntrypoint(path3),
4912
4952
  parentPath: entry.parentPath,
4913
4953
  global: GLOBAL_MIDDLEWARE_PATTERN.test(name)
4914
4954
  };
@@ -4926,8 +4966,8 @@ var init_CommandsRouter = __esm({
4926
4966
  );
4927
4967
  });
4928
4968
  }
4929
- replaceEntrypoint(path2) {
4930
- const normalized = (0, import_node_path4.normalize)(path2);
4969
+ replaceEntrypoint(path3) {
4970
+ const normalized = (0, import_node_path4.normalize)(path3);
4931
4971
  return normalized.replace(this.options.entrypoint, "");
4932
4972
  }
4933
4973
  };
@@ -5017,8 +5057,8 @@ var init_EventsRouter = __esm({
5017
5057
  const dirs = await (0, import_promises5.readdir)(entrypoint, { withFileTypes: true });
5018
5058
  for (const dir of dirs) {
5019
5059
  if (dir.isDirectory()) {
5020
- const path2 = (0, import_node_path5.join)(entrypoint, dir.name);
5021
- await this.scanEvent(dir.name, path2, null, [], true);
5060
+ const path3 = (0, import_node_path5.join)(entrypoint, dir.name);
5061
+ await this.scanEvent(dir.name, path3, null, [], true);
5022
5062
  }
5023
5063
  }
5024
5064
  }
@@ -5038,14 +5078,14 @@ var init_EventsRouter = __esm({
5038
5078
  * @param listeners - Array to collect listener file paths
5039
5079
  * @returns Promise resolving to the parsed event metadata
5040
5080
  */
5041
- async scanEvent(event, path2, _namespace = null, listeners = [], isRoot = false) {
5042
- const files = await (0, import_promises5.readdir)(path2, { withFileTypes: true });
5081
+ async scanEvent(event, path3, _namespace = null, listeners = [], isRoot = false) {
5082
+ const files = await (0, import_promises5.readdir)(path3, { withFileTypes: true });
5043
5083
  const isNamespace = isRoot && /^\(.+\)$/.test(event);
5044
5084
  const namespace = isNamespace ? event.slice(1, -1) : _namespace ?? null;
5045
5085
  for (const file of files) {
5046
5086
  if (file.name.includes("_")) continue;
5047
5087
  if (file.isDirectory()) {
5048
- const nextPath = (0, import_node_path5.join)(path2, file.name);
5088
+ const nextPath = (0, import_node_path5.join)(path3, file.name);
5049
5089
  await this.scanEvent(file.name, nextPath, namespace, listeners);
5050
5090
  continue;
5051
5091
  }
@@ -5054,7 +5094,7 @@ var init_EventsRouter = __esm({
5054
5094
  }
5055
5095
  }
5056
5096
  if (!isNamespace) {
5057
- this.events.set(event, { event, path: path2, listeners, namespace });
5097
+ this.events.set(event, { event, path: path3, listeners, namespace });
5058
5098
  }
5059
5099
  }
5060
5100
  };
@@ -5302,8 +5342,11 @@ var init_common2 = __esm({
5302
5342
  });
5303
5343
 
5304
5344
  // src/config/loader.ts
5345
+ function getPossibleConfigPaths(root) {
5346
+ return CONFIG_FILE_NAMES.map((name) => (0, import_node_path7.join)(root, name));
5347
+ }
5305
5348
  function findConfigFile(cwd) {
5306
- const locations = CONFIG_FILE_NAMES.map((name) => (0, import_node_path7.join)(cwd, name));
5349
+ const locations = getPossibleConfigPaths(cwd);
5307
5350
  for (const location of locations) {
5308
5351
  if ((0, import_node_fs7.existsSync)(location)) {
5309
5352
  return {
@@ -5337,6 +5380,7 @@ var init_loader = __esm({
5337
5380
  "commandkit.config.cjs",
5338
5381
  "commandkit.config.ts"
5339
5382
  ];
5383
+ __name(getPossibleConfigPaths, "getPossibleConfigPaths");
5340
5384
  __name(findConfigFile, "findConfigFile");
5341
5385
  loadedConfig = null;
5342
5386
  __name(loadConfigFile, "loadConfigFile");
@@ -5346,23 +5390,55 @@ var init_loader = __esm({
5346
5390
  // src/utils/dev-hooks.ts
5347
5391
  function registerDevHooks(commandkit2) {
5348
5392
  if (!COMMANDKIT_IS_DEV) return;
5349
- process.on("message", (message) => {
5393
+ process.on("message", async (message) => {
5350
5394
  if (typeof message !== "object" || message === null) return;
5351
- const { event, path: path2 } = message;
5395
+ const { event, path: path3, id } = message;
5352
5396
  if (!event) return;
5353
5397
  if (process.env.COMMANDKIT_DEBUG_HMR === "true") {
5354
- Logger.info(`Received HMR event: ${event}${path2 ? ` for ${path2}` : ""}`);
5398
+ Logger.info(`Received HMR event: ${event}${path3 ? ` for ${path3}` : ""}`);
5355
5399
  }
5356
- switch (event) {
5357
- case "reload-commands":
5358
- commandkit2.commandHandler.reloadCommands();
5359
- break;
5360
- case "reload-events":
5361
- commandkit2.eventHandler.reloadEvents();
5362
- break;
5363
- case "reload-locales":
5364
- commandkit2.commandHandler.reloadCommands();
5365
- break;
5400
+ let accepted = false, prevented = false, handled = false;
5401
+ const hmrEvent = {
5402
+ accept() {
5403
+ accepted = true;
5404
+ },
5405
+ preventDefault() {
5406
+ prevented = true;
5407
+ },
5408
+ path: path3,
5409
+ event
5410
+ };
5411
+ try {
5412
+ await commandkit2.plugins.execute(async (ctx, plugin) => {
5413
+ var _a;
5414
+ if (accepted) return;
5415
+ await ((_a = plugin.performHMR) == null ? void 0 : _a.call(plugin, ctx, hmrEvent));
5416
+ });
5417
+ if (prevented) return;
5418
+ switch (event) {
5419
+ case HMREventType.ReloadCommands:
5420
+ commandkit2.commandHandler.reloadCommands();
5421
+ handled = true;
5422
+ break;
5423
+ case HMREventType.ReloadEvents:
5424
+ case HMREventType.ReloadLocales:
5425
+ commandkit2.eventHandler.reloadEvents();
5426
+ handled = true;
5427
+ break;
5428
+ case HMREventType.Unknown:
5429
+ handled = false;
5430
+ break;
5431
+ default:
5432
+ break;
5433
+ }
5434
+ } finally {
5435
+ if (id && process.send) {
5436
+ process.send({
5437
+ type: "commandkit-hmr-ack",
5438
+ id,
5439
+ handled: handled || accepted
5440
+ });
5441
+ }
5366
5442
  }
5367
5443
  });
5368
5444
  }
@@ -5490,7 +5566,6 @@ var init_CommandKit = __esm({
5490
5566
  if (options.cacheProvider !== null && (!options.cacheProvider || !(options.cacheProvider instanceof CacheProvider))) {
5491
5567
  options.cacheProvider = new MemoryCache();
5492
5568
  }
5493
- this.eventInterceptor = new EventInterceptor(options.client);
5494
5569
  this.plugins = new CommandKitPluginRuntime(this);
5495
5570
  if (!_CommandKit.instance) {
5496
5571
  _CommandKit.instance = this;
@@ -5503,6 +5578,12 @@ var init_CommandKit = __esm({
5503
5578
  */
5504
5579
  async start(token) {
5505
5580
  if (__privateGet(this, _started)) return;
5581
+ if (!this.options.client) {
5582
+ throw new Error(
5583
+ colors_default.red('"client" is required when starting CommandKit.')
5584
+ );
5585
+ }
5586
+ this.eventInterceptor = new EventInterceptor(this.client);
5506
5587
  if (COMMANDKIT_IS_DEV) {
5507
5588
  try {
5508
5589
  registerDevHooks(this);
@@ -5716,7 +5797,7 @@ var init_version = __esm({
5716
5797
  "use strict";
5717
5798
  init_cjs_shims();
5718
5799
  version = /* @__MACRO__ $version */
5719
- "0.1.11-dev.20250331145527";
5800
+ "0.1.11-dev.20250402134128";
5720
5801
  }
5721
5802
  });
5722
5803
 
@@ -5866,7 +5947,7 @@ ${wrapInAsyncIIFE([envScript(isDev), antiCrashScript, requireScript])}
5866
5947
  import { CommandKit } from 'commandkit';
5867
5948
  import app from './app.js';
5868
5949
 
5869
- async function main() {
5950
+ async function bootstrap() {
5870
5951
  const commandkit = new CommandKit({
5871
5952
  client: app,
5872
5953
  });
@@ -5874,7 +5955,9 @@ async function main() {
5874
5955
  await commandkit.start();
5875
5956
  }
5876
5957
 
5877
- await main();
5958
+ await bootstrap().catch((e) => {
5959
+ console.error('Failed to bootstrap CommandKit application:\\n', e.stack);
5960
+ })
5878
5961
  `;
5879
5962
  const dist = isDev ? ".commandkit" : distDir || "dist";
5880
5963
  await (0, import_promises6.writeFile)((0, import_node_path10.join)(configPath, dist, "index.js"), code);
@@ -5956,52 +6039,116 @@ async function buildAndStart(configPath, skipStart = false) {
5956
6039
  });
5957
6040
  if (skipStart) return null;
5958
6041
  const ps = createAppProcess(mainFile, configPath, true);
5959
- ps.on("message", (message) => {
5960
- console.log(`Received message from child process: ${message}`);
5961
- });
5962
6042
  return ps;
5963
6043
  }
5964
6044
  async function bootstrapDevelopmentServer(configPath) {
5965
6045
  const start = performance.now();
5966
6046
  const cwd = configPath || process.cwd();
5967
- const watcher = (0, import_chokidar.watch)([(0, import_path2.join)(cwd, "src")], {
6047
+ const configPaths = getPossibleConfigPaths(cwd);
6048
+ const watcher = (0, import_chokidar.watch)([(0, import_path2.join)(cwd, "src"), ...configPaths], {
5968
6049
  ignoreInitial: true
5969
6050
  });
5970
6051
  let ps = null;
5971
- const performHMR = debounce(async (path2) => {
5972
- if (!path2 || !ps) return false;
5973
- if (!ps.send) return false;
5974
- if (isCommandSource(path2)) {
5975
- console.log(
5976
- `${colors_default.cyanBright("Reloading command(s) at ")} ${colors_default.yellowBright(path2)}`
6052
+ const waitForAcknowledgment = /* @__PURE__ */ __name((messageId) => {
6053
+ return new Promise((resolve) => {
6054
+ if (!ps) return resolve(false);
6055
+ let _handled = false;
6056
+ const onMessage = /* @__PURE__ */ __name((message) => {
6057
+ _handled = true;
6058
+ if (typeof message !== "object" || message === null) return;
6059
+ const { type, id, handled } = message;
6060
+ if (type === "commandkit-hmr-ack" && id === messageId) {
6061
+ ps == null ? void 0 : ps.off("message", onMessage);
6062
+ resolve(!!handled);
6063
+ }
6064
+ }, "onMessage");
6065
+ ps.once("message", onMessage);
6066
+ if (!_handled) {
6067
+ (0, import_promises7.setTimeout)(3e3).then(() => {
6068
+ ps == null ? void 0 : ps.off("message", onMessage);
6069
+ resolve(false);
6070
+ });
6071
+ }
6072
+ });
6073
+ }, "waitForAcknowledgment");
6074
+ const sendHmrEvent = /* @__PURE__ */ __name(async (event, path3) => {
6075
+ if (!ps || !ps.send) return false;
6076
+ const messageId = (0, import_node_crypto3.randomUUID)();
6077
+ const messagePromise = waitForAcknowledgment(messageId);
6078
+ ps.send({ event, path: path3, id: messageId });
6079
+ try {
6080
+ let triggered = false;
6081
+ const res = !!await Promise.race(
6082
+ [
6083
+ messagePromise,
6084
+ (0, import_promises7.setTimeout)(3e3).then(() => {
6085
+ if (!triggered) {
6086
+ console.warn(
6087
+ colors_default.yellow(
6088
+ `HMR acknowledgment timed out for event ${event} on path ${path3}`
6089
+ )
6090
+ );
6091
+ }
6092
+ return false;
6093
+ })
6094
+ ]
5977
6095
  );
5978
- await buildAndStart(cwd, true);
5979
- ps.send({ event: "reload-commands", path: path2 });
5980
- return true;
5981
- }
5982
- if (isEventSource(path2)) {
5983
- console.log(
5984
- `${colors_default.cyanBright("Reloading event(s) at ")} ${colors_default.yellowBright(path2)}`
6096
+ triggered = true;
6097
+ return res;
6098
+ } catch (error) {
6099
+ console.error(
6100
+ colors_default.red(`Error waiting for HMR acknowledgment: ${error}`)
5985
6101
  );
5986
- await buildAndStart(cwd, true);
5987
- ps.send({ event: "reload-events", path: path2 });
5988
- return true;
6102
+ return false;
5989
6103
  }
5990
- if (isLocaleSource(path2)) {
6104
+ }, "sendHmrEvent");
6105
+ const performHMR = debounce(async (path3) => {
6106
+ if (!path3 || !ps) return false;
6107
+ let eventType = null;
6108
+ let eventDescription = "";
6109
+ if (isCommandSource(path3)) {
6110
+ eventType = HMREventType.ReloadCommands;
6111
+ eventDescription = "command(s)";
6112
+ } else if (isEventSource(path3)) {
6113
+ eventType = HMREventType.ReloadEvents;
6114
+ eventDescription = "event(s)";
6115
+ } else if (isLocaleSource(path3)) {
6116
+ eventType = HMREventType.ReloadLocales;
6117
+ eventDescription = "locale(s)";
6118
+ } else {
6119
+ eventType = HMREventType.Unknown;
6120
+ eventDescription = "unknown source";
6121
+ }
6122
+ if (eventType) {
5991
6123
  console.log(
5992
- `${colors_default.cyanBright("Reloading locale(s) at ")} ${colors_default.yellowBright(path2)}`
6124
+ `${colors_default.cyanBright(`Attempting to reload ${eventDescription} at`)} ${colors_default.yellowBright(path3)}`
5993
6125
  );
5994
6126
  await buildAndStart(cwd, true);
5995
- ps.send({ event: "reload-locales", path: path2 });
5996
- return true;
6127
+ const hmrHandled = await sendHmrEvent(eventType, path3);
6128
+ if (hmrHandled) {
6129
+ console.log(
6130
+ `${colors_default.greenBright(`Successfully hot reloaded ${eventDescription} at`)} ${colors_default.yellowBright(path3)}`
6131
+ );
6132
+ return true;
6133
+ }
5997
6134
  }
5998
6135
  return false;
5999
6136
  }, 300);
6000
- const hmrHandler = /* @__PURE__ */ __name(async (path2) => {
6001
- const hmr = await performHMR(path2);
6137
+ const isConfigUpdate = /* @__PURE__ */ __name((path3) => {
6138
+ const isConfig = configPaths.some((configPath2) => path3 === configPath2);
6139
+ console.log(
6140
+ colors_default.yellowBright(
6141
+ "It seems like commandkit config file was updated, please restart the server manually to apply changes."
6142
+ )
6143
+ );
6144
+ return isConfig;
6145
+ }, "isConfigUpdate");
6146
+ const hmrHandler = /* @__PURE__ */ __name(async (path3) => {
6147
+ if (isConfigUpdate(path3)) return;
6148
+ const hmr = await performHMR(path3);
6002
6149
  if (hmr) return;
6003
6150
  console.log(
6004
- `${colors_default.yellowBright("\u26A1\uFE0F Performing full restart due to the changes in")} ${colors_default.cyanBright(path2)}`
6151
+ `${colors_default.yellowBright("\u26A1\uFE0F Performing full restart due to the changes in")} ${colors_default.cyanBright(path3)}`
6005
6152
  );
6006
6153
  ps == null ? void 0 : ps.kill();
6007
6154
  ps = await buildAndStart(cwd);
@@ -6013,19 +6160,19 @@ async function bootstrapDevelopmentServer(configPath) {
6013
6160
  console.log(`Received restart command, restarting...`);
6014
6161
  ps == null ? void 0 : ps.kill();
6015
6162
  ps = null;
6016
- await buildAndStart(cwd);
6163
+ ps = await buildAndStart(cwd);
6017
6164
  break;
6018
6165
  case "rc":
6019
6166
  console.log(`Received reload commands command, reloading...`);
6020
- ps == null ? void 0 : ps.send({ event: "reload-commands" });
6167
+ await sendHmrEvent(HMREventType.ReloadCommands);
6021
6168
  break;
6022
6169
  case "re":
6023
6170
  console.log(`Received reload events command, reloading...`);
6024
- ps == null ? void 0 : ps.send({ event: "reload-events" });
6171
+ await sendHmrEvent(HMREventType.ReloadEvents);
6025
6172
  break;
6026
6173
  case "rl":
6027
6174
  console.log(`Received reload locales command, reloading...`);
6028
- ps == null ? void 0 : ps.send({ event: "reload-locales" });
6175
+ await sendHmrEvent(HMREventType.ReloadLocales);
6029
6176
  break;
6030
6177
  }
6031
6178
  });
@@ -6049,7 +6196,7 @@ ${colors_default.yellowBright("re")} - Reload all events
6049
6196
  ${colors_default.yellowBright("rl")} - Reload all locales`
6050
6197
  );
6051
6198
  }
6052
- var import_path2, import_chokidar, isCommandSource, isEventSource, isLocaleSource;
6199
+ var import_path2, import_chokidar, import_promises7, import_node_crypto3, isCommandSource, isEventSource, isLocaleSource;
6053
6200
  var init_development = __esm({
6054
6201
  "src/cli/development.ts"() {
6055
6202
  "use strict";
@@ -6062,6 +6209,9 @@ var init_development = __esm({
6062
6209
  import_chokidar = require("chokidar");
6063
6210
  init_utilities();
6064
6211
  init_colors();
6212
+ import_promises7 = require("timers/promises");
6213
+ import_node_crypto3 = require("crypto");
6214
+ init_constants();
6065
6215
  __name(buildAndStart, "buildAndStart");
6066
6216
  isCommandSource = /* @__PURE__ */ __name((p) => p.replaceAll("\\", "/").includes("src/app/commands"), "isCommandSource");
6067
6217
  isEventSource = /* @__PURE__ */ __name((p) => p.replaceAll("\\", "/").includes("src/app/events"), "isEventSource");
@@ -6147,15 +6297,8 @@ __export(generators_exports, {
6147
6297
  function determineExtension() {
6148
6298
  return (0, import_fs2.existsSync)((0, import_path4.join)(BASE_PATH, "tsconfig.json")) ? "ts" : "js";
6149
6299
  }
6150
- async function generateCommand(name, customPath) {
6151
- const cmdPath = (0, import_path4.join)(customPath || COMMANDS_DIR);
6152
- if (!(0, import_fs2.existsSync)(cmdPath)) await (0, import_promises7.mkdir)(cmdPath, { recursive: true });
6153
- const fileName = `${name}.${determineExtension()}`;
6154
- if ((0, import_fs2.existsSync)((0, import_path4.join)(cmdPath, fileName))) {
6155
- panic(`Command ${name} already exists.`);
6156
- }
6157
- const commandFile = `
6158
- import type { CommandData, SlashCommand, MessageCommand } from 'commandkit';
6300
+ function TS_COMMAND_SOURCE(name) {
6301
+ return `import type { CommandData, SlashCommand, MessageCommand } from 'commandkit';
6159
6302
 
6160
6303
  export const command: CommandData = {
6161
6304
  name: '${name}',
@@ -6169,8 +6312,43 @@ export const chatInput: SlashCommand = async (ctx) => {
6169
6312
  export const message: MessageCommand = async (ctx) => {
6170
6313
  await ctx.message.reply('Hello from ${name}!');
6171
6314
  };
6172
- `.trim();
6173
- await (0, import_promises7.writeFile)((0, import_path4.join)(cmdPath, fileName), commandFile);
6315
+ `;
6316
+ }
6317
+ function JS_COMMAND_SOURCE(name) {
6318
+ return `/**
6319
+ * @type {import('commandkit').CommandData}
6320
+ */
6321
+ export const command = {
6322
+ name: '${name}',
6323
+ description: '${name} command',
6324
+ };
6325
+
6326
+ /**
6327
+ * @type {import('commandkit').SlashCommand}
6328
+ */
6329
+ export const chatInput = async (ctx) => {
6330
+ await ctx.interaction.reply('Hello from ${name}!');
6331
+ };
6332
+
6333
+ /**
6334
+ * @type {import('commandkit').MessageCommand}
6335
+ */
6336
+ export const message = async (ctx) => {
6337
+ await ctx.message.reply('Hello from ${name}!');
6338
+ };
6339
+ `;
6340
+ }
6341
+ async function generateCommand(name, customPath) {
6342
+ const cmdPath = (0, import_path4.join)(customPath || COMMANDS_DIR);
6343
+ if (!(0, import_fs2.existsSync)(cmdPath)) await (0, import_promises8.mkdir)(cmdPath, { recursive: true });
6344
+ const ext = determineExtension();
6345
+ const isTypeScript = ext === "ts";
6346
+ const fileName = `${name}.${ext}`;
6347
+ if ((0, import_fs2.existsSync)((0, import_path4.join)(cmdPath, fileName))) {
6348
+ panic(`Command ${name} already exists.`);
6349
+ }
6350
+ const commandFile = isTypeScript ? TS_COMMAND_SOURCE(name) : JS_COMMAND_SOURCE(name);
6351
+ await (0, import_promises8.writeFile)((0, import_path4.join)(cmdPath, fileName), commandFile);
6174
6352
  console.log(
6175
6353
  colors_default.green(
6176
6354
  `Command ${colors_default.magenta(name)} created at ${colors_default.blue(formatPath(`${cmdPath}/${fileName}`))}`
@@ -6179,10 +6357,11 @@ export const message: MessageCommand = async (ctx) => {
6179
6357
  }
6180
6358
  async function generateEvent(name, customPath) {
6181
6359
  const eventPath = (0, import_path4.join)(customPath || EVENTS_DIR, name);
6182
- if (!(0, import_fs2.existsSync)(eventPath)) await (0, import_promises7.mkdir)(eventPath, { recursive: true });
6183
- let filename = "event.ts";
6360
+ if (!(0, import_fs2.existsSync)(eventPath)) await (0, import_promises8.mkdir)(eventPath, { recursive: true });
6361
+ const ext = determineExtension();
6362
+ let filename = `event.${ext}`;
6184
6363
  if ((0, import_fs2.existsSync)((0, import_path4.join)(eventPath, filename))) {
6185
- const count = (await (0, import_promises7.readdir)(eventPath)).length;
6364
+ const count = (await (0, import_promises8.readdir)(eventPath)).length;
6186
6365
  filename = `${String(count).padStart(2, "0")}_${filename}`;
6187
6366
  }
6188
6367
  const eventFile = `
@@ -6190,7 +6369,7 @@ export default async function on${name[0].toUpperCase() + name.slice(1)}() {
6190
6369
  console.log('${name} event fired!');
6191
6370
  };
6192
6371
  `.trim();
6193
- await (0, import_promises7.writeFile)((0, import_path4.join)(eventPath, filename), eventFile);
6372
+ await (0, import_promises8.writeFile)((0, import_path4.join)(eventPath, filename), eventFile);
6194
6373
  console.log(
6195
6374
  colors_default.green(
6196
6375
  `Event ${colors_default.magenta(name)} created at ${colors_default.blue(formatPath(eventPath))}/${colors_default.magenta(filename)}`
@@ -6208,7 +6387,7 @@ async function generateLocale(locale, commandName, customPath) {
6208
6387
  panic("Command name is required.");
6209
6388
  }
6210
6389
  const localePath = (0, import_path4.join)(customPath || LOCALES_DIR, locale);
6211
- if (!(0, import_fs2.existsSync)(localePath)) await (0, import_promises7.mkdir)(localePath, { recursive: true });
6390
+ if (!(0, import_fs2.existsSync)(localePath)) await (0, import_promises8.mkdir)(localePath, { recursive: true });
6212
6391
  if ((0, import_fs2.existsSync)((0, import_path4.join)(localePath, `${commandName}.json`))) {
6213
6392
  panic(`Locale file for ${commandName} already exists.`);
6214
6393
  }
@@ -6219,7 +6398,7 @@ async function generateLocale(locale, commandName, customPath) {
6219
6398
  },
6220
6399
  translations: {}
6221
6400
  };
6222
- await (0, import_promises7.writeFile)(
6401
+ await (0, import_promises8.writeFile)(
6223
6402
  (0, import_path4.join)(localePath, `${commandName}.json`),
6224
6403
  JSON.stringify(localeFile, null, 2)
6225
6404
  );
@@ -6231,12 +6410,12 @@ async function generateLocale(locale, commandName, customPath) {
6231
6410
  )
6232
6411
  );
6233
6412
  }
6234
- var import_promises7, import_path4, import_discord21, import_fs2, BASE_PATH, COMMANDS_DIR, EVENTS_DIR, LOCALES_DIR, formatPath;
6413
+ var import_promises8, import_path4, import_discord21, import_fs2, BASE_PATH, COMMANDS_DIR, EVENTS_DIR, LOCALES_DIR, formatPath;
6235
6414
  var init_generators = __esm({
6236
6415
  "src/cli/generators.ts"() {
6237
6416
  "use strict";
6238
6417
  init_cjs_shims();
6239
- import_promises7 = require("fs/promises");
6418
+ import_promises8 = require("fs/promises");
6240
6419
  import_path4 = require("path");
6241
6420
  import_discord21 = require("discord.js");
6242
6421
  init_common2();
@@ -6246,14 +6425,169 @@ var init_generators = __esm({
6246
6425
  COMMANDS_DIR = (0, import_path4.join)(BASE_PATH, "src/app/commands");
6247
6426
  EVENTS_DIR = (0, import_path4.join)(BASE_PATH, "src/app/events");
6248
6427
  LOCALES_DIR = (0, import_path4.join)(BASE_PATH, "src/app/locales");
6249
- formatPath = /* @__PURE__ */ __name((path2) => path2.replace(process.cwd(), ".").replace(/\\/g, "/"), "formatPath");
6428
+ formatPath = /* @__PURE__ */ __name((path3) => path3.replace(process.cwd(), ".").replace(/\\/g, "/"), "formatPath");
6250
6429
  __name(determineExtension, "determineExtension");
6430
+ __name(TS_COMMAND_SOURCE, "TS_COMMAND_SOURCE");
6431
+ __name(JS_COMMAND_SOURCE, "JS_COMMAND_SOURCE");
6251
6432
  __name(generateCommand, "generateCommand");
6252
6433
  __name(generateEvent, "generateEvent");
6253
6434
  __name(generateLocale, "generateLocale");
6254
6435
  }
6255
6436
  });
6256
6437
 
6438
+ // src/cli/information.ts
6439
+ var information_exports = {};
6440
+ __export(information_exports, {
6441
+ showInformation: () => showInformation
6442
+ });
6443
+ function findPackageVersion(packageName) {
6444
+ try {
6445
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
6446
+ const packageJson = require(packageJsonPath);
6447
+ return packageJson.version;
6448
+ } catch (e) {
6449
+ try {
6450
+ const basePaths = [
6451
+ import_node_path11.default.join(process.cwd(), "node_modules", packageName),
6452
+ import_node_path11.default.join(process.cwd(), "..", "..", "node_modules", packageName),
6453
+ import_node_path11.default.join(process.cwd(), "..", "..", ".pnpm", packageName),
6454
+ import_node_path11.default.join(
6455
+ process.cwd(),
6456
+ "..",
6457
+ "..",
6458
+ "node_modules",
6459
+ ".pnpm",
6460
+ packageName
6461
+ )
6462
+ ];
6463
+ for (const basePath of basePaths) {
6464
+ const packageJsonPath = import_node_path11.default.join(basePath, "package.json");
6465
+ if (import_node_fs10.default.existsSync(packageJsonPath)) {
6466
+ const packageJson = JSON.parse(
6467
+ import_node_fs10.default.readFileSync(packageJsonPath, "utf8")
6468
+ );
6469
+ return packageJson.version;
6470
+ }
6471
+ }
6472
+ const nodeModulesPath = import_node_path11.default.join(
6473
+ process.cwd(),
6474
+ "..",
6475
+ "..",
6476
+ "node_modules",
6477
+ ".pnpm"
6478
+ );
6479
+ if (import_node_fs10.default.existsSync(nodeModulesPath)) {
6480
+ const folders = import_node_fs10.default.readdirSync(nodeModulesPath);
6481
+ const packageFolder = folders.find(
6482
+ (folder) => folder.startsWith(`${packageName.replace("/", "+")}@`)
6483
+ );
6484
+ if (packageFolder) {
6485
+ const packageJsonPath = import_node_path11.default.join(
6486
+ nodeModulesPath,
6487
+ packageFolder,
6488
+ "node_modules",
6489
+ packageName,
6490
+ "package.json"
6491
+ );
6492
+ if (import_node_fs10.default.existsSync(packageJsonPath)) {
6493
+ const packageJson = JSON.parse(
6494
+ import_node_fs10.default.readFileSync(packageJsonPath, "utf8")
6495
+ );
6496
+ return packageJson.version;
6497
+ }
6498
+ }
6499
+ }
6500
+ return null;
6501
+ } catch {
6502
+ return null;
6503
+ }
6504
+ }
6505
+ }
6506
+ function getBinaryVersion(binary) {
6507
+ try {
6508
+ const version2 = (0, import_node_child_process2.execSync)(`${binary} --version`).toString().trim();
6509
+ return version2;
6510
+ } catch {
6511
+ return null;
6512
+ }
6513
+ }
6514
+ async function showInformation() {
6515
+ const knownPlugins = [
6516
+ "@commandkit/redis",
6517
+ "@commandkit/legacy",
6518
+ "@commandkit/devtools"
6519
+ ];
6520
+ const runtimeName = (() => {
6521
+ if ("Deno" in globalThis && typeof Deno !== "undefined") return "Deno";
6522
+ if ("Bun" in globalThis && typeof Bun !== "undefined") return "Bun";
6523
+ return "Node.js";
6524
+ })();
6525
+ const info = {
6526
+ "Operating System": {
6527
+ Platform: process.platform,
6528
+ Arch: process.arch,
6529
+ Version: import_node_os.default.version(),
6530
+ "Available Memory (MB)": Math.round(import_node_os.default.totalmem() / 1024 / 1024),
6531
+ "Available CPU cores": import_node_os.default.cpus().length
6532
+ },
6533
+ Runtime: runtimeName,
6534
+ Binaries: {
6535
+ Node: process.version,
6536
+ npm: getBinaryVersion("npm") || "N/A",
6537
+ Yarn: getBinaryVersion("yarn") || "N/A",
6538
+ pnpm: getBinaryVersion("pnpm") || "N/A",
6539
+ Bun: getBinaryVersion("bun") || "N/A",
6540
+ Deno: getBinaryVersion("deno") || "N/A"
6541
+ },
6542
+ "Relevant Packages": {
6543
+ commandkit: version,
6544
+ "discord.js": findPackageVersion("discord.js") || "N/A",
6545
+ typescript: findPackageVersion("typescript") || "N/A",
6546
+ esbuild: findPackageVersion("esbuild") || "N/A",
6547
+ tsup: findPackageVersion("tsup") || "N/A",
6548
+ ...knownPlugins.reduce(
6549
+ (acc, plugin) => {
6550
+ acc[plugin] = findPackageVersion(plugin) || "N/A";
6551
+ return acc;
6552
+ },
6553
+ {}
6554
+ )
6555
+ }
6556
+ };
6557
+ let output = "";
6558
+ for (const [section, data] of Object.entries(info)) {
6559
+ output += `${section}:
6560
+ `;
6561
+ if (typeof data === "string") {
6562
+ output += ` ${data}
6563
+
6564
+ `;
6565
+ continue;
6566
+ }
6567
+ for (const [key, value] of Object.entries(data)) {
6568
+ output += ` ${key}: ${value}
6569
+ `;
6570
+ }
6571
+ output += "\n";
6572
+ }
6573
+ console.log(output.trim());
6574
+ }
6575
+ var import_node_os, import_node_child_process2, import_node_fs10, import_node_path11;
6576
+ var init_information = __esm({
6577
+ "src/cli/information.ts"() {
6578
+ "use strict";
6579
+ init_cjs_shims();
6580
+ import_node_os = __toESM(require("os"));
6581
+ import_node_child_process2 = require("child_process");
6582
+ init_version();
6583
+ import_node_fs10 = __toESM(require("fs"));
6584
+ import_node_path11 = __toESM(require("path"));
6585
+ __name(findPackageVersion, "findPackageVersion");
6586
+ __name(getBinaryVersion, "getBinaryVersion");
6587
+ __name(showInformation, "showInformation");
6588
+ }
6589
+ });
6590
+
6257
6591
  // src/index.ts
6258
6592
  var index_exports = {};
6259
6593
  __export(index_exports, {
@@ -6261,6 +6595,9 @@ __export(index_exports, {
6261
6595
  AppCommandHandler: () => AppCommandHandler,
6262
6596
  Button: () => Button,
6263
6597
  ButtonKit: () => ButtonKit,
6598
+ COMMANDKIT_CACHE_TAG: () => COMMANDKIT_CACHE_TAG,
6599
+ COMMANDKIT_IS_DEV: () => COMMANDKIT_IS_DEV,
6600
+ COMMANDKIT_IS_TEST: () => COMMANDKIT_IS_TEST,
6264
6601
  CacheProvider: () => CacheProvider,
6265
6602
  ChannelSelectMenu: () => ChannelSelectMenu,
6266
6603
  ChannelSelectMenuKit: () => ChannelSelectMenuKit,
@@ -6279,6 +6616,7 @@ __export(index_exports, {
6279
6616
  EventInterceptor: () => EventInterceptor,
6280
6617
  EventsRouter: () => EventsRouter,
6281
6618
  Fragment: () => Fragment,
6619
+ HMREventType: () => HMREventType,
6282
6620
  Localization: () => Localization,
6283
6621
  Logger: () => Logger,
6284
6622
  MemoryCache: () => MemoryCache,
@@ -6319,6 +6657,7 @@ __export(index_exports, {
6319
6657
  getContext: () => getContext,
6320
6658
  getCurrentDirectory: () => getCurrentDirectory,
6321
6659
  getElement: () => getElement,
6660
+ getSourceDirectories: () => getSourceDirectories,
6322
6661
  invalidate: () => invalidate,
6323
6662
  isCachedFunction: () => isCachedFunction,
6324
6663
  isCommandKitElement: () => isCommandKitElement,
@@ -6331,9 +6670,9 @@ __export(index_exports, {
6331
6670
  redirect: () => redirect,
6332
6671
  rethrow: () => rethrow,
6333
6672
  revalidate: () => revalidate,
6334
- super_duper_secret_internal_for_use_cache_directive_of_commandkit_cli_do_not_use_it_directly_or_you_will_be_fired_from_your_job_kthxbai: () => useCache,
6335
6673
  useEnvironment: () => useEnvironment,
6336
- version: () => version
6674
+ version: () => version,
6675
+ zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired: () => zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired
6337
6676
  });
6338
6677
  module.exports = __toCommonJS(index_exports);
6339
6678
  init_cjs_shims();
@@ -6386,12 +6725,13 @@ init_router();
6386
6725
  init_version();
6387
6726
  init_plugins();
6388
6727
  init_utilities();
6728
+ init_constants();
6389
6729
 
6390
6730
  // src/cli/init.ts
6391
6731
  init_cjs_shims();
6392
- var import_node_fs10 = require("fs");
6393
- var import_promises8 = require("fs/promises");
6394
- var import_node_path11 = require("path");
6732
+ var import_node_fs11 = require("fs");
6733
+ var import_promises9 = require("fs/promises");
6734
+ var import_node_path12 = require("path");
6395
6735
  async function bootstrapCommandkitCLI(argv, options) {
6396
6736
  process.title = "CommandKit CLI";
6397
6737
  const { Command } = await import("commander");
@@ -6399,6 +6739,7 @@ async function bootstrapCommandkitCLI(argv, options) {
6399
6739
  const { bootstrapProductionServer: bootstrapProductionServer2, createProductionBuild: createProductionBuild2 } = await Promise.resolve().then(() => (init_production(), production_exports));
6400
6740
  const { generateCommand: generateCommand2, generateEvent: generateEvent2, generateLocale: generateLocale2 } = await Promise.resolve().then(() => (init_generators(), generators_exports));
6401
6741
  const { version: version2 } = await Promise.resolve().then(() => (init_version(), version_exports));
6742
+ const { showInformation: showInformation2 } = await Promise.resolve().then(() => (init_information(), information_exports));
6402
6743
  const program = new Command("commandkit");
6403
6744
  program.command("dev").version(version2).description("Start your bot in development mode.").option(
6404
6745
  "-c, --config [path]",
@@ -6408,6 +6749,11 @@ async function bootstrapCommandkitCLI(argv, options) {
6408
6749
  const options2 = program.opts();
6409
6750
  bootstrapDevelopmentServer2(options2.config);
6410
6751
  });
6752
+ program.command("info").description(
6753
+ "Show information about the system which can be used to report bugs."
6754
+ ).action(async () => {
6755
+ await showInformation2();
6756
+ });
6411
6757
  program.command("start").description(
6412
6758
  "Start your bot in production mode after running the build command."
6413
6759
  ).option("-c, --config [path]", "Path to your commandkit.json file.").action(() => {
@@ -6439,9 +6785,9 @@ async function bootstrapCommandkitCLI(argv, options) {
6439
6785
  }
6440
6786
  });
6441
6787
  await program.parseAsync(argv, options);
6442
- const types = (0, import_node_path11.join)(process.cwd(), "node_modules", "commandkit-types");
6443
- if (!(0, import_node_fs10.existsSync)(types)) {
6444
- await (0, import_promises8.mkdir)(types, { recursive: true }).catch(() => {
6788
+ const types = (0, import_node_path12.join)(process.cwd(), "node_modules", "commandkit-types");
6789
+ if (!(0, import_node_fs11.existsSync)(types)) {
6790
+ await (0, import_promises9.mkdir)(types, { recursive: true }).catch(() => {
6445
6791
  });
6446
6792
  }
6447
6793
  }
@@ -6455,6 +6801,9 @@ var index_default = CommandKit;
6455
6801
  AppCommandHandler,
6456
6802
  Button,
6457
6803
  ButtonKit,
6804
+ COMMANDKIT_CACHE_TAG,
6805
+ COMMANDKIT_IS_DEV,
6806
+ COMMANDKIT_IS_TEST,
6458
6807
  CacheProvider,
6459
6808
  ChannelSelectMenu,
6460
6809
  ChannelSelectMenuKit,
@@ -6473,6 +6822,7 @@ var index_default = CommandKit;
6473
6822
  EventInterceptor,
6474
6823
  EventsRouter,
6475
6824
  Fragment,
6825
+ HMREventType,
6476
6826
  Localization,
6477
6827
  Logger,
6478
6828
  MemoryCache,
@@ -6512,6 +6862,7 @@ var index_default = CommandKit;
6512
6862
  getContext,
6513
6863
  getCurrentDirectory,
6514
6864
  getElement,
6865
+ getSourceDirectories,
6515
6866
  invalidate,
6516
6867
  isCachedFunction,
6517
6868
  isCommandKitElement,
@@ -6524,8 +6875,8 @@ var index_default = CommandKit;
6524
6875
  redirect,
6525
6876
  rethrow,
6526
6877
  revalidate,
6527
- super_duper_secret_internal_for_use_cache_directive_of_commandkit_cli_do_not_use_it_directly_or_you_will_be_fired_from_your_job_kthxbai,
6528
6878
  useEnvironment,
6529
- version
6879
+ version,
6880
+ zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired
6530
6881
  });
6531
6882
  //# sourceMappingURL=index.js.map