devrounds 0.0.0-stage → 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/README.md +9 -2
- package/bin/devrounds.js +13 -0
- package/install.js +71 -0
- package/package.json +25 -4
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# devrounds
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One local CLI that runs a "round" of checks on any repo or dev machine.
|
|
4
|
+
|
|
5
|
+
This npm package downloads the prebuilt `devrounds` binary for your platform from GitHub Releases and verifies its checksum.
|
|
6
|
+
|
|
7
|
+
npm install -g devrounds
|
|
8
|
+
devrounds --version
|
|
9
|
+
|
|
10
|
+
Full documentation: https://github.com/devrounds/devrounds
|
package/bin/devrounds.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { spawnSync } = require("child_process");
|
|
5
|
+
|
|
6
|
+
const name = process.platform === "win32" ? "devrounds.exe" : "devrounds";
|
|
7
|
+
const exe = path.join(__dirname, "..", "vendor", name);
|
|
8
|
+
const res = spawnSync(exe, process.argv.slice(2), { stdio: "inherit" });
|
|
9
|
+
if (res.error) {
|
|
10
|
+
console.error("devrounds: could not run " + exe + ": " + res.error.message);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
process.exit(res.status === null ? 1 : res.status);
|
package/install.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const os = require("os");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const crypto = require("crypto");
|
|
6
|
+
const { execFileSync } = require("child_process");
|
|
7
|
+
|
|
8
|
+
const version = require("./package.json").version;
|
|
9
|
+
const platforms = { linux: "linux", darwin: "darwin", win32: "windows" };
|
|
10
|
+
const arches = { x64: "amd64", arm64: "arm64" };
|
|
11
|
+
|
|
12
|
+
const goos = platforms[process.platform];
|
|
13
|
+
const goarch = arches[process.arch];
|
|
14
|
+
if (!goos || !goarch) {
|
|
15
|
+
console.error("devrounds: unsupported platform " + process.platform + "/" + process.arch);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const ext = goos === "windows" ? "zip" : "tar.gz";
|
|
20
|
+
const archive = "devrounds_" + version + "_" + goos + "_" + goarch + "." + ext;
|
|
21
|
+
const base = "https://github.com/devrounds/devrounds/releases/download/v" + version;
|
|
22
|
+
const vendor = path.join(__dirname, "vendor");
|
|
23
|
+
const exe = path.join(vendor, goos === "windows" ? "devrounds.exe" : "devrounds");
|
|
24
|
+
|
|
25
|
+
async function download(url) {
|
|
26
|
+
const res = await fetch(url);
|
|
27
|
+
if (!res.ok) {
|
|
28
|
+
throw new Error("download failed (" + res.status + "): " + url);
|
|
29
|
+
}
|
|
30
|
+
return Buffer.from(await res.arrayBuffer());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function tarCommand() {
|
|
34
|
+
if (process.platform === "win32") {
|
|
35
|
+
return path.join(process.env.SystemRoot || "C:\\Windows", "System32", "tar.exe");
|
|
36
|
+
}
|
|
37
|
+
return "tar";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function main() {
|
|
41
|
+
if (fs.existsSync(exe)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const data = await download(base + "/" + archive);
|
|
45
|
+
const sums = (await download(base + "/checksums.txt")).toString("utf8");
|
|
46
|
+
const line = sums.split(/\r?\n/).find((l) => l.trim().endsWith(archive));
|
|
47
|
+
if (!line) {
|
|
48
|
+
throw new Error("no checksum listed for " + archive);
|
|
49
|
+
}
|
|
50
|
+
const expected = line.trim().split(/\s+/)[0];
|
|
51
|
+
const actual = crypto.createHash("sha256").update(data).digest("hex");
|
|
52
|
+
if (expected !== actual) {
|
|
53
|
+
throw new Error("checksum mismatch for " + archive);
|
|
54
|
+
}
|
|
55
|
+
fs.mkdirSync(vendor, { recursive: true });
|
|
56
|
+
const tmp = path.join(os.tmpdir(), archive + "." + process.pid);
|
|
57
|
+
fs.writeFileSync(tmp, data);
|
|
58
|
+
try {
|
|
59
|
+
execFileSync(tarCommand(), ["-xf", tmp, "-C", vendor], { stdio: "inherit" });
|
|
60
|
+
} finally {
|
|
61
|
+
fs.rmSync(tmp, { force: true });
|
|
62
|
+
}
|
|
63
|
+
if (goos !== "windows") {
|
|
64
|
+
fs.chmodSync(exe, 0o755);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main().catch((err) => {
|
|
69
|
+
console.error("devrounds: " + err.message);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devrounds",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "One local CLI that runs a round of checks on any repo or dev machine.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"devrounds": "bin/devrounds.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node install.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"install.js",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18"
|
|
19
|
+
},
|
|
20
|
+
"keywords": ["cli", "developer-tools", "env", "readiness"],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/devrounds/devrounds.git",
|
|
24
|
+
"directory": "npm"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/devrounds/devrounds"
|
|
27
|
+
}
|