@twsxtd/hapi 0.15.4 → 0.16.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.
Files changed (2) hide show
  1. package/bin/hapi.cjs +68 -12
  2. package/package.json +6 -6
package/bin/hapi.cjs CHANGED
@@ -5,6 +5,38 @@ const path = require('path');
5
5
 
6
6
  const platform = process.platform;
7
7
  const arch = process.arch;
8
+ const RELEASE_URL = 'https://github.com/tiann/hapi/releases';
9
+ const OFFICIAL_NPM_REGISTRY = 'https://registry.npmjs.org';
10
+ const SUPPORTED_PLATFORMS = [
11
+ {
12
+ key: 'darwin-arm64',
13
+ label: 'darwin-arm64 (macOS Apple Silicon)',
14
+ },
15
+ {
16
+ key: 'darwin-x64',
17
+ label: 'darwin-x64 (macOS Intel)',
18
+ },
19
+ {
20
+ key: 'linux-arm64',
21
+ label: 'linux-arm64',
22
+ },
23
+ {
24
+ key: 'linux-x64',
25
+ label: 'linux-x64',
26
+ },
27
+ {
28
+ key: 'win32-x64',
29
+ label: 'win32-x64',
30
+ },
31
+ ];
32
+
33
+ function getPlatformKey(platformName = platform, archName = arch) {
34
+ return `${platformName}-${archName}`;
35
+ }
36
+
37
+ function isSupportedPlatform(platformName = platform, archName = arch) {
38
+ return SUPPORTED_PLATFORMS.some((item) => item.key === getPlatformKey(platformName, archName));
39
+ }
8
40
 
9
41
  function getBinaryPath(platformName = platform, archName = arch) {
10
42
  const pkgName = `@twsxtd/hapi-${platformName}-${archName}`;
@@ -51,21 +83,41 @@ function reportExecutionFailure(error, binPath, args, log = console.error) {
51
83
  return { status, signal };
52
84
  }
53
85
 
86
+ function reportUnsupportedPlatform(platformName = platform, archName = arch, log = console.error) {
87
+ log(`Unsupported platform: ${platformName}-${archName}`);
88
+ log('');
89
+ log('Supported platforms:');
90
+ for (const item of SUPPORTED_PLATFORMS) {
91
+ log(` - ${item.label}`);
92
+ }
93
+ log('');
94
+ log('You can download the binary manually from:');
95
+ log(` ${RELEASE_URL}`);
96
+ }
97
+
98
+ function reportMissingPlatformPackage(platformName = platform, archName = arch, log = console.error) {
99
+ const platformPackage = `@twsxtd/hapi-${platformName}-${archName}`;
100
+ log(`Missing platform package: ${platformPackage}`);
101
+ log('');
102
+ log(`Detected platform ${platformName}-${archName} is supported, but the platform binary package was not installed.`);
103
+ log('This may happen when using a registry mirror that has not synced all optionalDependencies.');
104
+ log('');
105
+ log('Try reinstalling with the official npm registry:');
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}`);
110
+ }
111
+
54
112
  function main() {
55
- const binPath = getBinaryPath();
113
+ if (!isSupportedPlatform()) {
114
+ reportUnsupportedPlatform();
115
+ process.exit(1);
116
+ }
56
117
 
118
+ const binPath = getBinaryPath();
57
119
  if (!binPath) {
58
- console.error(`Unsupported platform: ${platform}-${arch}`);
59
- console.error('');
60
- console.error('Supported platforms:');
61
- console.error(' - darwin-arm64 (macOS Apple Silicon)');
62
- console.error(' - darwin-x64 (macOS Intel)');
63
- console.error(' - linux-arm64');
64
- console.error(' - linux-x64');
65
- console.error(' - win32-x64');
66
- console.error('');
67
- console.error('You can download the binary manually from:');
68
- console.error(' https://github.com/tiann/hapi/releases');
120
+ reportMissingPlatformPackage();
69
121
  process.exit(1);
70
122
  }
71
123
 
@@ -98,7 +150,11 @@ if (require.main === module) {
98
150
 
99
151
  module.exports = {
100
152
  formatCommand,
153
+ getPlatformKey,
101
154
  getBinaryPath,
155
+ isSupportedPlatform,
102
156
  normalizeExecError,
103
157
  reportExecutionFailure,
158
+ reportMissingPlatformPackage,
159
+ reportUnsupportedPlatform,
104
160
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twsxtd/hapi",
3
- "version": "0.15.4",
3
+ "version": "0.16.0",
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.15.4",
24
- "@twsxtd/hapi-darwin-x64": "0.15.4",
25
- "@twsxtd/hapi-linux-arm64": "0.15.4",
26
- "@twsxtd/hapi-linux-x64": "0.15.4",
27
- "@twsxtd/hapi-win32-x64": "0.15.4"
23
+ "@twsxtd/hapi-darwin-arm64": "0.16.0",
24
+ "@twsxtd/hapi-darwin-x64": "0.16.0",
25
+ "@twsxtd/hapi-linux-arm64": "0.16.0",
26
+ "@twsxtd/hapi-linux-x64": "0.16.0",
27
+ "@twsxtd/hapi-win32-x64": "0.16.0"
28
28
  }
29
29
  }