@zaisma/cli 0.3.0 → 0.3.2
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.
- package/package.json +1 -1
- package/zaisma.mjs +15 -5
package/package.json
CHANGED
package/zaisma.mjs
CHANGED
|
@@ -65,7 +65,7 @@ async function api(method, path, body) {
|
|
|
65
65
|
body: body instanceof Uint8Array ? body : body ? JSON.stringify(body) : undefined,
|
|
66
66
|
});
|
|
67
67
|
const data = await res.json().catch(() => ({}));
|
|
68
|
-
if (!res.ok) fail(data.error
|
|
68
|
+
if (!res.ok) fail(data.error ? `${data.error.message} ${data.error.fix} (${data.error.code})` : `the server answered ${res.status}.`);
|
|
69
69
|
return data;
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -163,8 +163,8 @@ async function upload(folder, opts) {
|
|
|
163
163
|
console.log(`Publish it with: zaisma publish ${slug} ${v.id}`);
|
|
164
164
|
}
|
|
165
165
|
} else {
|
|
166
|
-
console.log(v.scan_status === "held" ? "Held
|
|
167
|
-
|
|
166
|
+
console.log(v.scan_status === "held" ? "Held for a person at Zaisma to look at. Why:" : "Rejected. Why:");
|
|
167
|
+
printReasons(v);
|
|
168
168
|
if (v.scan_status === "rejected") process.exit(1);
|
|
169
169
|
}
|
|
170
170
|
return;
|
|
@@ -172,6 +172,16 @@ async function upload(folder, opts) {
|
|
|
172
172
|
console.log(`Still scanning. Check later with: zaisma versions ${slug}`);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/** Why a version is held or rejected: a person's or a report's decision, then what the scan found, each with its code and rule, then what to do. */
|
|
176
|
+
function printReasons(version) {
|
|
177
|
+
const reasons = [...(version.review_reason ? [version.review_reason] : []), ...version.findings];
|
|
178
|
+
for (const reason of reasons) console.log(` - ${reason.message}${reason.path ? ` (${reason.path})` : ""} [${reason.code}${reason.content_rule ? `, rule: ${reason.content_rule}` : ""}]`);
|
|
179
|
+
for (const fix of new Set(reasons.map((reason) => reason.fix))) console.log(` ${fix}`);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** The code a held or removed game, or a held or rejected version, is held back by, to look up in the forum. */
|
|
183
|
+
const reasonCode = (thing) => (thing.review_reason ?? thing.findings?.[0])?.code ?? "";
|
|
184
|
+
|
|
175
185
|
const day = (at) => at.slice(0, 10);
|
|
176
186
|
|
|
177
187
|
function printTopic(topic) {
|
|
@@ -266,7 +276,7 @@ async function main() {
|
|
|
266
276
|
if (command === "games") {
|
|
267
277
|
const { games, unread_topic_count } = await api("GET", "/games");
|
|
268
278
|
if (!games.length) return console.log('No games yet. Make one with: zaisma new "My Game"');
|
|
269
|
-
for (const g of games) console.log(`${g.slug.padEnd(28)} ${g.visibility.padEnd(9)} ${g.review_status.padEnd(8)} ${g.title}`);
|
|
279
|
+
for (const g of games) console.log(`${g.slug.padEnd(28)} ${g.visibility.padEnd(9)} ${g.review_status.padEnd(8)} ${g.title}${g.review_reason ? ` [${reasonCode(g)}]` : ""}`);
|
|
270
280
|
if (unread_topic_count) console.log(`\nZaisma replied to ${unread_topic_count} of your forum topics. See them with: zaisma forum`);
|
|
271
281
|
return;
|
|
272
282
|
}
|
|
@@ -281,7 +291,7 @@ async function main() {
|
|
|
281
291
|
const slug = opts._[0];
|
|
282
292
|
if (!slug) fail("usage: zaisma versions <slug>");
|
|
283
293
|
const { versions } = await api("GET", `/games/${slug}`);
|
|
284
|
-
for (const v of versions) console.log(`${v.id} ${v.created_at.slice(0, 16).replace("T", " ")} ${(v.is_live ? "live" : v.scan_status).padEnd(9)} ${v.preview_url ?? ""}${v.scheduled_publish_at ? ` goes live ${new Date(v.scheduled_publish_at).toLocaleString()}` : ""}`);
|
|
294
|
+
for (const v of versions) console.log(`${v.id} ${v.created_at.slice(0, 16).replace("T", " ")} ${(v.is_live ? "live" : v.scan_status).padEnd(9)} ${v.preview_url ?? (v.scan_status === "held" || v.scan_status === "rejected" ? `[${reasonCode(v)}]` : "")}${v.scheduled_publish_at ? ` goes live ${new Date(v.scheduled_publish_at).toLocaleString()}` : ""}`);
|
|
285
295
|
return;
|
|
286
296
|
}
|
|
287
297
|
if (command === "publish") {
|