Files
t3code/scripts/release-smoke.ts
Julius Marminge aeaf31ff6d Rename published schema artifacts to .json
- Move server settings and keybindings schema URLs to shorter `.json` paths
- Update release tooling, docs, and tests to match the new schema locations
2026-03-30 15:39:49 -07:00

189 lines
5.1 KiB
TypeScript

import { execFileSync } from "node:child_process";
import {
cpSync,
existsSync,
mkdirSync,
mkdtempSync,
readFileSync,
rmSync,
writeFileSync,
} from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const workspaceFiles = [
"package.json",
"bun.lock",
"apps/server/package.json",
"apps/desktop/package.json",
"apps/web/package.json",
"apps/marketing/package.json",
"packages/contracts/package.json",
"packages/shared/package.json",
"scripts/package.json",
] as const;
function copyWorkspaceManifestFixture(targetRoot: string): void {
for (const relativePath of workspaceFiles) {
const sourcePath = resolve(repoRoot, relativePath);
const destinationPath = resolve(targetRoot, relativePath);
mkdirSync(dirname(destinationPath), { recursive: true });
cpSync(sourcePath, destinationPath);
}
}
function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
const assetDirectory = resolve(targetRoot, "release-assets");
mkdirSync(assetDirectory, { recursive: true });
const arm64Path = resolve(assetDirectory, "latest-mac.yml");
const x64Path = resolve(assetDirectory, "latest-mac-x64.yml");
writeFileSync(
arm64Path,
`version: 9.9.9-smoke.0
files:
- url: T3-Code-9.9.9-smoke.0-arm64.zip
sha512: arm64zip
size: 125621344
- url: T3-Code-9.9.9-smoke.0-arm64.dmg
sha512: arm64dmg
size: 131754935
path: T3-Code-9.9.9-smoke.0-arm64.zip
sha512: arm64zip
releaseDate: '2026-03-08T10:32:14.587Z'
`,
);
writeFileSync(
x64Path,
`version: 9.9.9-smoke.0
files:
- url: T3-Code-9.9.9-smoke.0-x64.zip
sha512: x64zip
size: 132000112
- url: T3-Code-9.9.9-smoke.0-x64.dmg
sha512: x64dmg
size: 138148807
path: T3-Code-9.9.9-smoke.0-x64.zip
sha512: x64zip
releaseDate: '2026-03-08T10:36:07.540Z'
`,
);
return { arm64Path, x64Path };
}
function assertContains(haystack: string, needle: string, message: string): void {
if (!haystack.includes(needle)) {
throw new Error(message);
}
}
const tempRoot = mkdtempSync(join(tmpdir(), "t3-release-smoke-"));
try {
copyWorkspaceManifestFixture(tempRoot);
execFileSync(
"bun",
[
resolve(repoRoot, "scripts/update-release-package-versions.ts"),
"9.9.9-smoke.0",
"--root",
tempRoot,
],
{
cwd: repoRoot,
stdio: "inherit",
},
);
execFileSync("bun", ["install", "--lockfile-only", "--ignore-scripts"], {
cwd: tempRoot,
stdio: "inherit",
});
const lockfile = readFileSync(resolve(tempRoot, "bun.lock"), "utf8");
assertContains(
lockfile,
`"version": "9.9.9-smoke.0"`,
"Expected bun.lock to contain the smoke version.",
);
const latestSchemaPath = resolve(tempRoot, "apps/marketing/public/schemas/settings.json");
const versionedSchemaPath = resolve(
tempRoot,
"apps/marketing/public/schemas/settings/9.9.9-smoke.0.json",
);
const latestKeybindingsSchemaPath = resolve(
tempRoot,
"apps/marketing/public/schemas/keybindings.json",
);
const versionedKeybindingsSchemaPath = resolve(
tempRoot,
"apps/marketing/public/schemas/keybindings/9.9.9-smoke.0.json",
);
if (!existsSync(latestSchemaPath)) {
throw new Error(
"Expected release version alignment to generate the latest server settings schema.",
);
}
if (!existsSync(versionedSchemaPath)) {
throw new Error(
"Expected release version alignment to generate the versioned server settings schema.",
);
}
if (!existsSync(latestKeybindingsSchemaPath)) {
throw new Error(
"Expected release version alignment to generate the latest keybindings schema.",
);
}
if (!existsSync(versionedKeybindingsSchemaPath)) {
throw new Error(
"Expected release version alignment to generate the versioned keybindings schema.",
);
}
const versionedSchema = readFileSync(versionedSchemaPath, "utf8");
assertContains(
versionedSchema,
'"title": "T3 Code Server Settings"',
"Expected versioned server settings schema to contain schema metadata.",
);
const versionedKeybindingsSchema = readFileSync(versionedKeybindingsSchemaPath, "utf8");
assertContains(
versionedKeybindingsSchema,
'"title": "T3 Code Keybindings"',
"Expected versioned keybindings schema to contain schema metadata.",
);
const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
execFileSync(
process.execPath,
[resolve(repoRoot, "scripts/merge-mac-update-manifests.ts"), arm64Path, x64Path],
{
cwd: repoRoot,
stdio: "inherit",
},
);
const mergedManifest = readFileSync(arm64Path, "utf8");
assertContains(
mergedManifest,
"T3-Code-9.9.9-smoke.0-arm64.zip",
"Merged manifest is missing the arm64 asset.",
);
assertContains(
mergedManifest,
"T3-Code-9.9.9-smoke.0-x64.zip",
"Merged manifest is missing the x64 asset.",
);
console.log("Release smoke checks passed.");
} finally {
rmSync(tempRoot, { recursive: true, force: true });
}