@lacodda/rigger 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/download.js +88 -0
- package/install.js +4 -0
- package/package.json +27 -0
- package/run.js +18 -0
package/download.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Downloads the rigger binary matching this package version from GitHub Releases.
|
|
2
|
+
// Shared by install.js (postinstall, where lifecycle scripts are allowed) and
|
|
3
|
+
// run.js (first-run fallback: npm v12 skips install scripts by default).
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const https = require("https");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const { spawnSync } = require("child_process");
|
|
8
|
+
|
|
9
|
+
const pkg = require("./package.json");
|
|
10
|
+
const REPO = "lacodda/rigger";
|
|
11
|
+
// The wrapper can be patched independently of the Rust binary: an explicit
|
|
12
|
+
// rigger.binary field pins the release tag, otherwise it follows the version.
|
|
13
|
+
const TAG = (pkg.rigger && pkg.rigger.binary) || `v${pkg.version}`;
|
|
14
|
+
|
|
15
|
+
const TARGETS = {
|
|
16
|
+
"win32-x64": ["x86_64-pc-windows-msvc", "zip"],
|
|
17
|
+
"linux-x64": ["x86_64-unknown-linux-gnu", "tar.gz"],
|
|
18
|
+
"darwin-arm64": ["aarch64-apple-darwin", "tar.gz"],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const exe = process.platform === "win32" ? "rigger.exe" : "rigger";
|
|
22
|
+
const exePath = path.join(__dirname, exe);
|
|
23
|
+
|
|
24
|
+
function download(url, file, redirects, done) {
|
|
25
|
+
if (redirects > 5) return done(new Error("too many redirects"));
|
|
26
|
+
https
|
|
27
|
+
.get(url, { headers: { "user-agent": "lacodda-rigger" } }, (res) => {
|
|
28
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
29
|
+
res.resume();
|
|
30
|
+
return download(res.headers.location, file, redirects + 1, done);
|
|
31
|
+
}
|
|
32
|
+
if (res.statusCode !== 200) {
|
|
33
|
+
res.resume();
|
|
34
|
+
return done(new Error(`HTTP ${res.statusCode} for ${url}`));
|
|
35
|
+
}
|
|
36
|
+
const out = fs.createWriteStream(file);
|
|
37
|
+
res.pipe(out);
|
|
38
|
+
out.on("finish", () => out.close(done));
|
|
39
|
+
out.on("error", done);
|
|
40
|
+
})
|
|
41
|
+
.on("error", done);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function install(done) {
|
|
45
|
+
const key = `${process.platform}-${process.arch}`;
|
|
46
|
+
const entry = TARGETS[key];
|
|
47
|
+
if (!entry) {
|
|
48
|
+
console.error(`@lacodda/rigger: no prebuilt binary for ${key}; install with: cargo install rigger`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
const [target, ext] = entry;
|
|
52
|
+
const name = `rigger-${TAG}-${target}`;
|
|
53
|
+
const url = `https://github.com/${REPO}/releases/download/${TAG}/${name}.${ext}`;
|
|
54
|
+
const archive = path.join(__dirname, `archive.${ext}`);
|
|
55
|
+
|
|
56
|
+
console.log(`@lacodda/rigger: downloading ${url}`);
|
|
57
|
+
download(url, archive, 0, (err) => {
|
|
58
|
+
if (err) {
|
|
59
|
+
console.error(`@lacodda/rigger: download failed: ${err.message}`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
// Extraction must not depend on which tar happens to be first in PATH
|
|
63
|
+
// (Git Bash ships a GNU tar that cannot read zip): zip goes through
|
|
64
|
+
// PowerShell's Expand-Archive, tar.gz through tar on Unix systems.
|
|
65
|
+
const result =
|
|
66
|
+
ext === "zip"
|
|
67
|
+
? spawnSync(
|
|
68
|
+
"powershell.exe",
|
|
69
|
+
["-NoProfile", "-NonInteractive", "-Command", "Expand-Archive -LiteralPath 'archive.zip' -DestinationPath . -Force"],
|
|
70
|
+
{ cwd: __dirname, stdio: "inherit" },
|
|
71
|
+
)
|
|
72
|
+
: spawnSync("tar", ["-xzf", `archive.${ext}`], { cwd: __dirname, stdio: "inherit" });
|
|
73
|
+
if (result.status !== 0) {
|
|
74
|
+
console.error("@lacodda/rigger: cannot extract the archive");
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
fs.renameSync(path.join(__dirname, name, exe), exePath);
|
|
78
|
+
fs.rmSync(path.join(__dirname, name), { recursive: true, force: true });
|
|
79
|
+
fs.rmSync(archive, { force: true });
|
|
80
|
+
if (process.platform !== "win32") {
|
|
81
|
+
fs.chmodSync(exePath, 0o755);
|
|
82
|
+
}
|
|
83
|
+
console.log(`@lacodda/rigger: installed rigger ${TAG}`);
|
|
84
|
+
done();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
module.exports = { install, exePath };
|
package/install.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lacodda/rigger",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"rigger": {
|
|
5
|
+
"binary": "v0.1.0"
|
|
6
|
+
},
|
|
7
|
+
"description": "One seat for all your projects and tasks: a local record of what is done, what is next and when it ships - read by you and your coding assistant",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "Kirill Lakhtachev <lahtachev@gmail.com> (https://lacodda.com)",
|
|
10
|
+
"homepage": "https://lacodda.github.io/rigger/",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/lacodda/rigger.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": ["cli", "project-management", "tasks", "mcp", "release-calendar", "developer-tools"],
|
|
16
|
+
"bin": {
|
|
17
|
+
"rigger": "run.js"
|
|
18
|
+
},
|
|
19
|
+
"files": ["download.js", "install.js", "run.js"],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"postinstall": "node install.js"
|
|
22
|
+
},
|
|
23
|
+
"os": ["win32", "darwin", "linux"],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/run.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Thin launcher: forwards everything to the rigger binary, downloading it on
|
|
3
|
+
// first run when the postinstall script was skipped (npm v12 default).
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const { spawnSync } = require("child_process");
|
|
6
|
+
const { install, exePath } = require("./download");
|
|
7
|
+
|
|
8
|
+
function exec() {
|
|
9
|
+
const result = spawnSync(exePath, process.argv.slice(2), { stdio: "inherit" });
|
|
10
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (fs.existsSync(exePath)) {
|
|
14
|
+
exec();
|
|
15
|
+
} else {
|
|
16
|
+
console.error("@lacodda/rigger: binary not present yet - downloading it now");
|
|
17
|
+
install(exec);
|
|
18
|
+
}
|