commandkit 1.0.0-dev.20250529020123 → 1.0.0-dev.20250530015910
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/ActionRow-CmTHbo2t.js +25 -0
- package/dist/ActionRow-CmTHbo2t.js.map +1 -0
- package/dist/ActionRow-D0wafJhZ.d.ts +16 -0
- package/dist/Button-Bl5nbwTS.d.ts +32 -0
- package/dist/ButtonKit-BSI7lCI0.d.ts +68 -0
- package/dist/ChannelSelectMenuKit-L15A2jpT.d.ts +51 -0
- package/dist/CommandKit-CDlCsGCx.d.ts +926 -0
- package/dist/CommandKit-DDrQtQns.js +3281 -0
- package/dist/CommandKit-DDrQtQns.js.map +1 -0
- package/dist/CommandKit.d.ts +33 -13
- package/dist/CommandKit.js +46 -16
- package/dist/CommandKitEventsChannel-B6LKgxmv.js +44 -0
- package/dist/CommandKitEventsChannel-B6LKgxmv.js.map +1 -0
- package/dist/CommandsRouter-BHaPno8o.js +127 -0
- package/dist/CommandsRouter-BHaPno8o.js.map +1 -0
- package/dist/CommandsRouter-C7X-eXE2.d.ts +67 -0
- package/dist/CompilerPlugin-XzuGixkC.js +32 -0
- package/dist/CompilerPlugin-XzuGixkC.js.map +1 -0
- package/dist/CompilerPluginRuntime-zFCCw1kM.js +70 -0
- package/dist/CompilerPluginRuntime-zFCCw1kM.js.map +1 -0
- package/dist/DefaultLogger-D3G0rGnV.d.ts +30 -0
- package/dist/EventInterceptor-D_oEWSnF.d.ts +84 -0
- package/dist/EventInterceptor-DtRINyTP.js +140 -0
- package/dist/EventInterceptor-DtRINyTP.js.map +1 -0
- package/dist/EventWorkerContext-C0e23GNY.d.ts +19 -0
- package/dist/EventWorkerContext-XZGSHn5F.js +45 -0
- package/dist/EventWorkerContext-XZGSHn5F.js.map +1 -0
- package/dist/EventsRouter-BacqK6z3.d.ts +90 -0
- package/dist/EventsRouter-CqnrlbjN.js +133 -0
- package/dist/EventsRouter-CqnrlbjN.js.map +1 -0
- package/dist/ILogger-BTMQuall.d.ts +11 -0
- package/dist/ILogger-DucYb0bG.js +0 -0
- package/dist/Logger-A3wjB7L1.d.ts +17 -0
- package/dist/MentionableSelectMenuKit-BiUSKUtZ.d.ts +51 -0
- package/dist/MessageCommandParser-B13Pkwo9.js +200 -0
- package/dist/MessageCommandParser-B13Pkwo9.js.map +1 -0
- package/dist/MessageCommandParser-tzroBwij.d.ts +62 -0
- package/dist/Modal-Cxm6cs5c.d.ts +58 -0
- package/dist/ModalKit-CKtQ8eXW.d.ts +66 -0
- package/dist/PluginCommon-DPqnQngK.js +48 -0
- package/dist/PluginCommon-DPqnQngK.js.map +1 -0
- package/dist/RoleSelectMenuKit-BSMKkru2.d.ts +51 -0
- package/dist/RuntimePlugin-CKsd83M3.js +130 -0
- package/dist/RuntimePlugin-CKsd83M3.js.map +1 -0
- package/dist/SelectMenu-b7jgrkjO.d.ts +36 -0
- package/dist/StringSelectMenuKit-B9FHTe48.d.ts +51 -0
- package/dist/UserSelectMenuKit-DiP0imyo.d.ts +51 -0
- package/dist/app/commands/AppCommandRunner.d.ts +33 -13
- package/dist/app/commands/AppCommandRunner.js +38 -3
- package/dist/app/commands/Context.d.ts +33 -13
- package/dist/app/commands/Context.js +40 -3
- package/dist/app/commands/MessageCommandParser.d.ts +2 -60
- package/dist/app/commands/MessageCommandParser.js +5 -2
- package/dist/app/commands/helpers.d.ts +2 -7
- package/dist/app/commands/helpers.js +4 -2
- package/dist/app/events/EventWorkerContext.d.ts +34 -28
- package/dist/app/events/EventWorkerContext.js +6 -2
- package/dist/app/handlers/AppCommandHandler.d.ts +33 -13
- package/dist/app/handlers/AppCommandHandler.js +38 -8
- package/dist/app/handlers/AppEventsHandler.d.ts +33 -13
- package/dist/app/handlers/AppEventsHandler.js +38 -3
- package/dist/app/index.d.ts +33 -15
- package/dist/app/index.js +51 -8
- package/dist/app/middleware/signals.d.ts +2 -18
- package/dist/app/middleware/signals.js +6 -2
- package/dist/app/register/CommandRegistrar.d.ts +33 -13
- package/dist/app/register/CommandRegistrar.js +38 -3
- package/dist/app/router/CommandsRouter.d.ts +2 -65
- package/dist/app/router/CommandsRouter.js +3 -2
- package/dist/app/router/EventsRouter.d.ts +2 -88
- package/dist/app/router/EventsRouter.js +3 -2
- package/dist/app/router/index.d.ts +4 -3
- package/dist/app/router/index.js +6 -2
- package/dist/app-CXCbKsPz.js +0 -0
- package/dist/app-process-uCX52YaE.js +48 -0
- package/dist/app-process-uCX52YaE.js.map +1 -0
- package/dist/build-Bkb5t3XA.js +122 -0
- package/dist/build-Bkb5t3XA.js.map +1 -0
- package/dist/chunk-nOFOJqeH.js +30 -0
- package/dist/cli/app-process.d.ts +5 -3
- package/dist/cli/app-process.js +8 -3
- package/dist/cli/build.d.ts +46 -21
- package/dist/cli/build.js +40 -48
- package/dist/cli/common.d.ts +39 -19
- package/dist/cli/common.js +13 -10
- package/dist/cli/development.d.ts +3 -1
- package/dist/cli/development.js +185 -50
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.d.ts +7 -5
- package/dist/cli/env.js +9 -2
- package/dist/cli/generators.d.ts +3 -1
- package/dist/cli/generators.js +64 -15
- package/dist/cli/generators.js.map +1 -1
- package/dist/cli/information.d.ts +3 -1
- package/dist/cli/information.js +110 -5
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.d.ts +2 -10
- package/dist/cli/init.js +4 -99
- package/dist/cli/parse-env.d.ts +3 -1
- package/dist/cli/parse-env.js +53 -1
- package/dist/cli/parse-env.js.map +1 -1
- package/dist/cli/production.d.ts +5 -3
- package/dist/cli/production.js +68 -46
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.d.ts +3 -1
- package/dist/cli/type-checker.js +7 -5
- package/dist/cli/utils.d.ts +4 -2
- package/dist/cli/utils.js +3 -2
- package/dist/colors-Cd4Oz-r-.js +14 -0
- package/dist/colors-Cd4Oz-r-.js.map +1 -0
- package/dist/common-CcfjYnPG.js +0 -0
- package/dist/common-CeO-vn8Y.js +14 -0
- package/dist/common-CeO-vn8Y.js.map +1 -0
- package/dist/common-DirpDCa6.js +182 -0
- package/dist/common-DirpDCa6.js.map +1 -0
- package/dist/common-pvPJVTfe.d.ts +25 -0
- package/dist/components/common/EventInterceptor.d.ts +2 -82
- package/dist/components/common/EventInterceptor.js +3 -2
- package/dist/components/common/element.d.ts +5 -29
- package/dist/components/common/element.js +10 -2
- package/dist/components/common/types.d.ts +2 -3
- package/dist/components/common/types.js +1 -2
- package/dist/components/index.d.ts +24 -22
- package/dist/components/index.js +72 -16
- package/dist/components/v1/action-row/ActionRow.d.ts +6 -18
- package/dist/components/v1/action-row/ActionRow.js +3 -2
- package/dist/components/v1/button/Button.d.ts +7 -31
- package/dist/components/v1/button/Button.js +38 -16
- package/dist/components/v1/button/ButtonKit.d.ts +3 -66
- package/dist/components/v1/button/ButtonKit.js +38 -16
- package/dist/components/v1/modal/Modal.d.ts +7 -57
- package/dist/components/v1/modal/Modal.js +41 -16
- package/dist/components/v1/modal/ModalKit.d.ts +3 -64
- package/dist/components/v1/modal/ModalKit.js +38 -16
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.d.ts +4 -49
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +38 -16
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.d.ts +4 -49
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +38 -16
- package/dist/components/v1/select-menu/RoleSelectMenuKit.d.ts +4 -49
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js +38 -16
- package/dist/components/v1/select-menu/SelectMenu.d.ts +10 -40
- package/dist/components/v1/select-menu/SelectMenu.js +43 -16
- package/dist/components/v1/select-menu/StringSelectMenuKit.d.ts +4 -49
- package/dist/components/v1/select-menu/StringSelectMenuKit.js +38 -16
- package/dist/components/v1/select-menu/UserSelectMenuKit.d.ts +4 -49
- package/dist/components/v1/select-menu/UserSelectMenuKit.js +38 -16
- package/dist/components/v1/select-menu/common.d.ts +3 -23
- package/dist/components/v1/select-menu/common.js +1 -2
- package/dist/components/v2/common.d.ts +5 -3
- package/dist/components/v2/common.js +3 -2
- package/dist/components/v2/container.d.ts +2 -8
- package/dist/components/v2/container.js +4 -2
- package/dist/components/v2/file.d.ts +2 -8
- package/dist/components/v2/file.js +3 -2
- package/dist/components/v2/index.d.ts +8 -7
- package/dist/components/v2/index.js +17 -2
- package/dist/components/v2/media-gallery.d.ts +2 -15
- package/dist/components/v2/media-gallery.js +5 -2
- package/dist/components/v2/section.d.ts +2 -16
- package/dist/components/v2/section.js +5 -2
- package/dist/components/v2/separator.d.ts +2 -7
- package/dist/components/v2/separator.js +3 -2
- package/dist/components/v2/text-display.d.ts +2 -10
- package/dist/components/v2/text-display.js +3 -2
- package/dist/config/config.d.ts +36 -28
- package/dist/config/config.js +39 -3
- package/dist/config/default.d.ts +37 -17
- package/dist/config/default.js +38 -3
- package/dist/config/loader.d.ts +37 -17
- package/dist/config/loader.js +39 -11
- package/dist/config/types.d.ts +34 -83
- package/dist/config/types.js +0 -2
- package/dist/config/utils.d.ts +35 -26
- package/dist/config/utils.js +15 -1
- package/dist/config/utils.js.map +1 -1
- package/dist/config-Dyb-zl9w.d.ts +17 -0
- package/dist/constants-Ce6w4OFe.d.ts +17 -0
- package/dist/constants-DOPSzXI0.js +47 -0
- package/dist/constants-DOPSzXI0.js.map +1 -0
- package/dist/container-CpuiLsZM.js +33 -0
- package/dist/container-CpuiLsZM.js.map +1 -0
- package/dist/container-CwEATQy2.d.ts +10 -0
- package/dist/context/async-context.d.ts +33 -13
- package/dist/context/async-context.js +44 -16
- package/dist/context/environment.d.ts +33 -13
- package/dist/context/environment.js +41 -3
- package/dist/element-D_nyVwgB.d.ts +30 -0
- package/dist/element-hdSqnIpC.js +62 -0
- package/dist/element-hdSqnIpC.js.map +1 -0
- package/dist/env-DKFSgEcR.js +68 -0
- package/dist/env-DKFSgEcR.js.map +1 -0
- package/dist/error-codes-C_UO39jz.js +53 -0
- package/dist/error-codes-C_UO39jz.js.map +1 -0
- package/dist/events/CommandKitEventsChannel.d.ts +33 -13
- package/dist/events/CommandKitEventsChannel.js +3 -2
- package/dist/feature-flags-BJp6kYmi.js +85 -0
- package/dist/feature-flags-BJp6kYmi.js.map +1 -0
- package/dist/file-BdyYwkaI.d.ts +10 -0
- package/dist/file-DE69SSOP.js +18 -0
- package/dist/file-DE69SSOP.js.map +1 -0
- package/dist/flags/feature-flags.d.ts +33 -13
- package/dist/flags/feature-flags.js +40 -16
- package/dist/flags/store.d.ts +33 -13
- package/dist/flags/store.js +3 -2
- package/dist/helpers-CswC9gKF.js +25 -0
- package/dist/helpers-CswC9gKF.js.map +1 -0
- package/dist/helpers-DAmE106r.d.ts +9 -0
- package/dist/index-CUPkUUOR.d.ts +1 -0
- package/dist/index-Dw5cCt-A.d.ts +1 -0
- package/dist/index-E7Wvm5uX.d.ts +1 -0
- package/dist/index.d.ts +43 -51
- package/dist/index.js +147 -102
- package/dist/index.js.map +1 -1
- package/dist/init--p1nl1NO.d.ts +13 -0
- package/dist/init-D2me-V0n.js +67 -0
- package/dist/init-D2me-V0n.js.map +1 -0
- package/dist/logger/DefaultLogger.d.ts +3 -28
- package/dist/logger/DefaultLogger.js +38 -3
- package/dist/logger/ILogger.d.ts +2 -9
- package/dist/logger/ILogger.js +1 -2
- package/dist/logger/Logger.d.ts +3 -15
- package/dist/logger/Logger.js +39 -3
- package/dist/media-gallery-DCu02VXc.d.ts +17 -0
- package/dist/media-gallery-nUEHqKVF.js +36 -0
- package/dist/media-gallery-nUEHqKVF.js.map +1 -0
- package/dist/plugins/CompilerPlugin.d.ts +33 -13
- package/dist/plugins/CompilerPlugin.js +5 -2
- package/dist/plugins/PluginCommon.d.ts +33 -13
- package/dist/plugins/PluginCommon.js +5 -2
- package/dist/plugins/RuntimePlugin.d.ts +33 -13
- package/dist/plugins/RuntimePlugin.js +5 -2
- package/dist/plugins/index.d.ts +33 -15
- package/dist/plugins/index.js +44 -3
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +33 -13
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +38 -3
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +33 -13
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +3 -3
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +33 -26
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +38 -3
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +40 -19
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +38 -3
- package/dist/plugins/plugin-runtime/runtime.d.ts +33 -13
- package/dist/plugins/plugin-runtime/runtime.js +1 -2
- package/dist/plugins/plugin-runtime/types.d.ts +2 -72
- package/dist/plugins/plugin-runtime/types.js +1 -2
- package/dist/plugins/types.d.ts +33 -13
- package/dist/plugins/types.js +1 -2
- package/dist/resolve-file-url-pO9_rLft.js +23 -0
- package/dist/resolve-file-url-pO9_rLft.js.map +1 -0
- package/dist/router-Dn35v30f.js +0 -0
- package/dist/runtime-ByJtSXs_.js +0 -0
- package/dist/section-D6t7tyEZ.js +40 -0
- package/dist/section-D6t7tyEZ.js.map +1 -0
- package/dist/section-fktaECHL.d.ts +18 -0
- package/dist/separator-CuesaLrC.d.ts +8 -0
- package/dist/separator-DYAFK-Jj.js +17 -0
- package/dist/separator-DYAFK-Jj.js.map +1 -0
- package/dist/signals-Bp0bzjE6.js +46 -0
- package/dist/signals-Bp0bzjE6.js.map +1 -0
- package/dist/signals-DUoWkeZ7.d.ts +20 -0
- package/dist/store-Ci6ib2C9.js +14 -0
- package/dist/store-Ci6ib2C9.js.map +1 -0
- package/dist/text-display-DNMwmGHJ.d.ts +12 -0
- package/dist/text-display-Dy6JHB5X.js +19 -0
- package/dist/text-display-Dy6JHB5X.js.map +1 -0
- package/dist/type-checker-FOYNSGX0.js +84 -0
- package/dist/type-checker-FOYNSGX0.js.map +1 -0
- package/dist/types-0ADL_reY.d.ts +73 -0
- package/dist/types-B5VPP9ig.js +0 -0
- package/dist/types-BDwNROY2.d.ts +74 -0
- package/dist/types-Bq0EWaM3.js +0 -0
- package/dist/types-CJ-XvOFN.d.ts +5 -0
- package/dist/types-Cdh4uaFR.js +0 -0
- package/dist/types-package-DRhFn59I.js +66 -0
- package/dist/types-package-DRhFn59I.js.map +1 -0
- package/dist/types.d.ts +33 -13
- package/dist/types.js +0 -2
- package/dist/utilities-5Jw5BdE1.d.ts +42 -0
- package/dist/utils/clone.d.ts +3 -1
- package/dist/utils/clone.js +8 -1
- package/dist/utils/clone.js.map +1 -1
- package/dist/utils/colors.d.ts +5 -3
- package/dist/utils/colors.js +4 -2
- package/dist/utils/constants.d.ts +2 -15
- package/dist/utils/constants.js +7 -2
- package/dist/utils/dev-hooks.d.ts +33 -13
- package/dist/utils/dev-hooks.js +38 -3
- package/dist/utils/error-codes.d.ts +9 -7
- package/dist/utils/error-codes.js +6 -2
- package/dist/utils/get-paths.d.ts +3 -1
- package/dist/utils/get-paths.js +33 -1
- package/dist/utils/get-paths.js.map +1 -1
- package/dist/utils/resolve-file-url.d.ts +3 -1
- package/dist/utils/resolve-file-url.js +3 -2
- package/dist/utils/types-package.d.ts +3 -1
- package/dist/utils/types-package.js +5 -14
- package/dist/utils/utilities.d.ts +2 -40
- package/dist/utils/utilities.js +44 -3
- package/dist/utils/warn-unstable.d.ts +3 -1
- package/dist/utils/warn-unstable.js +4 -2
- package/dist/utils-C0V7zD7R.d.ts +10 -0
- package/dist/utils-IYtoeTur.js +19 -0
- package/dist/utils-IYtoeTur.js.map +1 -0
- package/dist/v2-DofkPKHs.js +0 -0
- package/dist/version-DnRxh8U8.js +15 -0
- package/dist/version-DnRxh8U8.js.map +1 -0
- package/dist/version-SMsmj3M1.d.ts +8 -0
- package/dist/version.d.ts +2 -6
- package/dist/version.js +3 -2
- package/dist/warn-unstable-V20WCBDd.js +26 -0
- package/dist/warn-unstable-V20WCBDd.js.map +1 -0
- package/package.json +5 -4
- package/dist/CommandKit-jZCy9fZX.d.ts +0 -914
- package/dist/CommandKit.js.map +0 -1
- package/dist/app/commands/AppCommandRunner.js.map +0 -1
- package/dist/app/commands/Context.js.map +0 -1
- package/dist/app/commands/MessageCommandParser.js.map +0 -1
- package/dist/app/commands/helpers.js.map +0 -1
- package/dist/app/events/EventWorkerContext.js.map +0 -1
- package/dist/app/handlers/AppCommandHandler.js.map +0 -1
- package/dist/app/handlers/AppEventsHandler.js.map +0 -1
- package/dist/app/index.js.map +0 -1
- package/dist/app/middleware/signals.js.map +0 -1
- package/dist/app/register/CommandRegistrar.js.map +0 -1
- package/dist/app/router/CommandsRouter.js.map +0 -1
- package/dist/app/router/EventsRouter.js.map +0 -1
- package/dist/app/router/index.js.map +0 -1
- package/dist/cli/app-process.js.map +0 -1
- package/dist/cli/build.js.map +0 -1
- package/dist/cli/common.js.map +0 -1
- package/dist/cli/env.js.map +0 -1
- package/dist/cli/init.js.map +0 -1
- package/dist/cli/type-checker.js.map +0 -1
- package/dist/cli/utils.js.map +0 -1
- package/dist/components/common/EventInterceptor.js.map +0 -1
- package/dist/components/common/element.js.map +0 -1
- package/dist/components/common/types.js.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/v1/action-row/ActionRow.js.map +0 -1
- package/dist/components/v1/button/Button.js.map +0 -1
- package/dist/components/v1/button/ButtonKit.js.map +0 -1
- package/dist/components/v1/modal/Modal.js.map +0 -1
- package/dist/components/v1/modal/ModalKit.js.map +0 -1
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js.map +0 -1
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js.map +0 -1
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js.map +0 -1
- package/dist/components/v1/select-menu/SelectMenu.js.map +0 -1
- package/dist/components/v1/select-menu/StringSelectMenuKit.js.map +0 -1
- package/dist/components/v1/select-menu/UserSelectMenuKit.js.map +0 -1
- package/dist/components/v1/select-menu/common.js.map +0 -1
- package/dist/components/v2/common.js.map +0 -1
- package/dist/components/v2/container.js.map +0 -1
- package/dist/components/v2/file.js.map +0 -1
- package/dist/components/v2/index.js.map +0 -1
- package/dist/components/v2/media-gallery.js.map +0 -1
- package/dist/components/v2/section.js.map +0 -1
- package/dist/components/v2/separator.js.map +0 -1
- package/dist/components/v2/text-display.js.map +0 -1
- package/dist/config/config.js.map +0 -1
- package/dist/config/default.js.map +0 -1
- package/dist/config/loader.js.map +0 -1
- package/dist/config/types.js.map +0 -1
- package/dist/context/async-context.js.map +0 -1
- package/dist/context/environment.js.map +0 -1
- package/dist/events/CommandKitEventsChannel.js.map +0 -1
- package/dist/flags/feature-flags.js.map +0 -1
- package/dist/flags/store.js.map +0 -1
- package/dist/logger/DefaultLogger.js.map +0 -1
- package/dist/logger/ILogger.js.map +0 -1
- package/dist/logger/Logger.js.map +0 -1
- package/dist/plugins/CompilerPlugin.js.map +0 -1
- package/dist/plugins/PluginCommon.js.map +0 -1
- package/dist/plugins/RuntimePlugin.js.map +0 -1
- package/dist/plugins/index.js.map +0 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js.map +0 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js.map +0 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js.map +0 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js.map +0 -1
- package/dist/plugins/plugin-runtime/runtime.js.map +0 -1
- package/dist/plugins/plugin-runtime/types.js.map +0 -1
- package/dist/plugins/types.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/constants.js.map +0 -1
- package/dist/utils/dev-hooks.js.map +0 -1
- package/dist/utils/error-codes.js.map +0 -1
- package/dist/utils/resolve-file-url.js.map +0 -1
- package/dist/utils/types-package.js.map +0 -1
- package/dist/utils/utilities.js.map +0 -1
- package/dist/utils/warn-unstable.js.map +0 -1
- package/dist/version.js.map +0 -1
package/dist/cli/env.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
//#region src/cli/env.d.ts
|
|
1
2
|
declare function DevEnv(_static?: boolean): {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
NODE_ENV: string;
|
|
4
|
+
COMMANDKIT_IS_DEV: string;
|
|
4
5
|
};
|
|
5
6
|
declare function ProdEnv(_static?: boolean): {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
NODE_ENV: string;
|
|
8
|
+
COMMANDKIT_IS_DEV: string;
|
|
8
9
|
};
|
|
9
10
|
declare const CommonEnvFiles: string[];
|
|
10
11
|
declare const DevEnvFiles: string[];
|
|
11
12
|
declare const ProdEnvFiles: string[];
|
|
12
13
|
declare const devEnvFileArgs: string[];
|
|
13
14
|
declare const prodEnvFileArgs: string[];
|
|
14
|
-
|
|
15
|
+
//#endregion
|
|
15
16
|
export { CommonEnvFiles, DevEnv, DevEnvFiles, ProdEnv, ProdEnvFiles, devEnvFileArgs, prodEnvFileArgs };
|
|
17
|
+
//# sourceMappingURL=env.d.ts.map
|
package/dist/cli/env.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const require_env = require('../env-DKFSgEcR.js');
|
|
2
|
+
|
|
3
|
+
exports.CommonEnvFiles = require_env.CommonEnvFiles;
|
|
4
|
+
exports.DevEnv = require_env.DevEnv;
|
|
5
|
+
exports.DevEnvFiles = require_env.DevEnvFiles;
|
|
6
|
+
exports.ProdEnv = require_env.ProdEnv;
|
|
7
|
+
exports.ProdEnvFiles = require_env.ProdEnvFiles;
|
|
8
|
+
exports.devEnvFileArgs = require_env.devEnvFileArgs;
|
|
9
|
+
exports.prodEnvFileArgs = require_env.prodEnvFileArgs;
|
package/dist/cli/generators.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
//#region src/cli/generators.d.ts
|
|
1
2
|
declare function generateCommand(name: string, customPath?: string): Promise<void>;
|
|
2
3
|
declare function generateEvent(name: string, customPath?: string): Promise<void>;
|
|
3
|
-
|
|
4
|
+
//#endregion
|
|
4
5
|
export { generateCommand, generateEvent };
|
|
6
|
+
//# sourceMappingURL=generators.d.ts.map
|
package/dist/cli/generators.js
CHANGED
|
@@ -1,42 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const require_chunk = require('../chunk-nOFOJqeH.js');
|
|
2
|
+
const require_colors = require('../colors-Cd4Oz-r-.js');
|
|
3
|
+
require('../constants-DOPSzXI0.js');
|
|
4
|
+
require('../types-package-DRhFn59I.js');
|
|
5
|
+
const require_common = require('../common-DirpDCa6.js');
|
|
6
|
+
const path = require_chunk.__toESM(require("path"));
|
|
7
|
+
const fs_promises = require_chunk.__toESM(require("fs/promises"));
|
|
8
|
+
const fs = require_chunk.__toESM(require("fs"));
|
|
9
|
+
|
|
10
|
+
//#region src/cli/generators.ts
|
|
11
|
+
const BASE_PATH = process.cwd();
|
|
12
|
+
const COMMANDS_DIR = (0, path.join)(BASE_PATH, "src/app/commands");
|
|
13
|
+
const EVENTS_DIR = (0, path.join)(BASE_PATH, "src/app/events");
|
|
14
|
+
const formatPath = (path$1) => path$1.replace(process.cwd(), ".").replace(/\\/g, "/");
|
|
15
|
+
function determineExtension() {
|
|
16
|
+
return (0, fs.existsSync)((0, path.join)(BASE_PATH, "tsconfig.json")) ? "ts" : "js";
|
|
17
|
+
}
|
|
18
|
+
function TS_COMMAND_SOURCE(name) {
|
|
19
|
+
return `import type { CommandData, ChatInputCommand, MessageCommand } from 'commandkit';
|
|
3
20
|
|
|
4
21
|
export const command: CommandData = {
|
|
5
|
-
name: '${
|
|
6
|
-
description: '${
|
|
22
|
+
name: '${name}',
|
|
23
|
+
description: '${name} command',
|
|
7
24
|
};
|
|
8
25
|
|
|
9
26
|
export const chatInput: ChatInputCommand = async (ctx) => {
|
|
10
|
-
await ctx.interaction.reply('Hello from ${
|
|
27
|
+
await ctx.interaction.reply('Hello from ${name}!');
|
|
11
28
|
};
|
|
12
29
|
|
|
13
30
|
export const message: MessageCommand = async (ctx) => {
|
|
14
|
-
await ctx.message.reply('Hello from ${
|
|
31
|
+
await ctx.message.reply('Hello from ${name}!');
|
|
15
32
|
};
|
|
16
|
-
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
function JS_COMMAND_SOURCE(name) {
|
|
36
|
+
return `/**
|
|
17
37
|
* @type {import('commandkit').CommandData}
|
|
18
38
|
*/
|
|
19
39
|
export const command = {
|
|
20
|
-
name: '${
|
|
21
|
-
description: '${
|
|
40
|
+
name: '${name}',
|
|
41
|
+
description: '${name} command',
|
|
22
42
|
};
|
|
23
43
|
|
|
24
44
|
/**
|
|
25
45
|
* @type {import('commandkit').ChatInputCommand}
|
|
26
46
|
*/
|
|
27
47
|
export const chatInput = async (ctx) => {
|
|
28
|
-
await ctx.interaction.reply('Hello from ${
|
|
48
|
+
await ctx.interaction.reply('Hello from ${name}!');
|
|
29
49
|
};
|
|
30
50
|
|
|
31
51
|
/**
|
|
32
52
|
* @type {import('commandkit').MessageCommand}
|
|
33
53
|
*/
|
|
34
54
|
export const message = async (ctx) => {
|
|
35
|
-
await ctx.message.reply('Hello from ${
|
|
55
|
+
await ctx.message.reply('Hello from ${name}!');
|
|
36
56
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
async function generateCommand(name, customPath) {
|
|
60
|
+
const cmdPath = (0, path.join)(customPath || COMMANDS_DIR);
|
|
61
|
+
if (!(0, fs.existsSync)(cmdPath)) await (0, fs_promises.mkdir)(cmdPath, { recursive: true });
|
|
62
|
+
const ext = determineExtension();
|
|
63
|
+
const isTypeScript = ext === "ts";
|
|
64
|
+
const fileName = `${name}.${ext}`;
|
|
65
|
+
if ((0, fs.existsSync)((0, path.join)(cmdPath, fileName))) require_common.panic(`Command ${name} already exists.`);
|
|
66
|
+
const commandFile = isTypeScript ? TS_COMMAND_SOURCE(name) : JS_COMMAND_SOURCE(name);
|
|
67
|
+
await (0, fs_promises.writeFile)((0, path.join)(cmdPath, fileName), commandFile);
|
|
68
|
+
console.log(require_colors.colors_default.green(`Command ${require_colors.colors_default.magenta(name)} created at ${require_colors.colors_default.blue(formatPath(`${cmdPath}/${fileName}`))}`));
|
|
69
|
+
}
|
|
70
|
+
async function generateEvent(name, customPath) {
|
|
71
|
+
const eventPath = (0, path.join)(customPath || EVENTS_DIR, name);
|
|
72
|
+
if (!(0, fs.existsSync)(eventPath)) await (0, fs_promises.mkdir)(eventPath, { recursive: true });
|
|
73
|
+
const ext = determineExtension();
|
|
74
|
+
let filename = `event.${ext}`;
|
|
75
|
+
if ((0, fs.existsSync)((0, path.join)(eventPath, filename))) {
|
|
76
|
+
const count = (await (0, fs_promises.readdir)(eventPath)).length;
|
|
77
|
+
filename = `${String(count).padStart(2, "0")}_${filename}`;
|
|
78
|
+
}
|
|
79
|
+
const eventFile = `
|
|
80
|
+
export default async function on${name[0].toUpperCase() + name.slice(1)}() {
|
|
81
|
+
console.log('${name} event fired!');
|
|
40
82
|
};
|
|
41
|
-
`.trim();
|
|
83
|
+
`.trim();
|
|
84
|
+
await (0, fs_promises.writeFile)((0, path.join)(eventPath, filename), eventFile);
|
|
85
|
+
console.log(require_colors.colors_default.green(`Event ${require_colors.colors_default.magenta(name)} created at ${require_colors.colors_default.blue(formatPath(eventPath))}/${require_colors.colors_default.magenta(filename)}`));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
exports.generateCommand = generateCommand;
|
|
90
|
+
exports.generateEvent = generateEvent;
|
|
42
91
|
//# sourceMappingURL=generators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/generators.ts","../../src/cli/common.ts","../../src/utils/colors.ts","../../src/utils/types-package.ts","../../src/utils/constants.ts"],"sourcesContent":["import { mkdir, writeFile, readdir } from 'fs/promises';\nimport { join } from 'path';\nimport { panic } from './common';\nimport { existsSync } from 'fs';\nimport colors from '../utils/colors';\n\nconst BASE_PATH = process.cwd();\nconst COMMANDS_DIR = join(BASE_PATH, 'src/app/commands');\nconst EVENTS_DIR = join(BASE_PATH, 'src/app/events');\n\nconst formatPath = (path: string) =>\npath.replace(process.cwd(), '.').replace(/\\\\/g, '/');\n\nfunction determineExtension() {\n return existsSync(join(BASE_PATH, 'tsconfig.json')) ? 'ts' : 'js';\n}\n\nfunction TS_COMMAND_SOURCE(name: string) {\n return `import type { CommandData, ChatInputCommand, MessageCommand } from 'commandkit';\n\nexport const command: CommandData = {\n name: '${name}',\n description: '${name} command',\n};\n\nexport const chatInput: ChatInputCommand = async (ctx) => {\n await ctx.interaction.reply('Hello from ${name}!');\n};\n\nexport const message: MessageCommand = async (ctx) => {\n await ctx.message.reply('Hello from ${name}!');\n};\n`;\n}\n\nfunction JS_COMMAND_SOURCE(name: string) {\n return `/**\n * @type {import('commandkit').CommandData}\n */\nexport const command = {\n name: '${name}',\n description: '${name} command',\n};\n\n/**\n * @type {import('commandkit').ChatInputCommand}\n */\nexport const chatInput = async (ctx) => {\n await ctx.interaction.reply('Hello from ${name}!');\n};\n\n/**\n * @type {import('commandkit').MessageCommand}\n */\nexport const message = async (ctx) => {\n await ctx.message.reply('Hello from ${name}!');\n};\n`;\n}\n\nexport async function generateCommand(name: string, customPath?: string) {\n const cmdPath = join(customPath || COMMANDS_DIR);\n if (!existsSync(cmdPath)) await mkdir(cmdPath, { recursive: true });\n\n const ext = determineExtension();\n const isTypeScript = ext === 'ts';\n\n const fileName = `${name}.${ext}`;\n\n if (existsSync(join(cmdPath, fileName))) {\n panic(`Command ${name} already exists.`);\n }\n\n const commandFile = isTypeScript ?\n TS_COMMAND_SOURCE(name) :\n JS_COMMAND_SOURCE(name);\n\n await writeFile(join(cmdPath, fileName), commandFile);\n\n console.log(\n colors.green(\n `Command ${colors.magenta(name)} created at ${colors.blue(formatPath(`${cmdPath}/${fileName}`))}`\n )\n );\n}\n\nexport async function generateEvent(name: string, customPath?: string) {\n const eventPath = join(customPath || EVENTS_DIR, name);\n if (!existsSync(eventPath)) await mkdir(eventPath, { recursive: true });\n\n const ext = determineExtension();\n\n let filename = `event.${ext}`;\n\n if (existsSync(join(eventPath, filename))) {\n const count = (await readdir(eventPath)).length;\n filename = `${String(count).padStart(2, '0')}_${filename}`;\n }\n\n const eventFile = `\nexport default async function on${name[0].toUpperCase() + name.slice(1)}() {\n console.log('${name} event fired!');\n};\n`.trim();\n\n await writeFile(join(eventPath, filename), eventFile);\n\n console.log(\n colors.green(\n `Event ${colors.magenta(name)} created at ${colors.blue(formatPath(eventPath))}/${colors.magenta(filename)}`\n )\n );\n}","import { rimrafSync } from 'rimraf';\nimport { join } from 'node:path';\nimport fs from 'node:fs';\nimport colors from '../utils/colors';\nimport { ResolvedCommandKitConfig } from '../config/utils';\nimport { generateTypesPackage } from '../utils/types-package';\nimport { execSync } from 'node:child_process';\n\nlet ts: typeof import('typescript') | undefined;\n\nexport function write(message: any) {\n process.stdout.write(message);\n process.stdout.write('\\n');\n}\n\nexport function findEntrypoint(dir: string) {\n const target = join(dir, 'sharding-manager.js');\n\n // if sharding manager exists, return that file instead\n if (fs.existsSync(target)) return target;\n\n return join(dir, 'index.js');\n}\n\n/**\n * @returns {never}\n */\nexport function panic(message: any): never {\n write(colors.red(`Error: ${message}`));\n process.exit(1);\n}\n\nexport function findPackageJSON() {\n const cwd = process.cwd();\n const target = join(cwd, 'package.json');\n\n if (!fs.existsSync(target)) {\n panic('Could not find package.json in current directory.');\n }\n\n return JSON.parse(fs.readFileSync(target, 'utf8'));\n}\n\nasync function ensureTypeScript(target: string) {\n const isTypeScript = /\\.(c|m)?tsx?$/.test(target);\n\n if (!isTypeScript) return false;\n if (process.features.typescript) return true;\n\n await loadTypeScript();\n\n return true;\n}\n\nlet packageManager: string;\n\nfunction detectPackageManager() {\n if (packageManager) return packageManager;\n\n const lockfiles = {\n 'yarn.lock': 'yarn',\n 'pnpm-lock.yaml': 'pnpm',\n 'package-lock.json': 'npm',\n 'bun.lock': 'bun',\n 'bun.lockb': 'bun'\n };\n\n for (const [lockfile, manager] of Object.entries(lockfiles)) {\n if (fs.existsSync(join(process.cwd(), lockfile))) {\n packageManager = manager;\n break;\n }\n }\n\n if (!packageManager) {\n packageManager = 'npm';\n }\n\n return packageManager;\n}\n\nexport async function loadTypeScript(e?: string) {\n if (ts) return ts;\n\n try {\n ts = await import('typescript');\n } catch (e) {\n if (e instanceof Error && 'code' in e && e.code === 'MODULE_NOT_FOUND') {\n try {\n const packageManager = detectPackageManager();\n\n execSync(`${packageManager} add typescript`, {\n stdio: 'inherit',\n cwd: process.cwd()\n });\n\n console.log(\n colors.cyan(\n `TypeScript has been installed automatically, restarting...`\n )\n );\n\n ts = await import('typescript');\n\n return ts;\n } catch {\n panic(\n 'TypeScript is not installed and could not be installed automatically. Please install it manually.'\n );\n }\n }\n panic(e || 'TypeScript must be installed to use TypeScript config files.');\n }\n\n return ts;\n}\n\nexport async function loadConfigFileFromPath(\ntarget: string)\n: Promise<ResolvedCommandKitConfig> {\n await ensureExists(target);\n\n const isTs = await ensureTypeScript(target);\n\n if (isTs && ts) {\n const { transpileModule } = ts;\n const src = fs.readFileSync(target, 'utf8');\n const { outputText } = transpileModule(src, {\n compilerOptions: {\n module: ts.ModuleKind.ESNext,\n target: ts.ScriptTarget.ESNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext\n },\n fileName: target\n });\n\n const nodeModulesPath = await generateTypesPackage();\n\n const tmpFile = join(nodeModulesPath, 'compiled-commandkit.config.mjs');\n\n fs.writeFileSync(tmpFile, outputText);\n\n target = tmpFile;\n }\n\n /**\n * @type {import('..').CommandKitConfig}\n */\n const config = await import(`file://${target}`).then(\n (conf) => conf.default || conf\n );\n\n return config;\n}\n\nasync function ensureExists(loc: string) {\n const exists = fs.existsSync(loc);\n\n if (!exists) {\n throw new Error(`File not found: ${loc}`);\n }\n}\n\nexport function erase(dir: string) {\n rimrafSync(dir);\n}\n\nexport async function copyLocaleFiles(_from: string, _to: string) {\n const resolvedFrom = join(process.cwd(), _from);\n const resolvedTo = join(process.cwd(), _to);\n\n const localePaths = ['app/locales'];\n const srcLocalePaths = localePaths.map((path) => join(resolvedFrom, path));\n const destLocalePaths = localePaths.map((path) => join(resolvedTo, path));\n\n for (const localePath of srcLocalePaths) {\n if (!fs.existsSync(localePath)) {\n continue;\n }\n\n // copy localePath to destLocalePath\n const destLocalePath = destLocalePaths[srcLocalePaths.indexOf(localePath)];\n\n if (!fs.existsSync(destLocalePath)) {\n fs.promises.mkdir(destLocalePath, { recursive: true });\n }\n\n await fs.promises.cp(localePath, destLocalePath, {\n recursive: true,\n force: true\n });\n }\n}","import { createColors } from 'picocolors';\n\nexport default createColors(true);","import { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { COMMANDKIT_IS_DEV } from './constants';\nimport { existsSync } from 'node:fs';\n\nexport async function generateTypesPackage(force = false) {\n const location = join(process.cwd(), 'node_modules', 'commandkit-types');\n if (!COMMANDKIT_IS_DEV && !force) return location;\n const packageJSON = join(location, 'package.json');\n const index = join(location, 'index.js');\n const types = join(location, 'index.d.ts');\n const command = join(location, 'command.d.ts');\n\n const packageJSONContent = {\n name: 'commandkit-types',\n version: '1.0.0',\n description: 'CommandKit types package',\n type: 'commonjs',\n main: 'index.js',\n types: 'index.d.ts'\n };\n\n const indexContent = `module.exports = {};`;\n\n // Restructuring the type declarations to properly extend rather than replace types\n const typesContent = `// Main types index file - imports all type declarations\nimport './command';\nexport {};\n`;\n\n // Properly set up command types to extend the CommandTypeData interface\n const commandTypesContent = `// Auto-generated command types\n export {};\ndeclare module 'commandkit' {\n type CommandTypeData = string\n}`;\n\n await mkdir(location, { recursive: true }).catch(() => {});\n await writeFile(packageJSON, JSON.stringify(packageJSONContent, null, 2));\n await writeFile(index, indexContent);\n await writeFile(types, typesContent);\n await writeFile(command, commandTypesContent);\n\n return location;\n}\n\nexport async function rewriteCommandDeclaration(data: string) {\n const commandTypesContent = `// Auto-generated command types\n declare module 'commandkit' {\n ${data}\n}\n export {};\n`;\n\n const location = join(process.cwd(), 'node_modules', 'commandkit-types');\n\n if (!existsSync(location)) return;\n\n const type = join(location, 'command.d.ts');\n\n await writeFile(type, commandTypesContent, { encoding: 'utf-8' });\n}","export const COMMANDKIT_CACHE_TAG = Symbol('kCommandKitCacheTag');\n\nexport const COMMANDKIT_IS_DEV = process.env.COMMANDKIT_IS_DEV === 'true';\n\nexport const COMMANDKIT_IS_TEST = process.env.COMMANDKIT_IS_TEST === 'true';\n\nexport const COMMANDKIT_BOOTSTRAP_MODE = (process.env.\nCOMMANDKIT_BOOTSTRAP_MODE || 'development') as 'development' | 'production';\n\n/**\n * Types of Hot Module Replacement events\n */\nexport const HMREventType = {\n ReloadCommands: 'reload-commands',\n ReloadEvents: 'reload-events',\n Unknown: 'unknown'\n} as const;\n\nexport type HMREventType = (typeof HMREventType)[keyof typeof HMREventType];"],"mappings":"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","names":["generators_exports","__export","generateCommand","generateEvent","__toCommonJS","import_promises","import_path","import_rimraf","import_node_path","import_node_fs","import_picocolors","colors_default","import_promises","import_node_path","COMMANDKIT_CACHE_TAG","COMMANDKIT_IS_DEV","COMMANDKIT_IS_TEST","COMMANDKIT_BOOTSTRAP_MODE","import_node_fs","import_node_child_process","write","message","__name","panic","message","write","colors_default","__name","import_fs","BASE_PATH","COMMANDS_DIR","EVENTS_DIR","formatPath","__name","path","determineExtension","TS_COMMAND_SOURCE","name","JS_COMMAND_SOURCE","generateCommand","customPath","cmdPath","ext","isTypeScript","fileName","panic","commandFile","colors_default","generateEvent","eventPath","filename","count","eventFile"]}
|
|
1
|
+
{"version":3,"file":"generators.js","names":[],"sources":["../../src/cli/generators.ts"],"sourcesContent":["import { mkdir, writeFile, readdir } from 'fs/promises';\nimport { join } from 'path';\nimport { panic } from './common';\nimport { existsSync } from 'fs';\nimport colors from '../utils/colors';\n\nconst BASE_PATH = process.cwd();\nconst COMMANDS_DIR = join(BASE_PATH, 'src/app/commands');\nconst EVENTS_DIR = join(BASE_PATH, 'src/app/events');\n\nconst formatPath = (path: string) =>\n path.replace(process.cwd(), '.').replace(/\\\\/g, '/');\n\nfunction determineExtension() {\n return existsSync(join(BASE_PATH, 'tsconfig.json')) ? 'ts' : 'js';\n}\n\nfunction TS_COMMAND_SOURCE(name: string) {\n return `import type { CommandData, ChatInputCommand, MessageCommand } from 'commandkit';\n\nexport const command: CommandData = {\n name: '${name}',\n description: '${name} command',\n};\n\nexport const chatInput: ChatInputCommand = async (ctx) => {\n await ctx.interaction.reply('Hello from ${name}!');\n};\n\nexport const message: MessageCommand = async (ctx) => {\n await ctx.message.reply('Hello from ${name}!');\n};\n`;\n}\n\nfunction JS_COMMAND_SOURCE(name: string) {\n return `/**\n * @type {import('commandkit').CommandData}\n */\nexport const command = {\n name: '${name}',\n description: '${name} command',\n};\n\n/**\n * @type {import('commandkit').ChatInputCommand}\n */\nexport const chatInput = async (ctx) => {\n await ctx.interaction.reply('Hello from ${name}!');\n};\n\n/**\n * @type {import('commandkit').MessageCommand}\n */\nexport const message = async (ctx) => {\n await ctx.message.reply('Hello from ${name}!');\n};\n`;\n}\n\nexport async function generateCommand(name: string, customPath?: string) {\n const cmdPath = join(customPath || COMMANDS_DIR);\n if (!existsSync(cmdPath)) await mkdir(cmdPath, { recursive: true });\n\n const ext = determineExtension();\n const isTypeScript = ext === 'ts';\n\n const fileName = `${name}.${ext}`;\n\n if (existsSync(join(cmdPath, fileName))) {\n panic(`Command ${name} already exists.`);\n }\n\n const commandFile = isTypeScript\n ? TS_COMMAND_SOURCE(name)\n : JS_COMMAND_SOURCE(name);\n\n await writeFile(join(cmdPath, fileName), commandFile);\n\n console.log(\n colors.green(\n `Command ${colors.magenta(name)} created at ${colors.blue(formatPath(`${cmdPath}/${fileName}`))}`,\n ),\n );\n}\n\nexport async function generateEvent(name: string, customPath?: string) {\n const eventPath = join(customPath || EVENTS_DIR, name);\n if (!existsSync(eventPath)) await mkdir(eventPath, { recursive: true });\n\n const ext = determineExtension();\n\n let filename = `event.${ext}`;\n\n if (existsSync(join(eventPath, filename))) {\n const count = (await readdir(eventPath)).length;\n filename = `${String(count).padStart(2, '0')}_${filename}`;\n }\n\n const eventFile = `\nexport default async function on${name[0].toUpperCase() + name.slice(1)}() {\n console.log('${name} event fired!');\n};\n`.trim();\n\n await writeFile(join(eventPath, filename), eventFile);\n\n console.log(\n colors.green(\n `Event ${colors.magenta(name)} created at ${colors.blue(formatPath(eventPath))}/${colors.magenta(filename)}`,\n ),\n );\n}\n"],"mappings":";;;;;;;;;;AAMA,MAAM,YAAY,QAAQ,KAAK;AAC/B,MAAM,eAAe,eAAK,WAAW,mBAAmB;AACxD,MAAM,aAAa,eAAK,WAAW,iBAAiB;AAEpD,MAAM,aAAa,CAAC,WACpB,OAAK,QAAQ,QAAQ,KAAK,EAAE,IAAI,CAAC,QAAQ,OAAO,IAAI;AAEpD,SAAS,qBAAqB;AAC5B,QAAO,mBAAW,eAAK,WAAW,gBAAgB,CAAC,GAAG,OAAO;AAC/D;AAEA,SAAS,kBAAkB,MAAc;AACvC,SAAQ;;;WAGC,KAAK;kBACE,KAAK;;;;4CAIqB,KAAK;;;;wCAIT,KAAK;;;AAG7C;AAEA,SAAS,kBAAkB,MAAc;AACvC,SAAQ;;;;WAIC,KAAK;kBACE,KAAK;;;;;;;4CAOqB,KAAK;;;;;;;wCAOT,KAAK;;;AAG7C;AAEA,eAAsB,gBAAgB,MAAc,YAAqB;CACvE,MAAM,UAAU,eAAK,cAAc,aAAa;AAChD,MAAK,mBAAW,QAAQ,CAAE,OAAM,uBAAM,SAAS,EAAE,WAAW,KAAM,EAAC;CAEnE,MAAM,MAAM,oBAAoB;CAChC,MAAM,eAAe,QAAQ;CAE7B,MAAM,YAAY,EAAE,KAAK,GAAG,IAAI;AAEhC,KAAI,mBAAW,eAAK,SAAS,SAAS,CAAC,CACrC,uBAAO,UAAU,KAAK,kBAAkB;CAG1C,MAAM,cAAc,eACpB,kBAAkB,KAAK,GACvB,kBAAkB,KAAK;AAEvB,OAAM,2BAAU,eAAK,SAAS,SAAS,EAAE,YAAY;AAErD,SAAQ,IACN,8BAAO,OACJ,UAAU,8BAAO,QAAQ,KAAK,CAAC,cAAc,8BAAO,KAAK,YAAY,EAAE,QAAQ,GAAG,SAAS,EAAE,CAAC,CAAC,EACjG,CACF;AACH;AAEA,eAAsB,cAAc,MAAc,YAAqB;CACrE,MAAM,YAAY,eAAK,cAAc,YAAY,KAAK;AACtD,MAAK,mBAAW,UAAU,CAAE,OAAM,uBAAM,WAAW,EAAE,WAAW,KAAM,EAAC;CAEvE,MAAM,MAAM,oBAAoB;CAEhC,IAAI,YAAY,QAAQ,IAAI;AAE5B,KAAI,mBAAW,eAAK,WAAW,SAAS,CAAC,EAAE;EACzC,MAAM,SAAS,MAAM,yBAAQ,UAAU,EAAE;AACzC,cAAY,EAAE,OAAO,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,SAAS;CAC3D;CAEA,MAAM,YAAY,CAAA;kCACc,KAAK,GAAG,aAAa,GAAG,KAAK,MAAM,EAAE,CAAC;iBACvD,KAAK;;EAEpB,MAAM;AAEN,OAAM,2BAAU,eAAK,WAAW,SAAS,EAAE,UAAU;AAErD,SAAQ,IACN,8BAAO,OACJ,QAAQ,8BAAO,QAAQ,KAAK,CAAC,cAAc,8BAAO,KAAK,WAAW,UAAU,CAAC,CAAC,GAAG,8BAAO,QAAQ,SAAS,CAAC,EAC5G,CACF;AACH"}
|
package/dist/cli/information.js
CHANGED
|
@@ -1,7 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const require_chunk = require('../chunk-nOFOJqeH.js');
|
|
2
|
+
const require_version = require('../version-DnRxh8U8.js');
|
|
3
|
+
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
4
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
|
+
const node_child_process = require_chunk.__toESM(require("node:child_process"));
|
|
6
|
+
const node_os = require_chunk.__toESM(require("node:os"));
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
//#region src/cli/information.ts
|
|
9
|
+
const knownPlugins = [
|
|
10
|
+
"@commandkit/cache",
|
|
11
|
+
"@commandkit/devtools",
|
|
12
|
+
"@commandkit/i18n",
|
|
13
|
+
"@commandkit/legacy",
|
|
14
|
+
"@commandkit/redis"
|
|
15
|
+
];
|
|
16
|
+
function findPackageVersion(packageName) {
|
|
17
|
+
try {
|
|
18
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
19
|
+
const packageJson = require(packageJsonPath);
|
|
20
|
+
return packageJson.version;
|
|
21
|
+
} catch (e) {
|
|
22
|
+
try {
|
|
23
|
+
const basePaths = [
|
|
24
|
+
node_path.default.join(process.cwd(), "node_modules", packageName),
|
|
25
|
+
node_path.default.join(process.cwd(), "..", "..", "node_modules", packageName),
|
|
26
|
+
node_path.default.join(process.cwd(), "..", "..", ".pnpm", packageName),
|
|
27
|
+
node_path.default.join(process.cwd(), "..", "..", "node_modules", ".pnpm", packageName)
|
|
28
|
+
];
|
|
29
|
+
for (const basePath of basePaths) {
|
|
30
|
+
const packageJsonPath = node_path.default.join(basePath, "package.json");
|
|
31
|
+
if (node_fs.default.existsSync(packageJsonPath)) {
|
|
32
|
+
const packageJson = JSON.parse(node_fs.default.readFileSync(packageJsonPath, "utf8"));
|
|
33
|
+
return packageJson.version;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const nodeModulesPath = node_path.default.join(process.cwd(), "..", "..", "node_modules", ".pnpm");
|
|
37
|
+
if (node_fs.default.existsSync(nodeModulesPath)) {
|
|
38
|
+
const folders = node_fs.default.readdirSync(nodeModulesPath);
|
|
39
|
+
const packageFolder = folders.find((folder) => folder.startsWith(`${packageName.replace("/", "+")}@`));
|
|
40
|
+
if (packageFolder) {
|
|
41
|
+
const packageJsonPath = node_path.default.join(nodeModulesPath, packageFolder, "node_modules", packageName, "package.json");
|
|
42
|
+
if (node_fs.default.existsSync(packageJsonPath)) {
|
|
43
|
+
const packageJson = JSON.parse(node_fs.default.readFileSync(packageJsonPath, "utf8"));
|
|
44
|
+
return packageJson.version;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function getBinaryVersion(binary) {
|
|
55
|
+
try {
|
|
56
|
+
const version$1 = (0, node_child_process.execSync)(`${binary} --version`).toString().trim();
|
|
57
|
+
return version$1;
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function showInformation() {
|
|
63
|
+
const runtimeName = (() => {
|
|
64
|
+
if ("Deno" in globalThis && typeof Deno !== "undefined") return "Deno";
|
|
65
|
+
if ("Bun" in globalThis && typeof Bun !== "undefined") return "Bun";
|
|
66
|
+
return "Node.js";
|
|
67
|
+
})();
|
|
68
|
+
const info = {
|
|
69
|
+
"Operating System": {
|
|
70
|
+
Platform: process.platform,
|
|
71
|
+
Arch: process.arch,
|
|
72
|
+
Version: node_os.default.version(),
|
|
73
|
+
"Available Memory (MB)": Math.round(node_os.default.totalmem() / 1024 / 1024),
|
|
74
|
+
"Available CPU cores": node_os.default.cpus().length
|
|
75
|
+
},
|
|
76
|
+
Runtime: runtimeName,
|
|
77
|
+
Binaries: {
|
|
78
|
+
Node: process.version,
|
|
79
|
+
npm: getBinaryVersion("npm") || "N/A",
|
|
80
|
+
Yarn: getBinaryVersion("yarn") || "N/A",
|
|
81
|
+
pnpm: getBinaryVersion("pnpm") || "N/A",
|
|
82
|
+
Bun: getBinaryVersion("bun") || "N/A",
|
|
83
|
+
Deno: (getBinaryVersion("deno") || "N/A").replace(/\n|\r/g, " ")
|
|
84
|
+
},
|
|
85
|
+
"Relevant Packages": {
|
|
86
|
+
commandkit: require_version.version,
|
|
87
|
+
"discord.js": findPackageVersion("discord.js") || "N/A",
|
|
88
|
+
typescript: findPackageVersion("typescript") || "N/A",
|
|
89
|
+
esbuild: findPackageVersion("esbuild") || "N/A",
|
|
90
|
+
tsup: findPackageVersion("tsup") || "N/A",
|
|
91
|
+
...knownPlugins.reduce((acc, plugin) => {
|
|
92
|
+
acc[plugin] = findPackageVersion(plugin) || "N/A";
|
|
93
|
+
return acc;
|
|
94
|
+
}, {})
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
let output = "";
|
|
98
|
+
for (const [section, data] of Object.entries(info)) {
|
|
99
|
+
output += `${section}:\n`;
|
|
100
|
+
if (typeof data === "string") {
|
|
101
|
+
output += ` ${data}\n\n`;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
for (const [key, value] of Object.entries(data)) output += ` ${key}: ${value}\n`;
|
|
105
|
+
output += "\n";
|
|
106
|
+
}
|
|
107
|
+
console.log(output.trim());
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
exports.showInformation = showInformation;
|
|
7
112
|
//# sourceMappingURL=information.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/information.ts"
|
|
1
|
+
{"version":3,"file":"information.js","names":[],"sources":["../../src/cli/information.ts"],"sourcesContent":["import os from 'node:os';\nimport { execSync } from 'node:child_process';\nimport { version as commandkitVersion } from '../version';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nfunction $getKnownPlugins() {\n 'use macro';\n\n // remove name from the list when that plugin is stable\n const BLACKLISTED = new Set([\n 'commandkit', // core package itself, not a plugin\n 'create-commandkit', // generator, not a plugin\n 'tsconfig', // repo config related, not a plugin\n 'devtools-ui', // the ui part of devtools, not a plugin\n // the plugins below are TBD\n 'tasks',\n ]);\n\n const { readdirSync, readFileSync } =\n require('node:fs') as typeof import('node:fs');\n const { join } = require('node:path') as typeof path;\n\n const pluginsPath = join(__dirname, '..', '..', '..');\n\n const entries = readdirSync(pluginsPath, { withFileTypes: true }).filter(\n (e) => !BLACKLISTED.has(e.name),\n );\n\n const packages = entries.map((p) =>\n join(p.parentPath, p.name, 'package.json'),\n );\n\n const knownPlugins: string[] = [];\n\n for (const pkg of packages) {\n try {\n const { name } = JSON.parse(readFileSync(pkg, 'utf8'));\n if (name && !BLACKLISTED.has(name.replace('@commandkit/', ''))) {\n knownPlugins.push(name);\n }\n } catch {\n // Ignore errors\n }\n }\n\n return knownPlugins;\n}\n\nconst knownPlugins: string[] = $getKnownPlugins();\n\nfunction findPackageVersion(packageName: string) {\n try {\n const packageJsonPath = require.resolve(`${packageName}/package.json`);\n const packageJson = require(packageJsonPath);\n return packageJson.version;\n } catch (e) {\n try {\n const basePaths = [\n path.join(process.cwd(), 'node_modules', packageName),\n path.join(process.cwd(), '..', '..', 'node_modules', packageName),\n path.join(process.cwd(), '..', '..', '.pnpm', packageName),\n path.join(\n process.cwd(),\n '..',\n '..',\n 'node_modules',\n '.pnpm',\n packageName,\n ),\n ];\n\n for (const basePath of basePaths) {\n const packageJsonPath = path.join(basePath, 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(\n fs.readFileSync(packageJsonPath, 'utf8'),\n );\n return packageJson.version;\n }\n }\n\n const nodeModulesPath = path.join(\n process.cwd(),\n '..',\n '..',\n 'node_modules',\n '.pnpm',\n );\n if (fs.existsSync(nodeModulesPath)) {\n const folders = fs.readdirSync(nodeModulesPath);\n const packageFolder = folders.find((folder) =>\n folder.startsWith(`${packageName.replace('/', '+')}@`),\n );\n\n if (packageFolder) {\n const packageJsonPath = path.join(\n nodeModulesPath,\n packageFolder,\n 'node_modules',\n packageName,\n 'package.json',\n );\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(\n fs.readFileSync(packageJsonPath, 'utf8'),\n );\n return packageJson.version;\n }\n }\n }\n\n return null;\n } catch {\n return null;\n }\n }\n}\n\nfunction getBinaryVersion(binary: string) {\n try {\n const version = execSync(`${binary} --version`).toString().trim();\n return version;\n } catch {\n return null;\n }\n}\n\nexport async function showInformation() {\n const runtimeName: string = (() => {\n // @ts-ignore\n if ('Deno' in globalThis && typeof Deno !== 'undefined') return 'Deno';\n // @ts-ignore\n if ('Bun' in globalThis && typeof Bun !== 'undefined') return 'Bun';\n\n return 'Node.js';\n })();\n\n const info = {\n 'Operating System': {\n Platform: process.platform,\n Arch: process.arch,\n Version: os.version(),\n 'Available Memory (MB)': Math.round(os.totalmem() / 1024 / 1024),\n 'Available CPU cores': os.cpus().length,\n },\n Runtime: runtimeName,\n Binaries: {\n Node: process.version,\n npm: getBinaryVersion('npm') || 'N/A',\n Yarn: getBinaryVersion('yarn') || 'N/A',\n pnpm: getBinaryVersion('pnpm') || 'N/A',\n Bun: getBinaryVersion('bun') || 'N/A',\n Deno: (getBinaryVersion('deno') || 'N/A').replace(/\\n|\\r/g, ' '),\n },\n 'Relevant Packages': {\n commandkit: commandkitVersion,\n 'discord.js': findPackageVersion('discord.js') || 'N/A',\n typescript: findPackageVersion('typescript') || 'N/A',\n esbuild: findPackageVersion('esbuild') || 'N/A',\n tsup: findPackageVersion('tsup') || 'N/A',\n ...knownPlugins.reduce(\n (acc, plugin) => {\n acc[plugin] = findPackageVersion(plugin) || 'N/A';\n return acc;\n },\n {} as Record<string, string>,\n ),\n },\n };\n\n let output = '';\n\n for (const [section, data] of Object.entries(info)) {\n output += `${section}:\\n`;\n\n if (typeof data === 'string') {\n output += ` ${data}\\n\\n`;\n continue;\n }\n\n for (const [key, value] of Object.entries(data)) {\n output += ` ${key}: ${value}\\n`;\n }\n output += '\\n';\n }\n\n console.log(output.trim());\n}\n"],"mappings":"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"}
|
package/dist/cli/init.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates a command line interface for CommandKit.
|
|
5
|
-
* @param argv The arguments passed to the CLI.
|
|
6
|
-
* @param options The options passed to the CLI.
|
|
7
|
-
*/
|
|
8
|
-
declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
|
|
9
|
-
|
|
10
|
-
export { bootstrapCommandkitCLI };
|
|
1
|
+
import { bootstrapCommandkitCLI } from "../init--p1nl1NO.js";
|
|
2
|
+
export { bootstrapCommandkitCLI };
|
package/dist/cli/init.js
CHANGED
|
@@ -1,100 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`,g=`// Auto-generated command types
|
|
5
|
-
export {};
|
|
6
|
-
declare module 'commandkit' {
|
|
7
|
-
type CommandTypeData = string
|
|
8
|
-
}`;return await(0,H.mkdir)(e,{recursive:!0}).catch(()=>{}),await(0,H.writeFile)(o,JSON.stringify(d,null,2)),await(0,H.writeFile)(i,p),await(0,H.writeFile)(a,u),await(0,H.writeFile)(s,g),e}var H,Q,Co,ae=l(()=>{"use strict";n();H=require("fs/promises"),Q=require("path");j();Co=require("fs");r(ie,"generateTypesPackage")});var dt,m,T=l(()=>{"use strict";n();dt=require("picocolors"),m=(0,dt.createColors)(!0)});function xo(t){process.stdout.write(t),process.stdout.write(`
|
|
9
|
-
`)}function de(t){let e=(0,R.join)(t,"sharding-manager.js");return M.default.existsSync(e)?e:(0,R.join)(t,"index.js")}function A(t){xo(m.red(`Error: ${t}`)),process.exit(1)}async function bo(t){return/\.(c|m)?tsx?$/.test(t)?(process.features.typescript||await ke(),!0):!1}function wo(){if(Z)return Z;let t={"yarn.lock":"yarn","pnpm-lock.yaml":"pnpm","package-lock.json":"npm","bun.lock":"bun","bun.lockb":"bun"};for(let[e,o]of Object.entries(t))if(M.default.existsSync((0,R.join)(process.cwd(),e))){Z=o;break}return Z||(Z="npm"),Z}async function ke(t){if(v)return v;try{v=await import("typescript")}catch(e){if(e instanceof Error&&"code"in e&&e.code==="MODULE_NOT_FOUND")try{let o=wo();return(0,ut.execSync)(`${o} add typescript`,{stdio:"inherit",cwd:process.cwd()}),console.log(m.cyan("TypeScript has been installed automatically, restarting...")),v=await import("typescript"),v}catch{A("TypeScript is not installed and could not be installed automatically. Please install it manually.")}A(e||"TypeScript must be installed to use TypeScript config files.")}return v}async function pt(t){if(await vo(t),await bo(t)&&v){let{transpileModule:i}=v,a=M.default.readFileSync(t,"utf8"),{outputText:s}=i(a,{compilerOptions:{module:v.ModuleKind.ESNext,target:v.ScriptTarget.ESNext,moduleResolution:v.ModuleResolutionKind.NodeNext},fileName:t}),d=await ie(),p=(0,R.join)(d,"compiled-commandkit.config.mjs");M.default.writeFileSync(p,s),t=p}return await import(`file://${t}`).then(i=>i.default||i)}async function vo(t){if(!M.default.existsSync(t))throw new Error(`File not found: ${t}`)}async function ft(t,e){let o=(0,R.join)(process.cwd(),t),i=(0,R.join)(process.cwd(),e),a=["app/locales"],s=a.map(p=>(0,R.join)(o,p)),d=a.map(p=>(0,R.join)(i,p));for(let p of s){if(!M.default.existsSync(p))continue;let u=d[s.indexOf(p)];M.default.existsSync(u)||M.default.promises.mkdir(u,{recursive:!0}),await M.default.promises.cp(p,u,{recursive:!0,force:!0})}}var yo,R,M,ut,v,Z,B=l(()=>{"use strict";n();yo=require("rimraf"),R=require("path"),M=x(require("fs"));T();ae();ut=require("child_process");r(xo,"write");r(de,"findEntrypoint");r(A,"panic");r(bo,"ensureTypeScript");r(wo,"detectPackageManager");r(ke,"loadTypeScript");r(pt,"loadConfigFileFromPath");r(vo,"ensureExists");r(ft,"copyLocaleFiles")});function Te(t){return t instanceof ee}var ht,Ae,ee,Be=l(()=>{"use strict";n();ht=require("crypto"),Ae=class Ae{constructor(e){this.options=e}id=(0,ht.randomUUID)();loadedAt=Date.now();async activate(e){}async deactivate(e){}};r(Ae,"PluginCommon");ee=Ae;r(Te,"isPlugin")});function ue(t){return Te(t)&&t.type==="compiler"}var Oe,G,gt=l(()=>{"use strict";n();Be();Oe=class Oe extends ee{type="compiler";async transform(e){return null}async resolve(e){return null}async onBuildStart(){}async onBuildEnd(){}};r(Oe,"CompilerPlugin");G=Oe;r(ue,"isCompilerPlugin")});var Ct=l(()=>{"use strict";n();Be()});var yt=l(()=>{"use strict";n()});var se,_=l(()=>{"use strict";n();se={ExitMiddleware:Symbol("kExitMiddleware"),ForwardedCommand:Symbol("kForwardedCommand"),InvalidCommandPrefix:Symbol("kInvalidCommandPrefix"),PluginCaptureHandle:Symbol("kPluginCaptureHandle")}});var Mo,xt=l(()=>{"use strict";n();Mo=require("discord.js")});var Le,$e=l(()=>{"use strict";n();Le=require("discord.js");w()});var So,bt=l(()=>{"use strict";n();So=require("discord.js");$e()});var wt,Fe=l(()=>{"use strict";n();wt=require("discord.js");w()});var Ne,vt=l(()=>{"use strict";n();Ne=require("discord.js");Fe()});var Et,Ue=l(()=>{"use strict";n();Et=require("discord.js");w()});var Mt,je=l(()=>{"use strict";n();Mt=require("discord.js");w()});var St,He=l(()=>{"use strict";n();St=require("discord.js");w()});var It,Ge=l(()=>{"use strict";n();It=require("discord.js");w()});var Pt,_e=l(()=>{"use strict";n();Pt=require("discord.js");w()});var Io,Rt=l(()=>{"use strict";n();Io=require("discord.js");je();He();_e();Ue();Ge()});var Dt=l(()=>{"use strict";n()});var pe=l(()=>{"use strict";n()});var V,kt=l(()=>{"use strict";n();V=require("discord.js");pe()});var Po,Tt=l(()=>{"use strict";n();Po=require("discord.js")});var At,Bt=l(()=>{"use strict";n();At=require("discord.js");pe()});var fe,Ot=l(()=>{"use strict";n();fe=require("discord.js");pe()});var Ro,Lt=l(()=>{"use strict";n();Ro=require("discord.js")});var Do,$t=l(()=>{"use strict";n();Do=require("discord.js")});var Ft=l(()=>{"use strict";n();kt();Tt();Bt();Ot();Lt();$t()});var Nt=l(()=>{"use strict";n()});var Ut=l(()=>{"use strict";n();Nt()});var jt=l(()=>{"use strict";n()});var Ve=l(()=>{"use strict";n()});var Gt=l(()=>{"use strict";n();xt();$e();bt();Fe();vt();Ue();je();He();Ge();_e();Rt();Dt();Ft();Ut();jt();Ve()});var _t,Js,Ko,We=l(()=>{"use strict";n();_t=require("async_hooks"),Js=Symbol("commandkitEventWorker"),Ko=new _t.AsyncLocalStorage});function Vt(t,e){let o=null,i=null;return(...a)=>(o&&(clearTimeout(o),i&&i(null)),new Promise(s=>{i=s,o=setTimeout(()=>{let d=t(...a);s(d),o=null,i=null},e)}))}var ko,To,he=l(()=>{"use strict";n();ko=require("fs"),To=require("path");j();Je();We();r(Vt,"debounce")});var Ao,ze=l(()=>{"use strict";n();Ao=x(require("path"))});var ge,qt=l(()=>{"use strict";n();ge=require("discord.js");_()});var Ye,Jt=l(()=>{"use strict";n();Ye=require("discord.js");O()});var Bo,zt=l(()=>{"use strict";n();Bo=require("crypto");w()});var Yt=l(()=>{"use strict";n();_()});var Xt=l(()=>{"use strict";n();w();Yt()});var Lo,Zt=l(()=>{"use strict";n();Lo=require("discord.js");zt();O();Xt();w();_()});var q,en=l(()=>{"use strict";n();q=require("discord.js");ze();qt();_();Jt();O();Zt();j();ae();T()});var Fo,No,Uo,Ce,tn=l(()=>{"use strict";n();Fo=require("discord.js"),No=require("fs"),Uo=require("fs/promises"),Ce=require("path")});var jo,Ho,Go,_o,nn=l(()=>{"use strict";n();jo=require("discord.js"),Ho=require("fs"),Go=require("fs/promises"),_o=require("path")});var on=l(()=>{"use strict";n();tn();nn()});var Vo,rn=l(()=>{"use strict";n();Vo=require("discord.js");O();ze();he();We()});var an=l(()=>{"use strict";n();O();j()});var Wo,sn=l(()=>{"use strict";n();Wo=x(require("events"))});var qo,ln=l(()=>{"use strict";n();qo=require("discord.js")});var Jo,cn,zo,Yo,mn=l(()=>{"use strict";n();Jo=x(require("events"));T();Gt();Ve();cn=require("discord.js");he();zo=require("path");en();on();rn();Xe();le();j();an();Yo=require("fs");sn();L();ae();O();ln()});function E(){return Xo.getStore()}var dn,Km,Xo,w=l(()=>{"use strict";n();dn=require("async_hooks");mn();_();Km=Symbol("commandkitCommandWorker"),Xo=new dn.AsyncLocalStorage;r(E,"getContext")});var Qo,Zo,er,ye,Qe,xe,un=l(()=>{"use strict";n();w();T();Qo={autocomplete:"Autocomplete",messageContextMenu:"MessageContextMenu",userContextMenu:"UserContextMenu",chatInput:"ChatInputCommand",message:"Message"},Zo={0:m.blue,1:m.green,2:m.yellow,3:m.red,4:m.white},er={0:m.bgBlue,1:m.bgGreen,2:m.bgYellow,3:m.bgRed,4:m.bgWhite},ye={vertical:"\u2502",horizontalDown:"\u252C",horizontalUp:"\u2534",verticalRight:"\u251C",corner:"\u2514"},Qe=class Qe{constructor(e=process.stdout,o=process.stderr){this.stdout=e;this.stderr=o;this.logger=new console.Console(this.stdout,this.stderr)}logger;_formatTime(e){let o=e.getHours().toString().padStart(2,"0"),i=e.getMinutes().toString().padStart(2,"0"),a=e.getSeconds().toString().padStart(2,"0"),s=e.getMilliseconds().toString().padStart(3,"0");return`${o}:${i}:${a}.${s}`}_getContext(){let e=E();if(!e)return"";let o=e.variables.get("execHandlerKind"),i=e.variables.get("commandHandlerType"),a=e.variables.get("currentCommandName");if(!o&&!i)return"";let s=Qo[o];if(!s&&!i)return"";let d=e.variables.get("forwardedBy"),p=e.variables.get("forwardedTo"),u=a?m.magenta(`/${a}`)+" ":"",g=p?`${m.yellowBright(`(${d||a} \u2192 ${p})`)} `:"";return m.dim(`${ye.vertical} `)+m.cyanBright(`${u}${g}${s?m.gray(`[${s}]`):""}`.trim())}_getLevelLabel(e){let o;switch(e){case 0:o="[DEBUG]";break;case 1:o="[INFO]";break;case 2:o="[WARN]";break;case 3:o="[ERROR]";break;default:o="[LOG]"}return`${er[e](m.whiteBright(` ${o} `))} `}_getPrefix(e){let o=this._formatTime(new Date);return`${this._getLevelLabel(e)}${m.dim(ye.vertical)} ${m.dim(o)}`}_log(e,...o){let i=this._getPrefix(e),a=this._getContext(),s=Zo[e];a?this.logger.log(`${i}
|
|
10
|
-
${a} ${m.dim(ye.corner)}`,...o.map(d=>s(d))):this.logger.log(`${i} ${m.dim(ye.corner)}`,...o.map(d=>s(d)))}debug(...e){this._log(0,...e)}error(...e){this._log(3,...e)}log(...e){this._log(4,...e)}info(...e){this._log(1,...e)}warn(...e){this._log(2,...e)}};r(Qe,"DefaultLogger");xe=Qe});function tr(t){let e=t;if(!(e!=null&&e.provider))throw new Error("A logger provider must be provided.");let o=["log","error","warn","info","debug"],i={configure(a){e=a}};for(let a of o)i[a]=(...s)=>{e.provider[a](...s)};return i}var W,O=l(()=>{"use strict";n();un();r(tr,"createLogger");W=tr({provider:new xe})});var nr,Xe=l(()=>{"use strict";n();nr=require("discord.js");_();O()});function hn(t){let o=class o extends G{name=t.name;onBuildEnd(){var a;return(a=t.onBuildEnd)==null?void 0:a.call(t)}onBuildStart(){var a;return(a=t.onBuildStart)==null?void 0:a.call(t)}async transform(a){var s;return(s=t.transform)==null?void 0:s.call(t,a)}async resolve(a){var s;return(s=t.resolve)==null?void 0:s.call(t,a)}};r(o,"EsbuildPluginCompat");let e=o;return e}var fn,pn,Ze,be,gn=l(()=>{"use strict";n();fn=require("fs/promises");L();pn=/\.(c|m)?(t|j)sx?$/,Ze=class Ze{constructor(e){this.plugins=e}name="CompilerPluginRuntime";getPlugins(){return this.plugins}isEmpty(){return!this.plugins.length}async onLoad(e){var s,d;let i=await(0,fn.readFile)(e.path,"utf8"),a=(s=e.path)==null?void 0:s.split(".").pop();for(let p of this.plugins)try{let u=await((d=p.transform)==null?void 0:d.call(p,{contents:i,path:e.path,loader:a,args:e}));if(!u)continue;u.contents&&(i=u.contents),u.loader&&(a=u.loader)}catch(u){let g=u instanceof Error?u:new Error(u);return{pluginName:p.name,errors:[{text:g.message,detail:(g==null?void 0:g.stack)??g,location:null}]}}return{contents:i,loader:a}}async onResolve(e){var i;let o={};for(let a of this.plugins)try{let s=await((i=a.resolve)==null?void 0:i.call(a,e));if(!s)continue;o={...o,...s}}catch(s){let d=s instanceof Error?s:new Error(s);return{errors:[{text:d.message,detail:(d==null?void 0:d.stack)??d,location:null}]}}return o}async onStart(){var e;for(let o of this.plugins)try{await((e=o.onBuildStart)==null?void 0:e.call(o))}catch(i){console.error(`Plugin ${o.name} failed to run onBuildStart with ${(i==null?void 0:i.stack)||i}`)}}async onEnd(){var e;for(let o of this.plugins)try{await((e=o.onBuildEnd)==null?void 0:e.call(o))}catch(i){console.error(`Plugin ${o.name} failed to run onBuildEnd with ${(i==null?void 0:i.stack)||i}`)}}async onDispose(){var e;for(let o of this.plugins)try{await((e=o.deactivate)==null?void 0:e.call(o,this))}catch(i){console.error(`Plugin ${o.name} failed to deactivate with ${(i==null?void 0:i.stack)||i}`)}}async onInit(){var e;for(let o of this.plugins)try{await((e=o.activate)==null?void 0:e.call(o,this))}catch(i){console.error(`Plugin ${o.name} failed to activate with ${(i==null?void 0:i.stack)||i}`)}}async cleanup(){await this.onEnd(),await this.onDispose()}async setup(e){this.plugins.length&&(await this.onInit(),await e.onResolve({filter:pn},this.onResolve.bind(this)),await e.onLoad({filter:pn},this.onLoad.bind(this)),await e.onStart(this.onStart.bind(this)),e.onEnd(async()=>{await this.onEnd()}),e.onDispose(async()=>{await this.onDispose()}))}toEsbuildPlugin(){return{name:this.name,setup:this.setup.bind(this)}}};r(Ze,"CompilerPluginRuntime");be=Ze;r(hn,"fromEsbuildPlugin")});var Cn=l(()=>{"use strict";n()});var yn=l(()=>{"use strict";n()});var xn=l(()=>{"use strict";n();L()});var L=l(()=>{"use strict";n();gt();Ct();yt();Xe();gn();Cn();yn();xn()});var et,we,bn=l(()=>{"use strict";n();L();et=class et extends G{name="MacroPlugin";macroTransformer;async activate(){let e=await import("use-macro");this.macroTransformer=new e.MacroTransformer}async deactivate(){this.macroTransformer=null}async transform(e){if(!this.options.enabled)return null;let{contents:o,loader:i}=await this.macroTransformer.transform(e.contents.toString(),e.path);return{contents:o,loader:i}}};r(et,"MacroPlugin");we=et});var wn,vn=l(()=>{"use strict";n();bn();wn={plugins:[new we({enabled:!0})],esbuildPlugins:[],compilerOptions:{macro:{development:!1}},static:!0,typescript:{ignoreBuildErrors:!1},distDir:"dist",env:{},sourceMap:{development:!0,production:!0},typedCommands:!0}});function qe(){return or}var or,Je=l(()=>{"use strict";n();vn();or=wn;r(qe,"getConfig")});function nt(t){return rr.map(e=>(0,Mn.join)(t,e))}function ir(t){let e=nt(t);for(let o of e)if((0,En.existsSync)(o))return{path:o,isTypeScript:/\.ts$/.test(o)};return null}async function $(t=process.cwd()){if(tt)return tt;let e=ir(t);if(!e)return qe();let o=await pt(e.path);return tt=o,o}var En,Mn,rr,tt,le=l(()=>{"use strict";n();En=require("fs"),Mn=require("path");B();Je();rr=["commandkit.config.js","commandkit.config.mjs","commandkit.config.cjs","commandkit.config.ts"];r(nt,"getPossibleConfigPaths");r(ir,"findConfigFile");tt=null;r($,"loadConfigFile")});function ve(t=!1){let e={NODE_ENV:"development",COMMANDKIT_IS_DEV:"true"};return t?Object.assign({},e):Object.assign({},process.env,e)}function Ee(t=!1){let e={NODE_ENV:"production",COMMANDKIT_IS_DEV:"false"};return t?Object.assign({},e):Object.assign({},process.env,e)}var Sn,ar,sr,In,Pn,ot=l(()=>{"use strict";n();r(ve,"DevEnv");r(Ee,"ProdEnv");Sn=[".env",".env.local"],ar=[".env.development",".env.development.local"],sr=[".env.production",".env.production.local"],In=[...Sn,...ar],Pn=[...Sn,...sr]});function lr(t){return t?["pipe","pipe","pipe","ipc"]:["pipe","pipe","pipe"]}function Me(t,e,o){var s,d;(0,Kn.existsSync)((0,Dn.join)(e,t))||A(`Could not locate the entrypoint file: ${t}`);let i=lr(o),a=(0,Rn.spawn)("node",[`--title="CommandKit ${o?"Development":"Production"}"`,"--enable-source-maps",t],{cwd:e,windowsHide:!0,env:o?ve():Ee(),stdio:i});return(s=a.stdout)==null||s.pipe(process.stdout),(d=a.stderr)==null||d.pipe(process.stderr),a}var Rn,Dn,Kn,rt=l(()=>{"use strict";n();Rn=require("child_process");ot();Dn=require("path"),Kn=require("fs");B();r(lr,"getStdio");r(Me,"createAppProcess")});function mr(t,e,o){let i=t.flattenDiagnosticMessageText(e.messageText,`
|
|
11
|
-
`);if(!e.file)return`${m.red("error")}: ${i}`;let{line:a,character:s}=t.getLineAndCharacterOfPosition(e.file,e.start),d=(0,Se.relative)(o,e.file.fileName),p=`${a+1}:${s+1}`,u=e.code?`TS${e.code}`:"";return[`${m.bold(m.cyan(d))}:${m.bold(m.yellow(p))} - ${m.red("error")} ${m.gray(u)}`,`${i}`].join(`
|
|
12
|
-
`)}async function Tn(t){let e=(0,Se.join)(t,"tsconfig.json");if(!(0,kn.existsSync)(e))return;let o=await ke(cr),i={getCanonicalFileName:r(u=>u,"getCanonicalFileName"),getCurrentDirectory:o.sys.getCurrentDirectory,getNewLine:r(()=>o.sys.newLine,"getNewLine")},a=o.readConfigFile(e,o.sys.readFile);a.error&&(console.error(m.red(`Error reading tsconfig.json: ${o.formatDiagnostic(a.error,i)}`)),process.exit(1));let s=o.parseJsonConfigFileContent(a.config,o.sys,t);s.options.noEmit=!0;let d=o.createProgram({rootNames:s.fileNames,options:s.options,projectReferences:s.projectReferences}),p=[...d.getOptionsDiagnostics(),...d.getGlobalDiagnostics(),...d.getSyntacticDiagnostics(),...d.getSemanticDiagnostics()];if(p.length>0){console.log(""),console.error(m.bold(m.red("Type checking failed with the following errors:"))),console.log("");let u=new Map;for(let P of p){let f=P.file?P.file.fileName:"Global";u.has(f)||u.set(f,[]),u.get(f).push(P)}let g=p.length,C=0;for(let[P,f]of u)for(let h of f)C++,console.log(mr(o,h,t)),C<g&&console.log("");console.log(""),console.error(m.bold(m.red(`Found ${g} error${g>1?"s":""}`))),console.log(""),process.exit(1)}console.log(m.green("\u2713 Type checking completed successfully."))}var kn,Se,cr,An=l(()=>{"use strict";n();kn=require("fs");B();Se=require("path");T();cr="TypeScript must be installed in order to use the type checker. Please install it using `npm install typescript` or `yarn add typescript`";r(mr,"formatDiagnostic");r(Tn,"performTypeCheck")});async function Ie({plugins:t,esbuildPlugins:e,isDev:o,configPath:i}){var p;let a=await $(i);!o&&!((p=a==null?void 0:a.typescript)!=null&&p.ignoreBuildErrors)&&await Tn(i||process.cwd());let s=new be(t||[]),d=s.isEmpty()?[]:[s.toEsbuildPlugin()];e!=null&&e.length&&d.push(...e.map(hn));try{let u=o?".commandkit":a.distDir;await(0,Un.rimraf)(u),await(0,$n.build)({esbuildPlugins:d,watch:!1,banner:{js:o?"":"/* Optimized production build generated by commandkit */"},cjsInterop:!0,dts:!1,clean:!0,format:["esm"],shims:!0,keepNames:!0,minify:!1,esbuildOptions:r(g=>(g.jsx="automatic",g.jsxImportSource="commandkit",g),"esbuildOptions"),minifyIdentifiers:!1,minifySyntax:!1,silent:!!o,splitting:!0,skipNodeModulesBundle:!0,name:"CommandKit",sourcemap:!0,target:"node16",outDir:u,env:o?ve(!0):Ee(!0),entry:["src",`!${a.distDir}`,"!.commandkit","!**/*.test.*","!**/*.spec.*"]}),await ft("src",u),await ur(i||process.cwd(),!!o,a.distDir)}catch(u){console.error("Build failed:",u),u instanceof Error&&console.error("Error details:",u.stack),process.exit(1)}finally{await s.cleanup()}}async function ur(t,e,o){let i=`/* Entrypoint File Generated By CommandKit */
|
|
13
|
-
${e?`
|
|
1
|
+
require('../constants-DOPSzXI0.js');
|
|
2
|
+
require('../types-package-DRhFn59I.js');
|
|
3
|
+
const require_init = require('../init-D2me-V0n.js');
|
|
14
4
|
|
|
15
|
-
|
|
16
|
-
${Ln([Bn(e),dr,On])}
|
|
17
|
-
|
|
18
|
-
`:Ln([Bn(e),On])}
|
|
19
|
-
|
|
20
|
-
import { CommandKit } from 'commandkit';
|
|
21
|
-
|
|
22
|
-
async function bootstrap() {
|
|
23
|
-
const app = await import('./app.js').then((m) => m.default ?? m);
|
|
24
|
-
const commandkit = new CommandKit({
|
|
25
|
-
client: app,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
await commandkit.start();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
await bootstrap().catch((e) => {
|
|
32
|
-
console.error('Failed to bootstrap CommandKit application:\\n', e.stack);
|
|
33
|
-
})
|
|
34
|
-
`;await(0,Fn.writeFile)((0,Nn.join)(t,e?".commandkit":o||"dist","index.js"),i)}var $n,Fn,Nn,Un,Bn,On,dr,Ln,it=l(()=>{"use strict";n();$n=require("tsup");L();le();Fn=require("fs/promises"),Nn=require("path");ot();Un=require("rimraf");An();B();r(Ie,"buildApplication");Bn=r(t=>`// --- Environment Variables Loader ---
|
|
35
|
-
const $env = [${(t?In:Pn).map(e=>`"${e}"`).join(", ")}];
|
|
36
|
-
for (const file of $env) {
|
|
37
|
-
try {
|
|
38
|
-
process.loadEnvFile(file);
|
|
39
|
-
console.log('\\x1b[36m\u2714 Loaded \\x1b[0m\\x1b[33m%s\\x1b[0m', file);
|
|
40
|
-
} catch {}
|
|
41
|
-
}
|
|
42
|
-
`,"envScript"),On=["// --- CommandKit require() polyfill ---",' if (typeof require === "undefined") {',' const { createRequire } = await import("node:module");'," const __require = createRequire(import.meta.url);",' Object.defineProperty(globalThis, "require", {'," value: (id) => {"," return __require(id);"," },"," configurable: true,"," enumerable: false,"," writable: true,"," });"," }","// --- CommandKit require() polyfill ---"].join(`
|
|
43
|
-
`),dr=["// --- CommandKit Anti-Crash Monitor ---"," // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process"," // instead of using it as a means to resume operation."," // But it exists here due to compatibility reasons with discord bot ecosystem."," const p = (t) => `\\x1b[31m${t}\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';"," if (!process.eventNames().includes(e1)) // skip if it is already handled"," process.on(e1, (e) => {"," l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));"," })"," if (!process.eventNames().includes(e2)) // skip if it is already handled"," process.on(e2, (r) => {"," l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));"," });","// --- CommandKit Anti-Crash Monitor ---"].join(`
|
|
44
|
-
`),Ln=r(t=>`;await (async () => {
|
|
45
|
-
${t.join(`
|
|
46
|
-
|
|
47
|
-
`)}
|
|
48
|
-
})();`,"wrapInAsyncIIFE");r(ur,"injectEntryFile")});var _n={};Y(_n,{bootstrapDevelopmentServer:()=>hr});async function Pe(t,e=!1){let o=await $(t),i=de(".commandkit");return await Ie({configPath:t,isDev:!0,plugins:o.plugins.flat(2).filter(s=>ue(s)),esbuildPlugins:o.esbuildPlugins}),e?null:Me(i,t,!0)}async function hr(t){process.env.COMMANDKIT_BOOTSTRAP_MODE="development";let e=performance.now(),o=t||process.cwd(),i=nt(o),a=(0,Hn.watch)([(0,jn.join)(o,"src"),...i],{ignoreInitial:!0}),s=null,d=r(f=>new Promise(h=>{if(!s)return h(!1);let y=!1,z=r(k=>{if(y=!0,typeof k!="object"||k===null)return;let{type:Ke,id:lo,handled:co}=k;Ke==="commandkit-hmr-ack"&&lo===f&&(s==null||s.off("message",z),h(!!co))},"onMessage");s.once("message",z),y||(0,at.setTimeout)(3e3).then(()=>{s==null||s.off("message",z),h(!1)})}),"waitForAcknowledgment"),p=r(async(f,h)=>{if(!s||!s.send)return!1;let y=(0,Gn.randomUUID)(),z=d(y);s.send({event:f,path:h,id:y});try{let k=!1,Ke=!!await Promise.race([z,(0,at.setTimeout)(3e3).then(()=>(k||console.warn(m.yellow(`HMR acknowledgment timed out for event ${f} on path ${h}`)),!1))]);return k=!0,Ke}catch(k){return console.error(m.red(`Error waiting for HMR acknowledgment: ${k}`)),!1}},"sendHmrEvent"),u=Vt(async f=>{if(!f||!s)return!1;let h=null,y="";return pr(f)?(h=U.ReloadCommands,y="command(s)"):fr(f)?(h=U.ReloadEvents,y="event(s)"):(h=U.Unknown,y="unknown source"),h&&(console.log(`${m.cyanBright(`Attempting to reload ${y} at`)} ${m.yellowBright(f)}`),await Pe(o,!0),await p(h,f))?(console.log(`${m.greenBright(`Successfully hot reloaded ${y} at`)} ${m.yellowBright(f)}`),!0):!1},300),g=r(f=>{let h=i.some(y=>f===y);return h?(console.log(m.yellowBright("It seems like commandkit config file was updated, please restart the server manually to apply changes.")),h):!1},"isConfigUpdate"),C=r(async f=>{g(f)||await u(f)||(console.log(`${m.yellowBright("\u26A1\uFE0F Performing full restart due to the changes in")} ${m.cyanBright(f)}`),s==null||s.kill(),s=await Pe(o))},"hmrHandler");process.stdin.on("data",async f=>{switch(f.toString().trim()){case"r":console.log("Received restart command, restarting..."),s==null||s.kill(),s=null,s=await Pe(o);break;case"rc":console.log("Received reload commands command, reloading..."),await p(U.ReloadCommands);break;case"re":console.log("Received reload events command, reloading..."),await p(U.ReloadEvents);break}}),a.on("change",C),a.on("add",C),a.on("unlink",C),a.on("unlinkDir",C),a.on("error",f=>{console.error(f)}),s=await Pe(o);let P=performance.now();console.log(`${m.greenBright("Development server started in")} ${m.yellowBright(`${(P-e).toFixed(2)}ms`)}
|
|
49
|
-
${m.greenBright("Watching for changes in")} ${m.yellowBright("src")} ${m.greenBright("directory")}
|
|
50
|
-
|
|
51
|
-
${m.greenBright("Commands:")}
|
|
52
|
-
${m.yellowBright("r")} - Restart the server
|
|
53
|
-
${m.yellowBright("rc")} - Reload all commands
|
|
54
|
-
${m.yellowBright("re")} - Reload all events`)}var jn,Hn,at,Gn,pr,fr,Vn=l(()=>{"use strict";n();jn=require("path");le();L();rt();it();Hn=require("chokidar");he();T();at=require("timers/promises"),Gn=require("crypto");j();B();r(Pe,"buildAndStart");pr=r(t=>t.replaceAll("\\","/").includes("src/app/commands"),"isCommandSource"),fr=r(t=>t.replaceAll("\\","/").includes("src/app/events"),"isEventSource");r(hr,"bootstrapDevelopmentServer")});async function Wn(t){return Re||(Re=await import("ora")),(Re.default||Re)({text:t,color:"cyan"})}var Re,qn=l(()=>{"use strict";n();r(Wn,"createSpinner")});var zn={};Y(zn,{bootstrapProductionServer:()=>gr,createProductionBuild:()=>Cr});async function gr(t){process.env.COMMANDKIT_BOOTSTRAP_MODE="production";let e=t||process.cwd(),o=await $(e),i=de(o.distDir);return(0,Jn.existsSync)(i)||A("Could not locate the entrypoint. Did you forget to build the application? Run 'commandkit build' to build the application first."),Me(i,e,!1)}async function Cr(t){process.env.COMMANDKIT_BOOTSTRAP_MODE="production";let e=t||process.cwd(),o=await $(e),i=await Wn(`Creating an optimized production build
|
|
55
|
-
`);i.start(),await Ie({configPath:e,isDev:!1,plugins:o.plugins.filter(a=>ue(a)),esbuildPlugins:o.esbuildPlugins}),i.succeed("Production build completed!")}var Jn,Yn=l(()=>{"use strict";n();le();rt();Jn=require("fs");B();it();L();qn();r(gr,"bootstrapProductionServer");r(Cr,"createProductionBuild")});var Zn={};Y(Zn,{generateCommand:()=>vr,generateEvent:()=>Er});function Qn(){return(0,oe.existsSync)((0,I.join)(st,"tsconfig.json"))?"ts":"js"}function br(t){return`import type { CommandData, ChatInputCommand, MessageCommand } from 'commandkit';
|
|
56
|
-
|
|
57
|
-
export const command: CommandData = {
|
|
58
|
-
name: '${t}',
|
|
59
|
-
description: '${t} command',
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const chatInput: ChatInputCommand = async (ctx) => {
|
|
63
|
-
await ctx.interaction.reply('Hello from ${t}!');
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const message: MessageCommand = async (ctx) => {
|
|
67
|
-
await ctx.message.reply('Hello from ${t}!');
|
|
68
|
-
};
|
|
69
|
-
`}function wr(t){return`/**
|
|
70
|
-
* @type {import('commandkit').CommandData}
|
|
71
|
-
*/
|
|
72
|
-
export const command = {
|
|
73
|
-
name: '${t}',
|
|
74
|
-
description: '${t} command',
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @type {import('commandkit').ChatInputCommand}
|
|
79
|
-
*/
|
|
80
|
-
export const chatInput = async (ctx) => {
|
|
81
|
-
await ctx.interaction.reply('Hello from ${t}!');
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @type {import('commandkit').MessageCommand}
|
|
86
|
-
*/
|
|
87
|
-
export const message = async (ctx) => {
|
|
88
|
-
await ctx.message.reply('Hello from ${t}!');
|
|
89
|
-
};
|
|
90
|
-
`}async function vr(t,e){let o=(0,I.join)(e||yr);(0,oe.existsSync)(o)||await(0,F.mkdir)(o,{recursive:!0});let i=Qn(),a=i==="ts",s=`${t}.${i}`;(0,oe.existsSync)((0,I.join)(o,s))&&A(`Command ${t} already exists.`);let d=a?br(t):wr(t);await(0,F.writeFile)((0,I.join)(o,s),d),console.log(m.green(`Command ${m.magenta(t)} created at ${m.blue(Xn(`${o}/${s}`))}`))}async function Er(t,e){let o=(0,I.join)(e||xr,t);(0,oe.existsSync)(o)||await(0,F.mkdir)(o,{recursive:!0});let a=`event.${Qn()}`;if((0,oe.existsSync)((0,I.join)(o,a))){let d=(await(0,F.readdir)(o)).length;a=`${String(d).padStart(2,"0")}_${a}`}let s=`
|
|
91
|
-
export default async function on${t[0].toUpperCase()+t.slice(1)}() {
|
|
92
|
-
console.log('${t} event fired!');
|
|
93
|
-
};
|
|
94
|
-
`.trim();await(0,F.writeFile)((0,I.join)(o,a),s),console.log(m.green(`Event ${m.magenta(t)} created at ${m.blue(Xn(o))}/${m.magenta(a)}`))}var F,I,oe,st,yr,xr,Xn,eo=l(()=>{"use strict";n();F=require("fs/promises"),I=require("path");B();oe=require("fs");T();st=process.cwd(),yr=(0,I.join)(st,"src/app/commands"),xr=(0,I.join)(st,"src/app/events"),Xn=r(t=>t.replace(process.cwd(),".").replace(/\\/g,"/"),"formatPath");r(Qn,"determineExtension");r(br,"TS_COMMAND_SOURCE");r(wr,"JS_COMMAND_SOURCE");r(vr,"generateCommand");r(Er,"generateEvent")});var to={};Y(to,{version:()=>lt});var lt,ct=l(()=>{"use strict";n();lt="1.0.0-dev.20250529020123"});var oo={};Y(oo,{showInformation:()=>Sr});function ce(t){try{let e=require.resolve(`${t}/package.json`);return require(e).version}catch{try{let o=[N.default.join(process.cwd(),"node_modules",t),N.default.join(process.cwd(),"..","..","node_modules",t),N.default.join(process.cwd(),"..","..",".pnpm",t),N.default.join(process.cwd(),"..","..","node_modules",".pnpm",t)];for(let a of o){let s=N.default.join(a,"package.json");if(J.default.existsSync(s))return JSON.parse(J.default.readFileSync(s,"utf8")).version}let i=N.default.join(process.cwd(),"..","..","node_modules",".pnpm");if(J.default.existsSync(i)){let s=J.default.readdirSync(i).find(d=>d.startsWith(`${t.replace("/","+")}@`));if(s){let d=N.default.join(i,s,"node_modules",t,"package.json");if(J.default.existsSync(d))return JSON.parse(J.default.readFileSync(d,"utf8")).version}}return null}catch{return null}}}function me(t){try{return(0,no.execSync)(`${t} --version`).toString().trim()}catch{return null}}async function Sr(){let t="Deno"in globalThis&&typeof Deno<"u"?"Deno":"Bun"in globalThis&&typeof Bun<"u"?"Bun":"Node.js",e={"Operating System":{Platform:process.platform,Arch:process.arch,Version:De.default.version(),"Available Memory (MB)":Math.round(De.default.totalmem()/1024/1024),"Available CPU cores":De.default.cpus().length},Runtime:t,Binaries:{Node:process.version,npm:me("npm")||"N/A",Yarn:me("yarn")||"N/A",pnpm:me("pnpm")||"N/A",Bun:me("bun")||"N/A",Deno:(me("deno")||"N/A").replace(/\n|\r/g," ")},"Relevant Packages":{commandkit:lt,"discord.js":ce("discord.js")||"N/A",typescript:ce("typescript")||"N/A",esbuild:ce("esbuild")||"N/A",tsup:ce("tsup")||"N/A",...Mr.reduce((i,a)=>(i[a]=ce(a)||"N/A",i),{})}},o="";for(let[i,a]of Object.entries(e)){if(o+=`${i}:
|
|
95
|
-
`,typeof a=="string"){o+=` ${a}
|
|
96
|
-
|
|
97
|
-
`;continue}for(let[s,d]of Object.entries(a))o+=` ${s}: ${d}
|
|
98
|
-
`;o+=`
|
|
99
|
-
`}console.log(o.trim())}var De,no,J,N,Mr,ro=l(()=>{"use strict";n();De=x(require("os")),no=require("child_process");ct();J=x(require("fs")),N=x(require("path")),Mr=["@commandkit/cache","@commandkit/devtools","@commandkit/i18n","@commandkit/legacy","@commandkit/redis"];r(ce,"findPackageVersion");r(me,"getBinaryVersion");r(Sr,"showInformation")});var Pr={};Y(Pr,{bootstrapCommandkitCLI:()=>Ir});module.exports=go(Pr);n();var io=require("fs"),ao=require("fs/promises"),so=require("path");ae();async function Ir(t,e){process.title="CommandKit CLI";let{Command:o}=await import("commander"),{bootstrapDevelopmentServer:i}=await Promise.resolve().then(()=>(Vn(),_n)),{bootstrapProductionServer:a,createProductionBuild:s}=await Promise.resolve().then(()=>(Yn(),zn)),{generateCommand:d,generateEvent:p}=await Promise.resolve().then(()=>(eo(),Zn)),{version:u}=await Promise.resolve().then(()=>(ct(),to)),{showInformation:g}=await Promise.resolve().then(()=>(ro(),oo)),C=new o("commandkit");C.command("dev").version(u).description("Start your bot in development mode.").option("-c, --config [path]","Path to your commandkit config file.","./commandkit.js").action(()=>{let f=C.opts();i(f.config)}),C.command("info").description("Show information about the system which can be used to report bugs.").action(async()=>{await g()}),C.command("start").description("Start your bot in production mode after running the build command.").option("-c, --config [path]","Path to your commandkit config file.").action(()=>{let f=C.opts();a(f.config)}),C.command("build").description("Build your project for production usage.").option("-c, --config [path]","Path to your commandkit config file.").action(()=>{let f=C.opts();return s(f.config)}),C.command("create").description("Create new commands or events files").option("-c, --command","Create a new command").option("-e, --event","Create a new event").argument("<name>","The name of the command or event").action(async(f,h)=>{h.command?await d(f):h.event?await p(f):console.error("Please specify what to create: --command or --event")});let P=(0,so.join)(process.cwd(),"node_modules","commandkit-types");(0,io.existsSync)(P)||(await(0,ao.mkdir)(P,{recursive:!0}).catch(()=>{}),await ie(!0).catch(()=>{})),await C.parseAsync(t,e)}r(Ir,"bootstrapCommandkitCLI");0&&(module.exports={bootstrapCommandkitCLI});
|
|
100
|
-
//# sourceMappingURL=init.js.map
|
|
5
|
+
exports.bootstrapCommandkitCLI = require_init.bootstrapCommandkitCLI;
|
package/dist/cli/parse-env.d.ts
CHANGED