@anandb71/arbor-cli 1.9.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.
Files changed (3) hide show
  1. package/bin/arbor.js +27 -0
  2. package/install.js +86 -0
  3. package/package.json +44 -0
package/bin/arbor.js ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("child_process");
5
+ const path = require("path");
6
+ const fs = require("fs");
7
+
8
+ const binDir = __dirname;
9
+ const unixBin = path.join(binDir, "arbor");
10
+ const winBin = path.join(binDir, "arbor.exe");
11
+
12
+ const target = process.platform === "win32" ? winBin : unixBin;
13
+
14
+ if (!fs.existsSync(target)) {
15
+ console.error("Arbor binary is not installed yet.");
16
+ console.error("Run: npm rebuild @anandb71/arbor-cli or reinstall the package.");
17
+ process.exit(1);
18
+ }
19
+
20
+ const result = spawnSync(target, process.argv.slice(2), { stdio: "inherit" });
21
+
22
+ if (result.error) {
23
+ console.error(result.error.message);
24
+ process.exit(1);
25
+ }
26
+
27
+ process.exit(result.status ?? 0);
package/install.js ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+ // Arbor CLI npm postinstall — downloads the correct platform binary
3
+ "use strict";
4
+
5
+ const { execSync } = require("child_process");
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const https = require("https");
9
+
10
+ const VERSION = require("./package.json").version;
11
+ const REPO = "Anandb71/arbor";
12
+
13
+ const PLATFORM_MAP = {
14
+ "darwin-x64": "arbor-macos-x86_64.tar.gz",
15
+ "darwin-arm64": "arbor-macos-aarch64.tar.gz",
16
+ "linux-x64": "arbor-linux-x86_64.tar.gz",
17
+ "linux-arm64": "arbor-linux-aarch64.tar.gz",
18
+ "win32-x64": "arbor-windows-x86_64.zip",
19
+ };
20
+
21
+ function getPlatformKey() {
22
+ return `${process.platform}-${process.arch}`;
23
+ }
24
+
25
+ function downloadFile(url, dest) {
26
+ return new Promise((resolve, reject) => {
27
+ const follow = (url) => {
28
+ https.get(url, { headers: { "User-Agent": "arbor-npm" } }, (res) => {
29
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
30
+ return follow(res.headers.location);
31
+ }
32
+ if (res.statusCode !== 200) {
33
+ return reject(new Error(`Download failed: HTTP ${res.statusCode}`));
34
+ }
35
+ const file = fs.createWriteStream(dest);
36
+ res.pipe(file);
37
+ file.on("finish", () => { file.close(); resolve(); });
38
+ }).on("error", reject);
39
+ };
40
+ follow(url);
41
+ });
42
+ }
43
+
44
+ async function main() {
45
+ const key = getPlatformKey();
46
+ const asset = PLATFORM_MAP[key];
47
+
48
+ if (!asset) {
49
+ console.error(`Unsupported platform: ${key}`);
50
+ console.error("Install from source: cargo install arbor-graph-cli");
51
+ process.exit(1);
52
+ }
53
+
54
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${asset}`;
55
+ const binDir = path.join(__dirname, "bin");
56
+ fs.mkdirSync(binDir, { recursive: true });
57
+
58
+ const tmpFile = path.join(binDir, asset);
59
+
60
+ console.log(`Downloading Arbor v${VERSION} for ${key}...`);
61
+
62
+ try {
63
+ await downloadFile(url, tmpFile);
64
+
65
+ if (asset.endsWith(".tar.gz")) {
66
+ execSync(`tar -xzf "${tmpFile}" -C "${binDir}"`, { stdio: "inherit" });
67
+ fs.unlinkSync(tmpFile);
68
+ fs.chmodSync(path.join(binDir, "arbor"), 0o755);
69
+ } else if (asset.endsWith(".zip")) {
70
+ // On Windows, use PowerShell to extract
71
+ execSync(
72
+ `powershell -Command "Expand-Archive -Path '${tmpFile}' -DestinationPath '${binDir}' -Force"`,
73
+ { stdio: "inherit" }
74
+ );
75
+ fs.unlinkSync(tmpFile);
76
+ }
77
+
78
+ console.log("Arbor installed successfully!");
79
+ } catch (err) {
80
+ console.error("Failed to install Arbor binary:", err.message);
81
+ console.error("Fallback: cargo install arbor-graph-cli");
82
+ process.exit(1);
83
+ }
84
+ }
85
+
86
+ main();
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@anandb71/arbor-cli",
3
+ "version": "1.9.0",
4
+ "description": "Graph-native intelligence for codebases — know what breaks before you break it",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Anandb71/arbor.git"
9
+ },
10
+ "homepage": "https://github.com/Anandb71/arbor",
11
+ "keywords": [
12
+ "arbor",
13
+ "code-analysis",
14
+ "graph",
15
+ "impact-analysis",
16
+ "refactoring",
17
+ "mcp",
18
+ "ast",
19
+ "tree-sitter",
20
+ "cli"
21
+ ],
22
+ "bin": {
23
+ "arbor": "bin/arbor.js"
24
+ },
25
+ "scripts": {
26
+ "postinstall": "node install.js"
27
+ },
28
+ "files": [
29
+ "install.js",
30
+ "bin/"
31
+ ],
32
+ "os": [
33
+ "darwin",
34
+ "linux",
35
+ "win32"
36
+ ],
37
+ "cpu": [
38
+ "x64",
39
+ "arm64"
40
+ ],
41
+ "engines": {
42
+ "node": ">=18"
43
+ }
44
+ }