@rivetkit/cli 0.0.0-codex-rivetkit-cli-preview.5e414a8

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 ADDED
@@ -0,0 +1,9 @@
1
+ # @rivetkit/cli
2
+
3
+ Rivet Cloud CLI distributed over npm.
4
+
5
+ ```sh
6
+ npx @rivetkit/cli dev
7
+ npx @rivetkit/cli deploy --token cloud_api_xxxxx
8
+ npx @rivetkit/cli init
9
+ ```
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /** Returns the absolute path to the rivet CLI binary for the current host. */
2
+ export function getCliPath(): string;
3
+
4
+ /** Returns the expected platform-specific npm package for the current host, or null if unsupported. */
5
+ export function getPlatformPackageName(): string | null;
package/index.js ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+ const { existsSync } = require("node:fs");
3
+ const { spawnSync } = require("node:child_process");
4
+ const { dirname, join } = require("node:path");
5
+
6
+ function getPlatformPackageName() {
7
+ const { platform, arch } = process;
8
+ switch (platform) {
9
+ case "linux":
10
+ if (arch === "x64") return "@rivetkit/cli-linux-x64-musl";
11
+ if (arch === "arm64") return "@rivetkit/cli-linux-arm64-musl";
12
+ break;
13
+ case "darwin":
14
+ if (arch === "x64") return "@rivetkit/cli-darwin-x64";
15
+ if (arch === "arm64") return "@rivetkit/cli-darwin-arm64";
16
+ break;
17
+ case "win32":
18
+ if (arch === "x64") return "@rivetkit/cli-win32-x64";
19
+ break;
20
+ }
21
+ return null;
22
+ }
23
+
24
+ const BINARY_NAME = process.platform === "win32" ? "rivet.exe" : "rivet";
25
+
26
+ function getCliPath() {
27
+ if (process.env.RIVET_CLI_BINARY) {
28
+ if (!existsSync(process.env.RIVET_CLI_BINARY)) {
29
+ throw new Error(
30
+ `RIVET_CLI_BINARY is set to ${process.env.RIVET_CLI_BINARY} but the file does not exist`,
31
+ );
32
+ }
33
+ return process.env.RIVET_CLI_BINARY;
34
+ }
35
+
36
+ const localBinary = join(__dirname, BINARY_NAME);
37
+ if (existsSync(localBinary)) return localBinary;
38
+
39
+ const platformPkg = getPlatformPackageName();
40
+ if (!platformPkg) {
41
+ throw new Error(
42
+ `@rivetkit/cli: unsupported platform ${process.platform}/${process.arch}`,
43
+ );
44
+ }
45
+
46
+ let pkgJsonPath;
47
+ try {
48
+ pkgJsonPath = require.resolve(`${platformPkg}/package.json`);
49
+ } catch {
50
+ if (process.platform === "win32" && process.arch === "x64") {
51
+ const version = require("./package.json").version;
52
+ if (
53
+ typeof version === "string" &&
54
+ version.startsWith("0.0.0-")
55
+ ) {
56
+ throw new Error(
57
+ "@rivetkit/cli: Windows x64 binaries are only published for release versions.\n" +
58
+ `The current package version (${version}) is a preview build, so @rivetkit/cli-win32-x64 was intentionally not published.\n` +
59
+ "Use a release build or set RIVET_CLI_BINARY to a local rivet.exe binary.",
60
+ );
61
+ }
62
+ }
63
+ throw new Error(
64
+ `@rivetkit/cli: platform package ${platformPkg} is not installed.\n` +
65
+ "Optional dependencies may have been skipped. Try npm install --include=optional @rivetkit/cli.",
66
+ );
67
+ }
68
+ return join(dirname(pkgJsonPath), BINARY_NAME);
69
+ }
70
+
71
+ if (require.main === module) {
72
+ const result = spawnSync(getCliPath(), process.argv.slice(2), {
73
+ stdio: "inherit",
74
+ env: process.env,
75
+ });
76
+ if (result.error) throw result.error;
77
+ process.exit(result.status ?? 1);
78
+ }
79
+
80
+ module.exports.getCliPath = getCliPath;
81
+ module.exports.getPlatformPackageName = getPlatformPackageName;
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@rivetkit/cli",
3
+ "version": "0.0.0-codex-rivetkit-cli-preview.5e414a8",
4
+ "description": "Rivet Cloud CLI",
5
+ "license": "LicenseRef-RivetEnterprise",
6
+ "main": "index.js",
7
+ "types": "index.d.ts",
8
+ "bin": {
9
+ "rivet": "index.js"
10
+ },
11
+ "engines": {
12
+ "node": ">= 20.0.0"
13
+ },
14
+ "files": [
15
+ "index.js",
16
+ "index.d.ts",
17
+ "package.json",
18
+ "README.md"
19
+ ],
20
+ "optionalDependencies": {
21
+ "@rivetkit/cli-darwin-arm64": "0.0.0-codex-rivetkit-cli-preview.5e414a8",
22
+ "@rivetkit/cli-darwin-x64": "0.0.0-codex-rivetkit-cli-preview.5e414a8",
23
+ "@rivetkit/cli-linux-arm64-musl": "0.0.0-codex-rivetkit-cli-preview.5e414a8",
24
+ "@rivetkit/cli-linux-x64-musl": "0.0.0-codex-rivetkit-cli-preview.5e414a8"
25
+ }
26
+ }