Add metadata-only publication of role selection tag
This commit is contained in:
parent
f780b583cf
commit
593cc114df
1 changed files with 21 additions and 0 deletions
21
scripts/publish-tags.mjs
Normal file
21
scripts/publish-tags.mjs
Normal file
|
|
@ -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 }));
|
||||
Loading…
Add table
Add a link
Reference in a new issue