|
| 1 | +import { execFileSync } from "node:child_process"; |
| 2 | +import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | +import { tmpdir } from "node:os"; |
| 4 | +import { dirname, join, resolve } from "node:path"; |
| 5 | +import { fileURLToPath } from "node:url"; |
| 6 | + |
| 7 | +const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); |
| 8 | + |
| 9 | +const 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 | + |
| 21 | +function 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 | + } |
| 28 | +} |
| 29 | + |
| 30 | +function 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 |
| 40 | +files: |
| 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 |
| 47 | +path: T3-Code-9.9.9-smoke.0-arm64.zip |
| 48 | +sha512: arm64zip |
| 49 | +releaseDate: '2026-03-08T10:32:14.587Z' |
| 50 | +`, |
| 51 | + ); |
| 52 | + |
| 53 | + writeFileSync( |
| 54 | + x64Path, |
| 55 | + `version: 9.9.9-smoke.0 |
| 56 | +files: |
| 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 |
| 63 | +path: T3-Code-9.9.9-smoke.0-x64.zip |
| 64 | +sha512: x64zip |
| 65 | +releaseDate: '2026-03-08T10:36:07.540Z' |
| 66 | +`, |
| 67 | + ); |
| 68 | + |
| 69 | + return { arm64Path, x64Path }; |
| 70 | +} |
| 71 | + |
| 72 | +function assertContains(haystack: string, needle: string, message: string): void { |
| 73 | + if (!haystack.includes(needle)) { |
| 74 | + throw new Error(message); |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +const tempRoot = mkdtempSync(join(tmpdir(), "t3-release-smoke-")); |
| 79 | + |
| 80 | +try { |
| 81 | + copyWorkspaceManifestFixture(tempRoot); |
| 82 | + |
| 83 | + execFileSync( |
| 84 | + process.execPath, |
| 85 | + [resolve(repoRoot, "scripts/update-release-package-versions.ts"), "9.9.9-smoke.0", "--root", tempRoot], |
| 86 | + { |
| 87 | + cwd: repoRoot, |
| 88 | + stdio: "inherit", |
| 89 | + }, |
| 90 | + ); |
| 91 | + |
| 92 | + execFileSync("bun", ["install", "--lockfile-only", "--ignore-scripts"], { |
| 93 | + cwd: tempRoot, |
| 94 | + stdio: "inherit", |
| 95 | + }); |
| 96 | + |
| 97 | + const lockfile = readFileSync(resolve(tempRoot, "bun.lock"), "utf8"); |
| 98 | + assertContains(lockfile, `"version": "9.9.9-smoke.0"`, "Expected bun.lock to contain the smoke version."); |
| 99 | + |
| 100 | + const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot); |
| 101 | + execFileSync(process.execPath, [resolve(repoRoot, "scripts/merge-mac-update-manifests.ts"), arm64Path, x64Path], { |
| 102 | + cwd: repoRoot, |
| 103 | + stdio: "inherit", |
| 104 | + }); |
| 105 | + |
| 106 | + const mergedManifest = readFileSync(arm64Path, "utf8"); |
| 107 | + assertContains(mergedManifest, "T3-Code-9.9.9-smoke.0-arm64.zip", "Merged manifest is missing the arm64 asset."); |
| 108 | + assertContains(mergedManifest, "T3-Code-9.9.9-smoke.0-x64.zip", "Merged manifest is missing the x64 asset."); |
| 109 | + |
| 110 | + console.log("Release smoke checks passed."); |
| 111 | +} finally { |
| 112 | + rmSync(tempRoot, { recursive: true, force: true }); |
| 113 | +} |
0 commit comments