create-fluxstack 1.1.0 → 1.4.1
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/app/server/backend-only.ts +5 -5
- package/app/server/index.ts +63 -54
- package/app/server/live/FluxStackConfig.ts +43 -39
- package/app/server/live/SystemMonitorIntegration.ts +2 -2
- package/app/server/live/register-components.ts +1 -1
- package/app/server/middleware/errorHandling.ts +6 -4
- package/app/server/routes/config.ts +145 -0
- package/app/server/routes/index.ts +5 -3
- package/config/app.config.ts +113 -0
- package/config/build.config.ts +24 -0
- package/config/database.config.ts +99 -0
- package/config/index.ts +68 -0
- package/config/logger.config.ts +27 -0
- package/config/runtime.config.ts +92 -0
- package/config/server.config.ts +46 -0
- package/config/services.config.ts +130 -0
- package/config/system.config.ts +105 -0
- package/core/build/index.ts +10 -4
- package/core/cli/generators/index.ts +5 -2
- package/core/cli/generators/plugin.ts +290 -0
- package/core/cli/index.ts +117 -15
- package/core/config/env.ts +37 -95
- package/core/config/runtime-config.ts +61 -58
- package/core/config/schema.ts +4 -0
- package/core/framework/server.ts +22 -10
- package/core/plugins/built-in/index.ts +7 -17
- package/core/plugins/built-in/swagger/index.ts +228 -228
- package/core/plugins/built-in/vite/index.ts +374 -358
- package/core/plugins/dependency-manager.ts +5 -5
- package/core/plugins/manager.ts +12 -12
- package/core/plugins/registry.ts +3 -3
- package/core/server/index.ts +0 -1
- package/core/server/live/ComponentRegistry.ts +34 -8
- package/core/server/live/LiveComponentPerformanceMonitor.ts +1 -1
- package/core/server/live/websocket-plugin.ts +434 -434
- package/core/server/middleware/README.md +488 -0
- package/core/server/middleware/elysia-helpers.ts +227 -0
- package/core/server/middleware/index.ts +25 -9
- package/core/server/plugins/static-files-plugin.ts +231 -231
- package/core/utils/config-schema.ts +484 -0
- package/core/utils/env.ts +306 -0
- package/core/utils/helpers.ts +4 -4
- package/core/utils/logger/colors.ts +114 -0
- package/core/utils/logger/config.ts +35 -0
- package/core/utils/logger/formatter.ts +82 -0
- package/core/utils/logger/group-logger.ts +101 -0
- package/core/utils/logger/index.ts +199 -250
- package/core/utils/logger/stack-trace.ts +92 -0
- package/core/utils/logger/startup-banner.ts +92 -0
- package/core/utils/logger/winston-logger.ts +152 -0
- package/core/utils/version.ts +5 -0
- package/create-fluxstack.ts +118 -8
- package/fluxstack.config.ts +2 -2
- package/package.json +117 -115
- package/core/config/env-dynamic.ts +0 -326
- package/core/plugins/built-in/logger/index.ts +0 -180
- package/core/server/plugins/logger.ts +0 -47
- package/core/utils/env-runtime-v2.ts +0 -232
- package/core/utils/env-runtime.ts +0 -259
- package/core/utils/logger/formatters.ts +0 -222
- package/core/utils/logger/middleware.ts +0 -253
- package/core/utils/logger/performance.ts +0 -384
- package/core/utils/logger/transports.ts +0 -365
- package/core/utils/logger.ts +0 -106
|
@@ -139,7 +139,7 @@ export class PluginDependencyManager {
|
|
|
139
139
|
*/
|
|
140
140
|
async installPluginDependencies(resolutions: DependencyResolution[]): Promise<void> {
|
|
141
141
|
if (!this.config.autoInstall) {
|
|
142
|
-
this.logger?.
|
|
142
|
+
this.logger?.debug('Auto-instalação desabilitada, pulando instalação de dependências')
|
|
143
143
|
return
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -164,17 +164,17 @@ export class PluginDependencyManager {
|
|
|
164
164
|
})
|
|
165
165
|
|
|
166
166
|
if (needsInstallation.length === 0) {
|
|
167
|
-
this.logger?.
|
|
167
|
+
this.logger?.debug('Todas as dependências de plugins já estão instaladas')
|
|
168
168
|
return
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
this.logger?.
|
|
171
|
+
this.logger?.debug(`Instalando ${needsInstallation.length} dependências de plugins`, {
|
|
172
172
|
dependencies: needsInstallation.map(d => `${d.name}@${d.version}`)
|
|
173
173
|
})
|
|
174
174
|
|
|
175
175
|
try {
|
|
176
176
|
await this.installDependencies(needsInstallation)
|
|
177
|
-
this.logger?.
|
|
177
|
+
this.logger?.debug('Dependências de plugins instaladas com sucesso')
|
|
178
178
|
} catch (error) {
|
|
179
179
|
this.logger?.error('Erro ao instalar dependências de plugins', { error })
|
|
180
180
|
throw error
|
|
@@ -239,7 +239,7 @@ export class PluginDependencyManager {
|
|
|
239
239
|
const resolution = sortedVersions[0].version
|
|
240
240
|
conflict.resolution = resolution
|
|
241
241
|
|
|
242
|
-
this.logger?.
|
|
242
|
+
this.logger?.debug(`Conflito resolvido para '${conflict.package}': usando versão ${resolution}`, {
|
|
243
243
|
package: conflict.package,
|
|
244
244
|
resolution,
|
|
245
245
|
conflictingVersions: conflict.versions
|
package/core/plugins/manager.ts
CHANGED
|
@@ -60,27 +60,27 @@ export class PluginManager extends EventEmitter {
|
|
|
60
60
|
return
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
this.logger.
|
|
63
|
+
this.logger.debug('Initializing plugin manager')
|
|
64
64
|
|
|
65
65
|
try {
|
|
66
66
|
// Discover and load plugins
|
|
67
67
|
this.logger.debug('Starting plugin discovery...')
|
|
68
68
|
await this.discoverPlugins()
|
|
69
69
|
this.logger.debug('Plugin discovery completed')
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
// Setup plugin contexts
|
|
72
72
|
this.logger.debug('Setting up plugin contexts...')
|
|
73
73
|
this.setupPluginContexts()
|
|
74
74
|
this.logger.debug('Plugin contexts setup completed')
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
// Execute setup hooks
|
|
77
77
|
this.logger.debug('Executing setup hooks...')
|
|
78
78
|
await this.executeHook('setup')
|
|
79
79
|
this.logger.debug('Setup hooks execution completed')
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
this.initialized = true
|
|
82
82
|
const stats = this.registry.getStats()
|
|
83
|
-
this.logger.
|
|
83
|
+
this.logger.debug('Plugin manager initialized successfully', {
|
|
84
84
|
totalPlugins: stats.totalPlugins,
|
|
85
85
|
enabledPlugins: stats.enabledPlugins,
|
|
86
86
|
loadOrder: stats.loadOrder
|
|
@@ -412,19 +412,19 @@ export class PluginManager extends EventEmitter {
|
|
|
412
412
|
private async discoverPlugins(): Promise<void> {
|
|
413
413
|
try {
|
|
414
414
|
// Load built-in plugins first (handled by core system)
|
|
415
|
-
this.logger.
|
|
415
|
+
this.logger.debug('Loading built-in plugins...')
|
|
416
416
|
const builtInResults = await this.registry.discoverPlugins({
|
|
417
417
|
directories: [],
|
|
418
418
|
includeBuiltIn: true,
|
|
419
419
|
includeExternal: false
|
|
420
420
|
})
|
|
421
|
-
|
|
421
|
+
|
|
422
422
|
// Try to use auto-generated registry for external plugins (if available from build)
|
|
423
423
|
let externalResults: any[] = []
|
|
424
424
|
try {
|
|
425
425
|
const autoRegistryModule = await import('./auto-registry')
|
|
426
426
|
if (autoRegistryModule.discoveredPlugins && autoRegistryModule.registerDiscoveredPlugins) {
|
|
427
|
-
this.logger.
|
|
427
|
+
this.logger.debug('🚀 Using auto-generated external plugins registry')
|
|
428
428
|
await autoRegistryModule.registerDiscoveredPlugins(this.registry)
|
|
429
429
|
externalResults = autoRegistryModule.discoveredPlugins.map((plugin: any) => ({
|
|
430
430
|
success: true,
|
|
@@ -433,16 +433,16 @@ export class PluginManager extends EventEmitter {
|
|
|
433
433
|
}
|
|
434
434
|
} catch (error) {
|
|
435
435
|
this.logger.debug('Auto-generated external plugins registry not found, falling back to discovery', { error: error.message })
|
|
436
|
-
|
|
436
|
+
|
|
437
437
|
// Fallback to runtime discovery for external plugins
|
|
438
|
-
this.logger.
|
|
438
|
+
this.logger.debug('Discovering external plugins in directory: plugins')
|
|
439
439
|
externalResults = await this.registry.discoverPlugins({
|
|
440
440
|
directories: ['plugins'],
|
|
441
441
|
includeBuiltIn: false,
|
|
442
442
|
includeExternal: true
|
|
443
443
|
})
|
|
444
444
|
}
|
|
445
|
-
|
|
445
|
+
|
|
446
446
|
// Combine results
|
|
447
447
|
const results = [...builtInResults, ...externalResults]
|
|
448
448
|
|
|
@@ -463,7 +463,7 @@ export class PluginManager extends EventEmitter {
|
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
465
|
|
|
466
|
-
this.logger.
|
|
466
|
+
this.logger.debug('Plugin discovery completed', { loaded, failed })
|
|
467
467
|
} catch (error) {
|
|
468
468
|
this.logger.error('Plugin discovery failed', { error })
|
|
469
469
|
throw error
|
package/core/plugins/registry.ts
CHANGED
|
@@ -225,7 +225,7 @@ export class PluginRegistry {
|
|
|
225
225
|
|
|
226
226
|
// Descobrir plugins
|
|
227
227
|
for (const directory of directories) {
|
|
228
|
-
this.logger?.
|
|
228
|
+
this.logger?.debug(`Scanning directory: ${directory}`)
|
|
229
229
|
if (!existsSync(directory)) {
|
|
230
230
|
this.logger?.warn(`Directory does not exist: ${directory}`)
|
|
231
231
|
continue
|
|
@@ -233,7 +233,7 @@ export class PluginRegistry {
|
|
|
233
233
|
|
|
234
234
|
try {
|
|
235
235
|
const pluginResults = await this.discoverPluginsInDirectory(directory, _patterns)
|
|
236
|
-
this.logger?.
|
|
236
|
+
this.logger?.debug(`Found ${pluginResults.length} plugins in ${directory}`)
|
|
237
237
|
results.push(...pluginResults)
|
|
238
238
|
} catch (error) {
|
|
239
239
|
this.logger?.warn(`Failed to discover plugins in directory '${directory}'`, { error })
|
|
@@ -487,7 +487,7 @@ export class PluginRegistry {
|
|
|
487
487
|
existsSync(join(pluginDir, 'plugin.js'))
|
|
488
488
|
|
|
489
489
|
if (hasPluginFile) {
|
|
490
|
-
this.logger?.
|
|
490
|
+
this.logger?.debug(`Loading plugin from: ${pluginDir}`)
|
|
491
491
|
const result = await this.loadPlugin(pluginDir)
|
|
492
492
|
results.push(result)
|
|
493
493
|
}
|
package/core/server/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// FluxStack framework exports
|
|
2
2
|
export { FluxStackFramework } from "../framework/server"
|
|
3
|
-
export { loggerPlugin } from "../plugins/built-in/logger"
|
|
4
3
|
export { vitePlugin } from "../plugins/built-in/vite"
|
|
5
4
|
export { staticPlugin } from "../plugins/built-in/static"
|
|
6
5
|
export { swaggerPlugin } from "../plugins/built-in/swagger"
|
|
@@ -143,7 +143,7 @@ export class ComponentRegistry {
|
|
|
143
143
|
// Register component class dynamically
|
|
144
144
|
registerComponentClass(name: string, componentClass: any) {
|
|
145
145
|
this.autoDiscoveredComponents.set(name, componentClass)
|
|
146
|
-
|
|
146
|
+
// Logging is handled by autoDiscoverComponents
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
// Auto-discover components from directory
|
|
@@ -151,36 +151,62 @@ export class ComponentRegistry {
|
|
|
151
151
|
try {
|
|
152
152
|
const fs = await import('fs')
|
|
153
153
|
const path = await import('path')
|
|
154
|
-
|
|
154
|
+
const { startGroup, endGroup, logInGroup, groupSummary } = await import('../../utils/logger/group-logger')
|
|
155
|
+
|
|
155
156
|
if (!fs.existsSync(componentsPath)) {
|
|
156
157
|
console.log(`⚠️ Components path not found: ${componentsPath}`)
|
|
157
158
|
return
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
const files = fs.readdirSync(componentsPath)
|
|
161
|
-
|
|
162
|
+
let discoveredCount = 0
|
|
163
|
+
|
|
164
|
+
startGroup({
|
|
165
|
+
title: 'Live Components Auto-Discovery',
|
|
166
|
+
icon: '🔍',
|
|
167
|
+
color: 'blue',
|
|
168
|
+
collapsed: true
|
|
169
|
+
})
|
|
170
|
+
|
|
162
171
|
for (const file of files) {
|
|
163
172
|
if (file.endsWith('.ts') || file.endsWith('.js')) {
|
|
164
173
|
try {
|
|
165
174
|
const fullPath = path.join(componentsPath, file)
|
|
166
175
|
const module = await import(/* @vite-ignore */ fullPath)
|
|
167
|
-
|
|
176
|
+
|
|
168
177
|
// Look for exported classes that extend LiveComponent
|
|
169
178
|
Object.keys(module).forEach(exportName => {
|
|
170
179
|
const exportedItem = module[exportName]
|
|
171
|
-
if (typeof exportedItem === 'function' &&
|
|
172
|
-
exportedItem.prototype &&
|
|
180
|
+
if (typeof exportedItem === 'function' &&
|
|
181
|
+
exportedItem.prototype &&
|
|
173
182
|
this.isLiveComponentClass(exportedItem)) {
|
|
174
|
-
|
|
183
|
+
|
|
175
184
|
const componentName = exportName.replace(/Component$/, '')
|
|
176
185
|
this.registerComponentClass(componentName, exportedItem)
|
|
186
|
+
logInGroup(`${componentName} (from ${file})`, '📦')
|
|
187
|
+
discoveredCount++
|
|
177
188
|
}
|
|
178
189
|
})
|
|
190
|
+
|
|
191
|
+
// Check for integration hooks (like SystemMonitorIntegration)
|
|
192
|
+
if (module.default && typeof module.default === 'object' && module.default.setupIntegration) {
|
|
193
|
+
logInGroup('Integration hooks found', '🔗')
|
|
194
|
+
}
|
|
179
195
|
} catch (error) {
|
|
180
|
-
|
|
196
|
+
logInGroup(`Failed to load ${file}`, '⚠️')
|
|
181
197
|
}
|
|
182
198
|
}
|
|
183
199
|
}
|
|
200
|
+
|
|
201
|
+
if (discoveredCount > 0) {
|
|
202
|
+
const label = discoveredCount === 1 ? 'component discovered' : 'components discovered'
|
|
203
|
+
groupSummary(discoveredCount, label, '✓')
|
|
204
|
+
} else {
|
|
205
|
+
logInGroup('No components found', '⚠️')
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
endGroup()
|
|
209
|
+
console.log('') // Separator line
|
|
184
210
|
} catch (error) {
|
|
185
211
|
console.error('❌ Auto-discovery failed:', error)
|
|
186
212
|
}
|
|
@@ -180,7 +180,7 @@ export class LiveComponentPerformanceMonitor extends EventEmitter {
|
|
|
180
180
|
})
|
|
181
181
|
|
|
182
182
|
this.performanceObserver.observe({ entryTypes: ['measure', 'mark'] })
|
|
183
|
-
|
|
183
|
+
// Performance observer ready (logged at DEBUG level to keep startup clean)
|
|
184
184
|
} catch (error) {
|
|
185
185
|
console.warn('⚠️ Performance observer not available:', error)
|
|
186
186
|
}
|