micromachine.dev 1.0.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/micromachine.js +61 -0
- package/package.json +25 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
|
|
7
|
+
function getBinaryPath() {
|
|
8
|
+
const platform = process.platform;
|
|
9
|
+
const arch = process.arch;
|
|
10
|
+
|
|
11
|
+
// Map Node.js platform/arch to your package names
|
|
12
|
+
const platformMap = {
|
|
13
|
+
darwin: "darwin",
|
|
14
|
+
linux: "linux",
|
|
15
|
+
win32: "windows",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const archMap = {
|
|
19
|
+
arm64: "arm64",
|
|
20
|
+
x64: "x64",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const os = platformMap[platform];
|
|
24
|
+
const cpu = archMap[arch];
|
|
25
|
+
|
|
26
|
+
if (!os || !cpu) {
|
|
27
|
+
throw new Error(`Unsupported platform: ${platform}-${arch}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const binaryName = platform === "win32" ? "micromachine.exe" : "micromachine";
|
|
31
|
+
const pkgName = `@micromachine.dev/cli-${os}-${cpu}`;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
// Try to find the binary in the platform-specific package
|
|
35
|
+
const pkgPath = require.resolve(`${pkgName}/package.json`);
|
|
36
|
+
const binPath = path.join(path.dirname(pkgPath), "bin", binaryName);
|
|
37
|
+
|
|
38
|
+
if (fs.existsSync(binPath)) {
|
|
39
|
+
return binPath;
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
// Package not found
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Could not find binary for ${platform}-${arch}. ` +
|
|
47
|
+
`Please ensure ${pkgName} is installed.`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const binary = getBinaryPath();
|
|
52
|
+
const args = process.argv.slice(2);
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
execFileSync(binary, args, { stdio: "inherit" });
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error.status !== undefined) {
|
|
58
|
+
process.exit(error.status);
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "micromachine.dev",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"repository": "https://github.com/micromachine/cmd-utils",
|
|
5
|
+
"bugs": "https://github.com/micromachine/cmd-utils/issues",
|
|
6
|
+
"homepage": "https://micromachine.dev",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "bin/micromachine.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"micromachine": "bin/micromachine.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"schema.json"
|
|
15
|
+
],
|
|
16
|
+
"optionalDependencies": {
|
|
17
|
+
"@micromachine.dev/cli-darwin-x64": "0.1.0",
|
|
18
|
+
"@micromachine.dev/cli-darwin-arm64": "0.1.0",
|
|
19
|
+
"@micromachine.dev/cli-linux-x64": "0.1.0",
|
|
20
|
+
"@micromachine.dev/cli-linux-arm": "0.1.0",
|
|
21
|
+
"@micromachine.dev/cli-linux-arm64": "0.1.0",
|
|
22
|
+
"@micromachine.dev/cli-windows-x64": "0.1.0",
|
|
23
|
+
"@micromachine.dev/cli-windows-arm64": "0.1.0"
|
|
24
|
+
}
|
|
25
|
+
}
|