create-fluxstack 1.0.1 → 1.0.2

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 (100) hide show
  1. package/create-fluxstack.ts +2 -3
  2. package/package.json +1 -1
  3. package/.env +0 -30
  4. package/LICENSE +0 -21
  5. package/app/client/README.md +0 -69
  6. package/app/client/frontend-only.ts +0 -12
  7. package/app/client/index.html +0 -13
  8. package/app/client/public/vite.svg +0 -1
  9. package/app/client/src/App.css +0 -883
  10. package/app/client/src/App.tsx +0 -669
  11. package/app/client/src/assets/react.svg +0 -1
  12. package/app/client/src/components/TestPage.tsx +0 -453
  13. package/app/client/src/index.css +0 -51
  14. package/app/client/src/lib/eden-api.ts +0 -110
  15. package/app/client/src/main.tsx +0 -10
  16. package/app/client/src/vite-env.d.ts +0 -1
  17. package/app/client/tsconfig.app.json +0 -43
  18. package/app/client/tsconfig.json +0 -7
  19. package/app/client/tsconfig.node.json +0 -25
  20. package/app/server/app.ts +0 -10
  21. package/app/server/backend-only.ts +0 -15
  22. package/app/server/controllers/users.controller.ts +0 -69
  23. package/app/server/index.ts +0 -104
  24. package/app/server/routes/index.ts +0 -25
  25. package/app/server/routes/users.routes.ts +0 -121
  26. package/app/server/types/index.ts +0 -1
  27. package/app/shared/types/index.ts +0 -18
  28. package/bun.lock +0 -1053
  29. package/core/__tests__/integration.test.ts +0 -227
  30. package/core/build/index.ts +0 -186
  31. package/core/cli/command-registry.ts +0 -334
  32. package/core/cli/index.ts +0 -394
  33. package/core/cli/plugin-discovery.ts +0 -200
  34. package/core/client/standalone.ts +0 -57
  35. package/core/config/__tests__/config-loader.test.ts +0 -591
  36. package/core/config/__tests__/config-merger.test.ts +0 -657
  37. package/core/config/__tests__/env-converter.test.ts +0 -372
  38. package/core/config/__tests__/env-processor.test.ts +0 -431
  39. package/core/config/__tests__/env.test.ts +0 -452
  40. package/core/config/__tests__/integration.test.ts +0 -418
  41. package/core/config/__tests__/loader.test.ts +0 -331
  42. package/core/config/__tests__/schema.test.ts +0 -129
  43. package/core/config/__tests__/validator.test.ts +0 -318
  44. package/core/config/env-dynamic.ts +0 -326
  45. package/core/config/env.ts +0 -597
  46. package/core/config/index.ts +0 -317
  47. package/core/config/loader.ts +0 -546
  48. package/core/config/runtime-config.ts +0 -322
  49. package/core/config/schema.ts +0 -694
  50. package/core/config/validator.ts +0 -540
  51. package/core/framework/__tests__/server.test.ts +0 -233
  52. package/core/framework/client.ts +0 -132
  53. package/core/framework/index.ts +0 -8
  54. package/core/framework/server.ts +0 -501
  55. package/core/framework/types.ts +0 -63
  56. package/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  57. package/core/plugins/__tests__/manager.test.ts +0 -398
  58. package/core/plugins/__tests__/monitoring.test.ts +0 -401
  59. package/core/plugins/__tests__/registry.test.ts +0 -335
  60. package/core/plugins/built-in/index.ts +0 -142
  61. package/core/plugins/built-in/logger/index.ts +0 -180
  62. package/core/plugins/built-in/monitoring/README.md +0 -193
  63. package/core/plugins/built-in/monitoring/index.ts +0 -912
  64. package/core/plugins/built-in/static/index.ts +0 -289
  65. package/core/plugins/built-in/swagger/index.ts +0 -229
  66. package/core/plugins/built-in/vite/index.ts +0 -316
  67. package/core/plugins/config.ts +0 -348
  68. package/core/plugins/discovery.ts +0 -350
  69. package/core/plugins/executor.ts +0 -351
  70. package/core/plugins/index.ts +0 -195
  71. package/core/plugins/manager.ts +0 -583
  72. package/core/plugins/registry.ts +0 -424
  73. package/core/plugins/types.ts +0 -254
  74. package/core/server/framework.ts +0 -123
  75. package/core/server/index.ts +0 -8
  76. package/core/server/plugins/database.ts +0 -182
  77. package/core/server/plugins/logger.ts +0 -47
  78. package/core/server/plugins/swagger.ts +0 -34
  79. package/core/server/standalone.ts +0 -91
  80. package/core/templates/create-project.ts +0 -455
  81. package/core/types/api.ts +0 -169
  82. package/core/types/build.ts +0 -174
  83. package/core/types/config.ts +0 -68
  84. package/core/types/index.ts +0 -127
  85. package/core/types/plugin.ts +0 -94
  86. package/core/utils/__tests__/errors.test.ts +0 -139
  87. package/core/utils/__tests__/helpers.test.ts +0 -297
  88. package/core/utils/__tests__/logger.test.ts +0 -141
  89. package/core/utils/env-runtime-v2.ts +0 -232
  90. package/core/utils/env-runtime.ts +0 -252
  91. package/core/utils/errors/codes.ts +0 -115
  92. package/core/utils/errors/handlers.ts +0 -63
  93. package/core/utils/errors/index.ts +0 -81
  94. package/core/utils/helpers.ts +0 -180
  95. package/core/utils/index.ts +0 -18
  96. package/core/utils/logger/index.ts +0 -161
  97. package/core/utils/logger.ts +0 -106
  98. package/core/utils/monitoring/index.ts +0 -212
  99. package/tsconfig.json +0 -51
  100. package/vite.config.ts +0 -42
@@ -1,452 +0,0 @@
1
- /**
2
- * Tests for Environment Configuration System
3
- */
4
-
5
- import { describe, it, expect, beforeEach, afterEach } from 'vitest'
6
- import {
7
- getEnvironmentInfo,
8
- EnvConverter,
9
- EnvironmentProcessor,
10
- ConfigMerger,
11
- EnvironmentConfigApplier,
12
- isDevelopment,
13
- isProduction,
14
- isTest,
15
- getEnvironmentRecommendations
16
- } from '../env'
17
- import { defaultFluxStackConfig } from '../schema'
18
-
19
- describe('Environment Configuration System', () => {
20
- const originalEnv = { ...process.env }
21
-
22
- beforeEach(() => {
23
- // Clean environment
24
- Object.keys(process.env).forEach(key => {
25
- if (key.startsWith('FLUXSTACK_') || key.startsWith('TEST_')) {
26
- delete process.env[key]
27
- }
28
- })
29
- })
30
-
31
- afterEach(() => {
32
- // Restore original environment
33
- process.env = { ...originalEnv }
34
- })
35
-
36
- describe('getEnvironmentInfo', () => {
37
- it('should return development info by default', () => {
38
- delete process.env.NODE_ENV
39
- const info = getEnvironmentInfo()
40
-
41
- expect(info.name).toBe('development')
42
- expect(info.isDevelopment).toBe(true)
43
- expect(info.isProduction).toBe(false)
44
- expect(info.isTest).toBe(false)
45
- expect(info.nodeEnv).toBe('development')
46
- })
47
-
48
- it('should detect production environment', () => {
49
- process.env.NODE_ENV = 'production'
50
- const info = getEnvironmentInfo()
51
-
52
- expect(info.name).toBe('production')
53
- expect(info.isDevelopment).toBe(false)
54
- expect(info.isProduction).toBe(true)
55
- expect(info.isTest).toBe(false)
56
- })
57
-
58
- it('should detect test environment', () => {
59
- process.env.NODE_ENV = 'test'
60
- const info = getEnvironmentInfo()
61
-
62
- expect(info.name).toBe('test')
63
- expect(info.isDevelopment).toBe(false)
64
- expect(info.isProduction).toBe(false)
65
- expect(info.isTest).toBe(true)
66
- })
67
- })
68
-
69
- describe('EnvConverter', () => {
70
- describe('toNumber', () => {
71
- it('should convert valid numbers', () => {
72
- expect(EnvConverter.toNumber('123', 0)).toBe(123)
73
- expect(EnvConverter.toNumber('0', 100)).toBe(0)
74
- expect(EnvConverter.toNumber('-50', 0)).toBe(-50)
75
- })
76
-
77
- it('should return default for invalid numbers', () => {
78
- expect(EnvConverter.toNumber('abc', 42)).toBe(42)
79
- expect(EnvConverter.toNumber('', 100)).toBe(100)
80
- expect(EnvConverter.toNumber(undefined, 200)).toBe(200)
81
- })
82
- })
83
-
84
- describe('toBoolean', () => {
85
- it('should convert truthy values', () => {
86
- expect(EnvConverter.toBoolean('true', false)).toBe(true)
87
- expect(EnvConverter.toBoolean('1', false)).toBe(true)
88
- expect(EnvConverter.toBoolean('yes', false)).toBe(true)
89
- expect(EnvConverter.toBoolean('on', false)).toBe(true)
90
- expect(EnvConverter.toBoolean('TRUE', false)).toBe(true)
91
- })
92
-
93
- it('should convert falsy values', () => {
94
- expect(EnvConverter.toBoolean('false', true)).toBe(false)
95
- expect(EnvConverter.toBoolean('0', true)).toBe(false)
96
- expect(EnvConverter.toBoolean('no', true)).toBe(false)
97
- expect(EnvConverter.toBoolean('off', true)).toBe(false)
98
- })
99
-
100
- it('should return default for undefined', () => {
101
- expect(EnvConverter.toBoolean(undefined, true)).toBe(true)
102
- expect(EnvConverter.toBoolean(undefined, false)).toBe(false)
103
- })
104
- })
105
-
106
- describe('toArray', () => {
107
- it('should convert comma-separated values', () => {
108
- expect(EnvConverter.toArray('a,b,c')).toEqual(['a', 'b', 'c'])
109
- expect(EnvConverter.toArray('one, two, three')).toEqual(['one', 'two', 'three'])
110
- expect(EnvConverter.toArray('single')).toEqual(['single'])
111
- })
112
-
113
- it('should handle empty values', () => {
114
- expect(EnvConverter.toArray('')).toEqual([])
115
- expect(EnvConverter.toArray(undefined)).toEqual([])
116
- expect(EnvConverter.toArray('a,,b')).toEqual(['a', 'b']) // Filters empty strings
117
- })
118
- })
119
-
120
- describe('toLogLevel', () => {
121
- it('should convert valid log levels', () => {
122
- expect(EnvConverter.toLogLevel('debug', 'info')).toBe('debug')
123
- expect(EnvConverter.toLogLevel('INFO', 'debug')).toBe('info')
124
- expect(EnvConverter.toLogLevel('warn', 'info')).toBe('warn')
125
- expect(EnvConverter.toLogLevel('error', 'info')).toBe('error')
126
- })
127
-
128
- it('should return default for invalid levels', () => {
129
- expect(EnvConverter.toLogLevel('invalid', 'info')).toBe('info')
130
- expect(EnvConverter.toLogLevel(undefined, 'warn')).toBe('warn')
131
- })
132
- })
133
-
134
- describe('toObject', () => {
135
- it('should parse valid JSON', () => {
136
- expect(EnvConverter.toObject('{"key": "value"}', {})).toEqual({ key: 'value' })
137
- expect(EnvConverter.toObject('[1,2,3]', [] as any)).toEqual([1, 2, 3])
138
- })
139
-
140
- it('should return default for invalid JSON', () => {
141
- expect(EnvConverter.toObject('invalid-json', { default: true })).toEqual({ default: true })
142
- expect(EnvConverter.toObject(undefined, null)).toBe(null)
143
- })
144
- })
145
- })
146
-
147
- describe('EnvironmentProcessor', () => {
148
- it('should process basic environment variables', () => {
149
- process.env.PORT = '4000'
150
- process.env.HOST = 'example.com'
151
- process.env.FLUXSTACK_APP_NAME = 'test-app'
152
-
153
- const processor = new EnvironmentProcessor()
154
- const config = processor.processEnvironmentVariables()
155
-
156
- expect(config.server?.port).toBe(4000)
157
- expect(config.server?.host).toBe('example.com')
158
- expect(config.app?.name).toBe('test-app')
159
- })
160
-
161
- it('should process CORS configuration', () => {
162
- process.env.CORS_ORIGINS = 'http://localhost:3000,https://example.com'
163
- process.env.CORS_METHODS = 'GET,POST,PUT'
164
- process.env.CORS_CREDENTIALS = 'true'
165
-
166
- const processor = new EnvironmentProcessor()
167
- const config = processor.processEnvironmentVariables()
168
-
169
- expect(config.server?.cors?.origins).toEqual(['http://localhost:3000', 'https://example.com'])
170
- expect(config.server?.cors?.methods).toEqual(['GET', 'POST', 'PUT'])
171
- expect(config.server?.cors?.credentials).toBe(true)
172
- })
173
-
174
- it('should process build configuration', () => {
175
- process.env.BUILD_TARGET = 'node'
176
- process.env.BUILD_MINIFY = 'false'
177
- process.env.BUILD_SOURCEMAPS = 'true'
178
-
179
- const processor = new EnvironmentProcessor()
180
- const config = processor.processEnvironmentVariables()
181
-
182
- expect(config.build?.target).toBe('node')
183
- expect(config.build?.optimization?.minify).toBe(false)
184
- expect(config.build?.sourceMaps).toBe(true)
185
- })
186
-
187
- it('should process optional database configuration', () => {
188
- process.env.DATABASE_URL = 'postgresql://localhost:5432/test'
189
- process.env.DATABASE_SSL = 'true'
190
- process.env.DATABASE_POOL_SIZE = '10'
191
-
192
- const processor = new EnvironmentProcessor()
193
- const config = processor.processEnvironmentVariables()
194
-
195
- expect(config.database?.url).toBe('postgresql://localhost:5432/test')
196
- expect(config.database?.ssl).toBe(true)
197
- expect(config.database?.poolSize).toBe(10)
198
- })
199
-
200
- it('should track precedence information', () => {
201
- process.env.PORT = '5000'
202
- process.env.FLUXSTACK_APP_NAME = 'precedence-test'
203
-
204
- const processor = new EnvironmentProcessor()
205
- processor.processEnvironmentVariables()
206
-
207
- const precedence = processor.getPrecedenceInfo()
208
-
209
- expect(precedence.has('server.port')).toBe(true)
210
- expect(precedence.has('app.name')).toBe(true)
211
- expect(precedence.get('server.port')?.source).toBe('environment')
212
- expect(precedence.get('server.port')?.priority).toBe(3)
213
- })
214
- })
215
-
216
- describe('ConfigMerger', () => {
217
- it('should merge configurations with precedence', () => {
218
- const merger = new ConfigMerger()
219
-
220
- const baseConfig = {
221
- app: { name: 'base-app', version: '1.0.0' },
222
- server: {
223
- port: 3000,
224
- host: 'localhost',
225
- apiPrefix: '/api',
226
- cors: {
227
- origins: ['*'],
228
- methods: ['GET', 'POST'],
229
- headers: ['Content-Type'],
230
- credentials: false,
231
- maxAge: 86400
232
- },
233
- middleware: []
234
- }
235
- }
236
-
237
- const envConfig = {
238
- server: {
239
- port: 4000,
240
- host: 'localhost',
241
- apiPrefix: '/api',
242
- cors: {
243
- origins: ['*'],
244
- methods: ['GET', 'POST'],
245
- headers: ['Content-Type'],
246
- credentials: false,
247
- maxAge: 86400
248
- },
249
- middleware: []
250
- },
251
- logging: {
252
- level: 'debug' as const,
253
- format: 'pretty' as const,
254
- transports: [{ type: 'console' as const, level: 'debug' as const, format: 'pretty' as const }]
255
- }
256
- }
257
-
258
- const result = merger.merge(
259
- { config: baseConfig, source: 'file' },
260
- { config: envConfig, source: 'environment' }
261
- )
262
-
263
- expect(result.app.name).toBe('base-app') // From base
264
- expect(result.server.port).toBe(4000) // Overridden by env
265
- expect(result.server.host).toBe('localhost') // From base
266
- expect(result.logging?.level).toBe('debug') // From env
267
- })
268
-
269
- it('should handle nested object merging', () => {
270
- const merger = new ConfigMerger()
271
-
272
- const config1 = {
273
- server: {
274
- port: 3000,
275
- host: 'localhost',
276
- apiPrefix: '/api',
277
- cors: {
278
- origins: ['http://localhost:3000'],
279
- methods: ['GET', 'POST'],
280
- headers: ['Content-Type'],
281
- credentials: false,
282
- maxAge: 86400
283
- },
284
- middleware: []
285
- }
286
- }
287
-
288
- const config2 = {
289
- server: {
290
- port: 3000,
291
- host: 'localhost',
292
- apiPrefix: '/api',
293
- cors: {
294
- origins: ['https://example.com'],
295
- methods: ['GET', 'POST'],
296
- headers: ['Content-Type'],
297
- credentials: true,
298
- maxAge: 86400
299
- },
300
- middleware: []
301
- }
302
- }
303
-
304
- const result = merger.merge(
305
- { config: config1, source: 'default' },
306
- { config: config2, source: 'environment' }
307
- )
308
-
309
- expect(result.server.cors.origins).toEqual(['https://example.com'])
310
- expect(result.server.cors.methods).toEqual(['GET', 'POST'])
311
- expect(result.server.cors.credentials).toBe(true)
312
- })
313
- })
314
-
315
- describe('EnvironmentConfigApplier', () => {
316
- it('should apply environment-specific configuration', () => {
317
- const applier = new EnvironmentConfigApplier()
318
-
319
- const baseConfig = {
320
- ...defaultFluxStackConfig,
321
- environments: {
322
- production: {
323
- logging: {
324
- level: 'error' as const,
325
- format: 'json' as const,
326
- transports: [{ type: 'console' as const, level: 'error' as const, format: 'json' as const }]
327
- },
328
- monitoring: {
329
- enabled: true,
330
- metrics: {
331
- enabled: true,
332
- collectInterval: 30000,
333
- httpMetrics: true,
334
- systemMetrics: true,
335
- customMetrics: false
336
- },
337
- profiling: {
338
- enabled: true,
339
- sampleRate: 0.01,
340
- memoryProfiling: true,
341
- cpuProfiling: true
342
- },
343
- exporters: ['prometheus']
344
- }
345
- }
346
- }
347
- }
348
-
349
- const result = applier.applyEnvironmentConfig(baseConfig, 'production')
350
-
351
- expect(result.logging.level).toBe('error')
352
- expect(result.monitoring.enabled).toBe(true)
353
- })
354
-
355
- it('should get available environments', () => {
356
- const applier = new EnvironmentConfigApplier()
357
-
358
- const config = {
359
- ...defaultFluxStackConfig,
360
- environments: {
361
- staging: {},
362
- production: {},
363
- custom: {}
364
- }
365
- }
366
-
367
- const environments = applier.getAvailableEnvironments(config)
368
-
369
- expect(environments).toEqual(['staging', 'production', 'custom'])
370
- })
371
-
372
- it('should validate environment configuration', () => {
373
- const applier = new EnvironmentConfigApplier()
374
-
375
- const config = {
376
- ...defaultFluxStackConfig,
377
- environments: {
378
- production: {
379
- logging: {
380
- level: 'debug' as const,
381
- format: 'json' as const,
382
- transports: [{ type: 'console' as const, level: 'debug' as const, format: 'json' as const }]
383
- } // Bad for production
384
- }
385
- }
386
- }
387
-
388
- const result = applier.validateEnvironmentConfig(config, 'production')
389
-
390
- expect(result.valid).toBe(false)
391
- expect(result.errors.some(e => e.includes('debug'))).toBe(true)
392
- })
393
- })
394
-
395
- describe('Environment Helper Functions', () => {
396
- it('should detect development environment', () => {
397
- process.env.NODE_ENV = 'development'
398
- expect(isDevelopment()).toBe(true)
399
- expect(isProduction()).toBe(false)
400
- expect(isTest()).toBe(false)
401
- })
402
-
403
- it('should detect production environment', () => {
404
- process.env.NODE_ENV = 'production'
405
- expect(isDevelopment()).toBe(false)
406
- expect(isProduction()).toBe(true)
407
- expect(isTest()).toBe(false)
408
- })
409
-
410
- it('should detect test environment', () => {
411
- process.env.NODE_ENV = 'test'
412
- expect(isDevelopment()).toBe(false)
413
- expect(isProduction()).toBe(false)
414
- expect(isTest()).toBe(true)
415
- })
416
- })
417
-
418
- describe('getEnvironmentRecommendations', () => {
419
- it('should provide development recommendations', () => {
420
- const recommendations = getEnvironmentRecommendations('development')
421
-
422
- expect(recommendations.logging?.level).toBe('debug')
423
- expect(recommendations.logging?.format).toBe('pretty')
424
- expect(recommendations.build?.optimization?.minify).toBe(false)
425
- expect(recommendations.monitoring?.enabled).toBe(false)
426
- })
427
-
428
- it('should provide production recommendations', () => {
429
- const recommendations = getEnvironmentRecommendations('production')
430
-
431
- expect(recommendations.logging?.level).toBe('warn')
432
- expect(recommendations.logging?.format).toBe('json')
433
- expect(recommendations.build?.optimization?.minify).toBe(true)
434
- expect(recommendations.monitoring?.enabled).toBe(true)
435
- })
436
-
437
- it('should provide test recommendations', () => {
438
- const recommendations = getEnvironmentRecommendations('test')
439
-
440
- expect(recommendations.logging?.level).toBe('error')
441
- expect(recommendations.server?.port).toBe(0)
442
- expect(recommendations.client?.port).toBe(0)
443
- expect(recommendations.monitoring?.enabled).toBe(false)
444
- })
445
-
446
- it('should return empty for unknown environments', () => {
447
- const recommendations = getEnvironmentRecommendations('unknown')
448
-
449
- expect(Object.keys(recommendations)).toHaveLength(0)
450
- })
451
- })
452
- })