Open History to see the last commit
1import { execFileSync } from "node:child_process";
2import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3import { tmpdir } from "node:os";
4import { dirname, join, resolve } from "node:path";
5import { fileURLToPath } from "node:url";
6
7const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
8
9const workspaceFiles = [
10 "package.json",
11 "bun.lock",
12 "apps/server/package.json",
13 "apps/desktop/package.json",
14 "apps/web/package.json",
15 "apps/marketing/package.json",
16 "packages/client-runtime/package.json",
17 "packages/contracts/package.json",
18 "packages/shared/package.json",
19 "scripts/package.json",
20] as const;
21
22function copyWorkspaceManifestFixture(targetRoot: string): void {
23 for (const relativePath of workspaceFiles) {
24 const sourcePath = resolve(repoRoot, relativePath);
25 const destinationPath = resolve(targetRoot, relativePath);
26 mkdirSync(dirname(destinationPath), { recursive: true });
27 cpSync(sourcePath, destinationPath);
28 }
29}
30
31function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
32 const assetDirectory = resolve(targetRoot, "release-assets");
33 mkdirSync(assetDirectory, { recursive: true });
34
35 const arm64Path = resolve(assetDirectory, "latest-mac.yml");
36 const x64Path = resolve(assetDirectory, "latest-mac-x64.yml");
37
38 writeFileSync(
39 arm64Path,
40 `version: 9.9.9-smoke.0
41files:
42 - url: T3-Code-9.9.9-smoke.0-arm64.zip
43 sha512: arm64zip
44 size: 125621344
45 - url: T3-Code-9.9.9-smoke.0-arm64.dmg
46 sha512: arm64dmg
47 size: 131754935
48path: T3-Code-9.9.9-smoke.0-arm64.zip
49sha512: arm64zip
50releaseDate: '2026-03-08T10:32:14.587Z'
51`,
52 );
53
54 writeFileSync(
55 x64Path,
56 `version: 9.9.9-smoke.0
57files:
58 - url: T3-Code-9.9.9-smoke.0-x64.zip
59 sha512: x64zip
60 size: 132000112
61 - url: T3-Code-9.9.9-smoke.0-x64.dmg
62 sha512: x64dmg
63 size: 138148807
64path: T3-Code-9.9.9-smoke.0-x64.zip
65sha512: x64zip
66releaseDate: '2026-03-08T10:36:07.540Z'
67`,
68 );
69
70 return { arm64Path, x64Path };
71}
72
73function writeWindowsManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
74 const assetDirectory = resolve(targetRoot, "release-assets");
75 mkdirSync(assetDirectory, { recursive: true });
76
77 const arm64Path = resolve(assetDirectory, "latest-win-arm64.yml");
78 const x64Path = resolve(assetDirectory, "latest-win-x64.yml");
79
80 writeFileSync(
81 arm64Path,
82 `version: 9.9.9-smoke.0
83files:
84 - url: T3-Code-9.9.9-smoke.0-arm64.exe
85 sha512: arm64exe
86 size: 126621344
87 - url: T3-Code-9.9.9-smoke.0-arm64.exe.blockmap
88 sha512: arm64blockmap
89 size: 152344
90path: T3-Code-9.9.9-smoke.0-arm64.exe
91sha512: arm64exe
92releaseDate: '2026-03-08T10:32:14.587Z'
93`,
94 );
95
96 writeFileSync(
97 x64Path,
98 `version: 9.9.9-smoke.0
99files:
100 - url: T3-Code-9.9.9-smoke.0-x64.exe
101 sha512: x64exe
102 size: 132000112
103 - url: T3-Code-9.9.9-smoke.0-x64.exe.blockmap
104 sha512: x64blockmap
105 size: 160112
106path: T3-Code-9.9.9-smoke.0-x64.exe
107sha512: x64exe
108releaseDate: '2026-03-08T10:36:07.540Z'
109`,
110 );
111
112 return { arm64Path, x64Path };
113}
114
115function assertContains(haystack: string, needle: string, message: string): void {
116 if (!haystack.includes(needle)) {
117 throw new Error(message);
118 }
119}
120
121const tempRoot = mkdtempSync(join(tmpdir(), "t3-release-smoke-"));
122
123try {
124 copyWorkspaceManifestFixture(tempRoot);
125
126 execFileSync(
127 process.execPath,
128 [
129 resolve(repoRoot, "scripts/update-release-package-versions.ts"),
130 "9.9.9-smoke.0",
131 "--root",
132 tempRoot,
133 ],
134 {
135 cwd: repoRoot,
136 stdio: "inherit",
137 },
138 );
139
140 execFileSync("bun", ["install", "--ignore-scripts"], {
141 cwd: tempRoot,
142 stdio: "inherit",
143 });
144
145 const lockfile = readFileSync(resolve(tempRoot, "bun.lock"), "utf8");
146 assertContains(
147 lockfile,
148 `"version": "9.9.9-smoke.0"`,
149 "Expected bun.lock to contain the smoke version.",
150 );
151
152 const nightlyReleaseMetadata = execFileSync(
153 process.execPath,
154 [
155 resolve(repoRoot, "scripts/resolve-nightly-release.ts"),
156 "--date",
157 "20260413",
158 "--run-number",
159 "321",
160 "--sha",
161 "abcdef1234567890",
162 "--root",
163 tempRoot,
164 ],
165 {
166 cwd: repoRoot,
167 encoding: "utf8",
168 },
169 );
170 assertContains(
171 nightlyReleaseMetadata,
172 "version=9.9.10-nightly.20260413.321",
173 "Expected nightly metadata to contain the derived nightly version.",
174 );
175 assertContains(
176 nightlyReleaseMetadata,
177 "tag=nightly-v9.9.10-nightly.20260413.321",
178 "Expected nightly metadata to contain the derived nightly tag.",
179 );
180 assertContains(
181 nightlyReleaseMetadata,
182 "name=T3 Code Nightly 9.9.10-nightly.20260413.321 (abcdef123456)",
183 "Expected nightly metadata to include the short commit SHA in the release name.",
184 );
185
186 const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
187 execFileSync(
188 process.execPath,
189 [
190 resolve(repoRoot, "scripts/merge-update-manifests.ts"),
191 "--platform",
192 "mac",
193 arm64Path,
194 x64Path,
195 ],
196 {
197 cwd: repoRoot,
198 stdio: "inherit",
199 },
200 );
201
202 const mergedManifest = readFileSync(arm64Path, "utf8");
203 assertContains(
204 mergedManifest,
205 "T3-Code-9.9.9-smoke.0-arm64.zip",
206 "Merged manifest is missing the arm64 asset.",
207 );
208 assertContains(
209 mergedManifest,
210 "T3-Code-9.9.9-smoke.0-x64.zip",
211 "Merged manifest is missing the x64 asset.",
212 );
213
214 const { arm64Path: winArm64Path, x64Path: winX64Path } = writeWindowsManifestFixtures(tempRoot);
215 execFileSync(
216 process.execPath,
217 [
218 resolve(repoRoot, "scripts/merge-update-manifests.ts"),
219 "--platform",
220 "win",
221 winArm64Path,
222 winX64Path,
223 ],
224 {
225 cwd: repoRoot,
226 stdio: "inherit",
227 },
228 );
229
230 const mergedWindowsManifest = readFileSync(winArm64Path, "utf8");
231 assertContains(
232 mergedWindowsManifest,
233 "T3-Code-9.9.9-smoke.0-arm64.exe",
234 "Merged Windows manifest is missing the arm64 asset.",
235 );
236 assertContains(
237 mergedWindowsManifest,
238 "T3-Code-9.9.9-smoke.0-x64.exe",
239 "Merged Windows manifest is missing the x64 asset.",
240 );
241
242 console.log("Release smoke checks passed.");
243} finally {
244 rmSync(tempRoot, { recursive: true, force: true });
245}