@dotrino/terminal-agent 0.41.1 → 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/desktop.js +22 -7
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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.
|
|
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": {
|