@xelandernt/skilly 0.0.22 → 0.0.24
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/dist/src/bin/skilly.js +5 -0
- package/dist/src/lib/launcher.js +62 -0
- package/dist/src/lib/targets.js +90 -0
- package/package.json +4 -4
- package/vendor/aarch64-apple-darwin/skilly +0 -0
- package/vendor/x86_64-apple-darwin/skilly +0 -0
- package/vendor/x86_64-pc-windows-msvc/skilly.exe +0 -0
- package/vendor/x86_64-unknown-linux-gnu/skilly +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveBinaryPath = resolveBinaryPath;
|
|
7
|
+
exports.ensureBinaryExists = ensureBinaryExists;
|
|
8
|
+
exports.launch = launch;
|
|
9
|
+
exports.run = run;
|
|
10
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const node_child_process_1 = require("node:child_process");
|
|
13
|
+
const targets_1 = require("./targets");
|
|
14
|
+
function resolveBinaryPath(options = {}) {
|
|
15
|
+
const rootDir = options.rootDir ?? node_path_1.default.resolve(__dirname, "..", "..", "..");
|
|
16
|
+
const processLike = options.processLike ?? process;
|
|
17
|
+
const target = (0, targets_1.resolveTarget)(processLike);
|
|
18
|
+
return node_path_1.default.join(rootDir, (0, targets_1.vendorRelativePath)(target));
|
|
19
|
+
}
|
|
20
|
+
function ensureBinaryExists(binaryPath) {
|
|
21
|
+
if (node_fs_1.default.existsSync(binaryPath)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const error = new Error(`No packaged skilly binary was found at ${binaryPath}. Reinstall ${targets_1.PACKAGE_NAME} or rebuild the npm package with staged native binaries.`);
|
|
25
|
+
error.code = "ERR_MISSING_BINARY";
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
function launch(argv, options = {}) {
|
|
29
|
+
const processLike = options.processLike ?? process;
|
|
30
|
+
const spawnImpl = options.spawnImpl ?? node_child_process_1.spawn;
|
|
31
|
+
const binaryPath = resolveBinaryPath(options);
|
|
32
|
+
ensureBinaryExists(binaryPath);
|
|
33
|
+
const child = spawnImpl(binaryPath, argv, {
|
|
34
|
+
env: processLike.env,
|
|
35
|
+
stdio: "inherit",
|
|
36
|
+
windowsHide: false
|
|
37
|
+
});
|
|
38
|
+
return { child, binaryPath };
|
|
39
|
+
}
|
|
40
|
+
function writeError(processLike, message) {
|
|
41
|
+
if (processLike.stderr && typeof processLike.stderr.write === "function") {
|
|
42
|
+
processLike.stderr.write(`${message}\n`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
console.error(message);
|
|
46
|
+
}
|
|
47
|
+
function run(argv, options = {}) {
|
|
48
|
+
const processLike = options.processLike ?? process;
|
|
49
|
+
const { child, binaryPath } = launch(argv, options);
|
|
50
|
+
child.once("error", (error) => {
|
|
51
|
+
writeError(processLike, `Failed to launch skilly from ${binaryPath}: ${error.message}`);
|
|
52
|
+
processLike.exit(1);
|
|
53
|
+
});
|
|
54
|
+
child.once("close", (code, signal) => {
|
|
55
|
+
if (signal) {
|
|
56
|
+
processLike.kill(processLike.pid, signal);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
processLike.exit(code ?? 1);
|
|
60
|
+
});
|
|
61
|
+
return child;
|
|
62
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TARGETS = exports.PACKAGE_NAME = void 0;
|
|
7
|
+
exports.supportedTargetLabels = supportedTargetLabels;
|
|
8
|
+
exports.detectLinuxLibc = detectLinuxLibc;
|
|
9
|
+
exports.executableName = executableName;
|
|
10
|
+
exports.vendorRelativePath = vendorRelativePath;
|
|
11
|
+
exports.unsupportedPlatformError = unsupportedPlatformError;
|
|
12
|
+
exports.resolveTarget = resolveTarget;
|
|
13
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
exports.PACKAGE_NAME = "@xelandernt/skilly";
|
|
15
|
+
exports.TARGETS = [
|
|
16
|
+
{
|
|
17
|
+
platform: "darwin",
|
|
18
|
+
arch: "arm64",
|
|
19
|
+
triple: "aarch64-apple-darwin",
|
|
20
|
+
label: "macOS arm64"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
platform: "darwin",
|
|
24
|
+
arch: "x64",
|
|
25
|
+
triple: "x86_64-apple-darwin",
|
|
26
|
+
label: "macOS x64"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
platform: "linux",
|
|
30
|
+
arch: "x64",
|
|
31
|
+
libc: "glibc",
|
|
32
|
+
triple: "x86_64-unknown-linux-gnu",
|
|
33
|
+
label: "Linux x64 (glibc)"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
platform: "win32",
|
|
37
|
+
arch: "x64",
|
|
38
|
+
triple: "x86_64-pc-windows-msvc",
|
|
39
|
+
label: "Windows x64"
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
function supportedTargetLabels() {
|
|
43
|
+
return exports.TARGETS.map((target) => target.label);
|
|
44
|
+
}
|
|
45
|
+
function detectLinuxLibc(processLike = process) {
|
|
46
|
+
if (processLike.platform !== "linux") {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const report = processLike.report;
|
|
50
|
+
if (!report || typeof report.getReport !== "function") {
|
|
51
|
+
return "unknown";
|
|
52
|
+
}
|
|
53
|
+
const glibcVersionRuntime = report.getReport()?.header?.glibcVersionRuntime;
|
|
54
|
+
return glibcVersionRuntime ? "glibc" : "musl";
|
|
55
|
+
}
|
|
56
|
+
function executableName(target) {
|
|
57
|
+
return target.platform === "win32" ? "skilly.exe" : "skilly";
|
|
58
|
+
}
|
|
59
|
+
function vendorRelativePath(target) {
|
|
60
|
+
return node_path_1.default.posix.join("vendor", target.triple, executableName(target));
|
|
61
|
+
}
|
|
62
|
+
function unsupportedPlatformError(processLike = process) {
|
|
63
|
+
const libc = detectLinuxLibc(processLike);
|
|
64
|
+
const details = libc
|
|
65
|
+
? `${processLike.platform} ${processLike.arch} (${libc})`
|
|
66
|
+
: `${processLike.platform} ${processLike.arch}`;
|
|
67
|
+
const supported = supportedTargetLabels().join(", ");
|
|
68
|
+
const hint = processLike.platform === "linux" && libc !== "glibc"
|
|
69
|
+
? "Linux builds currently require glibc."
|
|
70
|
+
: "No packaged binary matches this platform.";
|
|
71
|
+
const error = new Error(`Unsupported platform for ${exports.PACKAGE_NAME}: ${details}. Supported targets: ${supported}. ${hint}`);
|
|
72
|
+
error.code = "ERR_UNSUPPORTED_PLATFORM";
|
|
73
|
+
return error;
|
|
74
|
+
}
|
|
75
|
+
function resolveTarget(processLike = process) {
|
|
76
|
+
const libc = detectLinuxLibc(processLike);
|
|
77
|
+
const target = exports.TARGETS.find((candidate) => {
|
|
78
|
+
if (candidate.platform !== processLike.platform || candidate.arch !== processLike.arch) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (candidate.platform !== "linux") {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return candidate.libc === libc;
|
|
85
|
+
});
|
|
86
|
+
if (!target) {
|
|
87
|
+
throw unsupportedPlatformError(processLike);
|
|
88
|
+
}
|
|
89
|
+
return target;
|
|
90
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xelandernt/skilly",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "Native npm launcher for the skilly CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
|
-
"skilly": "dist/bin/skilly.js"
|
|
7
|
+
"skilly": "dist/src/bin/skilly.js"
|
|
8
8
|
},
|
|
9
9
|
"type": "commonjs",
|
|
10
10
|
"files": [
|
|
11
11
|
"README.md",
|
|
12
|
-
"dist/bin",
|
|
13
|
-
"dist/lib",
|
|
12
|
+
"dist/src/bin",
|
|
13
|
+
"dist/src/lib",
|
|
14
14
|
"vendor"
|
|
15
15
|
],
|
|
16
16
|
"engines": {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|