@aptove/bridge 0.1.6 → 0.1.8

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 (3) hide show
  1. package/bin/bridge +24 -51
  2. package/package.json +6 -6
  3. 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,35 @@ const PLATFORM_PACKAGES = {
18
12
  'win32-x64': '@aptove/bridge-win32-x64',
19
13
  };
20
14
 
21
- function getBinaryPath() {
22
- const platformKey = `${process.platform}-${process.arch}`;
23
- const packageName = PLATFORM_PACKAGES[platformKey];
24
-
25
- if (!packageName) {
26
- console.error(`Unsupported platform: ${platformKey}`);
27
- console.error('Supported platforms: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-x64');
28
- process.exit(1);
29
- }
30
-
31
- const binaryName = process.platform === 'win32' ? 'bridge.exe' : 'bridge';
15
+ const platformKey = `${process.platform}-${process.arch}`;
16
+ const packageName = PLATFORM_PACKAGES[platformKey];
32
17
 
33
- const possiblePaths = [
34
- path.join(__dirname, '..', packageName, 'bin', binaryName),
35
- path.join(__dirname, '..', '..', packageName, 'bin', binaryName),
36
- path.join(__dirname, '..', 'node_modules', packageName, 'bin', binaryName),
37
- ];
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
+ }
38
23
 
39
- for (const binaryPath of possiblePaths) {
40
- if (fs.existsSync(binaryPath)) {
41
- return binaryPath;
42
- }
43
- }
24
+ const binaryName = process.platform === 'win32' ? 'bridge.exe' : 'bridge';
25
+ let binaryPath;
44
26
 
45
- try {
46
- const packagePath = require.resolve(`${packageName}/package.json`);
47
- const binaryPath = path.join(path.dirname(packagePath), 'bin', binaryName);
48
- if (fs.existsSync(binaryPath)) {
49
- return binaryPath;
50
- }
51
- } catch (e) {
52
- // Package not found
27
+ try {
28
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
29
+ const candidate = path.join(path.dirname(packageJsonPath), 'bin', binaryName);
30
+ if (fs.existsSync(candidate)) {
31
+ binaryPath = candidate;
53
32
  }
33
+ } catch (e) {
34
+ // package not installed
35
+ }
54
36
 
55
- console.error(`Could not find bridge binary for ${platformKey}`);
56
- console.error(`Please ensure ${packageName} is installed.`);
37
+ if (!binaryPath) {
38
+ console.error(`bridge: platform package not installed for ${platformKey}`);
57
39
  console.error('');
58
- console.error('Try reinstalling with:');
59
- console.error(' npm install -g @aptove/bridge');
40
+ console.error('Run:');
41
+ console.error(` npm install -g ${packageName}`);
60
42
  process.exit(1);
61
43
  }
62
44
 
63
- const binaryPath = getBinaryPath();
64
- const args = process.argv.slice(2);
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
- }
45
+ const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
46
+ process.exit(result.status ?? 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptove/bridge",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
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.6",
37
- "@aptove/bridge-darwin-x64": "0.1.6",
38
- "@aptove/bridge-linux-arm64": "0.1.6",
39
- "@aptove/bridge-linux-x64": "0.1.6",
40
- "@aptove/bridge-win32-x64": "0.1.6"
36
+ "@aptove/bridge-darwin-arm64": "0.1.8",
37
+ "@aptove/bridge-darwin-x64": "0.1.8",
38
+ "@aptove/bridge-linux-arm64": "0.1.8",
39
+ "@aptove/bridge-linux-x64": "0.1.8",
40
+ "@aptove/bridge-win32-x64": "0.1.8"
41
41
  }
42
42
  }
package/postinstall.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * bridge postinstall script
3
3
  *
4
- * Verifies the correct platform-specific package was installed
5
- * and the binary is executable.
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
- function main() {
21
- const platformKey = `${process.platform}-${process.arch}`;
22
- const packageName = PLATFORM_PACKAGES[platformKey];
20
+ const platformKey = `${process.platform}-${process.arch}`;
21
+ const packageName = PLATFORM_PACKAGES[platformKey];
23
22
 
24
- if (!packageName) {
25
- console.warn(`⚠️ bridge: Unsupported platform ${platformKey}`);
26
- console.warn(' Supported platforms: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-x64');
27
- return;
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
- if (process.platform !== 'win32') {
41
- try {
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
- try {
49
- execSync(`"${binaryPath}" --version`, { stdio: 'pipe' });
50
- console.log(`✓ bridge installed successfully for ${platformKey}`);
51
- } catch (e) {
52
- console.warn(`⚠️ bridge: Binary exists but failed to execute on ${platformKey}`);
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
- main();
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
+ }