commandkit 0.1.10 → 0.1.11-dev.20240203230231

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.
Files changed (328) hide show
  1. package/bin/index.cjs +3 -0
  2. package/dist/CommandKit--SA9LcIq.d.mts +452 -0
  3. package/dist/CommandKit-GIHMEeqf.d.ts +452 -0
  4. package/dist/CommandKit.d.mts +5 -0
  5. package/dist/CommandKit.d.ts +5 -0
  6. package/dist/CommandKit.js +11 -0
  7. package/dist/CommandKit.js.map +1 -0
  8. package/dist/CommandKit.mjs +2 -0
  9. package/dist/CommandKit.mjs.map +1 -0
  10. package/dist/bootstrap/client.d.mts +13 -0
  11. package/dist/bootstrap/client.d.ts +13 -0
  12. package/dist/bootstrap/client.js +2 -0
  13. package/dist/bootstrap/client.js.map +1 -0
  14. package/dist/bootstrap/client.mjs +2 -0
  15. package/dist/bootstrap/client.mjs.map +1 -0
  16. package/dist/bootstrap/loadEnv.d.mts +3 -0
  17. package/dist/bootstrap/loadEnv.d.ts +3 -0
  18. package/dist/bootstrap/loadEnv.js +2 -0
  19. package/dist/bootstrap/loadEnv.js.map +1 -0
  20. package/dist/bootstrap/loadEnv.mjs +2 -0
  21. package/dist/bootstrap/loadEnv.mjs.map +1 -0
  22. package/dist/chunk-5AIBE2QR.mjs +2 -0
  23. package/dist/chunk-5AIBE2QR.mjs.map +1 -0
  24. package/dist/chunk-6CLMSPNA.mjs +2 -0
  25. package/dist/chunk-6CLMSPNA.mjs.map +1 -0
  26. package/dist/chunk-77LPS2WP.mjs +2 -0
  27. package/dist/chunk-77LPS2WP.mjs.map +1 -0
  28. package/dist/chunk-7KD7ZCH6.mjs +2 -0
  29. package/dist/chunk-7KD7ZCH6.mjs.map +1 -0
  30. package/dist/chunk-BCQP4DZP.mjs +2 -0
  31. package/dist/chunk-BCQP4DZP.mjs.map +1 -0
  32. package/dist/chunk-BJCWVCAY.mjs +2 -0
  33. package/dist/chunk-BJCWVCAY.mjs.map +1 -0
  34. package/dist/chunk-BXBLPEWT.mjs +7 -0
  35. package/dist/chunk-BXBLPEWT.mjs.map +1 -0
  36. package/dist/chunk-CHI4NRSH.mjs +2 -0
  37. package/dist/chunk-CHI4NRSH.mjs.map +1 -0
  38. package/dist/chunk-DEB7FLUS.mjs +2 -0
  39. package/dist/chunk-DEB7FLUS.mjs.map +1 -0
  40. package/dist/chunk-FQGSVSCT.mjs +2 -0
  41. package/dist/chunk-FQGSVSCT.mjs.map +1 -0
  42. package/dist/chunk-IFTUM7TS.mjs +2 -0
  43. package/dist/chunk-IFTUM7TS.mjs.map +1 -0
  44. package/dist/chunk-KATLDJ7Z.mjs +2 -0
  45. package/dist/chunk-KATLDJ7Z.mjs.map +1 -0
  46. package/dist/chunk-KUU3KDAE.mjs +2 -0
  47. package/dist/chunk-KUU3KDAE.mjs.map +1 -0
  48. package/dist/chunk-M5FMJETI.mjs +1 -0
  49. package/dist/chunk-M5FMJETI.mjs.map +1 -0
  50. package/dist/chunk-PFU3PH6M.mjs +1 -0
  51. package/dist/chunk-PFU3PH6M.mjs.map +1 -0
  52. package/dist/chunk-Q7UFCVZL.mjs +2 -0
  53. package/dist/chunk-Q7UFCVZL.mjs.map +1 -0
  54. package/dist/chunk-QC2F7O3S.mjs +2 -0
  55. package/dist/chunk-QC2F7O3S.mjs.map +1 -0
  56. package/dist/chunk-QYJ4DE3N.mjs +2 -0
  57. package/dist/chunk-QYJ4DE3N.mjs.map +1 -0
  58. package/dist/chunk-R6PIHRXD.mjs +2 -0
  59. package/dist/chunk-R6PIHRXD.mjs.map +1 -0
  60. package/dist/chunk-RQQKHSL6.mjs +4 -0
  61. package/dist/chunk-RQQKHSL6.mjs.map +1 -0
  62. package/dist/chunk-SB3FAFCD.mjs +2 -0
  63. package/dist/chunk-SB3FAFCD.mjs.map +1 -0
  64. package/dist/chunk-SXUJOOQY.mjs +4 -0
  65. package/dist/chunk-SXUJOOQY.mjs.map +1 -0
  66. package/dist/chunk-SYOEMO4R.mjs +2 -0
  67. package/dist/chunk-SYOEMO4R.mjs.map +1 -0
  68. package/dist/chunk-TZXZ3UZS.mjs +2 -0
  69. package/dist/chunk-TZXZ3UZS.mjs.map +1 -0
  70. package/dist/chunk-UV2LVAQV.mjs +2 -0
  71. package/dist/chunk-UV2LVAQV.mjs.map +1 -0
  72. package/dist/chunk-VURGPMLB.mjs +2 -0
  73. package/dist/chunk-VURGPMLB.mjs.map +1 -0
  74. package/dist/chunk-ZJRAI4W5.mjs +2 -0
  75. package/dist/chunk-ZJRAI4W5.mjs.map +1 -0
  76. package/dist/components/ButtonKit.d.mts +55 -0
  77. package/dist/components/ButtonKit.d.ts +55 -0
  78. package/dist/components/ButtonKit.js +2 -0
  79. package/dist/components/ButtonKit.js.map +1 -0
  80. package/dist/components/ButtonKit.mjs +2 -0
  81. package/dist/components/ButtonKit.mjs.map +1 -0
  82. package/dist/components/index.d.mts +2 -0
  83. package/dist/components/index.d.ts +2 -0
  84. package/dist/components/index.js +2 -0
  85. package/dist/components/index.js.map +1 -0
  86. package/dist/components/index.mjs +2 -0
  87. package/dist/components/index.mjs.map +1 -0
  88. package/dist/config.d.mts +55 -0
  89. package/dist/config.d.ts +55 -0
  90. package/dist/config.js +2 -0
  91. package/dist/config.js.map +1 -0
  92. package/dist/config.mjs +2 -0
  93. package/dist/config.mjs.map +1 -0
  94. package/dist/environment/actions/development.d.mts +8 -0
  95. package/dist/environment/actions/development.d.ts +8 -0
  96. package/dist/environment/actions/development.js +2 -0
  97. package/dist/environment/actions/development.js.map +1 -0
  98. package/dist/environment/actions/development.mjs +2 -0
  99. package/dist/environment/actions/development.mjs.map +1 -0
  100. package/dist/environment/bundler/bundle.d.mts +3 -0
  101. package/dist/environment/bundler/bundle.d.ts +3 -0
  102. package/dist/environment/bundler/bundle.js +2 -0
  103. package/dist/environment/bundler/bundle.js.map +1 -0
  104. package/dist/environment/bundler/bundle.mjs +2 -0
  105. package/dist/environment/bundler/bundle.mjs.map +1 -0
  106. package/dist/environment/bundler/shims.d.mts +3 -0
  107. package/dist/environment/bundler/shims.d.ts +3 -0
  108. package/dist/environment/bundler/shims.js +11 -0
  109. package/dist/environment/bundler/shims.js.map +1 -0
  110. package/dist/environment/bundler/shims.mjs +11 -0
  111. package/dist/environment/bundler/shims.mjs.map +1 -0
  112. package/dist/environment/cli.d.mts +2 -0
  113. package/dist/environment/cli.d.ts +2 -0
  114. package/dist/environment/cli.js +2 -0
  115. package/dist/environment/cli.js.map +1 -0
  116. package/dist/environment/cli.mjs +2 -0
  117. package/dist/environment/cli.mjs.map +1 -0
  118. package/dist/environment/common/config.d.mts +7 -0
  119. package/dist/environment/common/config.d.ts +7 -0
  120. package/dist/environment/common/config.js +2 -0
  121. package/dist/environment/common/config.js.map +1 -0
  122. package/dist/environment/common/config.mjs +2 -0
  123. package/dist/environment/common/config.mjs.map +1 -0
  124. package/dist/environment/common/logger.d.mts +9 -0
  125. package/dist/environment/common/logger.d.ts +9 -0
  126. package/dist/environment/common/logger.js +2 -0
  127. package/dist/environment/common/logger.js.map +1 -0
  128. package/dist/environment/common/logger.mjs +2 -0
  129. package/dist/environment/common/logger.mjs.map +1 -0
  130. package/dist/handlers/command-handler/CommandHandler.d.mts +5 -0
  131. package/dist/handlers/command-handler/CommandHandler.d.ts +5 -0
  132. package/dist/handlers/command-handler/CommandHandler.js +11 -0
  133. package/dist/handlers/command-handler/CommandHandler.js.map +1 -0
  134. package/dist/handlers/command-handler/CommandHandler.mjs +2 -0
  135. package/dist/handlers/command-handler/CommandHandler.mjs.map +1 -0
  136. package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.mts +35 -0
  137. package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.ts +35 -0
  138. package/dist/handlers/command-handler/functions/loadCommandsWithRest.js +4 -0
  139. package/dist/handlers/command-handler/functions/loadCommandsWithRest.js.map +1 -0
  140. package/dist/handlers/command-handler/functions/loadCommandsWithRest.mjs +2 -0
  141. package/dist/handlers/command-handler/functions/loadCommandsWithRest.mjs.map +1 -0
  142. package/dist/handlers/command-handler/functions/registerCommands.d.mts +20 -0
  143. package/dist/handlers/command-handler/functions/registerCommands.d.ts +20 -0
  144. package/dist/handlers/command-handler/functions/registerCommands.js +7 -0
  145. package/dist/handlers/command-handler/functions/registerCommands.js.map +1 -0
  146. package/dist/handlers/command-handler/functions/registerCommands.mjs +2 -0
  147. package/dist/handlers/command-handler/functions/registerCommands.mjs.map +1 -0
  148. package/dist/handlers/command-handler/typings.d.mts +5 -0
  149. package/dist/handlers/command-handler/typings.d.ts +5 -0
  150. package/dist/handlers/command-handler/typings.js +2 -0
  151. package/dist/handlers/command-handler/typings.js.map +1 -0
  152. package/dist/handlers/command-handler/typings.mjs +1 -0
  153. package/dist/handlers/command-handler/typings.mjs.map +1 -0
  154. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.d.mts +9 -0
  155. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.d.ts +9 -0
  156. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.js +2 -0
  157. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.js.map +1 -0
  158. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.mjs +2 -0
  159. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.mjs.map +1 -0
  160. package/dist/handlers/command-handler/validations/devOnly.d.mts +9 -0
  161. package/dist/handlers/command-handler/validations/devOnly.d.ts +9 -0
  162. package/dist/handlers/command-handler/validations/devOnly.js +2 -0
  163. package/dist/handlers/command-handler/validations/devOnly.js.map +1 -0
  164. package/dist/handlers/command-handler/validations/devOnly.mjs +2 -0
  165. package/dist/handlers/command-handler/validations/devOnly.mjs.map +1 -0
  166. package/dist/handlers/command-handler/validations/index.d.mts +10 -0
  167. package/dist/handlers/command-handler/validations/index.d.ts +10 -0
  168. package/dist/handlers/command-handler/validations/index.js +4 -0
  169. package/dist/handlers/command-handler/validations/index.js.map +1 -0
  170. package/dist/handlers/command-handler/validations/index.mjs +2 -0
  171. package/dist/handlers/command-handler/validations/index.mjs.map +1 -0
  172. package/dist/handlers/command-handler/validations/permissions.d.mts +9 -0
  173. package/dist/handlers/command-handler/validations/permissions.d.ts +9 -0
  174. package/dist/handlers/command-handler/validations/permissions.js +4 -0
  175. package/dist/handlers/command-handler/validations/permissions.js.map +1 -0
  176. package/dist/handlers/command-handler/validations/permissions.mjs +2 -0
  177. package/dist/handlers/command-handler/validations/permissions.mjs.map +1 -0
  178. package/dist/handlers/event-handler/EventHandler.d.mts +5 -0
  179. package/dist/handlers/event-handler/EventHandler.d.ts +5 -0
  180. package/dist/handlers/event-handler/EventHandler.js +2 -0
  181. package/dist/handlers/event-handler/EventHandler.js.map +1 -0
  182. package/dist/handlers/event-handler/EventHandler.mjs +2 -0
  183. package/dist/handlers/event-handler/EventHandler.mjs.map +1 -0
  184. package/dist/handlers/event-handler/typings.d.mts +5 -0
  185. package/dist/handlers/event-handler/typings.d.ts +5 -0
  186. package/dist/handlers/event-handler/typings.js +2 -0
  187. package/dist/handlers/event-handler/typings.js.map +1 -0
  188. package/dist/handlers/event-handler/typings.mjs +1 -0
  189. package/dist/handlers/event-handler/typings.mjs.map +1 -0
  190. package/dist/handlers/index.d.mts +5 -0
  191. package/dist/handlers/index.d.ts +5 -0
  192. package/dist/handlers/index.js +11 -0
  193. package/dist/handlers/index.js.map +1 -0
  194. package/dist/handlers/index.mjs +2 -0
  195. package/dist/handlers/index.mjs.map +1 -0
  196. package/dist/handlers/validation-handler/ValidationHandler.d.mts +14 -0
  197. package/dist/handlers/validation-handler/ValidationHandler.d.ts +14 -0
  198. package/dist/handlers/validation-handler/ValidationHandler.js +2 -0
  199. package/dist/handlers/validation-handler/ValidationHandler.js.map +1 -0
  200. package/dist/handlers/validation-handler/ValidationHandler.mjs +2 -0
  201. package/dist/handlers/validation-handler/ValidationHandler.mjs.map +1 -0
  202. package/dist/handlers/validation-handler/typings.d.mts +14 -0
  203. package/dist/handlers/validation-handler/typings.d.ts +14 -0
  204. package/dist/handlers/validation-handler/typings.js +2 -0
  205. package/dist/handlers/validation-handler/typings.js.map +1 -0
  206. package/dist/handlers/validation-handler/typings.mjs +1 -0
  207. package/dist/handlers/validation-handler/typings.mjs.map +1 -0
  208. package/dist/hooks/common.d.mts +12 -0
  209. package/dist/hooks/common.d.ts +12 -0
  210. package/dist/hooks/common.js +11 -0
  211. package/dist/hooks/common.js.map +1 -0
  212. package/dist/hooks/common.mjs +2 -0
  213. package/dist/hooks/common.mjs.map +1 -0
  214. package/dist/hooks/index.d.mts +14 -0
  215. package/dist/hooks/index.d.ts +14 -0
  216. package/dist/hooks/index.js +11 -0
  217. package/dist/hooks/index.js.map +1 -0
  218. package/dist/hooks/index.mjs +2 -0
  219. package/dist/hooks/index.mjs.map +1 -0
  220. package/dist/hooks/response.d.mts +7 -0
  221. package/dist/hooks/response.d.ts +7 -0
  222. package/dist/hooks/response.js +11 -0
  223. package/dist/hooks/response.js.map +1 -0
  224. package/dist/hooks/response.mjs +2 -0
  225. package/dist/hooks/response.mjs.map +1 -0
  226. package/dist/hooks/useChannel.d.mts +5 -0
  227. package/dist/hooks/useChannel.d.ts +5 -0
  228. package/dist/hooks/useChannel.js +11 -0
  229. package/dist/hooks/useChannel.js.map +1 -0
  230. package/dist/hooks/useChannel.mjs +2 -0
  231. package/dist/hooks/useChannel.mjs.map +1 -0
  232. package/dist/hooks/useClient.d.mts +5 -0
  233. package/dist/hooks/useClient.d.ts +5 -0
  234. package/dist/hooks/useClient.js +11 -0
  235. package/dist/hooks/useClient.js.map +1 -0
  236. package/dist/hooks/useClient.mjs +2 -0
  237. package/dist/hooks/useClient.mjs.map +1 -0
  238. package/dist/hooks/useCommandData.d.mts +5 -0
  239. package/dist/hooks/useCommandData.d.ts +5 -0
  240. package/dist/hooks/useCommandData.js +11 -0
  241. package/dist/hooks/useCommandData.js.map +1 -0
  242. package/dist/hooks/useCommandData.mjs +2 -0
  243. package/dist/hooks/useCommandData.mjs.map +1 -0
  244. package/dist/hooks/useCommandKit.d.mts +9 -0
  245. package/dist/hooks/useCommandKit.d.ts +9 -0
  246. package/dist/hooks/useCommandKit.js +11 -0
  247. package/dist/hooks/useCommandKit.js.map +1 -0
  248. package/dist/hooks/useCommandKit.mjs +2 -0
  249. package/dist/hooks/useCommandKit.mjs.map +1 -0
  250. package/dist/hooks/useGuild.d.mts +5 -0
  251. package/dist/hooks/useGuild.d.ts +5 -0
  252. package/dist/hooks/useGuild.js +11 -0
  253. package/dist/hooks/useGuild.js.map +1 -0
  254. package/dist/hooks/useGuild.mjs +2 -0
  255. package/dist/hooks/useGuild.mjs.map +1 -0
  256. package/dist/hooks/useInteraction.d.mts +9 -0
  257. package/dist/hooks/useInteraction.d.ts +9 -0
  258. package/dist/hooks/useInteraction.js +11 -0
  259. package/dist/hooks/useInteraction.js.map +1 -0
  260. package/dist/hooks/useInteraction.mjs +2 -0
  261. package/dist/hooks/useInteraction.mjs.map +1 -0
  262. package/dist/hooks/useMember.d.mts +5 -0
  263. package/dist/hooks/useMember.d.ts +5 -0
  264. package/dist/hooks/useMember.js +11 -0
  265. package/dist/hooks/useMember.js.map +1 -0
  266. package/dist/hooks/useMember.mjs +2 -0
  267. package/dist/hooks/useMember.mjs.map +1 -0
  268. package/dist/hooks/useUser.d.mts +5 -0
  269. package/dist/hooks/useUser.d.ts +5 -0
  270. package/dist/hooks/useUser.js +11 -0
  271. package/dist/hooks/useUser.js.map +1 -0
  272. package/dist/hooks/useUser.mjs +2 -0
  273. package/dist/hooks/useUser.mjs.map +1 -0
  274. package/dist/index.d.mts +21 -375
  275. package/dist/index.d.ts +21 -375
  276. package/dist/index.js +11 -1122
  277. package/dist/index.js.map +1 -0
  278. package/dist/index.mjs +2 -1092
  279. package/dist/index.mjs.map +1 -0
  280. package/dist/types/index.d.mts +5 -0
  281. package/dist/types/index.d.ts +5 -0
  282. package/dist/types/index.js +2 -0
  283. package/dist/types/index.js.map +1 -0
  284. package/dist/types/index.mjs +2 -0
  285. package/dist/types/index.mjs.map +1 -0
  286. package/dist/typings.d.mts +5 -0
  287. package/dist/typings.d.ts +5 -0
  288. package/dist/typings.js +2 -0
  289. package/dist/typings.js.map +1 -0
  290. package/dist/typings.mjs +1 -0
  291. package/dist/typings.mjs.map +1 -0
  292. package/dist/utils/clone.d.mts +3 -0
  293. package/dist/utils/clone.d.ts +3 -0
  294. package/dist/utils/clone.js +2 -0
  295. package/dist/utils/clone.js.map +1 -0
  296. package/dist/utils/clone.mjs +2 -0
  297. package/dist/utils/clone.mjs.map +1 -0
  298. package/dist/utils/colors.d.mts +27 -0
  299. package/dist/utils/colors.d.ts +27 -0
  300. package/dist/utils/colors.js +2 -0
  301. package/dist/utils/colors.js.map +1 -0
  302. package/dist/utils/colors.mjs +2 -0
  303. package/dist/utils/colors.mjs.map +1 -0
  304. package/dist/utils/get-paths.d.mts +4 -0
  305. package/dist/utils/get-paths.d.ts +4 -0
  306. package/dist/utils/get-paths.js +2 -0
  307. package/dist/utils/get-paths.js.map +1 -0
  308. package/dist/utils/get-paths.mjs +2 -0
  309. package/dist/utils/get-paths.mjs.map +1 -0
  310. package/dist/utils/resolve-file-url.d.mts +8 -0
  311. package/dist/utils/resolve-file-url.d.ts +8 -0
  312. package/dist/utils/resolve-file-url.js +2 -0
  313. package/dist/utils/resolve-file-url.js.map +1 -0
  314. package/dist/utils/resolve-file-url.mjs +2 -0
  315. package/dist/utils/resolve-file-url.mjs.map +1 -0
  316. package/dist/utils/signal.d.mts +21 -0
  317. package/dist/utils/signal.d.ts +21 -0
  318. package/dist/utils/signal.js +2 -0
  319. package/dist/utils/signal.js.map +1 -0
  320. package/dist/utils/signal.mjs +2 -0
  321. package/dist/utils/signal.mjs.map +1 -0
  322. package/package.json +66 -55
  323. package/bin/build.mjs +0 -107
  324. package/bin/common.mjs +0 -102
  325. package/bin/development.mjs +0 -168
  326. package/bin/index.mjs +0 -39
  327. package/bin/parse-env.mjs +0 -61
  328. package/bin/production.mjs +0 -83
package/bin/common.mjs DELETED
@@ -1,102 +0,0 @@
1
- // @ts-check
2
-
3
- import { rimrafSync } from 'rimraf';
4
- import { join } from 'node:path';
5
- import fs from 'node:fs';
6
-
7
- const resetColor = '\x1b[0m';
8
-
9
- export const Colors = {
10
- reset: (text) => `${text}${resetColor}`,
11
- bright: (text) => `\x1b[1m${text}${resetColor}`,
12
- dim: (text) => `\x1b[2m${text}${resetColor}`,
13
- underscore: (text) => `\x1b[4m${text}${resetColor}`,
14
- blink: (text) => `\x1b[5m${text}${resetColor}`,
15
- reverse: (text) => `\x1b[7m${text}${resetColor}`,
16
- hidden: (text) => `\x1b[8m${text}${resetColor}`,
17
-
18
- black: (text) => `\x1b[30m${text}${resetColor}`,
19
- red: (text) => `\x1b[31m${text}${resetColor}`,
20
- green: (text) => `\x1b[32m${text}${resetColor}`,
21
- yellow: (text) => `\x1b[33m${text}${resetColor}`,
22
- blue: (text) => `\x1b[34m${text}${resetColor}`,
23
- magenta: (text) => `\x1b[35m${text}${resetColor}`,
24
- cyan: (text) => `\x1b[36m${text}${resetColor}`,
25
- white: (text) => `\x1b[37m${text}${resetColor}`,
26
-
27
- bgBlack: (text) => `\x1b[40m${text}${resetColor}`,
28
- bgRed: (text) => `\x1b[41m${text}${resetColor}`,
29
- bgGreen: (text) => `\x1b[42m${text}${resetColor}`,
30
- bgYellow: (text) => `\x1b[43m${text}${resetColor}`,
31
- bgBlue: (text) => `\x1b[44m${text}${resetColor}`,
32
- bgMagenta: (text) => `\x1b[45m${text}${resetColor}`,
33
- bgCyan: (text) => `\x1b[46m${text}${resetColor}`,
34
- bgWhite: (text) => `\x1b[47m${text}${resetColor}`,
35
- };
36
-
37
- export function write(message) {
38
- process.stdout.write(message);
39
- process.stdout.write('\n');
40
- }
41
-
42
- /**
43
- * @returns {never}
44
- */
45
- export function panic(message) {
46
- write(Colors.red(`Error: ${message}`));
47
- process.exit(1);
48
- }
49
-
50
- export function findPackageJSON() {
51
- const cwd = process.cwd();
52
- const target = join(cwd, 'package.json');
53
-
54
- if (!fs.existsSync(target)) {
55
- panic('Could not find package.json in current directory.');
56
- }
57
-
58
- return JSON.parse(fs.readFileSync(target, 'utf8'));
59
- }
60
-
61
- const possibleFileNames = [
62
- 'commandkit.json',
63
- 'commandkit.config.json',
64
- 'commandkit.js',
65
- 'commandkit.config.js',
66
- 'commandkit.mjs',
67
- 'commandkit.config.mjs',
68
- 'commandkit.cjs',
69
- 'commandkit.config.cjs',
70
- ];
71
-
72
- export async function findCommandKitConfig(src) {
73
- const cwd = process.cwd();
74
- const locations = src ? [join(cwd, src)] : possibleFileNames.map((name) => join(cwd, name));
75
-
76
- for (const location of locations) {
77
- try {
78
- return await loadConfigInner(location);
79
- } catch (e) {
80
- continue;
81
- }
82
- }
83
-
84
- panic('Could not locate commandkit config.');
85
- }
86
-
87
- async function loadConfigInner(target) {
88
- const isJSON = target.endsWith('.json');
89
-
90
- /**
91
- * @type {import('..').CommandKitConfig}
92
- */
93
- const config = await import(`file://${target}`, {
94
- assert: isJSON ? { type: 'json' } : undefined,
95
- }).then((conf) => conf.default || conf);
96
-
97
- return config;
98
- }
99
-
100
- export function erase(dir) {
101
- rimrafSync(dir);
102
- }
@@ -1,168 +0,0 @@
1
- // @ts-check
2
- import { config as dotenv } from 'dotenv';
3
- import { join } from 'node:path';
4
- import { build } from 'tsup';
5
- import { Colors, erase, findCommandKitConfig, panic, write } from './common.mjs';
6
- import { parseEnv } from './parse-env.mjs';
7
- import child_process from 'node:child_process';
8
- import ora from 'ora';
9
- import { injectShims } from './build.mjs';
10
-
11
- const RESTARTING_MSG_PATTERN = /^Restarting '|".+'|"\n?$/;
12
- const FAILED_RUNNING_PATTERN = /^Failed running '.+'|"\n?$/;
13
-
14
- export async function bootstrapDevelopmentServer(opts) {
15
- const {
16
- src,
17
- main,
18
- watch = Boolean(opts.noWatch),
19
- nodeOptions = [],
20
- envExtra = true,
21
- clearRestartLogs = true,
22
- outDir,
23
- requirePolyfill,
24
- } = await findCommandKitConfig(opts.config);
25
-
26
- if (!src) {
27
- panic('Could not find src in commandkit.json');
28
- }
29
-
30
- if (!main) {
31
- panic('Could not find main in commandkit.json');
32
- }
33
-
34
- const watchMode = watch;
35
- const status = ora(Colors.green('Starting a development server...\n')).start();
36
- const start = performance.now();
37
-
38
- if (watchMode && !nodeOptions.includes('--watch')) {
39
- nodeOptions.push('--watch');
40
- } else if (!watchMode && nodeOptions.includes('--watch')) {
41
- nodeOptions.splice(nodeOptions.indexOf('--watch'), 1);
42
- }
43
-
44
- if (!nodeOptions.includes('--enable-source-maps')) {
45
- nodeOptions.push('--enable-source-maps');
46
- }
47
-
48
- erase('.commandkit');
49
-
50
- try {
51
- await build({
52
- clean: true,
53
- format: ['esm'],
54
- dts: false,
55
- skipNodeModulesBundle: true,
56
- minify: false,
57
- shims: true,
58
- sourcemap: 'inline',
59
- keepNames: true,
60
- outDir: '.commandkit',
61
- silent: true,
62
- entry: [src, '!dist', '!.commandkit', `!${outDir}`].filter(Boolean),
63
- watch: watchMode,
64
- async onSuccess() {
65
- return await injectShims('.commandkit', main, false, requirePolyfill);
66
- },
67
- });
68
-
69
- status.succeed(
70
- Colors.green(`Dev server started in ${(performance.now() - start).toFixed(2)}ms!\n`),
71
- );
72
-
73
- if (watchMode) write(Colors.cyan('Watching for file changes...\n'));
74
-
75
- const processEnv = {};
76
-
77
- const env = dotenv({
78
- path: join(process.cwd(), '.env'),
79
- // @ts-expect-error
80
- processEnv,
81
- });
82
-
83
- if (envExtra) {
84
- parseEnv(processEnv);
85
- }
86
-
87
- if (env.error) {
88
- write(Colors.yellow(`[DOTENV] Warning: ${env.error.message}`));
89
- }
90
-
91
- if (env.parsed) {
92
- write(Colors.blue('[DOTENV] Loaded .env file!'));
93
- }
94
-
95
- /**
96
- * @type {child_process.ChildProcessWithoutNullStreams}
97
- */
98
- const ps = child_process.spawn(
99
- 'node',
100
- [...nodeOptions, join(process.cwd(), '.commandkit', main)],
101
- {
102
- env: {
103
- ...process.env,
104
- ...processEnv,
105
- NODE_ENV: 'development',
106
- // @ts-expect-error
107
- COMMANDKIT_DEV: true,
108
- // @ts-expect-error
109
- COMMANDKIT_PRODUCTION: false,
110
- },
111
- cwd: process.cwd(),
112
- },
113
- );
114
-
115
- let isLastLogRestarting = false,
116
- hasStarted = false;
117
-
118
- ps.stdout.on('data', (data) => {
119
- const message = data.toString();
120
-
121
- if (FAILED_RUNNING_PATTERN.test(message)) {
122
- write(Colors.cyan('Failed running the bot, waiting for changes...'));
123
- isLastLogRestarting = false;
124
- if (!hasStarted) hasStarted = true;
125
- return;
126
- }
127
-
128
- if (clearRestartLogs && !RESTARTING_MSG_PATTERN.test(message)) {
129
- write(message);
130
- isLastLogRestarting = false;
131
- } else {
132
- if (isLastLogRestarting || !hasStarted) {
133
- if (!hasStarted) hasStarted = true;
134
- return;
135
- }
136
- write(Colors.cyan('⌀ Restarting the bot...'));
137
- isLastLogRestarting = true;
138
- }
139
-
140
- if (!hasStarted) hasStarted = true;
141
- });
142
-
143
- ps.stderr.on('data', (data) => {
144
- const message = data.toString();
145
-
146
- if (
147
- message.includes(
148
- 'ExperimentalWarning: Watch mode is an experimental feature and might change at any time',
149
- )
150
- )
151
- return;
152
-
153
- write(Colors.red(message));
154
- });
155
-
156
- ps.on('close', (code) => {
157
- write('\n');
158
- process.exit(code ?? 0);
159
- });
160
-
161
- ps.on('error', (err) => {
162
- panic(err);
163
- });
164
- } catch (e) {
165
- status.fail(`Error occurred after ${(performance.now() - start).toFixed(2)}ms!\n`);
166
- panic(e.stack ?? e);
167
- }
168
- }
package/bin/index.mjs DELETED
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // @ts-check
4
-
5
- import { Command } from 'commander';
6
- import { bootstrapDevelopmentServer } from './development.mjs';
7
- import { bootstrapProductionServer } from './production.mjs';
8
- import { bootstrapProductionBuild } from './build.mjs';
9
-
10
- const program = new Command('commandkit');
11
-
12
- program
13
- .command('dev')
14
- .description('Start your bot in development mode.')
15
- .option('-c, --config <path>', 'Path to your commandkit config file.', './commandkit.js')
16
- .action(() => {
17
- const options = program.opts();
18
- bootstrapDevelopmentServer(options);
19
- });
20
-
21
- program
22
- .command('start')
23
- .description('Start your bot in production mode after running the build command.')
24
- .option('-c, --config <path>', 'Path to your commandkit.json file.', './commandkit.js')
25
- .action(() => {
26
- const options = program.opts();
27
- bootstrapProductionServer(options.config);
28
- });
29
-
30
- program
31
- .command('build')
32
- .description('Build your project for production usage.')
33
- .option('-c, --config <path>', 'Path to your commandkit.json file.', './commandkit.json')
34
- .action(() => {
35
- const options = program.opts();
36
- bootstrapProductionBuild(options.config);
37
- });
38
-
39
- program.parse();
package/bin/parse-env.mjs DELETED
@@ -1,61 +0,0 @@
1
- // @ts-check
2
-
3
- import { randomUUID } from 'node:crypto';
4
-
5
- const valuesMap = {
6
- true: true,
7
- false: false,
8
- null: null,
9
- undefined: undefined,
10
- __UUIDv4__: () => randomUUID(),
11
- };
12
-
13
- const VALUE_PREFIXES = {
14
- JSON: 'JSON::',
15
- DATE: 'DATE::',
16
- };
17
-
18
- function catcher(fn) {
19
- try {
20
- fn();
21
- return true;
22
- } catch {
23
- return false;
24
- }
25
- }
26
-
27
- export function parseEnv(src) {
28
- for (const key in src) {
29
- const value = src[key];
30
-
31
- if (typeof value !== 'string') continue;
32
-
33
- if (value.startsWith(VALUE_PREFIXES.JSON)) {
34
- catcher(() => (src[key] = JSON.parse(value.replace(VALUE_PREFIXES.JSON, ''))));
35
- continue;
36
- }
37
-
38
- if (value.startsWith(VALUE_PREFIXES.DATE)) {
39
- src[key] = new Date(value.replace(VALUE_PREFIXES.DATE, ''));
40
- continue;
41
- }
42
-
43
- if (value.includes(',')) {
44
- src[key] = value.split(',').map((v) => v.trim());
45
- continue;
46
- }
47
-
48
- if (/^[0-9]+n$/.test(value)) {
49
- src[key] = BigInt(value);
50
- continue;
51
- }
52
-
53
- if (value in valuesMap) {
54
- src[key] =
55
- typeof valuesMap[value] === 'function' ? valuesMap[value]() : valuesMap[value];
56
- continue;
57
- }
58
- }
59
-
60
- return src;
61
- }
@@ -1,83 +0,0 @@
1
- // @ts-check
2
- import { config as dotenv } from 'dotenv';
3
- import { existsSync } from 'node:fs';
4
- import { join } from 'node:path';
5
- import { Colors, findCommandKitConfig, panic, write } from './common.mjs';
6
- import { parseEnv } from './parse-env.mjs';
7
- import child_process from 'node:child_process';
8
-
9
- export async function bootstrapProductionServer(config) {
10
- const {
11
- main,
12
- outDir = 'dist',
13
- envExtra = true,
14
- sourcemap,
15
- } = await findCommandKitConfig(config);
16
-
17
- if (!existsSync(join(process.cwd(), outDir, main))) {
18
- panic('Could not find production build, maybe run `commandkit build` first?');
19
- }
20
-
21
- try {
22
- const processEnv = {};
23
-
24
- const env = dotenv({
25
- path: join(process.cwd(), '.env'),
26
- // @ts-expect-error
27
- processEnv,
28
- });
29
-
30
- if (envExtra) {
31
- parseEnv(processEnv);
32
- }
33
-
34
- if (env.error) {
35
- write(Colors.yellow(`[DOTENV] Warning: ${env.error.message}`));
36
- }
37
-
38
- if (env.parsed) {
39
- write(Colors.blue('[DOTENV] Loaded .env file!'));
40
- }
41
-
42
- /**
43
- * @type {child_process.ChildProcessWithoutNullStreams}
44
- */
45
- const ps = child_process.spawn(
46
- 'node',
47
- [sourcemap ? '--enable-source-maps' : '', join(process.cwd(), outDir, main)].filter(
48
- Boolean,
49
- ),
50
- {
51
- env: {
52
- ...process.env,
53
- ...processEnv,
54
- NODE_ENV: 'production',
55
- // @ts-expect-error
56
- COMMANDKIT_DEV: false,
57
- // @ts-expect-error
58
- COMMANDKIT_PROD: true,
59
- },
60
- cwd: process.cwd(),
61
- },
62
- );
63
-
64
- ps.stdout.on('data', (data) => {
65
- write(data.toString());
66
- });
67
-
68
- ps.stderr.on('data', (data) => {
69
- write(Colors.red(data.toString()));
70
- });
71
-
72
- ps.on('close', (code) => {
73
- write('\n');
74
- process.exit(code ?? 0);
75
- });
76
-
77
- ps.on('error', (err) => {
78
- panic(err);
79
- });
80
- } catch (e) {
81
- panic(e);
82
- }
83
- }