@nectarcrm/ccx 0.1.0 → 0.1.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/README.md +1 -1
- package/bin/ccx.js +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install -g @nectarcrm/ccx
|
|
|
13
13
|
## Usar
|
|
14
14
|
|
|
15
15
|
```
|
|
16
|
-
ccx login
|
|
16
|
+
ccx login # autoriza este computador (abre o navegador) e escolhe a conta
|
|
17
17
|
ccx # mostra suas contas e troca a conta deste computador
|
|
18
18
|
ccx claude-infra # troca direto
|
|
19
19
|
ccx status # conta atual e uso de cada conta
|
package/bin/ccx.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// ccx — escolhe qual conta Claude este computador usa. Conectado ao app Contas Claude.
|
|
3
3
|
//
|
|
4
|
-
// ccx login
|
|
4
|
+
// ccx login autoriza este computador (abre o navegador) e escolhe a conta
|
|
5
|
+
// (outro app: ccx login https://endereco)
|
|
5
6
|
// ccx mostra suas contas e troca a conta deste computador
|
|
6
7
|
// ccx <conta> troca direto (nome curto, ex.: claude-infra)
|
|
7
8
|
// ccx status conta atual e uso das contas liberadas pra você
|
|
@@ -27,6 +28,7 @@ const LOG = join(DIR, 'vigia.log')
|
|
|
27
28
|
const SETTINGS = join(process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude'), 'settings.json')
|
|
28
29
|
const WIN = process.platform === 'win32'
|
|
29
30
|
const MAC = process.platform === 'darwin'
|
|
31
|
+
const DEFAULT_URL = 'https://ccx.nectarcrm.com.br'
|
|
30
32
|
const SERVICE = 'ccx-app' // Keychain: guarda a chave do computador
|
|
31
33
|
const AGENT_MINUTES = 5
|
|
32
34
|
const AGENT_ID = 'br.com.nectarcrm.ccx' // launchd (Mac) / nome da tarefa (Windows)
|
|
@@ -289,7 +291,7 @@ async function login(url) {
|
|
|
289
291
|
const start = await api(target, null, 'POST', '/api/cli/device', { hostname: hostname(), platform: process.platform })
|
|
290
292
|
if (start.status !== 200) die(`Não consegui falar com o app: ${start.data.message ?? `HTTP ${start.status}`}`)
|
|
291
293
|
const { device_code, user_code, verify_url, expires_in, interval } = start.data
|
|
292
|
-
console.error(`\
|
|
294
|
+
console.error(`\nNo navegador, digite este código:\n\n ${c(1, user_code)}\n\n ${verify_url}\n`)
|
|
293
295
|
openBrowser(verify_url)
|
|
294
296
|
process.stderr.write('Esperando a aprovação')
|
|
295
297
|
const deadline = Date.now() + expires_in * 1000
|
|
@@ -358,11 +360,11 @@ if (cmd === 'vigia') {
|
|
|
358
360
|
process.exit(0)
|
|
359
361
|
}
|
|
360
362
|
|
|
361
|
-
if (cmd === 'login') await login(rest[0] ?? readJson(APP, null)?.url ??
|
|
363
|
+
if (cmd === 'login') await login(rest[0] ?? readJson(APP, null)?.url ?? DEFAULT_URL)
|
|
362
364
|
|
|
363
365
|
const app = readJson(APP, null)
|
|
364
366
|
const key = app && secretGet()
|
|
365
|
-
if (!app || !key) die('Este computador ainda não está conectado. Rode: ccx login
|
|
367
|
+
if (!app || !key) die('Este computador ainda não está conectado. Rode: ccx login')
|
|
366
368
|
|
|
367
369
|
if (cmd === 'logout') {
|
|
368
370
|
removeAccount(app)
|