From 593cc114df308ed64e14a8680b97ca5c6409d389 Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Sun, 18 Oct 2026 15:51:42 +0200 Subject: [PATCH] Add metadata-only publication of role selection tag --- scripts/publish-tags.mjs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 scripts/publish-tags.mjs diff --git a/scripts/publish-tags.mjs b/scripts/publish-tags.mjs new file mode 100644 index 0000000..45fc7d4 --- /dev/null +++ b/scripts/publish-tags.mjs @@ -0,0 +1,21 @@ +import { readFile } from "node:fs/promises"; +import { homedir } from "node:os"; +import assert from "node:assert/strict"; + +const token = (await readFile(`${homedir()}/.bgs`, "utf8")).trim(); +const url = "https://admin.boardgamers.space/api/admin/gameinfo/vanuatu/meta"; +const headers = { Authorization: `Bearer ${token}`, "Content-Type": "application/json" }; +const beforeResponse = await fetch(url, { headers }); +assert(beforeResponse.ok, `Metadata read: ${beforeResponse.status}`); +const before = await beforeResponse.json(); +const tags = [...new Set([...(before.tags ?? []), "role-selection"])]; +const response = await fetch(url, { method: "PUT", headers, body: JSON.stringify({ tags }) }); +assert(response.ok, `Tags update: ${response.status}`); +const afterResponse = await fetch(url, { headers }); +assert(afterResponse.ok, `Metadata verification: ${afterResponse.status}`); +const after = await afterResponse.json(); +assert.deepEqual(after.tags, tags); +for (const [key, value] of Object.entries(before)) { + if (!["tags", "updatedAt"].includes(key)) assert.deepEqual(after[key], value, key); +} +console.log(JSON.stringify({ game: "vanuatu", tags }));