@magic-meal-kits/cli 1.0.1
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/mmk.js +48 -0
- package/package.json +21 -0
package/bin/mmk.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
|
|
7
|
+
const PLATFORM_PACKAGES = {
|
|
8
|
+
"darwin-arm64": "@mmk/cli-darwin-arm64",
|
|
9
|
+
"darwin-x64": "@mmk/cli-darwin-x64",
|
|
10
|
+
"linux-arm64": "@mmk/cli-linux-arm64",
|
|
11
|
+
"linux-x64": "@mmk/cli-linux-x64",
|
|
12
|
+
"win32-arm64": "@mmk/cli-win32-arm64",
|
|
13
|
+
"win32-x64": "@mmk/cli-win32-x64",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function getBinaryPath() {
|
|
17
|
+
const platform = os.platform();
|
|
18
|
+
const arch = os.arch();
|
|
19
|
+
const key = `${platform}-${arch}`;
|
|
20
|
+
const pkg = PLATFORM_PACKAGES[key];
|
|
21
|
+
|
|
22
|
+
if (!pkg) {
|
|
23
|
+
console.error(`Unsupported platform: ${key}`);
|
|
24
|
+
console.error("Supported: " + Object.keys(PLATFORM_PACKAGES).join(", "));
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const pkgPath = require.resolve(`${pkg}/package.json`);
|
|
30
|
+
const binName = platform === "win32" ? "mmk.exe" : "mmk";
|
|
31
|
+
return path.join(path.dirname(pkgPath), "bin", binName);
|
|
32
|
+
} catch {
|
|
33
|
+
console.error(`Platform package ${pkg} not installed.`);
|
|
34
|
+
console.error("Try: npm install -g @mmk/cli");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const binary = getBinaryPath();
|
|
41
|
+
execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
42
|
+
} catch (e) {
|
|
43
|
+
if (e.status !== undefined) {
|
|
44
|
+
process.exit(e.status);
|
|
45
|
+
}
|
|
46
|
+
console.error(e.message);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@magic-meal-kits/cli",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Magic Meal Kits CLI",
|
|
5
|
+
"bin": {
|
|
6
|
+
"mmk": "bin/mmk.js"
|
|
7
|
+
},
|
|
8
|
+
"optionalDependencies": {
|
|
9
|
+
"@magic-meal-kits/cli-darwin-arm64": "1.0.1",
|
|
10
|
+
"@magic-meal-kits/cli-darwin-x64": "1.0.1",
|
|
11
|
+
"@magic-meal-kits/cli-linux-arm64": "1.0.1",
|
|
12
|
+
"@magic-meal-kits/cli-linux-x64": "1.0.1",
|
|
13
|
+
"@magic-meal-kits/cli-win32-arm64": "1.0.1",
|
|
14
|
+
"@magic-meal-kits/cli-win32-x64": "1.0.1"
|
|
15
|
+
},
|
|
16
|
+
"license": "UNLICENSED",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/pureugong/make-docker-pack"
|
|
20
|
+
}
|
|
21
|
+
}
|