create-fluxstack 1.5.0 → 1.5.1
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 +1 -8
- package/app/client/src/App.tsx +1 -4
- package/app/server/index.ts +0 -4
- package/app/server/routes/index.ts +1 -5
- package/config/index.ts +1 -9
- package/core/cli/generators/plugin.ts +34 -324
- package/core/cli/generators/template-engine.ts +0 -5
- package/core/cli/plugin-discovery.ts +12 -33
- package/core/framework/server.ts +0 -10
- package/core/plugins/dependency-manager.ts +22 -89
- package/core/plugins/index.ts +0 -4
- package/core/plugins/manager.ts +2 -3
- package/core/plugins/registry.ts +1 -28
- package/core/utils/logger/index.ts +0 -4
- package/fluxstack.config.ts +114 -253
- package/package.json +117 -117
- package/CRYPTO-AUTH-MIDDLEWARE-GUIDE.md +0 -475
- package/CRYPTO-AUTH-MIDDLEWARES.md +0 -473
- package/CRYPTO-AUTH-USAGE.md +0 -491
- package/EXEMPLO-ROTA-PROTEGIDA.md +0 -347
- package/QUICK-START-CRYPTO-AUTH.md +0 -221
- package/app/client/src/pages/CryptoAuthPage.tsx +0 -394
- 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/core/plugins/module-resolver.ts +0 -216
- package/plugins/crypto-auth/README.md +0 -788
- package/plugins/crypto-auth/ai-context.md +0 -1282
- package/plugins/crypto-auth/cli/make-protected-route.command.ts +0 -383
- package/plugins/crypto-auth/client/CryptoAuthClient.ts +0 -302
- package/plugins/crypto-auth/client/components/AuthProvider.tsx +0 -131
- package/plugins/crypto-auth/client/components/LoginButton.tsx +0 -138
- package/plugins/crypto-auth/client/components/ProtectedRoute.tsx +0 -89
- package/plugins/crypto-auth/client/components/index.ts +0 -12
- package/plugins/crypto-auth/client/index.ts +0 -12
- package/plugins/crypto-auth/config/index.ts +0 -34
- package/plugins/crypto-auth/index.ts +0 -162
- package/plugins/crypto-auth/package.json +0 -66
- package/plugins/crypto-auth/server/AuthMiddleware.ts +0 -181
- package/plugins/crypto-auth/server/CryptoAuthService.ts +0 -186
- package/plugins/crypto-auth/server/index.ts +0 -22
- package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +0 -65
- package/plugins/crypto-auth/server/middlewares/cryptoAuthOptional.ts +0 -26
- package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +0 -76
- package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +0 -45
- package/plugins/crypto-auth/server/middlewares/helpers.ts +0 -140
- package/plugins/crypto-auth/server/middlewares/index.ts +0 -22
- package/plugins/crypto-auth/server/middlewares.ts +0 -19
- package/test-crypto-auth.ts +0 -101
package/.env.example
CHANGED
|
@@ -27,11 +27,4 @@ LOG_LEVEL=info
|
|
|
27
27
|
|
|
28
28
|
# Build Configuration
|
|
29
29
|
BUILD_TARGET=bun
|
|
30
|
-
BUILD_OUTDIR=dist
|
|
31
|
-
|
|
32
|
-
# Crypto Auth Plugin
|
|
33
|
-
CRYPTO_AUTH_ENABLED=true
|
|
34
|
-
CRYPTO_AUTH_MAX_TIME_DRIFT=300000
|
|
35
|
-
# Adicione chaves públicas de admin separadas por vírgula (64 chars hex cada)
|
|
36
|
-
CRYPTO_AUTH_ADMIN_KEYS=
|
|
37
|
-
CRYPTO_AUTH_ENABLE_METRICS=true
|
|
30
|
+
BUILD_OUTDIR=dist
|
package/app/client/src/App.tsx
CHANGED
|
@@ -15,7 +15,6 @@ import { OverviewPage } from './pages/Overview'
|
|
|
15
15
|
import { DemoPage } from './pages/Demo'
|
|
16
16
|
import { HybridLivePage } from './pages/HybridLive'
|
|
17
17
|
import { ApiDocsPage } from './pages/ApiDocs'
|
|
18
|
-
import { CryptoAuthPage } from './pages/CryptoAuthPage'
|
|
19
18
|
import { MainLayout } from './components/MainLayout'
|
|
20
19
|
import { LiveClock } from './components/LiveClock'
|
|
21
20
|
|
|
@@ -167,7 +166,6 @@ function AppContent() {
|
|
|
167
166
|
{[
|
|
168
167
|
{ id: 'overview', label: 'Visão Geral', icon: <FaClipboardList />, path: '/' },
|
|
169
168
|
{ id: 'demo', label: 'Demo', icon: <FaRocket />, path: '/demo' },
|
|
170
|
-
{ id: 'crypto-auth', label: 'Crypto Auth', icon: <FaShieldAlt />, path: '/crypto-auth' },
|
|
171
169
|
{ id: 'hybrid-live', label: 'Hybrid Live', icon: <FaBolt />, path: '/hybrid-live' },
|
|
172
170
|
{ id: 'live-app', label: 'Live App', icon: <FaFire />, path: '/live-app' },
|
|
173
171
|
{ id: 'api-docs', label: 'API Docs', icon: <FaBook />, path: '/api-docs' },
|
|
@@ -210,8 +208,8 @@ function AppContent() {
|
|
|
210
208
|
{[
|
|
211
209
|
{ id: 'overview', label: 'Visão', icon: <FaClipboardList />, path: '/' },
|
|
212
210
|
{ id: 'demo', label: 'Demo', icon: <FaRocket />, path: '/demo' },
|
|
213
|
-
{ id: 'crypto-auth', label: 'Crypto', icon: <FaShieldAlt />, path: '/crypto-auth' },
|
|
214
211
|
{ id: 'hybrid-live', label: 'Hybrid', icon: <FaBolt />, path: '/hybrid-live' },
|
|
212
|
+
{ id: 'live-app', label: 'Live', icon: <FaFire />, path: '/live-app' },
|
|
215
213
|
{ id: 'api-docs', label: 'Docs', icon: <FaBook />, path: '/api-docs' },
|
|
216
214
|
{ id: 'tests', label: 'Testes', icon: <FaTest />, path: '/tests' }
|
|
217
215
|
].map(tab => (
|
|
@@ -258,7 +256,6 @@ function AppContent() {
|
|
|
258
256
|
/>
|
|
259
257
|
}
|
|
260
258
|
/>
|
|
261
|
-
<Route path="/crypto-auth" element={<CryptoAuthPage />} />
|
|
262
259
|
<Route path="/hybrid-live" element={<HybridLivePage />} />
|
|
263
260
|
<Route path="/api-docs" element={<ApiDocsPage />} />
|
|
264
261
|
<Route path="/tests" element={
|
package/app/server/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { helpers } from "@/core/utils/env"
|
|
|
7
7
|
import { serverConfig } from "@/config/server.config"
|
|
8
8
|
import { appConfig } from "@/config/app.config"
|
|
9
9
|
import { loggerConfig } from "@/config/logger.config"
|
|
10
|
-
import cryptoAuthPlugin from "@/plugins/crypto-auth"
|
|
11
10
|
import "./live/register-components"
|
|
12
11
|
|
|
13
12
|
// Startup info moved to DEBUG level (set LOG_LEVEL=debug to see details)
|
|
@@ -51,9 +50,6 @@ const app = new FluxStackFramework({
|
|
|
51
50
|
|
|
52
51
|
// Usar plugins de infraestrutura primeiro (Logger é core, não é plugin)
|
|
53
52
|
|
|
54
|
-
// Registrar plugin de autenticação ANTES dos outros plugins
|
|
55
|
-
app.use(cryptoAuthPlugin)
|
|
56
|
-
|
|
57
53
|
// Usar plugins condicionalmente baseado no ambiente
|
|
58
54
|
if (isDevelopment()) {
|
|
59
55
|
app.use(vitePlugin)
|
|
@@ -2,8 +2,6 @@ import { Elysia, t } from "elysia"
|
|
|
2
2
|
import { usersRoutes } from "./users.routes"
|
|
3
3
|
import { uploadRoutes } from "./upload"
|
|
4
4
|
import { configRoutes } from "./config"
|
|
5
|
-
import { cryptoAuthDemoRoutes } from "./crypto-auth-demo.routes"
|
|
6
|
-
import { exemploPostsRoutes } from "./exemplo-posts.routes"
|
|
7
5
|
|
|
8
6
|
export const apiRoutes = new Elysia({ prefix: "/api" })
|
|
9
7
|
.get("/", () => ({ message: "🔥 Hot Reload funcionando! FluxStack API v1.4.0 ⚡" }), {
|
|
@@ -38,6 +36,4 @@ export const apiRoutes = new Elysia({ prefix: "/api" })
|
|
|
38
36
|
})
|
|
39
37
|
.use(usersRoutes)
|
|
40
38
|
.use(uploadRoutes)
|
|
41
|
-
.use(configRoutes)
|
|
42
|
-
.use(cryptoAuthDemoRoutes)
|
|
43
|
-
.use(exemploPostsRoutes) // ✅ Exemplo de rotas com crypto-auth
|
|
39
|
+
.use(configRoutes)
|
package/config/index.ts
CHANGED
|
@@ -27,9 +27,6 @@ export { buildConfig } from './build.config'
|
|
|
27
27
|
export { appRuntimeConfig } from './runtime.config'
|
|
28
28
|
export { systemConfig, systemRuntimeInfo } from './system.config'
|
|
29
29
|
|
|
30
|
-
// Plugin configs (re-exported for convenience)
|
|
31
|
-
export { cryptoAuthConfig } from '../plugins/crypto-auth/config'
|
|
32
|
-
|
|
33
30
|
// Re-export types
|
|
34
31
|
export type { AppConfig } from './app.config'
|
|
35
32
|
export type { DatabaseConfig } from './database.config'
|
|
@@ -44,9 +41,6 @@ export type {
|
|
|
44
41
|
RedisConfig
|
|
45
42
|
} from './services.config'
|
|
46
43
|
|
|
47
|
-
// Plugin types
|
|
48
|
-
export type { CryptoAuthConfig } from '../plugins/crypto-auth/config'
|
|
49
|
-
|
|
50
44
|
/**
|
|
51
45
|
* All configs in one object
|
|
52
46
|
*/
|
|
@@ -58,7 +52,6 @@ import { loggerConfig } from './logger.config'
|
|
|
58
52
|
import { buildConfig } from './build.config'
|
|
59
53
|
import { appRuntimeConfig } from './runtime.config'
|
|
60
54
|
import { systemConfig, systemRuntimeInfo } from './system.config'
|
|
61
|
-
import { cryptoAuthConfig } from '../plugins/crypto-auth/config'
|
|
62
55
|
|
|
63
56
|
export const config = {
|
|
64
57
|
app: appConfig,
|
|
@@ -69,8 +62,7 @@ export const config = {
|
|
|
69
62
|
build: buildConfig,
|
|
70
63
|
runtime: appRuntimeConfig,
|
|
71
64
|
system: systemConfig,
|
|
72
|
-
systemRuntime: systemRuntimeInfo
|
|
73
|
-
cryptoAuth: cryptoAuthConfig
|
|
65
|
+
systemRuntime: systemRuntimeInfo
|
|
74
66
|
}
|
|
75
67
|
|
|
76
68
|
export default config
|
|
@@ -33,12 +33,11 @@ export class PluginGenerator implements Generator {
|
|
|
33
33
|
|
|
34
34
|
console.log(`\n✅ Generated plugin '${options.name}' with ${files.length} files`)
|
|
35
35
|
console.log(`\n📦 Next steps:`)
|
|
36
|
-
console.log(` 1.
|
|
37
|
-
console.log(` 2.
|
|
38
|
-
console.log(` 3.
|
|
39
|
-
console.log(` 4. Add
|
|
40
|
-
console.log(` 5.
|
|
41
|
-
console.log(` 6. Run: bun run dev`)
|
|
36
|
+
console.log(` 1. Edit plugins/${options.name}/plugin.json with your plugin metadata`)
|
|
37
|
+
console.log(` 2. Implement your plugin logic in plugins/${options.name}/index.ts`)
|
|
38
|
+
console.log(` 3. Add server-side code in plugins/${options.name}/server/ (optional)`)
|
|
39
|
+
console.log(` 4. Add client-side code in plugins/${options.name}/client/ (optional)`)
|
|
40
|
+
console.log(` 5. Run: bun run cli plugin:deps install`)
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
private getTemplate(templateName?: string): Template {
|
|
@@ -60,80 +59,31 @@ export class PluginGenerator implements Generator {
|
|
|
60
59
|
description: 'Basic plugin template with essential files',
|
|
61
60
|
files: [
|
|
62
61
|
{
|
|
63
|
-
path: 'plugins/{{name}}/
|
|
62
|
+
path: 'plugins/{{name}}/plugin.json',
|
|
64
63
|
content: `{
|
|
65
|
-
"name": "
|
|
64
|
+
"name": "{{name}}",
|
|
66
65
|
"version": "1.0.0",
|
|
67
66
|
"description": "{{description}}",
|
|
67
|
+
"author": "Your Name",
|
|
68
|
+
"type": "fluxstack-plugin",
|
|
68
69
|
"main": "index.ts",
|
|
69
|
-
"types": "index.ts",
|
|
70
|
-
"exports": {
|
|
71
|
-
".": {
|
|
72
|
-
"import": "./index.ts",
|
|
73
|
-
"types": "./index.ts"
|
|
74
|
-
},
|
|
75
|
-
"./config": {
|
|
76
|
-
"import": "./config/index.ts",
|
|
77
|
-
"types": "./config/index.ts"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
"keywords": [
|
|
81
|
-
"fluxstack",
|
|
82
|
-
"plugin",
|
|
83
|
-
"{{name}}",
|
|
84
|
-
"typescript"
|
|
85
|
-
],
|
|
86
|
-
"author": "FluxStack Developer",
|
|
87
|
-
"license": "MIT",
|
|
88
|
-
"peerDependencies": {},
|
|
89
70
|
"dependencies": {},
|
|
90
|
-
"devDependencies": {
|
|
91
|
-
"typescript": "^5.0.0"
|
|
92
|
-
},
|
|
93
71
|
"fluxstack": {
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
"
|
|
72
|
+
"minVersion": "1.4.0"
|
|
73
|
+
},
|
|
74
|
+
"hooks": {
|
|
75
|
+
"setup": true,
|
|
76
|
+
"onServerStart": false,
|
|
77
|
+
"onRequest": false,
|
|
78
|
+
"onResponse": false,
|
|
79
|
+
"onError": false
|
|
102
80
|
}
|
|
103
81
|
}
|
|
104
|
-
`
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
path: 'plugins/{{name}}/config/index.ts',
|
|
108
|
-
content: `/**
|
|
109
|
-
* {{pascalName}} Plugin Configuration
|
|
110
|
-
* Declarative config using FluxStack config system
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
import { defineConfig, config } from '@/core/utils/config-schema'
|
|
114
|
-
|
|
115
|
-
const {{camelName}}ConfigSchema = {
|
|
116
|
-
// Enable/disable plugin
|
|
117
|
-
enabled: config.boolean('{{constantName}}_ENABLED', true),
|
|
118
|
-
|
|
119
|
-
// Add your configuration options here
|
|
120
|
-
// Example:
|
|
121
|
-
// apiKey: config.string('{{constantName}}_API_KEY', ''),
|
|
122
|
-
// timeout: config.number('{{constantName}}_TIMEOUT', 5000),
|
|
123
|
-
// debug: config.boolean('{{constantName}}_DEBUG', false),
|
|
124
|
-
} as const
|
|
125
|
-
|
|
126
|
-
export const {{camelName}}Config = defineConfig({{camelName}}ConfigSchema)
|
|
127
|
-
|
|
128
|
-
export type {{pascalName}}Config = typeof {{camelName}}Config
|
|
129
|
-
export default {{camelName}}Config
|
|
130
82
|
`
|
|
131
83
|
},
|
|
132
84
|
{
|
|
133
85
|
path: 'plugins/{{name}}/index.ts',
|
|
134
86
|
content: `import type { FluxStackPlugin, PluginContext } from '@/core/types/plugin'
|
|
135
|
-
// ✅ Plugin imports its own configuration
|
|
136
|
-
import { {{camelName}}Config } from './config'
|
|
137
87
|
|
|
138
88
|
/**
|
|
139
89
|
* {{pascalName}} Plugin
|
|
@@ -147,12 +97,6 @@ export class {{pascalName}}Plugin implements FluxStackPlugin {
|
|
|
147
97
|
* Setup hook - called when plugin is loaded
|
|
148
98
|
*/
|
|
149
99
|
async setup(context: PluginContext): Promise<void> {
|
|
150
|
-
// Check if plugin is enabled
|
|
151
|
-
if (!{{camelName}}Config.enabled) {
|
|
152
|
-
context.logger.info(\`[{{name}}] Plugin disabled by configuration\`)
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
|
|
156
100
|
console.log(\`[{{name}}] Plugin initialized\`)
|
|
157
101
|
|
|
158
102
|
// Add your initialization logic here
|
|
@@ -163,8 +107,6 @@ export class {{pascalName}}Plugin implements FluxStackPlugin {
|
|
|
163
107
|
* Server start hook - called when server starts
|
|
164
108
|
*/
|
|
165
109
|
async onServerStart?(context: PluginContext): Promise<void> {
|
|
166
|
-
if (!{{camelName}}Config.enabled) return
|
|
167
|
-
|
|
168
110
|
console.log(\`[{{name}}] Server started\`)
|
|
169
111
|
|
|
170
112
|
// Add logic to run when server starts
|
|
@@ -174,8 +116,6 @@ export class {{pascalName}}Plugin implements FluxStackPlugin {
|
|
|
174
116
|
* Request hook - called on each request
|
|
175
117
|
*/
|
|
176
118
|
async onRequest?(context: PluginContext, request: Request): Promise<void> {
|
|
177
|
-
if (!{{camelName}}Config.enabled) return
|
|
178
|
-
|
|
179
119
|
// Add request processing logic
|
|
180
120
|
}
|
|
181
121
|
|
|
@@ -183,8 +123,6 @@ export class {{pascalName}}Plugin implements FluxStackPlugin {
|
|
|
183
123
|
* Response hook - called on each response
|
|
184
124
|
*/
|
|
185
125
|
async onResponse?(context: PluginContext, response: Response): Promise<void> {
|
|
186
|
-
if (!{{camelName}}Config.enabled) return
|
|
187
|
-
|
|
188
126
|
// Add response processing logic
|
|
189
127
|
}
|
|
190
128
|
|
|
@@ -218,29 +156,17 @@ This plugin is already in your FluxStack project. To use it:
|
|
|
218
156
|
bun run cli plugin:deps install
|
|
219
157
|
\`\`\`
|
|
220
158
|
|
|
221
|
-
## Configuration
|
|
222
|
-
|
|
223
|
-
This plugin uses FluxStack's declarative configuration system. Configure it by editing \`config/index.ts\` or by setting environment variables:
|
|
224
|
-
|
|
225
|
-
\`\`\`bash
|
|
226
|
-
# Enable/disable plugin
|
|
227
|
-
{{constantName}}_ENABLED=true
|
|
228
|
-
|
|
229
|
-
# Add your environment variables here
|
|
230
|
-
# Example:
|
|
231
|
-
# {{constantName}}_API_KEY=your-api-key
|
|
232
|
-
# {{constantName}}_TIMEOUT=5000
|
|
233
|
-
\`\`\`
|
|
234
|
-
|
|
235
|
-
The plugin's configuration is located in \`plugins/{{name}}/config/index.ts\` and is self-contained, making the plugin fully portable.
|
|
236
|
-
|
|
237
159
|
## Usage
|
|
238
160
|
|
|
239
161
|
\`\`\`typescript
|
|
240
162
|
// The plugin is automatically loaded by FluxStack
|
|
241
|
-
//
|
|
163
|
+
// Configure it in your app/server/index.ts if needed
|
|
242
164
|
\`\`\`
|
|
243
165
|
|
|
166
|
+
## Configuration
|
|
167
|
+
|
|
168
|
+
Add configuration options here.
|
|
169
|
+
|
|
244
170
|
## API
|
|
245
171
|
|
|
246
172
|
Document your plugin's API here.
|
|
@@ -258,8 +184,8 @@ This plugin uses the following hooks:
|
|
|
258
184
|
|
|
259
185
|
To modify this plugin:
|
|
260
186
|
|
|
261
|
-
1. Edit \`
|
|
262
|
-
2.
|
|
187
|
+
1. Edit \`index.ts\` with your logic
|
|
188
|
+
2. Update \`plugin.json\` with metadata
|
|
263
189
|
3. Test with: \`bun run dev\`
|
|
264
190
|
|
|
265
191
|
## License
|
|
@@ -278,60 +204,7 @@ MIT
|
|
|
278
204
|
name: 'server-plugin',
|
|
279
205
|
description: 'Plugin with server-side code',
|
|
280
206
|
files: [
|
|
281
|
-
|
|
282
|
-
path: 'plugins/{{name}}/package.json',
|
|
283
|
-
content: `{
|
|
284
|
-
"name": "@fluxstack/{{name}}-plugin",
|
|
285
|
-
"version": "1.0.0",
|
|
286
|
-
"description": "{{description}}",
|
|
287
|
-
"main": "index.ts",
|
|
288
|
-
"types": "index.ts",
|
|
289
|
-
"exports": {
|
|
290
|
-
".": {
|
|
291
|
-
"import": "./index.ts",
|
|
292
|
-
"types": "./index.ts"
|
|
293
|
-
},
|
|
294
|
-
"./config": {
|
|
295
|
-
"import": "./config/index.ts",
|
|
296
|
-
"types": "./config/index.ts"
|
|
297
|
-
},
|
|
298
|
-
"./server": {
|
|
299
|
-
"import": "./server/index.ts",
|
|
300
|
-
"types": "./server/index.ts"
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
"keywords": [
|
|
304
|
-
"fluxstack",
|
|
305
|
-
"plugin",
|
|
306
|
-
"{{name}}",
|
|
307
|
-
"server",
|
|
308
|
-
"typescript"
|
|
309
|
-
],
|
|
310
|
-
"author": "FluxStack Developer",
|
|
311
|
-
"license": "MIT",
|
|
312
|
-
"peerDependencies": {
|
|
313
|
-
"elysia": "^1.0.0"
|
|
314
|
-
},
|
|
315
|
-
"dependencies": {},
|
|
316
|
-
"devDependencies": {
|
|
317
|
-
"typescript": "^5.0.0"
|
|
318
|
-
},
|
|
319
|
-
"fluxstack": {
|
|
320
|
-
"plugin": true,
|
|
321
|
-
"version": "^1.0.0",
|
|
322
|
-
"hooks": [
|
|
323
|
-
"setup",
|
|
324
|
-
"onServerStart",
|
|
325
|
-
"onRequest",
|
|
326
|
-
"onResponse"
|
|
327
|
-
],
|
|
328
|
-
"category": "utility",
|
|
329
|
-
"tags": ["{{name}}", "server"]
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
`
|
|
333
|
-
},
|
|
334
|
-
...basic.files.slice(1), // Skip package.json from basic
|
|
207
|
+
...basic.files,
|
|
335
208
|
{
|
|
336
209
|
path: 'plugins/{{name}}/server/index.ts',
|
|
337
210
|
content: `/**
|
|
@@ -360,65 +233,7 @@ export const {{camelName}}Service = new {{pascalName}}Service()
|
|
|
360
233
|
name: 'client-plugin',
|
|
361
234
|
description: 'Plugin with client-side code',
|
|
362
235
|
files: [
|
|
363
|
-
|
|
364
|
-
path: 'plugins/{{name}}/package.json',
|
|
365
|
-
content: `{
|
|
366
|
-
"name": "@fluxstack/{{name}}-plugin",
|
|
367
|
-
"version": "1.0.0",
|
|
368
|
-
"description": "{{description}}",
|
|
369
|
-
"main": "index.ts",
|
|
370
|
-
"types": "index.ts",
|
|
371
|
-
"exports": {
|
|
372
|
-
".": {
|
|
373
|
-
"import": "./index.ts",
|
|
374
|
-
"types": "./index.ts"
|
|
375
|
-
},
|
|
376
|
-
"./config": {
|
|
377
|
-
"import": "./config/index.ts",
|
|
378
|
-
"types": "./config/index.ts"
|
|
379
|
-
},
|
|
380
|
-
"./client": {
|
|
381
|
-
"import": "./client/index.ts",
|
|
382
|
-
"types": "./client/index.ts"
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
"keywords": [
|
|
386
|
-
"fluxstack",
|
|
387
|
-
"plugin",
|
|
388
|
-
"{{name}}",
|
|
389
|
-
"react",
|
|
390
|
-
"client",
|
|
391
|
-
"typescript"
|
|
392
|
-
],
|
|
393
|
-
"author": "FluxStack Developer",
|
|
394
|
-
"license": "MIT",
|
|
395
|
-
"peerDependencies": {
|
|
396
|
-
"react": ">=16.8.0"
|
|
397
|
-
},
|
|
398
|
-
"peerDependenciesMeta": {
|
|
399
|
-
"react": {
|
|
400
|
-
"optional": true
|
|
401
|
-
}
|
|
402
|
-
},
|
|
403
|
-
"dependencies": {},
|
|
404
|
-
"devDependencies": {
|
|
405
|
-
"@types/react": "^18.0.0",
|
|
406
|
-
"typescript": "^5.0.0"
|
|
407
|
-
},
|
|
408
|
-
"fluxstack": {
|
|
409
|
-
"plugin": true,
|
|
410
|
-
"version": "^1.0.0",
|
|
411
|
-
"hooks": [
|
|
412
|
-
"setup",
|
|
413
|
-
"onServerStart"
|
|
414
|
-
],
|
|
415
|
-
"category": "utility",
|
|
416
|
-
"tags": ["{{name}}", "client", "react"]
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
`
|
|
420
|
-
},
|
|
421
|
-
...basic.files.slice(1), // Skip package.json from basic
|
|
236
|
+
...basic.files,
|
|
422
237
|
{
|
|
423
238
|
path: 'plugins/{{name}}/client/index.ts',
|
|
424
239
|
content: `/**
|
|
@@ -450,127 +265,22 @@ export const {{camelName}}Client = new {{pascalName}}Client()
|
|
|
450
265
|
name: 'full-plugin',
|
|
451
266
|
description: 'Complete plugin with server and client code',
|
|
452
267
|
files: [
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
"name": "@fluxstack/{{name}}-plugin",
|
|
457
|
-
"version": "1.0.0",
|
|
458
|
-
"description": "{{description}}",
|
|
459
|
-
"main": "index.ts",
|
|
460
|
-
"types": "index.ts",
|
|
461
|
-
"exports": {
|
|
462
|
-
".": {
|
|
463
|
-
"import": "./index.ts",
|
|
464
|
-
"types": "./index.ts"
|
|
465
|
-
},
|
|
466
|
-
"./config": {
|
|
467
|
-
"import": "./config/index.ts",
|
|
468
|
-
"types": "./config/index.ts"
|
|
469
|
-
},
|
|
470
|
-
"./server": {
|
|
471
|
-
"import": "./server/index.ts",
|
|
472
|
-
"types": "./server/index.ts"
|
|
473
|
-
},
|
|
474
|
-
"./client": {
|
|
475
|
-
"import": "./client/index.ts",
|
|
476
|
-
"types": "./client/index.ts"
|
|
477
|
-
},
|
|
478
|
-
"./types": {
|
|
479
|
-
"import": "./types.ts",
|
|
480
|
-
"types": "./types.ts"
|
|
481
|
-
}
|
|
482
|
-
},
|
|
483
|
-
"keywords": [
|
|
484
|
-
"fluxstack",
|
|
485
|
-
"plugin",
|
|
486
|
-
"{{name}}",
|
|
487
|
-
"react",
|
|
488
|
-
"server",
|
|
489
|
-
"client",
|
|
490
|
-
"typescript"
|
|
491
|
-
],
|
|
492
|
-
"author": "FluxStack Developer",
|
|
493
|
-
"license": "MIT",
|
|
494
|
-
"peerDependencies": {
|
|
495
|
-
"react": ">=16.8.0",
|
|
496
|
-
"elysia": "^1.0.0"
|
|
497
|
-
},
|
|
498
|
-
"peerDependenciesMeta": {
|
|
499
|
-
"react": {
|
|
500
|
-
"optional": true
|
|
501
|
-
}
|
|
502
|
-
},
|
|
503
|
-
"dependencies": {},
|
|
504
|
-
"devDependencies": {
|
|
505
|
-
"@types/react": "^18.0.0",
|
|
506
|
-
"typescript": "^5.0.0"
|
|
507
|
-
},
|
|
508
|
-
"fluxstack": {
|
|
509
|
-
"plugin": true,
|
|
510
|
-
"version": "^1.0.0",
|
|
511
|
-
"hooks": [
|
|
512
|
-
"setup",
|
|
513
|
-
"onServerStart",
|
|
514
|
-
"onRequest",
|
|
515
|
-
"onResponse",
|
|
516
|
-
"onError"
|
|
517
|
-
],
|
|
518
|
-
"category": "utility",
|
|
519
|
-
"tags": ["{{name}}", "server", "client", "react"]
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
`
|
|
523
|
-
},
|
|
524
|
-
...basic.files.slice(1), // Skip package.json from basic
|
|
525
|
-
{
|
|
526
|
-
path: 'plugins/{{name}}/server/index.ts',
|
|
527
|
-
content: `/**
|
|
528
|
-
* Server-side logic for {{pascalName}} plugin
|
|
529
|
-
*/
|
|
530
|
-
|
|
531
|
-
export class {{pascalName}}Service {
|
|
532
|
-
async initialize() {
|
|
533
|
-
console.log(\`[{{name}}] Server service initialized\`)
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// Add your server-side methods here
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
export const {{camelName}}Service = new {{pascalName}}Service()
|
|
540
|
-
`
|
|
541
|
-
},
|
|
542
|
-
{
|
|
543
|
-
path: 'plugins/{{name}}/client/index.ts',
|
|
544
|
-
content: `/**
|
|
545
|
-
* Client-side logic for {{pascalName}} plugin
|
|
546
|
-
*/
|
|
547
|
-
|
|
548
|
-
export class {{pascalName}}Client {
|
|
549
|
-
initialize() {
|
|
550
|
-
console.log(\`[{{name}}] Client initialized\`)
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
// Add your client-side methods here
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
export const {{camelName}}Client = new {{pascalName}}Client()
|
|
557
|
-
`
|
|
558
|
-
},
|
|
268
|
+
...basic.files,
|
|
269
|
+
...server.files.slice(basic.files.length), // Add server files
|
|
270
|
+
...client.files.slice(basic.files.length), // Add client files
|
|
559
271
|
{
|
|
560
272
|
path: 'plugins/{{name}}/types.ts',
|
|
561
273
|
content: `/**
|
|
562
274
|
* Type definitions for {{pascalName}} plugin
|
|
563
275
|
*/
|
|
564
276
|
|
|
565
|
-
|
|
566
|
-
//
|
|
567
|
-
|
|
568
|
-
export interface {{pascalName}}Options {
|
|
569
|
-
// Add your runtime options types here
|
|
277
|
+
export interface {{pascalName}}Config {
|
|
278
|
+
// Add your configuration types here
|
|
279
|
+
enabled: boolean
|
|
570
280
|
}
|
|
571
281
|
|
|
572
|
-
export interface {{pascalName}}
|
|
573
|
-
// Add your
|
|
282
|
+
export interface {{pascalName}}Options {
|
|
283
|
+
// Add your options types here
|
|
574
284
|
}
|
|
575
285
|
`
|
|
576
286
|
}
|
|
@@ -85,7 +85,6 @@ export class TemplateEngine {
|
|
|
85
85
|
camelName: this.toCamelCase(options.name),
|
|
86
86
|
pascalName: this.toPascalCase(options.name),
|
|
87
87
|
snakeName: this.toSnakeCase(options.name),
|
|
88
|
-
constantName: this.toConstantCase(options.name), // SCREAMING_SNAKE_CASE
|
|
89
88
|
timestamp: new Date().toISOString(),
|
|
90
89
|
date: new Date().toLocaleDateString(),
|
|
91
90
|
year: new Date().getFullYear(),
|
|
@@ -150,10 +149,6 @@ export class TemplateEngine {
|
|
|
150
149
|
.replace(/[\s-]+/g, '_')
|
|
151
150
|
.toLowerCase()
|
|
152
151
|
}
|
|
153
|
-
|
|
154
|
-
private toConstantCase(str: string): string {
|
|
155
|
-
return this.toSnakeCase(str).toUpperCase()
|
|
156
|
-
}
|
|
157
152
|
}
|
|
158
153
|
|
|
159
154
|
export const templateEngine = new TemplateEngine()
|