create-fluxstack 1.16.0 ā 1.17.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/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 +72 -112
- 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
|
@@ -7,7 +7,7 @@ import { Command } from 'commander'
|
|
|
7
7
|
import { readFileSync, writeFileSync, existsSync } from 'fs'
|
|
8
8
|
import { join } from 'path'
|
|
9
9
|
import { $ } from 'bun'
|
|
10
|
-
import
|
|
10
|
+
import { buildLogger } from '@core/utils/build-logger'
|
|
11
11
|
|
|
12
12
|
interface PluginAddOptions {
|
|
13
13
|
skipAudit?: boolean
|
|
@@ -21,26 +21,29 @@ export function createPluginAddCommand(): Command {
|
|
|
21
21
|
.option('--skip-audit', 'Skip npm audit check')
|
|
22
22
|
.option('--skip-confirmation', 'Skip confirmation prompt')
|
|
23
23
|
.action(async (pluginName: string, options: PluginAddOptions) => {
|
|
24
|
-
|
|
24
|
+
buildLogger.info('')
|
|
25
|
+
buildLogger.info('š FluxStack Plugin Installer')
|
|
26
|
+
buildLogger.info('')
|
|
25
27
|
|
|
26
28
|
try {
|
|
27
29
|
// 1. Validate plugin name
|
|
28
30
|
if (!isValidPluginName(pluginName)) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
buildLogger.error(`ā Invalid plugin name: ${pluginName}`)
|
|
32
|
+
buildLogger.info('')
|
|
33
|
+
buildLogger.info('š Valid plugin names:')
|
|
34
|
+
buildLogger.info(' - fluxstack-plugin-*')
|
|
35
|
+
buildLogger.info(' - fplugin-*')
|
|
36
|
+
buildLogger.info(' - @fluxstack/plugin-*')
|
|
37
|
+
buildLogger.info(' - @fplugin/*')
|
|
38
|
+
buildLogger.info(' - @org/fluxstack-plugin-*')
|
|
39
|
+
buildLogger.info(' - @org/fplugin-*')
|
|
37
40
|
process.exit(1)
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
// 2. Check if plugin already installed
|
|
41
44
|
const packageJsonPath = join(process.cwd(), 'package.json')
|
|
42
45
|
if (!existsSync(packageJsonPath)) {
|
|
43
|
-
|
|
46
|
+
buildLogger.error('ā package.json not found')
|
|
44
47
|
process.exit(1)
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -50,69 +53,83 @@ export function createPluginAddCommand(): Command {
|
|
|
50
53
|
packageJson.devDependencies?.[pluginName]
|
|
51
54
|
|
|
52
55
|
if (isAlreadyInstalled && !options.skipConfirmation) {
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
buildLogger.warn(`ā ļø Plugin ${pluginName} is already installed`)
|
|
57
|
+
buildLogger.warn(' Will only update whitelist')
|
|
58
|
+
buildLogger.info('')
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
// 3. Audit plugin (unless skipped)
|
|
58
62
|
if (!options.skipAudit && !isAlreadyInstalled) {
|
|
59
|
-
|
|
63
|
+
buildLogger.info('š Auditing plugin security...')
|
|
64
|
+
buildLogger.info('')
|
|
60
65
|
|
|
61
66
|
try {
|
|
62
67
|
// Get plugin info
|
|
63
68
|
const info = await $`npm view ${pluginName} repository homepage version description`.text()
|
|
64
|
-
|
|
69
|
+
buildLogger.info(info)
|
|
65
70
|
|
|
66
71
|
// Run audit
|
|
67
|
-
|
|
72
|
+
buildLogger.info('')
|
|
73
|
+
buildLogger.info('š”ļø Running npm audit...')
|
|
74
|
+
buildLogger.info('')
|
|
68
75
|
const auditResult = await $`npm audit ${pluginName}`.text()
|
|
69
|
-
|
|
76
|
+
buildLogger.info(auditResult)
|
|
70
77
|
} catch (error) {
|
|
71
|
-
|
|
78
|
+
buildLogger.warn(`ā ļø Could not audit plugin: ${error instanceof Error ? error.message : 'Unknown error'}`)
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
// 4. Confirmation prompt (unless skipped)
|
|
76
83
|
if (!options.skipConfirmation) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
buildLogger.warn('')
|
|
85
|
+
buildLogger.warn('ā ļø Security Warning:')
|
|
86
|
+
buildLogger.warn(' NPM plugins can execute arbitrary code')
|
|
87
|
+
buildLogger.warn(' Only install plugins from trusted sources')
|
|
88
|
+
buildLogger.info('')
|
|
80
89
|
|
|
81
|
-
const answer = prompt(
|
|
90
|
+
const answer = prompt('Continue with installation? (yes/no): ')
|
|
82
91
|
if (answer?.toLowerCase() !== 'yes' && answer?.toLowerCase() !== 'y') {
|
|
83
|
-
|
|
92
|
+
buildLogger.error('ā Installation cancelled')
|
|
84
93
|
process.exit(0)
|
|
85
94
|
}
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
// 5. Install plugin
|
|
89
98
|
if (!isAlreadyInstalled) {
|
|
90
|
-
|
|
99
|
+
buildLogger.info('')
|
|
100
|
+
buildLogger.info(`š¦ Installing ${pluginName}...`)
|
|
101
|
+
buildLogger.info('')
|
|
91
102
|
await $`bun add ${pluginName}`.quiet()
|
|
92
|
-
|
|
103
|
+
buildLogger.success('ā
Plugin installed successfully')
|
|
93
104
|
}
|
|
94
105
|
|
|
95
106
|
// 6. Update .env file
|
|
96
|
-
|
|
107
|
+
buildLogger.info('')
|
|
108
|
+
buildLogger.info('š§ Updating configuration...')
|
|
109
|
+
buildLogger.info('')
|
|
97
110
|
updateEnvFile(pluginName)
|
|
98
111
|
|
|
99
112
|
// 7. Success message
|
|
100
|
-
|
|
101
|
-
|
|
113
|
+
buildLogger.success('')
|
|
114
|
+
buildLogger.success('ā
Plugin setup complete!')
|
|
115
|
+
buildLogger.info('')
|
|
116
|
+
buildLogger.info('š What was done:')
|
|
102
117
|
if (!isAlreadyInstalled) {
|
|
103
|
-
|
|
118
|
+
buildLogger.info(` ⢠Installed ${pluginName}`)
|
|
104
119
|
}
|
|
105
|
-
|
|
106
|
-
|
|
120
|
+
buildLogger.info(' ⢠Enabled NPM plugin discovery (PLUGINS_DISCOVER_NPM=true)')
|
|
121
|
+
buildLogger.info(` ⢠Added ${pluginName} to whitelist (PLUGINS_ALLOWED)`)
|
|
107
122
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
buildLogger.info('')
|
|
124
|
+
buildLogger.info('š Next steps:')
|
|
125
|
+
buildLogger.info(' 1. Restart your dev server: bun run dev')
|
|
126
|
+
buildLogger.info(' 2. Plugin will be auto-discovered and loaded')
|
|
127
|
+
buildLogger.info(' 3. Check logs for plugin initialization')
|
|
112
128
|
|
|
113
129
|
} catch (error) {
|
|
114
|
-
|
|
115
|
-
|
|
130
|
+
buildLogger.error('')
|
|
131
|
+
buildLogger.error('ā Failed to install plugin:')
|
|
132
|
+
buildLogger.error(error instanceof Error ? error.message : String(error))
|
|
116
133
|
process.exit(1)
|
|
117
134
|
}
|
|
118
135
|
})
|
|
@@ -143,7 +160,7 @@ function updateEnvFile(pluginName: string): void {
|
|
|
143
160
|
const envPath = join(process.cwd(), '.env')
|
|
144
161
|
|
|
145
162
|
if (!existsSync(envPath)) {
|
|
146
|
-
|
|
163
|
+
buildLogger.warn('ā ļø .env file not found, creating...')
|
|
147
164
|
writeFileSync(envPath, '', 'utf-8')
|
|
148
165
|
}
|
|
149
166
|
|
|
@@ -157,11 +174,11 @@ function updateEnvFile(pluginName: string): void {
|
|
|
157
174
|
'PLUGINS_DISCOVER_NPM=true'
|
|
158
175
|
)
|
|
159
176
|
updated = true
|
|
160
|
-
|
|
177
|
+
buildLogger.info(' ⢠Set PLUGINS_DISCOVER_NPM=true')
|
|
161
178
|
} else if (!/^PLUGINS_DISCOVER_NPM=/m.test(envContent)) {
|
|
162
179
|
envContent += '\n# Plugin Discovery\nPLUGINS_DISCOVER_NPM=true\n'
|
|
163
180
|
updated = true
|
|
164
|
-
|
|
181
|
+
buildLogger.info(' ⢠Added PLUGINS_DISCOVER_NPM=true')
|
|
165
182
|
}
|
|
166
183
|
|
|
167
184
|
// 2. Add plugin to whitelist
|
|
@@ -181,14 +198,14 @@ function updateEnvFile(pluginName: string): void {
|
|
|
181
198
|
`PLUGINS_ALLOWED=${newPlugins}`
|
|
182
199
|
)
|
|
183
200
|
updated = true
|
|
184
|
-
|
|
201
|
+
buildLogger.info(` ⢠Added ${pluginName} to PLUGINS_ALLOWED`)
|
|
185
202
|
} else {
|
|
186
|
-
|
|
203
|
+
buildLogger.info(` ⢠${pluginName} already in PLUGINS_ALLOWED`)
|
|
187
204
|
}
|
|
188
205
|
} else {
|
|
189
206
|
envContent += `PLUGINS_ALLOWED=${pluginName}\n`
|
|
190
207
|
updated = true
|
|
191
|
-
|
|
208
|
+
buildLogger.info(` ⢠Created PLUGINS_ALLOWED with ${pluginName}`)
|
|
192
209
|
}
|
|
193
210
|
|
|
194
211
|
if (updated) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { Command } from 'commander'
|
|
6
|
-
import
|
|
6
|
+
import { buildLogger } from '@core/utils/build-logger'
|
|
7
7
|
import { PluginDependencyManager } from '@core/plugins/dependency-manager'
|
|
8
8
|
import { PluginRegistry } from '@core/plugins/registry'
|
|
9
9
|
import { existsSync, readFileSync } from 'fs'
|
|
@@ -26,17 +26,18 @@ function createInstallCommand(): Command {
|
|
|
26
26
|
.option('--dry-run', 'Mostrar o que seria instalado sem executar')
|
|
27
27
|
.option('--package-manager <pm>', 'Package manager a usar (npm, yarn, pnpm, bun)', 'bun')
|
|
28
28
|
.action(async (options) => {
|
|
29
|
-
|
|
29
|
+
buildLogger.info('š§ Instalando dependĆŖncias de plugins...')
|
|
30
|
+
buildLogger.info('')
|
|
30
31
|
|
|
31
32
|
try {
|
|
32
33
|
const dependencyManager = new PluginDependencyManager({
|
|
33
34
|
autoInstall: !options.dryRun,
|
|
34
35
|
packageManager: options.packageManager,
|
|
35
|
-
logger: createConsoleLogger()
|
|
36
|
+
logger: createConsoleLogger()
|
|
36
37
|
})
|
|
37
38
|
|
|
38
39
|
const registry = new PluginRegistry({
|
|
39
|
-
logger: createConsoleLogger()
|
|
40
|
+
logger: createConsoleLogger()
|
|
40
41
|
})
|
|
41
42
|
|
|
42
43
|
// Descobrir plugins
|
|
@@ -45,7 +46,8 @@ function createInstallCommand(): Command {
|
|
|
45
46
|
})
|
|
46
47
|
|
|
47
48
|
const successfulPlugins = results.filter(r => r.success)
|
|
48
|
-
|
|
49
|
+
buildLogger.success(`ā
Encontrados ${successfulPlugins.length} plugins`)
|
|
50
|
+
buildLogger.info('')
|
|
49
51
|
|
|
50
52
|
// Resolver dependĆŖncias
|
|
51
53
|
const resolutions = []
|
|
@@ -62,34 +64,34 @@ function createInstallCommand(): Command {
|
|
|
62
64
|
// Mostrar resumo
|
|
63
65
|
let totalDeps = 0
|
|
64
66
|
let totalConflicts = 0
|
|
65
|
-
|
|
67
|
+
|
|
66
68
|
for (const resolution of resolutions) {
|
|
67
69
|
totalDeps += resolution.dependencies.length
|
|
68
70
|
totalConflicts += resolution.conflicts.length
|
|
69
|
-
|
|
71
|
+
|
|
70
72
|
if (resolution.dependencies.length > 0) {
|
|
71
|
-
|
|
73
|
+
buildLogger.info(`š¦ ${resolution.plugin}:`)
|
|
72
74
|
for (const dep of resolution.dependencies) {
|
|
73
|
-
|
|
74
|
-
console.log(` ${typeColor(dep.name)}@${dep.version} (${dep.type})`)
|
|
75
|
+
buildLogger.info(` ${dep.name}@${dep.version} (${dep.type})`)
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
+
buildLogger.info('')
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
if (totalConflicts > 0) {
|
|
81
|
-
|
|
82
|
+
buildLogger.warn(`ā ļø ${totalConflicts} conflitos de dependĆŖncias detectados`)
|
|
83
|
+
buildLogger.info('')
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
if (options.dryRun) {
|
|
85
|
-
|
|
87
|
+
buildLogger.info(`š Dry run: ${totalDeps} dependĆŖncias seriam instaladas`)
|
|
86
88
|
} else {
|
|
87
89
|
await dependencyManager.installPluginDependencies(resolutions)
|
|
88
|
-
|
|
90
|
+
buildLogger.success(`ā
${totalDeps} dependĆŖncias instaladas com sucesso!`)
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
} catch (error) {
|
|
92
|
-
|
|
94
|
+
buildLogger.error('ā Erro ao instalar dependĆŖncias:', error)
|
|
93
95
|
process.exit(1)
|
|
94
96
|
}
|
|
95
97
|
})
|
|
@@ -100,11 +102,12 @@ function createListCommand(): Command {
|
|
|
100
102
|
.description('Listar dependĆŖncias de plugins')
|
|
101
103
|
.option('--plugin <name>', 'Mostrar apenas dependĆŖncias de um plugin especĆfico')
|
|
102
104
|
.action(async (options) => {
|
|
103
|
-
|
|
105
|
+
buildLogger.info('š DependĆŖncias de plugins:')
|
|
106
|
+
buildLogger.info('')
|
|
104
107
|
|
|
105
108
|
try {
|
|
106
109
|
const registry = new PluginRegistry({
|
|
107
|
-
logger: createConsoleLogger()
|
|
110
|
+
logger: createConsoleLogger()
|
|
108
111
|
})
|
|
109
112
|
|
|
110
113
|
const results = await registry.discoverPlugins({
|
|
@@ -113,7 +116,7 @@ function createListCommand(): Command {
|
|
|
113
116
|
|
|
114
117
|
const dependencyManager = new PluginDependencyManager({
|
|
115
118
|
autoInstall: false,
|
|
116
|
-
logger: createConsoleLogger()
|
|
119
|
+
logger: createConsoleLogger()
|
|
117
120
|
})
|
|
118
121
|
|
|
119
122
|
for (const result of results) {
|
|
@@ -125,30 +128,29 @@ function createListCommand(): Command {
|
|
|
125
128
|
const pluginDir = findPluginDirectory(result.plugin.name)
|
|
126
129
|
if (pluginDir) {
|
|
127
130
|
const resolution = await dependencyManager.resolvePluginDependencies(pluginDir)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
|
|
132
|
+
buildLogger.info(`š¦ ${resolution.plugin}`)
|
|
133
|
+
|
|
131
134
|
if (resolution.dependencies.length === 0) {
|
|
132
|
-
|
|
135
|
+
buildLogger.info(' Nenhuma dependĆŖncia')
|
|
133
136
|
} else {
|
|
134
137
|
for (const dep of resolution.dependencies) {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
console.log(` ${typeColor(dep.name)}@${dep.version} (${dep.type})${optional}`)
|
|
138
|
+
const optional = dep.optional ? ' (opcional)' : ''
|
|
139
|
+
buildLogger.info(` ${dep.name}@${dep.version} (${dep.type})${optional}`)
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
if (resolution.conflicts.length > 0) {
|
|
142
|
-
|
|
144
|
+
buildLogger.error(` ā ļø ${resolution.conflicts.length} conflitos`)
|
|
143
145
|
}
|
|
144
146
|
|
|
145
|
-
|
|
147
|
+
buildLogger.info('')
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
} catch (error) {
|
|
151
|
-
|
|
153
|
+
buildLogger.error('ā Erro ao listar dependĆŖncias:', error)
|
|
152
154
|
process.exit(1)
|
|
153
155
|
}
|
|
154
156
|
})
|
|
@@ -158,11 +160,12 @@ function createCheckCommand(): Command {
|
|
|
158
160
|
return new Command('check')
|
|
159
161
|
.description('Verificar conflitos de dependĆŖncias')
|
|
160
162
|
.action(async () => {
|
|
161
|
-
|
|
163
|
+
buildLogger.info('š Verificando conflitos de dependĆŖncias...')
|
|
164
|
+
buildLogger.info('')
|
|
162
165
|
|
|
163
166
|
try {
|
|
164
167
|
const registry = new PluginRegistry({
|
|
165
|
-
logger: createConsoleLogger()
|
|
168
|
+
logger: createConsoleLogger()
|
|
166
169
|
})
|
|
167
170
|
|
|
168
171
|
const results = await registry.discoverPlugins({
|
|
@@ -171,7 +174,7 @@ function createCheckCommand(): Command {
|
|
|
171
174
|
|
|
172
175
|
const dependencyManager = new PluginDependencyManager({
|
|
173
176
|
autoInstall: false,
|
|
174
|
-
logger: createConsoleLogger()
|
|
177
|
+
logger: createConsoleLogger()
|
|
175
178
|
})
|
|
176
179
|
|
|
177
180
|
const resolutions = []
|
|
@@ -186,26 +189,27 @@ function createCheckCommand(): Command {
|
|
|
186
189
|
}
|
|
187
190
|
|
|
188
191
|
const allConflicts = resolutions.flatMap(r => r.conflicts)
|
|
189
|
-
|
|
192
|
+
|
|
190
193
|
if (allConflicts.length === 0) {
|
|
191
|
-
|
|
194
|
+
buildLogger.success('ā
Nenhum conflito de dependĆŖncias encontrado!')
|
|
192
195
|
} else {
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
buildLogger.error(`ā ${allConflicts.length} conflitos encontrados:`)
|
|
197
|
+
buildLogger.info('')
|
|
198
|
+
|
|
195
199
|
for (const conflict of allConflicts) {
|
|
196
|
-
|
|
200
|
+
buildLogger.warn(`ā ļø ${conflict.package}:`)
|
|
197
201
|
for (const version of conflict.versions) {
|
|
198
|
-
|
|
202
|
+
buildLogger.info(` ${version.plugin}: ${version.version}`)
|
|
199
203
|
}
|
|
200
204
|
if (conflict.resolution) {
|
|
201
|
-
|
|
205
|
+
buildLogger.success(` Resolução: ${conflict.resolution}`)
|
|
202
206
|
}
|
|
203
|
-
|
|
207
|
+
buildLogger.info('')
|
|
204
208
|
}
|
|
205
209
|
}
|
|
206
210
|
|
|
207
211
|
} catch (error) {
|
|
208
|
-
|
|
212
|
+
buildLogger.error('ā Erro ao verificar conflitos:', error)
|
|
209
213
|
process.exit(1)
|
|
210
214
|
}
|
|
211
215
|
})
|
|
@@ -216,14 +220,15 @@ function createCleanCommand(): Command {
|
|
|
216
220
|
.description('Limpar dependências não utilizadas')
|
|
217
221
|
.option('--dry-run', 'Mostrar o que seria removido sem executar')
|
|
218
222
|
.action(async (options) => {
|
|
219
|
-
|
|
223
|
+
buildLogger.info('𧹠Limpando dependências não utilizadas...')
|
|
224
|
+
buildLogger.info('')
|
|
220
225
|
|
|
221
226
|
if (options.dryRun) {
|
|
222
|
-
|
|
227
|
+
buildLogger.info('š Dry run: mostrando dependĆŖncias que seriam removidas')
|
|
223
228
|
}
|
|
224
229
|
|
|
225
230
|
// TODO: Implementar lógica de limpeza
|
|
226
|
-
|
|
231
|
+
buildLogger.warn('ā ļø Funcionalidade ainda nĆ£o implementada')
|
|
227
232
|
})
|
|
228
233
|
}
|
|
229
234
|
|
|
@@ -243,29 +248,40 @@ function findPluginDirectory(pluginName: string): string | null {
|
|
|
243
248
|
}
|
|
244
249
|
|
|
245
250
|
interface ConsoleLogger {
|
|
246
|
-
debug: (
|
|
247
|
-
info: (
|
|
248
|
-
warn: (
|
|
249
|
-
error: (
|
|
251
|
+
debug: (message: unknown, ...args: unknown[]) => void
|
|
252
|
+
info: (message: unknown, ...args: unknown[]) => void
|
|
253
|
+
warn: (message: unknown, ...args: unknown[]) => void
|
|
254
|
+
error: (message: unknown, ...args: unknown[]) => void
|
|
250
255
|
child: () => ConsoleLogger
|
|
256
|
+
request: (method: string, path: string, status?: number, duration?: number, ip?: string) => void
|
|
257
|
+
plugin: (pluginName: string, message: string, meta?: unknown) => void
|
|
258
|
+
framework: (message: string, meta?: unknown) => void
|
|
259
|
+
time: (label: string) => void
|
|
260
|
+
timeEnd: (label: string) => void
|
|
251
261
|
}
|
|
252
262
|
|
|
253
263
|
function createConsoleLogger(): ConsoleLogger {
|
|
254
|
-
|
|
255
|
-
debug: (
|
|
264
|
+
const logger: ConsoleLogger = {
|
|
265
|
+
debug: (message: unknown, ...args: unknown[]) => {
|
|
256
266
|
if (process.env.DEBUG) {
|
|
257
|
-
|
|
267
|
+
buildLogger.info(`[DEBUG] ${message}`, ...args)
|
|
258
268
|
}
|
|
259
269
|
},
|
|
260
|
-
info: (
|
|
261
|
-
|
|
270
|
+
info: (message: unknown, ...args: unknown[]) => {
|
|
271
|
+
buildLogger.info(`[INFO] ${message}`, ...args)
|
|
262
272
|
},
|
|
263
|
-
warn: (
|
|
264
|
-
|
|
273
|
+
warn: (message: unknown, ...args: unknown[]) => {
|
|
274
|
+
buildLogger.warn(`[WARN] ${message}`, ...args)
|
|
265
275
|
},
|
|
266
|
-
error: (
|
|
267
|
-
|
|
276
|
+
error: (message: unknown, ...args: unknown[]) => {
|
|
277
|
+
buildLogger.error(`[ERROR] ${message}`, ...args)
|
|
268
278
|
},
|
|
269
|
-
child: () => createConsoleLogger()
|
|
279
|
+
child: () => createConsoleLogger(),
|
|
280
|
+
request: () => {},
|
|
281
|
+
plugin: () => {},
|
|
282
|
+
framework: () => {},
|
|
283
|
+
time: () => {},
|
|
284
|
+
timeEnd: () => {}
|
|
270
285
|
}
|
|
286
|
+
return logger
|
|
271
287
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { Command } from 'commander'
|
|
7
7
|
import { readFileSync, existsSync } from 'fs'
|
|
8
8
|
import { join } from 'path'
|
|
9
|
-
import
|
|
9
|
+
import { buildLogger } from '@core/utils/build-logger'
|
|
10
10
|
|
|
11
11
|
export function createPluginListCommand(): Command {
|
|
12
12
|
const command = new Command('plugin:list')
|
|
@@ -19,97 +19,100 @@ export function createPluginListCommand(): Command {
|
|
|
19
19
|
const info = getPluginInfo()
|
|
20
20
|
|
|
21
21
|
if (options.json) {
|
|
22
|
-
|
|
22
|
+
buildLogger.info(JSON.stringify(info, null, 2))
|
|
23
23
|
return
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
buildLogger.info('')
|
|
27
|
+
buildLogger.info('š FluxStack Plugin Status')
|
|
28
|
+
buildLogger.info('')
|
|
27
29
|
|
|
28
30
|
// Configuration
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
buildLogger.info('āļø Configuration:')
|
|
32
|
+
buildLogger.info(` NPM Plugin Discovery: ${info.config.npmDiscoveryEnabled ? 'enabled' : 'disabled'}`)
|
|
33
|
+
buildLogger.info(` Project Plugin Discovery: ${info.config.projectDiscoveryEnabled ? 'enabled' : 'disabled'}`)
|
|
34
|
+
buildLogger.info('')
|
|
33
35
|
|
|
34
36
|
// Whitelisted plugins
|
|
35
37
|
if (!options.installed) {
|
|
36
|
-
|
|
38
|
+
buildLogger.info('š”ļø Whitelisted NPM Plugins:')
|
|
37
39
|
if (info.whitelisted.length === 0) {
|
|
38
|
-
|
|
40
|
+
buildLogger.info(' (none)')
|
|
39
41
|
} else {
|
|
40
42
|
info.whitelisted.forEach(plugin => {
|
|
41
43
|
const isInstalled = info.installed.includes(plugin)
|
|
42
|
-
const status = isInstalled ?
|
|
43
|
-
|
|
44
|
+
const status = isInstalled ? 'ā installed' : 'ā not installed'
|
|
45
|
+
buildLogger.info(` ⢠${plugin} ${status}`)
|
|
44
46
|
})
|
|
45
47
|
}
|
|
46
|
-
|
|
48
|
+
buildLogger.info('')
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
// Installed NPM plugins
|
|
50
52
|
if (!options.whitelisted) {
|
|
51
|
-
|
|
53
|
+
buildLogger.info('š¦ Installed NPM Plugins:')
|
|
52
54
|
if (info.installed.length === 0) {
|
|
53
|
-
|
|
55
|
+
buildLogger.info(' (none)')
|
|
54
56
|
} else {
|
|
55
57
|
info.installed.forEach(plugin => {
|
|
56
58
|
const isWhitelisted = info.whitelisted.includes(plugin)
|
|
57
59
|
let status = ''
|
|
58
60
|
if (!info.config.npmDiscoveryEnabled) {
|
|
59
|
-
status =
|
|
61
|
+
status = 'ā discovery disabled'
|
|
60
62
|
} else if (!isWhitelisted) {
|
|
61
|
-
status =
|
|
63
|
+
status = 'ā not whitelisted (blocked)'
|
|
62
64
|
} else {
|
|
63
|
-
status =
|
|
65
|
+
status = 'ā whitelisted (loaded)'
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
buildLogger.info(` ⢠${plugin} ${status}`)
|
|
66
68
|
})
|
|
67
69
|
}
|
|
68
|
-
|
|
70
|
+
buildLogger.info('')
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
// Project plugins (from plugins/ directory)
|
|
72
|
-
|
|
74
|
+
buildLogger.info('š Project Plugins (plugins/):')
|
|
73
75
|
if (info.projectPlugins.length === 0) {
|
|
74
|
-
|
|
76
|
+
buildLogger.info(' (none found)')
|
|
75
77
|
} else {
|
|
76
78
|
info.projectPlugins.forEach(plugin => {
|
|
77
79
|
const status = info.config.projectDiscoveryEnabled
|
|
78
|
-
?
|
|
79
|
-
:
|
|
80
|
-
|
|
80
|
+
? 'ā auto-discovered'
|
|
81
|
+
: 'ā discovery disabled'
|
|
82
|
+
buildLogger.info(` ⢠${plugin} ${status}`)
|
|
81
83
|
})
|
|
82
84
|
}
|
|
83
|
-
|
|
85
|
+
buildLogger.info('')
|
|
84
86
|
|
|
85
87
|
// Summary
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
buildLogger.info('š Summary:')
|
|
89
|
+
buildLogger.info(` Total NPM plugins installed: ${info.installed.length}`)
|
|
90
|
+
buildLogger.info(` Total NPM plugins whitelisted: ${info.whitelisted.length}`)
|
|
91
|
+
buildLogger.info(` Total project plugins: ${info.projectPlugins.length}`)
|
|
90
92
|
|
|
91
93
|
const blockedCount = info.installed.filter(p => !info.whitelisted.includes(p)).length
|
|
92
94
|
if (blockedCount > 0) {
|
|
93
|
-
|
|
95
|
+
buildLogger.warn(` ā ļø ${blockedCount} installed plugin(s) blocked (not whitelisted)`)
|
|
94
96
|
}
|
|
95
|
-
|
|
97
|
+
buildLogger.info('')
|
|
96
98
|
|
|
97
99
|
// Help
|
|
98
100
|
if (info.installed.length > 0 && !info.config.npmDiscoveryEnabled) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
buildLogger.warn('š” Tip: Enable NPM plugin discovery with:')
|
|
102
|
+
buildLogger.info(' echo "PLUGINS_DISCOVER_NPM=true" >> .env')
|
|
103
|
+
buildLogger.info('')
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
if (blockedCount > 0 && info.config.npmDiscoveryEnabled) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
buildLogger.warn('š” Tip: Add blocked plugins to whitelist with:')
|
|
108
|
+
buildLogger.info(' bun run fluxstack plugin:add <plugin-name>')
|
|
109
|
+
buildLogger.info('')
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
} catch (error) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
buildLogger.error('')
|
|
114
|
+
buildLogger.error('ā Failed to list plugins:')
|
|
115
|
+
buildLogger.error(error instanceof Error ? error.message : String(error))
|
|
113
116
|
process.exit(1)
|
|
114
117
|
}
|
|
115
118
|
})
|
|
@@ -197,8 +200,8 @@ function getPluginInfo(): PluginInfo {
|
|
|
197
200
|
try {
|
|
198
201
|
const entries = fs.readdirSync(pluginsDir, { withFileTypes: true })
|
|
199
202
|
info.projectPlugins = entries
|
|
200
|
-
.filter((entry:
|
|
201
|
-
.map((entry:
|
|
203
|
+
.filter((entry: { isDirectory(): boolean; name: string }) => entry.isDirectory())
|
|
204
|
+
.map((entry: { isDirectory(): boolean; name: string }) => entry.name)
|
|
202
205
|
} catch (error) {
|
|
203
206
|
// Ignore errors reading directory
|
|
204
207
|
}
|