palabra 1.2.0 → 1.3.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 +5 -0
- package/letras/deno.json +8 -0
- package/lib/parser/execute.js +27 -0
- package/lib/parser/parser.js +9 -10
- package/lib/parser/unpack.js +23 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/letras/deno.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {rendy} from 'rendy';
|
|
2
|
+
|
|
3
|
+
const {entries} = Object;
|
|
4
|
+
|
|
5
|
+
export const execute = (letra) => {
|
|
6
|
+
const commands = [];
|
|
7
|
+
const {
|
|
8
|
+
link,
|
|
9
|
+
env = {},
|
|
10
|
+
} = letra;
|
|
11
|
+
|
|
12
|
+
const envLine = [];
|
|
13
|
+
|
|
14
|
+
for (const [name, value] of entries(env)) {
|
|
15
|
+
const envValue = rendy(value, letra);
|
|
16
|
+
envLine.push(`${name}=${envValue}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!envLine.length) {
|
|
20
|
+
commands.push(`curl -fsSL ${link} | sh`);
|
|
21
|
+
return commands;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
commands.push(`${envLine.join(' ')} curl -fsSL ${link} | sh`);
|
|
25
|
+
|
|
26
|
+
return commands;
|
|
27
|
+
};
|
package/lib/parser/parser.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {normalize} from 'node:path';
|
|
2
|
+
import {unpack} from './unpack.js';
|
|
3
|
+
import {execute} from './execute.js';
|
|
3
4
|
|
|
4
5
|
export const parse = (letra) => {
|
|
5
6
|
const commands = [];
|
|
@@ -10,16 +11,14 @@ export const parse = (letra) => {
|
|
|
10
11
|
camino,
|
|
11
12
|
} = letra;
|
|
12
13
|
|
|
13
|
-
const renderedLink = rendy(link, letra);
|
|
14
|
-
const filename = basename(renderedLink);
|
|
15
14
|
const dirBin = normalize(`${camino}/../bin/${name}`);
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
if (link.endsWith('tgz'))
|
|
17
|
+
commands.push(...unpack(letra));
|
|
18
|
+
|
|
19
|
+
if (link.endsWith('sh'))
|
|
20
|
+
commands.push(...execute(letra));
|
|
21
|
+
|
|
23
22
|
commands.push(`ln -fs ${camino}/${name}/${bin} ${dirBin}`);
|
|
24
23
|
|
|
25
24
|
return commands;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {basename} from 'node:path';
|
|
2
|
+
import {rendy} from 'rendy';
|
|
3
|
+
|
|
4
|
+
export const unpack = (letra) => {
|
|
5
|
+
const commands = [];
|
|
6
|
+
const {
|
|
7
|
+
name,
|
|
8
|
+
link,
|
|
9
|
+
camino,
|
|
10
|
+
} = letra;
|
|
11
|
+
|
|
12
|
+
const renderedLink = rendy(link, letra);
|
|
13
|
+
const filename = basename(renderedLink);
|
|
14
|
+
|
|
15
|
+
commands.push(`wget ${renderedLink}`);
|
|
16
|
+
commands.push(`tar zxf ${filename}`);
|
|
17
|
+
commands.push(`rm ${filename}`);
|
|
18
|
+
commands.push(`mkdir -p ${camino}`);
|
|
19
|
+
commands.push(`rm -rf ${camino}/${name}`);
|
|
20
|
+
commands.push(`mv -f ${name} ${camino}/${name}`);
|
|
21
|
+
|
|
22
|
+
return commands;
|
|
23
|
+
};
|