repomap-bin 2.1.0 → 2.1.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.
Files changed (3) hide show
  1. package/index.js +13 -8
  2. package/package.json +4 -4
  3. package/run.js +14 -10
package/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { existsSync } from "node:fs";
2
+ import { createRequire } from "node:module";
2
3
  import { join, dirname } from "node:path";
3
4
  import { fileURLToPath } from "node:url";
4
5
 
5
6
  const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const localRequire = createRequire(import.meta.url);
6
8
 
7
9
  function findBinary() {
8
10
  const platform = process.platform;
@@ -13,7 +15,7 @@ function findBinary() {
13
15
  const repoBin = join(__dirname, "..", "..", "dist", binName);
14
16
  if (existsSync(repoBin)) return repoBin;
15
17
 
16
- // 2. Check npm platform packages
18
+ // 2. Resolve platform package via Node module resolution (handles hoisted, npx, yarn, pnpm)
17
19
  const platformPackages = {
18
20
  "linux-x64": { pkg: "repomap-bin-linux-x64", bin: "repomap" },
19
21
  "darwin-arm64": { pkg: "repomap-bin-darwin-arm64", bin: "repomap" },
@@ -23,15 +25,18 @@ function findBinary() {
23
25
  const key = `${platform}-${arch}`;
24
26
  const info = platformPackages[key];
25
27
  if (info) {
26
- const candidate = join(__dirname, "node_modules", info.pkg, info.bin);
27
- if (existsSync(candidate)) return candidate;
28
+ try {
29
+ const pkgJson = localRequire.resolve(`${info.pkg}/package.json`);
30
+ const candidate = join(dirname(pkgJson), info.bin);
31
+ if (existsSync(candidate)) return candidate;
32
+ } catch { /* not resolvable */ }
33
+
34
+ // Non-hoisted: inside repomap-bin's own node_modules
35
+ const nested = join(__dirname, "node_modules", info.pkg, info.bin);
36
+ if (existsSync(nested)) return nested;
28
37
  }
29
38
 
30
- // 3. Vendor fallback
31
- const fallback = join(__dirname, "vendor", binName);
32
- if (existsSync(fallback)) return fallback;
33
-
34
- // 4. PATH fallback
39
+ // 3. PATH fallback
35
40
  return binName;
36
41
  }
37
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repomap-bin",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Standalone repomap binary \u2014 tree-sitter AST code intelligence CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,9 +11,9 @@
11
11
  "index.js"
12
12
  ],
13
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"
14
+ "repomap-bin-linux-x64": "2.1.1",
15
+ "repomap-bin-darwin-arm64": "2.1.1",
16
+ "repomap-bin-windows-x64": "2.1.1"
17
17
  },
18
18
  "engines": {
19
19
  "node": ">=18"
package/run.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { execFileSync } from "node:child_process";
2
+ import { createRequire } from "node:module";
2
3
  import { existsSync } from "node:fs";
3
4
  import { join, dirname } from "node:path";
4
5
  import { fileURLToPath } from "node:url";
5
6
 
6
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const localRequire = createRequire(import.meta.url);
7
9
 
8
10
  function findBinary() {
9
11
  const platform = process.platform;
@@ -14,7 +16,7 @@ function findBinary() {
14
16
  const repoBin = join(__dirname, "..", "..", "dist", binName);
15
17
  if (existsSync(repoBin)) return repoBin;
16
18
 
17
- // 2. Check npm platform packages
19
+ // 2. Resolve platform package via Node module resolution (handles hoisted, npx, yarn, pnpm)
18
20
  const platformPackages = {
19
21
  "linux-x64": { pkg: "repomap-bin-linux-x64", bin: "repomap" },
20
22
  "darwin-arm64": { pkg: "repomap-bin-darwin-arm64", bin: "repomap" },
@@ -24,15 +26,18 @@ function findBinary() {
24
26
  const key = `${platform}-${arch}`;
25
27
  const info = platformPackages[key];
26
28
  if (info) {
27
- const candidate = join(__dirname, "node_modules", info.pkg, info.bin);
28
- if (existsSync(candidate)) return candidate;
29
+ try {
30
+ const pkgJson = localRequire.resolve(`${info.pkg}/package.json`);
31
+ const candidate = join(dirname(pkgJson), info.bin);
32
+ if (existsSync(candidate)) return candidate;
33
+ } catch { /* not resolvable */ }
34
+
35
+ // Non-hoisted: inside repomap-bin's own node_modules
36
+ const nested = join(__dirname, "node_modules", info.pkg, info.bin);
37
+ if (existsSync(nested)) return nested;
29
38
  }
30
39
 
31
- // 3. Vendor fallback
32
- const fallback = join(__dirname, "vendor", binName);
33
- if (existsSync(fallback)) return fallback;
34
-
35
- // 4. PATH fallback
40
+ // 3. PATH fallback
36
41
  return binName;
37
42
  }
38
43
 
@@ -41,8 +46,7 @@ const binaryPath = findBinary();
41
46
  if (!binaryPath) {
42
47
  console.error(
43
48
  "repomap binary not found for this platform.\n" +
44
- "Try: npm install repomap-bin\n" +
45
- "Or: pip install repomap-cli"
49
+ "Try: npm install repomap-bin"
46
50
  );
47
51
  process.exit(1);
48
52
  }