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.
- package/.env.example +29 -29
- package/app/client/README.md +69 -69
- package/app/client/index.html +14 -13
- package/app/client/src/App.tsx +157 -524
- package/app/client/src/components/ErrorBoundary.tsx +107 -0
- package/app/client/src/components/ErrorDisplay.css +365 -0
- package/app/client/src/components/ErrorDisplay.tsx +258 -0
- package/app/client/src/components/FluxStackConfig.tsx +1321 -0
- package/app/client/src/components/HybridLiveCounter.tsx +140 -0
- package/app/client/src/components/LiveClock.tsx +286 -0
- package/app/client/src/components/MainLayout.tsx +390 -0
- package/app/client/src/components/SidebarNavigation.tsx +391 -0
- package/app/client/src/components/StateDemo.tsx +178 -0
- package/app/client/src/components/SystemMonitor.tsx +1038 -0
- package/app/client/src/components/Teste.tsx +104 -0
- package/app/client/src/components/UserProfile.tsx +809 -0
- package/app/client/src/hooks/useAuth.ts +39 -0
- package/app/client/src/hooks/useNotifications.ts +56 -0
- package/app/client/src/lib/eden-api.ts +189 -53
- package/app/client/src/lib/errors.ts +340 -0
- package/app/client/src/lib/hooks/useErrorHandler.ts +258 -0
- package/app/client/src/lib/index.ts +45 -0
- package/app/client/src/main.tsx +3 -2
- package/app/client/src/pages/ApiDocs.tsx +182 -0
- package/app/client/src/pages/Demo.tsx +174 -0
- package/app/client/src/pages/HybridLive.tsx +263 -0
- package/app/client/src/pages/Overview.tsx +155 -0
- package/app/client/src/store/README.md +43 -0
- package/app/client/src/store/index.ts +16 -0
- package/app/client/src/store/slices/uiSlice.ts +151 -0
- package/app/client/src/store/slices/userSlice.ts +161 -0
- package/app/client/src/test/README.md +257 -0
- package/app/client/src/test/setup.ts +70 -0
- package/app/client/src/test/types.ts +12 -0
- package/app/client/src/vite-env.d.ts +1 -1
- package/app/client/tsconfig.app.json +44 -43
- package/app/client/tsconfig.json +7 -7
- package/app/client/tsconfig.node.json +25 -25
- package/app/client/zustand-setup.md +65 -0
- package/app/server/controllers/users.controller.ts +68 -68
- package/app/server/index.ts +9 -1
- package/app/server/live/CounterComponent.ts +191 -0
- package/app/server/live/FluxStackConfig.ts +529 -0
- package/app/server/live/LiveClockComponent.ts +214 -0
- package/app/server/live/SidebarNavigation.ts +156 -0
- package/app/server/live/SystemMonitor.ts +594 -0
- package/app/server/live/SystemMonitorIntegration.ts +151 -0
- package/app/server/live/TesteComponent.ts +87 -0
- package/app/server/live/UserProfileComponent.ts +135 -0
- package/app/server/live/register-components.ts +28 -0
- package/app/server/middleware/auth.ts +136 -0
- package/app/server/middleware/errorHandling.ts +250 -0
- package/app/server/middleware/index.ts +10 -0
- package/app/server/middleware/rateLimit.ts +193 -0
- package/app/server/middleware/requestLogging.ts +215 -0
- package/app/server/middleware/validation.ts +270 -0
- package/app/server/routes/index.ts +14 -2
- package/app/server/routes/upload.ts +92 -0
- package/app/server/routes/users.routes.ts +2 -9
- package/app/server/services/NotificationService.ts +302 -0
- package/app/server/services/UserService.ts +222 -0
- package/app/server/services/index.ts +46 -0
- package/core/cli/commands/plugin-deps.ts +263 -0
- package/core/cli/generators/README.md +339 -0
- package/core/cli/generators/component.ts +770 -0
- package/core/cli/generators/controller.ts +299 -0
- package/core/cli/generators/index.ts +144 -0
- package/core/cli/generators/interactive.ts +228 -0
- package/core/cli/generators/prompts.ts +83 -0
- package/core/cli/generators/route.ts +513 -0
- package/core/cli/generators/service.ts +465 -0
- package/core/cli/generators/template-engine.ts +154 -0
- package/core/cli/generators/types.ts +71 -0
- package/core/cli/generators/utils.ts +192 -0
- package/core/cli/index.ts +69 -0
- package/core/cli/plugin-discovery.ts +16 -85
- package/core/client/fluxstack.ts +17 -0
- package/core/client/hooks/index.ts +7 -0
- package/core/client/hooks/state-validator.ts +130 -0
- package/core/client/hooks/useAuth.ts +49 -0
- package/core/client/hooks/useChunkedUpload.ts +258 -0
- package/core/client/hooks/useHybridLiveComponent.ts +967 -0
- package/core/client/hooks/useWebSocket.ts +373 -0
- package/core/client/index.ts +47 -0
- package/core/client/state/createStore.ts +193 -0
- package/core/client/state/index.ts +15 -0
- package/core/config/env-dynamic.ts +1 -1
- package/core/config/env.ts +2 -1
- package/core/config/runtime-config.ts +3 -3
- package/core/config/schema.ts +84 -49
- package/core/framework/server.ts +30 -0
- package/core/index.ts +25 -0
- package/core/live/ComponentRegistry.ts +399 -0
- package/core/live/types.ts +164 -0
- package/core/plugins/built-in/live-components/commands/create-live-component.ts +1201 -0
- package/core/plugins/built-in/live-components/index.ts +27 -0
- package/core/plugins/built-in/logger/index.ts +1 -1
- package/core/plugins/built-in/monitoring/index.ts +1 -1
- package/core/plugins/built-in/static/index.ts +1 -1
- package/core/plugins/built-in/swagger/index.ts +1 -1
- package/core/plugins/built-in/vite/index.ts +1 -1
- package/core/plugins/dependency-manager.ts +384 -0
- package/core/plugins/index.ts +5 -1
- package/core/plugins/manager.ts +7 -3
- package/core/plugins/registry.ts +88 -10
- package/core/plugins/types.ts +11 -11
- package/core/server/framework.ts +43 -0
- package/core/server/index.ts +11 -1
- package/core/server/live/ComponentRegistry.ts +1017 -0
- package/core/server/live/FileUploadManager.ts +272 -0
- package/core/server/live/LiveComponentPerformanceMonitor.ts +930 -0
- package/core/server/live/SingleConnectionManager.ts +0 -0
- package/core/server/live/StateSignature.ts +644 -0
- package/core/server/live/WebSocketConnectionManager.ts +688 -0
- package/core/server/live/websocket-plugin.ts +435 -0
- package/core/server/middleware/errorHandling.ts +141 -0
- package/core/server/middleware/index.ts +16 -0
- package/core/server/plugins/static-files-plugin.ts +232 -0
- package/core/server/services/BaseService.ts +95 -0
- package/core/server/services/ServiceContainer.ts +144 -0
- package/core/server/services/index.ts +9 -0
- package/core/templates/create-project.ts +46 -2
- package/core/testing/index.ts +10 -0
- package/core/testing/setup.ts +74 -0
- package/core/types/build.ts +38 -14
- package/core/types/types.ts +319 -0
- package/core/utils/env-runtime.ts +7 -0
- package/core/utils/errors/handlers.ts +264 -39
- package/core/utils/errors/index.ts +528 -18
- package/core/utils/errors/middleware.ts +114 -0
- package/core/utils/logger/formatters.ts +222 -0
- package/core/utils/logger/index.ts +167 -48
- package/core/utils/logger/middleware.ts +253 -0
- package/core/utils/logger/performance.ts +384 -0
- package/core/utils/logger/transports.ts +365 -0
- package/create-fluxstack.ts +296 -296
- package/fluxstack.config.ts +17 -1
- package/package-template.json +66 -66
- package/package.json +31 -6
- package/public/README.md +16 -0
- package/vite.config.ts +29 -14
- package/.claude/settings.local.json +0 -74
- package/.github/workflows/ci-build-tests.yml +0 -480
- package/.github/workflows/dependency-management.yml +0 -324
- package/.github/workflows/release-validation.yml +0 -355
- package/.kiro/specs/fluxstack-architecture-optimization/design.md +0 -700
- package/.kiro/specs/fluxstack-architecture-optimization/requirements.md +0 -127
- package/.kiro/specs/fluxstack-architecture-optimization/tasks.md +0 -330
- package/CLAUDE.md +0 -200
- package/Dockerfile +0 -58
- package/Dockerfile.backend +0 -52
- package/Dockerfile.frontend +0 -54
- package/README-Docker.md +0 -85
- package/ai-context/00-QUICK-START.md +0 -86
- package/ai-context/README.md +0 -88
- package/ai-context/development/eden-treaty-guide.md +0 -362
- package/ai-context/development/patterns.md +0 -382
- package/ai-context/development/plugins-guide.md +0 -572
- package/ai-context/examples/crud-complete.md +0 -626
- package/ai-context/project/architecture.md +0 -399
- package/ai-context/project/overview.md +0 -213
- package/ai-context/recent-changes/eden-treaty-refactor.md +0 -281
- package/ai-context/recent-changes/type-inference-fix.md +0 -223
- package/ai-context/reference/environment-vars.md +0 -384
- package/ai-context/reference/troubleshooting.md +0 -407
- package/app/client/src/components/TestPage.tsx +0 -453
- package/bun.lock +0 -1063
- package/bunfig.toml +0 -16
- package/core/__tests__/integration.test.ts +0 -227
- package/core/build/index.ts +0 -186
- package/core/config/__tests__/config-loader.test.ts +0 -554
- 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/framework/__tests__/server.test.ts +0 -233
- 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/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/create-test-app.ts +0 -156
- package/docker-compose.microservices.yml +0 -75
- package/docker-compose.simple.yml +0 -57
- package/docker-compose.yml +0 -71
- package/eslint.config.js +0 -23
- package/flux-cli.ts +0 -214
- package/nginx-lb.conf +0 -37
- package/publish.sh +0 -63
- package/run-clean.ts +0 -26
- package/run-env-tests.ts +0 -313
- package/tailwind.config.js +0 -34
- package/tests/__mocks__/api.ts +0 -56
- package/tests/fixtures/users.ts +0 -69
- package/tests/integration/api/users.routes.test.ts +0 -221
- package/tests/setup.ts +0 -29
- package/tests/unit/app/client/App-simple.test.tsx +0 -56
- package/tests/unit/app/client/App.test.tsx.skip +0 -237
- package/tests/unit/app/client/eden-api.test.ts +0 -186
- package/tests/unit/app/client/simple.test.tsx +0 -23
- package/tests/unit/app/controllers/users.controller.test.ts +0 -150
- package/tests/unit/core/create-project.test.ts.skip +0 -95
- package/tests/unit/core/framework.test.ts +0 -144
- package/tests/unit/core/plugins/logger.test.ts.skip +0 -268
- package/tests/unit/core/plugins/vite.test.ts.disabled +0 -188
- package/tests/utils/test-helpers.ts +0 -61
- package/vitest.config.ts +0 -50
- package/workspace.json +0 -6
|
@@ -1,554 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for Configuration Loader
|
|
3
|
-
* Tests the main configuration loading system, including file loading, caching, and fallbacks
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { describe, test, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
7
|
-
import {
|
|
8
|
-
getConfig,
|
|
9
|
-
getConfigSync,
|
|
10
|
-
reloadConfig,
|
|
11
|
-
createPluginConfig,
|
|
12
|
-
isFeatureEnabled,
|
|
13
|
-
createLegacyConfig
|
|
14
|
-
} from '../index'
|
|
15
|
-
import type { FluxStackConfig } from '../schema'
|
|
16
|
-
|
|
17
|
-
// Mock file system operations
|
|
18
|
-
vi.mock('fs', () => ({
|
|
19
|
-
existsSync: vi.fn(),
|
|
20
|
-
promises: {
|
|
21
|
-
readFile: vi.fn(),
|
|
22
|
-
access: vi.fn()
|
|
23
|
-
}
|
|
24
|
-
}))
|
|
25
|
-
|
|
26
|
-
vi.mock('fs/promises', () => ({
|
|
27
|
-
readFile: vi.fn(),
|
|
28
|
-
access: vi.fn()
|
|
29
|
-
}))
|
|
30
|
-
|
|
31
|
-
describe('Configuration Loader', () => {
|
|
32
|
-
let originalEnv: NodeJS.ProcessEnv
|
|
33
|
-
|
|
34
|
-
beforeEach(() => {
|
|
35
|
-
originalEnv = { ...process.env }
|
|
36
|
-
// Clear relevant environment variables
|
|
37
|
-
for (const key in process.env) {
|
|
38
|
-
if (key.startsWith('FLUXSTACK_') || key.startsWith('PORT') || key.startsWith('HOST') ||
|
|
39
|
-
key.startsWith('NODE_ENV') || key.startsWith('CORS_') || key.startsWith('LOG_') ||
|
|
40
|
-
key.startsWith('MONITORING_') || key.startsWith('METRICS_') || key.startsWith('PROFILING_') ||
|
|
41
|
-
key.startsWith('BUILD_')) {
|
|
42
|
-
delete process.env[key]
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Clear any cached configurations
|
|
47
|
-
vi.clearAllMocks()
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
afterEach(() => {
|
|
51
|
-
process.env = originalEnv
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
describe('getConfigSync', () => {
|
|
55
|
-
test('loads configuration from environment variables', () => {
|
|
56
|
-
process.env.PORT = '4000'
|
|
57
|
-
process.env.HOST = 'example.com'
|
|
58
|
-
process.env.LOG_LEVEL = 'debug'
|
|
59
|
-
process.env.NODE_ENV = 'production'
|
|
60
|
-
|
|
61
|
-
const config = getConfigSync()
|
|
62
|
-
|
|
63
|
-
expect(config.server?.port).toBe(4000)
|
|
64
|
-
expect(config.server?.host).toBe('example.com')
|
|
65
|
-
expect(config.logging?.level).toBe('debug')
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test('applies environment defaults based on NODE_ENV', () => {
|
|
69
|
-
process.env.NODE_ENV = 'production'
|
|
70
|
-
|
|
71
|
-
const config = getConfigSync()
|
|
72
|
-
|
|
73
|
-
// Should apply production defaults
|
|
74
|
-
expect(config.build?.optimization?.minify).toBe(true)
|
|
75
|
-
expect(config.monitoring?.enabled).toBe(true)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
test('uses development defaults when NODE_ENV not set', () => {
|
|
79
|
-
delete process.env.NODE_ENV
|
|
80
|
-
|
|
81
|
-
const config = getConfigSync()
|
|
82
|
-
|
|
83
|
-
// Should apply development defaults
|
|
84
|
-
expect(config.build?.optimization?.minify).toBe(false)
|
|
85
|
-
expect(config.monitoring?.enabled).toBe(false)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test('handles custom environment variables with FluxStack prefix', () => {
|
|
89
|
-
process.env.FLUXSTACK_PORT = '5000'
|
|
90
|
-
process.env.FLUXSTACK_API_PREFIX = '/v2'
|
|
91
|
-
process.env.FLUXSTACK_LOG_LEVEL = 'error'
|
|
92
|
-
|
|
93
|
-
// Force reload config to pick up new env vars
|
|
94
|
-
reloadConfig()
|
|
95
|
-
const config = getConfigSync()
|
|
96
|
-
|
|
97
|
-
expect(config.server?.port).toBe(5000)
|
|
98
|
-
expect(config.server?.apiPrefix).toBe('/v2')
|
|
99
|
-
expect(config.logging?.level).toBe('error')
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
test('merges CORS configuration from environment', () => {
|
|
103
|
-
process.env.CORS_ORIGINS = 'http://localhost:3000,https://example.com'
|
|
104
|
-
process.env.CORS_METHODS = 'GET,POST,DELETE'
|
|
105
|
-
process.env.CORS_CREDENTIALS = 'true'
|
|
106
|
-
|
|
107
|
-
const config = getConfigSync()
|
|
108
|
-
|
|
109
|
-
expect(config.server?.cors?.origins).toEqual(['http://localhost:3000', 'https://example.com'])
|
|
110
|
-
expect(config.server?.cors?.methods).toEqual(['GET', 'POST', 'DELETE'])
|
|
111
|
-
expect(config.server?.cors?.credentials).toBe(true)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
test('handles monitoring configuration', () => {
|
|
116
|
-
process.env.MONITORING_ENABLED = 'true'
|
|
117
|
-
process.env.METRICS_ENABLED = 'false'
|
|
118
|
-
process.env.METRICS_INTERVAL = '30000'
|
|
119
|
-
process.env.PROFILING_ENABLED = 'true'
|
|
120
|
-
|
|
121
|
-
const config = getConfigSync()
|
|
122
|
-
|
|
123
|
-
expect(config.monitoring?.enabled).toBe(true)
|
|
124
|
-
expect(config.monitoring?.metrics?.enabled).toBe(false)
|
|
125
|
-
expect(config.monitoring?.metrics?.collectInterval).toBe(30000)
|
|
126
|
-
expect(config.monitoring?.profiling?.enabled).toBe(true)
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
test('handles build configuration', () => {
|
|
130
|
-
process.env.FLUXSTACK_BUILD_TARGET = 'docker'
|
|
131
|
-
process.env.FLUXSTACK_BUILD_OUTDIR = 'build'
|
|
132
|
-
process.env.FLUXSTACK_BUILD_MINIFY = 'true'
|
|
133
|
-
process.env.FLUXSTACK_BUILD_SOURCEMAPS = 'false'
|
|
134
|
-
|
|
135
|
-
reloadConfig()
|
|
136
|
-
const config = getConfigSync()
|
|
137
|
-
|
|
138
|
-
expect(config.build?.target).toBe('docker')
|
|
139
|
-
expect(config.build?.outDir).toBe('build')
|
|
140
|
-
expect(config.build?.optimization?.minify).toBe(true)
|
|
141
|
-
expect(config.build?.sourceMaps).toBe(false)
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
test('handles plugin configuration', () => {
|
|
145
|
-
process.env.FLUXSTACK_PLUGINS_ENABLED = 'plugin1,plugin2,plugin3'
|
|
146
|
-
process.env.FLUXSTACK_PLUGINS_DISABLED = 'plugin4'
|
|
147
|
-
|
|
148
|
-
reloadConfig()
|
|
149
|
-
const config = getConfigSync()
|
|
150
|
-
|
|
151
|
-
expect(config.plugins?.enabled).toEqual(['plugin1', 'plugin2', 'plugin3'])
|
|
152
|
-
expect(config.plugins?.disabled).toEqual(['plugin4'])
|
|
153
|
-
})
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
describe('createPluginConfig', () => {
|
|
157
|
-
test('creates plugin configuration from main config', () => {
|
|
158
|
-
const mainConfig: FluxStackConfig = {
|
|
159
|
-
app: { name: 'TestApp', version: '1.0.0' },
|
|
160
|
-
server: {
|
|
161
|
-
port: 3000,
|
|
162
|
-
host: 'localhost',
|
|
163
|
-
apiPrefix: '/api',
|
|
164
|
-
cors: {
|
|
165
|
-
origins: ['*'],
|
|
166
|
-
methods: ['GET', 'POST'],
|
|
167
|
-
headers: ['Content-Type'],
|
|
168
|
-
credentials: false,
|
|
169
|
-
maxAge: 86400
|
|
170
|
-
},
|
|
171
|
-
middleware: []
|
|
172
|
-
},
|
|
173
|
-
client: {
|
|
174
|
-
port: 5173,
|
|
175
|
-
proxy: { target: 'http://localhost:3000' },
|
|
176
|
-
build: {
|
|
177
|
-
target: 'es2020',
|
|
178
|
-
outDir: 'dist/client',
|
|
179
|
-
sourceMaps: true,
|
|
180
|
-
minify: false
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
build: {
|
|
184
|
-
target: 'bun',
|
|
185
|
-
outDir: 'dist',
|
|
186
|
-
clean: true,
|
|
187
|
-
optimization: {
|
|
188
|
-
minify: false,
|
|
189
|
-
compress: false,
|
|
190
|
-
treeshake: false,
|
|
191
|
-
splitChunks: false,
|
|
192
|
-
bundleAnalyzer: false
|
|
193
|
-
},
|
|
194
|
-
sourceMaps: true
|
|
195
|
-
},
|
|
196
|
-
logging: {
|
|
197
|
-
level: 'info',
|
|
198
|
-
format: 'pretty',
|
|
199
|
-
transports: [
|
|
200
|
-
{ type: 'console', level: 'info', format: 'pretty' }
|
|
201
|
-
]
|
|
202
|
-
},
|
|
203
|
-
monitoring: {
|
|
204
|
-
enabled: false,
|
|
205
|
-
metrics: {
|
|
206
|
-
enabled: false,
|
|
207
|
-
collectInterval: 60000,
|
|
208
|
-
httpMetrics: true,
|
|
209
|
-
systemMetrics: true,
|
|
210
|
-
customMetrics: false
|
|
211
|
-
},
|
|
212
|
-
profiling: {
|
|
213
|
-
enabled: false,
|
|
214
|
-
sampleRate: 0.1,
|
|
215
|
-
memoryProfiling: false,
|
|
216
|
-
cpuProfiling: false
|
|
217
|
-
},
|
|
218
|
-
exporters: []
|
|
219
|
-
},
|
|
220
|
-
plugins: {
|
|
221
|
-
enabled: [],
|
|
222
|
-
disabled: [],
|
|
223
|
-
config: {
|
|
224
|
-
vite: {
|
|
225
|
-
port: 5174,
|
|
226
|
-
enabled: true
|
|
227
|
-
},
|
|
228
|
-
logger: {
|
|
229
|
-
logRequests: true,
|
|
230
|
-
logResponses: false
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
custom: {
|
|
235
|
-
myPlugin: {
|
|
236
|
-
customSetting: 'value'
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
} as FluxStackConfig
|
|
240
|
-
|
|
241
|
-
// Test plugin config from plugins.config
|
|
242
|
-
const viteConfig = createPluginConfig(mainConfig, 'vite')
|
|
243
|
-
expect(viteConfig).toEqual({
|
|
244
|
-
port: 5174,
|
|
245
|
-
enabled: true
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
// Test plugin config from custom section
|
|
249
|
-
const myPluginConfig = createPluginConfig(mainConfig, 'myPlugin')
|
|
250
|
-
expect(myPluginConfig).toEqual({
|
|
251
|
-
customSetting: 'value'
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
// Test merging both sections
|
|
255
|
-
const combinedConfig: FluxStackConfig = {
|
|
256
|
-
...mainConfig,
|
|
257
|
-
plugins: {
|
|
258
|
-
...mainConfig.plugins,
|
|
259
|
-
config: {
|
|
260
|
-
...mainConfig.plugins.config,
|
|
261
|
-
myPlugin: {
|
|
262
|
-
baseSetting: 'base'
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const mergedConfig = createPluginConfig(combinedConfig, 'myPlugin')
|
|
269
|
-
expect(mergedConfig).toEqual({
|
|
270
|
-
baseSetting: 'base',
|
|
271
|
-
customSetting: 'value' // custom should override plugins.config
|
|
272
|
-
})
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
test('returns empty object for non-existent plugin', () => {
|
|
276
|
-
const mainConfig: FluxStackConfig = {
|
|
277
|
-
app: { name: 'TestApp', version: '1.0.0' },
|
|
278
|
-
server: {
|
|
279
|
-
port: 3000,
|
|
280
|
-
host: 'localhost',
|
|
281
|
-
apiPrefix: '/api',
|
|
282
|
-
cors: {
|
|
283
|
-
origins: ['*'],
|
|
284
|
-
methods: ['GET', 'POST'],
|
|
285
|
-
headers: ['Content-Type'],
|
|
286
|
-
credentials: false,
|
|
287
|
-
maxAge: 86400
|
|
288
|
-
},
|
|
289
|
-
middleware: []
|
|
290
|
-
},
|
|
291
|
-
client: {
|
|
292
|
-
port: 5173,
|
|
293
|
-
proxy: { target: 'http://localhost:3000' },
|
|
294
|
-
build: {
|
|
295
|
-
target: 'es2020',
|
|
296
|
-
outDir: 'dist/client',
|
|
297
|
-
sourceMaps: true,
|
|
298
|
-
minify: false
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
|
-
build: {
|
|
302
|
-
target: 'bun',
|
|
303
|
-
outDir: 'dist',
|
|
304
|
-
clean: true,
|
|
305
|
-
optimization: {
|
|
306
|
-
minify: false,
|
|
307
|
-
compress: false,
|
|
308
|
-
treeshake: false,
|
|
309
|
-
splitChunks: false,
|
|
310
|
-
bundleAnalyzer: false
|
|
311
|
-
},
|
|
312
|
-
sourceMaps: true
|
|
313
|
-
},
|
|
314
|
-
logging: {
|
|
315
|
-
level: 'info',
|
|
316
|
-
format: 'pretty',
|
|
317
|
-
transports: [
|
|
318
|
-
{ type: 'console', level: 'info', format: 'pretty' }
|
|
319
|
-
]
|
|
320
|
-
},
|
|
321
|
-
monitoring: {
|
|
322
|
-
enabled: false,
|
|
323
|
-
metrics: {
|
|
324
|
-
enabled: false,
|
|
325
|
-
collectInterval: 60000,
|
|
326
|
-
httpMetrics: true,
|
|
327
|
-
systemMetrics: true,
|
|
328
|
-
customMetrics: false
|
|
329
|
-
},
|
|
330
|
-
profiling: {
|
|
331
|
-
enabled: false,
|
|
332
|
-
sampleRate: 0.1,
|
|
333
|
-
memoryProfiling: false,
|
|
334
|
-
cpuProfiling: false
|
|
335
|
-
},
|
|
336
|
-
exporters: []
|
|
337
|
-
},
|
|
338
|
-
plugins: {
|
|
339
|
-
enabled: [],
|
|
340
|
-
disabled: [],
|
|
341
|
-
config: {}
|
|
342
|
-
}
|
|
343
|
-
} as FluxStackConfig
|
|
344
|
-
|
|
345
|
-
const config = createPluginConfig(mainConfig, 'nonexistent')
|
|
346
|
-
expect(config).toEqual({})
|
|
347
|
-
})
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
describe('isFeatureEnabled', () => {
|
|
351
|
-
test('checks if feature is enabled in plugins', () => {
|
|
352
|
-
const config: FluxStackConfig = {
|
|
353
|
-
app: { name: 'TestApp', version: '1.0.0' },
|
|
354
|
-
server: {
|
|
355
|
-
port: 3000,
|
|
356
|
-
host: 'localhost',
|
|
357
|
-
apiPrefix: '/api',
|
|
358
|
-
cors: {
|
|
359
|
-
origins: ['*'],
|
|
360
|
-
methods: ['GET', 'POST'],
|
|
361
|
-
headers: ['Content-Type'],
|
|
362
|
-
credentials: false,
|
|
363
|
-
maxAge: 86400
|
|
364
|
-
},
|
|
365
|
-
middleware: []
|
|
366
|
-
},
|
|
367
|
-
client: {
|
|
368
|
-
port: 5173,
|
|
369
|
-
proxy: { target: 'http://localhost:3000' },
|
|
370
|
-
build: {
|
|
371
|
-
target: 'es2020',
|
|
372
|
-
outDir: 'dist/client',
|
|
373
|
-
sourceMaps: true,
|
|
374
|
-
minify: false
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
|
-
build: {
|
|
378
|
-
target: 'bun',
|
|
379
|
-
outDir: 'dist',
|
|
380
|
-
clean: true,
|
|
381
|
-
optimization: {
|
|
382
|
-
minify: false,
|
|
383
|
-
compress: false,
|
|
384
|
-
treeshake: false,
|
|
385
|
-
splitChunks: false,
|
|
386
|
-
bundleAnalyzer: false
|
|
387
|
-
},
|
|
388
|
-
sourceMaps: true
|
|
389
|
-
},
|
|
390
|
-
logging: {
|
|
391
|
-
level: 'info',
|
|
392
|
-
format: 'pretty',
|
|
393
|
-
transports: [
|
|
394
|
-
{ type: 'console', level: 'info', format: 'pretty' }
|
|
395
|
-
]
|
|
396
|
-
},
|
|
397
|
-
monitoring: {
|
|
398
|
-
enabled: true,
|
|
399
|
-
metrics: {
|
|
400
|
-
enabled: true,
|
|
401
|
-
collectInterval: 60000,
|
|
402
|
-
httpMetrics: true,
|
|
403
|
-
systemMetrics: true,
|
|
404
|
-
customMetrics: false
|
|
405
|
-
},
|
|
406
|
-
profiling: {
|
|
407
|
-
enabled: false,
|
|
408
|
-
sampleRate: 0.1,
|
|
409
|
-
memoryProfiling: false,
|
|
410
|
-
cpuProfiling: false
|
|
411
|
-
},
|
|
412
|
-
exporters: []
|
|
413
|
-
},
|
|
414
|
-
plugins: {
|
|
415
|
-
enabled: ['plugin1', 'plugin2'],
|
|
416
|
-
disabled: ['plugin3'],
|
|
417
|
-
config: {}
|
|
418
|
-
},
|
|
419
|
-
custom: {
|
|
420
|
-
customFeature: true
|
|
421
|
-
}
|
|
422
|
-
} as FluxStackConfig
|
|
423
|
-
|
|
424
|
-
expect(isFeatureEnabled(config, 'plugin1')).toBe(true)
|
|
425
|
-
expect(isFeatureEnabled(config, 'plugin2')).toBe(true)
|
|
426
|
-
expect(isFeatureEnabled(config, 'plugin3')).toBe(false) // disabled
|
|
427
|
-
expect(isFeatureEnabled(config, 'plugin4')).toBe(false) // not in enabled
|
|
428
|
-
expect(isFeatureEnabled(config, 'monitoring')).toBe(true)
|
|
429
|
-
expect(isFeatureEnabled(config, 'metrics')).toBe(true)
|
|
430
|
-
expect(isFeatureEnabled(config, 'profiling')).toBe(false)
|
|
431
|
-
expect(isFeatureEnabled(config, 'customFeature')).toBe(true)
|
|
432
|
-
expect(isFeatureEnabled(config, 'nonexistent')).toBe(false)
|
|
433
|
-
})
|
|
434
|
-
})
|
|
435
|
-
|
|
436
|
-
describe('createLegacyConfig', () => {
|
|
437
|
-
test('creates legacy configuration format', () => {
|
|
438
|
-
const config: FluxStackConfig = {
|
|
439
|
-
app: { name: 'TestApp', version: '1.0.0' },
|
|
440
|
-
server: {
|
|
441
|
-
port: 4000,
|
|
442
|
-
host: 'localhost',
|
|
443
|
-
apiPrefix: '/v2',
|
|
444
|
-
cors: {
|
|
445
|
-
origins: ['http://localhost:3000', 'https://example.com'],
|
|
446
|
-
methods: ['GET', 'POST', 'PUT'],
|
|
447
|
-
headers: ['Content-Type', 'Authorization'],
|
|
448
|
-
credentials: true,
|
|
449
|
-
maxAge: 86400
|
|
450
|
-
},
|
|
451
|
-
middleware: []
|
|
452
|
-
},
|
|
453
|
-
client: {
|
|
454
|
-
port: 5174,
|
|
455
|
-
proxy: { target: 'http://localhost:3000' },
|
|
456
|
-
build: {
|
|
457
|
-
target: 'es2020',
|
|
458
|
-
outDir: 'dist/client',
|
|
459
|
-
sourceMaps: true,
|
|
460
|
-
minify: false
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
build: {
|
|
464
|
-
target: 'docker',
|
|
465
|
-
outDir: 'build',
|
|
466
|
-
clean: true,
|
|
467
|
-
optimization: {
|
|
468
|
-
minify: false,
|
|
469
|
-
compress: false,
|
|
470
|
-
treeshake: false,
|
|
471
|
-
splitChunks: false,
|
|
472
|
-
bundleAnalyzer: false
|
|
473
|
-
},
|
|
474
|
-
sourceMaps: true
|
|
475
|
-
},
|
|
476
|
-
logging: {
|
|
477
|
-
level: 'info',
|
|
478
|
-
format: 'pretty',
|
|
479
|
-
transports: [
|
|
480
|
-
{ type: 'console', level: 'info', format: 'pretty' }
|
|
481
|
-
]
|
|
482
|
-
},
|
|
483
|
-
monitoring: {
|
|
484
|
-
enabled: false,
|
|
485
|
-
metrics: {
|
|
486
|
-
enabled: false,
|
|
487
|
-
collectInterval: 60000,
|
|
488
|
-
httpMetrics: true,
|
|
489
|
-
systemMetrics: true,
|
|
490
|
-
customMetrics: false
|
|
491
|
-
},
|
|
492
|
-
profiling: {
|
|
493
|
-
enabled: false,
|
|
494
|
-
sampleRate: 0.1,
|
|
495
|
-
memoryProfiling: false,
|
|
496
|
-
cpuProfiling: false
|
|
497
|
-
},
|
|
498
|
-
exporters: []
|
|
499
|
-
},
|
|
500
|
-
plugins: {
|
|
501
|
-
enabled: [],
|
|
502
|
-
disabled: [],
|
|
503
|
-
config: {}
|
|
504
|
-
}
|
|
505
|
-
} as FluxStackConfig
|
|
506
|
-
|
|
507
|
-
const legacyConfig = createLegacyConfig(config)
|
|
508
|
-
|
|
509
|
-
expect(legacyConfig).toEqual({
|
|
510
|
-
port: 4000,
|
|
511
|
-
vitePort: 5174,
|
|
512
|
-
clientPath: 'app/client',
|
|
513
|
-
apiPrefix: '/v2',
|
|
514
|
-
cors: {
|
|
515
|
-
origins: ['http://localhost:3000', 'https://example.com'],
|
|
516
|
-
methods: ['GET', 'POST', 'PUT'],
|
|
517
|
-
headers: ['Content-Type', 'Authorization']
|
|
518
|
-
},
|
|
519
|
-
build: {
|
|
520
|
-
outDir: 'build',
|
|
521
|
-
target: 'docker'
|
|
522
|
-
}
|
|
523
|
-
})
|
|
524
|
-
})
|
|
525
|
-
})
|
|
526
|
-
|
|
527
|
-
describe('error handling and warnings', () => {
|
|
528
|
-
test('handles configuration with warnings gracefully', () => {
|
|
529
|
-
// Test with invalid environment variables that should generate warnings
|
|
530
|
-
process.env.PORT = 'invalid-port' // Should fall back to default
|
|
531
|
-
process.env.LOG_LEVEL = 'debug' // Valid value
|
|
532
|
-
process.env.FLUXSTACK_BUILD_TARGET = 'bun' // Valid value
|
|
533
|
-
|
|
534
|
-
expect(() => {
|
|
535
|
-
const config = getConfigSync()
|
|
536
|
-
// Should not throw, but use defaults for invalid values
|
|
537
|
-
expect(typeof config.server?.port).toBe('number')
|
|
538
|
-
expect(['debug', 'info', 'warn', 'error']).toContain(config.logging?.level)
|
|
539
|
-
expect(['bun', 'node', 'docker']).toContain(config.build?.target)
|
|
540
|
-
}).not.toThrow()
|
|
541
|
-
})
|
|
542
|
-
|
|
543
|
-
test('handles missing optional configurations', () => {
|
|
544
|
-
// No environment variables set
|
|
545
|
-
const config = getConfigSync()
|
|
546
|
-
|
|
547
|
-
// Should have default values and structure
|
|
548
|
-
expect(config).toBeDefined()
|
|
549
|
-
expect(config.app).toBeDefined()
|
|
550
|
-
expect(config.server).toBeDefined()
|
|
551
|
-
expect(config.plugins).toBeDefined()
|
|
552
|
-
})
|
|
553
|
-
})
|
|
554
|
-
})
|