@buenojs/bueno 0.8.4 → 0.8.6

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 (234) hide show
  1. package/README.md +264 -17
  2. package/dist/cli/{index.js → bin.js} +413 -332
  3. package/dist/container/index.js +273 -0
  4. package/dist/context/index.js +219 -0
  5. package/dist/database/index.js +493 -0
  6. package/dist/frontend/index.js +7697 -0
  7. package/dist/graphql/index.js +2156 -0
  8. package/dist/health/index.js +364 -0
  9. package/dist/i18n/index.js +345 -0
  10. package/dist/index.js +9694 -5047
  11. package/dist/jobs/index.js +819 -0
  12. package/dist/lock/index.js +367 -0
  13. package/dist/logger/index.js +281 -0
  14. package/dist/metrics/index.js +289 -0
  15. package/dist/middleware/index.js +77 -0
  16. package/dist/migrations/index.js +571 -0
  17. package/dist/modules/index.js +3411 -0
  18. package/dist/notification/index.js +484 -0
  19. package/dist/observability/index.js +331 -0
  20. package/dist/openapi/index.js +795 -0
  21. package/dist/orm/index.js +1356 -0
  22. package/dist/router/index.js +886 -0
  23. package/dist/rpc/index.js +691 -0
  24. package/dist/schema/index.js +400 -0
  25. package/dist/telemetry/index.js +595 -0
  26. package/dist/template/index.js +640 -0
  27. package/dist/templates/index.js +640 -0
  28. package/dist/testing/index.js +1111 -0
  29. package/dist/types/index.js +60 -0
  30. package/llms.txt +231 -0
  31. package/package.json +125 -27
  32. package/src/cache/index.ts +2 -1
  33. package/src/cli/ARCHITECTURE.md +3 -3
  34. package/src/cli/bin.ts +2 -2
  35. package/src/cli/commands/build.ts +183 -165
  36. package/src/cli/commands/dev.ts +96 -89
  37. package/src/cli/commands/generate.ts +142 -111
  38. package/src/cli/commands/help.ts +20 -16
  39. package/src/cli/commands/index.ts +3 -6
  40. package/src/cli/commands/migration.ts +124 -105
  41. package/src/cli/commands/new.ts +294 -232
  42. package/src/cli/commands/start.ts +81 -79
  43. package/src/cli/core/args.ts +68 -50
  44. package/src/cli/core/console.ts +89 -95
  45. package/src/cli/core/index.ts +4 -4
  46. package/src/cli/core/prompt.ts +65 -62
  47. package/src/cli/core/spinner.ts +23 -20
  48. package/src/cli/index.ts +46 -38
  49. package/src/cli/templates/database/index.ts +37 -18
  50. package/src/cli/templates/database/mysql.ts +3 -3
  51. package/src/cli/templates/database/none.ts +2 -2
  52. package/src/cli/templates/database/postgresql.ts +3 -3
  53. package/src/cli/templates/database/sqlite.ts +3 -3
  54. package/src/cli/templates/deploy.ts +29 -26
  55. package/src/cli/templates/docker.ts +41 -30
  56. package/src/cli/templates/frontend/index.ts +33 -15
  57. package/src/cli/templates/frontend/none.ts +2 -2
  58. package/src/cli/templates/frontend/react.ts +18 -18
  59. package/src/cli/templates/frontend/solid.ts +15 -15
  60. package/src/cli/templates/frontend/svelte.ts +17 -17
  61. package/src/cli/templates/frontend/vue.ts +15 -15
  62. package/src/cli/templates/generators/index.ts +29 -29
  63. package/src/cli/templates/generators/types.ts +21 -21
  64. package/src/cli/templates/index.ts +6 -6
  65. package/src/cli/templates/project/api.ts +37 -36
  66. package/src/cli/templates/project/default.ts +25 -25
  67. package/src/cli/templates/project/fullstack.ts +28 -26
  68. package/src/cli/templates/project/index.ts +55 -16
  69. package/src/cli/templates/project/minimal.ts +17 -12
  70. package/src/cli/templates/project/types.ts +10 -5
  71. package/src/cli/templates/project/website.ts +15 -15
  72. package/src/cli/utils/fs.ts +55 -41
  73. package/src/cli/utils/index.ts +3 -3
  74. package/src/cli/utils/strings.ts +47 -33
  75. package/src/cli/utils/version.ts +14 -8
  76. package/src/config/env-validation.ts +100 -0
  77. package/src/config/env.ts +169 -41
  78. package/src/config/index.ts +28 -20
  79. package/src/config/loader.ts +25 -16
  80. package/src/config/merge.ts +21 -10
  81. package/src/config/types.ts +566 -25
  82. package/src/config/validation.ts +215 -7
  83. package/src/container/forward-ref.ts +22 -22
  84. package/src/container/index.ts +34 -12
  85. package/src/context/index.ts +11 -1
  86. package/src/database/index.ts +7 -190
  87. package/src/database/orm/builder.ts +457 -0
  88. package/src/database/orm/casts/index.ts +130 -0
  89. package/src/database/orm/casts/types.ts +25 -0
  90. package/src/database/orm/compiler.ts +304 -0
  91. package/src/database/orm/hooks/index.ts +114 -0
  92. package/src/database/orm/index.ts +61 -0
  93. package/src/database/orm/model-registry.ts +59 -0
  94. package/src/database/orm/model.ts +821 -0
  95. package/src/database/orm/relationships/base.ts +146 -0
  96. package/src/database/orm/relationships/belongs-to-many.ts +179 -0
  97. package/src/database/orm/relationships/belongs-to.ts +56 -0
  98. package/src/database/orm/relationships/has-many.ts +45 -0
  99. package/src/database/orm/relationships/has-one.ts +41 -0
  100. package/src/database/orm/relationships/index.ts +11 -0
  101. package/src/database/orm/scopes/index.ts +55 -0
  102. package/src/events/__tests__/event-system.test.ts +235 -0
  103. package/src/events/config.ts +238 -0
  104. package/src/events/example-usage.ts +185 -0
  105. package/src/events/index.ts +278 -0
  106. package/src/events/manager.ts +385 -0
  107. package/src/events/registry.ts +182 -0
  108. package/src/events/types.ts +124 -0
  109. package/src/frontend/api-routes.ts +65 -23
  110. package/src/frontend/bundler.ts +76 -34
  111. package/src/frontend/console-client.ts +2 -2
  112. package/src/frontend/console-stream.ts +94 -38
  113. package/src/frontend/dev-server.ts +94 -46
  114. package/src/frontend/file-router.ts +61 -19
  115. package/src/frontend/frameworks/index.ts +37 -10
  116. package/src/frontend/frameworks/react.ts +10 -8
  117. package/src/frontend/frameworks/solid.ts +11 -9
  118. package/src/frontend/frameworks/svelte.ts +15 -9
  119. package/src/frontend/frameworks/vue.ts +13 -11
  120. package/src/frontend/hmr-client.ts +12 -10
  121. package/src/frontend/hmr.ts +146 -103
  122. package/src/frontend/index.ts +14 -5
  123. package/src/frontend/islands.ts +41 -22
  124. package/src/frontend/isr.ts +59 -37
  125. package/src/frontend/layout.ts +36 -21
  126. package/src/frontend/ssr/react.ts +74 -27
  127. package/src/frontend/ssr/solid.ts +54 -20
  128. package/src/frontend/ssr/svelte.ts +48 -14
  129. package/src/frontend/ssr/vue.ts +50 -18
  130. package/src/frontend/ssr.ts +83 -39
  131. package/src/frontend/types.ts +91 -56
  132. package/src/graphql/built-in-engine.ts +598 -0
  133. package/src/graphql/context-builder.ts +110 -0
  134. package/src/graphql/decorators.ts +358 -0
  135. package/src/graphql/execution-pipeline.ts +227 -0
  136. package/src/graphql/graphql-module.ts +563 -0
  137. package/src/graphql/index.ts +101 -0
  138. package/src/graphql/metadata.ts +237 -0
  139. package/src/graphql/schema-builder.ts +319 -0
  140. package/src/graphql/subscription-handler.ts +283 -0
  141. package/src/graphql/types.ts +324 -0
  142. package/src/health/index.ts +21 -9
  143. package/src/i18n/engine.ts +305 -0
  144. package/src/i18n/index.ts +38 -0
  145. package/src/i18n/loader.ts +218 -0
  146. package/src/i18n/middleware.ts +164 -0
  147. package/src/i18n/negotiator.ts +162 -0
  148. package/src/i18n/types.ts +158 -0
  149. package/src/index.ts +182 -27
  150. package/src/jobs/drivers/memory.ts +315 -0
  151. package/src/jobs/drivers/redis.ts +459 -0
  152. package/src/jobs/index.ts +30 -0
  153. package/src/jobs/queue.ts +281 -0
  154. package/src/jobs/types.ts +295 -0
  155. package/src/jobs/worker.ts +380 -0
  156. package/src/logger/index.ts +1 -3
  157. package/src/logger/transports/index.ts +62 -22
  158. package/src/metrics/index.ts +25 -16
  159. package/src/migrations/index.ts +9 -0
  160. package/src/modules/filters.ts +13 -17
  161. package/src/modules/guards.ts +49 -26
  162. package/src/modules/index.ts +457 -299
  163. package/src/modules/interceptors.ts +58 -20
  164. package/src/modules/lazy.ts +11 -19
  165. package/src/modules/lifecycle.ts +15 -7
  166. package/src/modules/metadata.ts +15 -5
  167. package/src/modules/pipes.ts +94 -72
  168. package/src/notification/channels/base.ts +68 -0
  169. package/src/notification/channels/email.ts +105 -0
  170. package/src/notification/channels/push.ts +104 -0
  171. package/src/notification/channels/sms.ts +105 -0
  172. package/src/notification/channels/whatsapp.ts +104 -0
  173. package/src/notification/index.ts +48 -0
  174. package/src/notification/service.ts +354 -0
  175. package/src/notification/types.ts +344 -0
  176. package/src/observability/__tests__/observability.test.ts +483 -0
  177. package/src/observability/breadcrumbs.ts +114 -0
  178. package/src/observability/index.ts +136 -0
  179. package/src/observability/interceptor.ts +85 -0
  180. package/src/observability/service.ts +303 -0
  181. package/src/observability/trace.ts +37 -0
  182. package/src/observability/types.ts +196 -0
  183. package/src/openapi/__tests__/decorators.test.ts +335 -0
  184. package/src/openapi/__tests__/document-builder.test.ts +285 -0
  185. package/src/openapi/__tests__/route-scanner.test.ts +334 -0
  186. package/src/openapi/__tests__/schema-generator.test.ts +275 -0
  187. package/src/openapi/decorators.ts +328 -0
  188. package/src/openapi/document-builder.ts +274 -0
  189. package/src/openapi/index.ts +112 -0
  190. package/src/openapi/metadata.ts +112 -0
  191. package/src/openapi/route-scanner.ts +289 -0
  192. package/src/openapi/schema-generator.ts +256 -0
  193. package/src/openapi/swagger-module.ts +166 -0
  194. package/src/openapi/types.ts +398 -0
  195. package/src/orm/index.ts +10 -0
  196. package/src/rpc/index.ts +3 -1
  197. package/src/schema/index.ts +9 -0
  198. package/src/security/index.ts +15 -6
  199. package/src/ssg/index.ts +9 -8
  200. package/src/telemetry/index.ts +76 -22
  201. package/src/template/index.ts +7 -0
  202. package/src/templates/engine.ts +224 -0
  203. package/src/templates/index.ts +9 -0
  204. package/src/templates/loader.ts +331 -0
  205. package/src/templates/renderers/markdown.ts +212 -0
  206. package/src/templates/renderers/simple.ts +269 -0
  207. package/src/templates/types.ts +154 -0
  208. package/src/testing/index.ts +100 -27
  209. package/src/types/optional-deps.d.ts +347 -187
  210. package/src/validation/index.ts +92 -2
  211. package/src/validation/schemas.ts +536 -0
  212. package/tests/integration/cli.test.ts +19 -19
  213. package/tests/integration/fullstack.test.ts +4 -4
  214. package/tests/unit/cli.test.ts +1 -1
  215. package/tests/unit/database.test.ts +2 -72
  216. package/tests/unit/env-validation.test.ts +166 -0
  217. package/tests/unit/events.test.ts +910 -0
  218. package/tests/unit/graphql.test.ts +991 -0
  219. package/tests/unit/i18n.test.ts +455 -0
  220. package/tests/unit/jobs.test.ts +493 -0
  221. package/tests/unit/notification.test.ts +988 -0
  222. package/tests/unit/observability.test.ts +453 -0
  223. package/tests/unit/orm/builder.test.ts +323 -0
  224. package/tests/unit/orm/casts.test.ts +179 -0
  225. package/tests/unit/orm/compiler.test.ts +220 -0
  226. package/tests/unit/orm/eager-loading.test.ts +285 -0
  227. package/tests/unit/orm/hooks.test.ts +191 -0
  228. package/tests/unit/orm/model.test.ts +373 -0
  229. package/tests/unit/orm/relationships.test.ts +303 -0
  230. package/tests/unit/orm/scopes.test.ts +74 -0
  231. package/tests/unit/templates-simple.test.ts +53 -0
  232. package/tests/unit/templates.test.ts +454 -0
  233. package/tests/unit/validation.test.ts +18 -24
  234. package/tsconfig.json +11 -3
@@ -4,25 +4,31 @@
4
4
  * Manage database migrations
5
5
  */
6
6
 
7
- import { defineCommand } from './index';
8
- import { getOption, hasFlag, type ParsedArgs } from '../core/args';
9
- import { cliConsole, colors, printTable } from '../core/console';
10
- import { spinner } from '../core/spinner';
7
+ import { type ParsedArgs, getOption, hasFlag } from "../core/args";
8
+ import { cliConsole, colors, printTable } from "../core/console";
9
+ import { spinner } from "../core/spinner";
10
+ import { CLIError, CLIErrorType } from "../index";
11
11
  import {
12
12
  fileExists,
13
- readFile,
14
- writeFile,
15
- listFiles,
16
13
  getProjectRoot,
17
14
  isBuenoProject,
18
15
  joinPaths,
19
- } from '../utils/fs';
20
- import { CLIError, CLIErrorType } from '../index';
16
+ listFiles,
17
+ readFile,
18
+ writeFile,
19
+ } from "../utils/fs";
20
+ import { defineCommand } from "./index";
21
21
 
22
22
  /**
23
23
  * Migration actions
24
24
  */
25
- type MigrationAction = 'create' | 'up' | 'down' | 'reset' | 'refresh' | 'status';
25
+ type MigrationAction =
26
+ | "create"
27
+ | "up"
28
+ | "down"
29
+ | "reset"
30
+ | "refresh"
31
+ | "status";
26
32
 
27
33
  /**
28
34
  * Generate migration ID
@@ -30,11 +36,11 @@ type MigrationAction = 'create' | 'up' | 'down' | 'reset' | 'refresh' | 'status'
30
36
  function generateMigrationId(): string {
31
37
  const now = new Date();
32
38
  const year = now.getFullYear();
33
- const month = String(now.getMonth() + 1).padStart(2, '0');
34
- const day = String(now.getDate()).padStart(2, '0');
35
- const hour = String(now.getHours()).padStart(2, '0');
36
- const minute = String(now.getMinutes()).padStart(2, '0');
37
- const second = String(now.getSeconds()).padStart(2, '0');
39
+ const month = String(now.getMonth() + 1).padStart(2, "0");
40
+ const day = String(now.getDate()).padStart(2, "0");
41
+ const hour = String(now.getHours()).padStart(2, "0");
42
+ const minute = String(now.getMinutes()).padStart(2, "0");
43
+ const second = String(now.getSeconds()).padStart(2, "0");
38
44
  return `${year}${month}${day}${hour}${minute}${second}`;
39
45
  }
40
46
 
@@ -44,17 +50,14 @@ function generateMigrationId(): string {
44
50
  async function getMigrationsDir(): Promise<string> {
45
51
  const projectRoot = await getProjectRoot();
46
52
  if (!projectRoot) {
47
- throw new CLIError(
48
- 'Not in a project directory',
49
- CLIErrorType.NOT_FOUND,
50
- );
53
+ throw new CLIError("Not in a project directory", CLIErrorType.NOT_FOUND);
51
54
  }
52
55
 
53
56
  // Check common locations
54
57
  const possibleDirs = [
55
- joinPaths(projectRoot, 'server', 'database', 'migrations'),
56
- joinPaths(projectRoot, 'database', 'migrations'),
57
- joinPaths(projectRoot, 'migrations'),
58
+ joinPaths(projectRoot, "server", "database", "migrations"),
59
+ joinPaths(projectRoot, "database", "migrations"),
60
+ joinPaths(projectRoot, "migrations"),
58
61
  ];
59
62
 
60
63
  for (const dir of possibleDirs) {
@@ -64,14 +67,14 @@ async function getMigrationsDir(): Promise<string> {
64
67
  }
65
68
 
66
69
  // Default to server/database/migrations
67
- return possibleDirs[0] ?? '';
70
+ return possibleDirs[0] ?? "";
68
71
  }
69
72
 
70
73
  /**
71
74
  * Get migration files
72
75
  */
73
76
  async function getMigrationFiles(dir: string): Promise<string[]> {
74
- if (!await fileExists(dir)) {
77
+ if (!(await fileExists(dir))) {
75
78
  return [];
76
79
  }
77
80
 
@@ -100,11 +103,11 @@ function parseMigrationFile(filename: string): { id: string; name: string } {
100
103
  async function createMigration(name: string, dryRun: boolean): Promise<string> {
101
104
  const migrationsDir = await getMigrationsDir();
102
105
  const id = generateMigrationId();
103
- const kebabName = name.toLowerCase().replace(/\s+/g, '-');
106
+ const kebabName = name.toLowerCase().replace(/\s+/g, "-");
104
107
  const fileName = `${id}_${kebabName}.ts`;
105
108
  const filePath = joinPaths(migrationsDir, fileName);
106
109
 
107
- const template = `import { createMigration, type MigrationRunner } from '@buenojs/bueno';
110
+ const template = `import { createMigration, type MigrationRunner } from '@buenojs/bueno/migrations';
108
111
 
109
112
  export default createMigration('${id}', '${kebabName}')
110
113
  .up(async (db: MigrationRunner) => {
@@ -126,10 +129,10 @@ export default createMigration('${id}', '${kebabName}')
126
129
  `;
127
130
 
128
131
  if (dryRun) {
129
- cliConsole.log(`\n${colors.bold('File:')} ${filePath}`);
130
- cliConsole.log(colors.bold('Content:'));
132
+ cliConsole.log(`\n${colors.bold("File:")} ${filePath}`);
133
+ cliConsole.log(colors.bold("Content:"));
131
134
  cliConsole.log(template);
132
- cliConsole.log('');
135
+ cliConsole.log("");
133
136
  return filePath;
134
137
  }
135
138
 
@@ -145,19 +148,19 @@ async function showStatus(): Promise<void> {
145
148
  const files = await getMigrationFiles(migrationsDir);
146
149
 
147
150
  if (files.length === 0) {
148
- cliConsole.info('No migrations found');
151
+ cliConsole.info("No migrations found");
149
152
  return;
150
153
  }
151
154
 
152
- cliConsole.header('Migration Status');
155
+ cliConsole.header("Migration Status");
153
156
 
154
157
  const rows = files.map((file) => {
155
- const info = parseMigrationFile(file.split('/').pop() ?? '');
156
- return [info.id, info.name, colors.yellow('Pending')];
158
+ const info = parseMigrationFile(file.split("/").pop() ?? "");
159
+ return [info.id, info.name, colors.yellow("Pending")];
157
160
  });
158
161
 
159
- printTable(['ID', 'Name', 'Status'], rows);
160
- cliConsole.log('');
162
+ printTable(["ID", "Name", "Status"], rows);
163
+ cliConsole.log("");
161
164
  cliConsole.log(`Total: ${files.length} migration(s)`);
162
165
  }
163
166
 
@@ -169,45 +172,52 @@ async function handleMigration(args: ParsedArgs): Promise<void> {
169
172
  const action = args.positionals[0] as MigrationAction | undefined;
170
173
  if (!action) {
171
174
  throw new CLIError(
172
- 'Action is required. Usage: bueno migration <action>',
175
+ "Action is required. Usage: bueno migration <action>",
173
176
  CLIErrorType.INVALID_ARGS,
174
177
  );
175
178
  }
176
179
 
177
- const validActions: MigrationAction[] = ['create', 'up', 'down', 'reset', 'refresh', 'status'];
180
+ const validActions: MigrationAction[] = [
181
+ "create",
182
+ "up",
183
+ "down",
184
+ "reset",
185
+ "refresh",
186
+ "status",
187
+ ];
178
188
  if (!validActions.includes(action)) {
179
189
  throw new CLIError(
180
- `Unknown action: ${action}. Valid actions: ${validActions.join(', ')}`,
190
+ `Unknown action: ${action}. Valid actions: ${validActions.join(", ")}`,
181
191
  CLIErrorType.INVALID_ARGS,
182
192
  );
183
193
  }
184
194
 
185
195
  // Get options
186
- const dryRun = hasFlag(args, 'dry-run');
187
- const steps = getOption(args, 'steps', {
188
- name: 'steps',
189
- alias: 'n',
190
- type: 'number',
196
+ const dryRun = hasFlag(args, "dry-run");
197
+ const steps = getOption(args, "steps", {
198
+ name: "steps",
199
+ alias: "n",
200
+ type: "number",
191
201
  default: 1,
192
- description: '',
202
+ description: "",
193
203
  });
194
204
 
195
205
  // Check if in a Bueno project (except for create with dry-run)
196
- if (action !== 'create' || !dryRun) {
206
+ if (action !== "create" || !dryRun) {
197
207
  if (!(await isBuenoProject())) {
198
208
  throw new CLIError(
199
- 'Not in a Bueno project directory. Run this command from a Bueno project.',
209
+ "Not in a Bueno project directory. Run this command from a Bueno project.",
200
210
  CLIErrorType.NOT_FOUND,
201
211
  );
202
212
  }
203
213
  }
204
214
 
205
215
  switch (action) {
206
- case 'create': {
216
+ case "create": {
207
217
  const name = args.positionals[1];
208
218
  if (!name) {
209
219
  throw new CLIError(
210
- 'Migration name is required. Usage: bueno migration create <name>',
220
+ "Migration name is required. Usage: bueno migration create <name>",
211
221
  CLIErrorType.INVALID_ARGS,
212
222
  );
213
223
  }
@@ -216,7 +226,7 @@ async function handleMigration(args: ParsedArgs): Promise<void> {
216
226
  try {
217
227
  const filePath = await createMigration(name, dryRun);
218
228
  if (dryRun) {
219
- s.info('Dry run complete');
229
+ s.info("Dry run complete");
220
230
  } else {
221
231
  s.success(`Created ${colors.green(filePath)}`);
222
232
  }
@@ -227,83 +237,91 @@ async function handleMigration(args: ParsedArgs): Promise<void> {
227
237
  break;
228
238
  }
229
239
 
230
- case 'up': {
231
- cliConsole.info('Running pending migrations...');
232
- cliConsole.log('');
240
+ case "up": {
241
+ cliConsole.info("Running pending migrations...");
242
+ cliConsole.log("");
233
243
  cliConsole.warn(
234
- 'Migration execution requires database connection. Use the MigrationRunner in your application code.',
244
+ "Migration execution requires database connection. Use the MigrationRunner in your application code.",
235
245
  );
236
- cliConsole.log('');
237
- cliConsole.log('Example:');
238
- cliConsole.log(colors.cyan(`
239
- import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
246
+ cliConsole.log("");
247
+ cliConsole.log("Example:");
248
+ cliConsole.log(
249
+ colors.cyan(`
250
+ import { createMigrationRunner, loadMigrations } from '@buenojs/bueno/migrations';
240
251
  import { db } from './database';
241
252
 
242
253
  const runner = createMigrationRunner(db);
243
254
  const migrations = await loadMigrations('./database/migrations');
244
255
  await runner.migrate(migrations);
245
- `));
256
+ `),
257
+ );
246
258
  break;
247
259
  }
248
260
 
249
- case 'down': {
261
+ case "down": {
250
262
  cliConsole.info(`Rolling back ${steps} migration(s)...`);
251
- cliConsole.log('');
263
+ cliConsole.log("");
252
264
  cliConsole.warn(
253
- 'Migration rollback requires database connection. Use the MigrationRunner in your application code.',
265
+ "Migration rollback requires database connection. Use the MigrationRunner in your application code.",
254
266
  );
255
- cliConsole.log('');
256
- cliConsole.log('Example:');
257
- cliConsole.log(colors.cyan(`
258
- import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
267
+ cliConsole.log("");
268
+ cliConsole.log("Example:");
269
+ cliConsole.log(
270
+ colors.cyan(`
271
+ import { createMigrationRunner, loadMigrations } from '@buenojs/bueno/migrations';
259
272
  import { db } from './database';
260
273
 
261
274
  const runner = createMigrationRunner(db);
262
275
  const migrations = await loadMigrations('./database/migrations');
263
276
  await runner.rollback(migrations, ${steps});
264
- `));
277
+ `),
278
+ );
265
279
  break;
266
280
  }
267
281
 
268
- case 'reset': {
269
- cliConsole.info('Rolling back all migrations...');
270
- cliConsole.log('');
282
+ case "reset": {
283
+ cliConsole.info("Rolling back all migrations...");
284
+ cliConsole.log("");
271
285
  cliConsole.warn(
272
- 'Migration reset requires database connection. Use the MigrationRunner in your application code.',
286
+ "Migration reset requires database connection. Use the MigrationRunner in your application code.",
273
287
  );
274
- cliConsole.log('');
275
- cliConsole.log('Example:');
276
- cliConsole.log(colors.cyan(`
277
- import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
288
+ cliConsole.log("");
289
+ cliConsole.log("Example:");
290
+ cliConsole.log(
291
+ colors.cyan(`
292
+ import { createMigrationRunner, loadMigrations } from '@buenojs/bueno/migrations';
278
293
  import { db } from './database';
279
294
 
280
295
  const runner = createMigrationRunner(db);
281
296
  const migrations = await loadMigrations('./database/migrations');
282
297
  await runner.reset(migrations);
283
- `));
298
+ `),
299
+ );
284
300
  break;
285
301
  }
286
302
 
287
- case 'refresh': {
288
- cliConsole.info('Refreshing all migrations...');
289
- cliConsole.log('');
303
+ case "refresh": {
304
+ cliConsole.info("Refreshing all migrations...");
305
+ cliConsole.log("");
290
306
  cliConsole.warn(
291
- 'Migration refresh requires database connection. Use the MigrationRunner in your application code.',
307
+ "Migration refresh requires database connection. Use the MigrationRunner in your application code.",
292
308
  );
293
- cliConsole.log('');
294
- cliConsole.log('Example:');
295
- cliConsole.log(colors.cyan(`
296
- import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
309
+ cliConsole.log("");
310
+ cliConsole.log("Example:");
311
+ cliConsole.log(
312
+ colors.cyan(`
313
+ import { createMigrationRunner, loadMigrations } from '@buenojs/bueno/migrations';
297
314
  import { db } from './database';
298
315
 
299
316
  const runner = createMigrationRunner(db);
300
317
  const migrations = await loadMigrations('./database/migrations');
301
318
  await runner.refresh(migrations);
302
- `));
319
+ `),
320
+ );
303
321
  break;
304
322
  }
305
323
 
306
- case 'status': {
324
+ case "status": {
307
325
  await showStatus();
308
326
  break;
309
327
  }
@@ -313,43 +331,44 @@ await runner.refresh(migrations);
313
331
  // Register the command
314
332
  defineCommand(
315
333
  {
316
- name: 'migration',
317
- description: 'Manage database migrations',
334
+ name: "migration",
335
+ description: "Manage database migrations",
318
336
  positionals: [
319
337
  {
320
- name: 'action',
338
+ name: "action",
321
339
  required: true,
322
- description: 'Action to perform (create, up, down, reset, refresh, status)',
340
+ description:
341
+ "Action to perform (create, up, down, reset, refresh, status)",
323
342
  },
324
343
  {
325
- name: 'name',
344
+ name: "name",
326
345
  required: false,
327
- description: 'Migration name (required for create action)',
346
+ description: "Migration name (required for create action)",
328
347
  },
329
348
  ],
330
349
  options: [
331
350
  {
332
- name: 'steps',
333
- alias: 'n',
334
- type: 'number',
351
+ name: "steps",
352
+ alias: "n",
353
+ type: "number",
335
354
  default: 1,
336
- description: 'Number of migrations to rollback',
355
+ description: "Number of migrations to rollback",
337
356
  },
338
357
  {
339
- name: 'dry-run',
340
- type: 'boolean',
358
+ name: "dry-run",
359
+ type: "boolean",
341
360
  default: false,
342
- description: 'Show what would happen without executing',
361
+ description: "Show what would happen without executing",
343
362
  },
344
363
  ],
345
364
  examples: [
346
- 'bueno migration create add-users-table',
347
- 'bueno migration up',
348
- 'bueno migration down --steps 3',
349
- 'bueno migration reset',
350
- 'bueno migration refresh',
351
- 'bueno migration status',
365
+ "bueno migration create add-users-table",
366
+ "bueno migration up",
367
+ "bueno migration down --steps 3",
368
+ "bueno migration reset",
369
+ "bueno migration refresh",
370
+ "bueno migration status",
352
371
  ],
353
372
  },
354
373
  handleMigration,
355
- );
374
+ );