@nectarcrm/ccx 0.5.1 → 0.5.2

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 (2) hide show
  1. package/bin/ccx.js +11 -3
  2. package/package.json +1 -1
package/bin/ccx.js CHANGED
@@ -511,13 +511,21 @@ async function autoUpdate() {
511
511
  const prefix = globalPrefix()
512
512
  if (!prefix) return save({ error: 'ccx não foi instalado com npm install -g' })
513
513
  try {
514
- const npm = join(dirname(process.execPath), WIN ? 'npm.cmd' : 'npm')
515
- execFileSync(existsSync(npm) ? npm : 'npm', ['install', '-g', '--prefix', prefix, `${PKG}@${latest}`], { stdio: 'ignore', timeout: 180_000, shell: WIN })
514
+ const args = ['install', '-g', '--prefix', prefix, `${PKG}@${latest}`]
515
+ const opts = { stdio: ['ignore', 'ignore', 'pipe'], timeout: 180_000 }
516
+ // O npm que vem com o Node, rodado pelo próprio Node: sem cmd.exe, então espaço no caminho
517
+ // (C:\Program Files\nodejs, C:\Users\Nome Sobrenome) não quebra o comando
518
+ const cli = [join(dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js'), join(dirname(dirname(process.execPath)), 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js')].find(existsSync)
519
+ if (cli) execFileSync(process.execPath, [cli, ...args], opts)
520
+ else if (WIN) execFileSync('npm.cmd', args.map(a => `"${a}"`), { ...opts, shell: true })
521
+ else execFileSync('npm', args, opts)
516
522
  log(`ccx atualizado: ${mine} → ${latest}`)
517
523
  save({})
518
524
  }
519
525
  catch (e) {
520
- const msg = e.message.split('\n')[0]
526
+ // O motivo de verdade vem no fim do stderr do npm (ex.: EACCES, EPERM, ENOTFOUND)
527
+ const why = String(e.stderr ?? '').split(/\r?\n/).map(l => l.replace(/^npm (error|ERR!) ?/, '').trim()).filter(Boolean)
528
+ const msg = why.find(l => /^(code )?E[A-Z]+/.test(l)) ?? why.at(-1) ?? e.message.split('\n')[0]
521
529
  log(`não consegui atualizar o ccx pra ${latest}: ${msg}`)
522
530
  save({ error: msg })
523
531
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectarcrm/ccx",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Escolhe qual conta Claude este computador usa, conectado ao app Contas Claude da Nectar.",
5
5
  "type": "module",
6
6
  "bin": { "ccx": "bin/ccx.js" },