whichdep 0.0.0-stage → 0.0.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/bin/install.js +80 -0
- package/bin/whichdep.js +28 -0
- package/package.json +46 -4
- package/README.md +0 -3
package/bin/install.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const { execFileSync } = require("node:child_process");
|
|
7
|
+
|
|
8
|
+
const pkg = require("../package.json");
|
|
9
|
+
|
|
10
|
+
const TARGETS = {
|
|
11
|
+
"darwin:arm64": "aarch64-apple-darwin",
|
|
12
|
+
"darwin:x64": "x86_64-apple-darwin",
|
|
13
|
+
"linux:x64": "x86_64-unknown-linux-gnu",
|
|
14
|
+
"linux:arm64": "aarch64-unknown-linux-gnu",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function targetTriple() {
|
|
18
|
+
return TARGETS[`${process.platform}:${process.arch}`] || null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function binaryPath() {
|
|
22
|
+
return path.join(__dirname, "whichdep-bin");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function downloadBinary({ silent = false } = {}) {
|
|
26
|
+
const triple = targetTriple();
|
|
27
|
+
if (!triple) {
|
|
28
|
+
if (!silent) {
|
|
29
|
+
console.warn(
|
|
30
|
+
`whichdep: no prebuilt binary for ${process.platform}/${process.arch}; install via \`cargo install whichdep\` or \`uvx whichdep\`.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const dest = binaryPath();
|
|
37
|
+
if (fs.existsSync(dest)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const version = pkg.version;
|
|
42
|
+
const asset = `whichdep-v${version}-${triple}.tar.gz`;
|
|
43
|
+
const url = `https://github.com/devel0mer/whichdep/releases/download/v${version}/${asset}`;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const res = await fetch(url, { redirect: "follow" });
|
|
47
|
+
if (!res.ok) {
|
|
48
|
+
if (!silent) {
|
|
49
|
+
console.warn(
|
|
50
|
+
`whichdep: could not download ${url} (HTTP ${res.status}); install via \`cargo install whichdep\` if offline.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
56
|
+
const tmpDir = fs.mkdtempSync(path.join(__dirname, ".tmp-"));
|
|
57
|
+
const archive = path.join(tmpDir, asset);
|
|
58
|
+
try {
|
|
59
|
+
fs.writeFileSync(archive, buf);
|
|
60
|
+
execFileSync("tar", ["-xzf", archive, "-C", tmpDir], { stdio: "ignore" });
|
|
61
|
+
const extracted = path.join(tmpDir, "whichdep");
|
|
62
|
+
fs.renameSync(extracted, dest);
|
|
63
|
+
fs.chmodSync(dest, 0o755);
|
|
64
|
+
return true;
|
|
65
|
+
} finally {
|
|
66
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
67
|
+
}
|
|
68
|
+
} catch (err) {
|
|
69
|
+
if (!silent) {
|
|
70
|
+
console.warn(`whichdep: postinstall download skipped (${err.message}).`);
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = { binaryPath, downloadBinary };
|
|
77
|
+
|
|
78
|
+
if (require.main === module) {
|
|
79
|
+
downloadBinary().then(() => process.exit(0));
|
|
80
|
+
}
|
package/bin/whichdep.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const { spawnSync } = require("node:child_process");
|
|
6
|
+
const { binaryPath, downloadBinary } = require("./install.js");
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
let bin = binaryPath();
|
|
10
|
+
if (!fs.existsSync(bin)) {
|
|
11
|
+
const ok = await downloadBinary({ silent: false });
|
|
12
|
+
if (!ok) {
|
|
13
|
+
// Fall back to a globally installed `whichdep` binary on PATH if present.
|
|
14
|
+
bin = "whichdep";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
19
|
+
if (result.error) {
|
|
20
|
+
console.error(
|
|
21
|
+
`whichdep: failed to execute native binary (${result.error.message}). Install via \`cargo install whichdep\` or check your network connection.`
|
|
22
|
+
);
|
|
23
|
+
process.exit(2);
|
|
24
|
+
}
|
|
25
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whichdep",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "git bisect for lockfiles — isolate which dependency update broke your build (Cargo, uv, pip, npm, pnpm)",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/devel0mer/whichdep.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/devel0mer/whichdep#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/devel0mer/whichdep/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"bisect",
|
|
16
|
+
"delta-debugging",
|
|
17
|
+
"dependencies",
|
|
18
|
+
"lockfile",
|
|
19
|
+
"regression",
|
|
20
|
+
"npm",
|
|
21
|
+
"pnpm",
|
|
22
|
+
"cargo",
|
|
23
|
+
"uv"
|
|
24
|
+
],
|
|
25
|
+
"bin": {
|
|
26
|
+
"whichdep": "bin/whichdep.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"bin/whichdep.js",
|
|
30
|
+
"bin/install.js",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"os": [
|
|
35
|
+
"darwin",
|
|
36
|
+
"linux"
|
|
37
|
+
],
|
|
38
|
+
"cpu": [
|
|
39
|
+
"x64",
|
|
40
|
+
"arm64"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"postinstall": "node bin/install.js"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/README.md
DELETED