@thebushidocollective/han 3.7.3 → 3.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.
- package/bin.js +60 -31
- package/package.json +6 -6
package/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { execFileSync } = require('node:child_process');
|
|
3
3
|
const { existsSync } = require('node:fs');
|
|
4
|
-
const { join } = require('node:path');
|
|
4
|
+
const { dirname, join } = require('node:path');
|
|
5
5
|
|
|
6
6
|
const platform = process.platform;
|
|
7
7
|
const arch = process.arch;
|
|
@@ -23,47 +23,76 @@ if (!pkgName) {
|
|
|
23
23
|
process.exit(1);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const pkg = `@thebushidocollective/han-${pkgName}`;
|
|
27
27
|
const binName = platform === 'win32' ? 'han.exe' : 'han';
|
|
28
|
-
const paths = [
|
|
29
|
-
// Installed as dependency
|
|
30
|
-
join(__dirname, '..', '@thebushidocollective', `han-${pkgName}`, binName),
|
|
31
|
-
// npx cache location
|
|
32
|
-
join(
|
|
33
|
-
__dirname,
|
|
34
|
-
'node_modules',
|
|
35
|
-
'@thebushidocollective',
|
|
36
|
-
`han-${pkgName}`,
|
|
37
|
-
binName
|
|
38
|
-
),
|
|
39
|
-
];
|
|
40
28
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Find the platform binary using require.resolve (the canonical way to locate
|
|
31
|
+
* packages in Node.js). This works regardless of whether npm hoisted the
|
|
32
|
+
* optional dependency or kept it nested.
|
|
33
|
+
*/
|
|
34
|
+
function findBinaryViaResolve() {
|
|
45
35
|
try {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
const pkgJson = require.resolve(`${pkg}/package.json`);
|
|
37
|
+
const binPath = join(dirname(pkgJson), binName);
|
|
38
|
+
if (existsSync(binPath)) return binPath;
|
|
39
|
+
} catch {
|
|
40
|
+
// Package not resolvable
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Hardcoded path fallbacks for environments where require.resolve may not
|
|
47
|
+
* traverse into the expected node_modules tree (e.g., npx cache quirks).
|
|
48
|
+
*/
|
|
49
|
+
function findBinaryViaHardcodedPaths() {
|
|
50
|
+
const candidates = [
|
|
51
|
+
// Hoisted (standard npm layout)
|
|
52
|
+
join(__dirname, '..', '@thebushidocollective', `han-${pkgName}`, binName),
|
|
53
|
+
// Nested under wrapper
|
|
54
|
+
join(
|
|
53
55
|
__dirname,
|
|
54
56
|
'node_modules',
|
|
55
57
|
'@thebushidocollective',
|
|
56
58
|
`han-${pkgName}`,
|
|
57
59
|
binName
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
),
|
|
61
|
+
];
|
|
62
|
+
return candidates.find((p) => existsSync(p)) || null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Last resort: install the platform package on-demand and re-check all
|
|
67
|
+
* locations (both hoisted and nested) after the install.
|
|
68
|
+
*/
|
|
69
|
+
function installAndFind() {
|
|
70
|
+
try {
|
|
71
|
+
execFileSync('npm', ['install', '--no-save', '--ignore-scripts', pkg], {
|
|
72
|
+
stdio: 'pipe',
|
|
73
|
+
cwd: __dirname,
|
|
74
|
+
});
|
|
75
|
+
} catch {
|
|
76
|
+
// Install failed - fall through to checks anyway
|
|
62
77
|
}
|
|
78
|
+
// Re-check all locations after install
|
|
79
|
+
return findBinaryViaResolve() || findBinaryViaHardcodedPaths();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Resolution chain: resolve → hardcoded paths → install-and-retry
|
|
83
|
+
let binPath = findBinaryViaResolve() || findBinaryViaHardcodedPaths();
|
|
84
|
+
|
|
85
|
+
if (!binPath) {
|
|
86
|
+
binPath = installAndFind();
|
|
63
87
|
}
|
|
64
88
|
|
|
65
|
-
if (!
|
|
66
|
-
console.error(`
|
|
89
|
+
if (!binPath) {
|
|
90
|
+
console.error(`Error: han binary not found for ${key}`);
|
|
91
|
+
console.error(`Package: ${pkg}`);
|
|
92
|
+
console.error('');
|
|
93
|
+
console.error(
|
|
94
|
+
'Try: npx clear-npx-cache && npx -y @thebushidocollective/han --version'
|
|
95
|
+
);
|
|
67
96
|
process.exit(1);
|
|
68
97
|
}
|
|
69
98
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thebushidocollective/han",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "CLI for installing and managing curated Claude Code plugins from the Han marketplace",
|
|
5
5
|
"homepage": "https://han.guru",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"han": "bin.js"
|
|
13
13
|
},
|
|
14
14
|
"optionalDependencies": {
|
|
15
|
-
"@thebushidocollective/han-darwin-arm64": "3.
|
|
16
|
-
"@thebushidocollective/han-darwin-x64": "3.
|
|
17
|
-
"@thebushidocollective/han-linux-arm64": "3.
|
|
18
|
-
"@thebushidocollective/han-linux-x64": "3.
|
|
19
|
-
"@thebushidocollective/han-win32-x64": "3.
|
|
15
|
+
"@thebushidocollective/han-darwin-arm64": "3.9.0",
|
|
16
|
+
"@thebushidocollective/han-darwin-x64": "3.9.0",
|
|
17
|
+
"@thebushidocollective/han-linux-arm64": "3.9.0",
|
|
18
|
+
"@thebushidocollective/han-linux-x64": "3.9.0",
|
|
19
|
+
"@thebushidocollective/han-win32-x64": "3.9.0"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"claude",
|