@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

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