@buenojs/bueno 0.8.0

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 (120) hide show
  1. package/.env.example +109 -0
  2. package/.github/workflows/ci.yml +31 -0
  3. package/LICENSE +21 -0
  4. package/README.md +892 -0
  5. package/architecture.md +652 -0
  6. package/bun.lock +70 -0
  7. package/dist/cli/index.js +3233 -0
  8. package/dist/index.js +9014 -0
  9. package/package.json +77 -0
  10. package/src/cache/index.ts +795 -0
  11. package/src/cli/ARCHITECTURE.md +837 -0
  12. package/src/cli/bin.ts +10 -0
  13. package/src/cli/commands/build.ts +425 -0
  14. package/src/cli/commands/dev.ts +248 -0
  15. package/src/cli/commands/generate.ts +541 -0
  16. package/src/cli/commands/help.ts +55 -0
  17. package/src/cli/commands/index.ts +112 -0
  18. package/src/cli/commands/migration.ts +355 -0
  19. package/src/cli/commands/new.ts +804 -0
  20. package/src/cli/commands/start.ts +208 -0
  21. package/src/cli/core/args.ts +283 -0
  22. package/src/cli/core/console.ts +349 -0
  23. package/src/cli/core/index.ts +60 -0
  24. package/src/cli/core/prompt.ts +424 -0
  25. package/src/cli/core/spinner.ts +265 -0
  26. package/src/cli/index.ts +135 -0
  27. package/src/cli/templates/deploy.ts +295 -0
  28. package/src/cli/templates/docker.ts +307 -0
  29. package/src/cli/templates/index.ts +24 -0
  30. package/src/cli/utils/fs.ts +428 -0
  31. package/src/cli/utils/index.ts +8 -0
  32. package/src/cli/utils/strings.ts +197 -0
  33. package/src/config/env.ts +408 -0
  34. package/src/config/index.ts +506 -0
  35. package/src/config/loader.ts +329 -0
  36. package/src/config/merge.ts +285 -0
  37. package/src/config/types.ts +320 -0
  38. package/src/config/validation.ts +441 -0
  39. package/src/container/forward-ref.ts +143 -0
  40. package/src/container/index.ts +386 -0
  41. package/src/context/index.ts +360 -0
  42. package/src/database/index.ts +1142 -0
  43. package/src/database/migrations/index.ts +371 -0
  44. package/src/database/schema/index.ts +619 -0
  45. package/src/frontend/api-routes.ts +640 -0
  46. package/src/frontend/bundler.ts +643 -0
  47. package/src/frontend/console-client.ts +419 -0
  48. package/src/frontend/console-stream.ts +587 -0
  49. package/src/frontend/dev-server.ts +846 -0
  50. package/src/frontend/file-router.ts +611 -0
  51. package/src/frontend/frameworks/index.ts +106 -0
  52. package/src/frontend/frameworks/react.ts +85 -0
  53. package/src/frontend/frameworks/solid.ts +104 -0
  54. package/src/frontend/frameworks/svelte.ts +110 -0
  55. package/src/frontend/frameworks/vue.ts +92 -0
  56. package/src/frontend/hmr-client.ts +663 -0
  57. package/src/frontend/hmr.ts +728 -0
  58. package/src/frontend/index.ts +342 -0
  59. package/src/frontend/islands.ts +552 -0
  60. package/src/frontend/isr.ts +555 -0
  61. package/src/frontend/layout.ts +475 -0
  62. package/src/frontend/ssr/react.ts +446 -0
  63. package/src/frontend/ssr/solid.ts +523 -0
  64. package/src/frontend/ssr/svelte.ts +546 -0
  65. package/src/frontend/ssr/vue.ts +504 -0
  66. package/src/frontend/ssr.ts +699 -0
  67. package/src/frontend/types.ts +2274 -0
  68. package/src/health/index.ts +604 -0
  69. package/src/index.ts +410 -0
  70. package/src/lock/index.ts +587 -0
  71. package/src/logger/index.ts +444 -0
  72. package/src/logger/transports/index.ts +969 -0
  73. package/src/metrics/index.ts +494 -0
  74. package/src/middleware/built-in.ts +360 -0
  75. package/src/middleware/index.ts +94 -0
  76. package/src/modules/filters.ts +458 -0
  77. package/src/modules/guards.ts +405 -0
  78. package/src/modules/index.ts +1256 -0
  79. package/src/modules/interceptors.ts +574 -0
  80. package/src/modules/lazy.ts +418 -0
  81. package/src/modules/lifecycle.ts +478 -0
  82. package/src/modules/metadata.ts +90 -0
  83. package/src/modules/pipes.ts +626 -0
  84. package/src/router/index.ts +339 -0
  85. package/src/router/linear.ts +371 -0
  86. package/src/router/regex.ts +292 -0
  87. package/src/router/tree.ts +562 -0
  88. package/src/rpc/index.ts +1263 -0
  89. package/src/security/index.ts +436 -0
  90. package/src/ssg/index.ts +631 -0
  91. package/src/storage/index.ts +456 -0
  92. package/src/telemetry/index.ts +1097 -0
  93. package/src/testing/index.ts +1586 -0
  94. package/src/types/index.ts +236 -0
  95. package/src/types/optional-deps.d.ts +219 -0
  96. package/src/validation/index.ts +276 -0
  97. package/src/websocket/index.ts +1004 -0
  98. package/tests/integration/cli.test.ts +1016 -0
  99. package/tests/integration/fullstack.test.ts +234 -0
  100. package/tests/unit/cache.test.ts +174 -0
  101. package/tests/unit/cli-commands.test.ts +892 -0
  102. package/tests/unit/cli.test.ts +1258 -0
  103. package/tests/unit/container.test.ts +279 -0
  104. package/tests/unit/context.test.ts +221 -0
  105. package/tests/unit/database.test.ts +183 -0
  106. package/tests/unit/linear-router.test.ts +280 -0
  107. package/tests/unit/lock.test.ts +336 -0
  108. package/tests/unit/middleware.test.ts +184 -0
  109. package/tests/unit/modules.test.ts +142 -0
  110. package/tests/unit/pubsub.test.ts +257 -0
  111. package/tests/unit/regex-router.test.ts +265 -0
  112. package/tests/unit/router.test.ts +373 -0
  113. package/tests/unit/rpc.test.ts +1248 -0
  114. package/tests/unit/security.test.ts +174 -0
  115. package/tests/unit/telemetry.test.ts +371 -0
  116. package/tests/unit/test-cache.test.ts +110 -0
  117. package/tests/unit/test-database.test.ts +282 -0
  118. package/tests/unit/tree-router.test.ts +325 -0
  119. package/tests/unit/validation.test.ts +794 -0
  120. package/tsconfig.json +27 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * React Framework Build Configuration
3
+ *
4
+ * Provides build configuration specific to React applications,
5
+ * including JSX runtime, automatic import handling, and React-specific defines.
6
+ */
7
+
8
+ import type { FrameworkBuildConfig, BuildPlugin } from "../types.js";
9
+
10
+ /**
11
+ * React-specific build plugins
12
+ */
13
+ const reactPlugins: BuildPlugin[] = [];
14
+
15
+ /**
16
+ * Get React framework build configuration
17
+ */
18
+ export function getReactBuildConfig(): FrameworkBuildConfig {
19
+ return {
20
+ // React 17+ automatic JSX runtime
21
+ jsxRuntime: "automatic",
22
+ jsxImportSource: "react",
23
+
24
+ // React-specific file extensions
25
+ extensions: [".jsx", ".tsx", ".js", ".ts"],
26
+
27
+ // React-specific plugins
28
+ plugins: reactPlugins,
29
+
30
+ // React-specific global defines
31
+ define: {
32
+ // Enable React production mode in production builds
33
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
34
+ },
35
+
36
+ // External dependencies (should not be bundled in library mode)
37
+ external: [],
38
+
39
+ // Loader configurations for React files
40
+ loaders: {
41
+ ".jsx": "jsx",
42
+ ".tsx": "tsx",
43
+ },
44
+ };
45
+ }
46
+
47
+ /**
48
+ * Check if a file is a React component
49
+ */
50
+ export function isReactComponent(filePath: string): boolean {
51
+ return /\.(jsx|tsx)$/.test(filePath);
52
+ }
53
+
54
+ /**
55
+ * Get React refresh preamble for development
56
+ */
57
+ export function getReactRefreshPreamble(): string {
58
+ return `
59
+ import RefreshRuntime from 'react-refresh/runtime';
60
+ RefreshRuntime.injectIntoGlobalHook(window);
61
+ window.$RefreshReg$ = () => {};
62
+ window.$RefreshSig$ = () => (type) => type;
63
+ `;
64
+ }
65
+
66
+ /**
67
+ * React framework metadata
68
+ */
69
+ export const reactFrameworkMeta: {
70
+ name: "react";
71
+ displayName: string;
72
+ fileExtensions: string[];
73
+ componentExtensions: string[];
74
+ needsRefreshRuntime: boolean;
75
+ supportsHMR: boolean;
76
+ supportsSSR: boolean;
77
+ } = {
78
+ name: "react",
79
+ displayName: "React",
80
+ fileExtensions: [".jsx", ".tsx"],
81
+ componentExtensions: [".jsx", ".tsx"],
82
+ needsRefreshRuntime: true,
83
+ supportsHMR: true,
84
+ supportsSSR: true,
85
+ };
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Solid Framework Build Configuration
3
+ *
4
+ * Provides build configuration specific to Solid applications,
5
+ * including Solid JSX transforms and Solid-specific optimizations.
6
+ */
7
+
8
+ import type { FrameworkBuildConfig, BuildPlugin } from "../types.js";
9
+
10
+ /**
11
+ * Solid-specific build plugins
12
+ */
13
+ const solidPlugins: BuildPlugin[] = [];
14
+
15
+ /**
16
+ * Get Solid framework build configuration
17
+ */
18
+ export function getSolidBuildConfig(): FrameworkBuildConfig {
19
+ return {
20
+ // Solid uses automatic JSX runtime with solid-js
21
+ jsxRuntime: "automatic",
22
+ jsxImportSource: "solid-js",
23
+
24
+ // Solid-specific file extensions
25
+ extensions: [".jsx", ".tsx", ".js", ".ts"],
26
+
27
+ // Solid-specific plugins
28
+ plugins: solidPlugins,
29
+
30
+ // Solid-specific global defines
31
+ define: {
32
+ // Solid production mode
33
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
34
+ // Solid-specific flags
35
+ "DEV": JSON.stringify(process.env.NODE_ENV !== "production"),
36
+ },
37
+
38
+ // External dependencies
39
+ external: [],
40
+
41
+ // Loader configurations for Solid files
42
+ loaders: {
43
+ ".jsx": "jsx",
44
+ ".tsx": "tsx",
45
+ },
46
+ };
47
+ }
48
+
49
+ /**
50
+ * Check if a file is a Solid component
51
+ */
52
+ export function isSolidComponent(filePath: string): boolean {
53
+ return /\.(jsx|tsx)$/.test(filePath);
54
+ }
55
+
56
+ /**
57
+ * Get Solid refresh preamble for development
58
+ * Solid uses a different HMR mechanism than React
59
+ */
60
+ export function getSolidRefreshPreamble(): string {
61
+ return `
62
+ // Solid HMR is handled by solid-refresh
63
+ import { setHmr as setSolidHmr } from 'solid-js/web';
64
+ if (import.meta.hot) {
65
+ setSolidHmr(true);
66
+ }
67
+ `;
68
+ }
69
+
70
+ /**
71
+ * Solid babel-like transform options
72
+ * For use with custom build configurations
73
+ */
74
+ export function getSolidTransformOptions() {
75
+ return {
76
+ // Solid generates DOM elements
77
+ generate: "dom" as const,
78
+ // Enable hydration
79
+ hydratable: true,
80
+ // Compile time solid-js imports
81
+ runtime: "solid-js/web" as const,
82
+ };
83
+ }
84
+
85
+ /**
86
+ * Solid framework metadata
87
+ */
88
+ export const solidFrameworkMeta: {
89
+ name: "solid";
90
+ displayName: string;
91
+ fileExtensions: string[];
92
+ componentExtensions: string[];
93
+ needsRefreshRuntime: boolean;
94
+ supportsHMR: boolean;
95
+ supportsSSR: boolean;
96
+ } = {
97
+ name: "solid",
98
+ displayName: "Solid",
99
+ fileExtensions: [".jsx", ".tsx"],
100
+ componentExtensions: [".jsx", ".tsx"],
101
+ needsRefreshRuntime: true,
102
+ supportsHMR: true,
103
+ supportsSSR: true,
104
+ };
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Svelte Framework Build Configuration
3
+ *
4
+ * Provides build configuration specific to Svelte applications,
5
+ * including Svelte SFC support and Svelte-specific preprocessing.
6
+ */
7
+
8
+ import type { FrameworkBuildConfig, BuildPlugin } from "../types.js";
9
+
10
+ /**
11
+ * Svelte-specific build plugins
12
+ * Note: Svelte compilation requires svelte-preprocess
13
+ */
14
+ const sveltePlugins: BuildPlugin[] = [];
15
+
16
+ /**
17
+ * Get Svelte framework build configuration
18
+ */
19
+ export function getSvelteBuildConfig(): FrameworkBuildConfig {
20
+ return {
21
+ // Svelte doesn't use JSX runtime in the traditional sense
22
+ jsxRuntime: "classic",
23
+
24
+ // Svelte-specific file extensions
25
+ extensions: [".svelte", ".js", ".ts"],
26
+
27
+ // Svelte-specific plugins
28
+ plugins: sveltePlugins,
29
+
30
+ // Svelte-specific global defines
31
+ define: {
32
+ // Svelte production mode
33
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
34
+ },
35
+
36
+ // External dependencies
37
+ external: [],
38
+
39
+ // Loader configurations for Svelte files
40
+ loaders: {
41
+ ".svelte": "js", // Svelte SFCs are compiled to JS
42
+ },
43
+ };
44
+ }
45
+
46
+ /**
47
+ * Check if a file is a Svelte component
48
+ */
49
+ export function isSvelteComponent(filePath: string): boolean {
50
+ return /\.svelte$/.test(filePath);
51
+ }
52
+
53
+ /**
54
+ * Get Svelte preprocessor configuration
55
+ * Returns configuration for svelte-preprocess
56
+ */
57
+ export function getSveltePreprocessConfig() {
58
+ return {
59
+ typescript: {
60
+ compilerOptions: {
61
+ // Enable TypeScript in Svelte files
62
+ allowJs: true,
63
+ checkJs: false,
64
+ },
65
+ },
66
+ postcss: true,
67
+ scss: {
68
+ prependData: "",
69
+ },
70
+ };
71
+ }
72
+
73
+ /**
74
+ * Svelte compiler options
75
+ */
76
+ export function getSvelteCompilerOptions() {
77
+ return {
78
+ // Enable CSS hashing for scoped styles
79
+ cssHash: ({ hash, css, name }: { hash: (s: string) => string; css: string; name: string }) => {
80
+ return `svelte-${hash(css)}-${name}`;
81
+ },
82
+ // Generate SSR-friendly code
83
+ generate: "dom" as const,
84
+ // Enable hydration
85
+ hydratable: true,
86
+ // Preserve whitespace in development
87
+ preserveWhitespace: process.env.NODE_ENV !== "production",
88
+ };
89
+ }
90
+
91
+ /**
92
+ * Svelte framework metadata
93
+ */
94
+ export const svelteFrameworkMeta: {
95
+ name: "svelte";
96
+ displayName: string;
97
+ fileExtensions: string[];
98
+ componentExtensions: string[];
99
+ needsRefreshRuntime: boolean;
100
+ supportsHMR: boolean;
101
+ supportsSSR: boolean;
102
+ } = {
103
+ name: "svelte",
104
+ displayName: "Svelte",
105
+ fileExtensions: [".svelte"],
106
+ componentExtensions: [".svelte"],
107
+ needsRefreshRuntime: false, // Svelte has built-in HMR
108
+ supportsHMR: true,
109
+ supportsSSR: true,
110
+ };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Vue Framework Build Configuration
3
+ *
4
+ * Provides build configuration specific to Vue applications,
5
+ * including Vue SFC support, JSX configuration, and Vue-specific defines.
6
+ */
7
+
8
+ import type { FrameworkBuildConfig, BuildPlugin } from "../types.js";
9
+
10
+ /**
11
+ * Vue-specific build plugins
12
+ * Note: Vue SFC compilation is handled by Bun's built-in support
13
+ */
14
+ const vuePlugins: BuildPlugin[] = [];
15
+
16
+ /**
17
+ * Get Vue framework build configuration
18
+ */
19
+ export function getVueBuildConfig(): FrameworkBuildConfig {
20
+ return {
21
+ // Vue uses classic JSX runtime
22
+ jsxRuntime: "classic",
23
+
24
+ // Vue-specific file extensions
25
+ extensions: [".vue", ".jsx", ".tsx", ".js", ".ts"],
26
+
27
+ // Vue-specific plugins
28
+ plugins: vuePlugins,
29
+
30
+ // Vue-specific global defines
31
+ define: {
32
+ // Vue production mode flag
33
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
34
+ // Vue 3 specific features
35
+ "__VUE_OPTIONS_API__": "true",
36
+ "__VUE_PROD_DEVTOOLS__": "false",
37
+ "__VUE_PROD_HYDRATION_MISMATCH_DETAILS__": "false",
38
+ },
39
+
40
+ // External dependencies
41
+ external: [],
42
+
43
+ // Loader configurations for Vue files
44
+ loaders: {
45
+ ".vue": "js", // Vue SFCs are compiled to JS
46
+ ".jsx": "jsx",
47
+ ".tsx": "tsx",
48
+ },
49
+ };
50
+ }
51
+
52
+ /**
53
+ * Check if a file is a Vue component
54
+ */
55
+ export function isVueComponent(filePath: string): boolean {
56
+ return /\.vue$/.test(filePath);
57
+ }
58
+
59
+ /**
60
+ * Check if a file uses Vue JSX
61
+ */
62
+ export function isVueJsx(filePath: string): boolean {
63
+ return /\.(j|t)sx$/.test(filePath);
64
+ }
65
+
66
+ /**
67
+ * Get Vue SFC block types
68
+ */
69
+ export function getVueBlockTypes(): string[] {
70
+ return ["template", "script", "style", "customBlocks"];
71
+ }
72
+
73
+ /**
74
+ * Vue framework metadata
75
+ */
76
+ export const vueFrameworkMeta: {
77
+ name: "vue";
78
+ displayName: string;
79
+ fileExtensions: string[];
80
+ componentExtensions: string[];
81
+ needsRefreshRuntime: boolean;
82
+ supportsHMR: boolean;
83
+ supportsSSR: boolean;
84
+ } = {
85
+ name: "vue",
86
+ displayName: "Vue",
87
+ fileExtensions: [".vue", ".jsx", ".tsx"],
88
+ componentExtensions: [".vue"],
89
+ needsRefreshRuntime: false, // Vue has built-in HMR
90
+ supportsHMR: true,
91
+ supportsSSR: true,
92
+ };