media2ascii 1.0.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/bin/media2ascii.js +12 -0
- package/install.js +77 -0
- package/package.json +26 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const bin = path.join(__dirname, "media2ascii");
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
execFileSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
10
|
+
} catch (err) {
|
|
11
|
+
process.exit(err.status || 1);
|
|
12
|
+
}
|
package/install.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const https = require("https");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const { execSync } = require("child_process");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
const zlib = require("zlib");
|
|
9
|
+
|
|
10
|
+
const VERSION = "v1.0.0";
|
|
11
|
+
const REPO = "Andrelbmachado/media2ascii";
|
|
12
|
+
const BIN_DIR = path.join(__dirname, "bin");
|
|
13
|
+
const BIN_PATH = path.join(BIN_DIR, "media2ascii");
|
|
14
|
+
|
|
15
|
+
function getPlatformAsset() {
|
|
16
|
+
const platform = os.platform();
|
|
17
|
+
const arch = os.arch();
|
|
18
|
+
|
|
19
|
+
if (platform === "darwin") {
|
|
20
|
+
if (arch === "arm64") return "media2ascii_darwin_arm64.tar.gz";
|
|
21
|
+
return "media2ascii_darwin_amd64.tar.gz";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Plataforma não suportada: ${platform}/${arch}.\n` +
|
|
26
|
+
`Por favor, compile manualmente: https://github.com/${REPO}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function download(url, dest) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const follow = (u) => {
|
|
33
|
+
https.get(u, { headers: { "User-Agent": "media2ascii-npm-installer" } }, (res) => {
|
|
34
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
35
|
+
follow(res.headers.location);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (res.statusCode !== 200) {
|
|
39
|
+
reject(new Error(`Download falhou: HTTP ${res.statusCode} em ${u}`));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const file = fs.createWriteStream(dest);
|
|
43
|
+
res.pipe(file);
|
|
44
|
+
file.on("finish", () => file.close(resolve));
|
|
45
|
+
file.on("error", reject);
|
|
46
|
+
}).on("error", reject);
|
|
47
|
+
};
|
|
48
|
+
follow(url);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function extractTarGz(tarPath, destDir) {
|
|
53
|
+
execSync(`tar -xzf "${tarPath}" -C "${destDir}"`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function install() {
|
|
57
|
+
if (!fs.existsSync(BIN_DIR)) fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
58
|
+
|
|
59
|
+
const asset = getPlatformAsset();
|
|
60
|
+
const url = `https://github.com/${REPO}/releases/download/${VERSION}/${asset}`;
|
|
61
|
+
const tarPath = path.join(os.tmpdir(), asset);
|
|
62
|
+
|
|
63
|
+
console.log(`Baixando media2ascii ${VERSION}...`);
|
|
64
|
+
await download(url, tarPath);
|
|
65
|
+
|
|
66
|
+
console.log("Extraindo...");
|
|
67
|
+
extractTarGz(tarPath, BIN_DIR);
|
|
68
|
+
fs.unlinkSync(tarPath);
|
|
69
|
+
|
|
70
|
+
fs.chmodSync(BIN_PATH, 0o755);
|
|
71
|
+
console.log("media2ascii instalado com sucesso!");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
install().catch((err) => {
|
|
75
|
+
console.error("Erro na instalação:", err.message);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "media2ascii",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Converta imagens e vídeos em arte ASCII no terminal",
|
|
5
|
+
"bin": {
|
|
6
|
+
"media2ascii": "./bin/media2ascii.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node install.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/",
|
|
13
|
+
"install.js"
|
|
14
|
+
],
|
|
15
|
+
"keywords": ["ascii", "image", "video", "terminal", "cli"],
|
|
16
|
+
"author": "Andrelbmachado",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/Andrelbmachado/media2ascii"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/Andrelbmachado/media2ascii",
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=14"
|
|
25
|
+
}
|
|
26
|
+
}
|