@manaflow-ai/cloudrouter 0.8.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.
- package/bin/cloudrouter +60 -0
- package/lib/cmux +0 -0
- package/lib/postinstall.js +97 -0
- package/package.json +39 -0
package/bin/cloudrouter
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* cloudrouter CLI wrapper - delegates to the native cmux binary.
|
|
4
|
+
*
|
|
5
|
+
* This script exists so npm can create a proper bin symlink at install time.
|
|
6
|
+
* The postinstall script will overwrite this file with the platform-specific
|
|
7
|
+
* native binary. If postinstall hasn't run yet, this wrapper finds and
|
|
8
|
+
* executes the binary from lib/ or the platform package.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const { execFileSync } = require("child_process");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
|
|
15
|
+
const binName = process.platform === "win32" ? "cmux.exe" : "cmux";
|
|
16
|
+
|
|
17
|
+
// Look for the native binary in these locations (in order)
|
|
18
|
+
const candidates = [
|
|
19
|
+
// lib/cmux - copied by build process as fallback
|
|
20
|
+
path.join(__dirname, "..", "lib", binName),
|
|
21
|
+
// Platform package in node_modules (hoisted)
|
|
22
|
+
...getPlatformPaths(),
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
function getPlatformPaths() {
|
|
26
|
+
const platform = process.platform;
|
|
27
|
+
const arch = process.arch;
|
|
28
|
+
const pkgName = `@manaflow-ai/cloudrouter-${platform}-${arch}`;
|
|
29
|
+
return [
|
|
30
|
+
path.join(__dirname, "..", "..", pkgName, "bin", binName),
|
|
31
|
+
path.join(__dirname, "..", "node_modules", pkgName, "bin", binName),
|
|
32
|
+
// Unscoped fallback paths for hoisted installs
|
|
33
|
+
path.join(__dirname, "..", "..", "..", ".store", pkgName, "bin", binName),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let binaryPath;
|
|
38
|
+
for (const candidate of candidates) {
|
|
39
|
+
if (fs.existsSync(candidate)) {
|
|
40
|
+
binaryPath = candidate;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!binaryPath) {
|
|
46
|
+
console.error("cloudrouter: Could not find native binary. Try reinstalling: npm install -g @manaflow-ai/cloudrouter");
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
execFileSync(binaryPath, process.argv.slice(2), {
|
|
52
|
+
stdio: "inherit",
|
|
53
|
+
env: process.env,
|
|
54
|
+
});
|
|
55
|
+
} catch (err) {
|
|
56
|
+
if (err.status !== null) {
|
|
57
|
+
process.exit(err.status);
|
|
58
|
+
}
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
package/lib/cmux
ADDED
|
Binary file
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Post-install script for @manaflow-ai/cloudrouter
|
|
4
|
+
* Copies the platform-specific binary to the bin directory
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const PLATFORMS = {
|
|
11
|
+
'darwin-arm64': '@manaflow-ai/cloudrouter-darwin-arm64',
|
|
12
|
+
'darwin-x64': '@manaflow-ai/cloudrouter-darwin-x64',
|
|
13
|
+
'linux-arm64': '@manaflow-ai/cloudrouter-linux-arm64',
|
|
14
|
+
'linux-x64': '@manaflow-ai/cloudrouter-linux-x64',
|
|
15
|
+
'win32-x64': '@manaflow-ai/cloudrouter-win32-x64',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function getPlatformPackage() {
|
|
19
|
+
const platform = process.platform;
|
|
20
|
+
const arch = process.arch;
|
|
21
|
+
|
|
22
|
+
let archName = arch;
|
|
23
|
+
if (arch === 'x64') archName = 'x64';
|
|
24
|
+
else if (arch === 'arm64') archName = 'arm64';
|
|
25
|
+
|
|
26
|
+
const key = `${platform}-${archName}`;
|
|
27
|
+
return PLATFORMS[key];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function findBinary(packageName) {
|
|
31
|
+
const binName = process.platform === 'win32' ? 'cmux.exe' : 'cmux';
|
|
32
|
+
|
|
33
|
+
const possiblePaths = [
|
|
34
|
+
// Hoisted to top-level node_modules (local install)
|
|
35
|
+
path.join(__dirname, '..', '..', packageName, 'bin'),
|
|
36
|
+
// In our own node_modules
|
|
37
|
+
path.join(__dirname, '..', 'node_modules', packageName, 'bin'),
|
|
38
|
+
// Global install - sibling package
|
|
39
|
+
path.join(__dirname, '..', '..', '..', packageName, 'bin'),
|
|
40
|
+
// pnpm global
|
|
41
|
+
path.join(__dirname, '..', '..', '.pnpm', 'node_modules', packageName, 'bin'),
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
// Also try require.resolve to find the package
|
|
45
|
+
try {
|
|
46
|
+
const pkgPath = require.resolve(`${packageName}/package.json`, { paths: [path.join(__dirname, '..')] });
|
|
47
|
+
const pkgBinPath = path.join(path.dirname(pkgPath), 'bin', binName);
|
|
48
|
+
possiblePaths.unshift(path.dirname(pkgBinPath));
|
|
49
|
+
} catch (e) {
|
|
50
|
+
// Package not resolvable, continue with other paths
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for (const p of possiblePaths) {
|
|
54
|
+
const binPath = path.join(p, binName);
|
|
55
|
+
if (fs.existsSync(binPath)) {
|
|
56
|
+
return binPath;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function main() {
|
|
64
|
+
const platformPackage = getPlatformPackage();
|
|
65
|
+
|
|
66
|
+
if (!platformPackage) {
|
|
67
|
+
console.error(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
68
|
+
console.error('Supported platforms: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-x64');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const sourceBinary = findBinary(platformPackage);
|
|
73
|
+
|
|
74
|
+
if (!sourceBinary) {
|
|
75
|
+
console.error(`cloudrouter: Platform package ${platformPackage} not found`);
|
|
76
|
+
console.error(`cloudrouter: Please ensure the package installed correctly.`);
|
|
77
|
+
console.error(`cloudrouter: You can try: npm install -g ${platformPackage}`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
82
|
+
const destBinary = path.join(binDir, process.platform === 'win32' ? 'cmux.exe' : 'cmux');
|
|
83
|
+
|
|
84
|
+
if (!fs.existsSync(binDir)) {
|
|
85
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
fs.copyFileSync(sourceBinary, destBinary);
|
|
89
|
+
|
|
90
|
+
if (process.platform !== 'win32') {
|
|
91
|
+
fs.chmodSync(destBinary, 0o755);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log(`cloudrouter: Installed ${platformPackage} binary`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@manaflow-ai/cloudrouter",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "CLI tool to instantly spin up cloud VMs preloaded with Chrome, VNC, SSH, and rsync",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"devbox",
|
|
8
|
+
"cloud",
|
|
9
|
+
"sandbox",
|
|
10
|
+
"development",
|
|
11
|
+
"e2b",
|
|
12
|
+
"morph",
|
|
13
|
+
"vscode",
|
|
14
|
+
"vnc"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://cmux.sh",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Manaflow",
|
|
19
|
+
"bin": {
|
|
20
|
+
"cloudrouter": "bin/cloudrouter"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"bin",
|
|
24
|
+
"lib"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"postinstall": "node lib/postinstall.js"
|
|
28
|
+
},
|
|
29
|
+
"optionalDependencies": {
|
|
30
|
+
"@manaflow-ai/cloudrouter-darwin-arm64": "0.8.0",
|
|
31
|
+
"@manaflow-ai/cloudrouter-darwin-x64": "0.8.0",
|
|
32
|
+
"@manaflow-ai/cloudrouter-linux-arm64": "0.8.0",
|
|
33
|
+
"@manaflow-ai/cloudrouter-linux-x64": "0.8.0",
|
|
34
|
+
"@manaflow-ai/cloudrouter-win32-x64": "0.8.0"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=16"
|
|
38
|
+
}
|
|
39
|
+
}
|