@rivetkit/engine-cli 0.0.0-main.d6a0ba8
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/README.md +27 -0
- package/index.d.ts +14 -0
- package/index.js +106 -0
- package/package.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @rivetkit/engine-cli
|
|
2
|
+
|
|
3
|
+
Platform-specific rivet-engine binary distribution. Shipped as a set of
|
|
4
|
+
`@rivetkit/engine-cli-<platform>` packages. The meta package at
|
|
5
|
+
`@rivetkit/engine-cli` exposes `getEnginePath()` which returns the absolute
|
|
6
|
+
path to the binary for the current host.
|
|
7
|
+
|
|
8
|
+
## Supported platforms
|
|
9
|
+
|
|
10
|
+
- `linux-x64-musl` — Linux x86_64 (static, runs on any distro)
|
|
11
|
+
- `linux-arm64-musl` — Linux aarch64 (static)
|
|
12
|
+
- `darwin-x64` — macOS Intel
|
|
13
|
+
- `darwin-arm64` — macOS Apple Silicon
|
|
14
|
+
- `win32-x64` — Windows x64 on release versions only
|
|
15
|
+
|
|
16
|
+
Preview tags do not publish the Windows platform package. On preview builds,
|
|
17
|
+
use the PowerShell installer from `https://releases.rivet.dev` or point
|
|
18
|
+
`RIVET_ENGINE_BINARY` at a local `rivet-engine.exe`.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
const { getEnginePath } = require("@rivetkit/engine-cli");
|
|
24
|
+
const { spawn } = require("node:child_process");
|
|
25
|
+
|
|
26
|
+
const child = spawn(getEnginePath(), ["start"]);
|
|
27
|
+
```
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the absolute path to the rivet-engine binary for the current host.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order:
|
|
5
|
+
* 1. `RIVET_ENGINE_BINARY` env var (absolute path override)
|
|
6
|
+
* 2. Local `rivet-engine` binary next to this package (dev builds)
|
|
7
|
+
* 3. The platform-specific `@rivetkit/engine-cli-<platform>` npm package
|
|
8
|
+
*
|
|
9
|
+
* Throws if none of the above yields a binary.
|
|
10
|
+
*/
|
|
11
|
+
export function getEnginePath(): string;
|
|
12
|
+
|
|
13
|
+
/** Returns the expected name of the platform-specific npm package for the current host, or null if unsupported. */
|
|
14
|
+
export function getPlatformPackageName(): string | null;
|
package/index.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @rivetkit/engine-cli
|
|
3
|
+
*
|
|
4
|
+
* Platform-specific rivet-engine binary resolver. The binary itself is shipped
|
|
5
|
+
* in one of several `@rivetkit/engine-cli-<platform>` packages as an
|
|
6
|
+
* optionalDependency — npm only installs the one matching the current
|
|
7
|
+
* `os`/`cpu`/`libc` at install time.
|
|
8
|
+
*
|
|
9
|
+
* Priority at resolve time:
|
|
10
|
+
* 1. `RIVET_ENGINE_BINARY` env var (absolute path override for debugging)
|
|
11
|
+
* 2. Local `rivet-engine` binary next to this package (dev builds)
|
|
12
|
+
* 3. The platform-specific `@rivetkit/engine-cli-<platform>` npm package
|
|
13
|
+
*/
|
|
14
|
+
const { existsSync } = require("node:fs");
|
|
15
|
+
const { dirname, join } = require("node:path");
|
|
16
|
+
|
|
17
|
+
/** Returns the name of the platform-specific npm package for the current host. */
|
|
18
|
+
function getPlatformPackageName() {
|
|
19
|
+
const { platform, arch } = process;
|
|
20
|
+
switch (platform) {
|
|
21
|
+
case "linux":
|
|
22
|
+
// Engine is statically linked against musl, so the single musl
|
|
23
|
+
// build runs on both Alpine/musl and glibc hosts. We only publish
|
|
24
|
+
// the musl variant and every linux host maps to it.
|
|
25
|
+
if (arch === "x64") return "@rivetkit/engine-cli-linux-x64-musl";
|
|
26
|
+
if (arch === "arm64") return "@rivetkit/engine-cli-linux-arm64-musl";
|
|
27
|
+
break;
|
|
28
|
+
case "darwin":
|
|
29
|
+
if (arch === "x64") return "@rivetkit/engine-cli-darwin-x64";
|
|
30
|
+
if (arch === "arm64") return "@rivetkit/engine-cli-darwin-arm64";
|
|
31
|
+
break;
|
|
32
|
+
case "win32":
|
|
33
|
+
if (arch === "x64") return "@rivetkit/engine-cli-win32-x64";
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The binary filename inside each platform package. */
|
|
40
|
+
const BINARY_NAME =
|
|
41
|
+
process.platform === "win32" ? "rivet-engine.exe" : "rivet-engine";
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns the absolute path to the rivet-engine binary for the current host.
|
|
45
|
+
* @returns {string}
|
|
46
|
+
*/
|
|
47
|
+
function getEnginePath() {
|
|
48
|
+
// 1) Env var override.
|
|
49
|
+
if (process.env.RIVET_ENGINE_BINARY) {
|
|
50
|
+
if (!existsSync(process.env.RIVET_ENGINE_BINARY)) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`RIVET_ENGINE_BINARY is set to ${process.env.RIVET_ENGINE_BINARY} but the file does not exist`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return process.env.RIVET_ENGINE_BINARY;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 2) Local binary next to this package (dev flow: copy from cargo target).
|
|
59
|
+
const localBinary = join(__dirname, BINARY_NAME);
|
|
60
|
+
if (existsSync(localBinary)) {
|
|
61
|
+
return localBinary;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 3) Platform-specific npm package.
|
|
65
|
+
const platformPkg = getPlatformPackageName();
|
|
66
|
+
if (!platformPkg) {
|
|
67
|
+
if (process.platform === "win32" && process.arch === "x64") {
|
|
68
|
+
throw new Error(
|
|
69
|
+
"@rivetkit/engine-cli: Windows x64 is not yet supported via npm platform packages.\n" +
|
|
70
|
+
"Use the PowerShell installer from releases.rivet.dev or set RIVET_ENGINE_BINARY\n" +
|
|
71
|
+
"to a local rivet-engine.exe binary.",
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
throw new Error(
|
|
75
|
+
`@rivetkit/engine-cli: unsupported platform ${process.platform}/${process.arch}`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
let pkgJsonPath;
|
|
79
|
+
try {
|
|
80
|
+
pkgJsonPath = require.resolve(`${platformPkg}/package.json`);
|
|
81
|
+
} catch {
|
|
82
|
+
if (process.platform === "win32" && process.arch === "x64") {
|
|
83
|
+
const version = require("./package.json").version;
|
|
84
|
+
if (
|
|
85
|
+
typeof version === "string" &&
|
|
86
|
+
(version.includes("-pr.") || version.includes("-main."))
|
|
87
|
+
) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
"@rivetkit/engine-cli: Windows x64 binaries are only published for release versions.\n" +
|
|
90
|
+
`The current package version (${version}) is a preview build, so @rivetkit/engine-cli-win32-x64 was intentionally not published.\n` +
|
|
91
|
+
"Use a proper release, the PowerShell installer from releases.rivet.dev, or set RIVET_ENGINE_BINARY to a local rivet-engine.exe binary.",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
throw new Error(
|
|
96
|
+
`@rivetkit/engine-cli: platform package ${platformPkg} is not installed.\n` +
|
|
97
|
+
`This usually means the platform is not supported or optionalDependencies\n` +
|
|
98
|
+
`were skipped during install. Try: npm install --include=optional ${platformPkg}\n` +
|
|
99
|
+
`Or set RIVET_ENGINE_BINARY to a local rivet-engine binary.`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return join(dirname(pkgJsonPath), BINARY_NAME);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports.getEnginePath = getEnginePath;
|
|
106
|
+
module.exports.getPlatformPackageName = getPlatformPackageName;
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rivetkit/engine-cli",
|
|
3
|
+
"version": "0.0.0-main.d6a0ba8",
|
|
4
|
+
"description": "Rivet Engine binary distributed as platform-specific npm packages",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">= 20.0.0"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"index.d.ts",
|
|
14
|
+
"package.json",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"optionalDependencies": {
|
|
18
|
+
"@rivetkit/engine-cli-darwin-arm64": "0.0.0-main.d6a0ba8",
|
|
19
|
+
"@rivetkit/engine-cli-darwin-x64": "0.0.0-main.d6a0ba8",
|
|
20
|
+
"@rivetkit/engine-cli-linux-arm64-musl": "0.0.0-main.d6a0ba8",
|
|
21
|
+
"@rivetkit/engine-cli-linux-x64-musl": "0.0.0-main.d6a0ba8"
|
|
22
|
+
}
|
|
23
|
+
}
|