create-fluxstack 1.7.5 → 1.8.3
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/.dockerignore +82 -0
- package/.env.example +19 -0
- package/Dockerfile +70 -0
- package/README.md +6 -3
- package/app/client/SIMPLIFICATION.md +140 -0
- package/app/client/frontend-only.ts +1 -1
- package/app/client/src/App.tsx +148 -283
- package/app/client/src/index.css +5 -20
- package/app/client/src/lib/eden-api.ts +53 -220
- package/app/client/src/main.tsx +2 -3
- package/app/server/app.ts +20 -5
- package/app/server/backend-only.ts +15 -12
- package/app/server/controllers/users.controller.ts +57 -31
- package/app/server/index.ts +86 -96
- package/app/server/live/register-components.ts +18 -7
- package/app/server/routes/env-test.ts +110 -0
- package/app/server/routes/index.ts +1 -8
- package/app/server/routes/users.routes.ts +192 -91
- package/config/app.config.ts +2 -54
- package/config/client.config.ts +95 -0
- package/config/fluxstack.config.ts +2 -2
- package/config/index.ts +57 -22
- package/config/monitoring.config.ts +114 -0
- package/config/plugins.config.ts +80 -0
- package/config/runtime.config.ts +0 -17
- package/config/server.config.ts +50 -30
- package/core/build/bundler.ts +17 -16
- package/core/build/flux-plugins-generator.ts +34 -23
- package/core/build/index.ts +32 -31
- package/core/build/live-components-generator.ts +44 -30
- package/core/build/optimizer.ts +37 -17
- package/core/cli/command-registry.ts +4 -14
- package/core/cli/commands/plugin-deps.ts +8 -8
- package/core/cli/generators/component.ts +3 -3
- package/core/cli/generators/controller.ts +4 -4
- package/core/cli/generators/index.ts +8 -8
- package/core/cli/generators/interactive.ts +4 -4
- package/core/cli/generators/plugin.ts +3 -3
- package/core/cli/generators/prompts.ts +1 -1
- package/core/cli/generators/route.ts +27 -11
- package/core/cli/generators/service.ts +5 -5
- package/core/cli/generators/template-engine.ts +1 -1
- package/core/cli/generators/types.ts +1 -1
- package/core/cli/index.ts +158 -189
- package/core/cli/plugin-discovery.ts +3 -3
- package/core/client/hooks/index.ts +2 -2
- package/core/client/hooks/state-validator.ts +1 -1
- package/core/client/hooks/useAuth.ts +1 -1
- package/core/client/hooks/useChunkedUpload.ts +1 -1
- package/core/client/hooks/useHybridLiveComponent.ts +1 -1
- package/core/client/hooks/useWebSocket.ts +1 -1
- package/core/config/env.ts +5 -1
- package/core/config/runtime-config.ts +12 -10
- package/core/config/schema.ts +33 -2
- package/core/framework/server.ts +30 -14
- package/core/framework/types.ts +2 -2
- package/core/index.ts +31 -23
- package/core/live/ComponentRegistry.ts +1 -1
- package/core/plugins/built-in/live-components/commands/create-live-component.ts +1 -1
- package/core/plugins/built-in/live-components/index.ts +1 -1
- package/core/plugins/built-in/monitoring/index.ts +65 -161
- package/core/plugins/built-in/static/index.ts +75 -277
- package/core/plugins/built-in/swagger/index.ts +301 -231
- package/core/plugins/built-in/vite/index.ts +342 -377
- package/core/plugins/config.ts +2 -2
- package/core/plugins/dependency-manager.ts +2 -2
- package/core/plugins/discovery.ts +1 -1
- package/core/plugins/executor.ts +2 -2
- package/core/plugins/manager.ts +19 -4
- package/core/plugins/module-resolver.ts +1 -1
- package/core/plugins/registry.ts +25 -21
- package/core/plugins/types.ts +147 -5
- package/core/server/backend-entry.ts +51 -0
- package/core/server/framework.ts +2 -2
- package/core/server/live/ComponentRegistry.ts +9 -26
- package/core/server/live/FileUploadManager.ts +1 -1
- package/core/server/live/auto-generated-components.ts +26 -0
- package/core/server/live/websocket-plugin.ts +211 -19
- package/core/server/middleware/errorHandling.ts +1 -1
- package/core/server/middleware/index.ts +4 -4
- package/core/server/plugins/database.ts +1 -2
- package/core/server/plugins/static-files-plugin.ts +259 -231
- package/core/server/plugins/swagger.ts +1 -1
- package/core/server/services/BaseService.ts +1 -1
- package/core/server/services/ServiceContainer.ts +1 -1
- package/core/server/services/index.ts +4 -4
- package/core/server/standalone.ts +16 -1
- package/core/testing/index.ts +1 -1
- package/core/testing/setup.ts +1 -1
- package/core/types/plugin.ts +6 -0
- package/core/utils/build-logger.ts +324 -0
- package/core/utils/config-schema.ts +2 -6
- package/core/utils/helpers.ts +14 -9
- package/core/utils/logger/startup-banner.ts +7 -33
- package/core/utils/regenerate-files.ts +69 -0
- package/core/utils/version.ts +6 -6
- package/create-fluxstack.ts +68 -25
- package/fluxstack.config.ts +138 -252
- package/package.json +3 -18
- package/plugins/crypto-auth/index.ts +52 -47
- package/plugins/crypto-auth/server/AuthMiddleware.ts +1 -1
- package/plugins/crypto-auth/server/middlewares/helpers.ts +16 -1
- package/vitest.config.ts +17 -26
- package/app/client/src/App.css +0 -883
- package/app/client/src/components/ErrorBoundary.tsx +0 -107
- package/app/client/src/components/ErrorDisplay.css +0 -365
- package/app/client/src/components/ErrorDisplay.tsx +0 -258
- package/app/client/src/components/FluxStackConfig.tsx +0 -1321
- package/app/client/src/components/HybridLiveCounter.tsx +0 -140
- package/app/client/src/components/LiveClock.tsx +0 -286
- package/app/client/src/components/MainLayout.tsx +0 -388
- package/app/client/src/components/SidebarNavigation.tsx +0 -391
- package/app/client/src/components/StateDemo.tsx +0 -178
- package/app/client/src/components/SystemMonitor.tsx +0 -1044
- package/app/client/src/components/UserProfile.tsx +0 -809
- package/app/client/src/hooks/useAuth.ts +0 -39
- package/app/client/src/hooks/useNotifications.ts +0 -56
- package/app/client/src/lib/errors.ts +0 -340
- package/app/client/src/lib/hooks/useErrorHandler.ts +0 -258
- package/app/client/src/lib/index.ts +0 -45
- package/app/client/src/pages/ApiDocs.tsx +0 -182
- package/app/client/src/pages/CryptoAuthPage.tsx +0 -394
- package/app/client/src/pages/Demo.tsx +0 -174
- package/app/client/src/pages/HybridLive.tsx +0 -263
- package/app/client/src/pages/Overview.tsx +0 -155
- package/app/client/src/store/README.md +0 -43
- package/app/client/src/store/index.ts +0 -16
- package/app/client/src/store/slices/uiSlice.ts +0 -151
- package/app/client/src/store/slices/userSlice.ts +0 -161
- package/app/client/src/test/README.md +0 -257
- package/app/client/src/test/setup.ts +0 -70
- package/app/client/src/test/types.ts +0 -12
- package/app/server/live/CounterComponent.ts +0 -191
- package/app/server/live/FluxStackConfig.ts +0 -534
- package/app/server/live/SidebarNavigation.ts +0 -157
- package/app/server/live/SystemMonitor.ts +0 -595
- package/app/server/live/SystemMonitorIntegration.ts +0 -151
- package/app/server/live/UserProfileComponent.ts +0 -141
- package/app/server/middleware/auth.ts +0 -136
- package/app/server/middleware/errorHandling.ts +0 -252
- package/app/server/middleware/index.ts +0 -10
- package/app/server/middleware/rateLimit.ts +0 -193
- package/app/server/middleware/requestLogging.ts +0 -215
- package/app/server/middleware/validation.ts +0 -270
- package/app/server/routes/config.ts +0 -145
- package/app/server/routes/crypto-auth-demo.routes.ts +0 -167
- package/app/server/routes/example-with-crypto-auth.routes.ts +0 -235
- package/app/server/routes/exemplo-posts.routes.ts +0 -161
- package/app/server/routes/upload.ts +0 -92
- package/app/server/services/NotificationService.ts +0 -302
- package/app/server/services/UserService.ts +0 -222
- package/app/server/services/index.ts +0 -46
- package/app/server/types/index.ts +0 -1
- package/config/build.config.ts +0 -24
package/core/cli/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
import { FluxStackBuilder } from "
|
|
4
|
-
import { ProjectCreator } from "
|
|
5
|
-
import { getConfigSync } from "
|
|
3
|
+
import { FluxStackBuilder } from "@/core/build"
|
|
4
|
+
import { ProjectCreator } from "@/core/templates/create-project"
|
|
5
|
+
import { getConfigSync } from "@/core/config"
|
|
6
6
|
import { cliRegistry } from "./command-registry"
|
|
7
7
|
import { pluginDiscovery } from "./plugin-discovery"
|
|
8
|
-
import { generateCommand, interactiveGenerateCommand } from "./generators/index
|
|
9
|
-
import { startGroup, endGroup, logBox, logInGroup } from "
|
|
8
|
+
import { generateCommand, interactiveGenerateCommand } from "./generators/index"
|
|
9
|
+
import { startGroup, endGroup, logBox, logInGroup } from "@/core/utils/logger/group-logger"
|
|
10
10
|
|
|
11
11
|
const command = process.argv[2]
|
|
12
12
|
const args = process.argv.slice(3)
|
|
@@ -138,14 +138,14 @@ Examples:
|
|
|
138
138
|
// Grouped startup messages
|
|
139
139
|
startGroup({
|
|
140
140
|
title: 'FluxStack Development Server',
|
|
141
|
-
icon: '
|
|
141
|
+
icon: '',
|
|
142
142
|
color: 'cyan'
|
|
143
143
|
})
|
|
144
144
|
|
|
145
|
-
logInGroup(`
|
|
146
|
-
logInGroup(`
|
|
147
|
-
logInGroup(
|
|
148
|
-
logInGroup('Starting
|
|
145
|
+
logInGroup(`Server: http://localhost:${options.port}`, '')
|
|
146
|
+
logInGroup(`API: http://localhost:${options.port}/api`, '')
|
|
147
|
+
logInGroup(`Swagger: http://localhost:${options.port}/swagger`, '')
|
|
148
|
+
logInGroup('Starting with hot reload...', '')
|
|
149
149
|
|
|
150
150
|
endGroup()
|
|
151
151
|
console.log('') // Separator line
|
|
@@ -325,7 +325,7 @@ Examples:
|
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
// Use the plugin generator
|
|
328
|
-
const { generatorRegistry } = await import('./generators/index
|
|
328
|
+
const { generatorRegistry } = await import('./generators/index')
|
|
329
329
|
const pluginGenerator = generatorRegistry.get('plugin')
|
|
330
330
|
|
|
331
331
|
if (!pluginGenerator) {
|
|
@@ -356,6 +356,148 @@ Examples:
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
})
|
|
359
|
+
|
|
360
|
+
// Frontend command (frontend-only development)
|
|
361
|
+
cliRegistry.register({
|
|
362
|
+
name: 'frontend',
|
|
363
|
+
description: 'Start frontend development server only',
|
|
364
|
+
category: 'Development',
|
|
365
|
+
usage: 'flux frontend [options]',
|
|
366
|
+
examples: [
|
|
367
|
+
'flux frontend # Start Vite dev server on port 5173',
|
|
368
|
+
'flux frontend --port 3000 # Start on custom port'
|
|
369
|
+
],
|
|
370
|
+
options: [
|
|
371
|
+
{
|
|
372
|
+
name: 'port',
|
|
373
|
+
short: 'p',
|
|
374
|
+
description: 'Port for frontend server',
|
|
375
|
+
type: 'number',
|
|
376
|
+
default: 5173
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
handler: async (args, options, context) => {
|
|
380
|
+
console.log("🎨 FluxStack Frontend Development")
|
|
381
|
+
console.log(`🌐 Frontend: http://localhost:${options.port}`)
|
|
382
|
+
console.log("📦 Starting Vite dev server...")
|
|
383
|
+
console.log()
|
|
384
|
+
|
|
385
|
+
const { spawn } = await import("child_process")
|
|
386
|
+
const frontendProcess = spawn("vite", ["--config", "vite.config.ts", "--port", options.port.toString()], {
|
|
387
|
+
stdio: "inherit",
|
|
388
|
+
cwd: process.cwd()
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
process.on('SIGINT', () => {
|
|
392
|
+
frontendProcess.kill('SIGINT')
|
|
393
|
+
process.exit(0)
|
|
394
|
+
})
|
|
395
|
+
|
|
396
|
+
return new Promise((resolve) => {
|
|
397
|
+
frontendProcess.on('exit', resolve)
|
|
398
|
+
})
|
|
399
|
+
}
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
// Backend command (backend-only development)
|
|
403
|
+
cliRegistry.register({
|
|
404
|
+
name: 'backend',
|
|
405
|
+
description: 'Start backend development server only',
|
|
406
|
+
category: 'Development',
|
|
407
|
+
usage: 'flux backend [options]',
|
|
408
|
+
examples: [
|
|
409
|
+
'flux backend # Start backend on port 3001',
|
|
410
|
+
'flux backend --port 4000 # Start on custom port'
|
|
411
|
+
],
|
|
412
|
+
options: [
|
|
413
|
+
{
|
|
414
|
+
name: 'port',
|
|
415
|
+
short: 'p',
|
|
416
|
+
description: 'Port for backend server',
|
|
417
|
+
type: 'number',
|
|
418
|
+
default: 3001
|
|
419
|
+
}
|
|
420
|
+
],
|
|
421
|
+
handler: async (args, options, context) => {
|
|
422
|
+
console.log("⚡ FluxStack Backend Development")
|
|
423
|
+
console.log(`🚀 API Server: http://localhost:${options.port}`)
|
|
424
|
+
console.log("📦 Starting backend with hot reload...")
|
|
425
|
+
console.log()
|
|
426
|
+
|
|
427
|
+
// Ensure backend-only.ts exists
|
|
428
|
+
const { ensureBackendEntry } = await import("../utils/regenerate-files")
|
|
429
|
+
await ensureBackendEntry()
|
|
430
|
+
|
|
431
|
+
// Start backend with Bun watch for hot reload
|
|
432
|
+
const { spawn } = await import("child_process")
|
|
433
|
+
const backendProcess = spawn("bun", ["--watch", "app/server/backend-only.ts"], {
|
|
434
|
+
stdio: "inherit",
|
|
435
|
+
cwd: process.cwd(),
|
|
436
|
+
env: {
|
|
437
|
+
...process.env,
|
|
438
|
+
BACKEND_PORT: options.port.toString()
|
|
439
|
+
}
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
// Handle process cleanup
|
|
443
|
+
process.on('SIGINT', () => {
|
|
444
|
+
backendProcess.kill('SIGINT')
|
|
445
|
+
process.exit(0)
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
return new Promise((resolve) => {
|
|
449
|
+
backendProcess.on('exit', resolve)
|
|
450
|
+
})
|
|
451
|
+
}
|
|
452
|
+
})
|
|
453
|
+
|
|
454
|
+
// Start command (production server)
|
|
455
|
+
cliRegistry.register({
|
|
456
|
+
name: 'start',
|
|
457
|
+
description: 'Start production server',
|
|
458
|
+
category: 'Production',
|
|
459
|
+
usage: 'flux start',
|
|
460
|
+
examples: [
|
|
461
|
+
'flux start # Start production server from dist/'
|
|
462
|
+
],
|
|
463
|
+
handler: async (args, options, context) => {
|
|
464
|
+
console.log("🚀 Starting FluxStack production server...")
|
|
465
|
+
const { join } = await import("path")
|
|
466
|
+
await import(join(process.cwd(), "dist", "index.js"))
|
|
467
|
+
}
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
// Build:frontend command (shortcut)
|
|
471
|
+
cliRegistry.register({
|
|
472
|
+
name: 'build:frontend',
|
|
473
|
+
description: 'Build frontend only (shortcut for build --frontend-only)',
|
|
474
|
+
category: 'Build',
|
|
475
|
+
usage: 'flux build:frontend',
|
|
476
|
+
examples: [
|
|
477
|
+
'flux build:frontend # Build only frontend'
|
|
478
|
+
],
|
|
479
|
+
handler: async (args, options, context) => {
|
|
480
|
+
const config = getConfigSync()
|
|
481
|
+
const builder = new FluxStackBuilder(config)
|
|
482
|
+
await builder.buildClient()
|
|
483
|
+
}
|
|
484
|
+
})
|
|
485
|
+
|
|
486
|
+
// Build:backend command (shortcut)
|
|
487
|
+
cliRegistry.register({
|
|
488
|
+
name: 'build:backend',
|
|
489
|
+
description: 'Build backend only (shortcut for build --backend-only)',
|
|
490
|
+
category: 'Build',
|
|
491
|
+
usage: 'flux build:backend',
|
|
492
|
+
examples: [
|
|
493
|
+
'flux build:backend # Build only backend'
|
|
494
|
+
],
|
|
495
|
+
handler: async (args, options, context) => {
|
|
496
|
+
const config = getConfigSync()
|
|
497
|
+
const builder = new FluxStackBuilder(config)
|
|
498
|
+
await builder.buildServer()
|
|
499
|
+
}
|
|
500
|
+
})
|
|
359
501
|
}
|
|
360
502
|
|
|
361
503
|
// Main CLI logic
|
|
@@ -378,185 +520,12 @@ async function main() {
|
|
|
378
520
|
process.exit(exitCode)
|
|
379
521
|
return
|
|
380
522
|
}
|
|
381
|
-
|
|
382
|
-
// Fallback to legacy command handling for backward compatibility
|
|
383
|
-
await handleLegacyCommands()
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// Legacy command handling for backward compatibility
|
|
387
|
-
async function handleLegacyCommands() {
|
|
388
|
-
switch (command) {
|
|
389
|
-
case "dev":
|
|
390
|
-
// Grouped startup messages
|
|
391
|
-
startGroup({
|
|
392
|
-
title: 'FluxStack Development Server',
|
|
393
|
-
icon: '⚡',
|
|
394
|
-
color: 'cyan'
|
|
395
|
-
})
|
|
396
|
-
|
|
397
|
-
logInGroup('Frontend: http://localhost:5173', '🌐')
|
|
398
|
-
logInGroup('Backend: http://localhost:3000', '🚀')
|
|
399
|
-
logInGroup('Backend inicia Vite programaticamente', '🔄')
|
|
400
|
-
logInGroup('Starting backend server...', '📦')
|
|
401
|
-
|
|
402
|
-
endGroup()
|
|
403
|
-
console.log('') // Separator line
|
|
404
|
-
|
|
405
|
-
// Start only backend - it will start Vite programmatically
|
|
406
|
-
const { spawn } = await import("child_process")
|
|
407
|
-
const devProcess = spawn("bun", ["--watch", "app/server/index.ts"], {
|
|
408
|
-
stdio: "inherit",
|
|
409
|
-
cwd: process.cwd()
|
|
410
|
-
})
|
|
411
|
-
|
|
412
|
-
// Handle process cleanup
|
|
413
|
-
process.on('SIGINT', () => {
|
|
414
|
-
console.log('\n🛑 Shutting down gracefully...')
|
|
415
|
-
devProcess.kill('SIGTERM')
|
|
416
|
-
setTimeout(() => {
|
|
417
|
-
devProcess.kill('SIGKILL')
|
|
418
|
-
process.exit(0)
|
|
419
|
-
}, 5000)
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
devProcess.on('close', (code) => {
|
|
423
|
-
process.exit(code || 0)
|
|
424
|
-
})
|
|
425
|
-
|
|
426
|
-
// Keep the CLI running until the child process exits
|
|
427
|
-
await new Promise((resolve) => {
|
|
428
|
-
devProcess.on('exit', resolve)
|
|
429
|
-
})
|
|
430
|
-
break
|
|
431
|
-
|
|
432
|
-
case "frontend":
|
|
433
|
-
console.log("🎨 FluxStack Frontend Development")
|
|
434
|
-
console.log("🌐 Frontend: http://localhost:5173")
|
|
435
|
-
console.log("📦 Starting Vite dev server...")
|
|
436
|
-
console.log()
|
|
437
|
-
|
|
438
|
-
const { spawn: spawnFrontend } = await import("child_process")
|
|
439
|
-
const frontendProcess = spawnFrontend("vite", ["--config", "vite.config.ts"], {
|
|
440
|
-
stdio: "inherit",
|
|
441
|
-
cwd: process.cwd()
|
|
442
|
-
})
|
|
443
|
-
|
|
444
|
-
process.on('SIGINT', () => {
|
|
445
|
-
frontendProcess.kill('SIGINT')
|
|
446
|
-
process.exit(0)
|
|
447
|
-
})
|
|
448
|
-
break
|
|
449
|
-
|
|
450
|
-
case "backend":
|
|
451
|
-
console.log("⚡ FluxStack Backend Development")
|
|
452
|
-
console.log("🚀 API Server: http://localhost:3001")
|
|
453
|
-
console.log("📦 Starting backend with hot reload...")
|
|
454
|
-
console.log()
|
|
455
|
-
|
|
456
|
-
// Start backend with Bun watch for hot reload
|
|
457
|
-
const { spawn: spawnBackend } = await import("child_process")
|
|
458
|
-
const backendProcess = spawnBackend("bun", ["--watch", "app/server/backend-only.ts"], {
|
|
459
|
-
stdio: "inherit",
|
|
460
|
-
cwd: process.cwd()
|
|
461
|
-
})
|
|
462
|
-
|
|
463
|
-
// Handle process cleanup
|
|
464
|
-
process.on('SIGINT', () => {
|
|
465
|
-
backendProcess.kill('SIGINT')
|
|
466
|
-
process.exit(0)
|
|
467
|
-
})
|
|
468
|
-
break
|
|
469
|
-
|
|
470
|
-
case "build":
|
|
471
|
-
const config = getConfigSync()
|
|
472
|
-
const builder = new FluxStackBuilder(config)
|
|
473
|
-
await builder.build()
|
|
474
|
-
break
|
|
475
|
-
|
|
476
|
-
case "build:frontend":
|
|
477
|
-
const frontendConfig = getConfigSync()
|
|
478
|
-
const frontendBuilder = new FluxStackBuilder(frontendConfig)
|
|
479
|
-
await frontendBuilder.buildClient()
|
|
480
|
-
break
|
|
481
|
-
|
|
482
|
-
case "build:backend":
|
|
483
|
-
const backendConfig = getConfigSync()
|
|
484
|
-
const backendBuilder = new FluxStackBuilder(backendConfig)
|
|
485
|
-
await backendBuilder.buildServer()
|
|
486
|
-
break
|
|
487
|
-
|
|
488
|
-
case "start":
|
|
489
|
-
console.log("🚀 Starting FluxStack production server...")
|
|
490
|
-
const { join } = await import("path")
|
|
491
|
-
await import(join(process.cwd(), "dist", "index.js"))
|
|
492
|
-
break
|
|
493
|
-
|
|
494
|
-
case "create":
|
|
495
|
-
const projectName = process.argv[3]
|
|
496
|
-
const template = process.argv[4]
|
|
497
|
-
|
|
498
|
-
if (!projectName) {
|
|
499
|
-
console.error("❌ Please provide a project name: flux create my-app")
|
|
500
|
-
console.error()
|
|
501
|
-
console.error("Usage:")
|
|
502
|
-
console.error(" flux create <project-name> [template]")
|
|
503
|
-
console.error()
|
|
504
|
-
console.error("Templates:")
|
|
505
|
-
console.error(" basic Basic FluxStack project (default)")
|
|
506
|
-
console.error(" full Full-featured project with examples")
|
|
507
|
-
process.exit(1)
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// Validate project name
|
|
511
|
-
if (!/^[a-zA-Z0-9-_]+$/.test(projectName)) {
|
|
512
|
-
console.error("❌ Project name can only contain letters, numbers, hyphens, and underscores")
|
|
513
|
-
process.exit(1)
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
try {
|
|
517
|
-
const creator = new ProjectCreator({
|
|
518
|
-
name: projectName,
|
|
519
|
-
template: template as 'basic' | 'full' || 'basic'
|
|
520
|
-
})
|
|
521
|
-
|
|
522
|
-
await creator.create()
|
|
523
|
-
} catch (error) {
|
|
524
|
-
console.error("❌ Failed to create project:", error instanceof Error ? error.message : String(error))
|
|
525
|
-
process.exit(1)
|
|
526
|
-
}
|
|
527
|
-
break
|
|
528
523
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
flux dev Start full-stack development server
|
|
535
|
-
flux frontend Start frontend only (Vite dev server)
|
|
536
|
-
flux backend Start backend only (API server)
|
|
537
|
-
flux build Build both frontend and backend
|
|
538
|
-
flux build:frontend Build frontend only
|
|
539
|
-
flux build:backend Build backend only
|
|
540
|
-
flux start Start production server
|
|
541
|
-
flux create Create new project
|
|
542
|
-
|
|
543
|
-
Examples:
|
|
544
|
-
flux dev # Full-stack development
|
|
545
|
-
flux frontend # Frontend only (port 5173)
|
|
546
|
-
flux backend # Backend only (port 3001)
|
|
547
|
-
flux create my-app # Create new project
|
|
548
|
-
|
|
549
|
-
Alternative commands:
|
|
550
|
-
fluxstack dev # Same as flux dev
|
|
551
|
-
bun run dev:frontend # Direct frontend start
|
|
552
|
-
bun run dev:backend # Direct backend start
|
|
553
|
-
|
|
554
|
-
Environment Variables:
|
|
555
|
-
FRONTEND_PORT=5173 # Frontend port
|
|
556
|
-
BACKEND_PORT=3001 # Backend port
|
|
557
|
-
API_URL=http://localhost:3001 # API URL for frontend
|
|
558
|
-
`)
|
|
559
|
-
}
|
|
524
|
+
// Command not found - show error and help
|
|
525
|
+
console.error(`❌ Unknown command: ${command}`)
|
|
526
|
+
console.error()
|
|
527
|
+
await cliRegistry.execute('help', args)
|
|
528
|
+
process.exit(1)
|
|
560
529
|
}
|
|
561
530
|
|
|
562
531
|
// Run main CLI
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync } from 'fs'
|
|
2
2
|
import { join } from 'path'
|
|
3
|
-
import type { FluxStack } from '
|
|
3
|
+
import type { FluxStack } from '@/core/plugins/types'
|
|
4
4
|
import { cliRegistry } from './command-registry'
|
|
5
|
-
import { logger } from '
|
|
5
|
+
import { logger } from '@/core/utils/logger'
|
|
6
6
|
|
|
7
7
|
export class CliPluginDiscovery {
|
|
8
8
|
private loadedPlugins = new Set<string>()
|
|
@@ -110,7 +110,7 @@ export class CliPluginDiscovery {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
private registerPluginCommands(plugin: Plugin): void {
|
|
113
|
+
private registerPluginCommands(plugin: FluxStack.Plugin): void {
|
|
114
114
|
if (!plugin.commands || this.loadedPlugins.has(plugin.name)) {
|
|
115
115
|
return
|
|
116
116
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 🔥 WebSocket Hook for Live Components
|
|
2
2
|
|
|
3
3
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
4
|
-
import type { WebSocketMessage, WebSocketResponse } from '
|
|
4
|
+
import type { WebSocketMessage, WebSocketResponse } from '@/core/types/types'
|
|
5
5
|
|
|
6
6
|
// Re-export types for easier importing
|
|
7
7
|
export type { WebSocketMessage, WebSocketResponse }
|
package/core/config/env.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Handles environment variable processing and precedence
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { env, helpers } from '
|
|
6
|
+
import { env, helpers } from '@/core/utils/env'
|
|
7
7
|
import type { FluxStackConfig, LogLevel, BuildTarget, LogFormat } from './schema'
|
|
8
8
|
|
|
9
9
|
export interface EnvironmentInfo {
|
|
@@ -417,6 +417,8 @@ export function getEnvironmentRecommendations(environment: string): Partial<Flux
|
|
|
417
417
|
target: 'bun' as const,
|
|
418
418
|
outDir: 'dist',
|
|
419
419
|
clean: true,
|
|
420
|
+
minify: false,
|
|
421
|
+
treeshake: false,
|
|
420
422
|
optimization: {
|
|
421
423
|
minify: false,
|
|
422
424
|
compress: false,
|
|
@@ -459,6 +461,8 @@ export function getEnvironmentRecommendations(environment: string): Partial<Flux
|
|
|
459
461
|
target: 'bun' as const,
|
|
460
462
|
outDir: 'dist',
|
|
461
463
|
clean: true,
|
|
464
|
+
minify: true,
|
|
465
|
+
treeshake: true,
|
|
462
466
|
optimization: {
|
|
463
467
|
minify: true,
|
|
464
468
|
compress: true,
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
import { env, createNamespace } from '../utils/env'
|
|
7
7
|
import type { FluxStackConfig } from './schema'
|
|
8
8
|
import { defaultFluxStackConfig } from './schema'
|
|
9
|
-
import { loggerConfig } from '
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { loggerConfig } from '@/config/logger.config'
|
|
10
|
+
import { clientConfig } from '@/config/client.config'
|
|
11
|
+
import { serverConfig } from '@/config/server.config'
|
|
12
|
+
import { monitoringConfig } from '@/config/monitoring.config'
|
|
13
|
+
import { appConfig } from '@/config/app.config'
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Runtime Configuration Builder
|
|
@@ -163,7 +165,7 @@ export const runtimeConfig = {
|
|
|
163
165
|
.override('logging.format', 'json')
|
|
164
166
|
.override('build.optimization.minify', true)
|
|
165
167
|
.override('build.sourceMaps', false)
|
|
166
|
-
.override('monitoring.enabled',
|
|
168
|
+
.override('monitoring.enabled', monitoringConfig.monitoring.enabled)
|
|
167
169
|
.build()
|
|
168
170
|
},
|
|
169
171
|
|
|
@@ -304,14 +306,14 @@ export const configHelpers = {
|
|
|
304
306
|
return {
|
|
305
307
|
port: env.VITE_PORT,
|
|
306
308
|
proxy: {
|
|
307
|
-
target:
|
|
308
|
-
changeOrigin:
|
|
309
|
+
target: clientConfig.proxy.target,
|
|
310
|
+
changeOrigin: clientConfig.proxy.changeOrigin
|
|
309
311
|
},
|
|
310
312
|
build: {
|
|
311
|
-
outDir:
|
|
312
|
-
sourceMaps:
|
|
313
|
-
minify:
|
|
314
|
-
target:
|
|
313
|
+
outDir: clientConfig.build.outDir,
|
|
314
|
+
sourceMaps: clientConfig.build.sourceMaps,
|
|
315
|
+
minify: clientConfig.build.minify,
|
|
316
|
+
target: clientConfig.build.target
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
319
|
}
|
package/core/config/schema.ts
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Enhanced Configuration Schema for FluxStack
|
|
3
|
-
*
|
|
2
|
+
* ⚠️ DEPRECATED - Enhanced Configuration Schema for FluxStack
|
|
3
|
+
*
|
|
4
|
+
* This file is DEPRECATED and maintained only for backward compatibility.
|
|
5
|
+
* Please use the new modular config system from /config instead:
|
|
6
|
+
*
|
|
7
|
+
* ✅ NEW WAY:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { appConfig, serverConfig, clientConfig } from '@/config'
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* ❌ OLD WAY (DEPRECATED):
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { FluxStackConfig } from '@/core/config/schema'
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The modular system provides:
|
|
18
|
+
* - Better organization (separated by domain)
|
|
19
|
+
* - Automatic validation
|
|
20
|
+
* - Type inference
|
|
21
|
+
* - Laravel-style declarative schemas
|
|
22
|
+
*
|
|
23
|
+
* This file will be removed in a future version.
|
|
24
|
+
* @deprecated Use /config modular system instead
|
|
4
25
|
*/
|
|
5
26
|
|
|
27
|
+
|
|
6
28
|
export type LogLevel = 'debug' | 'info' | 'warn' | 'error'
|
|
7
29
|
export type BuildTarget = 'bun' | 'node' | 'docker'
|
|
8
30
|
export type LogFormat = 'json' | 'pretty'
|
|
@@ -187,6 +209,15 @@ export interface FluxStackConfig {
|
|
|
187
209
|
auth?: AuthConfig
|
|
188
210
|
email?: EmailConfig
|
|
189
211
|
storage?: StorageConfig
|
|
212
|
+
staticFiles?: {
|
|
213
|
+
publicDir?: string
|
|
214
|
+
uploadsDir?: string
|
|
215
|
+
cacheMaxAge?: number
|
|
216
|
+
enableUploads?: boolean
|
|
217
|
+
enablePublic?: boolean
|
|
218
|
+
publicRoute?: string
|
|
219
|
+
uploadsRoute?: string
|
|
220
|
+
}
|
|
190
221
|
|
|
191
222
|
// Environment-specific overrides
|
|
192
223
|
environments?: {
|
package/core/framework/server.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Elysia } from "elysia"
|
|
2
|
-
import type { FluxStackConfig, FluxStackContext } from "
|
|
3
|
-
import type { FluxStack, PluginContext, PluginUtils } from "
|
|
4
|
-
import { PluginRegistry } from "
|
|
5
|
-
import { PluginManager } from "
|
|
6
|
-
import { getConfigSync, getEnvironmentInfo } from "
|
|
7
|
-
import { logger } from "
|
|
8
|
-
import { displayStartupBanner, type StartupInfo } from "
|
|
9
|
-
import { createErrorHandler } from "
|
|
10
|
-
import { createTimer, formatBytes, isProduction, isDevelopment } from "
|
|
2
|
+
import type { FluxStackConfig, FluxStackContext } from "@/core/types"
|
|
3
|
+
import type { FluxStack, PluginContext, PluginUtils } from "@/core/plugins/types"
|
|
4
|
+
import { PluginRegistry } from "@/core/plugins/registry"
|
|
5
|
+
import { PluginManager } from "@/core/plugins/manager"
|
|
6
|
+
import { getConfigSync, getEnvironmentInfo } from "@/core/config"
|
|
7
|
+
import { logger } from "@/core/utils/logger"
|
|
8
|
+
import { displayStartupBanner, type StartupInfo } from "@/core/utils/logger/startup-banner"
|
|
9
|
+
import { createErrorHandler } from "@/core/utils/errors/handlers"
|
|
10
|
+
import { createTimer, formatBytes, isProduction, isDevelopment } from "@/core/utils/helpers"
|
|
11
|
+
import type { Plugin } from "@/core/plugins"
|
|
11
12
|
|
|
12
13
|
export class FluxStackFramework {
|
|
13
14
|
private app: Elysia
|
|
@@ -18,6 +19,21 @@ export class FluxStackFramework {
|
|
|
18
19
|
private isStarted: boolean = false
|
|
19
20
|
private requestTimings: Map<string, number> = new Map()
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Helper to safely parse request.url which might be relative or absolute
|
|
24
|
+
*/
|
|
25
|
+
private parseRequestURL(request: Request): URL {
|
|
26
|
+
try {
|
|
27
|
+
// Try parsing as absolute URL first
|
|
28
|
+
return new URL(request.url)
|
|
29
|
+
} catch {
|
|
30
|
+
// If relative, use host from headers or default to localhost
|
|
31
|
+
const host = request.headers.get('host') || 'localhost'
|
|
32
|
+
const protocol = request.headers.get('x-forwarded-proto') || 'http'
|
|
33
|
+
return new URL(request.url, `${protocol}://${host}`)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
21
37
|
constructor(config?: Partial<FluxStackConfig>) {
|
|
22
38
|
// Load the full configuration
|
|
23
39
|
const fullConfig = config ? { ...getConfigSync(), ...config } : getConfigSync()
|
|
@@ -159,7 +175,7 @@ export class FluxStackFramework {
|
|
|
159
175
|
private setupHeadHandler() {
|
|
160
176
|
// Global HEAD handler to prevent Elysia's automatic HEAD conversion bug
|
|
161
177
|
this.app.head("*", ({ request, set }) => {
|
|
162
|
-
const url =
|
|
178
|
+
const url = this.parseRequestURL(request)
|
|
163
179
|
|
|
164
180
|
// Handle API routes
|
|
165
181
|
if (url.pathname.startsWith(this.context.config.server.apiPrefix)) {
|
|
@@ -233,7 +249,7 @@ export class FluxStackFramework {
|
|
|
233
249
|
// Setup onRequest hook and onBeforeRoute hook
|
|
234
250
|
this.app.onRequest(async ({ request, set }) => {
|
|
235
251
|
const startTime = Date.now()
|
|
236
|
-
const url =
|
|
252
|
+
const url = this.parseRequestURL(request)
|
|
237
253
|
|
|
238
254
|
// Store start time for duration calculation (using request URL as key)
|
|
239
255
|
const requestKey = `${request.method}-${url.pathname}-${startTime}`
|
|
@@ -274,7 +290,7 @@ export class FluxStackFramework {
|
|
|
274
290
|
|
|
275
291
|
// Setup onResponse hook
|
|
276
292
|
this.app.onAfterHandle(async ({ request, response, set }) => {
|
|
277
|
-
const url =
|
|
293
|
+
const url = this.parseRequestURL(request)
|
|
278
294
|
|
|
279
295
|
// Retrieve start time using the timing key
|
|
280
296
|
const requestKey = set.headers['x-request-timing-key']
|
|
@@ -328,7 +344,7 @@ export class FluxStackFramework {
|
|
|
328
344
|
|
|
329
345
|
this.app.onError(async ({ error, request, path, set }) => {
|
|
330
346
|
const startTime = Date.now()
|
|
331
|
-
const url =
|
|
347
|
+
const url = this.parseRequestURL(request)
|
|
332
348
|
|
|
333
349
|
const errorContext = {
|
|
334
350
|
request,
|
|
@@ -447,7 +463,7 @@ export class FluxStackFramework {
|
|
|
447
463
|
|
|
448
464
|
private async handleViteProxy(errorContext: any): Promise<Response> {
|
|
449
465
|
const vitePort = this.context.config.client?.port || 5173
|
|
450
|
-
const url =
|
|
466
|
+
const url = this.parseRequestURL(errorContext.request)
|
|
451
467
|
|
|
452
468
|
try {
|
|
453
469
|
const viteUrl = `http://localhost:${vitePort}${url.pathname}${url.search}`
|