kythia-core 0.11.0-beta → 0.12.0-beta

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 (260) hide show
  1. package/dist/Kythia.d.ts +45 -0
  2. package/dist/Kythia.d.ts.map +1 -0
  3. package/dist/Kythia.js +443 -0
  4. package/dist/Kythia.js.map +1 -0
  5. package/dist/KythiaClient.d.ts +3 -0
  6. package/dist/KythiaClient.d.ts.map +1 -0
  7. package/dist/KythiaClient.js +69 -0
  8. package/dist/KythiaClient.js.map +1 -0
  9. package/dist/cli/Command.d.ts +9 -0
  10. package/dist/cli/Command.d.ts.map +1 -0
  11. package/dist/cli/Command.js +19 -0
  12. package/dist/cli/Command.js.map +1 -0
  13. package/dist/cli/commands/CacheClearCommand.d.ts +8 -0
  14. package/dist/cli/commands/CacheClearCommand.d.ts.map +1 -0
  15. package/dist/cli/commands/CacheClearCommand.js +94 -0
  16. package/dist/cli/commands/CacheClearCommand.js.map +1 -0
  17. package/dist/cli/commands/LangCheckCommand.d.ts +7 -0
  18. package/dist/cli/commands/LangCheckCommand.d.ts.map +1 -0
  19. package/dist/cli/commands/LangCheckCommand.js +345 -0
  20. package/dist/cli/commands/LangCheckCommand.js.map +1 -0
  21. package/dist/cli/commands/LangTranslateCommand.d.ts +8 -0
  22. package/dist/cli/commands/LangTranslateCommand.d.ts.map +1 -0
  23. package/dist/cli/commands/LangTranslateCommand.js +221 -0
  24. package/dist/cli/commands/LangTranslateCommand.js.map +1 -0
  25. package/dist/cli/commands/MakeMigrationCommand.d.ts +7 -0
  26. package/dist/cli/commands/MakeMigrationCommand.d.ts.map +1 -0
  27. package/dist/cli/commands/MakeMigrationCommand.js +55 -0
  28. package/dist/cli/commands/MakeMigrationCommand.js.map +1 -0
  29. package/dist/cli/commands/MakeModelCommand.d.ts +7 -0
  30. package/dist/cli/commands/MakeModelCommand.d.ts.map +1 -0
  31. package/dist/cli/commands/MakeModelCommand.js +56 -0
  32. package/dist/cli/commands/MakeModelCommand.js.map +1 -0
  33. package/dist/cli/commands/MigrateCommand.d.ts +14 -0
  34. package/dist/cli/commands/MigrateCommand.d.ts.map +1 -0
  35. package/dist/cli/commands/MigrateCommand.js +190 -0
  36. package/dist/cli/commands/MigrateCommand.js.map +1 -0
  37. package/dist/cli/commands/NamespaceCommand.d.ts +7 -0
  38. package/dist/cli/commands/NamespaceCommand.d.ts.map +1 -0
  39. package/dist/cli/commands/NamespaceCommand.js +92 -0
  40. package/dist/cli/commands/NamespaceCommand.js.map +1 -0
  41. package/dist/cli/commands/StructureCommand.d.ts +7 -0
  42. package/dist/cli/commands/StructureCommand.d.ts.map +1 -0
  43. package/dist/cli/commands/StructureCommand.js +51 -0
  44. package/dist/cli/commands/StructureCommand.js.map +1 -0
  45. package/dist/cli/commands/UpversionCommand.d.ts +7 -0
  46. package/dist/cli/commands/UpversionCommand.d.ts.map +1 -0
  47. package/dist/cli/commands/UpversionCommand.js +68 -0
  48. package/dist/cli/commands/UpversionCommand.js.map +1 -0
  49. package/dist/cli/index.d.ts +3 -0
  50. package/dist/cli/index.d.ts.map +1 -0
  51. package/dist/cli/index.js +44 -0
  52. package/dist/cli/index.js.map +1 -0
  53. package/dist/cli/utils/db.d.ts +9 -0
  54. package/dist/cli/utils/db.d.ts.map +1 -0
  55. package/dist/cli/utils/db.js +90 -0
  56. package/dist/cli/utils/db.js.map +1 -0
  57. package/dist/database/KythiaMigrator.d.ts +4 -0
  58. package/dist/database/KythiaMigrator.d.ts.map +1 -0
  59. package/dist/database/KythiaMigrator.js +94 -0
  60. package/dist/database/KythiaMigrator.js.map +1 -0
  61. package/dist/database/KythiaModel.d.ts +83 -0
  62. package/dist/database/KythiaModel.d.ts.map +1 -0
  63. package/dist/database/KythiaModel.js +1121 -0
  64. package/dist/database/KythiaModel.js.map +1 -0
  65. package/dist/database/KythiaSequelize.d.ts +4 -0
  66. package/dist/database/KythiaSequelize.d.ts.map +1 -0
  67. package/dist/database/KythiaSequelize.js +99 -0
  68. package/dist/database/KythiaSequelize.js.map +1 -0
  69. package/dist/database/KythiaStorage.d.ts +21 -0
  70. package/dist/database/KythiaStorage.d.ts.map +1 -0
  71. package/dist/database/KythiaStorage.js +80 -0
  72. package/dist/database/KythiaStorage.js.map +1 -0
  73. package/dist/database/ModelLoader.d.ts +4 -0
  74. package/dist/database/ModelLoader.d.ts.map +1 -0
  75. package/dist/database/ModelLoader.js +54 -0
  76. package/dist/database/ModelLoader.js.map +1 -0
  77. package/dist/index.d.ts +10 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +36 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/lang/en.json +85 -0
  82. package/dist/managers/AddonManager.d.ts +45 -0
  83. package/dist/managers/AddonManager.d.ts.map +1 -0
  84. package/dist/managers/AddonManager.js +932 -0
  85. package/dist/managers/AddonManager.js.map +1 -0
  86. package/dist/managers/EventManager.d.ts +19 -0
  87. package/dist/managers/EventManager.d.ts.map +1 -0
  88. package/dist/managers/EventManager.js +55 -0
  89. package/dist/managers/EventManager.js.map +1 -0
  90. package/dist/managers/InteractionManager.d.ts +41 -0
  91. package/dist/managers/InteractionManager.d.ts.map +1 -0
  92. package/dist/managers/InteractionManager.js +441 -0
  93. package/dist/managers/InteractionManager.js.map +1 -0
  94. package/dist/managers/MiddlewareManager.d.ts +14 -0
  95. package/dist/managers/MiddlewareManager.d.ts.map +1 -0
  96. package/dist/managers/MiddlewareManager.js +75 -0
  97. package/dist/managers/MiddlewareManager.js.map +1 -0
  98. package/dist/managers/ShutdownManager.d.ts +22 -0
  99. package/dist/managers/ShutdownManager.d.ts.map +1 -0
  100. package/dist/managers/ShutdownManager.js +151 -0
  101. package/dist/managers/ShutdownManager.js.map +1 -0
  102. package/dist/managers/TranslatorManager.d.ts +19 -0
  103. package/dist/managers/TranslatorManager.d.ts.map +1 -0
  104. package/dist/managers/TranslatorManager.js +118 -0
  105. package/dist/managers/TranslatorManager.js.map +1 -0
  106. package/dist/middlewares/botPermissions.d.ts +4 -0
  107. package/dist/middlewares/botPermissions.d.ts.map +1 -0
  108. package/dist/middlewares/botPermissions.js +28 -0
  109. package/dist/middlewares/botPermissions.js.map +1 -0
  110. package/dist/middlewares/cooldown.d.ts +4 -0
  111. package/dist/middlewares/cooldown.d.ts.map +1 -0
  112. package/dist/middlewares/cooldown.js +42 -0
  113. package/dist/middlewares/cooldown.js.map +1 -0
  114. package/dist/middlewares/isInMainGuild.d.ts +4 -0
  115. package/dist/middlewares/isInMainGuild.d.ts.map +1 -0
  116. package/dist/middlewares/isInMainGuild.js +52 -0
  117. package/dist/middlewares/isInMainGuild.js.map +1 -0
  118. package/dist/middlewares/ownerOnly.d.ts +4 -0
  119. package/dist/middlewares/ownerOnly.d.ts.map +1 -0
  120. package/dist/middlewares/ownerOnly.js +24 -0
  121. package/dist/middlewares/ownerOnly.js.map +1 -0
  122. package/dist/middlewares/teamOnly.d.ts +4 -0
  123. package/dist/middlewares/teamOnly.d.ts.map +1 -0
  124. package/dist/middlewares/teamOnly.js +26 -0
  125. package/dist/middlewares/teamOnly.js.map +1 -0
  126. package/dist/middlewares/userPermissions.d.ts +4 -0
  127. package/dist/middlewares/userPermissions.d.ts.map +1 -0
  128. package/dist/middlewares/userPermissions.js +28 -0
  129. package/dist/middlewares/userPermissions.js.map +1 -0
  130. package/dist/middlewares/voteLocked.d.ts +4 -0
  131. package/dist/middlewares/voteLocked.d.ts.map +1 -0
  132. package/dist/middlewares/voteLocked.js +50 -0
  133. package/dist/middlewares/voteLocked.js.map +1 -0
  134. package/dist/structures/BaseCommand.d.ts +23 -0
  135. package/dist/structures/BaseCommand.d.ts.map +1 -0
  136. package/dist/structures/BaseCommand.js +42 -0
  137. package/dist/structures/BaseCommand.js.map +1 -0
  138. package/dist/types/AddonManager.d.ts +58 -0
  139. package/dist/types/AddonManager.d.ts.map +1 -0
  140. package/dist/types/AddonManager.js +3 -0
  141. package/dist/types/AddonManager.js.map +1 -0
  142. package/dist/types/DiscordHelpers.d.ts +7 -0
  143. package/dist/types/DiscordHelpers.d.ts.map +1 -0
  144. package/dist/types/DiscordHelpers.js +3 -0
  145. package/dist/types/DiscordHelpers.js.map +1 -0
  146. package/dist/types/EventManager.d.ts +10 -0
  147. package/dist/types/EventManager.d.ts.map +1 -0
  148. package/dist/types/EventManager.js +3 -0
  149. package/dist/types/EventManager.js.map +1 -0
  150. package/dist/types/InteractionManager.d.ts +35 -0
  151. package/dist/types/InteractionManager.d.ts.map +1 -0
  152. package/dist/types/InteractionManager.js +3 -0
  153. package/dist/types/InteractionManager.js.map +1 -0
  154. package/dist/types/KythiaClient.d.ts +9 -0
  155. package/dist/types/KythiaClient.d.ts.map +1 -0
  156. package/dist/types/KythiaClient.js +3 -0
  157. package/dist/types/KythiaClient.js.map +1 -0
  158. package/dist/types/KythiaConfig.d.ts +291 -0
  159. package/dist/types/KythiaConfig.d.ts.map +1 -0
  160. package/dist/types/KythiaConfig.js +3 -0
  161. package/dist/types/KythiaConfig.js.map +1 -0
  162. package/dist/types/KythiaContainer.d.ts +38 -0
  163. package/dist/types/KythiaContainer.d.ts.map +1 -0
  164. package/dist/types/KythiaContainer.js +3 -0
  165. package/dist/types/KythiaContainer.js.map +1 -0
  166. package/dist/types/KythiaLogger.d.ts +5 -0
  167. package/dist/types/KythiaLogger.d.ts.map +1 -0
  168. package/dist/types/KythiaLogger.js +3 -0
  169. package/dist/types/KythiaLogger.js.map +1 -0
  170. package/dist/types/KythiaMigrator.d.ts +9 -0
  171. package/dist/types/KythiaMigrator.d.ts.map +1 -0
  172. package/dist/types/KythiaMigrator.js +3 -0
  173. package/dist/types/KythiaMigrator.js.map +1 -0
  174. package/dist/types/KythiaModel.d.ts +31 -0
  175. package/dist/types/KythiaModel.d.ts.map +1 -0
  176. package/dist/types/KythiaModel.js +3 -0
  177. package/dist/types/KythiaModel.js.map +1 -0
  178. package/dist/types/KythiaOptions.d.ts +13 -0
  179. package/dist/types/KythiaOptions.d.ts.map +1 -0
  180. package/dist/types/KythiaOptions.js +3 -0
  181. package/dist/types/KythiaOptions.js.map +1 -0
  182. package/dist/types/KythiaSequelize.d.ts +13 -0
  183. package/dist/types/KythiaSequelize.d.ts.map +1 -0
  184. package/dist/types/KythiaSequelize.js +3 -0
  185. package/dist/types/KythiaSequelize.js.map +1 -0
  186. package/dist/types/KythiaStorage.d.ts +22 -0
  187. package/dist/types/KythiaStorage.d.ts.map +1 -0
  188. package/dist/types/KythiaStorage.js +3 -0
  189. package/dist/types/KythiaStorage.js.map +1 -0
  190. package/dist/types/MiddlewareManager.d.ts +14 -0
  191. package/dist/types/MiddlewareManager.d.ts.map +1 -0
  192. package/dist/types/MiddlewareManager.js +3 -0
  193. package/dist/types/MiddlewareManager.js.map +1 -0
  194. package/dist/types/ModelLoader.d.ts +8 -0
  195. package/dist/types/ModelLoader.d.ts.map +1 -0
  196. package/dist/types/ModelLoader.js +3 -0
  197. package/dist/types/ModelLoader.js.map +1 -0
  198. package/dist/types/ShutdownManager.d.ts +15 -0
  199. package/dist/types/ShutdownManager.d.ts.map +1 -0
  200. package/dist/types/ShutdownManager.js +3 -0
  201. package/dist/types/ShutdownManager.js.map +1 -0
  202. package/dist/types/TranslatorManager.d.ts +16 -0
  203. package/dist/types/TranslatorManager.d.ts.map +1 -0
  204. package/dist/types/TranslatorManager.js +3 -0
  205. package/dist/types/TranslatorManager.js.map +1 -0
  206. package/dist/types/index.d.ts +13 -0
  207. package/dist/types/index.d.ts.map +1 -0
  208. package/dist/types/index.js +29 -0
  209. package/dist/types/index.js.map +1 -0
  210. package/dist/utils/color.d.ts +15 -0
  211. package/dist/utils/color.d.ts.map +1 -0
  212. package/dist/utils/color.js +156 -0
  213. package/dist/utils/color.js.map +1 -0
  214. package/dist/utils/discord.d.ts +8 -0
  215. package/dist/utils/discord.d.ts.map +1 -0
  216. package/dist/utils/discord.js +53 -0
  217. package/dist/utils/discord.js.map +1 -0
  218. package/dist/utils/formatter.d.ts +3 -0
  219. package/dist/utils/formatter.d.ts.map +1 -0
  220. package/dist/utils/formatter.js +89 -0
  221. package/dist/utils/formatter.js.map +1 -0
  222. package/dist/utils/index.d.ts +12 -0
  223. package/dist/utils/index.d.ts.map +1 -0
  224. package/dist/utils/index.js +54 -0
  225. package/dist/utils/index.js.map +1 -0
  226. package/dist/utils/logger.d.ts +5 -0
  227. package/dist/utils/logger.d.ts.map +1 -0
  228. package/dist/utils/logger.js +150 -0
  229. package/dist/utils/logger.js.map +1 -0
  230. package/package.json +28 -6
  231. package/src/lang/en.json +85 -0
  232. package/changelog.md +0 -53
  233. package/index.js +0 -15
  234. package/src/Kythia.js +0 -556
  235. package/src/KythiaClient.js +0 -94
  236. package/src/cli/Command.js +0 -68
  237. package/src/cli/commands/CacheClearCommand.js +0 -136
  238. package/src/cli/commands/LangCheckCommand.js +0 -367
  239. package/src/cli/commands/LangTranslateCommand.js +0 -336
  240. package/src/cli/commands/MakeMigrationCommand.js +0 -82
  241. package/src/cli/commands/MakeModelCommand.js +0 -81
  242. package/src/cli/commands/MigrateCommand.js +0 -259
  243. package/src/cli/commands/NamespaceCommand.js +0 -112
  244. package/src/cli/commands/StructureCommand.js +0 -70
  245. package/src/cli/commands/UpversionCommand.js +0 -94
  246. package/src/cli/index.js +0 -69
  247. package/src/cli/utils/db.js +0 -117
  248. package/src/database/KythiaMigrator.js +0 -116
  249. package/src/database/KythiaModel.js +0 -1557
  250. package/src/database/KythiaSequelize.js +0 -128
  251. package/src/database/KythiaStorage.js +0 -117
  252. package/src/database/ModelLoader.js +0 -79
  253. package/src/managers/AddonManager.js +0 -1219
  254. package/src/managers/EventManager.js +0 -104
  255. package/src/managers/InteractionManager.js +0 -815
  256. package/src/managers/ShutdownManager.js +0 -218
  257. package/src/structures/BaseCommand.js +0 -53
  258. package/src/utils/color.js +0 -180
  259. package/src/utils/formatter.js +0 -99
  260. package/src/utils/index.js +0 -4
@@ -1,259 +0,0 @@
1
- /**
2
- * 🚜 Database Migration Runner
3
- *
4
- * @file src/cli/commands/MigrateCommand.js
5
- * @copyright © 2025 kenndeclouv
6
- * @assistant chaa & graa
7
- * @version 0.11.0-beta
8
- *
9
- * @description
10
- * Manages database schema updates using Umzug. Supports standard migration,
11
- * fresh resets (nuclear option), and smart batch-based rollbacks.
12
- *
13
- * ✨ Core Features:
14
- * - Fresh Mode: Wipes database and re-runs migrations from scratch.
15
- * - Smart Rollback: Rolls back only the last batch of migrations.
16
- * - Auto-Create: Detects missing database and offers to create it.
17
- * - Safety Net: Prompts for confirmation on destructive actions.
18
- */
19
-
20
- const Command = require('../Command');
21
- const { umzug, sequelize, storage } = require('../utils/db');
22
- const pc = require('picocolors');
23
- const readline = require('node:readline');
24
-
25
- function promptYN(question) {
26
- return new Promise((resolve) => {
27
- const rl = readline.createInterface({
28
- input: process.stdin,
29
- output: process.stdout,
30
- });
31
- rl.question(question, (answer) => {
32
- rl.close();
33
- resolve(answer.trim().toLowerCase());
34
- });
35
- });
36
- }
37
-
38
- class MigrateCommand extends Command {
39
- signature = 'migrate';
40
- description = 'Run pending database migrations';
41
-
42
- configure(cmd) {
43
- cmd
44
- .option('-f, --fresh', 'Wipe database and re-run all migrations')
45
- .option('-r, --rollback', 'Rollback the last batch of migrations');
46
- }
47
-
48
- async handle(options) {
49
- console.log(pc.dim('🔌 Connecting to database...'));
50
- let needReauth = false;
51
-
52
- try {
53
- await sequelize.authenticate();
54
- } catch (err) {
55
- const dbErrorCodes = ['ER_BAD_DB_ERROR', '3D000'];
56
- if (
57
- dbErrorCodes.includes(err.original?.code) ||
58
- dbErrorCodes.includes(err.original?.sqlState)
59
- ) {
60
- const dbName = sequelize.config?.database || '(unknown)';
61
- console.log(pc.red(`❗ Database "${dbName}" does not exist.`));
62
- const answer = await promptYN(
63
- pc.yellow(`Do you want to create the database "${dbName}"? (y/n): `),
64
- );
65
- if (answer === 'y' || answer === 'yes') {
66
- try {
67
- const { Sequelize } = require('sequelize');
68
- const currentDialect = sequelize.getDialect();
69
- const adminConfig = {
70
- ...sequelize.config,
71
- dialect: currentDialect,
72
- };
73
-
74
- if (currentDialect === 'mysql' || currentDialect === 'mariadb') {
75
- delete adminConfig.database;
76
- } else if (currentDialect === 'postgres') {
77
- adminConfig.database = 'postgres';
78
- } else if (currentDialect === 'sqlite') {
79
- console.log(
80
- pc.green('SQLite database file will be created automatically.'),
81
- );
82
- }
83
-
84
- const adminSequelize = new Sequelize(adminConfig);
85
- adminSequelize.options.logging = false;
86
-
87
- await adminSequelize
88
- .query(`CREATE DATABASE \`${dbName}\``)
89
- .catch(async (e) => {
90
- if (currentDialect === 'postgres') {
91
- await adminSequelize.query(`CREATE DATABASE "${dbName}"`);
92
- } else {
93
- throw e;
94
- }
95
- });
96
-
97
- await adminSequelize.close();
98
- console.log(pc.green(`✅ Database "${dbName}" created.`));
99
- needReauth = true;
100
- } catch (createErr) {
101
- console.error(
102
- pc.bgRed(' ERROR '),
103
- pc.red('Failed to create database:'),
104
- createErr.message,
105
- );
106
- process.exit(1);
107
- }
108
- } else {
109
- console.log(pc.red('Migration cancelled.'));
110
- process.exit(1);
111
- }
112
- } else {
113
- console.error(pc.bgRed(' ERROR '), pc.red(err.message));
114
- process.exit(1);
115
- }
116
- }
117
-
118
- if (needReauth) {
119
- try {
120
- await sequelize.authenticate();
121
- } catch (e) {
122
- console.error(
123
- pc.bgRed(' ERROR '),
124
- pc.red('Failed to connect after creating database:'),
125
- e.message,
126
- );
127
- process.exit(1);
128
- }
129
- }
130
-
131
- try {
132
- if (options.fresh) {
133
- console.log(pc.red('🧨 DROPPING ALL TABLES (Fresh)...'));
134
-
135
- const answer = await promptYN(
136
- pc.bgRed(pc.white(' DANGER ')) +
137
- pc.yellow(' This will wipe ALL DATA. Are you sure? (y/n): '),
138
- );
139
- if (answer !== 'y' && answer !== 'yes') {
140
- console.log(pc.cyan('Operation cancelled.'));
141
- process.exit(0);
142
- }
143
-
144
- const queryInterface = sequelize.getQueryInterface();
145
-
146
- if (
147
- sequelize.getDialect() === 'mysql' ||
148
- sequelize.getDialect() === 'mariadb'
149
- ) {
150
- await sequelize.query('SET FOREIGN_KEY_CHECKS = 0', { raw: true });
151
- } else if (sequelize.getDialect() === 'sqlite') {
152
- await sequelize.query('PRAGMA foreign_keys = OFF', { raw: true });
153
- }
154
-
155
- try {
156
- await queryInterface.dropAllTables();
157
-
158
- await queryInterface.dropTable('migrations').catch(() => {});
159
- await queryInterface.dropTable('SequelizeMeta').catch(() => {});
160
-
161
- console.log(pc.green('✅ All tables dropped. Database is clean.'));
162
- } catch (e) {
163
- console.error(pc.red(`❌ Failed to drop tables: ${e.message}`));
164
- throw e;
165
- } finally {
166
- if (
167
- sequelize.getDialect() === 'mysql' ||
168
- sequelize.getDialect() === 'mariadb'
169
- ) {
170
- await sequelize.query('SET FOREIGN_KEY_CHECKS = 1', { raw: true });
171
- } else if (sequelize.getDialect() === 'sqlite') {
172
- await sequelize.query('PRAGMA foreign_keys = ON', { raw: true });
173
- }
174
- }
175
-
176
- console.log(pc.dim(' -> Re-running all migrations...'));
177
-
178
- if (storage && typeof storage.setBatch === 'function') {
179
- storage.setBatch(1);
180
- }
181
-
182
- const executed = await umzug.up();
183
-
184
- console.log(
185
- pc.green(
186
- `✅ Database refreshed! (${executed.length} migrations re-applied in Batch 1)`,
187
- ),
188
- );
189
- return;
190
- }
191
-
192
- if (options.rollback) {
193
- const lastBatchNum = await storage.getLastBatchNumber();
194
-
195
- if (lastBatchNum === 0) {
196
- console.log(pc.gray('✨ Nothing to rollback (No batches found).'));
197
- return;
198
- }
199
-
200
- const filesInBatch = await storage.getLastBatchMigrations();
201
-
202
- console.log(
203
- pc.yellow(
204
- `⏪ Rolling back Batch #${lastBatchNum} (${filesInBatch.length} files)...`,
205
- ),
206
- );
207
-
208
- if (filesInBatch.length > 0) {
209
- const rolledBack = await umzug.down({
210
- migrations: filesInBatch,
211
- });
212
-
213
- if (rolledBack.length === 0)
214
- console.log(
215
- pc.red('❌ Rollback logic executed but no files processed.'),
216
- );
217
- else
218
- console.log(
219
- pc.green(`✅ Batch #${lastBatchNum} rolled back successfully.`),
220
- );
221
- } else {
222
- console.log(
223
- pc.gray(
224
- '✨ Batch record exists but no files found (Manual DB modification?).',
225
- ),
226
- );
227
- }
228
- return;
229
- }
230
-
231
- const pending = await umzug.pending();
232
- if (pending.length === 0) {
233
- console.log(pc.gray('✨ Nothing to migrate. Database is up to date.'));
234
- return;
235
- }
236
-
237
- const lastBatch = await storage.getLastBatchNumber();
238
- const newBatch = lastBatch + 1;
239
-
240
- storage.setBatch(newBatch);
241
-
242
- console.log(pc.cyan(`🚜 Running migrations (Batch #${newBatch})...`));
243
-
244
- const executed = await umzug.up();
245
-
246
- console.log(
247
- pc.green(`✅ Batch #${newBatch} completed (${executed.length} files).`),
248
- );
249
- } catch (err) {
250
- console.error(pc.bgRed(' ERROR '), pc.red(err.message));
251
-
252
- process.exit(1);
253
- } finally {
254
- await sequelize.close();
255
- }
256
- }
257
- }
258
-
259
- module.exports = MigrateCommand;
@@ -1,112 +0,0 @@
1
- /**
2
- * 🏷️ JSDoc Namespace Automator
3
- *
4
- * @file src/cli/commands/NamespaceCommand.js
5
- * @copyright © 2025 kenndeclouv
6
- * @assistant chaa & graa
7
- * @version 0.11.0-beta
8
- *
9
- * @description
10
- * Scans the entire project structure and automatically adds or updates
11
- * JSDoc `@namespace` headers to ensure code documentation consistency.
12
- * Detects file types (Command, Model, Event) based on directory context.
13
- *
14
- * ✨ Core Features:
15
- * - Smart Detection: Infers `@type` from folder names (commands, events, etc).
16
- * - Recursive Scan: Processes nested directories including addons.
17
- * - Safe Update: Updates headers without touching code logic.
18
- */
19
-
20
- const Command = require('../Command');
21
- const path = require('node:path');
22
- const pc = require('picocolors');
23
- const fs = require('node:fs');
24
-
25
- class NamespaceCommand extends Command {
26
- signature = 'dev:namespace';
27
- description = 'Add or update JSDoc @namespace headers in command files';
28
-
29
- async handle() {
30
- console.log(pc.cyan('🚀 Starting namespace annotation process...'));
31
- const rootDir = process.cwd();
32
-
33
- // Helper: Find Files Recursive
34
- function findJsFilesRecursive(dir) {
35
- let results = [];
36
- if (!fs.existsSync(dir)) return results;
37
- const list = fs.readdirSync(dir, { withFileTypes: true });
38
- for (const file of list) {
39
- if (file.name === 'node_modules' || file.name === '.git') continue;
40
- const fullPath = path.join(dir, file.name);
41
- if (file.isDirectory()) {
42
- results = results.concat(findJsFilesRecursive(fullPath));
43
- } else if (file.name.endsWith('.js')) {
44
- results.push(fullPath);
45
- }
46
- }
47
- return results;
48
- }
49
-
50
- function getFileType(filePath) {
51
- const fileName = path.basename(filePath);
52
- const parentDirName = path.basename(path.dirname(filePath));
53
- const grandParentDirName = path.basename(
54
- path.dirname(path.dirname(filePath)),
55
- );
56
-
57
- if (fileName === '_command.js') return 'Command Group Definition';
58
- if (fileName === '_group.js') return 'Subcommand Group Definition';
59
- if (parentDirName === 'commands' || grandParentDirName === 'commands')
60
- return 'Command';
61
- if (parentDirName === 'events') return 'Event Handler';
62
- if (parentDirName === 'helpers') return 'Helper Script';
63
- if (parentDirName === 'models') return 'Database Model';
64
- if (parentDirName === 'migrations') return 'Database Migration';
65
- if (parentDirName === 'tasks') return 'Scheduled Task';
66
- return 'Module';
67
- }
68
-
69
- let filesToProcess = [];
70
-
71
- const addonsPath = path.join(rootDir, 'addons');
72
- if (fs.existsSync(addonsPath)) {
73
- console.log(pc.dim('🔎 Scanning addons...'));
74
- filesToProcess = filesToProcess.concat(findJsFilesRecursive(addonsPath));
75
- }
76
-
77
- const pkg = require(path.join(rootDir, 'package.json'));
78
- const currentYear = new Date().getFullYear();
79
-
80
- filesToProcess.forEach((filePath) => {
81
- const relativePath = path.relative(rootDir, filePath).replace(/\\/g, '/');
82
- const fileType = getFileType(filePath);
83
-
84
- const newHeader = `/**
85
- * @namespace: ${relativePath}
86
- * @type: ${fileType}
87
- * @copyright © ${currentYear} kenndeclouv
88
- * @assistant chaa & graa
89
- * @version ${pkg.version}
90
- */`;
91
-
92
- const content = fs.readFileSync(filePath, 'utf8');
93
- const headerRegex = /\/\*\*[\s\S]*?namespace:[\s\S]*?\*\//;
94
-
95
- let newContent;
96
- if (headerRegex.test(content)) {
97
- newContent = content.replace(headerRegex, newHeader.trim());
98
- } else {
99
- newContent = `${newHeader}\n\n${content}`;
100
- }
101
-
102
- if (newContent.trim() !== content.trim()) {
103
- fs.writeFileSync(filePath, newContent, 'utf8');
104
- console.log(pc.green(`🔄 Updated: ${relativePath}`));
105
- }
106
- });
107
-
108
- console.log(pc.green('\n✅ Namespace annotation complete!'));
109
- }
110
- }
111
-
112
- module.exports = NamespaceCommand;
@@ -1,70 +0,0 @@
1
- /**
2
- * 🗺️ Project Structure Mapper
3
- *
4
- * @file src/cli/commands/StructureCommand.js
5
- * @copyright © 2025 kenndeclouv
6
- * @assistant chaa & graa
7
- * @version 0.11.0-beta
8
- *
9
- * @description
10
- * Generates a markdown tree representation of the entire project directory.
11
- * Useful for documentation and providing context to AI assistants.
12
- *
13
- * ✨ Core Features:
14
- * - Clean Output: Excludes noise (`node_modules`, `.git`).
15
- * - Format: Outputs standardized tree syntax to `temp/structure.md`.
16
- */
17
-
18
- const Command = require('../Command');
19
- const fs = require('node:fs');
20
- const path = require('node:path');
21
- const pc = require('picocolors');
22
-
23
- class StructureCommand extends Command {
24
- signature = 'gen:structure';
25
- description = 'Generate project structure to temp/structure.md';
26
-
27
- async handle() {
28
- const rootDir = process.cwd();
29
- const outputDir = path.join(rootDir, 'temp');
30
- const outputFile = path.join(outputDir, 'structure.md');
31
- const exclude = [
32
- '.git',
33
- '.vscode',
34
- 'node_modules',
35
- 'dist',
36
- 'logs',
37
- '.husky',
38
- '.yalc',
39
- ];
40
-
41
- function generateTree(dir, prefix = '') {
42
- const items = fs
43
- .readdirSync(dir)
44
- .filter((item) => !exclude.includes(item));
45
- let tree = '';
46
-
47
- items.forEach((item, index) => {
48
- const fullPath = path.join(dir, item);
49
- const isLast = index === items.length - 1;
50
- const connector = isLast ? '└── ' : '├── ';
51
- tree += `${prefix}${connector}${item}\n`;
52
-
53
- if (fs.statSync(fullPath).isDirectory()) {
54
- tree += generateTree(fullPath, prefix + (isLast ? ' ' : '│ '));
55
- }
56
- });
57
- return tree;
58
- }
59
-
60
- if (!fs.existsSync(outputDir)) {
61
- fs.mkdirSync(outputDir, { recursive: true });
62
- }
63
-
64
- const tree = generateTree(rootDir);
65
- fs.writeFileSync(outputFile, tree, 'utf8');
66
- console.log(pc.green(`✅ Project structure saved to: ${outputFile}`));
67
- }
68
- }
69
-
70
- module.exports = StructureCommand;
@@ -1,94 +0,0 @@
1
- /**
2
- * 🆙 Semantic Version Bumper
3
- *
4
- * @file src/cli/commands/UpversionCommand.js
5
- * @copyright © 2025 kenndeclouv
6
- * @assistant chaa & graa
7
- * @version 0.11.0-beta
8
- *
9
- * @description
10
- * Synchronizes the `@version` tag in all JSDoc headers across the project
11
- * to match the version defined in `package.json`.
12
- *
13
- * ✨ Core Features:
14
- * - Mass Update: Updates hundreds of files in seconds.
15
- * - Regex Powered: Accurately targets version tags without affecting other code.
16
- * - Safety: Ignores sensitive folders like `node_modules` and `.git`.
17
- */
18
-
19
- const Command = require('../Command');
20
- const fs = require('node:fs');
21
- const path = require('node:path');
22
- const pc = require('picocolors');
23
-
24
- class UpversionCommand extends Command {
25
- signature = 'version:up';
26
- description = 'Update @version in JSDoc headers to match package.json';
27
-
28
- async handle() {
29
- const rootDir = process.cwd();
30
- const pkgPath = path.join(rootDir, 'package.json');
31
-
32
- if (!fs.existsSync(pkgPath)) {
33
- console.error(pc.red('❌ package.json not found!'));
34
- process.exit(1);
35
- }
36
-
37
- const pkg = require(pkgPath);
38
- const version = pkg.version;
39
- console.log(pc.cyan(`✨ Using version from package.json: ${version}`));
40
-
41
- const ignoredPaths = [
42
- 'node_modules',
43
- '.git',
44
- '.env',
45
- 'dist',
46
- 'obfuscate.js',
47
- '.yalc',
48
- ];
49
-
50
- function getAllJsFiles(dir, fileList = []) {
51
- const files = fs.readdirSync(dir);
52
- files.forEach((file) => {
53
- const fullPath = path.join(dir, file);
54
- if (ignoredPaths.includes(path.basename(fullPath))) return;
55
-
56
- const stat = fs.statSync(fullPath);
57
- if (stat.isDirectory()) {
58
- getAllJsFiles(fullPath, fileList);
59
- } else if (file.endsWith('.js')) {
60
- fileList.push(fullPath);
61
- }
62
- });
63
- return fileList;
64
- }
65
-
66
- const jsFiles = getAllJsFiles(rootDir);
67
- const versionRegex = /(@version\s+)v?[\d.\-a-zA-Z]+/g;
68
- let updatedCount = 0;
69
-
70
- jsFiles.forEach((file) => {
71
- try {
72
- const originalContent = fs.readFileSync(file, 'utf8');
73
- const newContent = originalContent.replace(
74
- versionRegex,
75
- `$1${version}`,
76
- );
77
-
78
- if (originalContent !== newContent) {
79
- fs.writeFileSync(file, newContent, 'utf8');
80
- console.log(pc.green(`✅ Updated: ${path.relative(rootDir, file)}`));
81
- updatedCount++;
82
- }
83
- } catch (err) {
84
- console.error(pc.red(`❌ Failed to process: ${file}`), err.message);
85
- }
86
- });
87
-
88
- console.log(
89
- pc.green(`\n🎉 Version update complete! (${updatedCount} files changed)`),
90
- );
91
- }
92
- }
93
-
94
- module.exports = UpversionCommand;
package/src/cli/index.js DELETED
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * ⚡ Kythia CLI Entry Point
5
- *
6
- * @file src/cli/index.js
7
- * @copyright © 2025 kenndeclouv
8
- * @assistant chaa & graa
9
- * @version 0.11.0-beta
10
- *
11
- * @description
12
- * The main bootstrap entry point for the Kythia CLI.
13
- * It dynamically scans, loads, and registers all command classes found in the
14
- * `commands` directory, orchestrating the `commander` program execution.
15
- *
16
- * ✨ Core Features:
17
- * - Dynamic Loading: Automatically finds new commands without manual import.
18
- * - Class-Based Architecture: Supports standard `Command` class structure.
19
- * - Error Handling: Gracefully handles malformed commands during boot.
20
- */
21
-
22
- const { version } = require('../../package.json');
23
- const { Command } = require('commander');
24
- const BaseCommand = require('./Command');
25
- const path = require('node:path');
26
- const pc = require('picocolors');
27
- const fs = require('node:fs');
28
-
29
- const program = new Command();
30
-
31
- program
32
- .name('kythia')
33
- .description(pc.cyan('🌸 Kythia Framework CLI'))
34
- .version(version);
35
-
36
- const commandsDir = path.join(__dirname, 'commands');
37
-
38
- if (fs.existsSync(commandsDir)) {
39
- const commandFiles = fs
40
- .readdirSync(commandsDir)
41
- .filter((file) => file.endsWith('.js'));
42
-
43
- for (const file of commandFiles) {
44
- const filePath = path.join(commandsDir, file);
45
- try {
46
- const CommandClass = require(filePath);
47
-
48
- if (
49
- typeof CommandClass === 'function' &&
50
- CommandClass.prototype instanceof BaseCommand
51
- ) {
52
- const commandInstance = new CommandClass();
53
- commandInstance.register(program);
54
- } else if (typeof CommandClass.register === 'function') {
55
- CommandClass.register(program);
56
- } else {
57
- console.warn(
58
- pc.yellow(
59
- `⚠️ Skipped ${file}: Not a valid Command class or missing 'register' function.`,
60
- ),
61
- );
62
- }
63
- } catch (err) {
64
- console.error(pc.red(`❌ Failed to load command ${file}:`), err);
65
- }
66
- }
67
- }
68
-
69
- program.parse(process.argv);