@kargobuild/kargo 0.0.0-stage → 0.7.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/kargo.js +105 -0
- package/package.json +35 -4
- package/README.md +0 -3
package/bin/kargo.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawn } = require("node:child_process");
|
|
5
|
+
const { constants } = require("node:os");
|
|
6
|
+
|
|
7
|
+
const PACKAGES = {
|
|
8
|
+
"darwin arm64": "@kargobuild/kargo-darwin-arm64",
|
|
9
|
+
"darwin x64": "@kargobuild/kargo-darwin-x64",
|
|
10
|
+
"linux arm64": "@kargobuild/kargo-linux-arm64",
|
|
11
|
+
"linux x64": "@kargobuild/kargo-linux-x64",
|
|
12
|
+
"win32 x64": "@kargobuild/kargo-win32-x64",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// crates/kargo-cli/src/signals.rs handles SIGTERM and nothing else, so a
|
|
16
|
+
// supervisor's stop request has to reach the binary rather than stop here.
|
|
17
|
+
const FORWARDED = ["SIGINT", "SIGTERM", "SIGHUP", "SIGBREAK"].filter(
|
|
18
|
+
(signal) => signal in constants.signals
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
function fail(message) {
|
|
22
|
+
process.stderr.write(`kargo: ${message}\n`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function resolveBinary() {
|
|
27
|
+
const host = `${process.platform} ${process.arch}`;
|
|
28
|
+
const pkg = PACKAGES[host];
|
|
29
|
+
|
|
30
|
+
if (pkg === undefined) {
|
|
31
|
+
fail(
|
|
32
|
+
`no prebuilt binary for ${host}.\n` +
|
|
33
|
+
" Supported: " +
|
|
34
|
+
Object.keys(PACKAGES).join(", ") +
|
|
35
|
+
".\n" +
|
|
36
|
+
" Build from source instead: https://kargo.build/getting-started/installation.html"
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const exe = process.platform === "win32" ? "kargo.exe" : "kargo";
|
|
41
|
+
let binary;
|
|
42
|
+
let found;
|
|
43
|
+
try {
|
|
44
|
+
binary = require.resolve(`${pkg}/bin/${exe}`);
|
|
45
|
+
found = require(`${pkg}/package.json`).version;
|
|
46
|
+
} catch {
|
|
47
|
+
fail(
|
|
48
|
+
`${pkg} is not installed.\n` +
|
|
49
|
+
" It is an optional dependency, so --no-optional and --omit=optional skip it.\n" +
|
|
50
|
+
" Reinstall with optional dependencies enabled, or install the binary directly:\n" +
|
|
51
|
+
" https://kargo.build/getting-started/installation.html"
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Node resolves by walking up node_modules, so a hoisted copy from another
|
|
56
|
+
// install can answer instead of the pinned optional dependency.
|
|
57
|
+
const expected = require("../package.json").version;
|
|
58
|
+
if (found !== expected) {
|
|
59
|
+
fail(
|
|
60
|
+
`${pkg} is ${found}, but this launcher is ${expected}.\n` +
|
|
61
|
+
` Resolved: ${binary}\n` +
|
|
62
|
+
" A copy from another install is shadowing the pinned one. Reinstall\n" +
|
|
63
|
+
" @kargobuild/kargo, or deduplicate the tree with `npm dedupe`."
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return binary;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const child = spawn(resolveBinary(), process.argv.slice(2), { stdio: "inherit" });
|
|
71
|
+
|
|
72
|
+
for (const signal of FORWARDED) {
|
|
73
|
+
process.on(signal, () => {
|
|
74
|
+
if (child.exitCode === null && child.signalCode === null) {
|
|
75
|
+
try {
|
|
76
|
+
child.kill(signal);
|
|
77
|
+
} catch {
|
|
78
|
+
// The child can exit between that check and here, and Windows rejects
|
|
79
|
+
// console signals it cannot deliver. Keep waiting for it either way.
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
child.on("error", (error) => fail(error.message));
|
|
86
|
+
|
|
87
|
+
child.on("exit", (code, signal) => {
|
|
88
|
+
for (const forwarded of FORWARDED) {
|
|
89
|
+
process.removeAllListeners(forwarded);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Exiting 1 on a signal would make Ctrl+C read as a build failure to whatever
|
|
93
|
+
// is watching the status, and would lose which signal stopped the build.
|
|
94
|
+
if (signal) {
|
|
95
|
+
process.kill(process.pid, signal);
|
|
96
|
+
|
|
97
|
+
// Re-raising is only fatal while the disposition still is, and Node ignores
|
|
98
|
+
// some signals with no way to reset that from JS. Returning here would then
|
|
99
|
+
// drain the loop and exit 0, reporting a signalled build as a success.
|
|
100
|
+
const number = constants.signals[signal];
|
|
101
|
+
process.exit(number === undefined ? 1 : 128 + number);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
process.exit(code === null ? 1 : code);
|
|
105
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kargobuild/kargo",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "A fast, modern build and dependency management tool for Kotlin, written in Rust.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"kotlin",
|
|
7
|
+
"build-tool",
|
|
8
|
+
"package-manager",
|
|
9
|
+
"maven",
|
|
10
|
+
"kmp",
|
|
11
|
+
"gradle-alternative"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://kargo.build",
|
|
14
|
+
"bugs": "https://github.com/kargobuild/kargo/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/kargobuild/kargo.git",
|
|
18
|
+
"directory": "packaging/npm/kargo"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT OR Apache-2.0",
|
|
21
|
+
"bin": {
|
|
22
|
+
"kargo": "bin/kargo.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin/kargo.js"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"optionalDependencies": {
|
|
31
|
+
"@kargobuild/kargo-darwin-arm64": "0.7.0",
|
|
32
|
+
"@kargobuild/kargo-darwin-x64": "0.7.0",
|
|
33
|
+
"@kargobuild/kargo-linux-arm64": "0.7.0",
|
|
34
|
+
"@kargobuild/kargo-linux-x64": "0.7.0",
|
|
35
|
+
"@kargobuild/kargo-win32-x64": "0.7.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/README.md
DELETED