create-fluxstack 1.16.0 → 1.17.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/CHANGELOG.md +80 -0
- package/app/client/src/App.tsx +8 -0
- package/app/client/src/live/AuthDemo.tsx +4 -4
- package/core/build/bundler.ts +40 -26
- package/core/build/flux-plugins-generator.ts +325 -325
- package/core/build/index.ts +92 -21
- package/core/cli/command-registry.ts +44 -46
- package/core/cli/commands/build.ts +11 -6
- package/core/cli/commands/create.ts +7 -5
- package/core/cli/commands/dev.ts +6 -5
- package/core/cli/commands/help.ts +3 -2
- package/core/cli/commands/make-plugin.ts +8 -7
- package/core/cli/commands/plugin-add.ts +60 -43
- package/core/cli/commands/plugin-deps.ts +73 -57
- package/core/cli/commands/plugin-list.ts +44 -41
- package/core/cli/commands/plugin-remove.ts +33 -22
- package/core/cli/generators/component.ts +770 -769
- package/core/cli/generators/controller.ts +9 -8
- package/core/cli/generators/index.ts +148 -146
- package/core/cli/generators/interactive.ts +228 -227
- package/core/cli/generators/plugin.ts +11 -10
- package/core/cli/generators/prompts.ts +83 -82
- package/core/cli/generators/route.ts +7 -6
- package/core/cli/generators/service.ts +10 -9
- package/core/cli/generators/template-engine.ts +2 -1
- package/core/cli/generators/types.ts +7 -7
- package/core/cli/generators/utils.ts +191 -191
- package/core/cli/index.ts +9 -8
- package/core/cli/plugin-discovery.ts +2 -2
- package/core/client/hooks/useAuth.ts +48 -48
- package/core/client/standalone.ts +18 -17
- package/core/client/state/createStore.ts +192 -192
- package/core/client/state/index.ts +14 -14
- package/core/config/index.ts +1 -0
- package/core/framework/client.ts +131 -131
- package/core/framework/index.ts +7 -7
- package/core/framework/server.ts +73 -113
- package/core/framework/types.ts +2 -2
- package/core/plugins/built-in/live-components/commands/create-live-component.ts +6 -3
- package/core/plugins/built-in/monitoring/index.ts +110 -68
- package/core/plugins/built-in/static/index.ts +2 -2
- package/core/plugins/built-in/swagger/index.ts +9 -9
- package/core/plugins/built-in/vite/index.ts +3 -3
- package/core/plugins/built-in/vite/vite-dev.ts +3 -3
- package/core/plugins/config.ts +50 -47
- package/core/plugins/discovery.ts +10 -4
- package/core/plugins/executor.ts +2 -2
- package/core/plugins/index.ts +206 -203
- package/core/plugins/manager.ts +21 -20
- package/core/plugins/registry.ts +76 -12
- package/core/plugins/types.ts +14 -14
- package/core/server/framework.ts +3 -189
- package/core/server/live/auto-generated-components.ts +11 -29
- package/core/server/live/index.ts +41 -31
- package/core/server/live/websocket-plugin.ts +11 -1
- package/core/server/middleware/elysia-helpers.ts +16 -15
- package/core/server/middleware/errorHandling.ts +14 -14
- package/core/server/middleware/index.ts +31 -31
- package/core/server/plugins/database.ts +181 -180
- package/core/server/plugins/static-files-plugin.ts +4 -3
- package/core/server/plugins/swagger.ts +11 -8
- package/core/server/rooms/RoomBroadcaster.ts +11 -10
- package/core/server/rooms/RoomSystem.ts +14 -11
- package/core/server/services/BaseService.ts +7 -7
- package/core/server/services/ServiceContainer.ts +5 -5
- package/core/server/services/index.ts +8 -8
- package/core/templates/create-project.ts +28 -27
- package/core/testing/index.ts +9 -9
- package/core/testing/setup.ts +73 -73
- package/core/types/api.ts +168 -168
- package/core/types/config.ts +5 -5
- package/core/types/index.ts +1 -1
- package/core/types/plugin.ts +2 -2
- package/core/types/types.ts +3 -3
- package/core/utils/build-logger.ts +324 -324
- package/core/utils/config-schema.ts +480 -480
- package/core/utils/env.ts +10 -8
- package/core/utils/errors/codes.ts +114 -114
- package/core/utils/errors/handlers.ts +30 -20
- package/core/utils/errors/index.ts +54 -46
- package/core/utils/errors/middleware.ts +113 -113
- package/core/utils/helpers.ts +19 -16
- package/core/utils/logger/colors.ts +114 -114
- package/core/utils/logger/config.ts +2 -2
- package/core/utils/logger/formatter.ts +82 -82
- package/core/utils/logger/group-logger.ts +101 -101
- package/core/utils/logger/index.ts +13 -3
- package/core/utils/logger/startup-banner.ts +2 -2
- package/core/utils/logger/winston-logger.ts +152 -152
- package/core/utils/monitoring/index.ts +211 -211
- package/core/utils/sync-version.ts +67 -66
- package/core/utils/version.ts +1 -1
- package/package.json +104 -100
- package/playwright-report/index.html +85 -0
- package/playwright.config.ts +31 -0
- package/plugins/crypto-auth/client/CryptoAuthClient.ts +302 -302
- package/plugins/crypto-auth/client/components/index.ts +11 -11
- package/plugins/crypto-auth/client/index.ts +11 -11
- package/plugins/crypto-auth/package.json +65 -65
- package/plugins/crypto-auth/server/CryptoAuthService.ts +185 -185
- package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +6 -5
- package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +6 -5
- package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +3 -3
- package/plugins/crypto-auth/server/middlewares/index.ts +22 -22
- package/plugins/crypto-auth/server/middlewares.ts +19 -19
- package/vite.config.ts +13 -0
- package/app/client/.live-stubs/LiveAdminPanel.js +0 -5
- package/app/client/.live-stubs/LiveCounter.js +0 -9
- package/app/client/.live-stubs/LiveForm.js +0 -11
- package/app/client/.live-stubs/LiveLocalCounter.js +0 -8
- package/app/client/.live-stubs/LivePingPong.js +0 -10
- package/app/client/.live-stubs/LiveRoomChat.js +0 -11
- package/app/client/.live-stubs/LiveSharedCounter.js +0 -10
- package/app/client/.live-stubs/LiveUpload.js +0 -15
- package/app/server/live/register-components.ts +0 -19
- package/core/build/live-components-generator.ts +0 -321
- package/core/live/ComponentRegistry.ts +0 -403
- package/core/live/types.ts +0 -241
- package/workspace.json +0 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Generator } from "./index"
|
|
2
2
|
import type { GeneratorContext, GeneratorOptions, Template } from "./types"
|
|
3
3
|
import { templateEngine } from "./template-engine"
|
|
4
|
+
import { buildLogger } from "@core/utils/build-logger"
|
|
4
5
|
|
|
5
6
|
export class ControllerGenerator implements Generator {
|
|
6
7
|
name = 'controller'
|
|
@@ -17,9 +18,9 @@ export class ControllerGenerator implements Generator {
|
|
|
17
18
|
const files = await templateEngine.processTemplate(template, context, options)
|
|
18
19
|
|
|
19
20
|
if (options.dryRun) {
|
|
20
|
-
|
|
21
|
+
buildLogger.info(`\n📋 Would generate controller '${options.name}':\n`)
|
|
21
22
|
for (const file of files) {
|
|
22
|
-
|
|
23
|
+
buildLogger.info(`${file.action === 'create' ? '📄' : '✏️'} ${file.path}`)
|
|
23
24
|
}
|
|
24
25
|
return
|
|
25
26
|
}
|
|
@@ -32,7 +33,7 @@ export class ControllerGenerator implements Generator {
|
|
|
32
33
|
await template.hooks.afterGenerate(context, options, filePaths)
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
buildLogger.success(`Generated controller '${options.name}' with ${files.length} files`)
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
private getTemplate(templateName?: string): Template {
|
|
@@ -121,10 +122,10 @@ export class {{pascalName}}Controller {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
async create({ body }: { body:
|
|
125
|
+
async create({ body }: { body: Record<string, unknown> }) {
|
|
125
126
|
try {
|
|
126
127
|
const {{camelName}} = await this.service.create(body)
|
|
127
|
-
|
|
128
|
+
|
|
128
129
|
return {
|
|
129
130
|
success: true,
|
|
130
131
|
data: {{camelName}},
|
|
@@ -138,7 +139,7 @@ export class {{pascalName}}Controller {
|
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
141
|
|
|
141
|
-
async update({ params, body }: { params: { id: string }, body:
|
|
142
|
+
async update({ params, body }: { params: { id: string }, body: Record<string, unknown> }) {
|
|
142
143
|
try {
|
|
143
144
|
const {{camelName}} = await this.service.update(params.id, body)
|
|
144
145
|
|
|
@@ -265,7 +266,7 @@ export class {{pascalName}}Controller {
|
|
|
265
266
|
}
|
|
266
267
|
}
|
|
267
268
|
|
|
268
|
-
async create({ body }: { body:
|
|
269
|
+
async create({ body }: { body: Record<string, unknown> }) {
|
|
269
270
|
// TODO: Implement create logic
|
|
270
271
|
return {
|
|
271
272
|
success: true,
|
|
@@ -274,7 +275,7 @@ export class {{pascalName}}Controller {
|
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
277
|
|
|
277
|
-
async update({ params, body }: { params: { id: string }, body:
|
|
278
|
+
async update({ params, body }: { params: { id: string }, body: Record<string, unknown> }) {
|
|
278
279
|
// TODO: Implement update logic
|
|
279
280
|
return {
|
|
280
281
|
success: true,
|
|
@@ -1,147 +1,149 @@
|
|
|
1
|
-
import type { CliCommand } from "../../plugins/types"
|
|
2
|
-
import { ControllerGenerator } from "./controller"
|
|
3
|
-
import { RouteGenerator } from "./route"
|
|
4
|
-
import { ComponentGenerator } from "./component"
|
|
5
|
-
import { ServiceGenerator } from "./service"
|
|
6
|
-
import { PluginGenerator } from "./plugin"
|
|
7
|
-
import type { GeneratorContext, GeneratorOptions } from "./types"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.register(new
|
|
25
|
-
this.register(new
|
|
26
|
-
this.register(new
|
|
27
|
-
this.register(new
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'flux generate
|
|
62
|
-
'flux generate
|
|
63
|
-
'flux generate
|
|
64
|
-
'flux generate
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
1
|
+
import type { CliCommand } from "../../plugins/types"
|
|
2
|
+
import { ControllerGenerator } from "./controller"
|
|
3
|
+
import { RouteGenerator } from "./route"
|
|
4
|
+
import { ComponentGenerator } from "./component"
|
|
5
|
+
import { ServiceGenerator } from "./service"
|
|
6
|
+
import { PluginGenerator } from "./plugin"
|
|
7
|
+
import type { GeneratorContext, GeneratorOptions } from "./types"
|
|
8
|
+
import { buildLogger } from "@core/utils/build-logger"
|
|
9
|
+
|
|
10
|
+
export interface Generator {
|
|
11
|
+
name: string
|
|
12
|
+
description: string
|
|
13
|
+
generate(context: GeneratorContext, options: GeneratorOptions): Promise<void>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class GeneratorRegistry {
|
|
17
|
+
private generators = new Map<string, Generator>()
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
this.registerBuiltInGenerators()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private registerBuiltInGenerators() {
|
|
24
|
+
this.register(new ControllerGenerator())
|
|
25
|
+
this.register(new RouteGenerator())
|
|
26
|
+
this.register(new ComponentGenerator())
|
|
27
|
+
this.register(new ServiceGenerator())
|
|
28
|
+
this.register(new PluginGenerator())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
register(generator: Generator): void {
|
|
32
|
+
this.generators.set(generator.name, generator)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get(name: string): Generator | undefined {
|
|
36
|
+
return this.generators.get(name)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getAll(): Generator[] {
|
|
40
|
+
return Array.from(this.generators.values())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
has(name: string): boolean {
|
|
44
|
+
return this.generators.has(name)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const generatorRegistry = new GeneratorRegistry()
|
|
49
|
+
|
|
50
|
+
// Export additional commands
|
|
51
|
+
export { interactiveGenerateCommand } from "./interactive"
|
|
52
|
+
|
|
53
|
+
// CLI command for code generation
|
|
54
|
+
export const generateCommand: CliCommand = {
|
|
55
|
+
name: 'generate',
|
|
56
|
+
description: 'Generate code from templates',
|
|
57
|
+
usage: 'flux generate <type> <name> [options]',
|
|
58
|
+
aliases: ['g', 'gen'],
|
|
59
|
+
category: 'Development',
|
|
60
|
+
examples: [
|
|
61
|
+
'flux generate controller user',
|
|
62
|
+
'flux generate component UserCard',
|
|
63
|
+
'flux generate service auth',
|
|
64
|
+
'flux generate route api/users',
|
|
65
|
+
'flux generate plugin my-plugin'
|
|
66
|
+
],
|
|
67
|
+
arguments: [
|
|
68
|
+
{
|
|
69
|
+
name: 'type',
|
|
70
|
+
description: 'Type of code to generate',
|
|
71
|
+
required: true,
|
|
72
|
+
type: 'string',
|
|
73
|
+
choices: ['controller', 'route', 'component', 'service', 'plugin']
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'name',
|
|
77
|
+
description: 'Name of the generated item',
|
|
78
|
+
required: true,
|
|
79
|
+
type: 'string'
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
options: [
|
|
83
|
+
{
|
|
84
|
+
name: 'path',
|
|
85
|
+
short: 'p',
|
|
86
|
+
description: 'Custom path for generated files',
|
|
87
|
+
type: 'string'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'template',
|
|
91
|
+
short: 't',
|
|
92
|
+
description: 'Template variant to use',
|
|
93
|
+
type: 'string'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'force',
|
|
97
|
+
short: 'f',
|
|
98
|
+
description: 'Overwrite existing files',
|
|
99
|
+
type: 'boolean',
|
|
100
|
+
default: false
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'dry-run',
|
|
104
|
+
description: 'Show what would be generated without creating files',
|
|
105
|
+
type: 'boolean',
|
|
106
|
+
default: false
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
handler: async (args, options, context) => {
|
|
110
|
+
const type = args[0] as string
|
|
111
|
+
const name = args[1] as string
|
|
112
|
+
|
|
113
|
+
const generator = generatorRegistry.get(type)
|
|
114
|
+
if (!generator) {
|
|
115
|
+
buildLogger.error(`Unknown generator type: ${type}`)
|
|
116
|
+
buildLogger.info('\nAvailable generators:')
|
|
117
|
+
for (const gen of generatorRegistry.getAll()) {
|
|
118
|
+
buildLogger.info(` ${gen.name.padEnd(12)} ${gen.description}`)
|
|
119
|
+
}
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const generatorContext: GeneratorContext = {
|
|
124
|
+
workingDir: context.workingDir,
|
|
125
|
+
config: context.config,
|
|
126
|
+
logger: context.logger,
|
|
127
|
+
utils: context.utils
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const generatorOptions: GeneratorOptions = {
|
|
131
|
+
name,
|
|
132
|
+
path: options.path as string | undefined,
|
|
133
|
+
template: options.template as string | undefined,
|
|
134
|
+
force: options.force as boolean | undefined,
|
|
135
|
+
dryRun: options['dry-run'] as boolean | undefined
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
await generator.generate(generatorContext, generatorOptions)
|
|
140
|
+
|
|
141
|
+
if (!options['dry-run']) {
|
|
142
|
+
buildLogger.success(`Successfully generated ${type}: ${name}`)
|
|
143
|
+
}
|
|
144
|
+
} catch (error) {
|
|
145
|
+
buildLogger.error(`Failed to generate ${type}: ${error instanceof Error ? error.message : String(error)}`)
|
|
146
|
+
throw error
|
|
147
|
+
}
|
|
148
|
+
}
|
|
147
149
|
}
|