create-fluxstack 1.0.0
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 +30 -0
- package/LICENSE +21 -0
- package/README.md +214 -0
- package/app/client/README.md +69 -0
- package/app/client/frontend-only.ts +12 -0
- package/app/client/index.html +13 -0
- package/app/client/public/vite.svg +1 -0
- package/app/client/src/App.css +883 -0
- package/app/client/src/App.tsx +669 -0
- package/app/client/src/assets/react.svg +1 -0
- package/app/client/src/components/TestPage.tsx +453 -0
- package/app/client/src/index.css +51 -0
- package/app/client/src/lib/eden-api.ts +110 -0
- package/app/client/src/main.tsx +10 -0
- package/app/client/src/vite-env.d.ts +1 -0
- package/app/client/tsconfig.app.json +43 -0
- package/app/client/tsconfig.json +7 -0
- package/app/client/tsconfig.node.json +25 -0
- package/app/server/app.ts +10 -0
- package/app/server/backend-only.ts +15 -0
- package/app/server/controllers/users.controller.ts +69 -0
- package/app/server/index.ts +104 -0
- package/app/server/routes/index.ts +25 -0
- package/app/server/routes/users.routes.ts +121 -0
- package/app/server/types/index.ts +1 -0
- package/app/shared/types/index.ts +18 -0
- package/bun.lock +1053 -0
- package/core/__tests__/integration.test.ts +227 -0
- package/core/build/index.ts +186 -0
- package/core/cli/command-registry.ts +334 -0
- package/core/cli/index.ts +394 -0
- package/core/cli/plugin-discovery.ts +200 -0
- package/core/client/standalone.ts +57 -0
- package/core/config/__tests__/config-loader.test.ts +591 -0
- package/core/config/__tests__/config-merger.test.ts +657 -0
- package/core/config/__tests__/env-converter.test.ts +372 -0
- package/core/config/__tests__/env-processor.test.ts +431 -0
- package/core/config/__tests__/env.test.ts +452 -0
- package/core/config/__tests__/integration.test.ts +418 -0
- package/core/config/__tests__/loader.test.ts +331 -0
- package/core/config/__tests__/schema.test.ts +129 -0
- package/core/config/__tests__/validator.test.ts +318 -0
- package/core/config/env-dynamic.ts +326 -0
- package/core/config/env.ts +597 -0
- package/core/config/index.ts +317 -0
- package/core/config/loader.ts +546 -0
- package/core/config/runtime-config.ts +322 -0
- package/core/config/schema.ts +694 -0
- package/core/config/validator.ts +540 -0
- package/core/framework/__tests__/server.test.ts +233 -0
- package/core/framework/client.ts +132 -0
- package/core/framework/index.ts +8 -0
- package/core/framework/server.ts +501 -0
- package/core/framework/types.ts +63 -0
- package/core/plugins/__tests__/built-in.test.ts.disabled +366 -0
- package/core/plugins/__tests__/manager.test.ts +398 -0
- package/core/plugins/__tests__/monitoring.test.ts +401 -0
- package/core/plugins/__tests__/registry.test.ts +335 -0
- package/core/plugins/built-in/index.ts +142 -0
- package/core/plugins/built-in/logger/index.ts +180 -0
- package/core/plugins/built-in/monitoring/README.md +193 -0
- package/core/plugins/built-in/monitoring/index.ts +912 -0
- package/core/plugins/built-in/static/index.ts +289 -0
- package/core/plugins/built-in/swagger/index.ts +229 -0
- package/core/plugins/built-in/vite/index.ts +316 -0
- package/core/plugins/config.ts +348 -0
- package/core/plugins/discovery.ts +350 -0
- package/core/plugins/executor.ts +351 -0
- package/core/plugins/index.ts +195 -0
- package/core/plugins/manager.ts +583 -0
- package/core/plugins/registry.ts +424 -0
- package/core/plugins/types.ts +254 -0
- package/core/server/framework.ts +123 -0
- package/core/server/index.ts +8 -0
- package/core/server/plugins/database.ts +182 -0
- package/core/server/plugins/logger.ts +47 -0
- package/core/server/plugins/swagger.ts +34 -0
- package/core/server/standalone.ts +91 -0
- package/core/templates/create-project.ts +455 -0
- package/core/types/api.ts +169 -0
- package/core/types/build.ts +174 -0
- package/core/types/config.ts +68 -0
- package/core/types/index.ts +127 -0
- package/core/types/plugin.ts +94 -0
- package/core/utils/__tests__/errors.test.ts +139 -0
- package/core/utils/__tests__/helpers.test.ts +297 -0
- package/core/utils/__tests__/logger.test.ts +141 -0
- package/core/utils/env-runtime-v2.ts +232 -0
- package/core/utils/env-runtime.ts +252 -0
- package/core/utils/errors/codes.ts +115 -0
- package/core/utils/errors/handlers.ts +63 -0
- package/core/utils/errors/index.ts +81 -0
- package/core/utils/helpers.ts +180 -0
- package/core/utils/index.ts +18 -0
- package/core/utils/logger/index.ts +161 -0
- package/core/utils/logger.ts +106 -0
- package/core/utils/monitoring/index.ts +212 -0
- package/create-fluxstack.ts +231 -0
- package/package.json +43 -0
- package/tsconfig.json +51 -0
- package/vite.config.ts +42 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Plugin System
|
|
3
|
+
* Comprehensive plugin system with lifecycle hooks, dependency management, and configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Core plugin types and interfaces
|
|
7
|
+
export type {
|
|
8
|
+
Plugin,
|
|
9
|
+
PluginContext,
|
|
10
|
+
PluginHook,
|
|
11
|
+
PluginPriority,
|
|
12
|
+
PluginManifest,
|
|
13
|
+
PluginLoadResult,
|
|
14
|
+
PluginRegistryState,
|
|
15
|
+
PluginHookResult,
|
|
16
|
+
PluginMetrics,
|
|
17
|
+
PluginDiscoveryOptions,
|
|
18
|
+
PluginInstallOptions,
|
|
19
|
+
PluginExecutionContext,
|
|
20
|
+
PluginValidationResult,
|
|
21
|
+
HookExecutionOptions,
|
|
22
|
+
PluginLifecycleEvent,
|
|
23
|
+
PluginConfigSchema,
|
|
24
|
+
RequestContext,
|
|
25
|
+
ResponseContext,
|
|
26
|
+
ErrorContext,
|
|
27
|
+
BuildContext
|
|
28
|
+
} from './types'
|
|
29
|
+
|
|
30
|
+
// Plugin registry
|
|
31
|
+
export { PluginRegistry } from './registry'
|
|
32
|
+
export type { PluginRegistryConfig } from './registry'
|
|
33
|
+
|
|
34
|
+
// Plugin discovery
|
|
35
|
+
export { PluginDiscovery, pluginDiscovery } from './discovery'
|
|
36
|
+
export type { PluginDiscoveryConfig } from './discovery'
|
|
37
|
+
|
|
38
|
+
// Plugin configuration management
|
|
39
|
+
export {
|
|
40
|
+
DefaultPluginConfigManager,
|
|
41
|
+
createPluginUtils
|
|
42
|
+
} from './config'
|
|
43
|
+
export type { PluginConfigManager } from './config'
|
|
44
|
+
|
|
45
|
+
// Plugin manager
|
|
46
|
+
export {
|
|
47
|
+
PluginManager,
|
|
48
|
+
createRequestContext,
|
|
49
|
+
createResponseContext,
|
|
50
|
+
createErrorContext,
|
|
51
|
+
createBuildContext
|
|
52
|
+
} from './manager'
|
|
53
|
+
export type { PluginManagerConfig } from './manager'
|
|
54
|
+
|
|
55
|
+
// Plugin executor
|
|
56
|
+
export {
|
|
57
|
+
PluginExecutor,
|
|
58
|
+
calculateExecutionStats
|
|
59
|
+
} from './executor'
|
|
60
|
+
export type {
|
|
61
|
+
PluginExecutionPlan,
|
|
62
|
+
PluginExecutionStep,
|
|
63
|
+
PluginExecutionStats
|
|
64
|
+
} from './executor'
|
|
65
|
+
|
|
66
|
+
// Utility functions for plugin development
|
|
67
|
+
export const PluginUtils = {
|
|
68
|
+
/**
|
|
69
|
+
* Create a simple plugin
|
|
70
|
+
*/
|
|
71
|
+
createPlugin: (config: {
|
|
72
|
+
name: string
|
|
73
|
+
version?: string
|
|
74
|
+
description?: string
|
|
75
|
+
dependencies?: string[]
|
|
76
|
+
priority?: number | PluginPriority
|
|
77
|
+
setup?: (context: PluginContext) => void | Promise<void>
|
|
78
|
+
onServerStart?: (context: PluginContext) => void | Promise<void>
|
|
79
|
+
onServerStop?: (context: PluginContext) => void | Promise<void>
|
|
80
|
+
onRequest?: (context: RequestContext) => void | Promise<void>
|
|
81
|
+
onResponse?: (context: ResponseContext) => void | Promise<void>
|
|
82
|
+
onError?: (context: ErrorContext) => void | Promise<void>
|
|
83
|
+
configSchema?: any
|
|
84
|
+
defaultConfig?: any
|
|
85
|
+
}): Plugin => {
|
|
86
|
+
const plugin = {
|
|
87
|
+
name: config.name,
|
|
88
|
+
...(config.version && { version: config.version }),
|
|
89
|
+
...(config.description && { description: config.description }),
|
|
90
|
+
...(config.dependencies && { dependencies: config.dependencies }),
|
|
91
|
+
...(config.priority !== undefined && { priority: config.priority }),
|
|
92
|
+
...(config.setup && { setup: config.setup }),
|
|
93
|
+
...(config.onServerStart && { onServerStart: config.onServerStart }),
|
|
94
|
+
...(config.onServerStop && { onServerStop: config.onServerStop }),
|
|
95
|
+
...(config.onRequest && { onRequest: config.onRequest }),
|
|
96
|
+
...(config.onResponse && { onResponse: config.onResponse }),
|
|
97
|
+
...(config.onError && { onError: config.onError }),
|
|
98
|
+
...(config.configSchema && { configSchema: config.configSchema }),
|
|
99
|
+
...(config.defaultConfig && { defaultConfig: config.defaultConfig })
|
|
100
|
+
} as Plugin
|
|
101
|
+
return plugin
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Create a plugin manifest
|
|
106
|
+
*/
|
|
107
|
+
createManifest: (config: {
|
|
108
|
+
name: string
|
|
109
|
+
version: string
|
|
110
|
+
description: string
|
|
111
|
+
author: string
|
|
112
|
+
license: string
|
|
113
|
+
homepage?: string
|
|
114
|
+
repository?: string
|
|
115
|
+
keywords?: string[]
|
|
116
|
+
dependencies?: Record<string, string>
|
|
117
|
+
peerDependencies?: Record<string, string>
|
|
118
|
+
fluxstack: {
|
|
119
|
+
version: string
|
|
120
|
+
hooks: PluginHook[]
|
|
121
|
+
config?: any
|
|
122
|
+
category?: string
|
|
123
|
+
tags?: string[]
|
|
124
|
+
}
|
|
125
|
+
}): any => {
|
|
126
|
+
return {
|
|
127
|
+
name: config.name,
|
|
128
|
+
version: config.version || '1.0.0',
|
|
129
|
+
description: config.description,
|
|
130
|
+
author: config.author,
|
|
131
|
+
license: config.license,
|
|
132
|
+
homepage: config.homepage,
|
|
133
|
+
repository: config.repository,
|
|
134
|
+
keywords: config.keywords || [],
|
|
135
|
+
dependencies: config.dependencies || {},
|
|
136
|
+
peerDependencies: config.peerDependencies,
|
|
137
|
+
fluxstack: config.fluxstack
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Validate plugin structure
|
|
143
|
+
*/
|
|
144
|
+
validatePlugin: (plugin: any): plugin is Plugin => {
|
|
145
|
+
return (
|
|
146
|
+
plugin &&
|
|
147
|
+
typeof plugin === 'object' &&
|
|
148
|
+
typeof plugin.name === 'string' &&
|
|
149
|
+
plugin.name.length > 0
|
|
150
|
+
)
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Check if plugin implements hook
|
|
155
|
+
*/
|
|
156
|
+
implementsHook: (plugin: Plugin, hook: PluginHook): boolean => {
|
|
157
|
+
const hookFunction = (plugin as any)[hook]
|
|
158
|
+
return hookFunction && typeof hookFunction === 'function'
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get plugin hooks
|
|
163
|
+
*/
|
|
164
|
+
getPluginHooks: (plugin: Plugin): PluginHook[] => {
|
|
165
|
+
const hooks: PluginHook[] = []
|
|
166
|
+
const possibleHooks: PluginHook[] = [
|
|
167
|
+
'setup',
|
|
168
|
+
'onServerStart',
|
|
169
|
+
'onServerStop',
|
|
170
|
+
'onRequest',
|
|
171
|
+
'onResponse',
|
|
172
|
+
'onError',
|
|
173
|
+
'onBuild',
|
|
174
|
+
'onBuildComplete'
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
for (const hook of possibleHooks) {
|
|
178
|
+
if (PluginUtils.implementsHook(plugin, hook)) {
|
|
179
|
+
hooks.push(hook)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return hooks
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Re-export types for convenience
|
|
188
|
+
import type {
|
|
189
|
+
PluginContext,
|
|
190
|
+
PluginHook,
|
|
191
|
+
PluginPriority,
|
|
192
|
+
RequestContext,
|
|
193
|
+
ResponseContext,
|
|
194
|
+
ErrorContext
|
|
195
|
+
} from './types'
|