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