tokenrace 0.1.21 → 0.2.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/bin/cli.js CHANGED
@@ -2,10 +2,8 @@
2
2
  import { startServer } from '../src/server.js'
3
3
  import { ensureEnvVars } from '../src/ensure-env-vars.js'
4
4
  import open from 'open'
5
- import { spawn } from 'node:child_process'
6
5
 
7
6
  const PORT = process.env.TOKENRACE_PORT ? Number(process.env.TOKENRACE_PORT) : 1337
8
- const CWD = process.cwd()
9
7
 
10
8
  const { added, rcPath } = ensureEnvVars(PORT)
11
9
 
@@ -27,12 +25,9 @@ ${envStatus}
27
25
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
28
26
  `)
29
27
 
30
- // Abrir el dashboard como ventana independiente (modo app sin barra de navegación)
28
+ // Abrir el dashboard en el navegador predeterminado del sistema
31
29
  openDashboard(PORT)
32
30
 
33
- // Abrir una nueva ventana de terminal en el directorio donde se ejecutó npx
34
- openTerminalHere(CWD)
35
-
36
31
  // ─── helpers ────────────────────────────────────────────────────────────────
37
32
 
38
33
  /** Abre el dashboard en el navegador predeterminado del sistema. */
@@ -40,42 +35,3 @@ function openDashboard(port) {
40
35
  const url = `http://localhost:${port}`
41
36
  open(url).catch(() => {})
42
37
  }
43
-
44
- /**
45
- * Abre una nueva ventana de terminal en el directorio indicado.
46
- * Compatible con macOS, Linux (varios emuladores) y Windows.
47
- */
48
- function openTerminalHere(dir) {
49
- try {
50
- if (process.platform === 'darwin') {
51
- // macOS: abrir Terminal.app con cd al directorio de trabajo
52
- // "quoted form of theDir" maneja espacios y caracteres especiales en el path
53
- spawn('osascript', [
54
- '-e', `set theDir to "${dir.replace(/\\/g, '/').replace(/"/g, '\\"')}"`,
55
- '-e', `tell application "Terminal" to do script "cd " & quoted form of theDir`,
56
- ], { detached: true, stdio: 'ignore' }).unref()
57
-
58
- } else if (process.platform === 'linux') {
59
- tryLinuxTerminal(dir, [
60
- ['gnome-terminal', [`--working-directory=${dir}`]],
61
- ['konsole', ['--workdir', dir]],
62
- ['xfce4-terminal', [`--working-directory=${dir}`]],
63
- ['xterm', ['-e', `bash -c "cd '${dir.replace(/'/g, "'\\''")}'; exec bash"`]],
64
- ])
65
-
66
- } else if (process.platform === 'win32') {
67
- spawn('cmd', ['/c', 'start', 'cmd', '/K', `cd /d "${dir}"`],
68
- { detached: true, stdio: 'ignore', shell: true }).unref()
69
- }
70
- } catch {
71
- // silencioso — no bloquear el arranque si no se puede abrir la terminal
72
- }
73
- }
74
-
75
- function tryLinuxTerminal(dir, emulators, i = 0) {
76
- if (i >= emulators.length) return
77
- const [cmd, args] = emulators[i]
78
- const p = spawn(cmd, args, { detached: true, stdio: 'ignore' })
79
- p.on('error', () => tryLinuxTerminal(dir, emulators, i + 1))
80
- p.unref()
81
- }