cmux 0.7.1 → 0.7.3

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/cmux ADDED
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * cmux CLI wrapper
4
+ * Finds and executes the platform-specific binary
5
+ */
6
+
7
+ const { execFileSync, spawnSync } = require('child_process');
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ const PLATFORMS = {
12
+ 'darwin-arm64': 'cmux-darwin-arm64',
13
+ 'darwin-x64': 'cmux-darwin-x64',
14
+ 'linux-arm64': 'cmux-linux-arm64',
15
+ 'linux-x64': 'cmux-linux-x64',
16
+ 'win32-x64': 'cmux-win32-x64',
17
+ };
18
+
19
+ function getPlatformPackage() {
20
+ const platform = process.platform;
21
+ const arch = process.arch;
22
+ const key = `${platform}-${arch}`;
23
+ return PLATFORMS[key];
24
+ }
25
+
26
+ function findBinary(packageName) {
27
+ const binName = process.platform === 'win32' ? 'cmux.exe' : 'cmux';
28
+
29
+ // Try require.resolve first
30
+ try {
31
+ const pkgPath = require.resolve(`${packageName}/package.json`);
32
+ const binPath = path.join(path.dirname(pkgPath), 'bin', binName);
33
+ if (fs.existsSync(binPath)) {
34
+ return binPath;
35
+ }
36
+ } catch (e) {
37
+ // Continue to other methods
38
+ }
39
+
40
+ // Try common paths
41
+ const possiblePaths = [
42
+ path.join(__dirname, '..', '..', packageName, 'bin'),
43
+ path.join(__dirname, '..', 'node_modules', packageName, 'bin'),
44
+ path.join(__dirname, '..', '..', '..', packageName, 'bin'),
45
+ ];
46
+
47
+ for (const p of possiblePaths) {
48
+ const binPath = path.join(p, binName);
49
+ if (fs.existsSync(binPath)) {
50
+ return binPath;
51
+ }
52
+ }
53
+
54
+ return null;
55
+ }
56
+
57
+ const platformPackage = getPlatformPackage();
58
+
59
+ if (!platformPackage) {
60
+ console.error(`Unsupported platform: ${process.platform}-${process.arch}`);
61
+ console.error('Supported platforms: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-x64');
62
+ process.exit(1);
63
+ }
64
+
65
+ const binary = findBinary(platformPackage);
66
+
67
+ if (!binary) {
68
+ console.error(`cmux: Could not find binary for ${platformPackage}`);
69
+ console.error(`Try reinstalling: npm install -g cmux`);
70
+ console.error(`Or install platform package directly: npm install -g ${platformPackage}`);
71
+ process.exit(1);
72
+ }
73
+
74
+ // Execute the binary with all arguments
75
+ const result = spawnSync(binary, process.argv.slice(2), {
76
+ stdio: 'inherit',
77
+ env: process.env,
78
+ });
79
+
80
+ process.exit(result.status || 0);
@@ -29,18 +29,30 @@ function getPlatformPackage() {
29
29
  }
30
30
 
31
31
  function findBinary(packageName) {
32
+ const binName = process.platform === 'win32' ? 'cmux.exe' : 'cmux';
33
+
32
34
  // Try to find the binary in node_modules
33
35
  const possiblePaths = [
34
- // Hoisted to top-level node_modules
36
+ // Hoisted to top-level node_modules (local install)
35
37
  path.join(__dirname, '..', '..', packageName, 'bin'),
36
38
  // In our own node_modules
37
39
  path.join(__dirname, '..', 'node_modules', packageName, 'bin'),
38
- // Global install
40
+ // Global install - sibling package
39
41
  path.join(__dirname, '..', '..', '..', packageName, 'bin'),
42
+ // pnpm global
43
+ path.join(__dirname, '..', '..', '.pnpm', 'node_modules', packageName, 'bin'),
40
44
  ];
41
45
 
46
+ // Also try require.resolve to find the package
47
+ try {
48
+ const pkgPath = require.resolve(`${packageName}/package.json`, { paths: [path.join(__dirname, '..')] });
49
+ const pkgBinPath = path.join(path.dirname(pkgPath), 'bin', binName);
50
+ possiblePaths.unshift(path.dirname(pkgBinPath));
51
+ } catch (e) {
52
+ // Package not resolvable, continue with other paths
53
+ }
54
+
42
55
  for (const p of possiblePaths) {
43
- const binName = process.platform === 'win32' ? 'cmux.exe' : 'cmux';
44
56
  const binPath = path.join(p, binName);
45
57
  if (fs.existsSync(binPath)) {
46
58
  return binPath;
@@ -62,10 +74,11 @@ function main() {
62
74
  const sourceBinary = findBinary(platformPackage);
63
75
 
64
76
  if (!sourceBinary) {
65
- // Binary not found - this is OK if we're in development or the optional dep wasn't installed
66
- console.log(`Platform package ${platformPackage} not found, skipping binary copy`);
67
- console.log('If you need the binary, install the platform-specific package manually:');
68
- console.log(` npm install ${platformPackage}`);
77
+ // Binary not found - try to install the platform package
78
+ console.error(`cmux: Platform package ${platformPackage} not found`);
79
+ console.error(`cmux: Please ensure the package installed correctly.`);
80
+ console.error(`cmux: You can try: npm install -g ${platformPackage}`);
81
+ // Don't exit with error - npm might still be installing optional deps
69
82
  return;
70
83
  }
71
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmux",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Cloud sandboxes for development - spawn isolated dev environments instantly",
5
5
  "keywords": [
6
6
  "cli",
@@ -31,11 +31,11 @@
31
31
  "postinstall": "node lib/postinstall.js"
32
32
  },
33
33
  "optionalDependencies": {
34
- "cmux-darwin-arm64": "0.7.1",
35
- "cmux-darwin-x64": "0.7.1",
36
- "cmux-linux-arm64": "0.7.1",
37
- "cmux-linux-x64": "0.7.1",
38
- "cmux-win32-x64": "0.7.1"
34
+ "cmux-darwin-arm64": "0.7.3",
35
+ "cmux-darwin-x64": "0.7.3",
36
+ "cmux-linux-arm64": "0.7.3",
37
+ "cmux-linux-x64": "0.7.3",
38
+ "cmux-win32-x64": "0.7.3"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=16"