create-fluxstack 1.7.4 β 1.7.5
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/core/build/index.ts +40 -34
- package/core/plugins/built-in/monitoring/index.ts +2 -0
- package/core/plugins/built-in/static/index.ts +2 -0
- package/core/plugins/built-in/swagger/index.ts +2 -0
- package/core/plugins/built-in/vite/index.ts +4 -1
- package/core/plugins/config.ts +2 -0
- package/core/plugins/discovery.ts +2 -0
- package/core/plugins/executor.ts +2 -0
- package/core/plugins/index.ts +2 -2
- package/core/utils/version.ts +1 -1
- package/package.json +1 -1
package/core/build/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ export class FluxStackBuilder {
|
|
|
13
13
|
|
|
14
14
|
constructor(config: FluxStackConfig) {
|
|
15
15
|
this.config = config
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
// Initialize bundler with configuration
|
|
18
18
|
this.bundler = new Bundler({
|
|
19
19
|
target: config.build.target,
|
|
@@ -21,7 +21,7 @@ export class FluxStackBuilder {
|
|
|
21
21
|
sourceMaps: config.build.sourceMaps,
|
|
22
22
|
external: config.build.external
|
|
23
23
|
})
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
// Initialize optimizer with configuration
|
|
26
26
|
this.optimizer = new Optimizer({
|
|
27
27
|
treeshake: config.build.treeshake,
|
|
@@ -47,10 +47,10 @@ export class FluxStackBuilder {
|
|
|
47
47
|
|
|
48
48
|
async createDockerFiles() {
|
|
49
49
|
console.log("π³ Creating Docker files...")
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
const distDir = this.config.build.outDir
|
|
52
52
|
console.log(`π Output directory: ${distDir}`)
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
// Ensure dist directory exists
|
|
55
55
|
if (!existsSync(distDir)) {
|
|
56
56
|
console.log(`π Creating directory: ${distDir}`)
|
|
@@ -59,7 +59,7 @@ export class FluxStackBuilder {
|
|
|
59
59
|
} else {
|
|
60
60
|
console.log(`β
Directory already exists`)
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
// Dockerfile optimizado para produΓ§Γ£o
|
|
64
64
|
const dockerfile = `# FluxStack Production Docker Image
|
|
65
65
|
FROM oven/bun:1.1-alpine AS production
|
|
@@ -166,17 +166,17 @@ coverage
|
|
|
166
166
|
console.error(`β Error writing Docker files:`, error)
|
|
167
167
|
throw error
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
// Copiar .env ou criar um de exemplo
|
|
171
171
|
const envPath = join(process.cwd(), '.env')
|
|
172
172
|
const envExamplePath = join(process.cwd(), '.env.example')
|
|
173
173
|
const distEnvPath = join(distDir, ".env")
|
|
174
|
-
|
|
174
|
+
|
|
175
175
|
console.log(`π Checking for .env files...`)
|
|
176
176
|
console.log(` - .env path: ${envPath}`)
|
|
177
177
|
console.log(` - .env.example path: ${envExamplePath}`)
|
|
178
178
|
console.log(` - target path: ${distEnvPath}`)
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
if (existsSync(envPath)) {
|
|
181
181
|
console.log(`π Copying .env file and setting production mode...`)
|
|
182
182
|
// Read .env content
|
|
@@ -204,15 +204,15 @@ MONITORING_ENABLED=true
|
|
|
204
204
|
writeFileSync(distEnvPath, defaultEnv)
|
|
205
205
|
console.log("π Default environment file created for production")
|
|
206
206
|
}
|
|
207
|
-
|
|
207
|
+
|
|
208
208
|
// Copy package.json for Docker build
|
|
209
209
|
const packageJsonPath = join(process.cwd(), 'package.json')
|
|
210
210
|
const distPackageJsonPath = join(distDir, 'package.json')
|
|
211
|
-
|
|
211
|
+
|
|
212
212
|
console.log(`π¦ Copying package.json...`)
|
|
213
213
|
console.log(` - source: ${packageJsonPath}`)
|
|
214
214
|
console.log(` - target: ${distPackageJsonPath}`)
|
|
215
|
-
|
|
215
|
+
|
|
216
216
|
if (existsSync(packageJsonPath)) {
|
|
217
217
|
copyFileSync(packageJsonPath, distPackageJsonPath)
|
|
218
218
|
console.log("π¦ Package.json copied successfully")
|
|
@@ -229,41 +229,44 @@ MONITORING_ENABLED=true
|
|
|
229
229
|
}
|
|
230
230
|
writeFileSync(distPackageJsonPath, JSON.stringify(minimalPackageJson, null, 2))
|
|
231
231
|
}
|
|
232
|
-
|
|
232
|
+
|
|
233
233
|
console.log("β
Docker files created in dist/")
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
|
|
237
237
|
async build(): Promise<BuildResult> {
|
|
238
238
|
console.log("β‘ FluxStack Framework - Building...")
|
|
239
|
-
|
|
239
|
+
|
|
240
240
|
const startTime = Date.now()
|
|
241
|
-
|
|
241
|
+
|
|
242
242
|
try {
|
|
243
243
|
// Pre-build checks (version sync, etc.)
|
|
244
244
|
await this.runPreBuildChecks()
|
|
245
|
-
|
|
245
|
+
|
|
246
246
|
// Validate configuration
|
|
247
247
|
await this.validateConfig()
|
|
248
|
-
|
|
248
|
+
|
|
249
249
|
// Clean output directory if requested
|
|
250
250
|
if (this.config.build.clean) {
|
|
251
251
|
await this.clean()
|
|
252
252
|
}
|
|
253
|
-
|
|
253
|
+
|
|
254
254
|
// Build client and server
|
|
255
255
|
const clientResult = await this.buildClient()
|
|
256
256
|
const serverResult = await this.buildServer()
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
// Check if builds were successful
|
|
259
259
|
if (!clientResult.success || !serverResult.success) {
|
|
260
|
+
const errorMessage = clientResult.error || serverResult.error || "Build failed"
|
|
260
261
|
return {
|
|
261
262
|
success: false,
|
|
262
263
|
duration: Date.now() - startTime,
|
|
263
|
-
error: clientResult.error || serverResult.error || "Build failed",
|
|
264
264
|
outputFiles: [],
|
|
265
265
|
warnings: [],
|
|
266
|
-
errors: [
|
|
266
|
+
errors: [{
|
|
267
|
+
message: errorMessage,
|
|
268
|
+
code: 'BUILD_FAILED'
|
|
269
|
+
}],
|
|
267
270
|
stats: {
|
|
268
271
|
totalSize: 0,
|
|
269
272
|
gzippedSize: 0,
|
|
@@ -274,25 +277,25 @@ MONITORING_ENABLED=true
|
|
|
274
277
|
}
|
|
275
278
|
}
|
|
276
279
|
}
|
|
277
|
-
|
|
280
|
+
|
|
278
281
|
// Optimize build if enabled
|
|
279
282
|
let optimizationResult
|
|
280
283
|
if (this.config.build.optimize) {
|
|
281
284
|
optimizationResult = await this.optimizer.optimize(this.config.build.outDir)
|
|
282
285
|
}
|
|
283
|
-
|
|
286
|
+
|
|
284
287
|
// Create Docker files
|
|
285
288
|
await this.createDockerFiles()
|
|
286
|
-
|
|
289
|
+
|
|
287
290
|
// Generate build manifest
|
|
288
291
|
const manifest = await this.generateManifest(clientResult, serverResult, optimizationResult)
|
|
289
|
-
|
|
292
|
+
|
|
290
293
|
const duration = Date.now() - startTime
|
|
291
|
-
|
|
294
|
+
|
|
292
295
|
console.log("π Build completed successfully!")
|
|
293
296
|
console.log(`β±οΈ Build time: ${duration}ms`)
|
|
294
297
|
console.log("π³ Ready for Docker deployment from dist/ directory")
|
|
295
|
-
|
|
298
|
+
|
|
296
299
|
return {
|
|
297
300
|
success: true,
|
|
298
301
|
duration,
|
|
@@ -308,20 +311,23 @@ MONITORING_ENABLED=true
|
|
|
308
311
|
dependencies: []
|
|
309
312
|
}
|
|
310
313
|
}
|
|
311
|
-
|
|
314
|
+
|
|
312
315
|
} catch (error) {
|
|
313
316
|
const duration = Date.now() - startTime
|
|
314
317
|
const errorMessage = error instanceof Error ? error.message : "Unknown build error"
|
|
315
|
-
|
|
318
|
+
|
|
316
319
|
console.error("β Build failed:", errorMessage)
|
|
317
|
-
|
|
320
|
+
|
|
318
321
|
return {
|
|
319
322
|
success: false,
|
|
320
323
|
duration,
|
|
321
|
-
error: errorMessage,
|
|
322
324
|
outputFiles: [],
|
|
323
325
|
warnings: [],
|
|
324
|
-
errors: [
|
|
326
|
+
errors: [{
|
|
327
|
+
message: errorMessage,
|
|
328
|
+
code: 'BUILD_EXCEPTION',
|
|
329
|
+
stack: error instanceof Error ? error.stack : undefined
|
|
330
|
+
}],
|
|
325
331
|
stats: {
|
|
326
332
|
totalSize: 0,
|
|
327
333
|
gzippedSize: 0,
|
|
@@ -350,7 +356,7 @@ MONITORING_ENABLED=true
|
|
|
350
356
|
if (!this.config.build.outDir) {
|
|
351
357
|
throw new Error("Build output directory not specified")
|
|
352
358
|
}
|
|
353
|
-
|
|
359
|
+
|
|
354
360
|
if (!this.config.build.target) {
|
|
355
361
|
throw new Error("Build target not specified")
|
|
356
362
|
}
|
|
@@ -362,8 +368,8 @@ MONITORING_ENABLED=true
|
|
|
362
368
|
}
|
|
363
369
|
|
|
364
370
|
private async generateManifest(
|
|
365
|
-
clientResult: any,
|
|
366
|
-
serverResult: any,
|
|
371
|
+
clientResult: any,
|
|
372
|
+
serverResult: any,
|
|
367
373
|
optimizationResult?: any
|
|
368
374
|
): Promise<BuildManifest> {
|
|
369
375
|
return {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { FluxStack, PluginContext, RequestContext } from "../../types"
|
|
2
2
|
import { createServer, type ViteDevServer } from 'vite'
|
|
3
|
+
import { FLUXSTACK_VERSION } from "../../../utils/version"
|
|
4
|
+
|
|
5
|
+
type Plugin = FluxStack.Plugin
|
|
3
6
|
|
|
4
7
|
let viteServer: ViteDevServer | null = null
|
|
5
8
|
|
|
6
9
|
export const vitePlugin: Plugin = {
|
|
7
10
|
name: "vite",
|
|
8
|
-
version:
|
|
11
|
+
version: FLUXSTACK_VERSION,
|
|
9
12
|
description: "Enhanced Vite integration plugin for FluxStack with improved error handling and monitoring",
|
|
10
13
|
author: "FluxStack Team",
|
|
11
14
|
priority: 800, // Should run early to setup proxying
|
package/core/plugins/config.ts
CHANGED
|
@@ -7,6 +7,8 @@ import type { FluxStack, PluginConfigSchema, PluginValidationResult } from "./ty
|
|
|
7
7
|
import type { FluxStackConfig } from "../config/schema"
|
|
8
8
|
import type { Logger } from "../utils/logger/index"
|
|
9
9
|
|
|
10
|
+
type Plugin = FluxStack.Plugin
|
|
11
|
+
|
|
10
12
|
export interface PluginConfigManager {
|
|
11
13
|
validatePluginConfig(plugin: Plugin, config: any): PluginValidationResult
|
|
12
14
|
mergePluginConfig(plugin: Plugin, userConfig: any): any
|
package/core/plugins/executor.ts
CHANGED
package/core/plugins/index.ts
CHANGED
|
@@ -27,7 +27,6 @@ export type {
|
|
|
27
27
|
BuildContext
|
|
28
28
|
} from './types'
|
|
29
29
|
|
|
30
|
-
export type { FluxStack }
|
|
31
30
|
export type Plugin = FluxStack.Plugin
|
|
32
31
|
|
|
33
32
|
// Plugin registry
|
|
@@ -200,5 +199,6 @@ import type {
|
|
|
200
199
|
PluginPriority,
|
|
201
200
|
RequestContext,
|
|
202
201
|
ResponseContext,
|
|
203
|
-
ErrorContext
|
|
202
|
+
ErrorContext,
|
|
203
|
+
FluxStack
|
|
204
204
|
} from './types'
|
package/core/utils/version.ts
CHANGED