nex-framework-cli 1.0.22 → 1.0.25

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/cli/nex-cli.js CHANGED
@@ -8,7 +8,7 @@ import chalk from 'chalk'
8
8
  import inquirer from 'inquirer'
9
9
  import fs from 'fs-extra'
10
10
  import path from 'path'
11
- import { fileURLToPath } from 'url'
11
+ import { fileURLToPath, pathToFileURL } from 'url'
12
12
 
13
13
  const __filename = fileURLToPath(import.meta.url)
14
14
  const __dirname = path.dirname(__filename)
@@ -28,10 +28,10 @@ program.configureHelp({
28
28
  program
29
29
  .name('nex')
30
30
  .description('NEX Framework - Framework completo de agentes AI')
31
- .version('1.0.21', '-v, --version', 'Mostra a versão')
31
+ .version('1.0.24', '-v, --version', 'Mostra a versão')
32
32
  .addHelpText('before', chalk.bold.cyan(`
33
33
  ╔════════════════════════════════════════════════════════════════╗
34
- ║ NEX Framework - CLI v1.0.9
34
+ ║ NEX Framework - CLI v1.0.24
35
35
  ║ Framework completo de agentes AI ║
36
36
  ╚════════════════════════════════════════════════════════════════╝
37
37
  `))
@@ -364,8 +364,27 @@ configCmd
364
364
  .command('reset')
365
365
  .description('Reconfigura o NEX CLI (nome, idiomas, integração Cursor)')
366
366
  .action(async () => {
367
- const { runSetup } = await import('../scripts/postinstall.js')
368
- await runSetup(true) // Force reconfiguration
367
+ try {
368
+ // Resolve path to postinstall.js relative to CLI location (works for global installs)
369
+ const postinstallPath = path.join(__dirname, '..', 'scripts', 'postinstall.js')
370
+ // Convert to file URL for ES module import
371
+ const postinstallUrl = pathToFileURL(postinstallPath).href
372
+ const { runSetup } = await import(postinstallUrl)
373
+ await runSetup(true) // Force reconfiguration
374
+ } catch (error) {
375
+ // Fallback: try relative import (works in development)
376
+ try {
377
+ const { runSetup } = await import('../scripts/postinstall.js')
378
+ await runSetup(true)
379
+ } catch (fallbackError) {
380
+ console.error(chalk.red(`\n❌ Erro ao reconfigurar: ${fallbackError.message}`))
381
+ if (fallbackError.code === 'ERR_MODULE_NOT_FOUND') {
382
+ console.error(chalk.yellow(`\n💡 Arquivo não encontrado. Verifique se o pacote está instalado corretamente.`))
383
+ }
384
+ console.error(chalk.gray(`\nCaminho tentado: ${path.join(__dirname, '..', 'scripts', 'postinstall.js')}`))
385
+ process.exit(1)
386
+ }
387
+ }
369
388
  })
370
389
 
371
390
  configCmd
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nex-framework-cli",
3
- "version": "1.0.22",
3
+ "version": "1.0.25",
4
4
  "description": "NEX CLI - Command-line interface for NEX Framework and Agent Marketplace",
5
5
  "type": "module",
6
6
  "main": "cli/nex-cli.js",
@@ -2,13 +2,14 @@
2
2
  /**
3
3
  * NEX CLI Post-Install Script
4
4
  * Runs after npm install to configure the CLI
5
+ *
6
+ * IMPORTANT: This script must be FAST and NON-BLOCKING
7
+ * Interactive setup is done via: nex config reset
5
8
  */
6
9
 
7
- import inquirer from 'inquirer'
8
10
  import fs from 'fs-extra'
9
11
  import path from 'path'
10
12
  import os from 'os'
11
- import chalk from 'chalk'
12
13
  import { fileURLToPath } from 'url'
13
14
 
14
15
  const __filename = fileURLToPath(import.meta.url)
@@ -27,7 +28,12 @@ export function getGlobalConfigPath() {
27
28
  }
28
29
  }
29
30
 
31
+ // Interactive setup (only called by nex config reset)
30
32
  export async function runSetup(force = false) {
33
+ // Dynamic import to avoid loading inquirer during postinstall
34
+ const inquirer = (await import('inquirer')).default
35
+ const chalk = (await import('chalk')).default
36
+
31
37
  // Check if config already exists
32
38
  const configPath = getGlobalConfigPath()
33
39
  const configDir = path.dirname(configPath)
@@ -116,7 +122,7 @@ export async function runSetup(force = false) {
116
122
  enabled: answers.cursorIntegration
117
123
  },
118
124
  installedAt: new Date().toISOString(),
119
- version: '1.0.21'
125
+ version: '1.0.24'
120
126
  }
121
127
 
122
128
  // Save config
@@ -132,39 +138,36 @@ export async function runSetup(force = false) {
132
138
  console.log(chalk.cyan('\n💡 Dica: Para reconfigurar, execute: nex config reset\n'))
133
139
  }
134
140
 
135
- // Always create default config silently (fast, non-blocking)
136
- // User can configure later with: nex config reset
137
- const configPath = getGlobalConfigPath()
138
- const configDir = path.dirname(configPath)
139
- const defaultConfig = {
140
- user: {
141
- name: process.env.USER || process.env.USERNAME || 'Developer',
142
- conversationLanguage: 'pt-BR',
143
- documentLanguage: 'pt-BR'
144
- },
141
+ // Post-install: Create default config SYNCHRONOUSLY and EXIT IMMEDIATELY
142
+ // This must be FAST - no async operations, no prompts, no delays
143
+ try {
144
+ const configPath = getGlobalConfigPath()
145
+ const configDir = path.dirname(configPath)
146
+ const defaultConfig = {
147
+ user: {
148
+ name: process.env.USER || process.env.USERNAME || 'Developer',
149
+ conversationLanguage: 'pt-BR',
150
+ documentLanguage: 'pt-BR'
151
+ },
145
152
  cursor: {
146
153
  enabled: false
147
154
  },
148
155
  installedAt: new Date().toISOString(),
149
- version: '1.0.21'
156
+ version: '1.0.24'
150
157
  }
151
158
 
152
- // Create config asynchronously without blocking
153
- fs.ensureDir(configDir)
154
- .then(() => fs.writeJSON(configPath, defaultConfig, { spaces: 2 }))
155
- .then(() => {
156
- // Only show message if in interactive mode and not CI
157
- const isInteractive = process.stdin.isTTY && process.stdout.isTTY && process.stderr.isTTY
158
- const isCI = process.env.CI === 'true'
159
- if (!isCI && isInteractive) {
160
- console.log(chalk.green('\n✅ NEX CLI instalado com configuração padrão'))
161
- console.log(chalk.gray(' Para configurar: nex config reset\n'))
162
- }
163
- })
164
- .catch(() => {
165
- // Silently fail - don't block installation
166
- })
167
- .finally(() => {
168
- // Always exit successfully to not block npm install
169
- process.exit(0)
170
- })
159
+ // Create directory and file synchronously (fast)
160
+ if (!fs.existsSync(configDir)) {
161
+ fs.mkdirSync(configDir, { recursive: true })
162
+ }
163
+
164
+ // Only create if doesn't exist (don't overwrite existing config)
165
+ if (!fs.existsSync(configPath)) {
166
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), 'utf8')
167
+ }
168
+ } catch (error) {
169
+ // Silently fail - don't block installation
170
+ }
171
+
172
+ // Exit immediately - don't wait for anything
173
+ process.exit(0)