@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
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Database Templates
3
+ *
4
+ * Database-specific configuration templates
5
+ */
6
+
7
+ import type { DatabaseDriver, DatabaseTemplateResult } from "../project/types";
8
+ import { mysqlTemplate } from "./mysql";
9
+ import { noneTemplate } from "./none";
10
+ import { postgresqlTemplate } from "./postgresql";
11
+ import { sqliteTemplate } from "./sqlite";
12
+
13
+ /**
14
+ * Database template registry
15
+ */
16
+ const databaseTemplates: Record<DatabaseDriver, () => DatabaseTemplateResult> =
17
+ {
18
+ sqlite: sqliteTemplate,
19
+ postgresql: postgresqlTemplate,
20
+ mysql: mysqlTemplate,
21
+ none: noneTemplate,
22
+ };
23
+
24
+ /**
25
+ * Get database template based on driver
26
+ */
27
+ export function getDatabaseTemplate(
28
+ driver: DatabaseDriver,
29
+ ): DatabaseTemplateResult {
30
+ return databaseTemplates[driver]();
31
+ }
32
+
33
+ /**
34
+ * Get database selection options for prompts
35
+ */
36
+ export function getDatabaseOptions(): {
37
+ value: DatabaseDriver;
38
+ name: string;
39
+ description: string;
40
+ }[] {
41
+ return [
42
+ { value: "none", name: "None", description: "No database required" },
43
+ {
44
+ value: "sqlite",
45
+ name: "SQLite",
46
+ description: "Local file-based database",
47
+ },
48
+ {
49
+ value: "postgresql",
50
+ name: "PostgreSQL",
51
+ description: "Production-ready relational database",
52
+ },
53
+ {
54
+ value: "mysql",
55
+ name: "MySQL",
56
+ description: "Popular relational database",
57
+ },
58
+ ];
59
+ }
60
+
61
+ export { sqliteTemplate, postgresqlTemplate, mysqlTemplate, noneTemplate };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * MySQL Database Template
3
+ */
4
+
5
+ import type { DatabaseTemplateResult } from "../project/types";
6
+
7
+ export function mysqlTemplate(): DatabaseTemplateResult {
8
+ return {
9
+ files: [],
10
+ directories: [],
11
+ envConfig: "DATABASE_URL=mysql://user:password@localhost:3306/dbname",
12
+ configCode: `{ url: process.env.DATABASE_URL ?? 'mysql://localhost/dbname' }`,
13
+ };
14
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * No Database Template
3
+ *
4
+ * Template for projects that don't need a database
5
+ */
6
+
7
+ import type { DatabaseTemplateResult } from "../project/types";
8
+
9
+ export function noneTemplate(): DatabaseTemplateResult {
10
+ return {
11
+ files: [],
12
+ directories: [],
13
+ envConfig: undefined,
14
+ configCode: undefined,
15
+ };
16
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * PostgreSQL Database Template
3
+ */
4
+
5
+ import type { DatabaseTemplateResult } from "../project/types";
6
+
7
+ export function postgresqlTemplate(): DatabaseTemplateResult {
8
+ return {
9
+ files: [],
10
+ directories: [],
11
+ envConfig: "DATABASE_URL=postgresql://user:password@localhost:5432/dbname",
12
+ configCode: `{ url: process.env.DATABASE_URL ?? 'postgresql://localhost/dbname' }`,
13
+ };
14
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * SQLite Database Template
3
+ */
4
+
5
+ import type { DatabaseTemplateResult } from "../project/types";
6
+
7
+ export function sqliteTemplate(): DatabaseTemplateResult {
8
+ return {
9
+ files: [],
10
+ directories: [],
11
+ envConfig: "DATABASE_URL=sqlite:./data.db",
12
+ configCode: `{ url: 'sqlite:./data.db' }`,
13
+ };
14
+ }
@@ -8,20 +8,23 @@
8
8
  /**
9
9
  * Valid deployment platforms
10
10
  */
11
- export type DeployPlatform = 'render' | 'fly' | 'railway';
11
+ export type DeployPlatform = "render" | "fly" | "railway";
12
12
 
13
13
  /**
14
14
  * Get Render.com deployment configuration (render.yaml)
15
15
  *
16
16
  * Blueprint format for Render.com with web service and optional database
17
17
  */
18
- export function getRenderYamlTemplate(projectName: string, database?: string): string {
19
- const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, '-');
20
-
21
- let databaseSection = '';
22
- let envVars = '';
18
+ export function getRenderYamlTemplate(
19
+ projectName: string,
20
+ database?: string,
21
+ ): string {
22
+ const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, "-");
23
23
 
24
- if (database === 'postgresql') {
24
+ let databaseSection = "";
25
+ let envVars = "";
26
+
27
+ if (database === "postgresql") {
25
28
  databaseSection = `
26
29
  # PostgreSQL Database
27
30
  - type: pserv
@@ -53,7 +56,7 @@ export function getRenderYamlTemplate(projectName: string, database?: string): s
53
56
  - key: BUN_ENV
54
57
  value: production
55
58
  `;
56
- } else if (database === 'mysql') {
59
+ } else if (database === "mysql") {
57
60
  databaseSection = `
58
61
  # MySQL Database (using Render's managed MySQL)
59
62
  - type: pserv
@@ -128,7 +131,7 @@ metadata:
128
131
  * Fly.io app configuration with HTTP service and auto-scaling
129
132
  */
130
133
  export function getFlyTomlTemplate(projectName: string): string {
131
- const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, '-');
134
+ const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, "-");
132
135
 
133
136
  return `# ${projectName} - Fly.io Deployment Configuration
134
137
  # https://fly.io/docs/reference/configuration/
@@ -193,7 +196,7 @@ primary_region = "sea"
193
196
  * Railway configuration with builder settings and health checks
194
197
  */
195
198
  export function getRailwayTomlTemplate(projectName: string): string {
196
- const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, '-');
199
+ const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, "-");
197
200
 
198
201
  return `# ${projectName} - Railway Deployment Configuration
199
202
  # https://docs.railway.app/reference/config-as-code
@@ -251,11 +254,11 @@ export function getDeployTemplate(
251
254
  database?: string,
252
255
  ): string {
253
256
  switch (platform) {
254
- case 'render':
257
+ case "render":
255
258
  return getRenderYamlTemplate(projectName, database);
256
- case 'fly':
259
+ case "fly":
257
260
  return getFlyTomlTemplate(projectName);
258
- case 'railway':
261
+ case "railway":
259
262
  return getRailwayTomlTemplate(projectName);
260
263
  default:
261
264
  throw new Error(`Unknown deployment platform: ${platform}`);
@@ -267,12 +270,12 @@ export function getDeployTemplate(
267
270
  */
268
271
  export function getDeployFilename(platform: DeployPlatform): string {
269
272
  switch (platform) {
270
- case 'render':
271
- return 'render.yaml';
272
- case 'fly':
273
- return 'fly.toml';
274
- case 'railway':
275
- return 'railway.toml';
273
+ case "render":
274
+ return "render.yaml";
275
+ case "fly":
276
+ return "fly.toml";
277
+ case "railway":
278
+ return "railway.toml";
276
279
  default:
277
280
  throw new Error(`Unknown deployment platform: ${platform}`);
278
281
  }
@@ -283,13 +286,13 @@ export function getDeployFilename(platform: DeployPlatform): string {
283
286
  */
284
287
  export function getDeployPlatformName(platform: DeployPlatform): string {
285
288
  switch (platform) {
286
- case 'render':
287
- return 'Render.com';
288
- case 'fly':
289
- return 'Fly.io';
290
- case 'railway':
291
- return 'Railway';
289
+ case "render":
290
+ return "Render.com";
291
+ case "fly":
292
+ return "Fly.io";
293
+ case "railway":
294
+ return "Railway";
292
295
  default:
293
296
  return platform;
294
297
  }
295
- }
298
+ }
@@ -6,10 +6,13 @@
6
6
 
7
7
  /**
8
8
  * Get Dockerfile template
9
- *
9
+ *
10
10
  * Multi-stage build using oven/bun image for production
11
11
  */
12
- export function getDockerfileTemplate(projectName: string, database?: string): string {
12
+ export function getDockerfileTemplate(
13
+ projectName: string,
14
+ database?: string,
15
+ ): string {
13
16
  return `# ${projectName} - Production Dockerfile
14
17
  # Multi-stage build for optimized production image
15
18
 
@@ -82,7 +85,7 @@ CMD ["bun", "run", "dist/main.js"]
82
85
 
83
86
  /**
84
87
  * Get .dockerignore template
85
- *
88
+ *
86
89
  * Patterns to exclude from Docker build context
87
90
  */
88
91
  export function getDockerignoreTemplate(): string {
@@ -145,16 +148,19 @@ tsconfig.json
145
148
 
146
149
  /**
147
150
  * Get docker-compose.yml template
148
- *
151
+ *
149
152
  * Local development setup with optional database services
150
153
  */
151
- export function getDockerComposeTemplate(projectName: string, database?: string): string {
152
- const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, '-');
153
-
154
- let databaseServices = '';
155
- let dependsOn = '';
154
+ export function getDockerComposeTemplate(
155
+ projectName: string,
156
+ database?: string,
157
+ ): string {
158
+ const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, "-");
159
+
160
+ let databaseServices = "";
161
+ let dependsOn = "";
156
162
 
157
- if (database === 'postgresql') {
163
+ if (database === "postgresql") {
158
164
  databaseServices = `
159
165
  # PostgreSQL Database
160
166
  postgres:
@@ -183,7 +189,7 @@ export function getDockerComposeTemplate(projectName: string, database?: string)
183
189
  postgres:
184
190
  condition: service_healthy
185
191
  `;
186
- } else if (database === 'mysql') {
192
+ } else if (database === "mysql") {
187
193
  databaseServices = `
188
194
  # MySQL Database
189
195
  mysql:
@@ -215,25 +221,27 @@ export function getDockerComposeTemplate(projectName: string, database?: string)
215
221
  `;
216
222
  }
217
223
 
218
- const volumes = database === 'postgresql'
219
- ? `\nvolumes:
224
+ const volumes =
225
+ database === "postgresql"
226
+ ? `\nvolumes:
220
227
  postgres_data:
221
228
  driver: local
222
229
  `
223
- : database === 'mysql'
224
- ? `\nvolumes:
230
+ : database === "mysql"
231
+ ? `\nvolumes:
225
232
  mysql_data:
226
233
  driver: local
227
234
  `
228
- : '';
235
+ : "";
229
236
 
230
- const databaseEnv = database === 'postgresql'
231
- ? ` DATABASE_URL: postgresql://\${POSTGRES_USER:-postgres}:\${POSTGRES_PASSWORD:-postgres}@postgres:5432/\${POSTGRES_DB:-${kebabName}}
237
+ const databaseEnv =
238
+ database === "postgresql"
239
+ ? ` DATABASE_URL: postgresql://\${POSTGRES_USER:-postgres}:\${POSTGRES_PASSWORD:-postgres}@postgres:5432/\${POSTGRES_DB:-${kebabName}}
232
240
  `
233
- : database === 'mysql'
234
- ? ` DATABASE_URL: mysql://\${MYSQL_USER:-mysql}:\${MYSQL_PASSWORD:-mysql}@mysql:3306/\${MYSQL_DATABASE:-${kebabName}}
241
+ : database === "mysql"
242
+ ? ` DATABASE_URL: mysql://\${MYSQL_USER:-mysql}:\${MYSQL_PASSWORD:-mysql}@mysql:3306/\${MYSQL_DATABASE:-${kebabName}}
235
243
  `
236
- : '';
244
+ : "";
237
245
 
238
246
  return `# ${projectName} - Docker Compose for Local Development
239
247
  # Usage: docker-compose up -d
@@ -268,15 +276,18 @@ ${volumes}
268
276
 
269
277
  /**
270
278
  * Get Docker environment variables template
271
- *
279
+ *
272
280
  * Environment variables for Docker Compose
273
281
  */
274
- export function getDockerEnvTemplate(projectName: string, database?: string): string {
275
- const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, '-');
276
-
277
- let dbEnv = '';
278
-
279
- if (database === 'postgresql') {
282
+ export function getDockerEnvTemplate(
283
+ projectName: string,
284
+ database?: string,
285
+ ): string {
286
+ const kebabName = projectName.toLowerCase().replace(/[^a-z0-9-]/g, "-");
287
+
288
+ let dbEnv = "";
289
+
290
+ if (database === "postgresql") {
280
291
  dbEnv = `
281
292
  # PostgreSQL Configuration
282
293
  POSTGRES_USER=postgres
@@ -285,7 +296,7 @@ POSTGRES_DB=${kebabName}
285
296
  POSTGRES_PORT=5432
286
297
  DATABASE_URL=postgresql://postgres:postgres@localhost:5432/${kebabName}
287
298
  `;
288
- } else if (database === 'mysql') {
299
+ } else if (database === "mysql") {
289
300
  dbEnv = `
290
301
  # MySQL Configuration
291
302
  MYSQL_ROOT_PASSWORD=root
@@ -304,4 +315,4 @@ DATABASE_URL=mysql://mysql:mysql@localhost:3306/${kebabName}
304
315
  APP_PORT=3000
305
316
  NODE_ENV=production
306
317
  ${dbEnv}`;
307
- }
318
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Frontend Templates
3
+ *
4
+ * Frontend framework-specific configuration templates
5
+ */
6
+
7
+ import type {
8
+ FrontendFramework,
9
+ FrontendTemplateResult,
10
+ } from "../project/types";
11
+ import { noneTemplate } from "./none";
12
+ import { reactTemplate } from "./react";
13
+ import { solidTemplate } from "./solid";
14
+ import { svelteTemplate } from "./svelte";
15
+ import { vueTemplate } from "./vue";
16
+
17
+ /**
18
+ * Frontend template registry
19
+ */
20
+ const frontendTemplates: Record<
21
+ FrontendFramework,
22
+ () => FrontendTemplateResult
23
+ > = {
24
+ react: reactTemplate,
25
+ vue: vueTemplate,
26
+ svelte: svelteTemplate,
27
+ solid: solidTemplate,
28
+ none: noneTemplate,
29
+ };
30
+
31
+ /**
32
+ * Get frontend template based on framework
33
+ */
34
+ export function getFrontendTemplate(
35
+ framework: FrontendFramework,
36
+ ): FrontendTemplateResult {
37
+ return frontendTemplates[framework]();
38
+ }
39
+
40
+ /**
41
+ * Get frontend selection options for prompts
42
+ */
43
+ export function getFrontendOptions(): {
44
+ value: FrontendFramework;
45
+ name: string;
46
+ description: string;
47
+ }[] {
48
+ return [
49
+ { value: "none", name: "None", description: "Static website or API only" },
50
+ { value: "react", name: "React", description: "React with SSR support" },
51
+ { value: "vue", name: "Vue", description: "Vue 3 with SSR support" },
52
+ { value: "svelte", name: "Svelte", description: "Svelte with SSR support" },
53
+ { value: "solid", name: "Solid", description: "SolidJS with SSR support" },
54
+ ];
55
+ }
56
+
57
+ export {
58
+ reactTemplate,
59
+ vueTemplate,
60
+ svelteTemplate,
61
+ solidTemplate,
62
+ noneTemplate,
63
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * No Frontend Template
3
+ *
4
+ * Template for API-only or static website projects
5
+ */
6
+
7
+ import type { FrontendTemplateResult } from "../project/types";
8
+
9
+ export function noneTemplate(): FrontendTemplateResult {
10
+ return {
11
+ files: [],
12
+ directories: [],
13
+ dependencies: {},
14
+ devDependencies: {},
15
+ scripts: {},
16
+ };
17
+ }
@@ -0,0 +1,140 @@
1
+ /**
2
+ * React Frontend Template
3
+ */
4
+
5
+ import type { FrontendTemplateResult } from "../project/types";
6
+
7
+ export function reactTemplate(): FrontendTemplateResult {
8
+ return {
9
+ files: [
10
+ {
11
+ path: "client/index.html",
12
+ content: `<!DOCTYPE html>
13
+ <html lang="en">
14
+ <head>
15
+ <meta charset="UTF-8">
16
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
17
+ <title>Bueno App</title>
18
+ </head>
19
+ <body>
20
+ <div id="root"></div>
21
+ <script type="module" src="./src/main.tsx"></script>
22
+ </body>
23
+ </html>
24
+ `,
25
+ },
26
+ {
27
+ path: "client/src/main.tsx",
28
+ content: `import { StrictMode } from 'react';
29
+ import { createRoot } from 'react-dom/client';
30
+ import { App } from './App';
31
+ import './styles/globals.css';
32
+
33
+ const root = createRoot(document.getElementById('root')!);
34
+
35
+ root.render(
36
+ <StrictMode>
37
+ <App />
38
+ </StrictMode>
39
+ );
40
+ `,
41
+ },
42
+ {
43
+ path: "client/src/App.tsx",
44
+ content: `import { useState } from 'react';
45
+
46
+ export function App() {
47
+ const [count, setCount] = useState(0);
48
+
49
+ return (
50
+ <main className="min-h-screen bg-gradient-to-br from-slate-900 to-slate-800 text-white">
51
+ <div className="container mx-auto px-4 py-16">
52
+ <div className="max-w-2xl mx-auto text-center">
53
+ <h1 className="text-5xl font-bold mb-4 bg-gradient-to-r from-blue-400 to-purple-500 bg-clip-text text-transparent">
54
+ Welcome to Bueno
55
+ </h1>
56
+ <p className="text-xl text-slate-300 mb-8">
57
+ A Bun-native full-stack framework
58
+ </p>
59
+
60
+ <div className="bg-slate-800/50 rounded-xl p-8 backdrop-blur-sm border border-slate-700">
61
+ <button
62
+ onClick={() => setCount(c => c + 1)}
63
+ className="px-6 py-3 bg-blue-500 hover:bg-blue-600 rounded-lg font-medium transition-colors"
64
+ >
65
+ Count: {count}
66
+ </button>
67
+ <p className="mt-4 text-slate-400 text-sm">
68
+ Click the button to test React hydration
69
+ </p>
70
+ </div>
71
+
72
+ <div className="mt-8 grid grid-cols-2 gap-4 text-left">
73
+ <a
74
+ href="https://bueno.github.io"
75
+ className="p-4 bg-slate-800/50 rounded-lg border border-slate-700 hover:border-blue-500 transition-colors"
76
+ >
77
+ <h3 className="font-semibold text-blue-400">Documentation</h3>
78
+ <p className="text-sm text-slate-400">Learn more about Bueno</p>
79
+ </a>
80
+ <a
81
+ href="https://github.com/buenojs/bueno"
82
+ className="p-4 bg-slate-800/50 rounded-lg border border-slate-700 hover:border-blue-500 transition-colors"
83
+ >
84
+ <h3 className="font-semibold text-blue-400">GitHub</h3>
85
+ <p className="text-sm text-slate-400">View the source code</p>
86
+ </a>
87
+ </div>
88
+ </div>
89
+ </div>
90
+ </main>
91
+ );
92
+ }
93
+ `,
94
+ },
95
+ {
96
+ path: "client/src/styles/globals.css",
97
+ content: `@tailwind base;
98
+ @tailwind components;
99
+ @tailwind utilities;
100
+
101
+ :root {
102
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
103
+ line-height: 1.5;
104
+ font-weight: 400;
105
+ font-synthesis: none;
106
+ text-rendering: optimizeLegibility;
107
+ -webkit-font-smoothing: antialiased;
108
+ -moz-osx-font-smoothing: grayscale;
109
+ }
110
+
111
+ body {
112
+ margin: 0;
113
+ min-width: 320px;
114
+ min-height: 100vh;
115
+ }
116
+ `,
117
+ },
118
+ ],
119
+ directories: [
120
+ "client/src/components",
121
+ "client/src/styles",
122
+ "client/public",
123
+ ],
124
+ dependencies: {
125
+ react: "^18.3.0",
126
+ "react-dom": "^18.3.0",
127
+ },
128
+ devDependencies: {
129
+ "@types/react": "^18.3.0",
130
+ "@types/react-dom": "^18.3.0",
131
+ tailwindcss: "^3.4.0",
132
+ postcss: "^8.4.0",
133
+ autoprefixer: "^10.4.0",
134
+ },
135
+ scripts: {
136
+ "dev:client": "bun run --watch client/index.html",
137
+ "build:client": "bun build ./client/src/main.tsx --outdir ./dist/client",
138
+ },
139
+ };
140
+ }