@twsxtd/hapi 0.33.0 → 0.33.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.
- package/bin/hapi.cjs +39 -9
- package/package.json +6 -6
package/bin/hapi.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { execFileSync } = require('child_process');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const { version: PACKAGE_VERSION } = require('../package.json');
|
|
5
6
|
|
|
6
7
|
const platform = process.platform;
|
|
7
8
|
const arch = process.arch;
|
|
@@ -40,15 +41,28 @@ function isSupportedPlatform(platformName = platform, archName = arch) {
|
|
|
40
41
|
|
|
41
42
|
function getBinaryPath(platformName = platform, archName = arch) {
|
|
42
43
|
const pkgName = `@twsxtd/hapi-${platformName}-${archName}`;
|
|
44
|
+
let pkgPath;
|
|
43
45
|
|
|
44
46
|
try {
|
|
45
47
|
// Try to find the platform-specific package
|
|
46
|
-
|
|
47
|
-
const binName = platformName === 'win32' ? 'hapi.exe' : 'hapi';
|
|
48
|
-
return path.join(path.dirname(pkgPath), 'bin', binName);
|
|
48
|
+
pkgPath = require.resolve(`${pkgName}/package.json`);
|
|
49
49
|
} catch (e) {
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
// A failed optional dependency upgrade can leave an older package on disk.
|
|
54
|
+
// Node resolves that package even though it does not satisfy our pinned version.
|
|
55
|
+
const installedVersion = require(pkgPath).version;
|
|
56
|
+
if (installedVersion !== PACKAGE_VERSION) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Platform package version mismatch: ${pkgName}\n` +
|
|
59
|
+
`Expected ${PACKAGE_VERSION}, but found ${installedVersion ?? 'unknown'}.\n` +
|
|
60
|
+
'Refusing to run a platform binary from a different HAPI release.'
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const binName = platformName === 'win32' ? 'hapi.exe' : 'hapi';
|
|
65
|
+
return path.join(path.dirname(pkgPath), 'bin', binName);
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
function formatCommand(binPath, args) {
|
|
@@ -95,6 +109,17 @@ function reportUnsupportedPlatform(platformName = platform, archName = arch, log
|
|
|
95
109
|
log(` ${RELEASE_URL}`);
|
|
96
110
|
}
|
|
97
111
|
|
|
112
|
+
function reportReinstall(log = console.error) {
|
|
113
|
+
log('Try reinstalling with the official npm registry:');
|
|
114
|
+
log('Use the same package manager as your current installation:');
|
|
115
|
+
log(` npm install -g @twsxtd/hapi@${PACKAGE_VERSION} --registry=${OFFICIAL_NPM_REGISTRY}`);
|
|
116
|
+
log('For Bun, remove the launcher first to retry skipped optional dependencies:');
|
|
117
|
+
log(` bun remove -g @twsxtd/hapi && bun add -g @twsxtd/hapi@${PACKAGE_VERSION} --registry=${OFFICIAL_NPM_REGISTRY}`);
|
|
118
|
+
log('');
|
|
119
|
+
log('Or download the binary manually from:');
|
|
120
|
+
log(` ${RELEASE_URL}`);
|
|
121
|
+
}
|
|
122
|
+
|
|
98
123
|
function reportMissingPlatformPackage(platformName = platform, archName = arch, log = console.error) {
|
|
99
124
|
const platformPackage = `@twsxtd/hapi-${platformName}-${archName}`;
|
|
100
125
|
log(`Missing platform package: ${platformPackage}`);
|
|
@@ -102,11 +127,7 @@ function reportMissingPlatformPackage(platformName = platform, archName = arch,
|
|
|
102
127
|
log(`Detected platform ${platformName}-${archName} is supported, but the platform binary package was not installed.`);
|
|
103
128
|
log('This may happen when using a registry mirror that has not synced all optionalDependencies.');
|
|
104
129
|
log('');
|
|
105
|
-
log
|
|
106
|
-
log(` npm install -g @twsxtd/hapi --registry=${OFFICIAL_NPM_REGISTRY}`);
|
|
107
|
-
log('');
|
|
108
|
-
log('Or download the binary manually from:');
|
|
109
|
-
log(` ${RELEASE_URL}`);
|
|
130
|
+
reportReinstall(log);
|
|
110
131
|
}
|
|
111
132
|
|
|
112
133
|
function main() {
|
|
@@ -115,7 +136,16 @@ function main() {
|
|
|
115
136
|
process.exit(1);
|
|
116
137
|
}
|
|
117
138
|
|
|
118
|
-
|
|
139
|
+
let binPath;
|
|
140
|
+
try {
|
|
141
|
+
binPath = getBinaryPath();
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error(error.message);
|
|
144
|
+
console.error('');
|
|
145
|
+
reportReinstall();
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
|
|
119
149
|
if (!binPath) {
|
|
120
150
|
reportMissingPlatformPackage();
|
|
121
151
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twsxtd/hapi",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.1",
|
|
4
4
|
"description": "App for agentic coding - access coding agent anywhere",
|
|
5
5
|
"author": "Kirill Dubovitskiy & weishu",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"NOTICE"
|
|
21
21
|
],
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@twsxtd/hapi-darwin-arm64": "0.33.
|
|
24
|
-
"@twsxtd/hapi-darwin-x64": "0.33.
|
|
25
|
-
"@twsxtd/hapi-linux-arm64": "0.33.
|
|
26
|
-
"@twsxtd/hapi-linux-x64": "0.33.
|
|
27
|
-
"@twsxtd/hapi-win32-x64": "0.33.
|
|
23
|
+
"@twsxtd/hapi-darwin-arm64": "0.33.1",
|
|
24
|
+
"@twsxtd/hapi-darwin-x64": "0.33.1",
|
|
25
|
+
"@twsxtd/hapi-linux-arm64": "0.33.1",
|
|
26
|
+
"@twsxtd/hapi-linux-x64": "0.33.1",
|
|
27
|
+
"@twsxtd/hapi-win32-x64": "0.33.1"
|
|
28
28
|
}
|
|
29
29
|
}
|