@buenojs/bueno 0.8.3 → 0.8.5

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 (218) hide show
  1. package/README.md +136 -16
  2. package/dist/cli/{index.js → bin.js} +3036 -1421
  3. package/dist/container/index.js +250 -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/health/index.js +364 -0
  8. package/dist/i18n/index.js +345 -0
  9. package/dist/index.js +11043 -6482
  10. package/dist/jobs/index.js +819 -0
  11. package/dist/lock/index.js +367 -0
  12. package/dist/logger/index.js +281 -0
  13. package/dist/metrics/index.js +289 -0
  14. package/dist/middleware/index.js +77 -0
  15. package/dist/migrations/index.js +571 -0
  16. package/dist/modules/index.js +3346 -0
  17. package/dist/notification/index.js +484 -0
  18. package/dist/observability/index.js +331 -0
  19. package/dist/openapi/index.js +776 -0
  20. package/dist/orm/index.js +1356 -0
  21. package/dist/router/index.js +886 -0
  22. package/dist/rpc/index.js +691 -0
  23. package/dist/schema/index.js +400 -0
  24. package/dist/telemetry/index.js +595 -0
  25. package/dist/template/index.js +640 -0
  26. package/dist/templates/index.js +640 -0
  27. package/dist/testing/index.js +1111 -0
  28. package/dist/types/index.js +60 -0
  29. package/package.json +121 -27
  30. package/src/cache/index.ts +2 -1
  31. package/src/cli/bin.ts +2 -2
  32. package/src/cli/commands/build.ts +183 -165
  33. package/src/cli/commands/dev.ts +96 -89
  34. package/src/cli/commands/generate.ts +142 -111
  35. package/src/cli/commands/help.ts +20 -16
  36. package/src/cli/commands/index.ts +3 -6
  37. package/src/cli/commands/migration.ts +124 -105
  38. package/src/cli/commands/new.ts +392 -438
  39. package/src/cli/commands/start.ts +81 -79
  40. package/src/cli/core/args.ts +68 -50
  41. package/src/cli/core/console.ts +89 -95
  42. package/src/cli/core/index.ts +4 -4
  43. package/src/cli/core/prompt.ts +65 -62
  44. package/src/cli/core/spinner.ts +23 -20
  45. package/src/cli/index.ts +46 -38
  46. package/src/cli/templates/database/index.ts +61 -0
  47. package/src/cli/templates/database/mysql.ts +14 -0
  48. package/src/cli/templates/database/none.ts +16 -0
  49. package/src/cli/templates/database/postgresql.ts +14 -0
  50. package/src/cli/templates/database/sqlite.ts +14 -0
  51. package/src/cli/templates/deploy.ts +29 -26
  52. package/src/cli/templates/docker.ts +41 -30
  53. package/src/cli/templates/frontend/index.ts +63 -0
  54. package/src/cli/templates/frontend/none.ts +17 -0
  55. package/src/cli/templates/frontend/react.ts +140 -0
  56. package/src/cli/templates/frontend/solid.ts +134 -0
  57. package/src/cli/templates/frontend/svelte.ts +131 -0
  58. package/src/cli/templates/frontend/vue.ts +130 -0
  59. package/src/cli/templates/generators/index.ts +339 -0
  60. package/src/cli/templates/generators/types.ts +56 -0
  61. package/src/cli/templates/index.ts +35 -2
  62. package/src/cli/templates/project/api.ts +81 -0
  63. package/src/cli/templates/project/default.ts +140 -0
  64. package/src/cli/templates/project/fullstack.ts +111 -0
  65. package/src/cli/templates/project/index.ts +95 -0
  66. package/src/cli/templates/project/minimal.ts +45 -0
  67. package/src/cli/templates/project/types.ts +94 -0
  68. package/src/cli/templates/project/website.ts +263 -0
  69. package/src/cli/utils/fs.ts +55 -41
  70. package/src/cli/utils/index.ts +3 -2
  71. package/src/cli/utils/strings.ts +47 -33
  72. package/src/cli/utils/version.ts +47 -0
  73. package/src/config/env-validation.ts +100 -0
  74. package/src/config/env.ts +169 -41
  75. package/src/config/index.ts +28 -20
  76. package/src/config/loader.ts +25 -16
  77. package/src/config/merge.ts +21 -10
  78. package/src/config/types.ts +545 -25
  79. package/src/config/validation.ts +215 -7
  80. package/src/container/forward-ref.ts +22 -22
  81. package/src/container/index.ts +34 -12
  82. package/src/context/index.ts +11 -1
  83. package/src/database/index.ts +7 -190
  84. package/src/database/orm/builder.ts +457 -0
  85. package/src/database/orm/casts/index.ts +130 -0
  86. package/src/database/orm/casts/types.ts +25 -0
  87. package/src/database/orm/compiler.ts +304 -0
  88. package/src/database/orm/hooks/index.ts +114 -0
  89. package/src/database/orm/index.ts +61 -0
  90. package/src/database/orm/model-registry.ts +59 -0
  91. package/src/database/orm/model.ts +821 -0
  92. package/src/database/orm/relationships/base.ts +146 -0
  93. package/src/database/orm/relationships/belongs-to-many.ts +179 -0
  94. package/src/database/orm/relationships/belongs-to.ts +56 -0
  95. package/src/database/orm/relationships/has-many.ts +45 -0
  96. package/src/database/orm/relationships/has-one.ts +41 -0
  97. package/src/database/orm/relationships/index.ts +11 -0
  98. package/src/database/orm/scopes/index.ts +55 -0
  99. package/src/events/__tests__/event-system.test.ts +235 -0
  100. package/src/events/config.ts +238 -0
  101. package/src/events/example-usage.ts +185 -0
  102. package/src/events/index.ts +278 -0
  103. package/src/events/manager.ts +385 -0
  104. package/src/events/registry.ts +182 -0
  105. package/src/events/types.ts +124 -0
  106. package/src/frontend/api-routes.ts +65 -23
  107. package/src/frontend/bundler.ts +76 -34
  108. package/src/frontend/console-client.ts +2 -2
  109. package/src/frontend/console-stream.ts +94 -38
  110. package/src/frontend/dev-server.ts +94 -46
  111. package/src/frontend/file-router.ts +61 -19
  112. package/src/frontend/frameworks/index.ts +37 -10
  113. package/src/frontend/frameworks/react.ts +10 -8
  114. package/src/frontend/frameworks/solid.ts +11 -9
  115. package/src/frontend/frameworks/svelte.ts +15 -9
  116. package/src/frontend/frameworks/vue.ts +13 -11
  117. package/src/frontend/hmr-client.ts +12 -10
  118. package/src/frontend/hmr.ts +146 -103
  119. package/src/frontend/index.ts +14 -5
  120. package/src/frontend/islands.ts +41 -22
  121. package/src/frontend/isr.ts +59 -37
  122. package/src/frontend/layout.ts +36 -21
  123. package/src/frontend/ssr/react.ts +74 -27
  124. package/src/frontend/ssr/solid.ts +54 -20
  125. package/src/frontend/ssr/svelte.ts +48 -14
  126. package/src/frontend/ssr/vue.ts +50 -18
  127. package/src/frontend/ssr.ts +83 -39
  128. package/src/frontend/types.ts +91 -56
  129. package/src/health/index.ts +21 -9
  130. package/src/i18n/engine.ts +305 -0
  131. package/src/i18n/index.ts +38 -0
  132. package/src/i18n/loader.ts +218 -0
  133. package/src/i18n/middleware.ts +164 -0
  134. package/src/i18n/negotiator.ts +162 -0
  135. package/src/i18n/types.ts +158 -0
  136. package/src/index.ts +179 -27
  137. package/src/jobs/drivers/memory.ts +315 -0
  138. package/src/jobs/drivers/redis.ts +459 -0
  139. package/src/jobs/index.ts +30 -0
  140. package/src/jobs/queue.ts +281 -0
  141. package/src/jobs/types.ts +295 -0
  142. package/src/jobs/worker.ts +380 -0
  143. package/src/logger/index.ts +1 -3
  144. package/src/logger/transports/index.ts +62 -22
  145. package/src/metrics/index.ts +25 -16
  146. package/src/migrations/index.ts +9 -0
  147. package/src/modules/filters.ts +13 -17
  148. package/src/modules/guards.ts +49 -26
  149. package/src/modules/index.ts +409 -298
  150. package/src/modules/interceptors.ts +58 -20
  151. package/src/modules/lazy.ts +11 -19
  152. package/src/modules/lifecycle.ts +15 -7
  153. package/src/modules/metadata.ts +15 -5
  154. package/src/modules/pipes.ts +94 -72
  155. package/src/notification/channels/base.ts +68 -0
  156. package/src/notification/channels/email.ts +105 -0
  157. package/src/notification/channels/push.ts +104 -0
  158. package/src/notification/channels/sms.ts +105 -0
  159. package/src/notification/channels/whatsapp.ts +104 -0
  160. package/src/notification/index.ts +48 -0
  161. package/src/notification/service.ts +354 -0
  162. package/src/notification/types.ts +344 -0
  163. package/src/observability/__tests__/observability.test.ts +483 -0
  164. package/src/observability/breadcrumbs.ts +114 -0
  165. package/src/observability/index.ts +136 -0
  166. package/src/observability/interceptor.ts +85 -0
  167. package/src/observability/service.ts +303 -0
  168. package/src/observability/trace.ts +37 -0
  169. package/src/observability/types.ts +196 -0
  170. package/src/openapi/__tests__/decorators.test.ts +335 -0
  171. package/src/openapi/__tests__/document-builder.test.ts +285 -0
  172. package/src/openapi/__tests__/route-scanner.test.ts +334 -0
  173. package/src/openapi/__tests__/schema-generator.test.ts +275 -0
  174. package/src/openapi/decorators.ts +328 -0
  175. package/src/openapi/document-builder.ts +274 -0
  176. package/src/openapi/index.ts +112 -0
  177. package/src/openapi/metadata.ts +112 -0
  178. package/src/openapi/route-scanner.ts +289 -0
  179. package/src/openapi/schema-generator.ts +256 -0
  180. package/src/openapi/swagger-module.ts +166 -0
  181. package/src/openapi/types.ts +398 -0
  182. package/src/orm/index.ts +10 -0
  183. package/src/rpc/index.ts +3 -1
  184. package/src/schema/index.ts +9 -0
  185. package/src/security/index.ts +15 -6
  186. package/src/ssg/index.ts +9 -8
  187. package/src/telemetry/index.ts +76 -22
  188. package/src/template/index.ts +7 -0
  189. package/src/templates/engine.ts +224 -0
  190. package/src/templates/index.ts +9 -0
  191. package/src/templates/loader.ts +331 -0
  192. package/src/templates/renderers/markdown.ts +212 -0
  193. package/src/templates/renderers/simple.ts +269 -0
  194. package/src/templates/types.ts +154 -0
  195. package/src/testing/index.ts +100 -27
  196. package/src/types/optional-deps.d.ts +347 -187
  197. package/src/validation/index.ts +92 -2
  198. package/src/validation/schemas.ts +536 -0
  199. package/tests/integration/fullstack.test.ts +4 -4
  200. package/tests/unit/database.test.ts +2 -72
  201. package/tests/unit/env-validation.test.ts +166 -0
  202. package/tests/unit/events.test.ts +910 -0
  203. package/tests/unit/i18n.test.ts +455 -0
  204. package/tests/unit/jobs.test.ts +493 -0
  205. package/tests/unit/notification.test.ts +988 -0
  206. package/tests/unit/observability.test.ts +453 -0
  207. package/tests/unit/orm/builder.test.ts +323 -0
  208. package/tests/unit/orm/casts.test.ts +179 -0
  209. package/tests/unit/orm/compiler.test.ts +220 -0
  210. package/tests/unit/orm/eager-loading.test.ts +285 -0
  211. package/tests/unit/orm/hooks.test.ts +191 -0
  212. package/tests/unit/orm/model.test.ts +373 -0
  213. package/tests/unit/orm/relationships.test.ts +303 -0
  214. package/tests/unit/orm/scopes.test.ts +74 -0
  215. package/tests/unit/templates-simple.test.ts +53 -0
  216. package/tests/unit/templates.test.ts +454 -0
  217. package/tests/unit/validation.test.ts +18 -24
  218. package/tsconfig.json +11 -3
@@ -4,43 +4,53 @@
4
4
  * Build the application for production
5
5
  */
6
6
 
7
- import { defineCommand } from './index';
8
- import { getOption, hasFlag, type ParsedArgs } from '../core/args';
9
- import { cliConsole, colors, formatSize, formatDuration } from '../core/console';
10
- import { spinner } from '../core/spinner';
7
+ import { type ParsedArgs, getOption, hasFlag } from "../core/args";
11
8
  import {
9
+ cliConsole,
10
+ colors,
11
+ formatDuration,
12
+ formatSize,
13
+ } from "../core/console";
14
+ import { spinner } from "../core/spinner";
15
+ import { CLIError, CLIErrorType } from "../index";
16
+ import {
17
+ deleteDirectory,
12
18
  fileExists,
13
19
  getProjectRoot,
14
20
  isBuenoProject,
15
21
  joinPaths,
16
- readFile,
17
- deleteDirectory,
18
22
  listFiles,
19
- } from '../utils/fs';
20
- import { CLIError, CLIErrorType } from '../index';
23
+ readFile,
24
+ } from "../utils/fs";
25
+ import { defineCommand } from "./index";
21
26
 
22
27
  /**
23
28
  * Build targets
24
29
  */
25
- type BuildTarget = 'bun' | 'node' | 'standalone';
30
+ type BuildTarget = "bun" | "node" | "standalone";
26
31
 
27
32
  /**
28
33
  * Cross-compile targets
29
34
  */
30
- type CrossCompileTarget = 'linux-x64' | 'linux-arm64' | 'windows-x64' | 'darwin-x64' | 'darwin-arm64';
35
+ type CrossCompileTarget =
36
+ | "linux-x64"
37
+ | "linux-arm64"
38
+ | "windows-x64"
39
+ | "darwin-x64"
40
+ | "darwin-arm64";
31
41
 
32
42
  /**
33
43
  * Find the entry point for the application
34
44
  */
35
45
  async function findEntryPoint(projectRoot: string): Promise<string | null> {
36
46
  const possibleEntries = [
37
- 'server/main.ts',
38
- 'src/main.ts',
39
- 'src/index.ts',
40
- 'main.ts',
41
- 'index.ts',
42
- 'server.ts',
43
- 'app.ts',
47
+ "server/main.ts",
48
+ "src/main.ts",
49
+ "src/index.ts",
50
+ "main.ts",
51
+ "index.ts",
52
+ "server.ts",
53
+ "app.ts",
44
54
  ];
45
55
 
46
56
  for (const entry of possibleEntries) {
@@ -58,58 +68,58 @@ async function findEntryPoint(projectRoot: string): Promise<string | null> {
58
68
  */
59
69
  async function handleBuild(args: ParsedArgs): Promise<void> {
60
70
  // Get options
61
- const target = getOption(args, 'target', {
62
- name: 'target',
63
- alias: 't',
64
- type: 'string',
65
- default: 'bun',
66
- description: '',
71
+ const target = getOption(args, "target", {
72
+ name: "target",
73
+ alias: "t",
74
+ type: "string",
75
+ default: "bun",
76
+ description: "",
67
77
  }) as BuildTarget;
68
78
 
69
- const outDir = getOption<string>(args, 'outdir', {
70
- name: 'outdir',
71
- alias: 'o',
72
- type: 'string',
73
- default: './dist',
74
- description: '',
79
+ const outDir = getOption<string>(args, "outdir", {
80
+ name: "outdir",
81
+ alias: "o",
82
+ type: "string",
83
+ default: "./dist",
84
+ description: "",
75
85
  });
76
86
 
77
- const minify = !hasFlag(args, 'no-minify');
78
- const sourcemap = hasFlag(args, 'sourcemap');
79
- const analyze = hasFlag(args, 'analyze');
80
- const configPath = getOption(args, 'config', {
81
- name: 'config',
82
- alias: 'c',
83
- type: 'string',
84
- description: '',
87
+ const minify = !hasFlag(args, "no-minify");
88
+ const sourcemap = hasFlag(args, "sourcemap");
89
+ const analyze = hasFlag(args, "analyze");
90
+ const configPath = getOption(args, "config", {
91
+ name: "config",
92
+ alias: "c",
93
+ type: "string",
94
+ description: "",
85
95
  });
86
96
 
87
97
  // Compile options
88
- const compile = hasFlag(args, 'compile');
89
- const crossCompile = getOption(args, 'cross-compile', {
90
- name: 'cross-compile',
91
- type: 'string',
92
- description: '',
98
+ const compile = hasFlag(args, "compile");
99
+ const crossCompile = getOption(args, "cross-compile", {
100
+ name: "cross-compile",
101
+ type: "string",
102
+ description: "",
93
103
  }) as CrossCompileTarget | undefined;
94
- const executableName = getOption<string>(args, 'executable-name', {
95
- name: 'executable-name',
96
- type: 'string',
97
- default: 'main',
98
- description: '',
104
+ const executableName = getOption<string>(args, "executable-name", {
105
+ name: "executable-name",
106
+ type: "string",
107
+ default: "main",
108
+ description: "",
99
109
  });
100
110
 
101
111
  // Validate cross-compile target
102
112
  if (crossCompile) {
103
113
  const validCrossCompileTargets: CrossCompileTarget[] = [
104
- 'linux-x64',
105
- 'linux-arm64',
106
- 'windows-x64',
107
- 'darwin-x64',
108
- 'darwin-arm64',
114
+ "linux-x64",
115
+ "linux-arm64",
116
+ "windows-x64",
117
+ "darwin-x64",
118
+ "darwin-arm64",
109
119
  ];
110
120
  if (!validCrossCompileTargets.includes(crossCompile)) {
111
121
  throw new CLIError(
112
- `Invalid cross-compile target: ${crossCompile}. Valid targets: ${validCrossCompileTargets.join(', ')}`,
122
+ `Invalid cross-compile target: ${crossCompile}. Valid targets: ${validCrossCompileTargets.join(", ")}`,
113
123
  CLIErrorType.INVALID_ARGS,
114
124
  );
115
125
  }
@@ -118,16 +128,16 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
118
128
  // Validate that cross-compile requires compile
119
129
  if (crossCompile && !compile) {
120
130
  throw new CLIError(
121
- '--cross-compile requires --compile flag',
131
+ "--cross-compile requires --compile flag",
122
132
  CLIErrorType.INVALID_ARGS,
123
133
  );
124
134
  }
125
135
 
126
136
  // Validate target
127
- const validTargets: BuildTarget[] = ['bun', 'node', 'standalone'];
137
+ const validTargets: BuildTarget[] = ["bun", "node", "standalone"];
128
138
  if (!validTargets.includes(target)) {
129
139
  throw new CLIError(
130
- `Invalid target: ${target}. Valid targets: ${validTargets.join(', ')}`,
140
+ `Invalid target: ${target}. Valid targets: ${validTargets.join(", ")}`,
131
141
  CLIErrorType.INVALID_ARGS,
132
142
  );
133
143
  }
@@ -136,14 +146,14 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
136
146
  const projectRoot = await getProjectRoot();
137
147
  if (!projectRoot) {
138
148
  throw new CLIError(
139
- 'Not in a project directory. Run this command from a Bueno project.',
149
+ "Not in a project directory. Run this command from a Bueno project.",
140
150
  CLIErrorType.NOT_FOUND,
141
151
  );
142
152
  }
143
153
 
144
154
  if (!(await isBuenoProject())) {
145
155
  throw new CLIError(
146
- 'Not a Bueno project. Make sure you have a bueno.config.ts or bueno in your dependencies.',
156
+ "Not a Bueno project. Make sure you have a bueno.config.ts or bueno in your dependencies.",
147
157
  CLIErrorType.NOT_FOUND,
148
158
  );
149
159
  }
@@ -152,33 +162,39 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
152
162
  const entryPoint = await findEntryPoint(projectRoot);
153
163
  if (!entryPoint) {
154
164
  throw new CLIError(
155
- 'Could not find entry point. Make sure you have a main.ts or index.ts file.',
165
+ "Could not find entry point. Make sure you have a main.ts or index.ts file.",
156
166
  CLIErrorType.FILE_NOT_FOUND,
157
167
  );
158
168
  }
159
169
 
160
170
  // Display build info
161
171
  if (compile) {
162
- cliConsole.header('Compiling Single-File Executable');
172
+ cliConsole.header("Compiling Single-File Executable");
163
173
  } else {
164
- cliConsole.header('Building for Production');
174
+ cliConsole.header("Building for Production");
165
175
  }
166
- cliConsole.log(`${colors.bold('Entry:')} ${entryPoint}`);
167
- cliConsole.log(`${colors.bold('Target:')} ${target}`);
176
+ cliConsole.log(`${colors.bold("Entry:")} ${entryPoint}`);
177
+ cliConsole.log(`${colors.bold("Target:")} ${target}`);
168
178
  if (compile) {
169
- cliConsole.log(`${colors.bold('Compile:')} ${colors.green('enabled')}`);
179
+ cliConsole.log(`${colors.bold("Compile:")} ${colors.green("enabled")}`);
170
180
  if (crossCompile) {
171
- cliConsole.log(`${colors.bold('Cross-compile:')} ${colors.cyan(crossCompile)}`);
181
+ cliConsole.log(
182
+ `${colors.bold("Cross-compile:")} ${colors.cyan(crossCompile)}`,
183
+ );
172
184
  }
173
- cliConsole.log(`${colors.bold('Executable:')} ${executableName}`);
185
+ cliConsole.log(`${colors.bold("Executable:")} ${executableName}`);
174
186
  }
175
- cliConsole.log(`${colors.bold('Output:')} ${outDir}`);
176
- cliConsole.log(`${colors.bold('Minify:')} ${minify ? colors.green('enabled') : colors.red('disabled')}`);
177
- cliConsole.log(`${colors.bold('Sourcemap:')} ${sourcemap ? colors.green('enabled') : colors.red('disabled')}`);
178
- cliConsole.log('');
187
+ cliConsole.log(`${colors.bold("Output:")} ${outDir}`);
188
+ cliConsole.log(
189
+ `${colors.bold("Minify:")} ${minify ? colors.green("enabled") : colors.red("disabled")}`,
190
+ );
191
+ cliConsole.log(
192
+ `${colors.bold("Sourcemap:")} ${sourcemap ? colors.green("enabled") : colors.red("disabled")}`,
193
+ );
194
+ cliConsole.log("");
179
195
 
180
196
  const startTime = Date.now();
181
- const s = spinner('Building...');
197
+ const s = spinner("Building...");
182
198
 
183
199
  try {
184
200
  // Clean output directory
@@ -190,7 +206,7 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
190
206
  // Handle compile build
191
207
  if (compile) {
192
208
  // Determine the executable filename
193
- const isWindows = crossCompile === 'windows-x64';
209
+ const isWindows = crossCompile === "windows-x64";
194
210
  const executableFileName = isWindows
195
211
  ? `${executableName}.exe`
196
212
  : executableName;
@@ -200,13 +216,13 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
200
216
  const buildOptions: any = {
201
217
  entrypoints: [joinPaths(projectRoot, entryPoint)],
202
218
  outdir: fullOutDir,
203
- target: crossCompile || 'bun',
219
+ target: crossCompile || "bun",
204
220
  minify,
205
- sourcemap: sourcemap ? 'external' : undefined,
221
+ sourcemap: sourcemap ? "external" : undefined,
206
222
  naming: executableFileName,
207
223
  compile: true,
208
224
  define: {
209
- 'process.env.NODE_ENV': '"production"',
225
+ "process.env.NODE_ENV": '"production"',
210
226
  },
211
227
  };
212
228
 
@@ -218,21 +234,18 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
218
234
  for (const error of buildResult.logs) {
219
235
  cliConsole.error(error.message);
220
236
  }
221
- throw new CLIError(
222
- 'Compile failed',
223
- CLIErrorType.TEMPLATE_ERROR,
224
- );
237
+ throw new CLIError("Compile failed", CLIErrorType.TEMPLATE_ERROR);
225
238
  }
226
239
 
227
240
  const elapsed = Date.now() - startTime;
228
241
  s.success(`Compile completed in ${formatDuration(elapsed)}`);
229
242
 
230
243
  // Show output info
231
- cliConsole.log('');
232
- cliConsole.log(`${colors.bold('Output Executable:')}`);
233
-
244
+ cliConsole.log("");
245
+ cliConsole.log(`${colors.bold("Output Executable:")}`);
246
+
234
247
  // Get executable file size
235
- const fs = require('fs');
248
+ const fs = require("fs");
236
249
  let executableSize = 0;
237
250
  try {
238
251
  const stat = fs.statSync(executablePath);
@@ -243,17 +256,19 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
243
256
  executableSize = buildResult.outputs[0].size;
244
257
  }
245
258
  }
246
-
247
- cliConsole.log(` ${colors.cyan(executablePath.replace(projectRoot, '.'))} ${colors.dim(`(${formatSize(executableSize)})`)}`);
248
- cliConsole.log('');
249
-
259
+
260
+ cliConsole.log(
261
+ ` ${colors.cyan(executablePath.replace(projectRoot, "."))} ${colors.dim(`(${formatSize(executableSize)})`)}`,
262
+ );
263
+ cliConsole.log("");
264
+
250
265
  // Show success message with run instructions
251
- cliConsole.success('Single-file executable created successfully!');
266
+ cliConsole.success("Single-file executable created successfully!");
252
267
  if (crossCompile) {
253
- cliConsole.log(`${colors.bold('Target Platform:')} ${crossCompile}`);
268
+ cliConsole.log(`${colors.bold("Target Platform:")} ${crossCompile}`);
254
269
  }
255
- cliConsole.log('');
256
- cliConsole.info('You can run the executable directly:');
270
+ cliConsole.log("");
271
+ cliConsole.info("You can run the executable directly:");
257
272
  if (isWindows) {
258
273
  cliConsole.log(colors.cyan(` .${outDir}/${executableFileName}`));
259
274
  } else {
@@ -262,9 +277,9 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
262
277
 
263
278
  // Analyze if requested
264
279
  if (analyze) {
265
- cliConsole.log('');
266
- cliConsole.header('Bundle Analysis');
267
- cliConsole.log('Output:');
280
+ cliConsole.log("");
281
+ cliConsole.header("Bundle Analysis");
282
+ cliConsole.log("Output:");
268
283
  for (const entry of buildResult.outputs) {
269
284
  cliConsole.log(` ${entry.path} (${formatSize(entry.size)})`);
270
285
  }
@@ -277,14 +292,14 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
277
292
  const buildResult = await Bun.build({
278
293
  entrypoints: [joinPaths(projectRoot, entryPoint)],
279
294
  outdir: fullOutDir,
280
- target: target === 'node' ? 'node' : 'bun',
295
+ target: target === "node" ? "node" : "bun",
281
296
  minify,
282
- sourcemap: sourcemap ? 'external' : undefined,
297
+ sourcemap: sourcemap ? "external" : undefined,
283
298
  splitting: true,
284
- format: 'esm',
285
- external: target === 'standalone' ? [] : ['bun:*'],
299
+ format: "esm",
300
+ external: target === "standalone" ? [] : ["bun:*"],
286
301
  define: {
287
- 'process.env.NODE_ENV': '"production"',
302
+ "process.env.NODE_ENV": '"production"',
288
303
  },
289
304
  });
290
305
 
@@ -293,10 +308,7 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
293
308
  for (const error of buildResult.logs) {
294
309
  cliConsole.error(error.message);
295
310
  }
296
- throw new CLIError(
297
- 'Build failed',
298
- CLIErrorType.TEMPLATE_ERROR,
299
- );
311
+ throw new CLIError("Build failed", CLIErrorType.TEMPLATE_ERROR);
300
312
  }
301
313
 
302
314
  const elapsed = Date.now() - startTime;
@@ -304,43 +316,48 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
304
316
  // Get output files info
305
317
  const outputFiles = await listFiles(fullOutDir, { recursive: true });
306
318
  const totalSize = outputFiles.reduce((acc, file) => {
307
- const stat = require('fs').statSync(file);
319
+ const stat = require("fs").statSync(file);
308
320
  return acc + stat.size;
309
321
  }, 0);
310
322
 
311
323
  s.success(`Build completed in ${formatDuration(elapsed)}`);
312
324
 
313
325
  // Show output info
314
- cliConsole.log('');
315
- cliConsole.log(`${colors.bold('Output Files:')}`);
326
+ cliConsole.log("");
327
+ cliConsole.log(`${colors.bold("Output Files:")}`);
316
328
  for (const file of outputFiles.slice(0, 10)) {
317
- const stat = require('fs').statSync(file);
318
- const relativePath = file.replace(projectRoot, '.');
319
- cliConsole.log(` ${colors.dim(relativePath)} ${colors.dim(`(${formatSize(stat.size)})`)}`);
329
+ const stat = require("fs").statSync(file);
330
+ const relativePath = file.replace(projectRoot, ".");
331
+ cliConsole.log(
332
+ ` ${colors.dim(relativePath)} ${colors.dim(`(${formatSize(stat.size)})`)}`,
333
+ );
320
334
  }
321
335
  if (outputFiles.length > 10) {
322
- cliConsole.log(` ${colors.dim(`... and ${outputFiles.length - 10} more files`)}`);
336
+ cliConsole.log(
337
+ ` ${colors.dim(`... and ${outputFiles.length - 10} more files`)}`,
338
+ );
323
339
  }
324
- cliConsole.log('');
325
- cliConsole.log(`${colors.bold('Total Size:')} ${formatSize(totalSize)}`);
340
+ cliConsole.log("");
341
+ cliConsole.log(`${colors.bold("Total Size:")} ${formatSize(totalSize)}`);
326
342
 
327
343
  // Analyze if requested
328
344
  if (analyze) {
329
- cliConsole.log('');
330
- cliConsole.header('Bundle Analysis');
331
- cliConsole.log('Entry points:');
345
+ cliConsole.log("");
346
+ cliConsole.header("Bundle Analysis");
347
+ cliConsole.log("Entry points:");
332
348
  for (const entry of buildResult.outputs) {
333
349
  cliConsole.log(` ${entry.path} (${formatSize(entry.size)})`);
334
350
  }
335
351
  }
336
352
 
337
353
  // Show standalone build info
338
- if (target === 'standalone') {
339
- cliConsole.log('');
340
- cliConsole.info('Standalone bundle created. You can run it with:');
341
- cliConsole.log(colors.cyan(` bun .${outDir}/${entryPoint.replace('.ts', '.js')}`));
354
+ if (target === "standalone") {
355
+ cliConsole.log("");
356
+ cliConsole.info("Standalone bundle created. You can run it with:");
357
+ cliConsole.log(
358
+ colors.cyan(` bun .${outDir}/${entryPoint.replace(".ts", ".js")}`),
359
+ );
342
360
  }
343
-
344
361
  } catch (error) {
345
362
  s.error();
346
363
  throw error;
@@ -350,76 +367,77 @@ async function handleBuild(args: ParsedArgs): Promise<void> {
350
367
  // Register the command
351
368
  defineCommand(
352
369
  {
353
- name: 'build',
354
- description: 'Build the application for production',
370
+ name: "build",
371
+ description: "Build the application for production",
355
372
  options: [
356
373
  {
357
- name: 'target',
358
- alias: 't',
359
- type: 'string',
360
- default: 'bun',
361
- description: 'Build target (bun, node, standalone)',
374
+ name: "target",
375
+ alias: "t",
376
+ type: "string",
377
+ default: "bun",
378
+ description: "Build target (bun, node, standalone)",
362
379
  },
363
380
  {
364
- name: 'outdir',
365
- alias: 'o',
366
- type: 'string',
367
- default: './dist',
368
- description: 'Output directory',
381
+ name: "outdir",
382
+ alias: "o",
383
+ type: "string",
384
+ default: "./dist",
385
+ description: "Output directory",
369
386
  },
370
387
  {
371
- name: 'no-minify',
372
- type: 'boolean',
388
+ name: "no-minify",
389
+ type: "boolean",
373
390
  default: false,
374
- description: 'Disable minification',
391
+ description: "Disable minification",
375
392
  },
376
393
  {
377
- name: 'sourcemap',
378
- type: 'boolean',
394
+ name: "sourcemap",
395
+ type: "boolean",
379
396
  default: false,
380
- description: 'Generate source maps',
397
+ description: "Generate source maps",
381
398
  },
382
399
  {
383
- name: 'analyze',
384
- type: 'boolean',
400
+ name: "analyze",
401
+ type: "boolean",
385
402
  default: false,
386
- description: 'Analyze bundle size',
403
+ description: "Analyze bundle size",
387
404
  },
388
405
  {
389
- name: 'config',
390
- alias: 'c',
391
- type: 'string',
392
- description: 'Path to config file',
406
+ name: "config",
407
+ alias: "c",
408
+ type: "string",
409
+ description: "Path to config file",
393
410
  },
394
411
  {
395
- name: 'compile',
396
- type: 'boolean',
412
+ name: "compile",
413
+ type: "boolean",
397
414
  default: false,
398
- description: 'Create a single-file executable using Bun compile',
415
+ description: "Create a single-file executable using Bun compile",
399
416
  },
400
417
  {
401
- name: 'cross-compile',
402
- type: 'string',
403
- description: 'Cross-compile for different platforms (linux-x64, linux-arm64, windows-x64, darwin-x64, darwin-arm64)',
418
+ name: "cross-compile",
419
+ type: "string",
420
+ description:
421
+ "Cross-compile for different platforms (linux-x64, linux-arm64, windows-x64, darwin-x64, darwin-arm64)",
404
422
  },
405
423
  {
406
- name: 'executable-name',
407
- type: 'string',
408
- default: 'main',
409
- description: 'Custom name for the output executable (default: main)',
424
+ name: "executable-name",
425
+ type: "string",
426
+ default: "main",
427
+ description: "Custom name for the output executable (default: main)",
410
428
  },
411
429
  ],
412
430
  examples: [
413
- 'bueno build',
414
- 'bueno build --target node',
415
- 'bueno build --target standalone',
416
- 'bueno build --sourcemap',
417
- 'bueno build --analyze',
418
- 'bueno build --compile',
419
- 'bueno build --compile --outdir ./bin',
420
- 'bueno build --compile --cross-compile linux-x64',
421
- 'bueno build --compile --executable-name myapp',
431
+ "bueno build",
432
+ "bueno build --target node",
433
+ "bueno build --target standalone",
434
+ "bueno build --sourcemap",
435
+ "bueno build --analyze",
436
+ "bueno build --compile",
437
+ "bueno build --compile --outdir ./bin",
438
+ "bueno build --compile --cross-compile linux-x64",
439
+ "bueno build --compile --executable-name myapp",
422
440
  ],
423
441
  },
424
442
  handleBuild,
425
- );
443
+ );