Public: anyone can read this; the crew can change it.
Games survival step 3: quality-of-life mods tried on a copy first (graves, essential-commands, sleep, harvest, vein miner, styled-chat) #18145
Merged 6h 13m ago, live in production
mason/forge:mason/18089-games-survival-step-3-quality-of-life-mo → main 0 commits fork
7 files
changed +188
−24
docs/features/game-mods.md +2 −1
| @@ -10,6 +10,7 @@ The server's mods or plugins come from Modrinth, for its loader and game version | ||
| 10 | 10 | - **Preview** picks the newest compatible version (a release when there is one) and resolves what it requires, recursively: "Adds Chunky 1.4.28; Adds ChunkyLib 1.0.2 (required by Chunky)". A project with no version for the server, a requirement with none, or two projects that say they are incompatible are refused with the reason. A bare slug already in `MODRINTH_PROJECTS` is pinned by the same change. |
| 11 | 11 | - **Install and restart** is one commit on the commit you previewed: the lockfile `<compose dir>/modrinth/<service>.lock.json` (each project's version id, file path, url and sha512, and whether it was asked for or is a dependency) and the compose env made from it: `MODRINTH_PROJECTS` lists `slug:versionId` for every project and `MODRINTH_DOWNLOAD_DEPENDENCIES=none`, so the image fetches exactly the locked set. A proxy also gets `MINECRAFT_VERSION`, which its Modrinth step needs. On a proxy whose servers sleep, `MODRINTH_PROJECTS` also holds AutoStopper (`PG4gqnzX:EclCtvWk`, see [](games.md)): it is sleep's, so a Modrinth change carries it over as it is and never lists it as the proxy's own, and Warm again takes only that entry. |
| 12 | 12 | - **Sets**: a named set installs in one preview and one commit. `set:survival` is the survival performance set for a Fabric server: Lithium, ScalableLux, Noisium and Chunky, each at its newest release for the server's Minecraft version, with what they require (Chunky needs Fabric API). It adds only what is missing, and a server on another loader is refused with the reason. The web Mods block shows it with a *Preview the set* button until it is installed; the terminal shows the same lines and `s` previews it; MCP `mods_install` takes `project: "set:survival"`. |
| 13 | - **Quality of life**: `set:quality` is graves (Universal Graves), Essential Commands, Styled Chat and Right Click Harvest for a Fabric server, installed like the survival set but optional by member: each is resolved alone, and one with no build for the server's Minecraft version (Right Click Harvest on 1.21.6) is left out with the reason ("Left out rightclickharvest: …") while the rest install; if none builds, it is refused. Essential Commands ships every command on; trimming it to /home, /spawn and /tpa is its config, which the owner sets, and the plan says so on a "Before players join" line, on the page and in the terminal. Each set shows a sentence on what it is for, and the web block offers *Preview the Quality of life set*, the terminal's key is `q`, MCP `mods_install` takes `project: "set:quality"`. | |
| 13 | 14 | - **Updates** post the locked sha512s to Modrinth's `/v2/version_files/update` (releases for the loader and version) and show "2 updates" as from → to, one click each or all. |
| 14 | 15 | - **Remove** takes a project and what only it required; a dependency something else requires stays. |
| 15 | 16 | |
| @@ -28,7 +29,7 @@ The image does not check a pack's file hashes (its Modrinth project path does; i | ||
| 28 | 29 | ## Where |
| 29 | 30 | |
| 30 | 31 | - **Web:** `/games/<box>/<service>`, the Mods (or Plugins) block: updates, what is installed, Search, Preview, Install and restart; on a mod server, the Modpack block: the pack, its locked files, Search packs, Preview, Install pack and restart. |
| 31 | - **Terminal:** a service's screen, `m`: `/` search, `a` install by a result's number or a slug, `s` the survival performance set, `u` update all, `d` remove, `p` a modpack by slug; `y` commits the preview shown, `n` drops it (`src/tui/screens/game_mods.ts`). | |
| 32 | - **Terminal:** a service's screen, `m`: `/` search, `a` install by a result's number or a slug, `s` the survival performance set, `q` the quality-of-life set, `u` update all, `d` remove, `p` a modpack by slug; `y` commits the preview shown, `n` drops it (`src/tui/screens/game_mods.ts`). | |
| 32 | 33 | - **MCP:** `games` with `mods`, `mods_search`, `mods_pack_search`, `mods_install`, `mods_update`, `mods_remove`, `mods_pack`; a change is planned until `dryRun: false`. |
| 33 | 34 | |
| 34 | 35 | All three read and write through `src/games/mods.ts`, over the client in `src/games/modrinth.ts`. |
src/games/mod_sets.ts +46 −1
| @@ -9,9 +9,23 @@ | ||
| 9 | 9 | export interface ModSet { |
| 10 | 10 | readonly name: string; |
| 11 | 11 | readonly title: string; |
| 12 | /** The terminal key that previews the set; unique among sets and the screen's other keys. */ | |
| 13 | readonly key: string; | |
| 14 | /** One sentence that says what the set is for, ahead of its rows. */ | |
| 15 | readonly about: string; | |
| 12 | 16 | /** The Modrinth loader its projects are for; a server on another loader is refused. */ |
| 13 | 17 | readonly loader: string; |
| 14 | 18 | readonly slugs: readonly string[]; |
| 19 | /** | |
| 20 | * Each project is tried alone and one with no build for the server is left out, with the reason, | |
| 21 | * where a set that is not optional is refused whole (#18089). | |
| 22 | */ | |
| 23 | readonly optional?: boolean; | |
| 24 | /** | |
| 25 | * What the owner must do about a member before players join, by slug; the plan says it on a line | |
| 26 | * when that member is in it. | |
| 27 | */ | |
| 28 | readonly cautions?: Readonly<Record<string, string>>; | |
| 15 | 29 | /** One line for each project: what it is for. */ |
| 16 | 30 | readonly why: readonly string[]; |
| 17 | 31 | } |
| @@ -22,6 +36,8 @@ export const SET_PREFIX = "set:"; | ||
| 22 | 36 | export const SURVIVAL: ModSet = Object.freeze({ |
| 23 | 37 | name: "survival", |
| 24 | 38 | title: "Survival performance", |
| 39 | key: "s", | |
| 40 | about: "Four mods that make a Fabric survival server cheaper to run without changing how it plays.", | |
| 25 | 41 | loader: "fabric", |
| 26 | 42 | slugs: Object.freeze(["lithium", "scalablelux", "noisium", "chunky"]), |
| 27 | 43 | why: Object.freeze([ |
| @@ -32,10 +48,39 @@ export const SURVIVAL: ModSet = Object.freeze({ | ||
| 32 | 48 | ]), |
| 33 | 49 | }); |
| 34 | 50 | |
| 51 | /** | |
| 52 | * Quality-of-life mods for a Fabric survival server (step 3 of #18059): graves, home/spawn/tpa | |
| 53 | * commands, styled chat and right-click harvest. Optional: a mod that does not build for the | |
| 54 | * server's Minecraft version (rightclickharvest on 1.21.6) is skipped and named, not a refusal. | |
| 55 | * Essential Commands ships with every command on; its config is the owner's to trim to /home, | |
| 56 | * /spawn and /tpa. | |
| 57 | */ | |
| 58 | export const QUALITY: ModSet = Object.freeze({ | |
| 59 | name: "quality", | |
| 60 | title: "Quality of life", | |
| 61 | key: "q", | |
| 62 | about: "Graves, home and spawn commands, styled chat and right-click harvest for a Fabric survival server.", | |
| 63 | loader: "fabric", | |
| 64 | optional: true, | |
| 65 | slugs: Object.freeze(["universal-graves", "essential-commands", "styled-chat", "rightclickharvest"]), | |
| 66 | cautions: Object.freeze({ | |
| 67 | "essential-commands": "Essential Commands installs with every command on: before players join, trim its config to /home, /spawn and /tpa.", | |
| 68 | }), | |
| 69 | why: Object.freeze([ | |
| 70 | "Universal Graves: a death leaves a grave with your items instead of a pile that despawns", | |
| 71 | "Essential Commands: /home, /spawn and /tpa for players", | |
| 72 | "Styled Chat: chat with colours and formatting", | |
| 73 | "Right Click Harvest: right-click a ripe crop to harvest and replant it (skipped when it has no build for this version)", | |
| 74 | ]), | |
| 75 | }); | |
| 76 | ||
| 77 | /** Every set a `project` value can name. */ | |
| 78 | export const SETS: readonly ModSet[] = Object.freeze([SURVIVAL, QUALITY]); | |
| 79 | ||
| 35 | 80 | /** The set a `project` value names (`set:survival`), if there is one. */ |
| 36 | 81 | export function setNamed(ref: string): ModSet | undefined { |
| 37 | 82 | const r = ref.trim().toLowerCase(); |
| 38 | return r === `${SET_PREFIX}${SURVIVAL.name}` ? SURVIVAL : undefined; | |
| 83 | return SETS.find((s) => r === `${SET_PREFIX}${s.name}`); | |
| 39 | 84 | } |
| 40 | 85 | |
| 41 | 86 | /** |
src/games/mods.ts +24 −7
| @@ -20,7 +20,7 @@ import type { App } from "../app.ts"; | ||
| 20 | 20 | import type { User } from "../core/users.ts"; |
| 21 | 21 | import { commitCompose, composeDir, pluginUrls, readCompose, readRepoFile, serviceEnv, setServiceEnv } from "./compose.ts"; |
| 22 | 22 | import { byVersion, latestRelease, newestPack, packUpdate, readPack, resolve, targetOf, updates, type Locked, type LockedPack, type Result, type Target, type Version } from "./modrinth.ts"; |
| 23 | import { missing as setMissing, setNamed, SET_PREFIX, type ModSet } from "./mod_sets.ts"; | |
| 23 | import { missing as setMissing, setNamed, SETS, SET_PREFIX, type ModSet } from "./mod_sets.ts"; | |
| 24 | 24 | import { memoryRefusal, type BoxRoom } from "./box_memory.ts"; |
| 25 | 25 | import { AUTOSTOPPER } from "./sleep.ts"; |
| 26 | 26 | import { servicesOf, type GameBox } from "./store.ts"; |
| @@ -200,7 +200,7 @@ export async function planInstall(app: App, m: Mods, service: string, ref: strin | ||
| 200 | 200 | const wantedRef = ref.trim(); |
| 201 | 201 | if (wantedRef.toLowerCase().startsWith(SET_PREFIX)) { |
| 202 | 202 | const set = setNamed(wantedRef); |
| 203 | return set === undefined ? { ok: false, error: `There is no set called ${wantedRef.slice(SET_PREFIX.length)}; the sets are ${SET_PREFIX}survival.` } : planSet(app, m, service, set); | |
| 203 | return set === undefined ? { ok: false, error: `There is no set called ${wantedRef.slice(SET_PREFIX.length)}; the sets are ${SETS.map((x) => `${SET_PREFIX}${x.name}`).join(", ")}.` } : planSet(app, m, service, set); | |
| 204 | 204 | } |
| 205 | 205 | if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,99}$/.test(wantedRef)) |
| 206 | 206 | return { ok: false, error: "Name a Modrinth project by its slug or id, like luckperms." }; |
| @@ -247,18 +247,35 @@ async function planSet(app: App, m: Mods, service: string, set: ModSet): Promise | ||
| 247 | 247 | if (missing.length === 0) return { ok: false, error: `The ${set.title.toLowerCase()} set is installed.` }; |
| 248 | 248 | const adopt = m.loose.filter(bareSlug).filter((s) => !missing.includes(s.toLowerCase())); |
| 249 | 249 | const kept = m.loose.filter((e) => !bareSlug(e) || missing.includes(e.toLowerCase())); |
| 250 | const got = await resolve(app, m.target, m.lock, [ | |
| 251 | ...missing.map((s) => ({ project: find(m.lock, s)?.project ?? s, top: true })), | |
| 250 | const asked = (slugs: readonly string[]) => [ | |
| 251 | ...slugs.map((s) => ({ project: find(m.lock, s)?.project ?? s, top: true })), | |
| 252 | 252 | ...adopt.map((s) => ({ project: s, top: true })), |
| 253 | ]); | |
| 253 | ]; | |
| 254 | const skipped = new Map<string, string>(); | |
| 255 | let got: Result<Locked[]>; | |
| 256 | if (set.optional !== true) got = await resolve(app, m.target, m.lock, asked(missing)); | |
| 257 | else { | |
| 258 | // Each project alone, on what the ones before it locked: one with no build is left out. | |
| 259 | got = await resolve(app, m.target, m.lock, asked([])); | |
| 260 | for (const slug of missing) { | |
| 261 | if (!got.ok) break; | |
| 262 | const one = await resolve(app, m.target, got.value, [{ project: find(m.lock, slug)?.project ?? slug, top: true }]); | |
| 263 | if (one.ok) got = one; | |
| 264 | else skipped.set(slug, one.error); | |
| 265 | } | |
| 266 | if (got.ok && skipped.size === missing.length) | |
| 267 | return { ok: false, error: `None of the ${set.title.toLowerCase()} set runs on ${m.target.label}: ${[...skipped].map(([k, v]) => `${k}: ${v}`).join(" ")}` }; | |
| 268 | } | |
| 254 | 269 | if (!got.ok) return got; |
| 255 | 270 | const deps = got.value.filter((l) => !l.top && !m.lock.some((o) => o.project === l.project)).length; |
| 256 | const what = `the ${set.title.toLowerCase()} set (${missing.join(", ")})`; | |
| 271 | const what = `the ${set.title.toLowerCase()} set (${missing.filter((x) => !skipped.has(x)).join(", ")})`; | |
| 257 | 272 | const withDeps = deps === 0 ? "" : ` and ${String(deps)} ${deps === 1 ? "dependency" : "dependencies"}`; |
| 258 | 273 | return { |
| 259 | 274 | ok: true, |
| 260 | 275 | value: { |
| 261 | lines: diffLines(m, got.value, new Set(adopt)), | |
| 276 | lines: [...diffLines(m, got.value, new Set(adopt)), ...[...skipped].map(([k, v]) => `Left out ${k}: ${v}`), | |
| 277 | ...Object.entries(set.cautions ?? {}).filter(([k]) => missing.includes(k) && !skipped.has(k)).map(([, v]) => `Before players join: ${v}`), | |
| 278 | ], | |
| 262 | 279 | lock: got.value, |
| 263 | 280 | env: envFor(m, got.value, kept), |
| 264 | 281 | message: `games: ${service} mods: add ${what}${withDeps}`, |
src/http/mcp/tools/games.ts +1 −1
Diff not shown — a line 3,047 characters wide (limit 2,000). +1 −1
View filesrc/tui/screens/game_mods.ts +6 −7
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | * shown and `n` drops it; `l` makes a link to the client pack for players and `x` ends every link. |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | import { offered, SET_PREFIX, SURVIVAL } from "../../games/mod_sets.ts"; | |
| 10 | import { offered, SETS, SET_PREFIX } from "../../games/mod_sets.ts"; | |
| 11 | 11 | import { search, type Hit, type Result } from "../../games/modrinth.ts"; |
| 12 | 12 | import { commitPlan, modsOf, packUpdateOf, planInstall, planPack, planPackUpdate, planRemove, planUpdate, updatesOf, type Mods, type Plan } from "../../games/mods.ts"; |
| 13 | 13 | import { makePackLink, packRow, revokeLinks, type PackRow } from "../../games/client_pack.ts"; |
| @@ -66,9 +66,7 @@ export function gameModsScreen(f: Session, ctx: Ctx, box: GameBox, service: stri | ||
| 66 | 66 | ...(m.lock.length + m.loose.length + m.urls.length === 0 ? ["Nothing is installed."] : []), |
| 67 | 67 | ...(players === undefined ? [] : [`players: ${players.open > 0 ? `${String(players.open)} link(s) open; x ends all. ` : ""}${players.can ? "l makes a link. " : ""}${players.words}`]), |
| 68 | 68 | ...(link === "" ? [] : [`link (30 days, shown once): ${link}`]), |
| 69 | ...(offered(SURVIVAL, m.target, m.lock) | |
| 70 | ? [`${SURVIVAL.title} set: ${SURVIVAL.slugs.join(", ")}; s previews it`, ...SURVIVAL.why.map((w) => ` ${w}`)] | |
| 71 | : []), | |
| 69 | ...SETS.filter((set) => offered(set, m.target, m.lock)).flatMap((set) => [`${set.title} set: ${set.about} ${set.slugs.join(", ")}; ${set.key} previews it`, ...set.why.map((w) => ` ${w}`)]), | |
| 72 | 70 | ...hits.map((h, i) => `${String(i + 1)}. ${h.title} (${h.slug}) ${h.fits ? `runs on ${m.target.gameVersion}` : h.why}`), |
| 73 | 71 | `Uploading a jar is on the web only: /games/${box.name}/${service}.`, |
| 74 | 72 | ]; |
| @@ -92,7 +90,7 @@ export function gameModsScreen(f: Session, ctx: Ctx, box: GameBox, service: stri | ||
| 92 | 90 | keys: [ |
| 93 | 91 | binding(["/"], "search Modrinth"), |
| 94 | 92 | binding(["a"], "install"), |
| 95 | binding(["s"], `preview the ${SURVIVAL.title.toLowerCase()} set`), | |
| 93 | ...SETS.map((set) => binding([set.key], `preview the ${set.title} set`)), | |
| 96 | 94 | binding(["u"], "update all"), |
| 97 | 95 | binding(["d"], "remove"), |
| 98 | 96 | binding(["p"], "modpack"), |
| @@ -135,9 +133,10 @@ export function gameModsScreen(f: Session, ctx: Ctx, box: GameBox, service: stri | ||
| 135 | 133 | const ref = /^\d+$/.test(v) ? (hits[Number(v) - 1]?.slug ?? v) : v; |
| 136 | 134 | return preview((m) => planInstall(f.app, m, service, ref)); |
| 137 | 135 | }); |
| 138 | else if (e.key === "s") { | |
| 136 | else if (SETS.some((set) => set.key === e.key)) { | |
| 137 | const set = SETS.find((x) => x.key === e.key)!; | |
| 139 | 138 | if (!operator()) say(`You are not an operator of ${service}.`); |
| 140 | else void preview((m) => planInstall(f.app, m, service, `${SET_PREFIX}${SURVIVAL.name}`)).then(say); | |
| 139 | else void preview((m) => planInstall(f.app, m, service, `${SET_PREFIX}${set.name}`)).then(say); | |
| 141 | 140 | } else if (e.key === "d") ask("Remove", "The slug of what to remove", (raw) => preview((m) => planRemove(m, service, raw.trim()))); |
| 142 | 141 | else if (e.key === "p") ask("Modpack", "A Modrinth modpack's slug", (raw) => preview((m) => planPack(f.app, m, service, raw.trim()))); |
| 143 | 142 | else if (e.key === "l" || e.key === "x") { |
src/web/pages/games.ts +7 −4
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | import { addPluginUrl, commitServiceEnv, composeServices, readCompose, serviceEnv } from "../../games/compose.ts"; |
| 11 | import { offered, SET_PREFIX, SURVIVAL } from "../../games/mod_sets.ts"; | |
| 11 | import { offered, SETS, SET_PREFIX } from "../../games/mod_sets.ts"; | |
| 12 | 12 | import { commitPlan, modsOf, packUpdateOf, planInstall, planPack, planPackUpdate, planRemove, planUpdate, updatesOf, type Mods, type Plan } from "../../games/mods.ts"; |
| 13 | 13 | import { search, searchPacks, type Hit, type Result } from "../../games/modrinth.ts"; |
| 14 | 14 | import { packRow } from "../../games/client_pack.ts"; |
| @@ -897,9 +897,12 @@ function modsBlock(o: { | ||
| 897 | 897 | }), |
| 898 | 898 | ), |
| 899 | 899 | ])} |
| 900 | ${o.act && offered(SURVIVAL, t, m.lock) && o.adding !== `${SET_PREFIX}${SURVIVAL.name}` | |
| 901 | ? html`${rowList(SURVIVAL.why.map((w) => row({ title: w })))} | |
| 902 | ${btn("Preview the set", { size: "sm", variant: "secondary", href: `${o.base}?add=${SET_PREFIX}${SURVIVAL.name}#mods`, label: `Preview installing the ${SURVIVAL.title.toLowerCase()} set` })}` | |
| 900 | ${o.act | |
| 901 | ? SETS.filter((set) => offered(set, t, m.lock) && o.adding !== `${SET_PREFIX}${set.name}`).map( | |
| 902 | (set) => html`<p class="muted">${set.about}</p> | |
| 903 | ${rowList(set.why.map((w) => row({ title: w })))} | |
| 904 | ${btn(`Preview the ${set.title} set`, { size: "sm", variant: "secondary", href: `${o.base}?add=${SET_PREFIX}${set.name}#mods`, label: `Preview installing the ${set.title} set` })}`, | |
| 905 | ) | |
| 903 | 906 | : null} |
| 904 | 907 | ${o.preview === undefined |
| 905 | 908 | ? null |
test/game-mods.test.ts +102 −3
| @@ -22,6 +22,7 @@ import { packVerdict } from "../src/games/pack_check.ts"; | ||
| 22 | 22 | import { askPower } from "../src/games/power.ts"; |
| 23 | 23 | import { AUTOSTOPPER, commitPolicy } from "../src/games/sleep.ts"; |
| 24 | 24 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 25 | import { QUALITY, SETS } from "../src/games/mod_sets.ts"; | |
| 25 | 26 | import { gameModsScreen } from "../src/tui/screens/game_mods.ts"; |
| 26 | 27 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 27 | 28 | import { quietLogs } from "./helpers/globals.ts"; |
| @@ -149,6 +150,10 @@ const PROJECTS = [ | ||
| 149 | 150 | { id: "QTid0001", slug: "bad,slug", title: "Comma" }, |
| 150 | 151 | { id: "FNid0001", slug: "farfile", title: "FarFile" }, |
| 151 | 152 | { id: "LIid0001", slug: "lithium", title: "Lithium" }, |
| 153 | { id: "UGid0001", slug: "universal-graves", title: "Universal Graves" }, | |
| 154 | { id: "ECid0001", slug: "essential-commands", title: "Essential Commands" }, | |
| 155 | { id: "SCid0001", slug: "styled-chat", title: "Styled Chat" }, | |
| 156 | { id: "RHid0001", slug: "rightclickharvest", title: "Right Click Harvest" }, | |
| 152 | 157 | { id: "SLid0001", slug: "scalablelux", title: "ScalableLux" }, |
| 153 | 158 | { id: "NOid0001", slug: "noisium", title: "Noisium" }, |
| 154 | 159 | { id: "FPid0001", slug: "fabric-api", title: "Fabric API" }, |
| @@ -200,6 +205,11 @@ const VERSIONS: V[] = [ | ||
| 200 | 205 | { id: "QTv00001", project: "QTid0001", number: "1.0", date: "2024-12-07", games: ["1.21.4"], loaders: PAPER, hash: "d" }, |
| 201 | 206 | { id: "FNv00001", project: "FNid0001", number: "1.0", date: "2024-12-08", games: ["1.21.4"], loaders: PAPER, hash: "e", filename: "../x.jar" }, |
| 202 | 207 | { id: "VPv00001", project: "VPid0001", number: "3.1", date: "2024-12-06", games: ["1.21.4", "1.21.3"], loaders: ["velocity"], hash: "c" }, |
| 208 | { id: "UGv00001", project: "UGid0001", number: "3.9.0", date: "2025-02-01", games: ["1.21.4"], loaders: FABRIC, hash: "2a", deps: [{ project_id: "FPid0001", version_id: null, dependency_type: "required" }] }, | |
| 209 | { id: "ECv00001", project: "ECid0001", number: "0.5.0", date: "2025-02-02", games: ["1.21.4"], loaders: FABRIC, hash: "2b", deps: [{ project_id: "FPid0001", version_id: null, dependency_type: "required" }] }, | |
| 210 | { id: "SCv00001", project: "SCid0001", number: "2.8.0", date: "2025-02-03", games: ["1.21.4"], loaders: FABRIC, hash: "2c" }, | |
| 211 | // Built for a newer game version only. | |
| 212 | { id: "RHv00001", project: "RHid0001", number: "4.5", date: "2025-02-04", games: ["1.21.8"], loaders: FABRIC, hash: "2d" }, | |
| 203 | 213 | { id: "LIv00001", project: "LIid0001", number: "0.17.0", date: "2025-01-01", games: ["1.21.4"], loaders: FABRIC, hash: "1a" }, |
| 204 | 214 | { id: "SLv00001", project: "SLid0001", number: "0.1.5", date: "2025-01-02", games: ["1.21.4"], loaders: FABRIC, hash: "1b" }, |
| 205 | 215 | { id: "NOv00001", project: "NOid0001", number: "2.0", date: "2025-01-03", games: ["1.21.4"], loaders: FABRIC, hash: "1c" }, |
| @@ -757,8 +767,8 @@ describe("the survival performance set", () => { | ||
| 757 | 767 | |
| 758 | 768 | test("the page offers it, previews it, and one commit locks all five", async () => { |
| 759 | 769 | const offered = await (await asAlice("/games/net/smp")).text(); |
| 760 | expect(offered).toContain("Preview the set"); | |
| 761 | expect(offered).toContain("Preview the set"); | |
| 770 | expect(offered).toContain("Preview the Survival performance set"); | |
| 771 | expect(offered).toContain("Preview the Survival performance set"); | |
| 762 | 772 | const preview = await (await asAlice("/games/net/smp?add=set:survival")).text(); |
| 763 | 773 | expect(preview).toContain("Adds Noisium 2.0"); |
| 764 | 774 | expect(preview).toContain("Install and restart"); |
| @@ -771,7 +781,7 @@ describe("the survival performance set", () => { | ||
| 771 | 781 | expect(lock.projects.map((p) => p.slug).sort()).toEqual(SLUGS); |
| 772 | 782 | expect(lock.projects.every((p) => p.sha512.length === 128)).toBe(true); |
| 773 | 783 | // Installed: no longer offered, and planning it again says so. |
| 774 | expect(await (await asAlice("/games/net/smp")).text()).not.toContain("Preview the set"); | |
| 784 | expect(await (await asAlice("/games/net/smp")).text()).not.toContain("Preview the Survival performance set"); | |
| 775 | 785 | expect(await planInstall(app, await mods("smp"), "smp", "set:survival")).toMatchObject({ ok: false, error: expect.stringContaining("is installed") }); |
| 776 | 786 | }); |
| 777 | 787 | |
| @@ -808,6 +818,95 @@ describe("the survival performance set", () => { | ||
| 808 | 818 | }); |
| 809 | 819 | }); |
| 810 | 820 | |
| 821 | describe("the quality-of-life set (#18089)", () => { | |
| 822 | test("a plan locks what builds for the server and says what it left out and why", async () => { | |
| 823 | const m = await mods("smp"); | |
| 824 | const planned = await planInstall(app, m, "smp", "set:quality"); | |
| 825 | if (!planned.ok) throw new Error(planned.error); | |
| 826 | const slugs = planned.value.lock.map((l) => l.slug); | |
| 827 | expect(slugs).toEqual(expect.arrayContaining(["essential-commands", "styled-chat", "universal-graves"])); | |
| 828 | expect(slugs).not.toContain("rightclickharvest"); | |
| 829 | expect(planned.value.lines).toEqual(expect.arrayContaining(["Adds Universal Graves 3.9.0", "Left out rightclickharvest: Right Click Harvest has no version for Fabric 1.21.4."])); | |
| 830 | expect(planned.value.message).not.toContain("rightclickharvest"); | |
| 831 | expect((await mods("smp")).lock.some((l) => l.slug === "styled-chat")).toBe(false); | |
| 832 | }); | |
| 833 | ||
| 834 | test("Essential Commands' plan says to trim it before players join, on the page's preview and the terminal's", async () => { | |
| 835 | const planned = await planInstall(app, await mods("smp"), "smp", "set:quality"); | |
| 836 | if (!planned.ok) throw new Error(planned.error); | |
| 837 | expect(planned.value.lines).toEqual(expect.arrayContaining([expect.stringContaining("Before players join: Essential Commands installs with every command on")])); | |
| 838 | const page = await (await asAlice("/games/net/smp?add=set:quality")).text(); | |
| 839 | expect(page).toContain("trim its config to /home, /spawn and /tpa"); | |
| 840 | }); | |
| 841 | ||
| 842 | test("two members that need Fabric API share one copy of it", async () => { | |
| 843 | // The survival set above locked Fabric API already: plan on a lock without it. | |
| 844 | const planned = await planInstall(app, { ...(await mods("smp")), lock: [] }, "smp", "set:quality"); | |
| 845 | if (!planned.ok) throw new Error(planned.error); | |
| 846 | expect(planned.value.lock.filter((l) => l.slug === "fabric-api")).toHaveLength(1); | |
| 847 | expect(planned.value.lines.filter((l) => l.startsWith("Adds Fabric API"))).toHaveLength(1); | |
| 848 | expect(planned.value.message).toContain("and 1 dependency"); | |
| 849 | }); | |
| 850 | ||
| 851 | test("a member already installed is kept and not planned again", async () => { | |
| 852 | const first = await planInstall(app, await mods("smp"), "smp", "styled-chat"); | |
| 853 | if (!first.ok) throw new Error(first.error); | |
| 854 | const done = await commitPlan(app, alice, box, "smp", await mods("smp"), first.value); | |
| 855 | if (!done.ok) throw new Error(done.error); | |
| 856 | const planned = await planInstall(app, await mods("smp"), "smp", "set:quality"); | |
| 857 | if (!planned.ok) throw new Error(planned.error); | |
| 858 | expect(planned.value.lines.some((l) => l.includes("Styled Chat"))).toBe(false); | |
| 859 | expect(planned.value.message).not.toContain("styled-chat"); | |
| 860 | expect(planned.value.lock.map((l) => l.slug)).toEqual(expect.arrayContaining(["styled-chat", "universal-graves", "essential-commands"])); | |
| 861 | const removed = await planRemove(await mods("smp"), "smp", "styled-chat"); | |
| 862 | if (!removed.ok) throw new Error(removed.error); | |
| 863 | const undone = await commitPlan(app, alice, box, "smp", await mods("smp"), removed.value); | |
| 864 | if (!undone.ok) throw new Error(undone.error); | |
| 865 | }); | |
| 866 | ||
| 867 | test("when no member builds for the server the set is refused, with each reason", async () => { | |
| 868 | const m = await mods("smp"); | |
| 869 | const old = { ...m, lock: [], target: { ...m.target, gameVersion: "1.19.2", label: "Fabric 1.19.2" } }; | |
| 870 | const planned = await planInstall(app, old, "smp", "set:quality"); | |
| 871 | expect(planned.ok).toBe(false); | |
| 872 | const said = planned.ok ? "" : String(planned.error); | |
| 873 | expect(said).toContain("None of the quality of life set runs on Fabric 1.19.2"); | |
| 874 | for (const slug of QUALITY.slugs) expect(said).toContain(`${slug}:`); | |
| 875 | }); | |
| 876 | ||
| 877 | test("each set has its own key, not one of the screen's, and the page labels every set alike", async () => { | |
| 878 | expect(new Set(SETS.map((s) => s.key)).size).toBe(SETS.length); | |
| 879 | expect(new Set(SETS.map((s) => s.name)).size).toBe(SETS.length); | |
| 880 | const terminal = headlessTerminal(160, 40); | |
| 881 | const { app: tui, session } = createForgeApp(app, { sshUsername: "alice", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user: alice }, { terminal, exitHooks: false }); | |
| 882 | const screen = gameModsScreen(session, tui.ctx, box, "smp"); | |
| 883 | const owners = screen.keys.flatMap((b) => b.keys); | |
| 884 | for (const set of SETS) expect(owners.filter((k) => k === set.key)).toHaveLength(1); | |
| 885 | expect(QUALITY.cautions).toBeDefined(); | |
| 886 | const page = await (await asAlice("/games/net/smp")).text(); | |
| 887 | expect(page).toContain(`Preview the ${QUALITY.title} set`); | |
| 888 | expect(page).not.toContain("Preview the set"); | |
| 889 | }); | |
| 890 | ||
| 891 | test("a Paper server is refused, and the page and terminal offer it beside the survival set", async () => { | |
| 892 | expect(await planInstall(app, await mods("hub"), "hub", "set:quality")).toMatchObject({ ok: false, error: expect.stringContaining("Fabric servers") }); | |
| 893 | expect(await planInstall(app, await mods("smp"), "smp", "set:nothing")).toMatchObject({ ok: false, error: expect.stringContaining("set:survival, set:quality") }); | |
| 894 | const page = await (await asAlice("/games/net/smp")).text(); | |
| 895 | expect(page).toContain("Preview the Quality of life set"); | |
| 896 | const terminal = headlessTerminal(160, 40); | |
| 897 | const { app: tui, session } = createForgeApp(app, { sshUsername: "alice", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user: alice }, { terminal, exitHooks: false }); | |
| 898 | tui.start(); | |
| 899 | tui.ctx.push(gameModsScreen(session, tui.ctx, box, "smp")); | |
| 900 | await settleUntil(tui, "Quality of life set"); | |
| 901 | terminal.feed("q"); | |
| 902 | await settleUntil(tui, "Left out rightclickharvest"); | |
| 903 | terminal.feed("y"); | |
| 904 | await settleUntil(tui, "is installed"); | |
| 905 | expect((await mods("smp")).lock.map((l) => l.slug)).toEqual(expect.arrayContaining(["essential-commands", "styled-chat", "universal-graves"])); | |
| 906 | tui.stop?.(); | |
| 907 | }); | |
| 908 | }); | |
| 909 | ||
| 811 | 910 | describe("room on the box (#18025)", () => { |
| 812 | 911 | // The hub sets no MEMORY: its heap is 1 GiB, so a stopped one needs 1536 MiB free. |
| 813 | 912 | const said = (free: number, ago = 60_000): GameBox => ({ ...box, seenAt: new Date(Date.now() - ago).toISOString(), host: { memMiB: 8000, memUsedMiB: 8000 - free } }); |
new above
offline