@gaossr/kiri 0.1.6-darwin-arm64 → 0.1.6
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/ports.js +5 -0
- package/lib/resolve-binary.js +127 -0
- package/package.json +16 -14
- package/vendor/darwin-arm64/ports +0 -0
package/bin/ports.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const { spawnSync } = require("node:child_process");
|
|
6
|
+
|
|
7
|
+
const PLATFORM_PACKAGES = {
|
|
8
|
+
"darwin-arm64": "@gaossr/kiri-darwin-arm64",
|
|
9
|
+
"darwin-x64": "@gaossr/kiri-darwin-x64",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function platformKey(runtime = process) {
|
|
13
|
+
const platform = runtime.platform;
|
|
14
|
+
const arch = runtime.arch;
|
|
15
|
+
|
|
16
|
+
if (platform === "darwin" && arch === "arm64") {
|
|
17
|
+
return "darwin-arm64";
|
|
18
|
+
}
|
|
19
|
+
if (platform === "darwin" && arch === "x64") {
|
|
20
|
+
return "darwin-x64";
|
|
21
|
+
}
|
|
22
|
+
if (platform === "linux" && arch === "x64") {
|
|
23
|
+
return "linux-x64";
|
|
24
|
+
}
|
|
25
|
+
if (platform === "win32" && arch === "x64") {
|
|
26
|
+
return "win32-x64";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return `${platform}-${arch}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function binaryName(command) {
|
|
33
|
+
return process.platform === "win32" ? `${command}.exe` : command;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function platformPackageName(key) {
|
|
37
|
+
return PLATFORM_PACKAGES[key];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function binaryPath(command, options = {}) {
|
|
41
|
+
const packageRoot = options.packageRoot || path.join(__dirname, "..");
|
|
42
|
+
const runtime = options.runtime || process;
|
|
43
|
+
return path.join(packageRoot, "vendor", platformKey(runtime), binaryName(command));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function platformPackageBinaryPath(packageRoot, key, command) {
|
|
47
|
+
return path.join(packageRoot, "vendor", key, binaryName(command));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function resolveBinary(command, options = {}) {
|
|
51
|
+
const runtime = options.runtime || process;
|
|
52
|
+
const key = platformKey(runtime);
|
|
53
|
+
const platformPackage = platformPackageName(key);
|
|
54
|
+
|
|
55
|
+
if (!platformPackage) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const requireFn = options.requireFn || require;
|
|
60
|
+
try {
|
|
61
|
+
const packageJsonPath = requireFn.resolve(`${platformPackage}/package.json`);
|
|
62
|
+
const resolved = platformPackageBinaryPath(
|
|
63
|
+
path.dirname(packageJsonPath),
|
|
64
|
+
key,
|
|
65
|
+
command
|
|
66
|
+
);
|
|
67
|
+
if (fs.existsSync(resolved)) {
|
|
68
|
+
return resolved;
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
// Fall back to local vendor for staged-package verification.
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const localBinary = binaryPath(command, options);
|
|
75
|
+
if (fs.existsSync(localBinary)) {
|
|
76
|
+
return localBinary;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function runBinary(command) {
|
|
83
|
+
const key = platformKey();
|
|
84
|
+
const resolved = resolveBinary(command);
|
|
85
|
+
|
|
86
|
+
if (!platformPackageName(key)) {
|
|
87
|
+
console.error(
|
|
88
|
+
[
|
|
89
|
+
`Kiri does not have a bundled binary for ${key}.`,
|
|
90
|
+
"macOS is supported first; Linux and Windows packages will be added after their collectors ship.",
|
|
91
|
+
"This npm package does not compile Rust locally and does not require Cargo.",
|
|
92
|
+
].join("\n")
|
|
93
|
+
);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!resolved || !fs.existsSync(resolved)) {
|
|
98
|
+
console.error(
|
|
99
|
+
[
|
|
100
|
+
`Kiri npm package artifacts are missing for ${key}.`,
|
|
101
|
+
"Reinstall Kiri with: npm install -g @gaossr/kiri@latest",
|
|
102
|
+
"The npm package uses precompiled release binaries and does not compile Rust locally.",
|
|
103
|
+
"This npm package does not compile Rust locally and does not require Cargo.",
|
|
104
|
+
].join("\n")
|
|
105
|
+
);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const result = spawnSync(resolved, process.argv.slice(2), {
|
|
110
|
+
stdio: "inherit",
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (result.error) {
|
|
114
|
+
console.error(result.error.message);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
process.exit(result.status ?? 1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = {
|
|
122
|
+
binaryPath,
|
|
123
|
+
platformPackageName,
|
|
124
|
+
platformKey,
|
|
125
|
+
resolveBinary,
|
|
126
|
+
runBinary,
|
|
127
|
+
};
|
package/package.json
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaossr/kiri",
|
|
3
|
-
"version": "0.1.6
|
|
4
|
-
"description": "Kiri CLI for inspecting local development ports; installs the ports command
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "Kiri CLI for inspecting local development ports; installs the ports command",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
6
|
+
"bin": {
|
|
7
|
+
"ports": "./bin/ports.js"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/GaoSSR/kiri.git",
|
|
12
|
+
"directory": "packaging/npm"
|
|
13
|
+
},
|
|
12
14
|
"files": [
|
|
13
15
|
"LICENSE",
|
|
14
16
|
"README.md",
|
|
15
|
-
"
|
|
17
|
+
"bin/",
|
|
18
|
+
"lib/"
|
|
16
19
|
],
|
|
20
|
+
"optionalDependencies": {
|
|
21
|
+
"@gaossr/kiri-darwin-arm64": "npm:@gaossr/kiri@0.1.6-darwin-arm64",
|
|
22
|
+
"@gaossr/kiri-darwin-x64": "npm:@gaossr/kiri@0.1.6-darwin-x64"
|
|
23
|
+
},
|
|
17
24
|
"engines": {
|
|
18
25
|
"node": ">=18"
|
|
19
|
-
},
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/GaoSSR/kiri.git",
|
|
23
|
-
"directory": "packaging/npm"
|
|
24
26
|
}
|
|
25
27
|
}
|
|
Binary file
|