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.
- package/create-fluxstack.ts +2 -3
- package/package.json +1 -1
- package/.env +0 -30
- package/LICENSE +0 -21
- package/app/client/README.md +0 -69
- package/app/client/frontend-only.ts +0 -12
- package/app/client/index.html +0 -13
- package/app/client/public/vite.svg +0 -1
- package/app/client/src/App.css +0 -883
- package/app/client/src/App.tsx +0 -669
- package/app/client/src/assets/react.svg +0 -1
- package/app/client/src/components/TestPage.tsx +0 -453
- package/app/client/src/index.css +0 -51
- package/app/client/src/lib/eden-api.ts +0 -110
- package/app/client/src/main.tsx +0 -10
- package/app/client/src/vite-env.d.ts +0 -1
- package/app/client/tsconfig.app.json +0 -43
- package/app/client/tsconfig.json +0 -7
- package/app/client/tsconfig.node.json +0 -25
- package/app/server/app.ts +0 -10
- package/app/server/backend-only.ts +0 -15
- package/app/server/controllers/users.controller.ts +0 -69
- package/app/server/index.ts +0 -104
- package/app/server/routes/index.ts +0 -25
- package/app/server/routes/users.routes.ts +0 -121
- package/app/server/types/index.ts +0 -1
- package/app/shared/types/index.ts +0 -18
- package/bun.lock +0 -1053
- package/core/__tests__/integration.test.ts +0 -227
- package/core/build/index.ts +0 -186
- package/core/cli/command-registry.ts +0 -334
- package/core/cli/index.ts +0 -394
- package/core/cli/plugin-discovery.ts +0 -200
- package/core/client/standalone.ts +0 -57
- package/core/config/__tests__/config-loader.test.ts +0 -591
- package/core/config/__tests__/config-merger.test.ts +0 -657
- package/core/config/__tests__/env-converter.test.ts +0 -372
- package/core/config/__tests__/env-processor.test.ts +0 -431
- package/core/config/__tests__/env.test.ts +0 -452
- package/core/config/__tests__/integration.test.ts +0 -418
- package/core/config/__tests__/loader.test.ts +0 -331
- package/core/config/__tests__/schema.test.ts +0 -129
- package/core/config/__tests__/validator.test.ts +0 -318
- package/core/config/env-dynamic.ts +0 -326
- package/core/config/env.ts +0 -597
- package/core/config/index.ts +0 -317
- package/core/config/loader.ts +0 -546
- package/core/config/runtime-config.ts +0 -322
- package/core/config/schema.ts +0 -694
- package/core/config/validator.ts +0 -540
- package/core/framework/__tests__/server.test.ts +0 -233
- package/core/framework/client.ts +0 -132
- package/core/framework/index.ts +0 -8
- package/core/framework/server.ts +0 -501
- package/core/framework/types.ts +0 -63
- package/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
- package/core/plugins/__tests__/manager.test.ts +0 -398
- package/core/plugins/__tests__/monitoring.test.ts +0 -401
- package/core/plugins/__tests__/registry.test.ts +0 -335
- package/core/plugins/built-in/index.ts +0 -142
- package/core/plugins/built-in/logger/index.ts +0 -180
- package/core/plugins/built-in/monitoring/README.md +0 -193
- package/core/plugins/built-in/monitoring/index.ts +0 -912
- package/core/plugins/built-in/static/index.ts +0 -289
- package/core/plugins/built-in/swagger/index.ts +0 -229
- package/core/plugins/built-in/vite/index.ts +0 -316
- package/core/plugins/config.ts +0 -348
- package/core/plugins/discovery.ts +0 -350
- package/core/plugins/executor.ts +0 -351
- package/core/plugins/index.ts +0 -195
- package/core/plugins/manager.ts +0 -583
- package/core/plugins/registry.ts +0 -424
- package/core/plugins/types.ts +0 -254
- package/core/server/framework.ts +0 -123
- package/core/server/index.ts +0 -8
- package/core/server/plugins/database.ts +0 -182
- package/core/server/plugins/logger.ts +0 -47
- package/core/server/plugins/swagger.ts +0 -34
- package/core/server/standalone.ts +0 -91
- package/core/templates/create-project.ts +0 -455
- package/core/types/api.ts +0 -169
- package/core/types/build.ts +0 -174
- package/core/types/config.ts +0 -68
- package/core/types/index.ts +0 -127
- package/core/types/plugin.ts +0 -94
- package/core/utils/__tests__/errors.test.ts +0 -139
- package/core/utils/__tests__/helpers.test.ts +0 -297
- package/core/utils/__tests__/logger.test.ts +0 -141
- package/core/utils/env-runtime-v2.ts +0 -232
- package/core/utils/env-runtime.ts +0 -252
- package/core/utils/errors/codes.ts +0 -115
- package/core/utils/errors/handlers.ts +0 -63
- package/core/utils/errors/index.ts +0 -81
- package/core/utils/helpers.ts +0 -180
- package/core/utils/index.ts +0 -18
- package/core/utils/logger/index.ts +0 -161
- package/core/utils/logger.ts +0 -106
- package/core/utils/monitoring/index.ts +0 -212
- package/tsconfig.json +0 -51
- package/vite.config.ts +0 -42
|
@@ -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
|
-
})
|