@aryaminus/controlkeel 0.1.14
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/README.md +19 -0
- package/bin/controlkeel.js +23 -0
- package/lib/install.js +108 -0
- package/lib/postinstall.js +12 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @aryaminus/controlkeel
|
|
2
|
+
|
|
3
|
+
This package is a bootstrap installer for the native ControlKeel CLI.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -g @aryaminus/controlkeel
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The package downloads the matching ControlKeel binary from GitHub Releases and exposes the `controlkeel` command.
|
|
12
|
+
|
|
13
|
+
You can also install the same bootstrap package from GitHub Packages:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
echo "@aryaminus:registry=https://npm.pkg.github.com" >> ~/.npmrc
|
|
17
|
+
echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_CLASSIC_PAT" >> ~/.npmrc
|
|
18
|
+
npm i -g @aryaminus/controlkeel --registry=https://npm.pkg.github.com
|
|
19
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require("node:child_process");
|
|
4
|
+
const { ensureBinary } = require("../lib/install");
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const binaryPath = await ensureBinary({ forceDownload: false });
|
|
8
|
+
const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
9
|
+
|
|
10
|
+
child.on("exit", (code, signal) => {
|
|
11
|
+
if (signal) {
|
|
12
|
+
process.kill(process.pid, signal);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
process.exit(code ?? 0);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
main().catch((error) => {
|
|
21
|
+
console.error(error.message || error);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
});
|
package/lib/install.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const os = require("node:os");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const https = require("node:https");
|
|
7
|
+
|
|
8
|
+
const REPOSITORY = process.env.CONTROLKEEL_GITHUB_REPO || "aryaminus/controlkeel";
|
|
9
|
+
const VERSION = process.env.CONTROLKEEL_VERSION || "latest";
|
|
10
|
+
|
|
11
|
+
function releaseBaseUrl() {
|
|
12
|
+
if (VERSION === "latest") {
|
|
13
|
+
return `https://github.com/${REPOSITORY}/releases/latest/download`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return `https://github.com/${REPOSITORY}/releases/download/v${VERSION}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function assetName(platform = process.platform, arch = process.arch) {
|
|
20
|
+
if (platform === "linux" && arch === "x64") {
|
|
21
|
+
return "controlkeel-linux-x86_64";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (platform === "darwin" && arch === "x64") {
|
|
25
|
+
return "controlkeel-macos-x86_64";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (platform === "darwin" && arch === "arm64") {
|
|
29
|
+
return "controlkeel-macos-arm64";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (platform === "win32" && arch === "x64") {
|
|
33
|
+
return "controlkeel-windows-x86_64.exe";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
throw new Error(`Unsupported platform for ControlKeel: ${platform}/${arch}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function binaryFilename(platform = process.platform) {
|
|
40
|
+
return platform === "win32" ? "controlkeel.exe" : "controlkeel";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function binaryPath() {
|
|
44
|
+
return path.join(__dirname, "..", "vendor", binaryFilename());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function ensureVendorDir() {
|
|
48
|
+
fs.mkdirSync(path.dirname(binaryPath()), { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function download(url, destination) {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
const request = https.get(url, (response) => {
|
|
54
|
+
if (response.statusCode && response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
|
|
55
|
+
response.resume();
|
|
56
|
+
download(response.headers.location, destination).then(resolve, reject);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (response.statusCode !== 200) {
|
|
61
|
+
reject(new Error(`Failed to download ${url} (HTTP ${response.statusCode})`));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const file = fs.createWriteStream(destination);
|
|
66
|
+
response.pipe(file);
|
|
67
|
+
|
|
68
|
+
file.on("finish", () => {
|
|
69
|
+
file.close(() => resolve(destination));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
file.on("error", (error) => {
|
|
73
|
+
fs.rmSync(destination, { force: true });
|
|
74
|
+
reject(error);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
request.on("error", reject);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function ensureBinary({ forceDownload = false } = {}) {
|
|
83
|
+
const destination = binaryPath();
|
|
84
|
+
|
|
85
|
+
if (!forceDownload && fs.existsSync(destination)) {
|
|
86
|
+
return destination;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
ensureVendorDir();
|
|
90
|
+
const tempPath = path.join(os.tmpdir(), `${assetName()}-${Date.now()}`);
|
|
91
|
+
const url = `${releaseBaseUrl()}/${assetName()}`;
|
|
92
|
+
|
|
93
|
+
await download(url, tempPath);
|
|
94
|
+
fs.copyFileSync(tempPath, destination);
|
|
95
|
+
fs.rmSync(tempPath, { force: true });
|
|
96
|
+
|
|
97
|
+
if (process.platform !== "win32") {
|
|
98
|
+
fs.chmodSync(destination, 0o755);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return destination;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = {
|
|
105
|
+
assetName,
|
|
106
|
+
binaryPath,
|
|
107
|
+
ensureBinary
|
|
108
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { ensureBinary } = require("./install");
|
|
4
|
+
|
|
5
|
+
if (process.env.CONTROLKEEL_SKIP_DOWNLOAD === "1") {
|
|
6
|
+
process.exit(0);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
ensureBinary({ forceDownload: true }).catch((error) => {
|
|
10
|
+
console.error(error.message || error);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aryaminus/controlkeel",
|
|
3
|
+
"version": "0.1.14",
|
|
4
|
+
"description": "Bootstrap installer for the ControlKeel native CLI.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/aryaminus/controlkeel.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/aryaminus/controlkeel#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/aryaminus/controlkeel/issues"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"controlkeel": "bin/controlkeel.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin",
|
|
19
|
+
"lib",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"postinstall": "node lib/postinstall.js"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=18"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
}
|
|
31
|
+
}
|