puxadinho 0.1.0 → 0.1.1
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/bin/puxadinho.js +31 -6
- package/checksums.txt +4 -4
- package/package.json +5 -5
package/bin/puxadinho.js
CHANGED
|
@@ -12,8 +12,9 @@ const path = require("node:path");
|
|
|
12
12
|
|
|
13
13
|
const pkg = require("../package.json");
|
|
14
14
|
const version = pkg.version;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const zlib = require("node:zlib");
|
|
16
|
+
// Reserva: o mesmo pacote da plataforma, baixado direto do registro do npm (.tgz).
|
|
17
|
+
const DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
17
18
|
|
|
18
19
|
const OS = { darwin: "darwin", linux: "linux" };
|
|
19
20
|
const ARCH = { arm64: "arm64", x64: "amd64" };
|
|
@@ -41,6 +42,22 @@ function platformBinary() {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
/** Extrai um arquivo de um tar (ustar) já descompactado. */
|
|
46
|
+
function fileFromTar(buf, want) {
|
|
47
|
+
for (let off = 0; off + 512 <= buf.length; ) {
|
|
48
|
+
const h = buf.subarray(off, off + 512);
|
|
49
|
+
if (h.every((b) => b === 0)) break;
|
|
50
|
+
const str = (a, b) => h.subarray(a, b).toString("utf8").replace(/\0.*$/s, "");
|
|
51
|
+
const prefix = str(345, 500);
|
|
52
|
+
const name = prefix ? `${prefix}/${str(0, 100)}` : str(0, 100);
|
|
53
|
+
const size = parseInt(str(124, 136).trim() || "0", 8);
|
|
54
|
+
const start = off + 512;
|
|
55
|
+
if (name === want) return buf.subarray(start, start + size);
|
|
56
|
+
off = start + Math.ceil(size / 512) * 512;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
44
61
|
async function ensureBinary() {
|
|
45
62
|
const local = platformBinary();
|
|
46
63
|
if (local) return local;
|
|
@@ -62,14 +79,22 @@ async function ensureBinary() {
|
|
|
62
79
|
} catch {
|
|
63
80
|
fail("este pacote veio sem checksums.txt; reinstale o puxadinho (npm i -g puxadinho@latest).");
|
|
64
81
|
}
|
|
65
|
-
const base = (process.env.PUXADINHO_DOWNLOAD_BASE || DEFAULT_BASE).replace(/\/+$/, "");
|
|
66
|
-
const root = `${base}/v${version}`;
|
|
67
82
|
process.stderr.write(`puxadinho: baixando ${name} v${version}…\n`);
|
|
68
83
|
let bin;
|
|
69
84
|
try {
|
|
70
|
-
|
|
85
|
+
if (process.env.PUXADINHO_DOWNLOAD_BASE) {
|
|
86
|
+
// Espelho com o layout de release: <base>/v<versão>/<binário>.
|
|
87
|
+
const base = process.env.PUXADINHO_DOWNLOAD_BASE.replace(/\/+$/, "");
|
|
88
|
+
bin = await fetchBuffer(`${base}/v${version}/${name}`);
|
|
89
|
+
} else {
|
|
90
|
+
const reg = (process.env.npm_config_registry || DEFAULT_REGISTRY).replace(/\/+$/, "");
|
|
91
|
+
const plat = `cli-${process.platform}-${process.arch}`;
|
|
92
|
+
const tgz = await fetchBuffer(`${reg}/@puxadinho/${plat}/-/${plat}-${version}.tgz`);
|
|
93
|
+
bin = fileFromTar(zlib.gunzipSync(tgz), "package/bin/puxadinho");
|
|
94
|
+
if (!bin) throw new Error(`o pacote @puxadinho/${plat} veio sem bin/puxadinho`);
|
|
95
|
+
}
|
|
71
96
|
} catch (err) {
|
|
72
|
-
fail(`não consegui baixar o binário (${err.message}). Verifique a rede ou
|
|
97
|
+
fail(`não consegui baixar o binário (${err.message}). Verifique a rede ou o registro do npm.`, 75);
|
|
73
98
|
}
|
|
74
99
|
const line = sums.split("\n").map((l) => l.trim().split(/\s+/)).find((p) => p[1] === name || p[1] === `*${name}`);
|
|
75
100
|
if (!line) fail(`o checksums.txt do pacote não lista ${name}.`);
|
package/checksums.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
e2e6bd0da352c021c1440f18533c099abb90e5f6e9b75b109f1a4e62896526b9 puxadinho_darwin_arm64
|
|
2
|
+
a9a468933c3649e6b62f68723df7faa1fc81e68c3bc548f0b5d9252d48a416d3 puxadinho_darwin_amd64
|
|
3
|
+
bbefcb248a2b64f8061278f8445ddbf20dce09e00eb647b3cda680f40b592a52 puxadinho_linux_amd64
|
|
4
|
+
53f93111a199c0e97c2e943cbc85a2869d0710848f9dd89d626bd4c671482072 puxadinho_linux_arm64
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "puxadinho",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "CLI do puxadinho: boxes Linux na nuvem para você e seus agentes.",
|
|
5
5
|
"license": "SEE LICENSE IN README.md",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"build:binaries": "node scripts/build-binaries.js"
|
|
23
23
|
},
|
|
24
24
|
"optionalDependencies": {
|
|
25
|
-
"@puxadinho/cli-darwin-arm64": "0.1.
|
|
26
|
-
"@puxadinho/cli-darwin-x64": "0.1.
|
|
27
|
-
"@puxadinho/cli-linux-arm64": "0.1.
|
|
28
|
-
"@puxadinho/cli-linux-x64": "0.1.
|
|
25
|
+
"@puxadinho/cli-darwin-arm64": "0.1.1",
|
|
26
|
+
"@puxadinho/cli-darwin-x64": "0.1.1",
|
|
27
|
+
"@puxadinho/cli-linux-arm64": "0.1.1",
|
|
28
|
+
"@puxadinho/cli-linux-x64": "0.1.1"
|
|
29
29
|
}
|
|
30
30
|
}
|