palabra 1.4.0 → 1.6.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/ChangeLog +11 -0
- package/letras/bun.json +1 -1
- package/letras/deno.json +1 -1
- package/letras/go.json +9 -0
- package/letras/rust.json +9 -0
- package/lib/buscar.js +1 -0
- package/lib/hablar.js +0 -2
- package/lib/parser/execute.js +5 -1
- package/lib/parser/parser.js +42 -6
- package/lib/parser/unpack.js +3 -4
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/letras/bun.json
CHANGED
package/letras/deno.json
CHANGED
package/letras/go.json
ADDED
package/letras/rust.json
ADDED
package/lib/buscar.js
CHANGED
package/lib/hablar.js
CHANGED
package/lib/parser/execute.js
CHANGED
|
@@ -5,18 +5,22 @@ const {entries} = Object;
|
|
|
5
5
|
export const execute = (letra) => {
|
|
6
6
|
const commands = [];
|
|
7
7
|
const {
|
|
8
|
+
|
|
8
9
|
url,
|
|
9
10
|
env = {},
|
|
11
|
+
confirmar,
|
|
10
12
|
} = letra;
|
|
11
13
|
|
|
12
14
|
const envLine = [];
|
|
13
15
|
|
|
14
16
|
for (const [name, value] of entries(env)) {
|
|
15
17
|
const envValue = rendy(value, letra);
|
|
18
|
+
|
|
16
19
|
envLine.push(`${name}=${envValue}`);
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
const
|
|
22
|
+
const arg = confirmar ? '' : ' -- -y';
|
|
23
|
+
const curl = `bash -c "$(curl -fsSL ${url})"${arg}`;
|
|
20
24
|
|
|
21
25
|
if (!envLine.length) {
|
|
22
26
|
commands.push(curl);
|
package/lib/parser/parser.js
CHANGED
|
@@ -2,7 +2,19 @@ import {extname, join} from 'node:path';
|
|
|
2
2
|
import {unpack} from './unpack.js';
|
|
3
3
|
import {execute} from './execute.js';
|
|
4
4
|
|
|
5
|
+
const {entries} = Object;
|
|
6
|
+
|
|
7
|
+
const isString = (a) => typeof a === 'string';
|
|
8
|
+
|
|
9
|
+
const addDefaults = (letra) => ({
|
|
10
|
+
confirmar: true,
|
|
11
|
+
camino: '~/.local/src',
|
|
12
|
+
...letra,
|
|
13
|
+
});
|
|
14
|
+
|
|
5
15
|
export const parse = (letra) => {
|
|
16
|
+
letra = addDefaults(letra);
|
|
17
|
+
|
|
6
18
|
const commands = [];
|
|
7
19
|
const {
|
|
8
20
|
url,
|
|
@@ -11,18 +23,42 @@ export const parse = (letra) => {
|
|
|
11
23
|
camino,
|
|
12
24
|
} = letra;
|
|
13
25
|
|
|
14
|
-
const
|
|
26
|
+
const ext = extname(new URL(url).pathname);
|
|
15
27
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (ext === '.tgz')
|
|
28
|
+
if (ext === '.tgz' || ext === '.gz')
|
|
19
29
|
commands.push(...unpack(letra));
|
|
20
30
|
|
|
21
31
|
if (!ext || ext === '.sh')
|
|
22
32
|
commands.push(...execute(letra));
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
commands.push(...createSymlinks({
|
|
35
|
+
camino,
|
|
36
|
+
name,
|
|
37
|
+
bin,
|
|
38
|
+
}));
|
|
26
39
|
|
|
27
40
|
return commands;
|
|
28
41
|
};
|
|
42
|
+
|
|
43
|
+
function createSymlinks({camino, name, bin}) {
|
|
44
|
+
const commands = [];
|
|
45
|
+
const parsedBin = parseBin(name, bin);
|
|
46
|
+
|
|
47
|
+
for (const [name, from] of entries(parsedBin)) {
|
|
48
|
+
const binFrom = join(camino, from);
|
|
49
|
+
const binTo = join(camino, '..', `bin/${name}`);
|
|
50
|
+
|
|
51
|
+
commands.push(`ln -fs ${binFrom} ${binTo}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return commands;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function parseBin(name, bin) {
|
|
58
|
+
if (isString(bin))
|
|
59
|
+
return {
|
|
60
|
+
[name]: `${name}/${bin}`,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return bin;
|
|
64
|
+
}
|
package/lib/parser/unpack.js
CHANGED
|
@@ -13,11 +13,10 @@ export const unpack = (letra) => {
|
|
|
13
13
|
const filename = basename(renderedurl);
|
|
14
14
|
|
|
15
15
|
commands.push(`wget ${renderedurl}`);
|
|
16
|
-
commands.push(`tar zxf ${filename}`);
|
|
17
|
-
commands.push(`rm ${filename}`);
|
|
18
|
-
commands.push(`mkdir -p ${camino}`);
|
|
19
16
|
commands.push(`rm -rf ${camino}/${name}`);
|
|
20
|
-
commands.push(`
|
|
17
|
+
commands.push(`mkdir -p ${camino}/${name}`);
|
|
18
|
+
commands.push(`tar zxf ${filename} -C ${camino}/${name}`);
|
|
19
|
+
commands.push(`rm ${filename}`);
|
|
21
20
|
|
|
22
21
|
return commands;
|
|
23
22
|
};
|