Open History to see the last commit
1// @effect-diagnostics nodeBuiltinImport:off
2import { execFileSync } from "node:child_process";
3import {
4 cpSync,
5 existsSync,
6 mkdirSync,
7 mkdtempSync,
8 readFileSync,
9 rmSync,
10 writeFileSync,
11} from "node:fs";
12import { tmpdir } from "node:os";
13import { dirname, join, resolve } from "node:path";
14import { fileURLToPath } from "node:url";
15import * as Console from "effect/Console";
16import * as Effect from "effect/Effect";
17
18const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
19
20const workspaceFiles = [
21 "package.json",
22 "bun.lock",
23 "apps/server/package.json",
24 "apps/desktop/package.json",
25 "apps/web/package.json",
26 "apps/marketing/package.json",
27 "oxlint-plugin-t3code/package.json",
28 "packages/client-runtime/package.json",
29 "packages/contracts/package.json",
30 "packages/shared/package.json",
31 "packages/ssh/package.json",
32 "packages/tailscale/package.json",
33 "packages/effect-acp/package.json",
34 "packages/effect-codex-app-server/package.json",
35 "scripts/package.json",
36] as const;
37
38function copyWorkspaceManifestFixture(targetRoot: string): void {
39 for (const relativePath of workspaceFiles) {
40 const sourcePath = resolve(repoRoot, relativePath);
41 const destinationPath = resolve(targetRoot, relativePath);
42 mkdirSync(dirname(destinationPath), { recursive: true });
43 cpSync(sourcePath, destinationPath);
44 }
45
46 const packageJson = JSON.parse(readFileSync(resolve(repoRoot, "package.json"), "utf8")) as {
47 readonly patchedDependencies?: Record<string, string>;
48 };
49
50 for (const relativePath of Object.values(packageJson.patchedDependencies ?? {})) {
51 const sourcePath = resolve(repoRoot, relativePath);
52 const destinationPath = resolve(targetRoot, relativePath);
53 mkdirSync(dirname(destinationPath), { recursive: true });
54 cpSync(sourcePath, destinationPath);
55 }
56}
57
58function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
59 const assetDirectory = resolve(targetRoot, "release-assets");
60 mkdirSync(assetDirectory, { recursive: true });
61
62 const arm64Path = resolve(assetDirectory, "latest-mac.yml");
63 const x64Path = resolve(assetDirectory, "latest-mac-x64.yml");
64
65 writeFileSync(
66 arm64Path,
67 `version: 9.9.9-smoke.0
68files:
69 - url: T3-Code-9.9.9-smoke.0-arm64.zip
70 sha512: arm64zip
71 size: 125621344
72 - url: T3-Code-9.9.9-smoke.0-arm64.dmg
73 sha512: arm64dmg
74 size: 131754935
75path: T3-Code-9.9.9-smoke.0-arm64.zip
76sha512: arm64zip
77releaseDate: '2026-03-08T10:32:14.587Z'
78`,
79 );
80
81 writeFileSync(
82 x64Path,
83 `version: 9.9.9-smoke.0
84files:
85 - url: T3-Code-9.9.9-smoke.0-x64.zip
86 sha512: x64zip
87 size: 132000112
88 - url: T3-Code-9.9.9-smoke.0-x64.dmg
89 sha512: x64dmg
90 size: 138148807
91path: T3-Code-9.9.9-smoke.0-x64.zip
92sha512: x64zip
93releaseDate: '2026-03-08T10:36:07.540Z'
94`,
95 );
96
97 return { arm64Path, x64Path };
98}
99
100function writeWindowsManifestFixtures(
101 targetRoot: string,
102 channel: string,
103): { arm64Path: string; x64Path: string } {
104 const assetDirectory = resolve(targetRoot, "release-assets");
105 mkdirSync(assetDirectory, { recursive: true });
106
107 const arm64Path = resolve(assetDirectory, `${channel}-win-arm64.yml`);
108 const x64Path = resolve(assetDirectory, `${channel}-win-x64.yml`);
109
110 writeFileSync(
111 arm64Path,
112 `version: 9.9.9-smoke.0
113files:
114 - url: T3-Code-9.9.9-smoke.0-arm64.exe
115 sha512: arm64exe
116 size: 126621344
117 - url: T3-Code-9.9.9-smoke.0-arm64.exe.blockmap
118 sha512: arm64blockmap
119 size: 152344
120path: T3-Code-9.9.9-smoke.0-arm64.exe
121sha512: arm64exe
122releaseDate: '2026-03-08T10:32:14.587Z'
123`,
124 );
125
126 writeFileSync(
127 x64Path,
128 `version: 9.9.9-smoke.0
129files:
130 - url: T3-Code-9.9.9-smoke.0-x64.exe
131 sha512: x64exe
132 size: 132000112
133 - url: T3-Code-9.9.9-smoke.0-x64.exe.blockmap
134 sha512: x64blockmap
135 size: 160112
136path: T3-Code-9.9.9-smoke.0-x64.exe
137sha512: x64exe
138releaseDate: '2026-03-08T10:36:07.540Z'
139`,
140 );
141
142 return { arm64Path, x64Path };
143}
144
145function writeWindowsBuilderDebugFixtures(targetRoot: string): {
146 arm64Path: string;
147 x64Path: string;
148} {
149 const assetDirectory = resolve(targetRoot, "release-assets");
150 mkdirSync(assetDirectory, { recursive: true });
151
152 const arm64Path = resolve(assetDirectory, "builder-debug-win-arm64.yml");
153 const x64Path = resolve(assetDirectory, "builder-debug-win-x64.yml");
154 const debugFixture = `arm64:
155 firstOrDefaultFilePatterns:
156 - '**/*'
157nsis:
158 script: |-
159 !include "example.nsh"
160`;
161
162 writeFileSync(arm64Path, debugFixture);
163 writeFileSync(x64Path, debugFixture);
164
165 return { arm64Path, x64Path };
166}
167function assertContains(haystack: string, needle: string, message: string): void {
168 if (!haystack.includes(needle)) {
169 throw new Error(message);
170 }
171}
172
173function assertExists(path: string, message: string): void {
174 if (!existsSync(path)) {
175 throw new Error(message);
176 }
177}
178
179function assertMissing(path: string, message: string): void {
180 if (existsSync(path)) {
181 throw new Error(message);
182 }
183}
184
185const tempRoot = mkdtempSync(join(tmpdir(), "t3-release-smoke-"));
186
187try {
188 copyWorkspaceManifestFixture(tempRoot);
189
190 execFileSync(
191 process.execPath,
192 [
193 resolve(repoRoot, "scripts/update-release-package-versions.ts"),
194 "9.9.9-smoke.0",
195 "--root",
196 tempRoot,
197 ],
198 {
199 cwd: repoRoot,
200 stdio: "inherit",
201 },
202 );
203
204 rmSync(resolve(tempRoot, "bun.lock"), { force: true });
205
206 execFileSync("bun", ["install", "--ignore-scripts"], {
207 cwd: tempRoot,
208 stdio: "inherit",
209 });
210
211 const lockfile = readFileSync(resolve(tempRoot, "bun.lock"), "utf8");
212 assertContains(
213 lockfile,
214 `"version": "9.9.9-smoke.0"`,
215 "Expected bun.lock to contain the smoke version.",
216 );
217
218 const nightlyReleaseMetadata = execFileSync(
219 process.execPath,
220 [
221 resolve(repoRoot, "scripts/resolve-nightly-release.ts"),
222 "--date",
223 "20260413",
224 "--run-number",
225 "321",
226 "--sha",
227 "abcdef1234567890",
228 "--root",
229 tempRoot,
230 ],
231 {
232 cwd: repoRoot,
233 encoding: "utf8",
234 },
235 );
236 assertContains(
237 nightlyReleaseMetadata,
238 "version=9.9.10-nightly.20260413.321",
239 "Expected nightly metadata to contain the derived nightly version.",
240 );
241 assertContains(
242 nightlyReleaseMetadata,
243 "tag=v9.9.10-nightly.20260413.321",
244 "Expected nightly metadata to contain the derived nightly tag.",
245 );
246 assertContains(
247 nightlyReleaseMetadata,
248 "name=T3 Code Nightly 9.9.10-nightly.20260413.321 (abcdef123456)",
249 "Expected nightly metadata to include the short commit SHA in the release name.",
250 );
251
252 const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
253 execFileSync(
254 process.execPath,
255 [
256 resolve(repoRoot, "scripts/merge-update-manifests.ts"),
257 "--platform",
258 "mac",
259 arm64Path,
260 x64Path,
261 ],
262 {
263 cwd: repoRoot,
264 stdio: "inherit",
265 },
266 );
267
268 const mergedManifest = readFileSync(arm64Path, "utf8");
269 assertContains(
270 mergedManifest,
271 "T3-Code-9.9.9-smoke.0-arm64.zip",
272 "Merged manifest is missing the arm64 asset.",
273 );
274 assertContains(
275 mergedManifest,
276 "T3-Code-9.9.9-smoke.0-x64.zip",
277 "Merged manifest is missing the x64 asset.",
278 );
279
280 const { arm64Path: winArm64Path, x64Path: winX64Path } = writeWindowsManifestFixtures(
281 tempRoot,
282 "latest",
283 );
284 const mergedWindowsManifestPath = resolve(tempRoot, "release-assets/latest.yml");
285 const { arm64Path: nightlyWinArm64Path, x64Path: nightlyWinX64Path } =
286 writeWindowsManifestFixtures(tempRoot, "nightly");
287 const mergedNightlyWindowsManifestPath = resolve(tempRoot, "release-assets/nightly.yml");
288 const { arm64Path: previewWinArm64Path, x64Path: previewWinX64Path } =
289 writeWindowsManifestFixtures(tempRoot, "preview");
290 const mergedPreviewWindowsManifestPath = resolve(tempRoot, "release-assets/preview.yml");
291 const { arm64Path: winDebugArm64Path, x64Path: winDebugX64Path } =
292 writeWindowsBuilderDebugFixtures(tempRoot);
293 execFileSync(
294 "bash",
295 [
296 "-lc",
297 `
298 release_assets_dir=${JSON.stringify(resolve(tempRoot, "release-assets"))}
299 shopt -s nullglob
300 found_windows_manifest=false
301 for x64_manifest in "$release_assets_dir"/*-win-x64.yml; do
302 if [[ "$(basename "$x64_manifest")" == builder-debug-* ]]; then
303 continue
304 fi
305
306 arm64_manifest="\${x64_manifest/-x64.yml/-arm64.yml}"
307 output_manifest="\${x64_manifest/-win-x64.yml/.yml}"
308 if [[ ! -f "$arm64_manifest" ]]; then
309 echo "Missing matching arm64 Windows manifest for $x64_manifest" >&2
310 exit 1
311 fi
312
313 found_windows_manifest=true
314 ${JSON.stringify(process.execPath)} ${JSON.stringify(resolve(repoRoot, "scripts/merge-update-manifests.ts"))} --platform win \
315 "$arm64_manifest" \
316 "$x64_manifest" \
317 "$output_manifest"
318 rm -f "$arm64_manifest" "$x64_manifest"
319 done
320
321 if [[ "$found_windows_manifest" != true ]]; then
322 echo "No Windows updater manifests found to merge." >&2
323 exit 1
324 fi
325 `,
326 ],
327 {
328 cwd: repoRoot,
329 stdio: "inherit",
330 },
331 );
332
333 const mergedWindowsManifest = readFileSync(mergedWindowsManifestPath, "utf8");
334 assertContains(
335 mergedWindowsManifest,
336 "T3-Code-9.9.9-smoke.0-arm64.exe",
337 "Merged Windows manifest is missing the arm64 asset.",
338 );
339 assertContains(
340 mergedWindowsManifest,
341 "T3-Code-9.9.9-smoke.0-x64.exe",
342 "Merged Windows manifest is missing the x64 asset.",
343 );
344 const mergedNightlyWindowsManifest = readFileSync(mergedNightlyWindowsManifestPath, "utf8");
345 assertContains(
346 mergedNightlyWindowsManifest,
347 "T3-Code-9.9.9-smoke.0-arm64.exe",
348 "Merged nightly Windows manifest is missing the arm64 asset.",
349 );
350 assertContains(
351 mergedNightlyWindowsManifest,
352 "T3-Code-9.9.9-smoke.0-x64.exe",
353 "Merged nightly Windows manifest is missing the x64 asset.",
354 );
355 const mergedPreviewWindowsManifest = readFileSync(mergedPreviewWindowsManifestPath, "utf8");
356 assertContains(
357 mergedPreviewWindowsManifest,
358 "T3-Code-9.9.9-smoke.0-arm64.exe",
359 "Merged preview Windows manifest is missing the arm64 asset.",
360 );
361 assertContains(
362 mergedPreviewWindowsManifest,
363 "T3-Code-9.9.9-smoke.0-x64.exe",
364 "Merged preview Windows manifest is missing the x64 asset.",
365 );
366 assertMissing(
367 winArm64Path,
368 "Windows release smoke unexpectedly kept the arm64 updater manifest.",
369 );
370 assertMissing(winX64Path, "Windows release smoke unexpectedly kept the x64 updater manifest.");
371 assertMissing(
372 nightlyWinArm64Path,
373 "Windows release smoke unexpectedly kept the nightly arm64 updater manifest.",
374 );
375 assertMissing(
376 nightlyWinX64Path,
377 "Windows release smoke unexpectedly kept the nightly x64 updater manifest.",
378 );
379 assertMissing(
380 previewWinArm64Path,
381 "Windows release smoke unexpectedly kept the preview arm64 updater manifest.",
382 );
383 assertMissing(
384 previewWinX64Path,
385 "Windows release smoke unexpectedly kept the preview x64 updater manifest.",
386 );
387 assertExists(
388 winDebugArm64Path,
389 "Windows release smoke unexpectedly removed the arm64 builder debug fixture.",
390 );
391 assertExists(
392 winDebugX64Path,
393 "Windows release smoke unexpectedly removed the x64 builder debug fixture.",
394 );
395
396 Effect.runSync(Console.log("Release smoke checks passed."));
397} finally {
398 rmSync(tempRoot, { recursive: true, force: true });
399}