@zaisma/cli 0.9.0 → 0.11.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 +4 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaisma/cli",
3
- "version": "0.9.0",
3
+ "version": "0.11.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
@@ -3,12 +3,14 @@
3
3
  // Docs: https://github.com/zaisma/zaisma/blob/main/docs/DEVELOPER-API.md#the-upload-command
4
4
 
5
5
  import { createHash } from "node:crypto";
6
- import { createReadStream } from "node:fs";
6
+ import { createReadStream, readFileSync } from "node:fs";
7
7
  import { open, readdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
8
8
  import { extname, join, relative, sep } from "node:path";
9
9
 
10
10
  const API = (process.env.ZAISMA_API || "https://zaisma.com").replace(/\/+$/, "");
11
11
  const KEY = process.env.ZAISMA_KEY || "";
12
+ /** This command's version, sent as its user agent so a game's history can say "the upload command 0.10.0". */
13
+ const CLI_VERSION = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8")).version;
12
14
  /** Files bigger than this go in parts; the server says how big each part is. */
13
15
  const DIRECT_BYTES = 95 * 1024 * 1024;
14
16
  const JUNK = new Set([".DS_Store", "Thumbs.db", "desktop.ini", "__MACOSX", ".git", "node_modules"]);
@@ -353,7 +355,7 @@ async function api(method, path, body) {
353
355
  try {
354
356
  response = await fetch(`${API}/api/dev${path}`, {
355
357
  method,
356
- headers: { authorization: `Bearer ${KEY}`, "x-zaisma-client": "cli", ...(body && !(body instanceof Uint8Array) ? { "content-type": "application/json" } : {}) },
358
+ headers: { authorization: `Bearer ${KEY}`, "x-zaisma-client": "cli", "user-agent": `zaisma-cli/${CLI_VERSION}`, ...(body && !(body instanceof Uint8Array) ? { "content-type": "application/json" } : {}) },
357
359
  body: body instanceof Uint8Array ? body : body ? JSON.stringify(body) : undefined,
358
360
  });
359
361
  } catch (error) {