Skip to content

Commit 53534f4

Browse files
committed
chore(core): add api helper scripts
1 parent f557664 commit 53534f4

File tree

5 files changed

+58
-4
lines changed

5 files changed

+58
-4
lines changed
File renamed without changes.

scripts/run-config/delete-run-config.ts renamed to scripts/api/delete-run-config.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,23 @@ const namespace =
2121
(await rl.question("Namespace (default: default): ")) || "default";
2222
const runnerName = await rl.question("Runner name to delete: ");
2323

24-
rl.close();
25-
2624
if (!runnerName) {
2725
console.error("Error: Runner name is required");
26+
rl.close();
2827
process.exit(1);
2928
}
3029

30+
const confirmDelete = await rl.question(
31+
`Are you sure you want to delete runner "${runnerName}" in namespace "${namespace}"? (yes/no): `,
32+
);
33+
34+
rl.close();
35+
36+
if (confirmDelete.toLowerCase() !== "yes") {
37+
console.log("Deletion cancelled.");
38+
process.exit(0);
39+
}
40+
3141
const response = await fetch(
3242
`${endpoint}/runner-configs/${runnerName}?namespace=${namespace}`,
3343
{
@@ -44,4 +54,4 @@ if (!response.ok) {
4454
process.exit(1);
4555
}
4656

47-
console.log(`✅ Successfully deleted runner configuration "${runnerName}"!`);
57+
console.log(`✅ Successfully deleted runner configuration "${runnerName}"!`);

scripts/run-config/list-run-config.ts renamed to scripts/api/list-run-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ if (!response.ok) {
4141
const data = await response.json();
4242

4343
// Just show the raw formatted JSON
44-
console.log(JSON.stringify(data, null, 2));
44+
console.log(JSON.stringify(data, null, 2));

scripts/api/list-runners.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env tsx
2+
3+
import * as readline from "readline/promises";
4+
5+
const rl = readline.createInterface({
6+
input: process.stdin,
7+
output: process.stdout,
8+
});
9+
10+
const rivetToken = process.env.RIVET_TOKEN;
11+
if (!rivetToken) {
12+
console.error("Error: RIVET_TOKEN environment variable is not set");
13+
process.exit(1);
14+
}
15+
16+
const endpoint =
17+
process.env.RIVET_ENDPOINT ||
18+
(await rl.question("Rivet Endpoint (default: https://api.rivet.gg): ")) ||
19+
"https://api.rivet.gg";
20+
const namespace =
21+
(await rl.question("Namespace (default: default): ")) || "default";
22+
23+
rl.close();
24+
25+
const response = await fetch(
26+
`${endpoint}/runners?namespace=${namespace}`,
27+
{
28+
method: "GET",
29+
headers: {
30+
Authorization: `Bearer ${rivetToken}`,
31+
},
32+
},
33+
);
34+
35+
if (!response.ok) {
36+
console.error(`Error: ${response.status} ${response.statusText}`);
37+
console.error(await response.text());
38+
process.exit(1);
39+
}
40+
41+
const data = await response.json();
42+
43+
// Just show the raw formatted JSON
44+
console.log(JSON.stringify(data, null, 2));
File renamed without changes.

0 commit comments

Comments
 (0)