@manaflow-ai/cloudrouter 0.9.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 +61 -0
- package/lib/cloudrouter +0 -0
- package/lib/postinstall.js +106 -0
- package/package.json +43 -0
package/bin/cloudrouter
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* cloudrouter CLI wrapper - delegates to the native 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" ? "cloudrouter.exe" : "cloudrouter";
|
|
16
|
+
|
|
17
|
+
// Look for the native binary in these locations (in order)
|
|
18
|
+
const candidates = [
|
|
19
|
+
// lib/cloudrouter - 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
|
+
// Scoped package paths
|
|
33
|
+
path.join(__dirname, "..", "..", "..", "@manaflow-ai", `cloudrouter-${platform}-${arch}`, "bin", binName),
|
|
34
|
+
path.join(__dirname, "..", "node_modules", "@manaflow-ai", `cloudrouter-${platform}-${arch}`, "bin", binName),
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let binaryPath;
|
|
39
|
+
for (const candidate of candidates) {
|
|
40
|
+
if (fs.existsSync(candidate)) {
|
|
41
|
+
binaryPath = candidate;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!binaryPath) {
|
|
47
|
+
console.error("cloudrouter: Could not find native binary. Try reinstalling: npm install -g @manaflow-ai/cloudrouter");
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const result = execFileSync(binaryPath, process.argv.slice(2), {
|
|
53
|
+
stdio: "inherit",
|
|
54
|
+
env: process.env,
|
|
55
|
+
});
|
|
56
|
+
} catch (err) {
|
|
57
|
+
if (err.status !== null) {
|
|
58
|
+
process.exit(err.status);
|
|
59
|
+
}
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
package/lib/cloudrouter
ADDED
|
Binary file
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Post-install script for 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
|
+
// Map Node.js arch to our naming
|
|
23
|
+
let archName = arch;
|
|
24
|
+
if (arch === 'x64') archName = 'x64';
|
|
25
|
+
else if (arch === 'arm64') archName = 'arm64';
|
|
26
|
+
|
|
27
|
+
const key = `${platform}-${archName}`;
|
|
28
|
+
return PLATFORMS[key];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function findBinary(packageName) {
|
|
32
|
+
const binName = process.platform === 'win32' ? 'cloudrouter.exe' : 'cloudrouter';
|
|
33
|
+
// Extract the short name for scoped package paths
|
|
34
|
+
const shortName = packageName.replace('@manaflow-ai/', '');
|
|
35
|
+
|
|
36
|
+
// Try to find the binary in node_modules
|
|
37
|
+
const possiblePaths = [
|
|
38
|
+
// Hoisted to top-level node_modules (local install) - scoped
|
|
39
|
+
path.join(__dirname, '..', '..', '@manaflow-ai', shortName, 'bin'),
|
|
40
|
+
// In our own node_modules - scoped
|
|
41
|
+
path.join(__dirname, '..', 'node_modules', '@manaflow-ai', shortName, 'bin'),
|
|
42
|
+
// Global install - sibling package - scoped
|
|
43
|
+
path.join(__dirname, '..', '..', '..', '@manaflow-ai', shortName, 'bin'),
|
|
44
|
+
// pnpm global - scoped
|
|
45
|
+
path.join(__dirname, '..', '..', '.pnpm', 'node_modules', '@manaflow-ai', shortName, 'bin'),
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
// Also try require.resolve to find the package
|
|
49
|
+
try {
|
|
50
|
+
const pkgPath = require.resolve(`${packageName}/package.json`, { paths: [path.join(__dirname, '..')] });
|
|
51
|
+
const pkgBinPath = path.join(path.dirname(pkgPath), 'bin', binName);
|
|
52
|
+
possiblePaths.unshift(path.dirname(pkgBinPath));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
// Package not resolvable, continue with other paths
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for (const p of possiblePaths) {
|
|
58
|
+
const binPath = path.join(p, binName);
|
|
59
|
+
if (fs.existsSync(binPath)) {
|
|
60
|
+
return binPath;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function main() {
|
|
68
|
+
const platformPackage = getPlatformPackage();
|
|
69
|
+
|
|
70
|
+
if (!platformPackage) {
|
|
71
|
+
console.error(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
72
|
+
console.error('Supported platforms: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-x64');
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const sourceBinary = findBinary(platformPackage);
|
|
77
|
+
|
|
78
|
+
if (!sourceBinary) {
|
|
79
|
+
// Binary not found - try to install the platform package
|
|
80
|
+
console.error(`cloudrouter: Platform package ${platformPackage} not found`);
|
|
81
|
+
console.error(`cloudrouter: Please ensure the package installed correctly.`);
|
|
82
|
+
console.error(`cloudrouter: You can try: npm install -g ${platformPackage}`);
|
|
83
|
+
// Don't exit with error - npm might still be installing optional deps
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
88
|
+
const destBinary = path.join(binDir, process.platform === 'win32' ? 'cloudrouter.exe' : 'cloudrouter');
|
|
89
|
+
|
|
90
|
+
// Ensure bin directory exists
|
|
91
|
+
if (!fs.existsSync(binDir)) {
|
|
92
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Copy the binary
|
|
96
|
+
fs.copyFileSync(sourceBinary, destBinary);
|
|
97
|
+
|
|
98
|
+
// Make executable on Unix
|
|
99
|
+
if (process.platform !== 'win32') {
|
|
100
|
+
fs.chmodSync(destBinary, 0o755);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log(`cloudrouter: Installed ${platformPackage} binary`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@manaflow-ai/cloudrouter",
|
|
3
|
+
"version": "0.9.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
|
+
"cloudrouter",
|
|
12
|
+
"vscode",
|
|
13
|
+
"vnc"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://cmux.sh",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/manaflow-ai/cloudrouter.git"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "Manaflow",
|
|
22
|
+
"bin": {
|
|
23
|
+
"cloudrouter": "bin/cloudrouter",
|
|
24
|
+
"cr": "bin/cloudrouter"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"bin",
|
|
28
|
+
"lib"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"postinstall": "node lib/postinstall.js"
|
|
32
|
+
},
|
|
33
|
+
"optionalDependencies": {
|
|
34
|
+
"@manaflow-ai/cloudrouter-darwin-arm64": "0.9.0",
|
|
35
|
+
"@manaflow-ai/cloudrouter-darwin-x64": "0.9.0",
|
|
36
|
+
"@manaflow-ai/cloudrouter-linux-arm64": "0.9.0",
|
|
37
|
+
"@manaflow-ai/cloudrouter-linux-x64": "0.9.0",
|
|
38
|
+
"@manaflow-ai/cloudrouter-win32-x64": "0.9.0"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=16"
|
|
42
|
+
}
|
|
43
|
+
}
|