@aptove/bridge 0.1.7 → 0.1.9
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/bridge +30 -46
- package/package.json +6 -6
- package/postinstall.js +26 -39
package/bin/bridge
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* bridge - ACP bridge
|
|
5
|
-
*
|
|
6
|
-
* This script finds and executes the platform-specific binary.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const { execFileSync } = require('child_process');
|
|
3
|
+
const { spawnSync } = require('child_process');
|
|
10
4
|
const path = require('path');
|
|
11
5
|
const fs = require('fs');
|
|
12
6
|
|
|
@@ -18,56 +12,46 @@ const PLATFORM_PACKAGES = {
|
|
|
18
12
|
'win32-x64': '@aptove/bridge-win32-x64',
|
|
19
13
|
};
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const packageName = PLATFORM_PACKAGES[platformKey];
|
|
15
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
16
|
+
const packageName = PLATFORM_PACKAGES[platformKey];
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
if (!packageName) {
|
|
19
|
+
console.error(`bridge: unsupported platform ${platformKey}`);
|
|
20
|
+
console.error('Supported: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-x64');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
30
23
|
|
|
31
|
-
|
|
24
|
+
const binaryName = process.platform === 'win32' ? 'bridge.exe' : 'bridge';
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
// Both @aptove/bridge and @aptove/bridge-<platform> live under the same
|
|
27
|
+
// @aptove scope directory, so the platform package is always a sibling:
|
|
28
|
+
// __dirname = .../node_modules/@aptove/bridge/bin
|
|
29
|
+
// platform = .../node_modules/@aptove/bridge-darwin-arm64/bin/bridge
|
|
30
|
+
const shortName = packageName.split('/')[1]; // e.g. "bridge-darwin-arm64"
|
|
31
|
+
const siblingPath = path.join(__dirname, '..', '..', shortName, 'bin', binaryName);
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
if (fs.existsSync(binaryPath)) {
|
|
41
|
-
return binaryPath;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
33
|
+
let binaryPath = fs.existsSync(siblingPath) ? siblingPath : null;
|
|
44
34
|
|
|
35
|
+
// Fallback: require.resolve handles pnpm virtual stores and other layouts
|
|
36
|
+
if (!binaryPath) {
|
|
45
37
|
try {
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
if (fs.existsSync(
|
|
49
|
-
|
|
38
|
+
const pkgJson = require.resolve(`${packageName}/package.json`);
|
|
39
|
+
const candidate = path.join(path.dirname(pkgJson), 'bin', binaryName);
|
|
40
|
+
if (fs.existsSync(candidate)) {
|
|
41
|
+
binaryPath = candidate;
|
|
50
42
|
}
|
|
51
43
|
} catch (e) {
|
|
52
|
-
//
|
|
44
|
+
// not found
|
|
53
45
|
}
|
|
46
|
+
}
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
console.error(`
|
|
48
|
+
if (!binaryPath) {
|
|
49
|
+
console.error(`bridge: platform package not installed for ${platformKey}`);
|
|
57
50
|
console.error('');
|
|
58
|
-
console.error('
|
|
59
|
-
console.error(
|
|
51
|
+
console.error('Run:');
|
|
52
|
+
console.error(` npm install -g ${packageName}`);
|
|
60
53
|
process.exit(1);
|
|
61
54
|
}
|
|
62
55
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
execFileSync(binaryPath, args, { stdio: 'inherit' });
|
|
68
|
-
} catch (error) {
|
|
69
|
-
if (error.status !== undefined) {
|
|
70
|
-
process.exit(error.status);
|
|
71
|
-
}
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
56
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
57
|
+
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptove/bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "ACP bridge — connects ACP agents to mobile and desktop clients over WebSocket",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"node": ">=16"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@aptove/bridge-darwin-arm64": "0.1.
|
|
37
|
-
"@aptove/bridge-darwin-x64": "0.1.
|
|
38
|
-
"@aptove/bridge-linux-arm64": "0.1.
|
|
39
|
-
"@aptove/bridge-linux-x64": "0.1.
|
|
40
|
-
"@aptove/bridge-win32-x64": "0.1.
|
|
36
|
+
"@aptove/bridge-darwin-arm64": "0.1.9",
|
|
37
|
+
"@aptove/bridge-darwin-x64": "0.1.9",
|
|
38
|
+
"@aptove/bridge-linux-arm64": "0.1.9",
|
|
39
|
+
"@aptove/bridge-linux-x64": "0.1.9",
|
|
40
|
+
"@aptove/bridge-win32-x64": "0.1.9"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/postinstall.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* bridge postinstall script
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Checks whether the platform-specific binary package was installed.
|
|
5
|
+
* npm sometimes skips optional dependencies during global installs.
|
|
6
|
+
* If so, prints the exact command to complete installation.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
const { execSync } = require('child_process');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
|
|
@@ -17,44 +17,31 @@ const PLATFORM_PACKAGES = {
|
|
|
17
17
|
'win32-x64': '@aptove/bridge-win32-x64',
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const packageName = PLATFORM_PACKAGES[platformKey];
|
|
20
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
21
|
+
const packageName = PLATFORM_PACKAGES[platformKey];
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
const packagePath = require.resolve(`${packageName}/package.json`);
|
|
32
|
-
const binaryName = process.platform === 'win32' ? 'bridge.exe' : 'bridge';
|
|
33
|
-
const binaryPath = path.join(path.dirname(packagePath), 'bin', binaryName);
|
|
34
|
-
|
|
35
|
-
if (!fs.existsSync(binaryPath)) {
|
|
36
|
-
console.warn(`⚠️ bridge: Binary not found at ${binaryPath}`);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
23
|
+
if (!packageName) {
|
|
24
|
+
console.warn(`⚠️ bridge: unsupported platform ${platformKey}`);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
39
27
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
fs.chmodSync(binaryPath, 0o755);
|
|
43
|
-
} catch (e) {
|
|
44
|
-
// Not critical
|
|
45
|
-
}
|
|
46
|
-
}
|
|
28
|
+
const binaryName = process.platform === 'win32' ? 'bridge.exe' : 'bridge';
|
|
29
|
+
let installed = false;
|
|
47
30
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} catch (e) {
|
|
55
|
-
console.warn(`⚠️ bridge: Platform package ${packageName} not installed`);
|
|
56
|
-
console.warn(' This is expected on CI or unsupported platforms');
|
|
57
|
-
}
|
|
31
|
+
try {
|
|
32
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
33
|
+
const binaryPath = path.join(path.dirname(packageJsonPath), 'bin', binaryName);
|
|
34
|
+
installed = fs.existsSync(binaryPath);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
// package not installed
|
|
58
37
|
}
|
|
59
38
|
|
|
60
|
-
|
|
39
|
+
if (installed) {
|
|
40
|
+
console.log(`✓ bridge installed successfully for ${platformKey}`);
|
|
41
|
+
} else {
|
|
42
|
+
console.log('');
|
|
43
|
+
console.log(`⚠️ bridge: platform binary not found (npm skipped optional dependency)`);
|
|
44
|
+
console.log(` To complete installation, run:`);
|
|
45
|
+
console.log(` npm install -g ${packageName}`);
|
|
46
|
+
console.log('');
|
|
47
|
+
}
|