GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(install): find channel releases beyond the first page · pingdotgg/t3code@b5a425f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • scripts
    • install.ps1
    • install.sh
    • install.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎scripts/install.ps1‎

Copy file name to clipboardExpand all lines: scripts/install.ps1
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,13 @@ if (-not $version) {
139139
"preview" { '^v\d+\.\d+\.\d+-preview\.\d+\.\d+$' }
140140
default { Fail "T3CODE_CHANNEL must be stable, nightly, or preview" }
141141
}
142-
$releases = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases?per_page=100" -Headers @{ "User-Agent" = "t3-install" }
143-
$tag = ($releases | Where-Object { -not $_.draft -and $_.tag_name -match $tagPattern } | Select-Object -First 1).tag_name
142+
# Match t3 update's ten-page limit so a long run of nightlies cannot hide a channel.
143+
$tag = $null
144+
for ($page = 1; $page -le 10; $page++) {
145+
$releases = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases?per_page=100&page=$page" -Headers @{ "User-Agent" = "t3-install" }
146+
$tag = ($releases | Where-Object { -not $_.draft -and $_.tag_name -match $tagPattern } | Select-Object -First 1).tag_name
147+
if ($tag -or $releases.Count -eq 0) { break }
148+
}
144149
if (-not $tag) { Fail "could not find a $channel release; set T3CODE_VERSION" }
145150
$version = $tag.Substring(1)
146151
}
Collapse file

‎scripts/install.sh‎

Copy file name to clipboardExpand all lines: scripts/install.sh
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,15 @@ if [ -z "$version" ]; then
154154
*) fail "T3CODE_CHANNEL must be stable, nightly, or preview" ;;
155155
esac
156156
tmp_index="$(mktemp)"
157-
fetch "https://api.github.com/repos/${repo}/releases?per_page=100" "$tmp_index"
158-
version="$(sed -n "s/.*\"tag_name\": *\"${tag_pattern}\".*/\1/p" "$tmp_index" | head -n 1)"
157+
# Match t3 update's ten-page limit so a long run of nightlies cannot hide a channel.
158+
page=1
159+
while [ "$page" -le 10 ]; do
160+
fetch "https://api.github.com/repos/${repo}/releases?per_page=100&page=${page}" "$tmp_index"
161+
version="$(sed -n "s/.*\"tag_name\": *\"${tag_pattern}\".*/\1/p" "$tmp_index" | head -n 1)"
162+
[ -n "$version" ] && break
163+
grep -q '"tag_name"' "$tmp_index" || break
164+
page=$((page + 1))
165+
done
159166
rm -f "$tmp_index"
160167
[ -n "$version" ] || fail "could not find a ${channel} release; set T3CODE_VERSION"
161168
fi
Collapse file

‎scripts/install.test.ts‎

Copy file name to clipboardExpand all lines: scripts/install.test.ts
+84Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,90 @@ import * as NodePath from "node:path";
99
import { describe, expect, it } from "vite-plus/test";
1010

1111
describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("installer terminal", () => {
12+
it.each([
13+
{ channel: "stable", matchPage: 1, endPage: 1 },
14+
{ channel: "stable", matchPage: 2, endPage: 2 },
15+
{ channel: "nightly", matchPage: 2, endPage: 2 },
16+
{ channel: "preview", matchPage: 2, endPage: 2 },
17+
{ channel: "stable", matchPage: 0, endPage: 2 },
18+
{ channel: "stable", matchPage: 0, endPage: 10 },
19+
])(
20+
"resolves $channel releases (match page: $matchPage, last page: $endPage)",
21+
async ({ channel, matchPage, endPage }) => {
22+
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-install-index-"));
23+
const version = `1.2.3${channel === "stable" ? "" : `-${channel}.20261020.1`}`;
24+
const target = NodePath.join(root, "home/runtime/versions", version);
25+
const pages: number[] = [];
26+
const server = NodeHttp.createServer((request, response) => {
27+
const url = new URL(request.url ?? "/", "http://localhost");
28+
const page = Number(url.searchParams.get("page") ?? "1");
29+
pages.push(page);
30+
const releases =
31+
page === matchPage
32+
? [{ tag_name: `v${version}` }]
33+
: page === endPage && endPage < 10
34+
? []
35+
: Array.from({ length: 100 }, (_, index) => ({
36+
tag_name: `v1.2.4-${channel === "nightly" ? "preview" : "nightly"}.20261020.${100 - index}`,
37+
}));
38+
response.setHeader("Content-Type", "application/json");
39+
response.end(JSON.stringify(releases, null, 2));
40+
});
41+
try {
42+
// An existing completed install isolates release resolution from archive downloads.
43+
await NodeFSP.mkdir(target, { recursive: true });
44+
await NodeFSP.writeFile(NodePath.join(target, ".install-complete"), `${version}\n`);
45+
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
46+
const address = server.address();
47+
if (!address || typeof address === "string") throw new Error("Expected a TCP listener");
48+
const source = await NodeFSP.readFile(
49+
NodePath.resolve(import.meta.dirname, "install.sh"),
50+
"utf8",
51+
);
52+
const installer = NodePath.join(root, "install.sh");
53+
// Redirect only the API host; keep the installer's real channel lookup intact.
54+
await NodeFSP.writeFile(
55+
installer,
56+
source.replace("https://api.github.com", `http://127.0.0.1:${address.port}`),
57+
);
58+
const { code, output } = await new Promise<{ code: number | null; output: string }>(
59+
(resolve, reject) => {
60+
const child = NodeChildProcess.spawn("sh", [installer], {
61+
env: {
62+
...process.env,
63+
T3CODE_VERSION: "",
64+
T3CODE_CHANNEL: channel,
65+
T3CODE_HOME: NodePath.join(root, "home"),
66+
T3CODE_INSTALL_BIN_DIR: NodePath.join(root, "bin"),
67+
},
68+
stdio: ["ignore", "pipe", "pipe"],
69+
});
70+
let output = "";
71+
child.stdout.on("data", (chunk: Buffer) => (output += chunk.toString()));
72+
child.stderr.on("data", (chunk: Buffer) => (output += chunk.toString()));
73+
child.on("error", reject);
74+
child.on("close", (code) => resolve({ code, output }));
75+
},
76+
);
77+
expect(pages).toEqual(Array.from({ length: endPage }, (_, index) => index + 1));
78+
if (matchPage) {
79+
expect(code, output).toBe(0);
80+
expect(output).toContain(`Installed T3 Code ${version}`);
81+
expect(await NodeFSP.readlink(NodePath.join(root, "bin/t3"))).toBe(
82+
NodePath.join(target, "t3"),
83+
);
84+
} else {
85+
expect(code).not.toBe(0);
86+
expect(output).toContain(`could not find a ${channel} release; set T3CODE_VERSION`);
87+
}
88+
} finally {
89+
server.closeAllConnections();
90+
await new Promise<void>((resolve) => server.close(() => resolve()));
91+
await NodeFSP.rm(root, { recursive: true, force: true });
92+
}
93+
},
94+
);
95+
1296
it.each([false, true])(
1397
"preserves download and install behavior (HTTP failure: %s)",
1498
async (fail) => {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.