create-fluxstack 1.0.13 → 1.0.14

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 (214) hide show
  1. package/.env.example +29 -29
  2. package/app/client/README.md +69 -69
  3. package/app/client/index.html +14 -13
  4. package/app/client/src/App.tsx +157 -524
  5. package/app/client/src/components/ErrorBoundary.tsx +107 -0
  6. package/app/client/src/components/ErrorDisplay.css +365 -0
  7. package/app/client/src/components/ErrorDisplay.tsx +258 -0
  8. package/app/client/src/components/FluxStackConfig.tsx +1321 -0
  9. package/app/client/src/components/HybridLiveCounter.tsx +140 -0
  10. package/app/client/src/components/LiveClock.tsx +286 -0
  11. package/app/client/src/components/MainLayout.tsx +390 -0
  12. package/app/client/src/components/SidebarNavigation.tsx +391 -0
  13. package/app/client/src/components/StateDemo.tsx +178 -0
  14. package/app/client/src/components/SystemMonitor.tsx +1038 -0
  15. package/app/client/src/components/Teste.tsx +104 -0
  16. package/app/client/src/components/UserProfile.tsx +809 -0
  17. package/app/client/src/hooks/useAuth.ts +39 -0
  18. package/app/client/src/hooks/useNotifications.ts +56 -0
  19. package/app/client/src/lib/eden-api.ts +189 -53
  20. package/app/client/src/lib/errors.ts +340 -0
  21. package/app/client/src/lib/hooks/useErrorHandler.ts +258 -0
  22. package/app/client/src/lib/index.ts +45 -0
  23. package/app/client/src/main.tsx +3 -2
  24. package/app/client/src/pages/ApiDocs.tsx +182 -0
  25. package/app/client/src/pages/Demo.tsx +174 -0
  26. package/app/client/src/pages/HybridLive.tsx +263 -0
  27. package/app/client/src/pages/Overview.tsx +155 -0
  28. package/app/client/src/store/README.md +43 -0
  29. package/app/client/src/store/index.ts +16 -0
  30. package/app/client/src/store/slices/uiSlice.ts +151 -0
  31. package/app/client/src/store/slices/userSlice.ts +161 -0
  32. package/app/client/src/test/README.md +257 -0
  33. package/app/client/src/test/setup.ts +70 -0
  34. package/app/client/src/test/types.ts +12 -0
  35. package/app/client/src/vite-env.d.ts +1 -1
  36. package/app/client/tsconfig.app.json +44 -43
  37. package/app/client/tsconfig.json +7 -7
  38. package/app/client/tsconfig.node.json +25 -25
  39. package/app/client/zustand-setup.md +65 -0
  40. package/app/server/controllers/users.controller.ts +68 -68
  41. package/app/server/index.ts +9 -1
  42. package/app/server/live/CounterComponent.ts +191 -0
  43. package/app/server/live/FluxStackConfig.ts +529 -0
  44. package/app/server/live/LiveClockComponent.ts +214 -0
  45. package/app/server/live/SidebarNavigation.ts +156 -0
  46. package/app/server/live/SystemMonitor.ts +594 -0
  47. package/app/server/live/SystemMonitorIntegration.ts +151 -0
  48. package/app/server/live/TesteComponent.ts +87 -0
  49. package/app/server/live/UserProfileComponent.ts +135 -0
  50. package/app/server/live/register-components.ts +28 -0
  51. package/app/server/middleware/auth.ts +136 -0
  52. package/app/server/middleware/errorHandling.ts +250 -0
  53. package/app/server/middleware/index.ts +10 -0
  54. package/app/server/middleware/rateLimit.ts +193 -0
  55. package/app/server/middleware/requestLogging.ts +215 -0
  56. package/app/server/middleware/validation.ts +270 -0
  57. package/app/server/routes/index.ts +14 -2
  58. package/app/server/routes/upload.ts +92 -0
  59. package/app/server/routes/users.routes.ts +2 -9
  60. package/app/server/services/NotificationService.ts +302 -0
  61. package/app/server/services/UserService.ts +222 -0
  62. package/app/server/services/index.ts +46 -0
  63. package/core/cli/commands/plugin-deps.ts +263 -0
  64. package/core/cli/generators/README.md +339 -0
  65. package/core/cli/generators/component.ts +770 -0
  66. package/core/cli/generators/controller.ts +299 -0
  67. package/core/cli/generators/index.ts +144 -0
  68. package/core/cli/generators/interactive.ts +228 -0
  69. package/core/cli/generators/prompts.ts +83 -0
  70. package/core/cli/generators/route.ts +513 -0
  71. package/core/cli/generators/service.ts +465 -0
  72. package/core/cli/generators/template-engine.ts +154 -0
  73. package/core/cli/generators/types.ts +71 -0
  74. package/core/cli/generators/utils.ts +192 -0
  75. package/core/cli/index.ts +69 -0
  76. package/core/cli/plugin-discovery.ts +16 -85
  77. package/core/client/fluxstack.ts +17 -0
  78. package/core/client/hooks/index.ts +7 -0
  79. package/core/client/hooks/state-validator.ts +130 -0
  80. package/core/client/hooks/useAuth.ts +49 -0
  81. package/core/client/hooks/useChunkedUpload.ts +258 -0
  82. package/core/client/hooks/useHybridLiveComponent.ts +967 -0
  83. package/core/client/hooks/useWebSocket.ts +373 -0
  84. package/core/client/index.ts +47 -0
  85. package/core/client/state/createStore.ts +193 -0
  86. package/core/client/state/index.ts +15 -0
  87. package/core/config/env-dynamic.ts +1 -1
  88. package/core/config/env.ts +2 -1
  89. package/core/config/runtime-config.ts +3 -3
  90. package/core/config/schema.ts +84 -49
  91. package/core/framework/server.ts +30 -0
  92. package/core/index.ts +25 -0
  93. package/core/live/ComponentRegistry.ts +399 -0
  94. package/core/live/types.ts +164 -0
  95. package/core/plugins/built-in/live-components/commands/create-live-component.ts +1201 -0
  96. package/core/plugins/built-in/live-components/index.ts +27 -0
  97. package/core/plugins/built-in/logger/index.ts +1 -1
  98. package/core/plugins/built-in/monitoring/index.ts +1 -1
  99. package/core/plugins/built-in/static/index.ts +1 -1
  100. package/core/plugins/built-in/swagger/index.ts +1 -1
  101. package/core/plugins/built-in/vite/index.ts +1 -1
  102. package/core/plugins/dependency-manager.ts +384 -0
  103. package/core/plugins/index.ts +5 -1
  104. package/core/plugins/manager.ts +7 -3
  105. package/core/plugins/registry.ts +88 -10
  106. package/core/plugins/types.ts +11 -11
  107. package/core/server/framework.ts +43 -0
  108. package/core/server/index.ts +11 -1
  109. package/core/server/live/ComponentRegistry.ts +1017 -0
  110. package/core/server/live/FileUploadManager.ts +272 -0
  111. package/core/server/live/LiveComponentPerformanceMonitor.ts +930 -0
  112. package/core/server/live/SingleConnectionManager.ts +0 -0
  113. package/core/server/live/StateSignature.ts +644 -0
  114. package/core/server/live/WebSocketConnectionManager.ts +688 -0
  115. package/core/server/live/websocket-plugin.ts +435 -0
  116. package/core/server/middleware/errorHandling.ts +141 -0
  117. package/core/server/middleware/index.ts +16 -0
  118. package/core/server/plugins/static-files-plugin.ts +232 -0
  119. package/core/server/services/BaseService.ts +95 -0
  120. package/core/server/services/ServiceContainer.ts +144 -0
  121. package/core/server/services/index.ts +9 -0
  122. package/core/templates/create-project.ts +46 -2
  123. package/core/testing/index.ts +10 -0
  124. package/core/testing/setup.ts +74 -0
  125. package/core/types/build.ts +38 -14
  126. package/core/types/types.ts +319 -0
  127. package/core/utils/env-runtime.ts +7 -0
  128. package/core/utils/errors/handlers.ts +264 -39
  129. package/core/utils/errors/index.ts +528 -18
  130. package/core/utils/errors/middleware.ts +114 -0
  131. package/core/utils/logger/formatters.ts +222 -0
  132. package/core/utils/logger/index.ts +167 -48
  133. package/core/utils/logger/middleware.ts +253 -0
  134. package/core/utils/logger/performance.ts +384 -0
  135. package/core/utils/logger/transports.ts +365 -0
  136. package/create-fluxstack.ts +296 -296
  137. package/fluxstack.config.ts +17 -1
  138. package/package-template.json +66 -66
  139. package/package.json +31 -6
  140. package/public/README.md +16 -0
  141. package/vite.config.ts +29 -14
  142. package/.claude/settings.local.json +0 -74
  143. package/.github/workflows/ci-build-tests.yml +0 -480
  144. package/.github/workflows/dependency-management.yml +0 -324
  145. package/.github/workflows/release-validation.yml +0 -355
  146. package/.kiro/specs/fluxstack-architecture-optimization/design.md +0 -700
  147. package/.kiro/specs/fluxstack-architecture-optimization/requirements.md +0 -127
  148. package/.kiro/specs/fluxstack-architecture-optimization/tasks.md +0 -330
  149. package/CLAUDE.md +0 -200
  150. package/Dockerfile +0 -58
  151. package/Dockerfile.backend +0 -52
  152. package/Dockerfile.frontend +0 -54
  153. package/README-Docker.md +0 -85
  154. package/ai-context/00-QUICK-START.md +0 -86
  155. package/ai-context/README.md +0 -88
  156. package/ai-context/development/eden-treaty-guide.md +0 -362
  157. package/ai-context/development/patterns.md +0 -382
  158. package/ai-context/development/plugins-guide.md +0 -572
  159. package/ai-context/examples/crud-complete.md +0 -626
  160. package/ai-context/project/architecture.md +0 -399
  161. package/ai-context/project/overview.md +0 -213
  162. package/ai-context/recent-changes/eden-treaty-refactor.md +0 -281
  163. package/ai-context/recent-changes/type-inference-fix.md +0 -223
  164. package/ai-context/reference/environment-vars.md +0 -384
  165. package/ai-context/reference/troubleshooting.md +0 -407
  166. package/app/client/src/components/TestPage.tsx +0 -453
  167. package/bun.lock +0 -1063
  168. package/bunfig.toml +0 -16
  169. package/core/__tests__/integration.test.ts +0 -227
  170. package/core/build/index.ts +0 -186
  171. package/core/config/__tests__/config-loader.test.ts +0 -554
  172. package/core/config/__tests__/config-merger.test.ts +0 -657
  173. package/core/config/__tests__/env-converter.test.ts +0 -372
  174. package/core/config/__tests__/env-processor.test.ts +0 -431
  175. package/core/config/__tests__/env.test.ts +0 -452
  176. package/core/config/__tests__/integration.test.ts +0 -418
  177. package/core/config/__tests__/loader.test.ts +0 -331
  178. package/core/config/__tests__/schema.test.ts +0 -129
  179. package/core/config/__tests__/validator.test.ts +0 -318
  180. package/core/framework/__tests__/server.test.ts +0 -233
  181. package/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  182. package/core/plugins/__tests__/manager.test.ts +0 -398
  183. package/core/plugins/__tests__/monitoring.test.ts +0 -401
  184. package/core/plugins/__tests__/registry.test.ts +0 -335
  185. package/core/utils/__tests__/errors.test.ts +0 -139
  186. package/core/utils/__tests__/helpers.test.ts +0 -297
  187. package/core/utils/__tests__/logger.test.ts +0 -141
  188. package/create-test-app.ts +0 -156
  189. package/docker-compose.microservices.yml +0 -75
  190. package/docker-compose.simple.yml +0 -57
  191. package/docker-compose.yml +0 -71
  192. package/eslint.config.js +0 -23
  193. package/flux-cli.ts +0 -214
  194. package/nginx-lb.conf +0 -37
  195. package/publish.sh +0 -63
  196. package/run-clean.ts +0 -26
  197. package/run-env-tests.ts +0 -313
  198. package/tailwind.config.js +0 -34
  199. package/tests/__mocks__/api.ts +0 -56
  200. package/tests/fixtures/users.ts +0 -69
  201. package/tests/integration/api/users.routes.test.ts +0 -221
  202. package/tests/setup.ts +0 -29
  203. package/tests/unit/app/client/App-simple.test.tsx +0 -56
  204. package/tests/unit/app/client/App.test.tsx.skip +0 -237
  205. package/tests/unit/app/client/eden-api.test.ts +0 -186
  206. package/tests/unit/app/client/simple.test.tsx +0 -23
  207. package/tests/unit/app/controllers/users.controller.test.ts +0 -150
  208. package/tests/unit/core/create-project.test.ts.skip +0 -95
  209. package/tests/unit/core/framework.test.ts +0 -144
  210. package/tests/unit/core/plugins/logger.test.ts.skip +0 -268
  211. package/tests/unit/core/plugins/vite.test.ts.disabled +0 -188
  212. package/tests/utils/test-helpers.ts +0 -61
  213. package/vitest.config.ts +0 -50
  214. package/workspace.json +0 -6
@@ -1,331 +0,0 @@
1
- /**
2
- * Tests for Configuration Loader
3
- */
4
-
5
- import { describe, it, expect, beforeEach, afterEach } from 'vitest'
6
- import {
7
- loadConfig,
8
- loadConfigSync,
9
- getConfigValue,
10
- hasConfigValue,
11
- createConfigSubset
12
- } from '../loader'
13
- import { defaultFluxStackConfig } from '../schema'
14
- import { writeFileSync, unlinkSync, existsSync } from 'fs'
15
- import { join } from 'path'
16
-
17
- describe('Configuration Loader', () => {
18
- const testConfigPath = join(process.cwd(), 'test.config.ts')
19
- const originalEnv = { ...process.env }
20
-
21
- beforeEach(() => {
22
- // Clean up environment
23
- Object.keys(process.env).forEach(key => {
24
- if (key.startsWith('FLUXSTACK_') || key.startsWith('TEST_') ||
25
- ['PORT', 'HOST', 'LOG_LEVEL', 'CORS_ORIGINS', 'CORS_METHODS', 'CORS_HEADERS',
26
- 'CORS_CREDENTIALS', 'MONITORING_ENABLED', 'VITE_PORT'].includes(key)) {
27
- delete process.env[key]
28
- }
29
- })
30
- })
31
-
32
- afterEach(() => {
33
- // Restore original environment
34
- process.env = { ...originalEnv }
35
-
36
- // Clean up test files
37
- if (existsSync(testConfigPath)) {
38
- unlinkSync(testConfigPath)
39
- }
40
- })
41
-
42
- describe('loadConfigSync', () => {
43
- it('should load default configuration', () => {
44
- const result = loadConfigSync({ environment: 'development' })
45
-
46
- expect(result.config).toBeDefined()
47
- expect(result.sources).toContain('defaults')
48
- expect(result.errors).toHaveLength(0)
49
- })
50
-
51
- it('should load environment variables', () => {
52
- process.env.PORT = '4000'
53
- process.env.FLUXSTACK_APP_NAME = 'test-app'
54
- process.env.LOG_LEVEL = 'debug'
55
-
56
- const result = loadConfigSync({ environment: 'development' })
57
-
58
- expect(result.config.server.port).toBe(4000)
59
- expect(result.config.app.name).toBe('test-app')
60
- expect(result.config.logging.level).toBe('debug')
61
- expect(result.sources).toContain('environment')
62
- })
63
-
64
- it('should handle boolean environment variables', () => {
65
- process.env.FLUXSTACK_CORS_CREDENTIALS = 'true'
66
- process.env.FLUXSTACK_BUILD_MINIFY = 'false'
67
- process.env.MONITORING_ENABLED = 'true'
68
-
69
- const result = loadConfigSync()
70
-
71
- expect(result.config.server.cors.credentials).toBe(true)
72
- expect(result.config.build.optimization.minify).toBe(false)
73
- expect(result.config.monitoring.enabled).toBe(true)
74
- })
75
-
76
- it('should handle array environment variables', () => {
77
- process.env.CORS_ORIGINS = 'http://localhost:3000,http://localhost:5173,https://example.com'
78
- process.env.CORS_METHODS = 'GET,POST,PUT,DELETE'
79
-
80
- const result = loadConfigSync()
81
-
82
- expect(result.config.server.cors.origins).toEqual([
83
- 'http://localhost:3000',
84
- 'http://localhost:5173',
85
- 'https://example.com'
86
- ])
87
- expect(result.config.server.cors.methods).toEqual(['GET', 'POST', 'PUT', 'DELETE'])
88
- })
89
-
90
- it('should handle custom environment variables', () => {
91
- process.env.FLUXSTACK_CUSTOM_FEATURE = 'enabled'
92
- process.env.FLUXSTACK_CUSTOM_TIMEOUT = '5000'
93
-
94
- const result = loadConfigSync({ environment: 'development' })
95
-
96
- expect(result.config.custom?.['custom.feature']).toBe('enabled')
97
- expect(result.config.custom?.['custom.timeout']).toBe(5000)
98
- })
99
-
100
- it('should apply environment-specific configuration', () => {
101
- const originalNodeEnv = process.env.NODE_ENV
102
- process.env.NODE_ENV = 'development'
103
-
104
- const result = loadConfigSync()
105
-
106
- expect(result.config.logging.level).toBe('debug')
107
- expect(result.config.logging.format).toBe('pretty')
108
- expect(result.sources).toContain('environment:development')
109
-
110
- process.env.NODE_ENV = originalNodeEnv
111
- })
112
- })
113
-
114
- describe('loadConfig (async)', () => {
115
- it('should load configuration from file', async () => {
116
- // Create test configuration file
117
- const testConfig = `
118
- export default {
119
- app: {
120
- name: 'file-test-app',
121
- version: '2.0.0'
122
- },
123
- server: {
124
- port: 8080,
125
- host: 'test-host',
126
- apiPrefix: '/test-api',
127
- cors: {
128
- origins: ['http://test.com'],
129
- methods: ['GET', 'POST'],
130
- headers: ['Content-Type']
131
- },
132
- middleware: []
133
- }
134
- }
135
- `
136
-
137
- writeFileSync(testConfigPath, testConfig)
138
-
139
- const result = await loadConfig({ configPath: testConfigPath, environment: 'development' })
140
-
141
- expect(result.config.app.name).toBe('file-test-app')
142
- expect(result.config.server.port).toBe(8080)
143
- expect(result.config.server.host).toBe('test-host')
144
- expect(result.sources).toContain(`file:${testConfigPath}`)
145
- })
146
-
147
- it('should merge file config with environment variables', async () => {
148
- process.env.PORT = '9000'
149
- process.env.FLUXSTACK_APP_NAME = 'env-override'
150
-
151
- const testConfig = `
152
- export default {
153
- app: {
154
- name: 'file-app',
155
- version: '1.0.0'
156
- },
157
- server: {
158
- port: 8080,
159
- host: 'localhost',
160
- apiPrefix: '/api',
161
- cors: {
162
- origins: ['http://localhost:3000'],
163
- methods: ['GET'],
164
- headers: ['Content-Type']
165
- },
166
- middleware: []
167
- }
168
- }
169
- `
170
-
171
- writeFileSync(testConfigPath, testConfig)
172
-
173
- const result = await loadConfig({ configPath: testConfigPath, environment: 'development' })
174
-
175
- // Environment variables should override file config
176
- expect(result.config.server.port).toBe(9000)
177
- expect(result.config.app.name).toBe('env-override')
178
- expect(result.sources).toContain('environment')
179
- expect(result.sources).toContain(`file:${testConfigPath}`)
180
- })
181
-
182
- it('should handle configuration file errors gracefully', async () => {
183
- const result = await loadConfig({ configPath: 'non-existent-config.ts' })
184
-
185
- expect(result.errors.length).toBeGreaterThan(0)
186
- expect(result.config).toBeDefined() // Should fall back to defaults
187
- })
188
-
189
- it('should validate configuration when requested', async () => {
190
- const invalidConfig = `
191
- export default {
192
- app: {
193
- name: '',
194
- version: 'invalid-version'
195
- }
196
- }
197
- `
198
-
199
- writeFileSync(testConfigPath, invalidConfig)
200
-
201
- const result = await loadConfig({
202
- configPath: testConfigPath,
203
- validateSchema: true
204
- })
205
-
206
- // Current implementation is lenient - doesn't fail on minor validation issues
207
- expect(result.errors.length).toBe(0)
208
- expect(result.config).toBeDefined()
209
- expect(result.warnings).toBeDefined()
210
- })
211
- })
212
-
213
- describe('getConfigValue', () => {
214
- it('should get nested configuration values', () => {
215
- const config = defaultFluxStackConfig
216
-
217
- expect(getConfigValue(config, 'app.name', '')).toBe(config.app.name)
218
- expect(getConfigValue(config, 'server.port', 0)).toBe(config.server.port)
219
- expect(getConfigValue(config, 'server.cors.origins', [] as string[])).toEqual(config.server.cors.origins)
220
- })
221
-
222
- it('should return default value for missing paths', () => {
223
- const config = defaultFluxStackConfig
224
-
225
- expect(getConfigValue(config, 'nonexistent.path', 'default')).toBe('default')
226
- expect(getConfigValue(config, 'app.nonexistent', null)).toBe(null)
227
- })
228
-
229
- it('should handle deep nested paths', () => {
230
- const config = defaultFluxStackConfig
231
-
232
- expect(getConfigValue(config, 'build.optimization.minify', false)).toBe(config.build.optimization.minify)
233
- expect(getConfigValue(config, 'monitoring.metrics.enabled', false)).toBe(config.monitoring.metrics.enabled)
234
- })
235
- })
236
-
237
- describe('hasConfigValue', () => {
238
- it('should check if configuration values exist', () => {
239
- const config = defaultFluxStackConfig
240
-
241
- expect(hasConfigValue(config, 'app.name')).toBe(true)
242
- expect(hasConfigValue(config, 'server.port')).toBe(true)
243
- expect(hasConfigValue(config, 'nonexistent.path')).toBe(false)
244
- })
245
-
246
- it('should handle optional configurations', () => {
247
- const config = { ...defaultFluxStackConfig, database: { url: 'test://db' } }
248
-
249
- expect(hasConfigValue(config, 'database.url')).toBe(true)
250
- expect(hasConfigValue(config, 'database.host')).toBe(false)
251
- })
252
- })
253
-
254
- describe('createConfigSubset', () => {
255
- it('should create configuration subset', () => {
256
- const config = defaultFluxStackConfig
257
- const paths = ['app.name', 'server.port', 'logging.level']
258
-
259
- const subset = createConfigSubset(config, paths)
260
-
261
- expect(subset.app.name).toBe(config.app.name)
262
- expect(subset.server.port).toBe(config.server.port)
263
- expect(subset.logging.level).toBe(config.logging.level)
264
- expect(subset.client).toBeUndefined()
265
- })
266
-
267
- it('should handle missing paths gracefully', () => {
268
- const config = defaultFluxStackConfig
269
- const paths = ['app.name', 'nonexistent.path', 'server.port']
270
-
271
- const subset = createConfigSubset(config, paths)
272
-
273
- expect(subset.app.name).toBe(config.app.name)
274
- expect(subset.server.port).toBe(config.server.port)
275
- expect(subset.nonexistent).toBeUndefined()
276
- })
277
- })
278
-
279
- describe('Environment Handling', () => {
280
- it('should handle different NODE_ENV values', () => {
281
- const environments = ['development', 'production', 'test']
282
-
283
- environments.forEach(env => {
284
- process.env.NODE_ENV = env
285
- const result = loadConfigSync({ environment: env })
286
-
287
- expect(result.sources).toContain(`environment:${env}`)
288
- expect(result.config).toBeDefined()
289
- })
290
- })
291
-
292
- it('should apply correct environment defaults', () => {
293
- process.env.NODE_ENV = 'production'
294
- const result = loadConfigSync({ environment: 'production' })
295
-
296
- expect(result.config.logging.level).toBe('warn')
297
- expect(result.config.logging.format).toBe('json')
298
- expect(result.config.monitoring.enabled).toBe(true)
299
- })
300
-
301
- it('should handle custom environment names', () => {
302
- const result = loadConfigSync({ environment: 'staging' })
303
-
304
- expect(result.sources).toContain('environment:staging')
305
- expect(result.config).toBeDefined()
306
- })
307
- })
308
-
309
- describe('Error Handling', () => {
310
- it('should collect and report warnings', () => {
311
- process.env.INVALID_ENV_VAR = 'invalid-json-{'
312
-
313
- const result = loadConfigSync()
314
-
315
- // Should not fail, but may have warnings
316
- expect(result.config).toBeDefined()
317
- expect(result.errors).toBeDefined()
318
- })
319
-
320
- it('should handle malformed environment variables', () => {
321
- process.env.PORT = 'not-a-number'
322
- process.env.MONITORING_ENABLED = 'maybe'
323
-
324
- const result = loadConfigSync()
325
-
326
- // Should use defaults for invalid values
327
- expect(typeof result.config.server.port).toBe('number')
328
- expect(typeof result.config.monitoring.enabled).toBe('boolean')
329
- })
330
- })
331
- })
@@ -1,129 +0,0 @@
1
- /**
2
- * Tests for FluxStack Configuration Schema
3
- */
4
-
5
- import { describe, it, expect } from 'vitest'
6
- import {
7
- defaultFluxStackConfig,
8
- environmentDefaults,
9
- fluxStackConfigSchema,
10
- type FluxStackConfig
11
- } from '../schema'
12
-
13
- describe('Configuration Schema', () => {
14
- describe('defaultFluxStackConfig', () => {
15
- it('should have all required properties', () => {
16
- expect(defaultFluxStackConfig).toHaveProperty('app')
17
- expect(defaultFluxStackConfig).toHaveProperty('server')
18
- expect(defaultFluxStackConfig).toHaveProperty('client')
19
- expect(defaultFluxStackConfig).toHaveProperty('build')
20
- expect(defaultFluxStackConfig).toHaveProperty('plugins')
21
- expect(defaultFluxStackConfig).toHaveProperty('logging')
22
- expect(defaultFluxStackConfig).toHaveProperty('monitoring')
23
- })
24
-
25
- it('should have valid app configuration', () => {
26
- expect(defaultFluxStackConfig.app.name).toBe('fluxstack-app')
27
- expect(defaultFluxStackConfig.app.version).toBe('1.0.0')
28
- expect(defaultFluxStackConfig.app.description).toBe('A FluxStack application')
29
- })
30
-
31
- it('should have valid server configuration', () => {
32
- expect(defaultFluxStackConfig.server.port).toBe(3000)
33
- expect(defaultFluxStackConfig.server.host).toBe('localhost')
34
- expect(defaultFluxStackConfig.server.apiPrefix).toBe('/api')
35
- expect(defaultFluxStackConfig.server.cors.origins).toContain('http://localhost:3000')
36
- expect(defaultFluxStackConfig.server.cors.methods).toContain('GET')
37
- })
38
-
39
- it('should have valid client configuration', () => {
40
- expect(defaultFluxStackConfig.client.port).toBe(5173)
41
- expect(defaultFluxStackConfig.client.proxy.target).toBe('http://localhost:3000')
42
- expect(defaultFluxStackConfig.client.build.sourceMaps).toBe(true)
43
- })
44
-
45
- it('should have valid build configuration', () => {
46
- expect(defaultFluxStackConfig.build.target).toBe('bun')
47
- expect(defaultFluxStackConfig.build.outDir).toBe('dist')
48
- expect(defaultFluxStackConfig.build.optimization.minify).toBe(true)
49
- })
50
- })
51
-
52
- describe('environmentDefaults', () => {
53
- it('should have development overrides', () => {
54
- expect(environmentDefaults.development.logging?.level).toBe('debug')
55
- expect(environmentDefaults.development.logging?.format).toBe('pretty')
56
- expect(environmentDefaults.development.build?.optimization.minify).toBe(false)
57
- })
58
-
59
- it('should have production overrides', () => {
60
- expect(environmentDefaults.production.logging?.level).toBe('warn')
61
- expect(environmentDefaults.production.logging?.format).toBe('json')
62
- expect(environmentDefaults.production.monitoring?.enabled).toBe(true)
63
- })
64
-
65
- it('should have test overrides', () => {
66
- expect(environmentDefaults.test.logging?.level).toBe('error')
67
- expect(environmentDefaults.test.server?.port).toBe(0)
68
- expect(environmentDefaults.test.client?.port).toBe(0)
69
- })
70
- })
71
-
72
- describe('fluxStackConfigSchema', () => {
73
- it('should be a valid JSON schema', () => {
74
- expect(fluxStackConfigSchema).toHaveProperty('type', 'object')
75
- expect(fluxStackConfigSchema).toHaveProperty('properties')
76
- expect(fluxStackConfigSchema).toHaveProperty('required')
77
- })
78
-
79
- it('should require essential properties', () => {
80
- const required = fluxStackConfigSchema.required
81
- expect(required).toContain('app')
82
- expect(required).toContain('server')
83
- expect(required).toContain('client')
84
- expect(required).toContain('build')
85
- expect(required).toContain('plugins')
86
- expect(required).toContain('logging')
87
- expect(required).toContain('monitoring')
88
- })
89
-
90
- it('should have proper app schema', () => {
91
- const appSchema = fluxStackConfigSchema.properties.app
92
- expect(appSchema.required).toContain('name')
93
- expect(appSchema.required).toContain('version')
94
- expect(appSchema.properties.version.pattern).toBe('^\\d+\\.\\d+\\.\\d+')
95
- })
96
-
97
- it('should have proper server schema', () => {
98
- const serverSchema = fluxStackConfigSchema.properties.server
99
- expect(serverSchema.properties.port.minimum).toBe(1)
100
- expect(serverSchema.properties.port.maximum).toBe(65535)
101
- expect(serverSchema.required).toContain('cors')
102
- })
103
- })
104
-
105
- describe('Type Safety', () => {
106
- it('should accept valid configuration', () => {
107
- const validConfig: FluxStackConfig = {
108
- ...defaultFluxStackConfig,
109
- app: {
110
- name: 'test-app',
111
- version: '2.0.0'
112
- }
113
- }
114
-
115
- expect(validConfig.app.name).toBe('test-app')
116
- expect(validConfig.server.port).toBe(3000)
117
- })
118
-
119
- it('should enforce type constraints', () => {
120
- // TypeScript should catch these at compile time
121
- // This test ensures our types are properly defined
122
- const config: FluxStackConfig = defaultFluxStackConfig
123
-
124
- expect(typeof config.server.port).toBe('number')
125
- expect(Array.isArray(config.server.cors.origins)).toBe(true)
126
- expect(typeof config.build.optimization.minify).toBe('boolean')
127
- })
128
- })
129
- })