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.
Files changed (119) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/app/client/src/App.tsx +8 -0
  3. package/app/client/src/live/AuthDemo.tsx +4 -4
  4. package/core/build/bundler.ts +40 -26
  5. package/core/build/flux-plugins-generator.ts +325 -325
  6. package/core/build/index.ts +92 -21
  7. package/core/cli/command-registry.ts +44 -46
  8. package/core/cli/commands/build.ts +11 -6
  9. package/core/cli/commands/create.ts +7 -5
  10. package/core/cli/commands/dev.ts +6 -5
  11. package/core/cli/commands/help.ts +3 -2
  12. package/core/cli/commands/make-plugin.ts +8 -7
  13. package/core/cli/commands/plugin-add.ts +60 -43
  14. package/core/cli/commands/plugin-deps.ts +73 -57
  15. package/core/cli/commands/plugin-list.ts +44 -41
  16. package/core/cli/commands/plugin-remove.ts +33 -22
  17. package/core/cli/generators/component.ts +770 -769
  18. package/core/cli/generators/controller.ts +9 -8
  19. package/core/cli/generators/index.ts +148 -146
  20. package/core/cli/generators/interactive.ts +228 -227
  21. package/core/cli/generators/plugin.ts +11 -10
  22. package/core/cli/generators/prompts.ts +83 -82
  23. package/core/cli/generators/route.ts +7 -6
  24. package/core/cli/generators/service.ts +10 -9
  25. package/core/cli/generators/template-engine.ts +2 -1
  26. package/core/cli/generators/types.ts +7 -7
  27. package/core/cli/generators/utils.ts +191 -191
  28. package/core/cli/index.ts +9 -8
  29. package/core/cli/plugin-discovery.ts +2 -2
  30. package/core/client/hooks/useAuth.ts +48 -48
  31. package/core/client/standalone.ts +18 -17
  32. package/core/client/state/createStore.ts +192 -192
  33. package/core/client/state/index.ts +14 -14
  34. package/core/config/index.ts +1 -0
  35. package/core/framework/client.ts +131 -131
  36. package/core/framework/index.ts +7 -7
  37. package/core/framework/server.ts +72 -112
  38. package/core/framework/types.ts +2 -2
  39. package/core/plugins/built-in/live-components/commands/create-live-component.ts +6 -3
  40. package/core/plugins/built-in/monitoring/index.ts +110 -68
  41. package/core/plugins/built-in/static/index.ts +2 -2
  42. package/core/plugins/built-in/swagger/index.ts +9 -9
  43. package/core/plugins/built-in/vite/index.ts +3 -3
  44. package/core/plugins/built-in/vite/vite-dev.ts +3 -3
  45. package/core/plugins/config.ts +50 -47
  46. package/core/plugins/discovery.ts +10 -4
  47. package/core/plugins/executor.ts +2 -2
  48. package/core/plugins/index.ts +206 -203
  49. package/core/plugins/manager.ts +21 -20
  50. package/core/plugins/registry.ts +76 -12
  51. package/core/plugins/types.ts +14 -14
  52. package/core/server/framework.ts +3 -189
  53. package/core/server/live/auto-generated-components.ts +11 -29
  54. package/core/server/live/index.ts +41 -31
  55. package/core/server/live/websocket-plugin.ts +11 -1
  56. package/core/server/middleware/elysia-helpers.ts +16 -15
  57. package/core/server/middleware/errorHandling.ts +14 -14
  58. package/core/server/middleware/index.ts +31 -31
  59. package/core/server/plugins/database.ts +181 -180
  60. package/core/server/plugins/static-files-plugin.ts +4 -3
  61. package/core/server/plugins/swagger.ts +11 -8
  62. package/core/server/rooms/RoomBroadcaster.ts +11 -10
  63. package/core/server/rooms/RoomSystem.ts +14 -11
  64. package/core/server/services/BaseService.ts +7 -7
  65. package/core/server/services/ServiceContainer.ts +5 -5
  66. package/core/server/services/index.ts +8 -8
  67. package/core/templates/create-project.ts +28 -27
  68. package/core/testing/index.ts +9 -9
  69. package/core/testing/setup.ts +73 -73
  70. package/core/types/api.ts +168 -168
  71. package/core/types/config.ts +5 -5
  72. package/core/types/index.ts +1 -1
  73. package/core/types/plugin.ts +2 -2
  74. package/core/types/types.ts +3 -3
  75. package/core/utils/build-logger.ts +324 -324
  76. package/core/utils/config-schema.ts +480 -480
  77. package/core/utils/env.ts +10 -8
  78. package/core/utils/errors/codes.ts +114 -114
  79. package/core/utils/errors/handlers.ts +30 -20
  80. package/core/utils/errors/index.ts +54 -46
  81. package/core/utils/errors/middleware.ts +113 -113
  82. package/core/utils/helpers.ts +19 -16
  83. package/core/utils/logger/colors.ts +114 -114
  84. package/core/utils/logger/config.ts +2 -2
  85. package/core/utils/logger/formatter.ts +82 -82
  86. package/core/utils/logger/group-logger.ts +101 -101
  87. package/core/utils/logger/index.ts +13 -3
  88. package/core/utils/logger/startup-banner.ts +2 -2
  89. package/core/utils/logger/winston-logger.ts +152 -152
  90. package/core/utils/monitoring/index.ts +211 -211
  91. package/core/utils/sync-version.ts +67 -66
  92. package/core/utils/version.ts +1 -1
  93. package/package.json +104 -100
  94. package/playwright-report/index.html +85 -0
  95. package/playwright.config.ts +31 -0
  96. package/plugins/crypto-auth/client/CryptoAuthClient.ts +302 -302
  97. package/plugins/crypto-auth/client/components/index.ts +11 -11
  98. package/plugins/crypto-auth/client/index.ts +11 -11
  99. package/plugins/crypto-auth/package.json +65 -65
  100. package/plugins/crypto-auth/server/CryptoAuthService.ts +185 -185
  101. package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +6 -5
  102. package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +6 -5
  103. package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +3 -3
  104. package/plugins/crypto-auth/server/middlewares/index.ts +22 -22
  105. package/plugins/crypto-auth/server/middlewares.ts +19 -19
  106. package/vite.config.ts +13 -0
  107. package/app/client/.live-stubs/LiveAdminPanel.js +0 -5
  108. package/app/client/.live-stubs/LiveCounter.js +0 -9
  109. package/app/client/.live-stubs/LiveForm.js +0 -11
  110. package/app/client/.live-stubs/LiveLocalCounter.js +0 -8
  111. package/app/client/.live-stubs/LivePingPong.js +0 -10
  112. package/app/client/.live-stubs/LiveRoomChat.js +0 -11
  113. package/app/client/.live-stubs/LiveSharedCounter.js +0 -10
  114. package/app/client/.live-stubs/LiveUpload.js +0 -15
  115. package/app/server/live/register-components.ts +0 -19
  116. package/core/build/live-components-generator.ts +0 -321
  117. package/core/live/ComponentRegistry.ts +0 -403
  118. package/core/live/types.ts +0 -241
  119. 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 chalk from 'chalk'
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
- console.log(chalk.blue('\nšŸ”Œ FluxStack Plugin Installer\n'))
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
- console.error(chalk.red(`āŒ Invalid plugin name: ${pluginName}`))
30
- console.log(chalk.yellow('\nšŸ“ Valid plugin names:'))
31
- console.log(' - fluxstack-plugin-*')
32
- console.log(' - fplugin-*')
33
- console.log(' - @fluxstack/plugin-*')
34
- console.log(' - @fplugin/*')
35
- console.log(' - @org/fluxstack-plugin-*')
36
- console.log(' - @org/fplugin-*')
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
- console.error(chalk.red('āŒ package.json not found'))
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
- console.log(chalk.yellow(`āš ļø Plugin ${pluginName} is already installed`))
54
- console.log(chalk.yellow(' Will only update whitelist\n'))
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
- console.log(chalk.blue('šŸ” Auditing plugin security...\n'))
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
- console.log(chalk.gray(info))
69
+ buildLogger.info(info)
65
70
 
66
71
  // Run audit
67
- console.log(chalk.blue('\nšŸ›”ļø Running npm audit...\n'))
72
+ buildLogger.info('')
73
+ buildLogger.info('šŸ›”ļø Running npm audit...')
74
+ buildLogger.info('')
68
75
  const auditResult = await $`npm audit ${pluginName}`.text()
69
- console.log(chalk.gray(auditResult))
76
+ buildLogger.info(auditResult)
70
77
  } catch (error) {
71
- console.warn(chalk.yellow(`āš ļø Could not audit plugin: ${error instanceof Error ? error.message : 'Unknown error'}`))
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
- console.log(chalk.yellow('\nāš ļø Security Warning:'))
78
- console.log(chalk.yellow(' NPM plugins can execute arbitrary code'))
79
- console.log(chalk.yellow(' Only install plugins from trusted sources\n'))
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(chalk.blue('Continue with installation? (yes/no): '))
90
+ const answer = prompt('Continue with installation? (yes/no): ')
82
91
  if (answer?.toLowerCase() !== 'yes' && answer?.toLowerCase() !== 'y') {
83
- console.log(chalk.red('āŒ Installation cancelled'))
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
- console.log(chalk.blue(`\nšŸ“¦ Installing ${pluginName}...\n`))
99
+ buildLogger.info('')
100
+ buildLogger.info(`šŸ“¦ Installing ${pluginName}...`)
101
+ buildLogger.info('')
91
102
  await $`bun add ${pluginName}`.quiet()
92
- console.log(chalk.green(`āœ… Plugin installed successfully`))
103
+ buildLogger.success('āœ… Plugin installed successfully')
93
104
  }
94
105
 
95
106
  // 6. Update .env file
96
- console.log(chalk.blue('\nšŸ”§ Updating configuration...\n'))
107
+ buildLogger.info('')
108
+ buildLogger.info('šŸ”§ Updating configuration...')
109
+ buildLogger.info('')
97
110
  updateEnvFile(pluginName)
98
111
 
99
112
  // 7. Success message
100
- console.log(chalk.green('\nāœ… Plugin setup complete!\n'))
101
- console.log(chalk.blue('šŸ“‹ What was done:'))
113
+ buildLogger.success('')
114
+ buildLogger.success('āœ… Plugin setup complete!')
115
+ buildLogger.info('')
116
+ buildLogger.info('šŸ“‹ What was done:')
102
117
  if (!isAlreadyInstalled) {
103
- console.log(chalk.gray(` • Installed ${pluginName}`))
118
+ buildLogger.info(` • Installed ${pluginName}`)
104
119
  }
105
- console.log(chalk.gray(' • Enabled NPM plugin discovery (PLUGINS_DISCOVER_NPM=true)'))
106
- console.log(chalk.gray(` • Added ${pluginName} to whitelist (PLUGINS_ALLOWED)`))
120
+ buildLogger.info(' • Enabled NPM plugin discovery (PLUGINS_DISCOVER_NPM=true)')
121
+ buildLogger.info(` • Added ${pluginName} to whitelist (PLUGINS_ALLOWED)`)
107
122
 
108
- console.log(chalk.blue('\nšŸš€ Next steps:'))
109
- console.log(chalk.gray(' 1. Restart your dev server: bun run dev'))
110
- console.log(chalk.gray(' 2. Plugin will be auto-discovered and loaded'))
111
- console.log(chalk.gray(' 3. Check logs for plugin initialization'))
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
- console.error(chalk.red('\nāŒ Failed to install plugin:'))
115
- console.error(chalk.red(error instanceof Error ? error.message : String(error)))
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
- console.warn(chalk.yellow('āš ļø .env file not found, creating...'))
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
- console.log(chalk.gray(' • Set PLUGINS_DISCOVER_NPM=true'))
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
- console.log(chalk.gray(' • Added PLUGINS_DISCOVER_NPM=true'))
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
- console.log(chalk.gray(` • Added ${pluginName} to PLUGINS_ALLOWED`))
201
+ buildLogger.info(` • Added ${pluginName} to PLUGINS_ALLOWED`)
185
202
  } else {
186
- console.log(chalk.gray(` • ${pluginName} already in PLUGINS_ALLOWED`))
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
- console.log(chalk.gray(` • Created PLUGINS_ALLOWED with ${pluginName}`))
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 chalk from 'chalk'
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
- console.log(chalk.blue('šŸ”§ Instalando dependĆŖncias de plugins...\n'))
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() as any as any
36
+ logger: createConsoleLogger()
36
37
  })
37
38
 
38
39
  const registry = new PluginRegistry({
39
- logger: createConsoleLogger() as any as any
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
- console.log(chalk.green(`āœ… Encontrados ${successfulPlugins.length} plugins\n`))
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
- console.log(chalk.cyan(`šŸ“¦ ${resolution.plugin}:`))
73
+ buildLogger.info(`šŸ“¦ ${resolution.plugin}:`)
72
74
  for (const dep of resolution.dependencies) {
73
- const typeColor = dep.type === 'peerDependency' ? chalk.yellow : chalk.white
74
- console.log(` ${typeColor(dep.name)}@${dep.version} (${dep.type})`)
75
+ buildLogger.info(` ${dep.name}@${dep.version} (${dep.type})`)
75
76
  }
76
- console.log()
77
+ buildLogger.info('')
77
78
  }
78
79
  }
79
80
 
80
81
  if (totalConflicts > 0) {
81
- console.log(chalk.yellow(`āš ļø ${totalConflicts} conflitos de dependĆŖncias detectados\n`))
82
+ buildLogger.warn(`āš ļø ${totalConflicts} conflitos de dependĆŖncias detectados`)
83
+ buildLogger.info('')
82
84
  }
83
85
 
84
86
  if (options.dryRun) {
85
- console.log(chalk.blue(`šŸ“‹ Dry run: ${totalDeps} dependĆŖncias seriam instaladas`))
87
+ buildLogger.info(`šŸ“‹ Dry run: ${totalDeps} dependĆŖncias seriam instaladas`)
86
88
  } else {
87
89
  await dependencyManager.installPluginDependencies(resolutions)
88
- console.log(chalk.green(`āœ… ${totalDeps} dependĆŖncias instaladas com sucesso!`))
90
+ buildLogger.success(`āœ… ${totalDeps} dependĆŖncias instaladas com sucesso!`)
89
91
  }
90
92
 
91
93
  } catch (error) {
92
- console.error(chalk.red('āŒ Erro ao instalar dependĆŖncias:'), error)
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
- console.log(chalk.blue('šŸ“‹ DependĆŖncias de plugins:\n'))
105
+ buildLogger.info('šŸ“‹ DependĆŖncias de plugins:')
106
+ buildLogger.info('')
104
107
 
105
108
  try {
106
109
  const registry = new PluginRegistry({
107
- logger: createConsoleLogger() as any
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() as any
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
- console.log(chalk.cyan(`šŸ“¦ ${resolution.plugin}`))
130
-
131
+
132
+ buildLogger.info(`šŸ“¦ ${resolution.plugin}`)
133
+
131
134
  if (resolution.dependencies.length === 0) {
132
- console.log(chalk.gray(' Nenhuma dependĆŖncia'))
135
+ buildLogger.info(' Nenhuma dependĆŖncia')
133
136
  } else {
134
137
  for (const dep of resolution.dependencies) {
135
- const typeColor = dep.type === 'peerDependency' ? chalk.yellow : chalk.white
136
- const optional = dep.optional ? chalk.gray(' (opcional)') : ''
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
- console.log(chalk.red(` āš ļø ${resolution.conflicts.length} conflitos`))
144
+ buildLogger.error(` āš ļø ${resolution.conflicts.length} conflitos`)
143
145
  }
144
146
 
145
- console.log()
147
+ buildLogger.info('')
146
148
  }
147
149
  }
148
150
  }
149
151
 
150
152
  } catch (error) {
151
- console.error(chalk.red('āŒ Erro ao listar dependĆŖncias:'), error)
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
- console.log(chalk.blue('šŸ” Verificando conflitos de dependĆŖncias...\n'))
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() as any
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() as any
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
- console.log(chalk.green('āœ… Nenhum conflito de dependĆŖncias encontrado!'))
194
+ buildLogger.success('āœ… Nenhum conflito de dependĆŖncias encontrado!')
192
195
  } else {
193
- console.log(chalk.red(`āŒ ${allConflicts.length} conflitos encontrados:\n`))
194
-
196
+ buildLogger.error(`āŒ ${allConflicts.length} conflitos encontrados:`)
197
+ buildLogger.info('')
198
+
195
199
  for (const conflict of allConflicts) {
196
- console.log(chalk.yellow(`āš ļø ${conflict.package}:`))
200
+ buildLogger.warn(`āš ļø ${conflict.package}:`)
197
201
  for (const version of conflict.versions) {
198
- console.log(` ${version.plugin}: ${version.version}`)
202
+ buildLogger.info(` ${version.plugin}: ${version.version}`)
199
203
  }
200
204
  if (conflict.resolution) {
201
- console.log(chalk.green(` Resolução: ${conflict.resolution}`))
205
+ buildLogger.success(` Resolução: ${conflict.resolution}`)
202
206
  }
203
- console.log()
207
+ buildLogger.info('')
204
208
  }
205
209
  }
206
210
 
207
211
  } catch (error) {
208
- console.error(chalk.red('āŒ Erro ao verificar conflitos:'), error)
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
- console.log(chalk.blue('🧹 Limpando dependências não utilizadas...\n'))
223
+ buildLogger.info('🧹 Limpando dependências não utilizadas...')
224
+ buildLogger.info('')
220
225
 
221
226
  if (options.dryRun) {
222
- console.log(chalk.blue('šŸ“‹ Dry run: mostrando dependĆŖncias que seriam removidas'))
227
+ buildLogger.info('šŸ“‹ Dry run: mostrando dependĆŖncias que seriam removidas')
223
228
  }
224
229
 
225
230
  // TODO: Implementar lógica de limpeza
226
- console.log(chalk.yellow('āš ļø Funcionalidade ainda nĆ£o implementada'))
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: (msg: string, meta?: unknown) => void
247
- info: (msg: string, meta?: unknown) => void
248
- warn: (msg: string, meta?: unknown) => void
249
- error: (msg: string, meta?: unknown) => void
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
- return {
255
- debug: (msg: string, meta?: unknown) => {
264
+ const logger: ConsoleLogger = {
265
+ debug: (message: unknown, ...args: unknown[]) => {
256
266
  if (process.env.DEBUG) {
257
- console.log(chalk.gray(`[DEBUG] ${msg}`), meta || '')
267
+ buildLogger.info(`[DEBUG] ${message}`, ...args)
258
268
  }
259
269
  },
260
- info: (msg: string, meta?: unknown) => {
261
- console.log(chalk.blue(`[INFO] ${msg}`), meta || '')
270
+ info: (message: unknown, ...args: unknown[]) => {
271
+ buildLogger.info(`[INFO] ${message}`, ...args)
262
272
  },
263
- warn: (msg: string, meta?: unknown) => {
264
- console.log(chalk.yellow(`[WARN] ${msg}`), meta || '')
273
+ warn: (message: unknown, ...args: unknown[]) => {
274
+ buildLogger.warn(`[WARN] ${message}`, ...args)
265
275
  },
266
- error: (msg: string, meta?: unknown) => {
267
- console.log(chalk.red(`[ERROR] ${msg}`), meta || '')
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 chalk from 'chalk'
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
- console.log(JSON.stringify(info, null, 2))
22
+ buildLogger.info(JSON.stringify(info, null, 2))
23
23
  return
24
24
  }
25
25
 
26
- console.log(chalk.blue('\nšŸ”Œ FluxStack Plugin Status\n'))
26
+ buildLogger.info('')
27
+ buildLogger.info('šŸ”Œ FluxStack Plugin Status')
28
+ buildLogger.info('')
27
29
 
28
30
  // Configuration
29
- console.log(chalk.bold('āš™ļø Configuration:'))
30
- console.log(chalk.gray(` NPM Plugin Discovery: ${info.config.npmDiscoveryEnabled ? chalk.green('enabled') : chalk.red('disabled')}`))
31
- console.log(chalk.gray(` Project Plugin Discovery: ${info.config.projectDiscoveryEnabled ? chalk.green('enabled') : chalk.red('disabled')}`))
32
- console.log()
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
- console.log(chalk.bold('šŸ›”ļø Whitelisted NPM Plugins:'))
38
+ buildLogger.info('šŸ›”ļø Whitelisted NPM Plugins:')
37
39
  if (info.whitelisted.length === 0) {
38
- console.log(chalk.gray(' (none)'))
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 ? chalk.green('āœ“ installed') : chalk.yellow('⚠ not installed')
43
- console.log(chalk.gray(` • ${plugin} ${status}`))
44
+ const status = isInstalled ? 'āœ“ installed' : '⚠ not installed'
45
+ buildLogger.info(` • ${plugin} ${status}`)
44
46
  })
45
47
  }
46
- console.log()
48
+ buildLogger.info('')
47
49
  }
48
50
 
49
51
  // Installed NPM plugins
50
52
  if (!options.whitelisted) {
51
- console.log(chalk.bold('šŸ“¦ Installed NPM Plugins:'))
53
+ buildLogger.info('šŸ“¦ Installed NPM Plugins:')
52
54
  if (info.installed.length === 0) {
53
- console.log(chalk.gray(' (none)'))
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 = chalk.red('āœ— discovery disabled')
61
+ status = 'āœ— discovery disabled'
60
62
  } else if (!isWhitelisted) {
61
- status = chalk.red('āœ— not whitelisted (blocked)')
63
+ status = 'āœ— not whitelisted (blocked)'
62
64
  } else {
63
- status = chalk.green('āœ“ whitelisted (loaded)')
65
+ status = 'āœ“ whitelisted (loaded)'
64
66
  }
65
- console.log(chalk.gray(` • ${plugin} ${status}`))
67
+ buildLogger.info(` • ${plugin} ${status}`)
66
68
  })
67
69
  }
68
- console.log()
70
+ buildLogger.info('')
69
71
  }
70
72
 
71
73
  // Project plugins (from plugins/ directory)
72
- console.log(chalk.bold('šŸ“ Project Plugins (plugins/):'))
74
+ buildLogger.info('šŸ“ Project Plugins (plugins/):')
73
75
  if (info.projectPlugins.length === 0) {
74
- console.log(chalk.gray(' (none found)'))
76
+ buildLogger.info(' (none found)')
75
77
  } else {
76
78
  info.projectPlugins.forEach(plugin => {
77
79
  const status = info.config.projectDiscoveryEnabled
78
- ? chalk.green('āœ“ auto-discovered')
79
- : chalk.red('āœ— discovery disabled')
80
- console.log(chalk.gray(` • ${plugin} ${status}`))
80
+ ? 'āœ“ auto-discovered'
81
+ : 'āœ— discovery disabled'
82
+ buildLogger.info(` • ${plugin} ${status}`)
81
83
  })
82
84
  }
83
- console.log()
85
+ buildLogger.info('')
84
86
 
85
87
  // Summary
86
- console.log(chalk.bold('šŸ“Š Summary:'))
87
- console.log(chalk.gray(` Total NPM plugins installed: ${info.installed.length}`))
88
- console.log(chalk.gray(` Total NPM plugins whitelisted: ${info.whitelisted.length}`))
89
- console.log(chalk.gray(` Total project plugins: ${info.projectPlugins.length}`))
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
- console.log(chalk.yellow(` āš ļø ${blockedCount} installed plugin(s) blocked (not whitelisted)`))
95
+ buildLogger.warn(` āš ļø ${blockedCount} installed plugin(s) blocked (not whitelisted)`)
94
96
  }
95
- console.log()
97
+ buildLogger.info('')
96
98
 
97
99
  // Help
98
100
  if (info.installed.length > 0 && !info.config.npmDiscoveryEnabled) {
99
- console.log(chalk.yellow('šŸ’” Tip: Enable NPM plugin discovery with:'))
100
- console.log(chalk.gray(' echo "PLUGINS_DISCOVER_NPM=true" >> .env'))
101
- console.log()
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
- console.log(chalk.yellow('šŸ’” Tip: Add blocked plugins to whitelist with:'))
106
- console.log(chalk.gray(' bun run fluxstack plugin:add <plugin-name>'))
107
- console.log()
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
- console.error(chalk.red('\nāŒ Failed to list plugins:'))
112
- console.error(chalk.red(error instanceof Error ? error.message : String(error)))
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: any) => entry.isDirectory())
201
- .map((entry: any) => entry.name)
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
  }