create-fluxstack 1.0.12 → 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 (215) 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/loader.ts +8 -32
  90. package/core/config/runtime-config.ts +3 -3
  91. package/core/config/schema.ts +84 -49
  92. package/core/framework/server.ts +30 -0
  93. package/core/index.ts +25 -0
  94. package/core/live/ComponentRegistry.ts +399 -0
  95. package/core/live/types.ts +164 -0
  96. package/core/plugins/built-in/live-components/commands/create-live-component.ts +1201 -0
  97. package/core/plugins/built-in/live-components/index.ts +27 -0
  98. package/core/plugins/built-in/logger/index.ts +1 -1
  99. package/core/plugins/built-in/monitoring/index.ts +1 -1
  100. package/core/plugins/built-in/static/index.ts +1 -1
  101. package/core/plugins/built-in/swagger/index.ts +1 -1
  102. package/core/plugins/built-in/vite/index.ts +1 -1
  103. package/core/plugins/dependency-manager.ts +384 -0
  104. package/core/plugins/index.ts +5 -1
  105. package/core/plugins/manager.ts +7 -3
  106. package/core/plugins/registry.ts +88 -10
  107. package/core/plugins/types.ts +11 -11
  108. package/core/server/framework.ts +43 -0
  109. package/core/server/index.ts +11 -1
  110. package/core/server/live/ComponentRegistry.ts +1017 -0
  111. package/core/server/live/FileUploadManager.ts +272 -0
  112. package/core/server/live/LiveComponentPerformanceMonitor.ts +930 -0
  113. package/core/server/live/SingleConnectionManager.ts +0 -0
  114. package/core/server/live/StateSignature.ts +644 -0
  115. package/core/server/live/WebSocketConnectionManager.ts +688 -0
  116. package/core/server/live/websocket-plugin.ts +435 -0
  117. package/core/server/middleware/errorHandling.ts +141 -0
  118. package/core/server/middleware/index.ts +16 -0
  119. package/core/server/plugins/static-files-plugin.ts +232 -0
  120. package/core/server/services/BaseService.ts +95 -0
  121. package/core/server/services/ServiceContainer.ts +144 -0
  122. package/core/server/services/index.ts +9 -0
  123. package/core/templates/create-project.ts +46 -2
  124. package/core/testing/index.ts +10 -0
  125. package/core/testing/setup.ts +74 -0
  126. package/core/types/build.ts +38 -14
  127. package/core/types/types.ts +319 -0
  128. package/core/utils/env-runtime.ts +7 -0
  129. package/core/utils/errors/handlers.ts +264 -39
  130. package/core/utils/errors/index.ts +528 -18
  131. package/core/utils/errors/middleware.ts +114 -0
  132. package/core/utils/logger/formatters.ts +222 -0
  133. package/core/utils/logger/index.ts +167 -48
  134. package/core/utils/logger/middleware.ts +253 -0
  135. package/core/utils/logger/performance.ts +384 -0
  136. package/core/utils/logger/transports.ts +365 -0
  137. package/create-fluxstack.ts +296 -296
  138. package/fluxstack.config.ts +17 -1
  139. package/package-template.json +66 -66
  140. package/package.json +31 -6
  141. package/public/README.md +16 -0
  142. package/vite.config.ts +29 -14
  143. package/.claude/settings.local.json +0 -74
  144. package/.github/workflows/ci-build-tests.yml +0 -480
  145. package/.github/workflows/dependency-management.yml +0 -324
  146. package/.github/workflows/release-validation.yml +0 -355
  147. package/.kiro/specs/fluxstack-architecture-optimization/design.md +0 -700
  148. package/.kiro/specs/fluxstack-architecture-optimization/requirements.md +0 -127
  149. package/.kiro/specs/fluxstack-architecture-optimization/tasks.md +0 -330
  150. package/CLAUDE.md +0 -200
  151. package/Dockerfile +0 -58
  152. package/Dockerfile.backend +0 -52
  153. package/Dockerfile.frontend +0 -54
  154. package/README-Docker.md +0 -85
  155. package/ai-context/00-QUICK-START.md +0 -86
  156. package/ai-context/README.md +0 -88
  157. package/ai-context/development/eden-treaty-guide.md +0 -362
  158. package/ai-context/development/patterns.md +0 -382
  159. package/ai-context/development/plugins-guide.md +0 -572
  160. package/ai-context/examples/crud-complete.md +0 -626
  161. package/ai-context/project/architecture.md +0 -399
  162. package/ai-context/project/overview.md +0 -213
  163. package/ai-context/recent-changes/eden-treaty-refactor.md +0 -281
  164. package/ai-context/recent-changes/type-inference-fix.md +0 -223
  165. package/ai-context/reference/environment-vars.md +0 -384
  166. package/ai-context/reference/troubleshooting.md +0 -407
  167. package/app/client/src/components/TestPage.tsx +0 -453
  168. package/bun.lock +0 -1063
  169. package/bunfig.toml +0 -16
  170. package/core/__tests__/integration.test.ts +0 -227
  171. package/core/build/index.ts +0 -186
  172. package/core/config/__tests__/config-loader.test.ts +0 -591
  173. package/core/config/__tests__/config-merger.test.ts +0 -657
  174. package/core/config/__tests__/env-converter.test.ts +0 -372
  175. package/core/config/__tests__/env-processor.test.ts +0 -431
  176. package/core/config/__tests__/env.test.ts +0 -452
  177. package/core/config/__tests__/integration.test.ts +0 -418
  178. package/core/config/__tests__/loader.test.ts +0 -331
  179. package/core/config/__tests__/schema.test.ts +0 -129
  180. package/core/config/__tests__/validator.test.ts +0 -318
  181. package/core/framework/__tests__/server.test.ts +0 -233
  182. package/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  183. package/core/plugins/__tests__/manager.test.ts +0 -398
  184. package/core/plugins/__tests__/monitoring.test.ts +0 -401
  185. package/core/plugins/__tests__/registry.test.ts +0 -335
  186. package/core/utils/__tests__/errors.test.ts +0 -139
  187. package/core/utils/__tests__/helpers.test.ts +0 -297
  188. package/core/utils/__tests__/logger.test.ts +0 -141
  189. package/create-test-app.ts +0 -156
  190. package/docker-compose.microservices.yml +0 -75
  191. package/docker-compose.simple.yml +0 -57
  192. package/docker-compose.yml +0 -71
  193. package/eslint.config.js +0 -23
  194. package/flux-cli.ts +0 -214
  195. package/nginx-lb.conf +0 -37
  196. package/publish.sh +0 -63
  197. package/run-clean.ts +0 -26
  198. package/run-env-tests.ts +0 -313
  199. package/tailwind.config.js +0 -34
  200. package/tests/__mocks__/api.ts +0 -56
  201. package/tests/fixtures/users.ts +0 -69
  202. package/tests/integration/api/users.routes.test.ts +0 -221
  203. package/tests/setup.ts +0 -29
  204. package/tests/unit/app/client/App-simple.test.tsx +0 -56
  205. package/tests/unit/app/client/App.test.tsx.skip +0 -237
  206. package/tests/unit/app/client/eden-api.test.ts +0 -186
  207. package/tests/unit/app/client/simple.test.tsx +0 -23
  208. package/tests/unit/app/controllers/users.controller.test.ts +0 -150
  209. package/tests/unit/core/create-project.test.ts.skip +0 -95
  210. package/tests/unit/core/framework.test.ts +0 -144
  211. package/tests/unit/core/plugins/logger.test.ts.skip +0 -268
  212. package/tests/unit/core/plugins/vite.test.ts.disabled +0 -188
  213. package/tests/utils/test-helpers.ts +0 -61
  214. package/vitest.config.ts +0 -50
  215. package/workspace.json +0 -6
@@ -0,0 +1,529 @@
1
+ // 🔥 FluxStack Configuration Live Component
2
+
3
+ import { LiveComponent } from '@/core/types/types'
4
+
5
+ export interface FluxStackConfigState {
6
+ // Environment Configuration
7
+ environment: 'development' | 'production' | 'test'
8
+ port: number
9
+ host: string
10
+ apiPrefix: string
11
+
12
+ // Framework Information
13
+ framework: {
14
+ name: string
15
+ version: string
16
+ description: string
17
+ author: string
18
+ license: string
19
+ }
20
+
21
+ // Plugin Configuration
22
+ plugins: Array<{
23
+ name: string
24
+ version: string
25
+ enabled: boolean
26
+ dependencies: string[]
27
+ config?: Record<string, any>
28
+ }>
29
+
30
+ // Runtime Configuration
31
+ runtime: {
32
+ nodeVersion: string
33
+ bunVersion: string
34
+ platform: string
35
+ architecture: string
36
+ cpuCount: number
37
+ totalMemory: number
38
+ workingDirectory: string
39
+ executablePath: string
40
+ }
41
+
42
+ // Live Components Configuration
43
+ liveComponents: {
44
+ enabled: boolean
45
+ autoDiscovery: boolean
46
+ websocketPath: string
47
+ signatureSecret: string
48
+ maxConnections: number
49
+ timeout: number
50
+ }
51
+
52
+ // Vite Configuration
53
+ vite: {
54
+ enabled: boolean
55
+ port: number
56
+ host: string
57
+ hmr: boolean
58
+ publicDir: string
59
+ buildDir: string
60
+ }
61
+
62
+ // Static Files Configuration
63
+ staticFiles: {
64
+ enabled: boolean
65
+ publicPath: string
66
+ uploadsPath: string
67
+ maxFileSize: number
68
+ allowedExtensions: string[]
69
+ }
70
+
71
+ // Swagger Configuration
72
+ swagger: {
73
+ enabled: boolean
74
+ title: string
75
+ version: string
76
+ description: string
77
+ path: string
78
+ }
79
+
80
+ // Security Configuration
81
+ security: {
82
+ cors: {
83
+ enabled: boolean
84
+ origins: string[]
85
+ credentials: boolean
86
+ }
87
+ rateLimit: {
88
+ enabled: boolean
89
+ windowMs: number
90
+ maxRequests: number
91
+ }
92
+ helmet: {
93
+ enabled: boolean
94
+ options: Record<string, any>
95
+ }
96
+ }
97
+
98
+ // Performance Configuration
99
+ performance: {
100
+ compression: boolean
101
+ cache: {
102
+ enabled: boolean
103
+ maxAge: number
104
+ strategy: string
105
+ }
106
+ clustering: {
107
+ enabled: boolean
108
+ workers: number
109
+ }
110
+ }
111
+
112
+ // Database Configuration (if applicable)
113
+ database: {
114
+ enabled: boolean
115
+ type?: string
116
+ host?: string
117
+ port?: number
118
+ name?: string
119
+ ssl?: boolean
120
+ }
121
+
122
+ // Logging Configuration
123
+ logging: {
124
+ level: 'debug' | 'info' | 'warn' | 'error'
125
+ format: 'json' | 'pretty' | 'compact'
126
+ file: {
127
+ enabled: boolean
128
+ path?: string
129
+ maxSize?: string
130
+ maxFiles?: number
131
+ }
132
+ console: {
133
+ enabled: boolean
134
+ colors: boolean
135
+ }
136
+ }
137
+
138
+ // Advanced Configuration
139
+ advanced: {
140
+ hotReload: boolean
141
+ typeChecking: boolean
142
+ sourceMap: boolean
143
+ minification: boolean
144
+ bundleAnalyzer: boolean
145
+ }
146
+
147
+ lastUpdated: number
148
+ }
149
+
150
+ export class FluxStackConfig extends LiveComponent<FluxStackConfigState> {
151
+
152
+ constructor(initialState: FluxStackConfigState, ws: any, options?: any) {
153
+ super(initialState, ws, options)
154
+
155
+ // Set default state with real configuration
156
+ this.state = {
157
+ environment: (process.env.NODE_ENV as any) || 'development',
158
+ port: parseInt(process.env.PORT || '3000'),
159
+ host: process.env.HOST || 'localhost',
160
+ apiPrefix: '/api',
161
+
162
+ framework: {
163
+ name: 'FluxStack',
164
+ version: '1.5.0',
165
+ description: 'Modern Full-Stack TypeScript Framework with Live Components',
166
+ author: 'FluxStack Team',
167
+ license: 'MIT'
168
+ },
169
+
170
+ plugins: this.getPluginConfiguration(),
171
+ runtime: this.getRuntimeConfiguration(),
172
+ liveComponents: this.getLiveComponentsConfiguration(),
173
+ vite: this.getViteConfiguration(),
174
+ staticFiles: this.getStaticFilesConfiguration(),
175
+ swagger: this.getSwaggerConfiguration(),
176
+ security: this.getSecurityConfiguration(),
177
+ performance: this.getPerformanceConfiguration(),
178
+ database: this.getDatabaseConfiguration(),
179
+ logging: this.getLoggingConfiguration(),
180
+ advanced: this.getAdvancedConfiguration(),
181
+
182
+ lastUpdated: Date.now(),
183
+ ...initialState
184
+ }
185
+
186
+ console.log('⚙️ FluxStackConfig component created:', this.id)
187
+ }
188
+
189
+ // Get plugin configuration
190
+ private getPluginConfiguration() {
191
+ return [
192
+ {
193
+ name: 'logger',
194
+ version: '1.0.0',
195
+ enabled: true,
196
+ dependencies: [],
197
+ config: {
198
+ level: process.env.LOG_LEVEL || 'info',
199
+ format: 'pretty'
200
+ }
201
+ },
202
+ {
203
+ name: 'vite',
204
+ version: '1.0.0',
205
+ enabled: true,
206
+ dependencies: [],
207
+ config: {
208
+ port: 5173,
209
+ hmr: true
210
+ }
211
+ },
212
+ {
213
+ name: 'static-files',
214
+ version: '1.0.0',
215
+ enabled: true,
216
+ dependencies: [],
217
+ config: {
218
+ publicPath: 'public',
219
+ uploadsPath: 'uploads'
220
+ }
221
+ },
222
+ {
223
+ name: 'live-components',
224
+ version: '1.0.0',
225
+ enabled: true,
226
+ dependencies: [],
227
+ config: {
228
+ websocketPath: '/api/live/ws',
229
+ autoDiscovery: true
230
+ }
231
+ },
232
+ {
233
+ name: 'swagger',
234
+ version: '1.0.0',
235
+ enabled: true,
236
+ dependencies: [],
237
+ config: {
238
+ path: '/swagger',
239
+ title: 'FluxStack API'
240
+ }
241
+ }
242
+ ]
243
+ }
244
+
245
+ // Get runtime configuration
246
+ private getRuntimeConfiguration() {
247
+ const os = require('os')
248
+
249
+ return {
250
+ nodeVersion: process.version,
251
+ bunVersion: process.versions.bun || 'N/A',
252
+ platform: process.platform,
253
+ architecture: process.arch,
254
+ cpuCount: os.cpus().length,
255
+ totalMemory: Math.round(os.totalmem() / 1024 / 1024 / 1024 * 100) / 100, // GB
256
+ workingDirectory: process.cwd(),
257
+ executablePath: process.execPath
258
+ }
259
+ }
260
+
261
+ // Get Live Components configuration
262
+ private getLiveComponentsConfiguration() {
263
+ return {
264
+ enabled: true,
265
+ autoDiscovery: true,
266
+ websocketPath: '/api/live/ws',
267
+ signatureSecret: '***hidden***',
268
+ maxConnections: 1000,
269
+ timeout: 30000
270
+ }
271
+ }
272
+
273
+ // Get Vite configuration
274
+ private getViteConfiguration() {
275
+ return {
276
+ enabled: true,
277
+ port: 5173,
278
+ host: 'localhost',
279
+ hmr: true,
280
+ publicDir: 'public',
281
+ buildDir: 'dist'
282
+ }
283
+ }
284
+
285
+ // Get Static Files configuration
286
+ private getStaticFilesConfiguration() {
287
+ return {
288
+ enabled: true,
289
+ publicPath: 'public',
290
+ uploadsPath: 'uploads',
291
+ maxFileSize: 10 * 1024 * 1024, // 10MB
292
+ allowedExtensions: ['.jpg', '.png', '.gif', '.pdf', '.txt', '.json']
293
+ }
294
+ }
295
+
296
+ // Get Swagger configuration
297
+ private getSwaggerConfiguration() {
298
+ return {
299
+ enabled: true,
300
+ title: 'FluxStack API',
301
+ version: '1.0.0',
302
+ description: 'Modern Full-Stack TypeScript Framework API',
303
+ path: '/swagger'
304
+ }
305
+ }
306
+
307
+ // Get Security configuration
308
+ private getSecurityConfiguration() {
309
+ return {
310
+ cors: {
311
+ enabled: true,
312
+ origins: ['http://localhost:5173', 'http://localhost:3000'],
313
+ credentials: true
314
+ },
315
+ rateLimit: {
316
+ enabled: false,
317
+ windowMs: 15 * 60 * 1000, // 15 minutes
318
+ maxRequests: 100
319
+ },
320
+ helmet: {
321
+ enabled: false,
322
+ options: {}
323
+ }
324
+ }
325
+ }
326
+
327
+ // Get Performance configuration
328
+ private getPerformanceConfiguration() {
329
+ return {
330
+ compression: true,
331
+ cache: {
332
+ enabled: false,
333
+ maxAge: 3600,
334
+ strategy: 'memory'
335
+ },
336
+ clustering: {
337
+ enabled: false,
338
+ workers: 1
339
+ }
340
+ }
341
+ }
342
+
343
+ // Get Database configuration
344
+ private getDatabaseConfiguration() {
345
+ return {
346
+ enabled: false,
347
+ type: undefined,
348
+ host: undefined,
349
+ port: undefined,
350
+ name: undefined,
351
+ ssl: false
352
+ }
353
+ }
354
+
355
+ // Get Logging configuration
356
+ private getLoggingConfiguration() {
357
+ return {
358
+ level: (process.env.LOG_LEVEL as any) || 'info',
359
+ format: 'pretty',
360
+ file: {
361
+ enabled: false,
362
+ path: undefined,
363
+ maxSize: undefined,
364
+ maxFiles: undefined
365
+ },
366
+ console: {
367
+ enabled: true,
368
+ colors: true
369
+ }
370
+ }
371
+ }
372
+
373
+ // Get Advanced configuration
374
+ private getAdvancedConfiguration() {
375
+ return {
376
+ hotReload: true,
377
+ typeChecking: true,
378
+ sourceMap: true,
379
+ minification: false,
380
+ bundleAnalyzer: false
381
+ }
382
+ }
383
+
384
+ // Refresh all configuration
385
+ async refreshConfiguration() {
386
+ this.setState({
387
+ plugins: this.getPluginConfiguration(),
388
+ runtime: this.getRuntimeConfiguration(),
389
+ liveComponents: this.getLiveComponentsConfiguration(),
390
+ vite: this.getViteConfiguration(),
391
+ staticFiles: this.getStaticFilesConfiguration(),
392
+ swagger: this.getSwaggerConfiguration(),
393
+ security: this.getSecurityConfiguration(),
394
+ performance: this.getPerformanceConfiguration(),
395
+ database: this.getDatabaseConfiguration(),
396
+ logging: this.getLoggingConfiguration(),
397
+ advanced: this.getAdvancedConfiguration(),
398
+ lastUpdated: Date.now()
399
+ })
400
+
401
+ this.emit('CONFIGURATION_REFRESHED', {
402
+ timestamp: Date.now()
403
+ })
404
+
405
+ console.log('🔄 FluxStackConfig: Configuration refreshed')
406
+ }
407
+
408
+ // Update specific configuration section
409
+ async updateConfiguration(data: { section: string; config: Record<string, any> }) {
410
+ const { section, config } = data
411
+
412
+ if (!this.state[section as keyof FluxStackConfigState]) {
413
+ throw new Error(`Invalid configuration section: ${section}`)
414
+ }
415
+
416
+ this.setState({
417
+ [section]: {
418
+ ...this.state[section as keyof FluxStackConfigState],
419
+ ...config
420
+ },
421
+ lastUpdated: Date.now()
422
+ } as Partial<FluxStackConfigState>)
423
+
424
+ this.emit('CONFIGURATION_UPDATED', {
425
+ section,
426
+ config,
427
+ timestamp: Date.now()
428
+ })
429
+
430
+ console.log(`⚙️ FluxStackConfig: Updated section '${section}'`, config)
431
+ }
432
+
433
+ // Get environment variables
434
+ async getEnvironmentVariables() {
435
+ const envVars = {
436
+ NODE_ENV: process.env.NODE_ENV,
437
+ PORT: process.env.PORT,
438
+ HOST: process.env.HOST,
439
+ LOG_LEVEL: process.env.LOG_LEVEL,
440
+ // Add other non-sensitive env vars
441
+ PWD: process.env.PWD,
442
+ PATH: process.env.PATH ? '***truncated***' : undefined,
443
+ USER: process.env.USER || process.env.USERNAME,
444
+ HOME: process.env.HOME || process.env.USERPROFILE
445
+ }
446
+
447
+ this.emit('ENVIRONMENT_VARIABLES_REQUESTED', {
448
+ count: Object.keys(envVars).length,
449
+ timestamp: Date.now()
450
+ })
451
+
452
+ return envVars
453
+ }
454
+
455
+ // Export configuration as JSON
456
+ async exportConfiguration() {
457
+ const config = {
458
+ ...this.state,
459
+ exportedAt: new Date().toISOString(),
460
+ exportedBy: 'FluxStack Configuration Manager'
461
+ }
462
+
463
+ this.emit('CONFIGURATION_EXPORTED', {
464
+ timestamp: Date.now()
465
+ })
466
+
467
+ console.log('📤 FluxStackConfig: Configuration exported')
468
+ return config
469
+ }
470
+
471
+ // Validate configuration
472
+ async validateConfiguration() {
473
+ const issues: string[] = []
474
+
475
+ // Check port conflicts
476
+ if (this.state.port === this.state.vite.port) {
477
+ issues.push('Server port conflicts with Vite port')
478
+ }
479
+
480
+ // Check memory usage
481
+ if (this.state.runtime.totalMemory < 2) {
482
+ issues.push('Low system memory (< 2GB)')
483
+ }
484
+
485
+ // Check required directories
486
+ if (!this.state.staticFiles.publicPath) {
487
+ issues.push('Public directory not configured')
488
+ }
489
+
490
+ const result = {
491
+ valid: issues.length === 0,
492
+ issues,
493
+ timestamp: Date.now()
494
+ }
495
+
496
+ this.emit('CONFIGURATION_VALIDATED', result)
497
+
498
+ console.log(`✅ FluxStackConfig: Validation ${result.valid ? 'passed' : 'failed'}`,
499
+ { issues: issues.length })
500
+
501
+ return result
502
+ }
503
+
504
+ // Get system health based on configuration
505
+ async getSystemHealth() {
506
+ const health = {
507
+ status: 'healthy' as 'healthy' | 'warning' | 'critical',
508
+ checks: {
509
+ memory: this.state.runtime.totalMemory > 1,
510
+ plugins: this.state.plugins.every(p => p.enabled),
511
+ liveComponents: this.state.liveComponents.enabled,
512
+ vite: this.state.vite.enabled,
513
+ swagger: this.state.swagger.enabled
514
+ },
515
+ score: 0,
516
+ timestamp: Date.now()
517
+ }
518
+
519
+ const passed = Object.values(health.checks).filter(Boolean).length
520
+ health.score = Math.round((passed / Object.keys(health.checks).length) * 100)
521
+
522
+ if (health.score < 60) health.status = 'critical'
523
+ else if (health.score < 80) health.status = 'warning'
524
+
525
+ this.emit('SYSTEM_HEALTH_CHECKED', health)
526
+
527
+ return health
528
+ }
529
+ }