create-fluxstack 1.8.1 → 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/.env.example +19 -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/controllers/users.controller.ts +57 -31
- package/app/server/index.ts +5 -2
- package/app/server/live/register-components.ts +18 -7
- package/app/server/routes/env-test.ts +53 -2
- package/app/server/routes/index.ts +1 -8
- package/app/server/routes/users.routes.ts +192 -91
- package/config/fluxstack.config.ts +2 -2
- package/config/plugins.config.ts +22 -1
- package/core/build/flux-plugins-generator.ts +5 -5
- package/core/build/live-components-generator.ts +15 -12
- 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 -193
- 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 +1 -1
- package/core/config/runtime-config.ts +5 -5
- package/core/config/schema.ts +9 -0
- package/core/framework/server.ts +30 -15
- package/core/framework/types.ts +2 -2
- 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 +18 -47
- package/core/plugins/built-in/swagger/index.ts +301 -231
- package/core/plugins/built-in/vite/index.ts +74 -109
- 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 +3 -3
- package/core/plugins/types.ts +147 -5
- 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/utils/logger/startup-banner.ts +7 -33
- package/core/utils/version.ts +6 -6
- package/create-fluxstack.ts +68 -25
- package/package.json +2 -2
- 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 +11 -2
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Generator } from "./index
|
|
2
|
-
import type { GeneratorContext, GeneratorOptions, Template } from "./types
|
|
3
|
-
import { templateEngine } from "./template-engine
|
|
1
|
+
import type { Generator } from "./index"
|
|
2
|
+
import type { GeneratorContext, GeneratorOptions, Template } from "./types"
|
|
3
|
+
import { templateEngine } from "./template-engine"
|
|
4
4
|
|
|
5
5
|
export class RouteGenerator implements Generator {
|
|
6
6
|
name = 'route'
|
|
@@ -54,15 +54,23 @@ export class RouteGenerator implements Generator {
|
|
|
54
54
|
path: 'app/server/routes/{{kebabName}}.routes.ts',
|
|
55
55
|
content: `import { Elysia, t } from 'elysia'
|
|
56
56
|
import { {{pascalName}}Controller } from '../controllers/{{kebabName}}.controller'
|
|
57
|
-
import { errorHandler } from '
|
|
58
|
-
import { logger } from '
|
|
57
|
+
import { errorHandler } from '@/core/utils/errors/middleware'
|
|
58
|
+
import { logger } from '@/core/utils/logger'
|
|
59
59
|
|
|
60
60
|
const controller = new {{pascalName}}Controller()
|
|
61
61
|
|
|
62
62
|
export const {{camelName}}Routes = new Elysia({ prefix: '/api/{{kebabName}}s' })
|
|
63
63
|
.use(errorHandler)
|
|
64
64
|
.onBeforeHandle(({ request }) => {
|
|
65
|
-
|
|
65
|
+
const url = (() => {
|
|
66
|
+
try {
|
|
67
|
+
return new URL(request.url)
|
|
68
|
+
} catch {
|
|
69
|
+
const host = request.headers.get('host') || 'localhost'
|
|
70
|
+
return new URL(request.url, \`http://\${host}\`)
|
|
71
|
+
}
|
|
72
|
+
})()
|
|
73
|
+
logger.request(request.method, url.pathname)
|
|
66
74
|
})
|
|
67
75
|
.get('/', async () => {
|
|
68
76
|
return await controller.getAll()
|
|
@@ -300,16 +308,24 @@ export const {{camelName}}Routes = new Elysia({ prefix: '/api/{{kebabName}}s' })
|
|
|
300
308
|
path: 'app/server/routes/auth.routes.ts',
|
|
301
309
|
content: `import { Elysia, t } from 'elysia'
|
|
302
310
|
import { AuthController } from '../controllers/auth.controller'
|
|
303
|
-
import { errorHandler } from '
|
|
311
|
+
import { errorHandler } from '@/core/utils/errors/middleware'
|
|
304
312
|
import { authMiddleware } from '../middleware/auth.middleware'
|
|
305
|
-
import { logger } from '
|
|
313
|
+
import { logger } from '@/core/utils/logger'
|
|
306
314
|
|
|
307
315
|
const controller = new AuthController()
|
|
308
316
|
|
|
309
317
|
export const authRoutes = new Elysia({ prefix: '/api/auth' })
|
|
310
318
|
.use(errorHandler)
|
|
311
319
|
.onBeforeHandle(({ request }) => {
|
|
312
|
-
|
|
320
|
+
const url = (() => {
|
|
321
|
+
try {
|
|
322
|
+
return new URL(request.url)
|
|
323
|
+
} catch {
|
|
324
|
+
const host = request.headers.get('host') || 'localhost'
|
|
325
|
+
return new URL(request.url, \`http://\${host}\`)
|
|
326
|
+
}
|
|
327
|
+
})()
|
|
328
|
+
logger.request(request.method, url.pathname)
|
|
313
329
|
})
|
|
314
330
|
.post('/register', async ({ body }) => {
|
|
315
331
|
return await controller.register({ body })
|
|
@@ -456,8 +472,8 @@ export const authRoutes = new Elysia({ prefix: '/api/auth' })
|
|
|
456
472
|
{
|
|
457
473
|
path: 'app/server/middleware/auth.middleware.ts',
|
|
458
474
|
content: `import { Context } from 'elysia'
|
|
459
|
-
import { UnauthorizedError } from '
|
|
460
|
-
import { logger } from '
|
|
475
|
+
import { UnauthorizedError } from '@/core/utils/errors'
|
|
476
|
+
import { logger } from '@/core/utils/logger'
|
|
461
477
|
|
|
462
478
|
// JWT verification function (implement based on your JWT library)
|
|
463
479
|
async function verifyJWT(token: string): Promise<any> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Generator } from "./index
|
|
2
|
-
import type { GeneratorContext, GeneratorOptions, Template } from "./types
|
|
3
|
-
import { templateEngine } from "./template-engine
|
|
1
|
+
import type { Generator } from "./index"
|
|
2
|
+
import type { GeneratorContext, GeneratorOptions, Template } from "./types"
|
|
3
|
+
import { templateEngine } from "./template-engine"
|
|
4
4
|
|
|
5
5
|
export class ServiceGenerator implements Generator {
|
|
6
6
|
name = 'service'
|
|
@@ -54,8 +54,8 @@ export class ServiceGenerator implements Generator {
|
|
|
54
54
|
path: 'app/server/services/{{kebabName}}.service.ts',
|
|
55
55
|
content: `import { {{pascalName}}, Create{{pascalName}}, Update{{pascalName}} } from '../schemas/{{kebabName}}.schema'
|
|
56
56
|
import { {{pascalName}}Repository } from '../repositories/{{kebabName}}.repository'
|
|
57
|
-
import { ValidationError, NotFoundError } from '
|
|
58
|
-
import { logger } from '
|
|
57
|
+
import { ValidationError, NotFoundError } from '@/core/utils/errors'
|
|
58
|
+
import { logger } from '@/core/utils/logger'
|
|
59
59
|
|
|
60
60
|
export class {{pascalName}}Service {
|
|
61
61
|
private repository: {{pascalName}}Repository
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GeneratorContext, GeneratorOptions, Template, TemplateFile, GeneratedFile, TemplateProcessor } from "./types
|
|
1
|
+
import type { GeneratorContext, GeneratorOptions, Template, TemplateFile, GeneratedFile, TemplateProcessor } from "./types"
|
|
2
2
|
import { join, dirname } from "path"
|
|
3
3
|
import { mkdir, writeFile, readFile, stat } from "fs/promises"
|
|
4
4
|
import { existsSync } from "fs"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FluxStackConfig } from "../../config/schema"
|
|
2
|
-
import type { Logger } from "
|
|
2
|
+
import type { Logger } from "@/core/utils/logger/index"
|
|
3
3
|
import type { PluginUtils } from "../../plugins/types"
|
|
4
4
|
|
|
5
5
|
export interface GeneratorContext {
|
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,189 +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
|
-
// Ensure backend-only.ts exists
|
|
457
|
-
const { ensureBackendEntry } = await import("../utils/regenerate-files")
|
|
458
|
-
await ensureBackendEntry()
|
|
459
|
-
|
|
460
|
-
// Start backend with Bun watch for hot reload
|
|
461
|
-
const { spawn: spawnBackend } = await import("child_process")
|
|
462
|
-
const backendProcess = spawnBackend("bun", ["--watch", "app/server/backend-only.ts"], {
|
|
463
|
-
stdio: "inherit",
|
|
464
|
-
cwd: process.cwd()
|
|
465
|
-
})
|
|
466
|
-
|
|
467
|
-
// Handle process cleanup
|
|
468
|
-
process.on('SIGINT', () => {
|
|
469
|
-
backendProcess.kill('SIGINT')
|
|
470
|
-
process.exit(0)
|
|
471
|
-
})
|
|
472
|
-
break
|
|
473
|
-
|
|
474
|
-
case "build":
|
|
475
|
-
const config = getConfigSync()
|
|
476
|
-
const builder = new FluxStackBuilder(config)
|
|
477
|
-
await builder.build()
|
|
478
|
-
break
|
|
479
|
-
|
|
480
|
-
case "build:frontend":
|
|
481
|
-
const frontendConfig = getConfigSync()
|
|
482
|
-
const frontendBuilder = new FluxStackBuilder(frontendConfig)
|
|
483
|
-
await frontendBuilder.buildClient()
|
|
484
|
-
break
|
|
485
|
-
|
|
486
|
-
case "build:backend":
|
|
487
|
-
const backendConfig = getConfigSync()
|
|
488
|
-
const backendBuilder = new FluxStackBuilder(backendConfig)
|
|
489
|
-
await backendBuilder.buildServer()
|
|
490
|
-
break
|
|
491
|
-
|
|
492
|
-
case "start":
|
|
493
|
-
console.log("🚀 Starting FluxStack production server...")
|
|
494
|
-
const { join } = await import("path")
|
|
495
|
-
await import(join(process.cwd(), "dist", "index.js"))
|
|
496
|
-
break
|
|
497
|
-
|
|
498
|
-
case "create":
|
|
499
|
-
const projectName = process.argv[3]
|
|
500
|
-
const template = process.argv[4]
|
|
501
|
-
|
|
502
|
-
if (!projectName) {
|
|
503
|
-
console.error("❌ Please provide a project name: flux create my-app")
|
|
504
|
-
console.error()
|
|
505
|
-
console.error("Usage:")
|
|
506
|
-
console.error(" flux create <project-name> [template]")
|
|
507
|
-
console.error()
|
|
508
|
-
console.error("Templates:")
|
|
509
|
-
console.error(" basic Basic FluxStack project (default)")
|
|
510
|
-
console.error(" full Full-featured project with examples")
|
|
511
|
-
process.exit(1)
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// Validate project name
|
|
515
|
-
if (!/^[a-zA-Z0-9-_]+$/.test(projectName)) {
|
|
516
|
-
console.error("❌ Project name can only contain letters, numbers, hyphens, and underscores")
|
|
517
|
-
process.exit(1)
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
try {
|
|
521
|
-
const creator = new ProjectCreator({
|
|
522
|
-
name: projectName,
|
|
523
|
-
template: template as 'basic' | 'full' || 'basic'
|
|
524
|
-
})
|
|
525
|
-
|
|
526
|
-
await creator.create()
|
|
527
|
-
} catch (error) {
|
|
528
|
-
console.error("❌ Failed to create project:", error instanceof Error ? error.message : String(error))
|
|
529
|
-
process.exit(1)
|
|
530
|
-
}
|
|
531
|
-
break
|
|
532
523
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
flux dev Start full-stack development server
|
|
539
|
-
flux frontend Start frontend only (Vite dev server)
|
|
540
|
-
flux backend Start backend only (API server)
|
|
541
|
-
flux build Build both frontend and backend
|
|
542
|
-
flux build:frontend Build frontend only
|
|
543
|
-
flux build:backend Build backend only
|
|
544
|
-
flux start Start production server
|
|
545
|
-
flux create Create new project
|
|
546
|
-
|
|
547
|
-
Examples:
|
|
548
|
-
flux dev # Full-stack development
|
|
549
|
-
flux frontend # Frontend only (port 5173)
|
|
550
|
-
flux backend # Backend only (port 3001)
|
|
551
|
-
flux create my-app # Create new project
|
|
552
|
-
|
|
553
|
-
Alternative commands:
|
|
554
|
-
fluxstack dev # Same as flux dev
|
|
555
|
-
bun run dev:frontend # Direct frontend start
|
|
556
|
-
bun run dev:backend # Direct backend start
|
|
557
|
-
|
|
558
|
-
Environment Variables:
|
|
559
|
-
FRONTEND_PORT=5173 # Frontend port
|
|
560
|
-
BACKEND_PORT=3001 # Backend port
|
|
561
|
-
API_URL=http://localhost:3001 # API URL for frontend
|
|
562
|
-
`)
|
|
563
|
-
}
|
|
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)
|
|
564
529
|
}
|
|
565
530
|
|
|
566
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 {
|
|
@@ -6,11 +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 { clientConfig } from '
|
|
11
|
-
import { serverConfig } from '
|
|
12
|
-
import { monitoringConfig } from '
|
|
13
|
-
import { appConfig } from '
|
|
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'
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Runtime Configuration Builder
|
package/core/config/schema.ts
CHANGED
|
@@ -209,6 +209,15 @@ export interface FluxStackConfig {
|
|
|
209
209
|
auth?: AuthConfig
|
|
210
210
|
email?: EmailConfig
|
|
211
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
|
+
}
|
|
212
221
|
|
|
213
222
|
// Environment-specific overrides
|
|
214
223
|
environments?: {
|