@rivet-dev/services 0.1.3-rc.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/README.md +19 -0
- package/cli.js +12 -0
- package/index.d.ts +6 -0
- package/index.js +63 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @rivet-dev/services
|
|
2
|
+
|
|
3
|
+
Resolves the prebuilt `rivet-services` binary for the current host. The binary
|
|
4
|
+
is intentionally a no-op while the managed services runtime is being built.
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
const { getServicesPath } = require("@rivet-dev/services");
|
|
8
|
+
|
|
9
|
+
const binaryPath = getServicesPath();
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The package also exposes the binary as an npm executable:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npx @rivet-dev/services start
|
|
16
|
+
npx @rivet-dev/services dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Set `RIVET_SERVICES_BINARY` to override binary resolution during development.
|
package/cli.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require("node:child_process");
|
|
5
|
+
const { getServicesPath } = require("./index.js");
|
|
6
|
+
|
|
7
|
+
const result = spawnSync(getServicesPath(), process.argv.slice(2), {
|
|
8
|
+
stdio: "inherit",
|
|
9
|
+
});
|
|
10
|
+
if (result.error) throw result.error;
|
|
11
|
+
if (result.signal) process.kill(process.pid, result.signal);
|
|
12
|
+
process.exit(result.status ?? 1);
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { existsSync } = require("node:fs");
|
|
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 "@rivet-dev/services-linux-x64-musl";
|
|
11
|
+
if (arch === "arm64") return "@rivet-dev/services-linux-arm64-musl";
|
|
12
|
+
break;
|
|
13
|
+
case "darwin":
|
|
14
|
+
if (arch === "x64") return "@rivet-dev/services-darwin-x64";
|
|
15
|
+
if (arch === "arm64") return "@rivet-dev/services-darwin-arm64";
|
|
16
|
+
break;
|
|
17
|
+
case "win32":
|
|
18
|
+
if (arch === "x64") return "@rivet-dev/services-win32-x64";
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const BINARY_NAME =
|
|
25
|
+
process.platform === "win32" ? "rivet-services.exe" : "rivet-services";
|
|
26
|
+
|
|
27
|
+
function getServicesPath() {
|
|
28
|
+
const override = process.env.RIVET_SERVICES_BINARY;
|
|
29
|
+
if (override) {
|
|
30
|
+
if (!existsSync(override)) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`RIVET_SERVICES_BINARY is set to ${override} but the file does not exist`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return override;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const localBinary = join(__dirname, BINARY_NAME);
|
|
39
|
+
if (existsSync(localBinary)) return localBinary;
|
|
40
|
+
|
|
41
|
+
const platformPackage = getPlatformPackageName();
|
|
42
|
+
if (!platformPackage) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`@rivet-dev/services: unsupported platform ${process.platform}/${process.arch}`,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let packageJsonPath;
|
|
49
|
+
try {
|
|
50
|
+
packageJsonPath = require.resolve(`${platformPackage}/package.json`);
|
|
51
|
+
} catch {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`@rivet-dev/services: platform package ${platformPackage} is not installed.\n` +
|
|
54
|
+
"Optional dependencies may have been skipped. Reinstall with optional dependencies enabled,\n" +
|
|
55
|
+
"or set RIVET_SERVICES_BINARY to a local rivet-services binary.",
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return join(dirname(packageJsonPath), BINARY_NAME);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports.getServicesPath = getServicesPath;
|
|
63
|
+
module.exports.getPlatformPackageName = getPlatformPackageName;
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rivet-dev/services",
|
|
3
|
+
"version": "0.1.3-rc.1",
|
|
4
|
+
"description": "Rivet Managed Services binary distributed as platform-specific npm packages",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/rivet-dev/services.git",
|
|
9
|
+
"directory": "npm/services-cli"
|
|
10
|
+
},
|
|
11
|
+
"main": "index.js",
|
|
12
|
+
"types": "index.d.ts",
|
|
13
|
+
"bin": {
|
|
14
|
+
"services": "cli.js",
|
|
15
|
+
"rivet-services": "cli.js"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"index.js",
|
|
22
|
+
"index.d.ts",
|
|
23
|
+
"cli.js",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"optionalDependencies": {
|
|
27
|
+
"@rivet-dev/services-darwin-arm64": "0.1.3-rc.1",
|
|
28
|
+
"@rivet-dev/services-darwin-x64": "0.1.3-rc.1",
|
|
29
|
+
"@rivet-dev/services-linux-arm64-musl": "0.1.3-rc.1",
|
|
30
|
+
"@rivet-dev/services-linux-x64-musl": "0.1.3-rc.1",
|
|
31
|
+
"@rivet-dev/services-win32-x64": "0.1.3-rc.1"
|
|
32
|
+
}
|
|
33
|
+
}
|