@zaisma/cli 0.21.0 → 0.22.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/zaisma.mjs +19 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaisma/cli",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Upload and publish browser games on Zaisma from the command line.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://zaisma.com",
package/zaisma.mjs CHANGED
@@ -136,6 +136,8 @@ const COMMANDS = {
136
136
  secrets: { about: "A game's secrets, which its game server reads as server.secrets and room.secrets: their names and when each was set, never the values", arguments: [{ name: "slug" }], flags: {} },
137
137
  "secrets set": { about: "Set a secret for a game's server, replacing one of the same name: the value piped in, or typed without showing; it's never shown again", arguments: [{ name: "slug" }, { name: "secret_name" }], flags: {} },
138
138
  "secrets delete": { about: "Delete one of a game's secrets", arguments: [{ name: "slug" }, { name: "secret_name" }], flags: {} },
139
+ "kept-rooms": { about: "A game's kept rooms (room.setKept), worlds that sleep with nobody in them: each one's code, name, size and when it was last played, and the game's storage", arguments: [{ name: "slug" }], flags: {} },
140
+ "kept-rooms delete": { about: "Delete a kept room's world for good; players in it are sent out", arguments: [{ name: "slug" }, { name: "room_code" }], flags: {} },
139
141
  logs: {
140
142
  about: "What a game's server printed on Zaisma in the last 30 days, oldest first: the newest lines, older ones with --cursor, or new ones as they come with --follow",
141
143
  arguments: [{ name: "slug" }],
@@ -237,7 +239,7 @@ const COMMANDS = {
237
239
  help: { about: "This help; with --json, every command, flag, exit code and error code", arguments: [], flags: {} },
238
240
  };
239
241
  /** Commands with a second word, like zaisma forum post. */
240
- const SUBCOMMANDS = { links: ["set", "remove"], forum: ["post", "message", "reply"], database: ["query", "batch", "export", "import", "restore", "undo-restore"], saves: ["get", "change", "replace", "reset", "copies", "copy", "restore"], secrets: ["set", "delete"] };
242
+ const SUBCOMMANDS = { links: ["set", "remove"], forum: ["post", "message", "reply"], database: ["query", "batch", "export", "import", "restore", "undo-restore"], saves: ["get", "change", "replace", "reset", "copies", "copy", "restore"], secrets: ["set", "delete"], "kept-rooms": ["delete"] };
241
243
  /** Flags every command takes. */
242
244
  const GLOBAL_FLAGS = {
243
245
  json: { hasValue: false, about: "Print the API's answer as JSON, as-is (on failure its { error }), and nothing else" },
@@ -1455,6 +1457,21 @@ async function secrets(command, values) {
1455
1457
  if (answer.next_steps.some((step) => step.tool === "update_game")) console.log(`It calls no other servers yet: list the hosts it uses this with, like zaisma allowed-hosts ${values.slug} discord.com`);
1456
1458
  }
1457
1459
 
1460
+ /** A game's kept rooms (…/games/<slug>/kept-rooms…), as the MCP's list_kept_rooms and delete_kept_room. */
1461
+ async function keptRooms(command, values) {
1462
+ if (command === "kept-rooms") {
1463
+ const answer = await api("GET", `/games/${values.slug}/kept-rooms`);
1464
+ if (isJson) return printJson(answer);
1465
+ if (!answer.kept_rooms.length) console.log(`No kept rooms. A game server keeps one with room.setKept(true).`);
1466
+ for (const keptRoom of answer.kept_rooms) console.log(`${keptRoom.room_code} ${(keptRoom.name ?? "").padEnd(24)} ${sizeText(keptRoom.saved_size_bytes).padStart(9)} played ${keptRoom.last_played_at ? when(keptRoom.last_played_at) : "never"}`);
1467
+ console.log(`Storage: ${sizeText(answer.storage_size_bytes)} of ${sizeText(answer.free_storage_size_bytes)} free (database and kept rooms).`);
1468
+ return;
1469
+ }
1470
+ const answer = await api("DELETE", `/games/${values.slug}/kept-rooms/${encodeURIComponent(values.room_code)}`);
1471
+ if (isJson) return printJson(answer);
1472
+ console.log(`Deleted kept room ${values.room_code.toUpperCase()} from ${values.slug}, and its world with it.`);
1473
+ }
1474
+
1458
1475
  /** A game server's logs (GET …/games/<slug>/logs), as the MCP's get_logs; --follow asks for new lines every 2 seconds. */
1459
1476
  async function logs(values, flags) {
1460
1477
  if (flags.follow && flags.cursor) refuse("conflicting_flags", { message: "--follow prints new lines, and --cursor older ones.", field: "cursor", fix: `Use one: zaisma logs ${values.slug} --follow, or zaisma logs ${values.slug} --cursor <next_cursor>.` });
@@ -1673,6 +1690,7 @@ async function run({ command, values, flags, globalFlags, rest }) {
1673
1690
  else if (command === "own-servers") await ownServers(values, flags);
1674
1691
  else if (command === "links" || command.startsWith("links ")) await links(command, values, flags);
1675
1692
  else if (command === "secrets" || command.startsWith("secrets ")) await secrets(command, values);
1693
+ else if (command === "kept-rooms" || command.startsWith("kept-rooms ")) await keptRooms(command, values);
1676
1694
  else if (command === "logs") await logs(values, flags);
1677
1695
  else if (command === "database" || command.startsWith("database ")) await database(command, values, flags);
1678
1696
  else if (command === "saves" || command.startsWith("saves ")) await saves(command, values, flags);