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