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