palabra 1.2.0 → 1.4.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 +7 -0
- package/letras/deno.json +7 -0
- package/letras/fasm.json +1 -1
- package/lib/parser/execute.js +29 -0
- package/lib/parser/parser.js +16 -14
- package/lib/parser/unpack.js +23 -0
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/letras/bun.json
ADDED
package/letras/deno.json
ADDED
package/letras/fasm.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {rendy} from 'rendy';
|
|
2
|
+
|
|
3
|
+
const {entries} = Object;
|
|
4
|
+
|
|
5
|
+
export const execute = (letra) => {
|
|
6
|
+
const commands = [];
|
|
7
|
+
const {
|
|
8
|
+
url,
|
|
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
|
+
const curl = `bash -c "$(curl -fsSL ${url})"`;
|
|
20
|
+
|
|
21
|
+
if (!envLine.length) {
|
|
22
|
+
commands.push(curl);
|
|
23
|
+
return commands;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
commands.push(`${envLine.join(' ')} ${curl}`);
|
|
27
|
+
|
|
28
|
+
return commands;
|
|
29
|
+
};
|
package/lib/parser/parser.js
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {extname, join} 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 = [];
|
|
6
7
|
const {
|
|
7
|
-
|
|
8
|
+
url,
|
|
8
9
|
name,
|
|
9
|
-
bin
|
|
10
|
+
bin = `/bin/${name}`,
|
|
10
11
|
camino,
|
|
11
12
|
} = letra;
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
const filename = basename(renderedLink);
|
|
15
|
-
const dirBin = normalize(`${camino}/../bin/${name}`);
|
|
14
|
+
const binTo = join(camino, '..', `bin/${name}`);
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const ext = extname(url);
|
|
17
|
+
|
|
18
|
+
if (ext === '.tgz')
|
|
19
|
+
commands.push(...unpack(letra));
|
|
20
|
+
|
|
21
|
+
if (!ext || ext === '.sh')
|
|
22
|
+
commands.push(...execute(letra));
|
|
23
|
+
|
|
24
|
+
const binFrom = join(camino, name, bin);
|
|
25
|
+
commands.push(`ln -fs ${binFrom} ${binTo}`);
|
|
24
26
|
|
|
25
27
|
return commands;
|
|
26
28
|
};
|
|
@@ -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
|
+
url,
|
|
9
|
+
camino,
|
|
10
|
+
} = letra;
|
|
11
|
+
|
|
12
|
+
const renderedurl = rendy(url, letra);
|
|
13
|
+
const filename = basename(renderedurl);
|
|
14
|
+
|
|
15
|
+
commands.push(`wget ${renderedurl}`);
|
|
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
|
+
};
|