repomap-bin 1.0.0 → 2.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/index.js +31 -6
- package/package.json +7 -7
- package/run.js +36 -6
- package/postinstall.js +0 -76
- package/vendor/.gitkeep +0 -0
package/index.js
CHANGED
|
@@ -4,14 +4,39 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
|
|
5
5
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const
|
|
7
|
+
function findBinary() {
|
|
8
|
+
const platform = process.platform;
|
|
9
|
+
const arch = process.arch;
|
|
10
|
+
const binName = platform === "win32" ? "repomap.exe" : "repomap";
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
// 1. Check repo dist/ directory (local development)
|
|
13
|
+
const repoBin = join(__dirname, "..", "..", "dist", binName);
|
|
14
|
+
if (existsSync(repoBin)) return repoBin;
|
|
15
|
+
|
|
16
|
+
// 2. Check npm platform packages
|
|
17
|
+
const platformPackages = {
|
|
18
|
+
"linux-x64": { pkg: "repomap-bin-linux-x64", bin: "repomap" },
|
|
19
|
+
"darwin-arm64": { pkg: "repomap-bin-darwin-arm64", bin: "repomap" },
|
|
20
|
+
"win32-x64": { pkg: "repomap-bin-windows-x64", bin: "repomap.exe" },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const key = `${platform}-${arch}`;
|
|
24
|
+
const info = platformPackages[key];
|
|
25
|
+
if (info) {
|
|
26
|
+
const candidate = join(__dirname, "node_modules", info.pkg, info.bin);
|
|
27
|
+
if (existsSync(candidate)) return candidate;
|
|
13
28
|
}
|
|
14
|
-
|
|
29
|
+
|
|
30
|
+
// 3. Vendor fallback
|
|
31
|
+
const fallback = join(__dirname, "vendor", binName);
|
|
32
|
+
if (existsSync(fallback)) return fallback;
|
|
33
|
+
|
|
34
|
+
// 4. PATH fallback
|
|
35
|
+
return binName;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function getBinaryPath() {
|
|
39
|
+
return findBinary();
|
|
15
40
|
}
|
|
16
41
|
|
|
17
42
|
export default { getBinaryPath };
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repomap-bin",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "Standalone repomap binary
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Standalone repomap binary \u2014 tree-sitter AST code intelligence CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"repomap": "./run.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"run.js",
|
|
11
|
-
"
|
|
12
|
-
"index.js",
|
|
13
|
-
"vendor/.gitkeep"
|
|
11
|
+
"index.js"
|
|
14
12
|
],
|
|
15
|
-
"
|
|
16
|
-
"
|
|
13
|
+
"optionalDependencies": {
|
|
14
|
+
"repomap-bin-linux-x64": "2.1.0",
|
|
15
|
+
"repomap-bin-darwin-arm64": "2.1.0",
|
|
16
|
+
"repomap-bin-windows-x64": "2.1.0"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=18"
|
package/run.js
CHANGED
|
@@ -5,14 +5,44 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
|
|
6
6
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
function findBinary() {
|
|
9
|
+
const platform = process.platform;
|
|
10
|
+
const arch = process.arch;
|
|
11
|
+
const binName = platform === "win32" ? "repomap.exe" : "repomap";
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
// 1. Check repo dist/ directory (local development)
|
|
14
|
+
const repoBin = join(__dirname, "..", "..", "dist", binName);
|
|
15
|
+
if (existsSync(repoBin)) return repoBin;
|
|
16
|
+
|
|
17
|
+
// 2. Check npm platform packages
|
|
18
|
+
const platformPackages = {
|
|
19
|
+
"linux-x64": { pkg: "repomap-bin-linux-x64", bin: "repomap" },
|
|
20
|
+
"darwin-arm64": { pkg: "repomap-bin-darwin-arm64", bin: "repomap" },
|
|
21
|
+
"win32-x64": { pkg: "repomap-bin-windows-x64", bin: "repomap.exe" },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const key = `${platform}-${arch}`;
|
|
25
|
+
const info = platformPackages[key];
|
|
26
|
+
if (info) {
|
|
27
|
+
const candidate = join(__dirname, "node_modules", info.pkg, info.bin);
|
|
28
|
+
if (existsSync(candidate)) return candidate;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 3. Vendor fallback
|
|
32
|
+
const fallback = join(__dirname, "vendor", binName);
|
|
33
|
+
if (existsSync(fallback)) return fallback;
|
|
34
|
+
|
|
35
|
+
// 4. PATH fallback
|
|
36
|
+
return binName;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const binaryPath = findBinary();
|
|
40
|
+
|
|
41
|
+
if (!binaryPath) {
|
|
12
42
|
console.error(
|
|
13
|
-
"repomap binary not found
|
|
14
|
-
"Try
|
|
15
|
-
"Or
|
|
43
|
+
"repomap binary not found for this platform.\n" +
|
|
44
|
+
"Try: npm install repomap-bin\n" +
|
|
45
|
+
"Or: pip install repomap-cli"
|
|
16
46
|
);
|
|
17
47
|
process.exit(1);
|
|
18
48
|
}
|
package/postinstall.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, chmodSync } from "node:fs";
|
|
2
|
-
import { createWriteStream } from "node:fs";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { pipeline } from "node:stream/promises";
|
|
5
|
-
import { Readable } from "node:stream";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
|
|
8
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
|
|
10
|
-
const RELEASES_BASE = "https://github.com/gjczone/repomap/releases/latest/download";
|
|
11
|
-
|
|
12
|
-
function detectAsset() {
|
|
13
|
-
const platform = process.platform;
|
|
14
|
-
const arch = process.arch;
|
|
15
|
-
|
|
16
|
-
if (platform === "linux" && arch === "x64") {
|
|
17
|
-
return { assetName: "repomap-linux", binName: "repomap" };
|
|
18
|
-
}
|
|
19
|
-
if (platform === "darwin" && arch === "arm64") {
|
|
20
|
-
return { assetName: "repomap-macos", binName: "repomap" };
|
|
21
|
-
}
|
|
22
|
-
if (platform === "win32" && arch === "x64") {
|
|
23
|
-
return { assetName: "repomap.exe", binName: "repomap.exe" };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
console.warn(
|
|
27
|
-
`repomap-bin: unsupported platform ${platform}-${arch}, skipping binary download.\n` +
|
|
28
|
-
"Install repomap manually: pip install repomap-cli"
|
|
29
|
-
);
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function download(url, dest) {
|
|
34
|
-
mkdirSync(dirname(dest), { recursive: true });
|
|
35
|
-
|
|
36
|
-
const res = await fetch(url, { redirect: "follow" });
|
|
37
|
-
if (!res.ok) {
|
|
38
|
-
throw new Error(`HTTP ${res.status} from ${url}`);
|
|
39
|
-
}
|
|
40
|
-
if (!res.body) {
|
|
41
|
-
throw new Error(`Empty response from ${url}`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const stream = createWriteStream(dest);
|
|
45
|
-
await pipeline(Readable.fromWeb(res.body), stream);
|
|
46
|
-
|
|
47
|
-
if (process.platform !== "win32") {
|
|
48
|
-
chmodSync(dest, 0o755);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function main() {
|
|
53
|
-
const asset = detectAsset();
|
|
54
|
-
if (!asset) return;
|
|
55
|
-
|
|
56
|
-
const dest = join(__dirname, "vendor", asset.binName);
|
|
57
|
-
|
|
58
|
-
if (existsSync(dest)) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const url = `${RELEASES_BASE}/${asset.assetName}`;
|
|
63
|
-
console.log(`repomap-bin: downloading ${asset.assetName}...`);
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
await download(url, dest);
|
|
67
|
-
console.log("repomap-bin: download complete.");
|
|
68
|
-
} catch (err) {
|
|
69
|
-
console.warn(
|
|
70
|
-
`repomap-bin: download failed (${err.message}).\n` +
|
|
71
|
-
"You can install repomap manually: pip install repomap-cli"
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
main();
|
package/vendor/.gitkeep
DELETED
|
File without changes
|