onepipeline-api-cli 0.3.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/onepipeline-api.js +94 -0
- package/package.json +36 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Launcher for the `onepipeline-api` command installed from the
|
|
3
|
+
// `onepipeline-api-cli` npm package.
|
|
4
|
+
//
|
|
5
|
+
// Like the PyPI wheels (maturin `bindings = "bin"`, see pyproject.toml), the npm
|
|
6
|
+
// distribution carries the *prebuilt* Rust binary — no Rust toolchain, no
|
|
7
|
+
// compile, no download at install time. The platform-specific binary ships
|
|
8
|
+
// inside a per-platform package (`onepipeline-api-cli-<platform>-<arch>`)
|
|
9
|
+
// declared in this package's `optionalDependencies`; npm installs only the one
|
|
10
|
+
// whose `os`/`cpu` match the host, and this shim resolves it and execs it with
|
|
11
|
+
// the caller's argv.
|
|
12
|
+
//
|
|
13
|
+
// This file is committed source; the version and the optionalDependency
|
|
14
|
+
// versions are stamped from Cargo.toml at publish time by scripts/npm-build.mjs,
|
|
15
|
+
// which also generates the per-platform packages from the release binaries.
|
|
16
|
+
|
|
17
|
+
"use strict";
|
|
18
|
+
|
|
19
|
+
const { spawnSync } = require("node:child_process");
|
|
20
|
+
|
|
21
|
+
// process.platform-process.arch -> the platform package that carries the binary.
|
|
22
|
+
// The keys mirror the Rust target matrix in .github/workflows/release.yml and
|
|
23
|
+
// the optionalDependencies in package.json; keep the three in lockstep.
|
|
24
|
+
const PACKAGES = {
|
|
25
|
+
"linux-x64": "onepipeline-api-cli-linux-x64",
|
|
26
|
+
"linux-arm64": "onepipeline-api-cli-linux-arm64",
|
|
27
|
+
"darwin-x64": "onepipeline-api-cli-darwin-x64",
|
|
28
|
+
"darwin-arm64": "onepipeline-api-cli-darwin-arm64",
|
|
29
|
+
"win32-x64": "onepipeline-api-cli-win32-x64",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Every failure here is a failed install, so say what to do about it rather than
|
|
33
|
+
// only what went wrong.
|
|
34
|
+
const OTHER_INSTALLS =
|
|
35
|
+
"Install another way instead: 'pip install onepipeline-api-cli', or " +
|
|
36
|
+
"'cargo install onepipeline-ui --locked'.";
|
|
37
|
+
|
|
38
|
+
function fail(message) {
|
|
39
|
+
process.stderr.write(`onepipeline-api: ${message}\n`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function binaryPath() {
|
|
44
|
+
const key = `${process.platform}-${process.arch}`;
|
|
45
|
+
const pkg = PACKAGES[key];
|
|
46
|
+
// llmlint: ignore-block[changed_behavior_has_e2e] reaching this branch means running
|
|
47
|
+
// where no prebuilt package exists, and a test can only get there by lying to node
|
|
48
|
+
// about process.platform — which would prove the lie. The sibling branches are driven
|
|
49
|
+
// for real by tests/e2e/packaging.rs (npm omits the optional dependency; the binary
|
|
50
|
+
// resolves and execs), and npm's own os/cpu fields keep a user from installing a
|
|
51
|
+
// platform package this map does not name.
|
|
52
|
+
if (!pkg) {
|
|
53
|
+
fail(
|
|
54
|
+
`unsupported platform ${key}. Prebuilt binaries exist for: ` +
|
|
55
|
+
`${Object.keys(PACKAGES).join(", ")}. ${OTHER_INSTALLS}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
// llmlint: ignore-end[changed_behavior_has_e2e]
|
|
59
|
+
|
|
60
|
+
const binName =
|
|
61
|
+
process.platform === "win32" ? "onepipeline-api.exe" : "onepipeline-api";
|
|
62
|
+
try {
|
|
63
|
+
// Resolve the platform package's manifest, then locate the binary beside it.
|
|
64
|
+
// Resolving package.json (rather than the binary file directly) is portable
|
|
65
|
+
// across Node resolution modes and does not require an `exports` entry for a
|
|
66
|
+
// non-JS asset.
|
|
67
|
+
const path = require("node:path");
|
|
68
|
+
const manifest = require.resolve(`${pkg}/package.json`);
|
|
69
|
+
return path.join(path.dirname(manifest), "bin", binName);
|
|
70
|
+
} catch (_err) {
|
|
71
|
+
fail(
|
|
72
|
+
`the platform package ${pkg} is not installed. This usually means npm ` +
|
|
73
|
+
"skipped optional dependencies (e.g. --no-optional / --omit=optional) " +
|
|
74
|
+
"or the install was for a different platform. Reinstall with optional " +
|
|
75
|
+
`dependencies enabled. ${OTHER_INSTALLS}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const result = spawnSync(binaryPath(), process.argv.slice(2), {
|
|
81
|
+
stdio: "inherit",
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (result.error) {
|
|
85
|
+
fail(`failed to launch the onepipeline-api binary: ${result.error.message}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Re-raise a terminating signal so callers observe the true cause; otherwise
|
|
89
|
+
// propagate the child's exit code verbatim — a caller scripting against the
|
|
90
|
+
// documented exit codes depends on seeing them.
|
|
91
|
+
if (result.signal) {
|
|
92
|
+
process.kill(process.pid, result.signal);
|
|
93
|
+
}
|
|
94
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "onepipeline-api-cli",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Read API and browser view for onepipeline runs.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"api",
|
|
8
|
+
"telemetry",
|
|
9
|
+
"observability",
|
|
10
|
+
"onepipeline"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/nickderobertis/onepipeline-ui",
|
|
13
|
+
"bugs": "https://github.com/nickderobertis/onepipeline-ui/issues",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/nickderobertis/onepipeline-ui.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Nick DeRobertis",
|
|
20
|
+
"bin": {
|
|
21
|
+
"onepipeline-api": "bin/onepipeline-api.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin/onepipeline-api.js"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"optionalDependencies": {
|
|
30
|
+
"onepipeline-api-cli-linux-x64": "0.3.1",
|
|
31
|
+
"onepipeline-api-cli-linux-arm64": "0.3.1",
|
|
32
|
+
"onepipeline-api-cli-darwin-x64": "0.3.1",
|
|
33
|
+
"onepipeline-api-cli-darwin-arm64": "0.3.1",
|
|
34
|
+
"onepipeline-api-cli-win32-x64": "0.3.1"
|
|
35
|
+
}
|
|
36
|
+
}
|