@scm-js/cli 0.8.10 → 0.8.11

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.
@@ -1,4 +1,4 @@
1
- Third-party notices for scmjs 0.8.10
1
+ Third-party notices for scmjs 0.8.11
2
2
 
3
3
  scmjs is MIT-licensed (LICENSE). It is built into one file from scmJS's own code and the
4
4
  packages below, whose license texts this file carries. Who wrote what, and where the
package/dist/scmjs.mjs CHANGED
@@ -6857,8 +6857,8 @@ document.getElementById("go").onclick = go;
6857
6857
  //#endregion
6858
6858
  //#region cli/src/about.ts
6859
6859
  /** `scmjs about`: this build and whether npm has a newer one, who made it, the machine it runs on, the desktop app and Docker, and where everything is. */
6860
- var VERSION = "0.8.10";
6861
- var COMMIT = "6cf22f8";
6860
+ var VERSION = "0.8.11";
6861
+ var COMMIT = "71d8282";
6862
6862
  var BUILT = "2026-11-06";
6863
6863
  var PACKAGE = "@scm-js/cli";
6864
6864
  /** a < b, for x.y.z versions (a prerelease or build suffix is ignored). */
@@ -6893,7 +6893,7 @@ async function aboutReport() {
6893
6893
  return {
6894
6894
  version: VERSION,
6895
6895
  latest,
6896
- outdated: latest !== null && olderThan("0.8.10", latest),
6896
+ outdated: latest !== null && olderThan("0.8.11", latest),
6897
6897
  commit: COMMIT,
6898
6898
  built: BUILT,
6899
6899
  node: process.version,
@@ -6953,6 +6953,68 @@ function printAbout(r) {
6953
6953
  ];
6954
6954
  }
6955
6955
  //#endregion
6956
+ //#region cli/src/banner.ts
6957
+ /**
6958
+ * The app mark, the wireframe globe of `public/favicon.svg` and the splash screen, in braille (2 × 4 dots a
6959
+ * character): the splash's sphere (`src/components/splash/starfield.ts`) with 6 rings and 8 segments, turned 0.3 rad
6960
+ * about y and −0.45 about x, its near half and its outline, on 32 × 32 dots.
6961
+ */
6962
+ var GLOBE = [
6963
+ " ⣠⡴⢶⡿⣿⢿⢿⣲⢦⣄ ",
6964
+ " ⣠⠞⣡⠟⠯⢤⡧⠬⢷⡴⠛⠮⡳⣄ ",
6965
+ "⢰⢳⡼⠁ ⡞ ⢣ ⣘⣾⡆",
6966
+ "⡇⡼⠉⠙⠒⢦⠧⠤⠤⠤⠼⡖⠋⠁⠘⣾",
6967
+ "⡷⣇ ⢸ ⢧ ⣠⣿",
6968
+ "⠸⣏⠙⠒⠦⢼⠤⠤⠤⠤⠤⢼⠒⠋⢡⠇",
6969
+ " ⠙⢦⣀⡀⢸ ⣞⣀⡴⠋ ",
6970
+ " ⠙⠻⠭⣯⣓⣒⣫⠽⠟⠋ "
6971
+ ];
6972
+ /** The same globe in ASCII, for a console without braille (the old Windows one, where ui.ts's marks fall back too). */
6973
+ var GLOBE_ASCII = [
6974
+ " .-'''-. ",
6975
+ " .'/ | \\'. ",
6976
+ " /-+---+---+-\\ ",
6977
+ " | | | | | ",
6978
+ " |==+===+===+==| ",
6979
+ " \\-+---+---+-/ ",
6980
+ " '.\\ | /.' ",
6981
+ " '-...-' "
6982
+ ];
6983
+ /** The logo's violet (#a06cf0), or the terminal's magenta without 24-bit colour. */
6984
+ var violet = (s) => truecolor ? rgb("#a06cf0", s) : import_picocolors.default.magenta(s);
6985
+ /**
6986
+ * `text` beside the globe, centred on its height; the text alone when the terminal is narrower than both. `width` is
6987
+ * the terminal's (80 when it is not one).
6988
+ */
6989
+ function banner(text, { width = 80, ascii = !unicode } = {}) {
6990
+ const art = ascii ? GLOBE_ASCII : GLOBE;
6991
+ const artWidth = Math.max(...art.map((l) => l.length));
6992
+ const indent = " ", gap = " ";
6993
+ if (2 + artWidth + 3 + Math.max(...text.map((l) => visible(l).length)) > width) return text;
6994
+ const top = Math.max(0, Math.floor((art.length - text.length) / 2));
6995
+ return art.map((l, i) => text[i - top] ? `${indent}${violet(l.padEnd(artWidth))}${gap}${text[i - top]}` : `${indent}${violet(l.trimEnd())}`);
6996
+ }
6997
+ /** The overview, in place of commander's: the banner, the command groups as commander lays them out, the options. */
6998
+ function rootHelp(cmd, helper, version, opts = {}) {
6999
+ const termWidth = helper.padWidth(cmd, helper);
7000
+ const out = banner([
7001
+ `${import_picocolors.default.bold(import_picocolors.default.cyan(cmd.name()))} ${import_picocolors.default.bold(version)}`,
7002
+ "scmJS on the command line",
7003
+ import_picocolors.default.dim("StarCraft: Brood War maps, replays, plugins and bots"),
7004
+ "",
7005
+ `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`,
7006
+ `${helper.styleTitle("Docs:")} ${import_picocolors.default.cyan("https://docs.scmjs.dev")}`
7007
+ ], {
7008
+ width: helper.helpWidth ?? 80,
7009
+ ...opts
7010
+ });
7011
+ out.push("");
7012
+ const groups = helper.groupItems([...cmd.commands], helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
7013
+ for (const [heading, commands] of groups) out.push(...helper.formatItemList(heading, commands.map((sub) => helper.formatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), termWidth, helper.styleSubcommandDescription(helper.subcommandDescription(sub)), helper)), helper));
7014
+ out.push(`${helper.styleTitle("Options:")} ${helper.visibleOptions(cmd).map((o) => helper.styleOptionTerm(helper.optionTerm(o))).join(" ")}`, "");
7015
+ return out.join("\n");
7016
+ }
7017
+ //#endregion
6956
7018
  //#region src/formats/chk/binary.ts
6957
7019
  /** Little-endian readers/writers over a Uint8Array. StarCraft data is LE throughout. */
6958
7020
  var Reader$1 = class {
@@ -13008,10 +13070,18 @@ async function restoreBuiltMap(chk, extras) {
13008
13070
  };
13009
13071
  }
13010
13072
  //#endregion
13011
- //#region src/services/mapIo.ts
13012
- /** Read a picked or dropped file into a parsed document. */
13013
- async function openMapFile(file, handle = null) {
13014
- const loaded = await loadMap(new Uint8Array(await file.arrayBuffer()));
13073
+ //#region src/editor/mapFile.ts
13074
+ /**
13075
+ * A map file as bytes, in and out — the half of opening and saving that needs no browser.
13076
+ *
13077
+ * `openMapBytes` is what File ▸ Open, a drop, the command line and `@scm-js/core` all run:
13078
+ * the archive read, the scenario parsed, the other members kept, a built map restored to the
13079
+ * map it was built from, and the warnings the editor would show. `writeMapBytes` is the
13080
+ * reverse. The pickers, handles and downloads around them are `services/mapIo.ts`.
13081
+ */
13082
+ /** Read a map file's bytes (.scm, .scx or a bare .chk) into a parsed scenario and the rest of its archive. */
13083
+ async function openMapBytes(bytes, fileName) {
13084
+ const loaded = await loadMap(bytes);
13015
13085
  const problems = [];
13016
13086
  let members = {
13017
13087
  extras: /* @__PURE__ */ new Map(),
@@ -13057,8 +13127,7 @@ async function openMapFile(file, handle = null) {
13057
13127
  scenario,
13058
13128
  extras,
13059
13129
  stored,
13060
- fileName: file.name,
13061
- handle,
13130
+ fileName,
13062
13131
  origin: loaded.scenarioInfo,
13063
13132
  builtBy
13064
13133
  };
@@ -13709,7 +13778,7 @@ function kindOf(name, bytes) {
13709
13778
  }
13710
13779
  async function loadMapInput(input) {
13711
13780
  try {
13712
- return await openMapFile(new File([input.bytes], input.name));
13781
+ return await openMapBytes(input.bytes, input.name);
13713
13782
  } catch (e) {
13714
13783
  throw new CliError(`${input.name} is not a map this can read: ${e instanceof Error ? e.message : e}`);
13715
13784
  }
@@ -16256,17 +16325,9 @@ var program = new Command$1("scmjs").description("StarCraft: Brood War maps, rep
16256
16325
  subcommandTerm: (cmd) => {
16257
16326
  const subs = cmd.commands.map((c) => c.name()).filter((n) => n !== "help");
16258
16327
  return subs.length ? `${cmd.name()} ${subs.join("|")}` : new Help$1().subcommandTerm(cmd).replace(" [options]", "");
16259
- }
16260
- }).addHelpText("after", () => `
16261
- ${import_picocolors.default.bold("Examples:")}
16262
- ${import_picocolors.default.dim("$")} scmjs info "(2)Destination.scx" what a map or a replay holds
16263
- ${import_picocolors.default.dim("$")} scmjs map check *.scx Check Map on every map here
16264
- ${import_picocolors.default.dim("$")} scmjs replay open game.rep watch it in the editor
16265
- ${import_picocolors.default.dim("$")} scmjs plugin new "Base Check" a plugin for the editor to start from
16266
- ${import_picocolors.default.dim("$")} scmjs bot new a BWAPI bot to start from, for scmjs.dev/play
16267
- ${import_picocolors.default.dim("$")} scmjs about this version, and where things are
16268
-
16269
- ${import_picocolors.default.dim("Docs: https://docs.scmjs.dev")}`);
16328
+ },
16329
+ formatHelp: (cmd, helper) => cmd.parent ? Help$1.prototype.formatHelp.call(helper, cmd, helper) : rootHelp(cmd, helper, VERSION)
16330
+ });
16270
16331
  program.command("info").description("what a map, replay or bot file holds").helpGroup("Maps and replays:").argument("<files...>", "maps (.scm .scx .chk), replays (.rep) or bots (.scmbot)").addOption(json).action(async (files, o) => void await eachFile(files, !!o.json, async (input) => {
16271
16332
  const kind = expectKind(input, "map", "replay", "bot");
16272
16333
  return kind === "map" ? mapInfo(input) : kind === "replay" ? replayInfo(input) : botInfo(input);
@@ -16350,7 +16411,7 @@ program.command("about").description("this version, any newer one, and links").h
16350
16411
  const r = await aboutReport();
16351
16412
  print(...o.json ? [JSON.stringify(r, null, 2)] : printAbout(r));
16352
16413
  });
16353
- try {
16414
+ if (!process.env.VITEST) try {
16354
16415
  if (process.argv.length <= 2) program.outputHelp();
16355
16416
  else await program.parseAsync();
16356
16417
  } catch (e) {
@@ -16363,4 +16424,4 @@ try {
16363
16424
  }
16364
16425
  }
16365
16426
  //#endregion
16366
- export {};
16427
+ export { program };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/cli",
3
- "version": "0.8.10",
3
+ "version": "0.8.11",
4
4
  "description": "StarCraft: Brood War maps, replays and bots from the command line: what a map or replay holds, Check Map, opening them in scmJS, and building a BWAPI bot for the play page",
5
5
  "keywords": [
6
6
  "starcraft",