Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

release-smoke.ts

134 lines3.5 KB

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/contracts/package.json",
17 "packages/shared/package.json",
18 "scripts/package.json",
19] as const;
20​
21function copyWorkspaceManifestFixture(targetRoot: string): void {
22 for (const relativePath of workspaceFiles) {
23 const sourcePath = resolve(repoRoot, relativePath);
24 const destinationPath = resolve(targetRoot, relativePath);
25 mkdirSync(dirname(destinationPath), { recursive: true });
26 cpSync(sourcePath, destinationPath);
27 }
29​
30function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
31 const assetDirectory = resolve(targetRoot, "release-assets");
32 mkdirSync(assetDirectory, { recursive: true });
33​
34 const arm64Path = resolve(assetDirectory, "latest-mac.yml");
35 const x64Path = resolve(assetDirectory, "latest-mac-x64.yml");
36​
37 writeFileSync(
38 arm64Path,
39 `version: 9.9.9-smoke.0
40files:
41 - url: T3-Code-9.9.9-smoke.0-arm64.zip
42 sha512: arm64zip
43 size: 125621344
44 - url: T3-Code-9.9.9-smoke.0-arm64.dmg
45 sha512: arm64dmg
46 size: 131754935
47path: T3-Code-9.9.9-smoke.0-arm64.zip
48sha512: arm64zip
49releaseDate: '2026-03-08T10:32:14.587Z'
50`,
51 );
52​
53 writeFileSync(
54 x64Path,
55 `version: 9.9.9-smoke.0
56files:
57 - url: T3-Code-9.9.9-smoke.0-x64.zip
58 sha512: x64zip
59 size: 132000112
60 - url: T3-Code-9.9.9-smoke.0-x64.dmg
61 sha512: x64dmg
62 size: 138148807
63path: T3-Code-9.9.9-smoke.0-x64.zip
64sha512: x64zip
65releaseDate: '2026-03-08T10:36:07.540Z'
66`,
67 );
68​
69 return { arm64Path, x64Path };
71​
72function assertContains(haystack: string, needle: string, message: string): void {
73 if (!haystack.includes(needle)) {
74 throw new Error(message);
75 }
77​
78const tempRoot = mkdtempSync(join(tmpdir(), "t3-release-smoke-"));
79​
80try {
81 copyWorkspaceManifestFixture(tempRoot);
82​
83 execFileSync(
84 process.execPath,
85 [
86 resolve(repoRoot, "scripts/update-release-package-versions.ts"),
87 "9.9.9-smoke.0",
88 "--root",
89 tempRoot,
90 ],
91 {
92 cwd: repoRoot,
93 stdio: "inherit",
94 },
95 );
96​
97 execFileSync("bun", ["install", "--lockfile-only", "--ignore-scripts"], {
98 cwd: tempRoot,
99 stdio: "inherit",
100 });
101​
102 const lockfile = readFileSync(resolve(tempRoot, "bun.lock"), "utf8");
103 assertContains(
104 lockfile,
105 `"version": "9.9.9-smoke.0"`,
106 "Expected bun.lock to contain the smoke version.",
107 );
108​
109 const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
110 execFileSync(
111 process.execPath,
112 [resolve(repoRoot, "scripts/merge-mac-update-manifests.ts"), arm64Path, x64Path],
113 {
114 cwd: repoRoot,
115 stdio: "inherit",
116 },
117 );
118​
119 const mergedManifest = readFileSync(arm64Path, "utf8");
120 assertContains(
121 mergedManifest,
122 "T3-Code-9.9.9-smoke.0-arm64.zip",
123 "Merged manifest is missing the arm64 asset.",
124 );
125 assertContains(
126 mergedManifest,
127 "T3-Code-9.9.9-smoke.0-x64.zip",
128 "Merged manifest is missing the x64 asset.",
129 );
130​
131 console.log("Release smoke checks passed.");
132} finally {
133 rmSync(tempRoot, { recursive: true, force: true });