repomap-bin 1.0.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 ADDED
@@ -0,0 +1,17 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join, dirname } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+
7
+ const binName = process.platform === "win32" ? "repomap.exe" : "repomap";
8
+ const binaryPath = join(__dirname, "vendor", binName);
9
+
10
+ export function getBinaryPath() {
11
+ if (existsSync(binaryPath)) {
12
+ return binaryPath;
13
+ }
14
+ return null;
15
+ }
16
+
17
+ export default { getBinaryPath };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "repomap-bin",
3
+ "version": "1.0.0",
4
+ "description": "Standalone repomap binary — tree-sitter AST code intelligence CLI",
5
+ "type": "module",
6
+ "bin": {
7
+ "repomap": "./run.js"
8
+ },
9
+ "files": [
10
+ "run.js",
11
+ "postinstall.js",
12
+ "index.js",
13
+ "vendor/.gitkeep"
14
+ ],
15
+ "scripts": {
16
+ "postinstall": "node postinstall.js"
17
+ },
18
+ "engines": {
19
+ "node": ">=18"
20
+ },
21
+ "keywords": [
22
+ "repomap",
23
+ "tree-sitter",
24
+ "ast",
25
+ "code-analysis",
26
+ "cli"
27
+ ],
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/gjczone/repomap.git"
31
+ },
32
+ "homepage": "https://github.com/gjczone/repomap",
33
+ "license": "MIT"
34
+ }
package/postinstall.js ADDED
@@ -0,0 +1,76 @@
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/run.js ADDED
@@ -0,0 +1,27 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { join, dirname } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+
8
+ const binName = process.platform === "win32" ? "repomap.exe" : "repomap";
9
+ const binaryPath = join(__dirname, "vendor", binName);
10
+
11
+ if (!existsSync(binaryPath)) {
12
+ console.error(
13
+ "repomap binary not found. It should be downloaded automatically during npm install.\n" +
14
+ "Try running: npm install repomap-bin\n" +
15
+ "Or install via pip: pip install repomap-cli"
16
+ );
17
+ process.exit(1);
18
+ }
19
+
20
+ try {
21
+ execFileSync(binaryPath, process.argv.slice(2), {
22
+ stdio: "inherit",
23
+ env: { ...process.env },
24
+ });
25
+ } catch (e) {
26
+ process.exit(e.status ?? 1);
27
+ }
File without changes