christ-cli 0.1.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/run.js +16 -0
- package/install.js +103 -0
- package/package.json +25 -0
package/bin/run.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execFileSync } = require("child_process");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const os = require("os");
|
|
5
|
+
|
|
6
|
+
const ext = os.platform() === "win32" ? ".exe" : "";
|
|
7
|
+
const binary = path.join(__dirname, `christ${ext}`);
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
11
|
+
} catch (err) {
|
|
12
|
+
if (err.status !== null) {
|
|
13
|
+
process.exit(err.status);
|
|
14
|
+
}
|
|
15
|
+
throw err;
|
|
16
|
+
}
|
package/install.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const https = require("https");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
|
|
7
|
+
const REPO = "whoisyurii/christ-cli";
|
|
8
|
+
const BINARY = "christ";
|
|
9
|
+
|
|
10
|
+
function getPlatform() {
|
|
11
|
+
const platform = os.platform();
|
|
12
|
+
const arch = os.arch();
|
|
13
|
+
|
|
14
|
+
const targets = {
|
|
15
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
16
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
17
|
+
"linux-x64": "x86_64-unknown-linux-gnu",
|
|
18
|
+
"linux-arm64": "aarch64-unknown-linux-gnu",
|
|
19
|
+
"win32-x64": "x86_64-pc-windows-msvc",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const key = `${platform}-${arch}`;
|
|
23
|
+
const target = targets[key];
|
|
24
|
+
|
|
25
|
+
if (!target) {
|
|
26
|
+
console.error(`Unsupported platform: ${key}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return { target, isWindows: platform === "win32" };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getLatestVersion() {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
https.get(
|
|
36
|
+
`https://api.github.com/repos/${REPO}/releases/latest`,
|
|
37
|
+
{ headers: { "User-Agent": "christ-cli-npm" } },
|
|
38
|
+
(res) => {
|
|
39
|
+
let data = "";
|
|
40
|
+
res.on("data", (chunk) => (data += chunk));
|
|
41
|
+
res.on("end", () => {
|
|
42
|
+
try {
|
|
43
|
+
const json = JSON.parse(data);
|
|
44
|
+
resolve(json.tag_name.replace("v", ""));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
).on("error", reject);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function download(url, dest) {
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
const follow = (url) => {
|
|
57
|
+
https.get(url, { headers: { "User-Agent": "christ-cli-npm" } }, (res) => {
|
|
58
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
59
|
+
follow(res.headers.location);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (res.statusCode !== 200) {
|
|
63
|
+
reject(new Error(`Download failed: HTTP ${res.statusCode}`));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const file = fs.createWriteStream(dest);
|
|
67
|
+
res.pipe(file);
|
|
68
|
+
file.on("finish", () => file.close(resolve));
|
|
69
|
+
}).on("error", reject);
|
|
70
|
+
};
|
|
71
|
+
follow(url);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function main() {
|
|
76
|
+
const { target, isWindows } = getPlatform();
|
|
77
|
+
const version = await getLatestVersion();
|
|
78
|
+
const ext = isWindows ? "zip" : "tar.gz";
|
|
79
|
+
const url = `https://github.com/${REPO}/releases/download/v${version}/${BINARY}-${target}.${ext}`;
|
|
80
|
+
|
|
81
|
+
console.log(`Downloading christ-cli v${version} for ${target}...`);
|
|
82
|
+
|
|
83
|
+
const binDir = path.join(__dirname, "bin");
|
|
84
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
85
|
+
|
|
86
|
+
const archivePath = path.join(binDir, `christ.${ext}`);
|
|
87
|
+
await download(url, archivePath);
|
|
88
|
+
|
|
89
|
+
if (isWindows) {
|
|
90
|
+
execSync(`tar -xf "${archivePath}" -C "${binDir}"`, { stdio: "inherit" });
|
|
91
|
+
} else {
|
|
92
|
+
execSync(`tar xzf "${archivePath}" -C "${binDir}"`, { stdio: "inherit" });
|
|
93
|
+
fs.chmodSync(path.join(binDir, BINARY), 0o755);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fs.unlinkSync(archivePath);
|
|
97
|
+
console.log("christ-cli installed successfully!");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
main().catch((err) => {
|
|
101
|
+
console.error("Installation failed:", err.message);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "christ-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A beautiful Bible TUI for Christian developers",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/whoisyurii/christ-cli"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"christ": "bin/run.js"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"postinstall": "node install.js"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"bible",
|
|
18
|
+
"cli",
|
|
19
|
+
"tui",
|
|
20
|
+
"christian",
|
|
21
|
+
"scripture",
|
|
22
|
+
"kjv"
|
|
23
|
+
],
|
|
24
|
+
"author": "whoisyurii"
|
|
25
|
+
}
|