diff --git a/scripts/run-config/add-serverless.ts b/scripts/api/add-serverless.ts similarity index 100% rename from scripts/run-config/add-serverless.ts rename to scripts/api/add-serverless.ts diff --git a/scripts/run-config/delete-run-config.ts b/scripts/api/delete-run-config.ts similarity index 80% rename from scripts/run-config/delete-run-config.ts rename to scripts/api/delete-run-config.ts index b2ab310092..b0ff49c389 100755 --- a/scripts/run-config/delete-run-config.ts +++ b/scripts/api/delete-run-config.ts @@ -21,13 +21,23 @@ const namespace = (await rl.question("Namespace (default: default): ")) || "default"; const runnerName = await rl.question("Runner name to delete: "); -rl.close(); - if (!runnerName) { console.error("Error: Runner name is required"); + rl.close(); process.exit(1); } +const confirmDelete = await rl.question( + `Are you sure you want to delete runner "${runnerName}" in namespace "${namespace}"? (yes/no): `, +); + +rl.close(); + +if (confirmDelete.toLowerCase() !== "yes") { + console.log("Deletion cancelled."); + process.exit(0); +} + const response = await fetch( `${endpoint}/runner-configs/${runnerName}?namespace=${namespace}`, { @@ -44,4 +54,4 @@ if (!response.ok) { process.exit(1); } -console.log(`✅ Successfully deleted runner configuration "${runnerName}"!`); \ No newline at end of file +console.log(`✅ Successfully deleted runner configuration "${runnerName}"!`); diff --git a/scripts/run-config/list-run-config.ts b/scripts/api/list-run-config.ts similarity index 95% rename from scripts/run-config/list-run-config.ts rename to scripts/api/list-run-config.ts index 4f3f6a7023..9a82ede8ed 100755 --- a/scripts/run-config/list-run-config.ts +++ b/scripts/api/list-run-config.ts @@ -41,4 +41,4 @@ if (!response.ok) { const data = await response.json(); // Just show the raw formatted JSON -console.log(JSON.stringify(data, null, 2)); \ No newline at end of file +console.log(JSON.stringify(data, null, 2)); diff --git a/scripts/api/list-runners.ts b/scripts/api/list-runners.ts new file mode 100755 index 0000000000..527ab19609 --- /dev/null +++ b/scripts/api/list-runners.ts @@ -0,0 +1,44 @@ +#!/usr/bin/env tsx + +import * as readline from "readline/promises"; + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, +}); + +const rivetToken = process.env.RIVET_TOKEN; +if (!rivetToken) { + console.error("Error: RIVET_TOKEN environment variable is not set"); + process.exit(1); +} + +const endpoint = + process.env.RIVET_ENDPOINT || + (await rl.question("Rivet Endpoint (default: https://api.rivet.gg): ")) || + "https://api.rivet.gg"; +const namespace = + (await rl.question("Namespace (default: default): ")) || "default"; + +rl.close(); + +const response = await fetch( + `${endpoint}/runners?namespace=${namespace}`, + { + method: "GET", + headers: { + Authorization: `Bearer ${rivetToken}`, + }, + }, +); + +if (!response.ok) { + console.error(`Error: ${response.status} ${response.statusText}`); + console.error(await response.text()); + process.exit(1); +} + +const data = await response.json(); + +// Just show the raw formatted JSON +console.log(JSON.stringify(data, null, 2)); \ No newline at end of file diff --git a/scripts/run-config/package.json b/scripts/api/package.json similarity index 100% rename from scripts/run-config/package.json rename to scripts/api/package.json