@dotrino/terminal-agent 0.41.0 → 0.41.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.
package/bin/terminal.js CHANGED
@@ -601,9 +601,13 @@ async function note () {
601
601
  // Dentro de una consola, el perfil es el de esa consola, no el `default`.
602
602
  const dir = opt('--dir') || (opt('--name') ? dataDir(opt('--name')) : process.env.DOTRINO_TERMINAL_PROFILE_DIR || dataDir())
603
603
  const valued = new Set(['--id', '--dir', '--name', '--add', '--task', '--title'])
604
+ const flags = new Set([...valued, '--clear', '--json'])
604
605
  const words = []
605
606
  for (let i = 1; i < args.length; i++) {
606
607
  if (valued.has(args[i])) { i++; continue }
608
+ // Una bandera que no se conoce PARA, no se salta: saltarla dejaba su valor como texto suelto, y
609
+ // el texto suelto reemplaza la nota de la persona (un cliente viejo con `--title` lo hizo).
610
+ if (args[i].startsWith('--') && !flags.has(args[i])) die(t(`no conozco ${args[i]}: no se cambió nada. Mira «dotrino-terminal --help».`, `unknown option ${args[i]}: nothing was changed. See "dotrino-terminal --help".`))
607
611
  if (args[i] === '-' || !args[i].startsWith('-')) words.push(args[i])
608
612
  }
609
613
  const stdin = () => fs.readFileSync(0, 'utf8').replace(/\n+$/, '')
package/desktop.js CHANGED
@@ -79,7 +79,23 @@ export const assetFor = (assets, kind) => pickAsset(assets, [MATCH[kind]])
79
79
  function asRoot (cmd, args, { run, uid }) {
80
80
  const [c, a] = uid === 0 ? [cmd, args] : ['sudo', [cmd, ...args]]
81
81
  run(c, a, { stdio: 'inherit' })
82
- return [c, ...a].join(' ')
82
+ }
83
+
84
+ const has = (cmd, run) => { try { run('sh', ['-c', `command -v ${cmd}`], { stdio: 'ignore' }); return true } catch (_) { return false } }
85
+
86
+ /**
87
+ * Con qué se instala el paquete ya bajado. Se prefiere el gestor que RESUELVE dependencias
88
+ * (`apt-get`, `dnf`, `zypper`) al que solo desempaqueta (`dpkg`, `rpm`): una versión nueva
89
+ * puede pedir una librería que la anterior no pedía, y `rpm -U` se para ahí sin traerla.
90
+ *
91
+ * @returns {[string, string[]]}
92
+ */
93
+ export function packageCommand (kind, file, { run = execFileSync } = {}) {
94
+ if (kind === 'deb') return has('apt-get', run) ? ['apt-get', ['install', '-y', file]] : ['dpkg', ['-i', file]]
95
+ if (has('dnf', run)) return ['dnf', ['install', '-y', file]]
96
+ // El paquete no va firmado con una llave de rpm: lo que se comprobó es su atestación.
97
+ if (has('zypper', run)) return ['zypper', ['--non-interactive', 'install', '--allow-unsigned-rpm', file]]
98
+ return ['rpm', ['-U', file]]
83
99
  }
84
100
 
85
101
  /**
@@ -92,11 +108,10 @@ function asRoot (cmd, args, { run, uid }) {
92
108
  * @returns {any}
93
109
  */
94
110
  export function install (file, how, { exe, run = execFileSync, uid = process.getuid?.() } = {}) {
95
- try {
96
- if (how.kind === 'deb') { asRoot('dpkg', ['-i', file], { run, uid }); return { ok: true } }
97
- if (how.kind === 'rpm') { asRoot('rpm', ['-U', file], { run, uid }); return { ok: true } }
98
- } catch (e) {
99
- return fail('install-failed', `the package manager did not install it: ${e.message}`, { file })
111
+ if (how.kind === 'deb' || how.kind === 'rpm') {
112
+ try { asRoot(...packageCommand(how.kind, file, { run }), { run, uid }); return { ok: true } } catch (e) {
113
+ return fail('install-failed', `the package manager did not install it: ${e.message}`, { file })
114
+ }
100
115
  }
101
116
  if (how.kind === 'tar') {
102
117
  const work = path.dirname(file)
@@ -171,4 +186,4 @@ export async function updateDesktop ({ exe, current, check = false, say = () =>
171
186
  }
172
187
  }
173
188
 
174
- export default { updateDesktop, latestDesktop, installKind, assetFor, install, DESKTOP_TAG, BINARY }
189
+ export default { packageCommand, updateDesktop, latestDesktop, installKind, assetFor, install, DESKTOP_TAG, BINARY }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/terminal-agent",
3
- "version": "0.41.0",
3
+ "version": "0.41.2",
4
4
  "description": "Dotrino Terminal: las ventanas de esta máquina (dotrino-terminal) y su agente, que deja abrir esas mismas consolas desde los otros aparatos de tu cuenta, cifrado punto a punto.",
5
5
  "type": "module",
6
6
  "bin": {