hopcoderx-ai 1.0.99 → 1.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/bin/hopcoderx +9 -3
- package/package.json +2 -2
- package/postinstall.mjs +59 -0
package/bin/hopcoderx
CHANGED
|
@@ -5,9 +5,18 @@ const fs = require("fs")
|
|
|
5
5
|
const path = require("path")
|
|
6
6
|
const os = require("os")
|
|
7
7
|
|
|
8
|
+
const scriptPath = fs.realpathSync(__filename)
|
|
9
|
+
const scriptDir = path.dirname(scriptPath)
|
|
10
|
+
|
|
8
11
|
function run(target) {
|
|
9
12
|
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
13
|
stdio: "inherit",
|
|
14
|
+
env: {
|
|
15
|
+
...process.env,
|
|
16
|
+
HOPCODERX_LAUNCHER_PATH: scriptPath,
|
|
17
|
+
HOPCODERX_LAUNCHER_DIR: scriptDir,
|
|
18
|
+
HOPCODERX_LAUNCHER_TARGET: target,
|
|
19
|
+
},
|
|
11
20
|
})
|
|
12
21
|
if (result.error) {
|
|
13
22
|
console.error(result.error.message)
|
|
@@ -22,9 +31,6 @@ if (envPath) {
|
|
|
22
31
|
run(envPath)
|
|
23
32
|
}
|
|
24
33
|
|
|
25
|
-
const scriptPath = fs.realpathSync(__filename)
|
|
26
|
-
const scriptDir = path.dirname(scriptPath)
|
|
27
|
-
|
|
28
34
|
//
|
|
29
35
|
const cached = path.join(scriptDir, ".hopcoderx")
|
|
30
36
|
if (fs.existsSync(cached)) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hopcoderx-ai",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "HopCoderX CLI - AI-powered development tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": { "hopcoderx": "./bin/hopcoderx" },
|
|
7
7
|
"scripts": { "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs" },
|
|
8
|
-
"optionalDependencies": {"hopcoderx-linux-x64-musl":"1.0
|
|
8
|
+
"optionalDependencies": {"hopcoderx-linux-x64-musl":"1.1.0","hopcoderx-windows-x64":"1.1.0","hopcoderx-linux-x64-baseline-musl":"1.1.0","hopcoderx-darwin-x64":"1.1.0","hopcoderx-linux-x64-baseline":"1.1.0","hopcoderx-windows-x64-baseline":"1.1.0","hopcoderx-linux-x64":"1.1.0","hopcoderx-darwin-arm64":"1.1.0","hopcoderx-darwin-x64-baseline":"1.1.0","hopcoderx-linux-arm64-musl":"1.1.0","hopcoderx-linux-arm64":"1.1.0"}
|
|
9
9
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -47,6 +47,63 @@ function detectPlatformAndArch() {
|
|
|
47
47
|
return { platform, arch }
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function detectInstaller() {
|
|
51
|
+
const ua = process.env.npm_config_user_agent || ""
|
|
52
|
+
if (ua.startsWith("bun/")) return "bun"
|
|
53
|
+
if (ua.startsWith("pnpm/")) return "pnpm"
|
|
54
|
+
if (ua.startsWith("yarn/")) return "yarn"
|
|
55
|
+
if (ua.startsWith("npm/")) return "npm"
|
|
56
|
+
return "unknown"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function extractBunShimTarget(shimPath) {
|
|
60
|
+
try {
|
|
61
|
+
const text = fs.readFileSync(shimPath, "utf8")
|
|
62
|
+
const match = text.match(/(\.\.[^"\r\n\0]*hopcoderx-ai[\\/]+bin[\\/]+hopcoderx)/)
|
|
63
|
+
if (match?.[1]) {
|
|
64
|
+
return path.resolve(path.dirname(shimPath), match[1])
|
|
65
|
+
}
|
|
66
|
+
} catch {}
|
|
67
|
+
|
|
68
|
+
return path.resolve(path.dirname(shimPath), "..", "node_modules", "hopcoderx-ai", "bin", "hopcoderx")
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function findBrokenBunShim(binDir = path.join(os.homedir(), ".bun", "bin")) {
|
|
72
|
+
const bunxShim = path.join(binDir, "hopcoderx.bunx")
|
|
73
|
+
if (!fs.existsSync(bunxShim)) return null
|
|
74
|
+
|
|
75
|
+
const expectedTarget = extractBunShimTarget(bunxShim)
|
|
76
|
+
if (fs.existsSync(expectedTarget)) return null
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
bunxShim,
|
|
80
|
+
expectedTarget,
|
|
81
|
+
related: [path.join(binDir, "hopcoderx"), path.join(binDir, "hopcoderx.exe"), bunxShim],
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function cleanupBrokenBunShim(installer) {
|
|
86
|
+
if (installer === "bun") return
|
|
87
|
+
|
|
88
|
+
const broken = findBrokenBunShim()
|
|
89
|
+
if (!broken) return
|
|
90
|
+
|
|
91
|
+
const removed = []
|
|
92
|
+
for (const candidate of broken.related) {
|
|
93
|
+
if (!fs.existsSync(candidate)) continue
|
|
94
|
+
fs.unlinkSync(candidate)
|
|
95
|
+
removed.push(candidate)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (removed.length === 0) return
|
|
99
|
+
|
|
100
|
+
console.warn("Removed stale Bun HopCoderX shim(s):")
|
|
101
|
+
for (const candidate of removed) {
|
|
102
|
+
console.warn(` ${candidate}`)
|
|
103
|
+
}
|
|
104
|
+
console.warn(`These shims pointed to a missing module target: ${broken.expectedTarget}`)
|
|
105
|
+
}
|
|
106
|
+
|
|
50
107
|
function findBinary() {
|
|
51
108
|
const { platform, arch } = detectPlatformAndArch()
|
|
52
109
|
const packageName = `hopcoderx-${platform}-${arch}`
|
|
@@ -99,6 +156,7 @@ function symlinkBinary(sourcePath, binaryName) {
|
|
|
99
156
|
|
|
100
157
|
async function main() {
|
|
101
158
|
try {
|
|
159
|
+
const installer = detectInstaller()
|
|
102
160
|
const { platform, arch } = detectPlatformAndArch()
|
|
103
161
|
const { binaryPath } = findBinary()
|
|
104
162
|
const target = path.join(__dirname, "bin", ".hopcoderx")
|
|
@@ -115,6 +173,7 @@ async function main() {
|
|
|
115
173
|
}
|
|
116
174
|
fs.chmodSync(target, 0o755)
|
|
117
175
|
}
|
|
176
|
+
cleanupBrokenBunShim(installer)
|
|
118
177
|
} catch (error) {
|
|
119
178
|
console.error("Failed to setup hopcoderx binary:", error.message)
|
|
120
179
|
const { platform, arch } = detectPlatformAndArch()
|