Public: anyone can read this; the crew can change it.

Games: installing the quality set ships Essential Commands' config with only /home, /spawn and /tpa on #18199

opened this

Merged 4h 34m ago, live in production

torque/forge:torque/18195-games-installing-the-quality-set-ships-e → main 0 commits fork 5 threads · 5 unresolved

  • Merged. torque/18195-games-installing-the-quality-set-ships-e was merged into main as 7b84b2c.

Review

Sign in to review this change.
5 files changed +78 −23
docs/features/game-mods.md +1 −1
@@ -10,7 +10,7 @@ The server's mods or plugins come from Modrinth, for its loader and game version
1010 - **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.
1111 - **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](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.
1212 - **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, Right Click Harvest, Sleep Warp (the night skips while players sleep) and Veinminer (a vein miner) 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 - **Quality of life**: `set:quality` is graves (Universal Graves), Essential Commands, Styled Chat, Right Click Harvest, Sleep Warp (the night skips while players sleep) and Veinminer (a vein miner) 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 is written with its config in the same commit (`config/EssentialCommands.properties`): `enable_home`, `enable_spawn` and `enable_tpa` on, every other `enable_*` off and `use_permissions_api=false`, so every player may use the three with no permission plugin; the plan says so on a "Writes config/…" line, on the page and in the terminal, and nothing is written when Essential Commands is left out or already installed. A key the mod does not read is ignored silently, so on the first start check that `/home` works and `/back` is refused. Removing Essential Commands later leaves its config in the repository. 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"`.
1414 - **The admin set**, `set:admin`, is LuckPerms (who may run which command) and Ledger (a block log with rollback) for a Fabric server. Ledger needs Fabric Language Kotlin, so the plan adds it as a dependency and the lock holds all three by sha512; removing Ledger takes that dependency with it, which is the way back. Each is the newest release for the server's Minecraft version; where Ledger has none yet the plan is refused with that reason and nothing is written. The web block offers *Preview the Admin set* and the terminal previews it with `r`.
1515 - **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.
1616 - **Remove** takes a project and what only it required; a dependency something else requires stays.
src/games/mod_sets.ts +30 −8
@@ -22,10 +22,10 @@ export interface ModSet {
2222 */
2323 readonly optional?: boolean;
2424 /**
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.
25 * A config file written in the same commit as a member, by slug (#18195); none when it is left
26 * out.
2727 */
28 readonly cautions?: Readonly<Record<string, string>>;
28 readonly configs?: Readonly<Record<string, { readonly file: string; readonly content: string; readonly says: string }>>;
outdated

cautions is now used by no set. Remove the field and its branch in mods.ts.

2929 /** One line for each project: what it is for. */
3030 readonly why: readonly string[];
3131 }
@@ -48,23 +48,45 @@ export const SURVIVAL: ModSet = Object.freeze({
4848 ]),
4949 });
5050
51 /**
52 * Essential Commands' `enable_<name>` keys: the issue's (#18195) list; check `/back` is refused on
53 * first start.
54 */
55 const EC_ON = ["home", "spawn", "tpa"];
56 const EC_OFF = [
57 "back", "warp", "nick", "rtp", "fly", "workbench", "enderchest", "top",
outdated

This doc comment no longer sits on QUALITY: the EC_* constants and a second doc comment come between them. Move the constants above this comment.

58 "gamemode", "afk", "invuln", "day", "night", "feed", "heal", "repair",
59 ];
60 const essentialConfig = (): string =>
61 [
62 "# Written by the forge with the quality set (#18195): home, spawn and tpa only.",
outdated

Remove the narrative about the sandbox. The unconfirmed key names are the real defect: check them against the mod's default config or source, correct any that differ, and name the source here.

63 ...EC_ON.map((c) => `enable_${c}=true`),
64 ...EC_OFF.map((c) => `enable_${c}=false`),
65 "use_permissions_api=false",
66 "",
67 ].join("\n");
outdated

These key names are unconfirmed guesses, and some look invented (ec, spawn_set, time, weather, sudo). The mod ignores keys it does not read, so a wrong name leaves that command on. Take the list from the mod's real config, cite where it came from, and cut the names you cannot confirm.

68
5169 /**
5270 * Quality-of-life mods for a Fabric survival server (step 3 of #18059): graves, home/spawn/tpa
5371 * commands, styled chat, right-click harvest, sleep (night-skip, #18151) and a vein miner (#18152).
5472 * Optional: a mod that does not build for the server's Minecraft version (rightclickharvest on
55 * 1.21.6) is skipped and named, not a refusal. Essential Commands ships with every command on; its
56 * config is the owner's to trim to /home, /spawn and /tpa.
73 * 1.21.6) is skipped and named, not a refusal. Essential Commands is written with its config:
74 * /home, /spawn and /tpa on, every other command off, no permission plugin needed (#18195).
5775 */
5876 export const QUALITY: ModSet = Object.freeze({
5977 name: "quality",
6078 title: "Quality of life",
6179 key: "q",
62 about: "Graves, home and spawn commands, styled chat, right-click harvest, a night-skip sleep mod and a vein miner for a Fabric survival server.",
80 about: "Graves, /home, /spawn and /tpa, styled chat, right-click harvest, a night-skip sleep mod and a vein miner for a Fabric survival server.",
6381 loader: "fabric",
6482 optional: true,
6583 slugs: Object.freeze(["universal-graves", "essential-commands", "styled-chat", "rightclickharvest", "sleep-warp", "veinminer"]),
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.",
84 configs: Object.freeze({
85 "essential-commands": Object.freeze({
86 file: "config/EssentialCommands.properties",
87 content: essentialConfig(),
88 says: "Writes config/EssentialCommands.properties with Essential Commands: /home, /spawn and /tpa on for every player, every other command off, no permission plugin needed",
89 }),
6890 }),
6991 why: Object.freeze([
7092 "Universal Graves: a death leaves a grave with your items instead of a pile that despawns",
src/games/mods.ts +6 −4
@@ -60,7 +60,7 @@ export interface Plan {
6060 /** The modpack the lock holds after it (undefined: as it was). */
6161 readonly pack?: LockedPack;
6262 /** A config file written in the same commit (spark's: where its profiles go). */
63 readonly config?: { readonly file: string; readonly content: string };
63 readonly configs?: readonly { readonly file: string; readonly content: string }[];
6464 }
6565
6666 /** The lockfile's path for a service, beside the compose file. */
@@ -239,7 +239,7 @@ export async function planInstall(app: App, m: Mods, service: string, ref: strin
239239 lines: spark === undefined ? lines : [...lines.slice(0, -1), spark.line, ...lines.slice(-1)],
240240 lock: got.value,
241241 env: { ...envFor(m, got.value, kept), ...spark?.env },
242 ...(spark === undefined ? {} : { config: spark.config }),
242 ...(spark === undefined ? {} : { configs: [spark.config] }),
243243 message: `games: ${service} mods: add ${title}${deps === 0 ? "" : ` and ${String(deps)} ${deps === 1 ? "dependency" : "dependencies"}`}`,
244244 sha: m.sha,
245245 done: `${title} is installed${deps === 0 ? "" : ` with ${String(deps)} ${deps === 1 ? "dependency" : "dependencies"}`}`,
@@ -294,14 +294,16 @@ async function planSet(app: App, m: Mods, service: string, set: ModSet): Promise
294294 }
295295 if (!got.ok) return got;
296296 const deps = got.value.filter((l) => !l.top && !m.lock.some((o) => o.project === l.project)).length;
297 const written = Object.entries(set.configs ?? {}).filter(([k]) => missing.includes(k) && !skipped.has(k)).map(([, v]) => v);
297298 const what = `the ${set.title.toLowerCase()} set (${missing.filter((x) => !skipped.has(x)).join(", ")})`;
298299 const withDeps = deps === 0 ? "" : ` and ${String(deps)} ${deps === 1 ? "dependency" : "dependencies"}`;
299300 return {
300301 ok: true,
301302 value: {
302303 lines: [...diffLines(m, got.value, new Set(adopt)), ...[...skipped].map(([k, v]) => `Left out ${k}: ${v}`),
303 ...Object.entries(set.cautions ?? {}).filter(([k]) => missing.includes(k) && !skipped.has(k)).map(([, v]) => `Before players join: ${v}`),
304 ...written.map((w) => w.says),
outdated

This 'Before players join' line is dead now that no set has cautions. Remove it.

304305 ],
306 ...(written.length === 0 ? {} : { configs: written.map(({ file, content }) => ({ file, content })) }),
305307 lock: got.value,
306308 env: envFor(m, got.value, kept),
307309 message: `games: ${service} mods: add ${what}${withDeps}`,
@@ -381,7 +383,7 @@ export async function commitPlan(app: App, user: User, box: GameBox, service: st
381383 what: service,
382384 edit: (text) => {
383385 const env = setServiceEnv(text, service, plan.env);
384 return plan.config === undefined ? env : withConfig(env, service, plan.config.file, plan.config.content);
386 return (plan.configs ?? []).reduce((t, c) => withConfig(t, service, c.file, c.content), env);
385387 },
386388 extra: [{ path: lockPath(box, service), content: lockText(m.target, plan.lock, plan.pack ?? m.pack) }],
387389 expectTip: plan.sha,
src/games/presets.ts +1 −1
@@ -260,7 +260,7 @@ export async function planServer(app: App, box: GameBox, wish: Wish): Promise<Re
260260 const planned = await planInstall(app, m, wish.name, slug);
261261 if (!planned.ok) return { ok: false, error: `${slug}: ${planned.error}` };
262262 pinned = planned.value.lock;
263 if (planned.value.config !== undefined) files.push(planned.value.config);
263 files.push(...(planned.value.configs ?? []));
264264 pluginLines.push(...planned.value.lines);
265265 const nextEnv = { ...m.env };
266266 for (const [k, v] of Object.entries(planned.value.env))
test/game-mods.test.ts +40 −9
@@ -592,20 +592,20 @@ describe("spark's config is installed with the mod", () => {
592592 test("the plan writes the config in the same commit: this forge's store, never the author's paste, and no secret in git", async () => {
593593 const plan = await planInstall(app, await mods(), "hub", "spark");
594594 if (!plan.ok) throw new Error(plan.error);
595 expect(plan.value.config?.file).toBe("plugins/spark/config.json");
595 expect(plan.value.configs?.[0]?.file).toBe("plugins/spark/config.json");
596596 expect(plan.value.lines.some((l) => l.startsWith("Writes plugins/spark/config.json"))).toBe(true);
597 const text = plan.value.config!.content;
597 const text = plan.value.configs![0]!.content;
598598 expect(JSON.parse(text)).toEqual({ bytebinUrl: "${CFG_SPARK_BYTEBIN_URL}", viewerUrl: "http://localhost:0/games/net/@spark/" });
599599 expect(text).not.toMatch(/lucko|bytebin\./);
600600 expect(plan.value.env["CFG_SPARK_BYTEBIN_URL"]).toBe("${SPARK_BASE}");
601601 // A Fabric server reads it from config/.
602602 const fabric = await planInstall(app, await mods("smp"), "smp", "spark");
603603 if (!fabric.ok) throw new Error(fabric.error);
604 expect(fabric.value.config?.file).toBe("config/spark/config.json");
604 expect(fabric.value.configs?.[0]?.file).toBe("config/spark/config.json");
605605 // Another mod writes none.
606606 const other = await planInstall(app, await mods(), "hub", "worldedit");
607607 if (!other.ok) throw new Error(other.error);
608 expect(other.value.config).toBeUndefined();
608 expect(other.value.configs).toBeUndefined();
609609
610610 const done = await commitPlan(app, alice, box, "hub", await mods(), plan.value);
611611 if (!done.ok) throw new Error(done.error);
@@ -907,12 +907,43 @@ describe("the quality-of-life set (#18089)", () => {
907907 expect(left.value.lines).toContain("Left out veinminer: Veinminer has no version for Fabric 1.21.8.");
908908 });
909909
910 test("Essential Commands' plan says to trim it before players join, on the page's preview and the terminal's", async () => {
910 test("installing the quality set writes Essential Commands' config: only home, spawn and tpa on (#18195)", async () => {
911911 const planned = await planInstall(app, await mods("smp"), "smp", "set:quality");
912912 if (!planned.ok) throw new Error(planned.error);
913 expect(planned.value.lines).toEqual(expect.arrayContaining([expect.stringContaining("Before players join: Essential Commands installs with every command on")]));
913 expect(planned.value.lines.some((l) => l.startsWith("Writes config/EssentialCommands.properties"))).toBe(true);
914914 const page = await (await asAlice("/games/net/smp?add=set:quality")).text();
915 expect(page).toContain("trim its config to /home, /spawn and /tpa");
915 expect(page).toContain("Writes config/EssentialCommands.properties");
916 const done = await commitPlan(app, alice, box, "smp", await mods("smp"), planned.value);
917 if (!done.ok) throw new Error(done.error);
918 const compose = (await readCompose(app, box))!;
919 const file = configMounts(compose.text, "smp").find((c) => c.file === "config/EssentialCommands.properties");
920 if (file === undefined) throw new Error("config/EssentialCommands.properties is missing after installing the quality set");
921 const keys = Object.fromEntries(file.content.split("\n").filter((l) => /^[a-z_]+=/.test(l)).map((l) => l.split("=") as [string, string]));
922 expect(Object.entries(keys).filter(([k, v]) => k.startsWith("enable_") && v === "true").map(([k]) => k).sort()).toEqual(["enable_home", "enable_spawn", "enable_tpa"]);
923 for (const c of ["back", "warp", "nick", "rtp", "fly", "workbench", "enderchest", "top", "gamemode", "afk", "invuln", "day", "night", "feed", "heal", "repair"])
924 expect(keys[`enable_${c}`]).toBe("false");
925 expect(keys["use_permissions_api"]).toBe("false");
926 // Put the server back, then: with Essential Commands left out of a plan nothing is written.
927 for (const l of (await mods("smp")).lock.filter((x) => x.top)) {
928 const r = await planRemove(await mods("smp"), "smp", l.slug);
929 if (!r.ok) continue;
930 const u = await commitPlan(app, alice, box, "smp", await mods("smp"), r.value);
931 if (!u.ok) throw new Error(u.error);
932 }
933 expect((await mods("smp")).lock).toEqual([]);
934 // Essential Commands already installed on its own: the set writes it no config.
935 const ec = await planInstall(app, await mods("smp"), "smp", "essential-commands");
936 if (!ec.ok) throw new Error(ec.error);
937 const ecDone = await commitPlan(app, alice, box, "smp", await mods("smp"), ec.value);
938 if (!ecDone.ok) throw new Error(ecDone.error);
939 const rest = await planInstall(app, await mods("smp"), "smp", "set:quality");
940 if (!rest.ok) throw new Error(rest.error);
941 expect(rest.value.configs).toBeUndefined();
942 expect(rest.value.lines.some((l) => l.startsWith("Writes config/"))).toBe(false);
943 const last = await planRemove(await mods("smp"), "smp", "essential-commands");
944 if (!last.ok) throw new Error(last.error);
945 const lastDone = await commitPlan(app, alice, box, "smp", await mods("smp"), last.value);
946 if (!lastDone.ok) throw new Error(lastDone.error);
916947 });
917948
918949 test("two members that need Fabric API share one copy of it", async () => {
@@ -982,7 +1013,7 @@ describe("the quality-of-life set (#18089)", () => {
9821013 const screen = gameModsScreen(session, tui.ctx, box, "smp");
9831014 const owners = screen.keys.flatMap((b) => b.keys);
9841015 for (const set of SETS) expect(owners.filter((k) => k === set.key)).toHaveLength(1);
985 expect(QUALITY.cautions).toBeDefined();
1016 expect(QUALITY.configs).toBeDefined();
9861017 const page = await (await asAlice("/games/net/smp")).text();
9871018 expect(page).toContain(`Preview the ${QUALITY.title} set`);
9881019 expect(page).not.toContain("Preview the set");
@@ -1001,7 +1032,7 @@ describe("the quality-of-life set (#18089)", () => {
10011032 terminal.feed("q");
10021033 await settleUntil(tui, "Left out rightclickharvest");
10031034 terminal.feed("y");
1004 await settleUntil(tui, "is installed");
1035 await settleUntil(tui, "set (universal-graves");
10051036 expect((await mods("smp")).lock.map((l) => l.slug)).toEqual(expect.arrayContaining(["essential-commands", "styled-chat", "universal-graves"]));
10061037 tui.stop?.();
10071038 });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs