create-fluxstack 1.0.13 → 1.0.15
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 +196 -33
- 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
package/core/plugins/registry.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FluxStack, PluginManifest, PluginLoadResult, PluginDiscoveryOptions } from "./types"
|
|
2
|
+
|
|
3
|
+
type FluxStackPlugin = FluxStack.Plugin
|
|
2
4
|
import type { FluxStackConfig } from "../config/schema"
|
|
3
5
|
import type { Logger } from "../utils/logger/index"
|
|
4
6
|
import { FluxStackError } from "../utils/errors"
|
|
7
|
+
import { PluginDependencyManager } from "./dependency-manager"
|
|
5
8
|
import { readdir, readFile } from "fs/promises"
|
|
6
9
|
import { join, resolve } from "path"
|
|
7
10
|
import { existsSync } from "fs"
|
|
@@ -13,23 +16,29 @@ export interface PluginRegistryConfig {
|
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export class PluginRegistry {
|
|
16
|
-
private plugins: Map<string,
|
|
19
|
+
private plugins: Map<string, FluxStackPlugin> = new Map()
|
|
17
20
|
private manifests: Map<string, PluginManifest> = new Map()
|
|
18
21
|
private loadOrder: string[] = []
|
|
19
22
|
private dependencies: Map<string, string[]> = new Map()
|
|
20
23
|
private conflicts: string[] = []
|
|
21
24
|
private logger?: Logger
|
|
22
25
|
private config?: FluxStackConfig
|
|
26
|
+
private dependencyManager: PluginDependencyManager
|
|
23
27
|
|
|
24
28
|
constructor(options: PluginRegistryConfig = {}) {
|
|
25
29
|
this.logger = options.logger
|
|
26
30
|
this.config = options.config
|
|
31
|
+
this.dependencyManager = new PluginDependencyManager({
|
|
32
|
+
logger: this.logger,
|
|
33
|
+
autoInstall: true,
|
|
34
|
+
packageManager: 'bun'
|
|
35
|
+
})
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
/**
|
|
30
39
|
* Register a plugin with the registry
|
|
31
40
|
*/
|
|
32
|
-
async register(plugin:
|
|
41
|
+
async register(plugin: FluxStackPlugin, manifest?: PluginManifest): Promise<void> {
|
|
33
42
|
if (this.plugins.has(plugin.name)) {
|
|
34
43
|
throw new FluxStackError(
|
|
35
44
|
`Plugin '${plugin.name}' is already registered`,
|
|
@@ -100,7 +109,7 @@ export class PluginRegistry {
|
|
|
100
109
|
/**
|
|
101
110
|
* Get a plugin by name
|
|
102
111
|
*/
|
|
103
|
-
get(name: string):
|
|
112
|
+
get(name: string): FluxStackPlugin | undefined {
|
|
104
113
|
return this.plugins.get(name)
|
|
105
114
|
}
|
|
106
115
|
|
|
@@ -114,7 +123,7 @@ export class PluginRegistry {
|
|
|
114
123
|
/**
|
|
115
124
|
* Get all registered plugins
|
|
116
125
|
*/
|
|
117
|
-
getAll():
|
|
126
|
+
getAll(): FluxStackPlugin[] {
|
|
118
127
|
return Array.from(this.plugins.values())
|
|
119
128
|
}
|
|
120
129
|
|
|
@@ -208,19 +217,23 @@ export class PluginRegistry {
|
|
|
208
217
|
async discoverPlugins(options: PluginDiscoveryOptions = {}): Promise<PluginLoadResult[]> {
|
|
209
218
|
const results: PluginLoadResult[] = []
|
|
210
219
|
const {
|
|
211
|
-
directories = ['
|
|
220
|
+
directories = ['plugins'],
|
|
212
221
|
patterns: _patterns = ['**/plugin.{js,ts}', '**/index.{js,ts}'],
|
|
213
|
-
includeBuiltIn: _includeBuiltIn =
|
|
222
|
+
includeBuiltIn: _includeBuiltIn = false,
|
|
214
223
|
includeExternal: _includeExternal = true
|
|
215
224
|
} = options
|
|
216
225
|
|
|
226
|
+
// Descobrir plugins
|
|
217
227
|
for (const directory of directories) {
|
|
228
|
+
this.logger?.info(`Scanning directory: ${directory}`)
|
|
218
229
|
if (!existsSync(directory)) {
|
|
230
|
+
this.logger?.warn(`Directory does not exist: ${directory}`)
|
|
219
231
|
continue
|
|
220
232
|
}
|
|
221
233
|
|
|
222
234
|
try {
|
|
223
235
|
const pluginResults = await this.discoverPluginsInDirectory(directory, _patterns)
|
|
236
|
+
this.logger?.info(`Found ${pluginResults.length} plugins in ${directory}`)
|
|
224
237
|
results.push(...pluginResults)
|
|
225
238
|
} catch (error) {
|
|
226
239
|
this.logger?.warn(`Failed to discover plugins in directory '${directory}'`, { error })
|
|
@@ -231,6 +244,9 @@ export class PluginRegistry {
|
|
|
231
244
|
}
|
|
232
245
|
}
|
|
233
246
|
|
|
247
|
+
// Resolver e instalar dependências
|
|
248
|
+
await this.resolveDependencies(results)
|
|
249
|
+
|
|
234
250
|
return results
|
|
235
251
|
}
|
|
236
252
|
|
|
@@ -250,7 +266,7 @@ export class PluginRegistry {
|
|
|
250
266
|
|
|
251
267
|
// Try to import the plugin
|
|
252
268
|
const pluginModule = await import(resolve(pluginPath))
|
|
253
|
-
const plugin:
|
|
269
|
+
const plugin: FluxStackPlugin = pluginModule.default || pluginModule
|
|
254
270
|
|
|
255
271
|
if (!plugin || typeof plugin !== 'object' || !plugin.name) {
|
|
256
272
|
return {
|
|
@@ -278,7 +294,7 @@ export class PluginRegistry {
|
|
|
278
294
|
/**
|
|
279
295
|
* Validate plugin structure
|
|
280
296
|
*/
|
|
281
|
-
private validatePlugin(plugin:
|
|
297
|
+
private validatePlugin(plugin: FluxStackPlugin): void {
|
|
282
298
|
if (!plugin.name || typeof plugin.name !== 'string') {
|
|
283
299
|
throw new FluxStackError(
|
|
284
300
|
'Plugin must have a valid name property',
|
|
@@ -315,7 +331,7 @@ export class PluginRegistry {
|
|
|
315
331
|
/**
|
|
316
332
|
* Validate plugin configuration against schema
|
|
317
333
|
*/
|
|
318
|
-
private validatePluginConfig(plugin:
|
|
334
|
+
private validatePluginConfig(plugin: FluxStackPlugin, config: any): void {
|
|
319
335
|
if (!plugin.configSchema) {
|
|
320
336
|
return
|
|
321
337
|
}
|
|
@@ -387,6 +403,62 @@ export class PluginRegistry {
|
|
|
387
403
|
})
|
|
388
404
|
}
|
|
389
405
|
|
|
406
|
+
/**
|
|
407
|
+
* Resolver dependências de todos os plugins descobertos
|
|
408
|
+
*/
|
|
409
|
+
private async resolveDependencies(results: PluginLoadResult[]): Promise<void> {
|
|
410
|
+
const resolutions = []
|
|
411
|
+
|
|
412
|
+
// Resolver dependências para cada plugin carregado com sucesso
|
|
413
|
+
for (const result of results) {
|
|
414
|
+
if (result.success && result.plugin) {
|
|
415
|
+
try {
|
|
416
|
+
// Tentar encontrar o diretório do plugin
|
|
417
|
+
const pluginDir = this.findPluginDirectory(result.plugin.name)
|
|
418
|
+
if (pluginDir) {
|
|
419
|
+
const resolution = await this.dependencyManager.resolvePluginDependencies(pluginDir)
|
|
420
|
+
resolutions.push(resolution)
|
|
421
|
+
|
|
422
|
+
if (!resolution.resolved) {
|
|
423
|
+
this.logger?.warn(`Plugin '${result.plugin.name}' tem conflitos de dependências`, {
|
|
424
|
+
conflicts: resolution.conflicts.length
|
|
425
|
+
})
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
} catch (error) {
|
|
429
|
+
this.logger?.warn(`Erro ao resolver dependências do plugin '${result.plugin.name}'`, { error })
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Instalar dependências se houver resoluções
|
|
435
|
+
if (resolutions.length > 0) {
|
|
436
|
+
try {
|
|
437
|
+
await this.dependencyManager.installPluginDependencies(resolutions)
|
|
438
|
+
} catch (error) {
|
|
439
|
+
this.logger?.error('Erro ao instalar dependências de plugins', { error })
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Encontrar diretório de um plugin pelo nome
|
|
446
|
+
*/
|
|
447
|
+
private findPluginDirectory(pluginName: string): string | null {
|
|
448
|
+
const possiblePaths = [
|
|
449
|
+
`plugins/${pluginName}`,
|
|
450
|
+
`core/plugins/built-in/${pluginName}`
|
|
451
|
+
]
|
|
452
|
+
|
|
453
|
+
for (const path of possiblePaths) {
|
|
454
|
+
if (existsSync(path)) {
|
|
455
|
+
return path
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return null
|
|
460
|
+
}
|
|
461
|
+
|
|
390
462
|
/**
|
|
391
463
|
* Discover plugins in a specific directory
|
|
392
464
|
*/
|
|
@@ -404,12 +476,18 @@ export class PluginRegistry {
|
|
|
404
476
|
const pluginDir = join(directory, entry.name)
|
|
405
477
|
|
|
406
478
|
// Check if this looks like a plugin directory
|
|
479
|
+
// Skip if it's just an index file in the root of built-in directory
|
|
480
|
+
if (directory === 'core/plugins/built-in' && entry.name === 'index.ts') {
|
|
481
|
+
continue
|
|
482
|
+
}
|
|
483
|
+
|
|
407
484
|
const hasPluginFile = existsSync(join(pluginDir, 'index.ts')) ||
|
|
408
485
|
existsSync(join(pluginDir, 'index.js')) ||
|
|
409
486
|
existsSync(join(pluginDir, 'plugin.ts')) ||
|
|
410
487
|
existsSync(join(pluginDir, 'plugin.js'))
|
|
411
488
|
|
|
412
489
|
if (hasPluginFile) {
|
|
490
|
+
this.logger?.info(`Loading plugin from: ${pluginDir}`)
|
|
413
491
|
const result = await this.loadPlugin(pluginDir)
|
|
414
492
|
results.push(result)
|
|
415
493
|
}
|
package/core/plugins/types.ts
CHANGED
|
@@ -75,13 +75,16 @@ export interface PluginConfigSchema {
|
|
|
75
75
|
additionalProperties?: boolean
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
export
|
|
78
|
+
export namespace FluxStack {
|
|
79
|
+
export interface Plugin {
|
|
79
80
|
name: string
|
|
80
81
|
version?: string
|
|
81
82
|
description?: string
|
|
82
83
|
author?: string
|
|
83
84
|
dependencies?: string[]
|
|
84
85
|
priority?: number | PluginPriority
|
|
86
|
+
category?: string
|
|
87
|
+
tags?: string[]
|
|
85
88
|
|
|
86
89
|
// Lifecycle hooks
|
|
87
90
|
setup?: (context: PluginContext) => void | Promise<void>
|
|
@@ -94,19 +97,16 @@ export interface Plugin {
|
|
|
94
97
|
onBuild?: (context: BuildContext) => void | Promise<void>
|
|
95
98
|
onBuildComplete?: (context: BuildContext) => void | Promise<void>
|
|
96
99
|
|
|
97
|
-
// CLI commands
|
|
98
|
-
commands?: CliCommand[]
|
|
99
|
-
|
|
100
100
|
// Configuration
|
|
101
101
|
configSchema?: PluginConfigSchema
|
|
102
102
|
defaultConfig?: any
|
|
103
103
|
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
category?: string
|
|
104
|
+
// CLI commands
|
|
105
|
+
commands?: CliCommand[]
|
|
106
|
+
}
|
|
108
107
|
}
|
|
109
108
|
|
|
109
|
+
|
|
110
110
|
export interface PluginManifest {
|
|
111
111
|
name: string
|
|
112
112
|
version: string
|
|
@@ -129,13 +129,13 @@ export interface PluginManifest {
|
|
|
129
129
|
|
|
130
130
|
export interface PluginLoadResult {
|
|
131
131
|
success: boolean
|
|
132
|
-
plugin?: Plugin
|
|
132
|
+
plugin?: FluxStack.Plugin
|
|
133
133
|
error?: string
|
|
134
134
|
warnings?: string[]
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
export interface PluginRegistryState {
|
|
138
|
-
plugins: Map<string, Plugin>
|
|
138
|
+
plugins: Map<string, FluxStack.Plugin>
|
|
139
139
|
manifests: Map<string, PluginManifest>
|
|
140
140
|
loadOrder: string[]
|
|
141
141
|
dependencies: Map<string, string[]>
|
|
@@ -177,7 +177,7 @@ export interface PluginInstallOptions {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
export interface PluginExecutionContext {
|
|
180
|
-
plugin: Plugin
|
|
180
|
+
plugin: FluxStack.Plugin
|
|
181
181
|
hook: PluginHook
|
|
182
182
|
startTime: number
|
|
183
183
|
timeout?: number
|
package/core/server/framework.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Elysia } from "elysia"
|
|
2
2
|
import type { FluxStackConfig, FluxStackContext, Plugin } from "../types"
|
|
3
3
|
import type { PluginContext, PluginUtils } from "../plugins/types"
|
|
4
|
+
import { PluginManager } from "../plugins/manager"
|
|
4
5
|
import { getConfigSync, getEnvironmentInfo } from "../config"
|
|
5
6
|
import { logger, type Logger } from "../utils/logger/index"
|
|
6
7
|
import { createTimer, formatBytes, isProduction, isDevelopment } from "../utils/helpers"
|
|
@@ -10,8 +11,10 @@ export class FluxStackFramework {
|
|
|
10
11
|
private context: FluxStackContext
|
|
11
12
|
private pluginContext: PluginContext
|
|
12
13
|
private plugins: Plugin[] = []
|
|
14
|
+
private pluginManager: PluginManager
|
|
13
15
|
|
|
14
16
|
constructor(config?: Partial<FluxStackConfig>) {
|
|
17
|
+
console.log('🚀 [DEBUG] FluxStackFramework constructor called!')
|
|
15
18
|
// Load the full configuration
|
|
16
19
|
const fullConfig = config ? { ...getConfigSync(), ...config } : getConfigSync()
|
|
17
20
|
const envInfo = getEnvironmentInfo()
|
|
@@ -67,7 +70,41 @@ export class FluxStackFramework {
|
|
|
67
70
|
utils: pluginUtils
|
|
68
71
|
}
|
|
69
72
|
|
|
73
|
+
// Initialize plugin manager
|
|
74
|
+
this.pluginManager = new PluginManager({
|
|
75
|
+
config: fullConfig,
|
|
76
|
+
logger: logger as Logger,
|
|
77
|
+
app: this.app
|
|
78
|
+
})
|
|
79
|
+
|
|
70
80
|
this.setupCors()
|
|
81
|
+
|
|
82
|
+
console.log('🔍 [DEBUG] About to call initializePluginsAsync()...')
|
|
83
|
+
// Initialize plugins automatically in the background
|
|
84
|
+
this.initializePluginsAsync().catch(error => {
|
|
85
|
+
console.error('❌ [DEBUG] Failed to initialize plugins async:', error)
|
|
86
|
+
})
|
|
87
|
+
console.log('🔍 [DEBUG] initializePluginsAsync() call dispatched')
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private async initializePluginsAsync() {
|
|
91
|
+
console.log('🚀 [DEBUG] initializePluginsAsync() CALLED!')
|
|
92
|
+
try {
|
|
93
|
+
console.log('🔍 [DEBUG] Starting automatic plugin discovery...')
|
|
94
|
+
console.log('🔍 [DEBUG] Current working directory:', process.cwd())
|
|
95
|
+
logger.info('[FluxStack] Initializing automatic plugin discovery...')
|
|
96
|
+
await this.pluginManager.initialize()
|
|
97
|
+
const stats = this.pluginManager.getRegistry().getStats()
|
|
98
|
+
console.log('🔍 [DEBUG] Plugin discovery completed:', stats)
|
|
99
|
+
logger.info('[FluxStack] Automatic plugins loaded successfully', {
|
|
100
|
+
pluginCount: stats.totalPlugins,
|
|
101
|
+
enabledPlugins: stats.enabledPlugins,
|
|
102
|
+
disabledPlugins: stats.disabledPlugins
|
|
103
|
+
})
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error('❌ [DEBUG] Plugin discovery error:', error)
|
|
106
|
+
logger.error('[FluxStack] Failed to initialize automatic plugins', { error })
|
|
107
|
+
}
|
|
71
108
|
}
|
|
72
109
|
|
|
73
110
|
private setupCors() {
|
|
@@ -114,6 +151,12 @@ export class FluxStackFramework {
|
|
|
114
151
|
const apiPrefix = this.context.config.server.apiPrefix
|
|
115
152
|
|
|
116
153
|
this.app.listen(port, () => {
|
|
154
|
+
logger.info('[FluxStack] Server started on port ' + port, {
|
|
155
|
+
apiPrefix,
|
|
156
|
+
environment: this.context.environment,
|
|
157
|
+
manualPlugins: this.plugins.length,
|
|
158
|
+
automaticPlugins: this.pluginManager.getRegistry().getStats().totalPlugins
|
|
159
|
+
})
|
|
117
160
|
console.log(`🚀 API ready at http://localhost:${port}${apiPrefix}`)
|
|
118
161
|
console.log(`📋 Health check: http://localhost:${port}${apiPrefix}/health`)
|
|
119
162
|
console.log()
|
package/core/server/index.ts
CHANGED
|
@@ -5,4 +5,14 @@ export { vitePlugin } from "../plugins/built-in/vite"
|
|
|
5
5
|
export { staticPlugin } from "../plugins/built-in/static"
|
|
6
6
|
export { swaggerPlugin } from "../plugins/built-in/swagger"
|
|
7
7
|
export { PluginRegistry } from "../plugins/registry"
|
|
8
|
-
export * from "../types"
|
|
8
|
+
export * from "../types"
|
|
9
|
+
|
|
10
|
+
// Live Components exports
|
|
11
|
+
export { liveComponentsPlugin } from "./live/websocket-plugin"
|
|
12
|
+
export { componentRegistry } from "./live/ComponentRegistry"
|
|
13
|
+
export { LiveComponent } from "../types/types"
|
|
14
|
+
|
|
15
|
+
// Static Files Plugin
|
|
16
|
+
export { staticFilesPlugin } from "./plugins/static-files-plugin"
|
|
17
|
+
|
|
18
|
+
export * from "../types/types"
|