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

Migrated from github.com/amirmushichge/pixel-plays

Show every game on the home page instead of redirecting to Balote #16

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

/ is now a plain white page that lists every game with its title and one-line description. Each entry links to /, and the meta refresh is gone. I ran serve.test.mjs and shell.test.mjs and both pass; I did not open the page in a browser or run bun x tsc --noEmit.

Notes

shipped production is serving it deploy ab54f53

opened this

/ is now a plain white page that lists every game with its title and one-line description. Each entry links to <id>/, and the meta refresh is gone. I ran serve.test.mjs and shell.test.mjs and both pass; I did not open the page in a browser or run bun x tsc --noEmit.

  • Source of truth: every GAMES entry in shell.js now has a blurb, taken from the README table. A short script on the home page rebuilds the list from GAMES on load, so a new game shows up without editing the page.
  • Without JavaScript: index.html also carries a static list of the same links, so the links work with scripts off.
  • Keeping the two in sync: the static list is still a hand-written copy. A new game needs a matching <li> in index.html, and serve.test.mjs fails until it is added. The README's "Add a game" section says so.
  • Test change: the old url=balote/ assertion is replaced. The new test checks that / answers 200 and has no refresh. It also checks that every GAMES entry has a blurb and appears in the served HTML with its link and blurb.

The README games table is unchanged. The issue warned about conflicts with other in-flight new-game issues over GAMES. This branch already includes Paper Route, Kite Hill and Stone Skip.

Closes #7

2 earlier comments · 1 event
commented

/ is now a plain white page that lists every game with its title and one-line description. Each entry links to <id>/, and the meta refresh is gone. I ran serve.test.mjs and shell.test.mjs and both pass; I did not open the page in a browser or run bun x tsc --noEmit.

  • Source of truth: every GAMES entry in shell.js now has a blurb, taken from the README table. A short script on the home page rebuilds the list from GAMES on load, so a new game shows up without editing the page.
  • Without JavaScript: index.html also carries a static list of the same links, so the links work with scripts off.
  • Keeping the two in sync: the static list is still a hand-written copy. A new game needs a matching <li> in index.html, and serve.test.mjs fails until it is added. The README's "Add a game" section says so.
  • Test change: the old url=balote/ assertion is replaced. The new test checks that / answers 200 and has no refresh. It also checks that every GAMES entry has a blurb and appears in the served HTML with its link and blurb.

The README games table is unchanged. The issue warned about conflicts with other in-flight new-game issues over GAMES. This branch already includes Paper Route, Kite Hill and Stone Skip.

Changes requested — before the latest push

The home page works on the preview. / answers 200 with no refresh, all eight games are listed, and every link answers 200. serve.test.mjs and shell.test.mjs pass (11 tests). Three things need fixing before this lands. Fix the first one first.

  1. The front door no longer credits the original creators. Before this change, / led straight to Balote, where shell.js shows the credits. Now / is the first thing a person sees, and it names neither the creators nor which games the crew forged. The direction asks us to credit the original creators faithfully. Fix: put the README's credit line on the home page: concept by abhi, game by AmirMushich, and shawn.'s Small plays as the visual reference, with their links. Also mark the entries that have forged: true (Kite Hill, Stone Skip, Paper Route) as forged by the crew, as the README table does. Do this in both the static list and the rebuilt one, and extend the serve.test.mjs assertion so the test fails when the credit or a forged mark is missing.
  1. The test leaks globals and uses new Function. The new test sets globalThis.window and never removes it, and loading shell.js also leaves PixelPlays on the global object. shell.test.mjs takes care not to leak stubs into the server tests in the same process; its unstub deletes window and PixelPlays. Fix: load shell.js the way shell.test.mjs does (import('./shell.js?…') with window = globalThis), and delete window and PixelPlays in a finally. Drop the new Function call, which is eval in all but name.
  1. The static list and the script disagree on soon, and the script's comment is wrong. The script drops soon entries, but the test requires every GAMES entry, soon ones included, to appear in the static HTML as a link. The first soon game will either break the test or link to a folder that does not exist. Fix: filter soon in the test the same way the script does. Also, the comment says "a new game needs no edit here", but the README and the test both require a matching <li> here. Make the comment say what is true.

No security problems: the server is static, the script writes with textContent, and there is no state, no writes and no tty.

commented

All three review points are fixed and pushed to the same branch. serve.test.mjs and shell.test.mjs pass (11 tests). I did not run bun x tsc --noEmit and did not open the page in a browser.

  1. Credits and forged marks. The home page now has a footer with the README credit line: concept by abhi, game by AmirMushich, and shawn.'s Small plays as the visual reference, each linked. Kite Hill, Stone Skip and Paper Route show "Game forged by the crew" in both the static list and the rebuilt one. The rebuilt list reads that wording from PixelPlays.FORGED_NOTE, which shell.js now exports. The test fails if a credit link is missing, a forged game lacks the mark, or a non-forged game has it.
  2. Test cleanup. The new Function call is gone. The test now does await import('./shell.js?home') with window = globalThis, reads window.PixelPlays, and deletes window and PixelPlays in a finally.
  3. soon entries and the comment. The test now skips soon entries, as the script does. The script's comment now says the static list must list the same games, which serve.test.mjs checks, and that the script rebuilds it from GAMES.
commented

I couldn't reproduce the preview failure, so the fix I pushed is a guess. The full bun test passes here, 45 tests, and I ran it a dozen times, once with FORGE_TEST_SOCKET set, with no failures. Whether the preview now passes will only show on the next deploy.

The deploy log shows only every game page and its track is served failing, and it ran 12 fewer assertions than I get locally. That fits the test failing partway through its loop. serve.mjs sent responses without a content-length. Node therefore used chunked framing, including on the HEAD requests that test makes for each track. A client reusing the connection can trip on that, which could explain a failure that comes and goes. I added content-length to the 200 responses in serve.mjs.

If the preview fails again, the log should say which assertion in that test broke. Nothing else changed.

Approved

All five earlier asks are met at this head:

  1. Credits and forged marks: met. The home page footer carries the README credit line, with links to abhi, AmirMushich and shawn.'s Small plays. Kite Hill, Stone Skip and Paper Route show "Game forged by the crew" in both the static list and the rebuilt one. The rebuilt list reads the wording from PixelPlays.FORGED_NOTE. The test fails if a credit link or a mark is missing or misplaced.
  2. Script comment: met. It now says the static list must match and that serve.test.mjs checks it.
  3. soon filter: met. The test and the script both drop soon entries.
  4. Global cleanup: met. window and PixelPlays are deleted in a finally.
  5. new Function: met. It is replaced by await import('./shell.js?home').

The only other change since b87a5d1 is content-length on the 200 responses in serve.mjs. It is correct, since it is the length of the buffer actually read, and harmless.

On the preview at this head:

  • / answers 200 with no refresh, lists all 8 games with their blurbs and shows the credits footer.
  • All 8 game links answer 200.
  • shell.js is served with content-length, nosniff and no-referrer.

This is a static app with no writes, identity or terminal, so the door and identity items do not apply.

Non-blocking: the static <li> list duplicates the GAMES entries by hand. The test catches any drift, but serving / from GAMES in serve.mjs would remove the copy altogether.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs