create-fluxstack 1.0.1 → 1.0.2

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.
Files changed (100) hide show
  1. package/create-fluxstack.ts +2 -3
  2. package/package.json +1 -1
  3. package/.env +0 -30
  4. package/LICENSE +0 -21
  5. package/app/client/README.md +0 -69
  6. package/app/client/frontend-only.ts +0 -12
  7. package/app/client/index.html +0 -13
  8. package/app/client/public/vite.svg +0 -1
  9. package/app/client/src/App.css +0 -883
  10. package/app/client/src/App.tsx +0 -669
  11. package/app/client/src/assets/react.svg +0 -1
  12. package/app/client/src/components/TestPage.tsx +0 -453
  13. package/app/client/src/index.css +0 -51
  14. package/app/client/src/lib/eden-api.ts +0 -110
  15. package/app/client/src/main.tsx +0 -10
  16. package/app/client/src/vite-env.d.ts +0 -1
  17. package/app/client/tsconfig.app.json +0 -43
  18. package/app/client/tsconfig.json +0 -7
  19. package/app/client/tsconfig.node.json +0 -25
  20. package/app/server/app.ts +0 -10
  21. package/app/server/backend-only.ts +0 -15
  22. package/app/server/controllers/users.controller.ts +0 -69
  23. package/app/server/index.ts +0 -104
  24. package/app/server/routes/index.ts +0 -25
  25. package/app/server/routes/users.routes.ts +0 -121
  26. package/app/server/types/index.ts +0 -1
  27. package/app/shared/types/index.ts +0 -18
  28. package/bun.lock +0 -1053
  29. package/core/__tests__/integration.test.ts +0 -227
  30. package/core/build/index.ts +0 -186
  31. package/core/cli/command-registry.ts +0 -334
  32. package/core/cli/index.ts +0 -394
  33. package/core/cli/plugin-discovery.ts +0 -200
  34. package/core/client/standalone.ts +0 -57
  35. package/core/config/__tests__/config-loader.test.ts +0 -591
  36. package/core/config/__tests__/config-merger.test.ts +0 -657
  37. package/core/config/__tests__/env-converter.test.ts +0 -372
  38. package/core/config/__tests__/env-processor.test.ts +0 -431
  39. package/core/config/__tests__/env.test.ts +0 -452
  40. package/core/config/__tests__/integration.test.ts +0 -418
  41. package/core/config/__tests__/loader.test.ts +0 -331
  42. package/core/config/__tests__/schema.test.ts +0 -129
  43. package/core/config/__tests__/validator.test.ts +0 -318
  44. package/core/config/env-dynamic.ts +0 -326
  45. package/core/config/env.ts +0 -597
  46. package/core/config/index.ts +0 -317
  47. package/core/config/loader.ts +0 -546
  48. package/core/config/runtime-config.ts +0 -322
  49. package/core/config/schema.ts +0 -694
  50. package/core/config/validator.ts +0 -540
  51. package/core/framework/__tests__/server.test.ts +0 -233
  52. package/core/framework/client.ts +0 -132
  53. package/core/framework/index.ts +0 -8
  54. package/core/framework/server.ts +0 -501
  55. package/core/framework/types.ts +0 -63
  56. package/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
  57. package/core/plugins/__tests__/manager.test.ts +0 -398
  58. package/core/plugins/__tests__/monitoring.test.ts +0 -401
  59. package/core/plugins/__tests__/registry.test.ts +0 -335
  60. package/core/plugins/built-in/index.ts +0 -142
  61. package/core/plugins/built-in/logger/index.ts +0 -180
  62. package/core/plugins/built-in/monitoring/README.md +0 -193
  63. package/core/plugins/built-in/monitoring/index.ts +0 -912
  64. package/core/plugins/built-in/static/index.ts +0 -289
  65. package/core/plugins/built-in/swagger/index.ts +0 -229
  66. package/core/plugins/built-in/vite/index.ts +0 -316
  67. package/core/plugins/config.ts +0 -348
  68. package/core/plugins/discovery.ts +0 -350
  69. package/core/plugins/executor.ts +0 -351
  70. package/core/plugins/index.ts +0 -195
  71. package/core/plugins/manager.ts +0 -583
  72. package/core/plugins/registry.ts +0 -424
  73. package/core/plugins/types.ts +0 -254
  74. package/core/server/framework.ts +0 -123
  75. package/core/server/index.ts +0 -8
  76. package/core/server/plugins/database.ts +0 -182
  77. package/core/server/plugins/logger.ts +0 -47
  78. package/core/server/plugins/swagger.ts +0 -34
  79. package/core/server/standalone.ts +0 -91
  80. package/core/templates/create-project.ts +0 -455
  81. package/core/types/api.ts +0 -169
  82. package/core/types/build.ts +0 -174
  83. package/core/types/config.ts +0 -68
  84. package/core/types/index.ts +0 -127
  85. package/core/types/plugin.ts +0 -94
  86. package/core/utils/__tests__/errors.test.ts +0 -139
  87. package/core/utils/__tests__/helpers.test.ts +0 -297
  88. package/core/utils/__tests__/logger.test.ts +0 -141
  89. package/core/utils/env-runtime-v2.ts +0 -232
  90. package/core/utils/env-runtime.ts +0 -252
  91. package/core/utils/errors/codes.ts +0 -115
  92. package/core/utils/errors/handlers.ts +0 -63
  93. package/core/utils/errors/index.ts +0 -81
  94. package/core/utils/helpers.ts +0 -180
  95. package/core/utils/index.ts +0 -18
  96. package/core/utils/logger/index.ts +0 -161
  97. package/core/utils/logger.ts +0 -106
  98. package/core/utils/monitoring/index.ts +0 -212
  99. package/tsconfig.json +0 -51
  100. package/vite.config.ts +0 -42
@@ -1,227 +0,0 @@
1
- /**
2
- * Integration Tests for Core Framework Restructuring
3
- * Tests the complete integration of all restructured components
4
- */
5
-
6
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
7
- import { FluxStackFramework } from '../framework/server'
8
- import { PluginRegistry } from '../plugins/registry'
9
- import { logger } from '../utils/logger'
10
- import type { Plugin } from '../plugins/types'
11
-
12
- // Set test environment
13
- process.env.NODE_ENV = 'test'
14
-
15
- describe('Core Framework Integration', () => {
16
- let framework: FluxStackFramework
17
- let consoleSpy: any
18
-
19
- beforeEach(() => {
20
- framework = new FluxStackFramework()
21
- consoleSpy = {
22
- debug: vi.spyOn(console, 'debug').mockImplementation(() => {}),
23
- info: vi.spyOn(console, 'info').mockImplementation(() => {}),
24
- warn: vi.spyOn(console, 'warn').mockImplementation(() => {}),
25
- error: vi.spyOn(console, 'error').mockImplementation(() => {})
26
- }
27
- })
28
-
29
- afterEach(() => {
30
- vi.clearAllMocks()
31
- vi.restoreAllMocks()
32
- })
33
-
34
- describe('Framework Initialization', () => {
35
- it('should initialize all core components', () => {
36
- expect(framework.getContext()).toBeDefined()
37
- expect(framework.getApp()).toBeDefined()
38
- expect(framework.getPluginRegistry()).toBeInstanceOf(PluginRegistry)
39
- })
40
-
41
- it('should have proper directory structure exports', async () => {
42
- // Test that all new exports are available
43
- const { FluxStackFramework: ServerFramework } = await import('../framework/server')
44
- const { FluxStackClient } = await import('../framework/client')
45
- const { PluginRegistry: Registry } = await import('../plugins/registry')
46
- const { logger: Logger } = await import('../utils/logger')
47
- const { FluxStackError } = await import('../utils/errors')
48
-
49
- expect(ServerFramework).toBeDefined()
50
- expect(FluxStackClient).toBeDefined()
51
- expect(Registry).toBeDefined()
52
- expect(Logger).toBeDefined()
53
- expect(FluxStackError).toBeDefined()
54
- })
55
- })
56
-
57
- describe('Plugin System Integration', () => {
58
- it('should register and load built-in plugins', async () => {
59
- const mockPlugin: Plugin = {
60
- name: 'test-integration-plugin',
61
- setup: vi.fn(),
62
- onServerStart: vi.fn(),
63
- onServerStop: vi.fn()
64
- }
65
-
66
- framework.use(mockPlugin)
67
-
68
- expect(framework.getPluginRegistry().get('test-integration-plugin')).toBe(mockPlugin)
69
-
70
- await framework.start()
71
-
72
- expect(mockPlugin.setup).toHaveBeenCalled()
73
- expect(mockPlugin.onServerStart).toHaveBeenCalled()
74
-
75
- await framework.stop()
76
-
77
- expect(mockPlugin.onServerStop).toHaveBeenCalled()
78
- })
79
-
80
- it('should handle plugin dependencies correctly', async () => {
81
- const basePlugin: Plugin = {
82
- name: 'base-plugin',
83
- setup: vi.fn()
84
- }
85
-
86
- const dependentPlugin: Plugin = {
87
- name: 'dependent-plugin',
88
- dependencies: ['base-plugin'],
89
- setup: vi.fn()
90
- }
91
-
92
- framework.use(basePlugin)
93
- framework.use(dependentPlugin)
94
-
95
- await framework.start()
96
-
97
- const loadOrder = framework.getPluginRegistry().getLoadOrder()
98
- expect(loadOrder.indexOf('base-plugin')).toBeLessThan(loadOrder.indexOf('dependent-plugin'))
99
- })
100
- })
101
-
102
- describe('Logger Integration', () => {
103
- it('should use enhanced logger throughout the system', () => {
104
- // Test basic logger functionality
105
- logger.info('Test message')
106
-
107
- expect(consoleSpy.info).toHaveBeenCalled()
108
- const logMessage = consoleSpy.info.mock.calls[0][0]
109
- expect(logMessage).toContain('Test message')
110
- })
111
-
112
- it('should provide framework logging', () => {
113
- logger.info('Framework test message')
114
- expect(consoleSpy.info).toHaveBeenCalled()
115
- })
116
- })
117
-
118
- describe('Error Handling Integration', () => {
119
- it('should set up centralized error handling', () => {
120
- const app = framework.getApp()
121
- expect(app).toBeDefined()
122
- // Error handler is set up in constructor
123
- })
124
- })
125
-
126
- describe('Type System Integration', () => {
127
- it('should have comprehensive type exports', async () => {
128
- // Test that all type exports are available
129
- const types = await import('../types')
130
-
131
- // Test that the main types module is properly structured (it's a module, not an object)
132
- expect(typeof types).toBe('object')
133
- expect(types).toBeDefined()
134
-
135
- // Test config schema exports directly
136
- const configTypes = await import('../config/schema')
137
- expect(configTypes).toHaveProperty('defaultFluxStackConfig')
138
- expect(configTypes).toHaveProperty('environmentDefaults')
139
-
140
- // Test plugin types from the main types index
141
- const coreTypes = await import('../types')
142
- // Plugin types should be available through the main types module
143
- expect(typeof coreTypes).toBe('object')
144
- expect(coreTypes).toBeDefined()
145
-
146
- // Test utility types
147
- const loggerTypes = await import('../utils/logger')
148
- expect(loggerTypes).toHaveProperty('logger')
149
-
150
- const errorTypes = await import('../utils/errors')
151
- expect(errorTypes).toHaveProperty('FluxStackError')
152
- })
153
- })
154
-
155
- describe('Utilities Integration', () => {
156
- it('should provide all utility functions', async () => {
157
- const utils = await import('../utils')
158
-
159
- expect(utils.logger).toBeDefined()
160
- expect(utils.log).toBeDefined()
161
- expect(utils.FluxStackError).toBeDefined()
162
- expect(utils.MetricsCollector).toBeDefined()
163
- expect(utils.formatBytes).toBeDefined()
164
- expect(utils.createTimer).toBeDefined()
165
- })
166
-
167
- it('should have working helper functions', async () => {
168
- const { formatBytes, createTimer, isTest } = await import('../utils/helpers')
169
-
170
- expect(formatBytes(1024)).toBe('1 KB')
171
- expect(isTest()).toBe(true)
172
-
173
- const timer = createTimer('test')
174
- expect(timer.label).toBe('test')
175
- expect(typeof timer.end).toBe('function')
176
- })
177
- })
178
-
179
- describe('Backward Compatibility', () => {
180
- it('should maintain exports from core/server/index.ts', async () => {
181
- try {
182
- const serverExports = await import('../server')
183
-
184
- expect(serverExports.FluxStackFramework).toBeDefined()
185
- expect(serverExports.PluginRegistry).toBeDefined()
186
- expect(serverExports.loggerPlugin).toBeDefined()
187
- expect(serverExports.vitePlugin).toBeDefined()
188
- expect(serverExports.staticPlugin).toBeDefined()
189
- expect(serverExports.swaggerPlugin).toBeDefined()
190
- } catch (error) {
191
- // Skip this test if there are environment issues (e.g., esbuild + Windows + Bun)
192
- if (error instanceof Error && error.message.includes('Invariant violation')) {
193
- console.warn('⚠️ Skipping server exports test due to environment compatibility issues')
194
- expect(true).toBe(true) // Mark test as passed
195
- } else {
196
- throw error // Re-throw other errors
197
- }
198
- }
199
- })
200
- })
201
-
202
- describe('Complete Workflow', () => {
203
- it('should support complete framework lifecycle', async () => {
204
- const testPlugin: Plugin = {
205
- name: 'workflow-test-plugin',
206
- setup: vi.fn(),
207
- onServerStart: vi.fn(),
208
- onServerStop: vi.fn()
209
- }
210
-
211
- // Register plugin
212
- framework.use(testPlugin)
213
-
214
- // Start framework
215
- await framework.start()
216
- expect(testPlugin.setup).toHaveBeenCalled()
217
- expect(testPlugin.onServerStart).toHaveBeenCalled()
218
-
219
- // Verify framework is running
220
- expect(framework.getPluginRegistry().getAll()).toHaveLength(1)
221
-
222
- // Stop framework
223
- await framework.stop()
224
- expect(testPlugin.onServerStop).toHaveBeenCalled()
225
- })
226
- })
227
- })
@@ -1,186 +0,0 @@
1
- import { spawn } from "bun"
2
- import { copyFile, copyFileSync, writeFileSync } from "fs"
3
- import { join } from "path"
4
- import type { FluxStackConfig } from "../config"
5
-
6
- export class FluxStackBuilder {
7
- private config: FluxStackConfig
8
-
9
- constructor(config: FluxStackConfig) {
10
- this.config = config
11
- }
12
-
13
- async buildClient() {
14
- console.log("⚡ Building client...")
15
-
16
- const buildProcess = spawn({
17
- cmd: ["bunx", "vite", "build", "--config", "vite.config.ts"],
18
- cwd: process.cwd(),
19
- stdout: "pipe",
20
- stderr: "pipe",
21
- env: {
22
- ...process.env,
23
- VITE_BUILD_OUTDIR: this.config.client.build.outDir,
24
- VITE_BUILD_MINIFY: this.config.client.build.minify.toString(),
25
- VITE_BUILD_SOURCEMAPS: this.config.client.build.sourceMaps.toString()
26
- }
27
- })
28
-
29
- const exitCode = await buildProcess.exited
30
-
31
- if (exitCode === 0) {
32
- console.log("✅ Client build completed")
33
- } else {
34
- console.error("❌ Client build failed")
35
- process.exit(1)
36
- }
37
- }
38
-
39
- async buildServer() {
40
- console.log("⚡ Building server...")
41
-
42
- const buildProcess = spawn({
43
- cmd: [
44
- "bun", "build",
45
- "app/server/index.ts",
46
- "--outdir", this.config.build.outDir,
47
- "--target", this.config.build.target,
48
- "--external", "@tailwindcss/vite",
49
- "--external", "tailwindcss",
50
- "--external", "lightningcss",
51
- "--external", "vite",
52
- "--external", "@vitejs/plugin-react"
53
- ],
54
- stdout: "pipe",
55
- stderr: "pipe"
56
- })
57
-
58
- const exitCode = await buildProcess.exited
59
-
60
- if (exitCode === 0) {
61
- console.log("✅ Server build completed")
62
- } else {
63
- console.error("❌ Server build failed")
64
- process.exit(1)
65
- }
66
- }
67
-
68
- async createDockerFiles() {
69
- console.log("🐳 Creating Docker files...")
70
-
71
- const distDir = this.config.build.outDir
72
-
73
- // Dockerfile optimizado para produção
74
- const dockerfile = `# FluxStack Production Docker Image
75
- FROM oven/bun:1.1-alpine AS production
76
-
77
- WORKDIR /app
78
-
79
- # Copy package.json first for better caching
80
- COPY package.json ./
81
-
82
- # Install dependencies
83
- RUN bun install --frozen-lockfile
84
-
85
- # Copy built application
86
- COPY . .
87
-
88
- # Create non-root user
89
- RUN addgroup -g 1001 -S fluxstack && \\
90
- adduser -S fluxstack -u 1001
91
-
92
- # Set permissions
93
- RUN chown -R fluxstack:fluxstack /app
94
- USER fluxstack
95
-
96
- # Environment variables
97
- ENV NODE_ENV=production
98
- ENV PORT=3000
99
-
100
- # Health check
101
- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \\
102
- CMD bun run -e "fetch('http://localhost:3000/api/health').then(r => r.ok ? process.exit(0) : process.exit(1))" || exit 1
103
-
104
- # Expose port
105
- EXPOSE 3000
106
-
107
- # Start the application
108
- CMD ["bun", "run", "index.js"]
109
- `
110
-
111
- // docker-compose.yml para deploy rápido
112
- const dockerCompose = `version: '3.8'
113
-
114
- services:
115
- fluxstack:
116
- build: .
117
- ports:
118
- - "3000:3000"
119
- environment:
120
- - NODE_ENV=production
121
- - PORT=3000
122
- restart: unless-stopped
123
- healthcheck:
124
- test: ["CMD", "bun", "run", "-e", "fetch('http://localhost:3000/api/health').then(r => r.ok ? process.exit(0) : process.exit(1))"]
125
- interval: 30s
126
- timeout: 3s
127
- retries: 3
128
- deploy:
129
- resources:
130
- limits:
131
- memory: 512M
132
- reservations:
133
- memory: 256M
134
-
135
- # Opcional: adicionar nginx reverse proxy
136
- # nginx:
137
- # image: nginx:alpine
138
- # ports:
139
- # - "80:80"
140
- # volumes:
141
- # - ./nginx.conf:/etc/nginx/nginx.conf
142
- # depends_on:
143
- # - fluxstack
144
- # restart: unless-stopped
145
- `
146
-
147
- // .dockerignore otimizado
148
- const dockerignore = `node_modules
149
- .git
150
- .gitignore
151
- README.md
152
- .env
153
- .env.local
154
- .env.*.local
155
- npm-debug.log*
156
- yarn-debug.log*
157
- yarn-error.log*
158
- .DS_Store
159
- *.log
160
- coverage
161
- .nyc_output
162
- .vscode
163
- .idea
164
- *.swp
165
- *.swo
166
- `
167
-
168
- // Escrever arquivos no dist
169
- writeFileSync(join(distDir, "Dockerfile"), dockerfile)
170
- writeFileSync(join(distDir, "docker-compose.yml"), dockerCompose)
171
- writeFileSync(join(distDir, ".dockerignore"), dockerignore)
172
- copyFileSync(join(process.cwd(),'.env'), join(distDir, ".env"))
173
- //writeFileSync(join(distDir, "package.json"), JSON.stringify(packageJson, null, 2))
174
-
175
- console.log("✅ Docker files created in dist/")
176
- }
177
-
178
- async build() {
179
- console.log("⚡ FluxStack Framework - Building...")
180
- await this.buildClient()
181
- await this.buildServer()
182
- await this.createDockerFiles()
183
- console.log("🎉 Build completed successfully!")
184
- console.log("🐳 Ready for Docker deployment from dist/ directory")
185
- }
186
- }