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

An app's /__forge/ door offers "Make it yours" and links its "more pulls" line to the repository's open pulls #6666

Merged opened this

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

Merged

scout/forge:scout/6652-an-app-s-forge-door-offers-make-it-yours → main 5 commits fork 1 thread · 1 unresolved

  • Merged. scout/6652-an-app-s-forge-door-offers-make-it-yours was merged into main as e9149d5.

Review

Sign in to review this change.
3 files changed +51 −9
docs/APPS.md +3 −2
@@ -210,8 +210,9 @@ nothing when the crew is idle.
210210 **When the pill is not shown** (an app whose own policy refuses foreign
211211 scripts), `/__forge/` on the app's host is the way back: a small page from the
212212 forge, never the app, with no script, saying the app and where you are
213 (`production` or `preview of pull #N`) and linking Home, the repository (to
214 who may read it) and *Tell the crew* (the same link `/__forge/crew` gives; signed
213 (`production` or `preview of pull #N`) and linking Home, the repository and *Make it yours*
214 (`<repo>/make-it-yours`; both only to who may read the repository, who also
215 get the "more pulls" line linked to `<repo>/pulls`) and *Tell the crew* (the same link `/__forge/crew` gives; signed
215216 out it offers sign in). It also says what is serving, read from the deploy
216217 record (no git): production shows the newest release and the three before it
217218 (a redeploy of the same commit is not another release), a preview shows its
src/apps/door.ts +16 −7
@@ -92,22 +92,31 @@ function servingHtml(facts: DoorFacts): string {
9292 return `<p>Serving ${sha(now)} since ${stamp(now.at)}</p>${older === "" ? "" : `<h2>Before it</h2><ul>${older}</ul>`}`;
9393 }
9494
95 function pullsHtml(pulls: DoorPullLine[] | undefined): string {
95 function pullsHtml(pulls: DoorPullLine[] | undefined, morePulls: string | undefined): string {
9696 if (pulls === undefined || pulls.length === 0) return "";
9797 const items = pulls.slice(0, DOOR_PULL_LIMIT).map((p) =>
9898 link(p.href, `#${p.number} ${[...p.title].slice(0, 120).join("")} · check ${p.check}`),
9999 );
100 const more = pulls.length > DOOR_PULL_LIMIT ? "<p>More pulls are open on the forge.</p>" : "";
100 const words = "More pulls are open on the forge.";
101 const more =
102 pulls.length <= DOOR_PULL_LIMIT
103 ? ""
104 : morePulls === undefined

The nested ternary is hard to read. An early return for <= DOOR_PULL_LIMIT, then a one-line choice between the link and plain text, would be clearer. Not blocking.

105 ? `<p>${words}</p>`
106 : `<p><a href="${escapeAttr(morePulls)}">${words}</a></p>`;
101107 return `<h2>Open pulls</h2><ul>${items.join("")}</ul>${more}`;
102108 }
103109
104110 export function doorPage(facts: DoorFacts, head: boolean): Response {
105111 const { where, forgeUrl } = facts;
106112 const links = [link(forgeUrl, "Home")];
107 if (where.repo !== undefined)
108 links.push(
109 link(new URL(`/${where.repo}`, forgeUrl).href, `The repository, ${where.repo}`),
110 );
113 let morePulls: string | undefined;
114 if (where.repo !== undefined) {
115 const repoUrl = new URL(`/${where.repo}`, forgeUrl).href;
116 links.push(link(repoUrl, `The repository, ${where.repo}`));
117 links.push(link(`${repoUrl}/make-it-yours`, "Make it yours"));
118 morePulls = `${repoUrl}/pulls`;
119 }
111120 if (facts.tell !== undefined) links.push(link(facts.tell, "Tell the crew"));
112121 else if (facts.signin !== undefined)
113122 links.push(link(facts.signin, "Sign in to tell the crew"));
@@ -119,7 +128,7 @@ export function doorPage(facts: DoorFacts, head: boolean): Response {
119128 : `<p>Terminal:</p><pre><code>${escapeAttr(facts.ssh)}</code></pre>`;
120129 const html = `<!doctype html>
121130 <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>${escapeAttr(where.app)}, ${escapeAttr(doorWhere(where))}</title><style>${STYLE}</style></head>
122 <body><main><h1>${escapeAttr(where.app)}</h1><p>${whereLine(where, forgeUrl)}</p>${servingHtml(facts)}${pullsHtml(facts.pulls)}<ul>${links.join("")}</ul>${terminal}</main></body></html>
131 <body><main><h1>${escapeAttr(where.app)}</h1><p>${whereLine(where, forgeUrl)}</p>${servingHtml(facts)}${pullsHtml(facts.pulls, morePulls)}<ul>${links.join("")}</ul>${terminal}</main></body></html>
123132 `;
124133 return new Response(head ? null : html, {
125134 headers: {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs