From 8b307cd7bc904be4c79bed39dbe44264a00e617e Mon Sep 17 00:00:00 2001 From: MarioCadenas Date: Wed, 29 Apr 2026 10:54:07 +0200 Subject: [PATCH 1/2] chore: format generated type files in their generators The per-package `build:package` scripts run the schema/registry type generators before `tsdown`, but only the root `generate:types` script piped the output through Biome. Since `pnpm build` and `pnpm dev` skip that root script, every build left `plugin-manifest.generated.ts` and `types.generated.ts` dirty until `pnpm format` was run. Have each generator invoke `biome check --write` on its own output so the file lands formatted regardless of how it was produced. The trailing biome step in the root `generate:types` script is now redundant and removed. --- package.json | 2 +- tools/generate-registry-types.ts | 18 ++++++++++++++++++ tools/generate-schema-types.ts | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d3af43fc..df8bec590 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build:watch": "pnpm -r --filter=!dev-playground --filter=!docs build:watch", "check:fix": "biome check --write .", "check": "biome check .", - "generate:types": "tsx tools/generate-schema-types.ts && tsx tools/generate-registry-types.ts && biome check --write packages/shared/src/schemas/plugin-manifest.generated.ts packages/appkit/src/registry/types.generated.ts", + "generate:types": "tsx tools/generate-schema-types.ts && tsx tools/generate-registry-types.ts", "generate:app-templates": "tsx tools/generate-app-templates.ts", "check:licenses": "tsx tools/check-licenses.ts", "build:notice": "tsx tools/build-notice.ts > NOTICE.md", diff --git a/tools/generate-registry-types.ts b/tools/generate-registry-types.ts index fa833d24d..49205fe5c 100644 --- a/tools/generate-registry-types.ts +++ b/tools/generate-registry-types.ts @@ -4,6 +4,7 @@ * * Run from repo root: pnpm exec tsx tools/generate-registry-types.ts */ +import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; @@ -149,7 +150,24 @@ function main(): void { const out = generate(schema); fs.mkdirSync(path.dirname(OUT_PATH), { recursive: true }); fs.writeFileSync(OUT_PATH, out, "utf-8"); + formatWithBiome(OUT_PATH); console.log("Wrote", OUT_PATH); } +/** + * Run Biome on the generated file so its formatting matches the rest of the + * repo. Without this, every `pnpm build`/`pnpm dev` would leave the file dirty + * until `pnpm format` is run. + */ +function formatWithBiome(filePath: string): void { + const result = spawnSync( + "pnpm", + ["exec", "biome", "check", "--write", "--no-errors-on-unmatched", filePath], + { cwd: REPO_ROOT, stdio: "inherit" }, + ); + if (result.status !== 0) { + throw new Error(`biome check --write failed for ${filePath}`); + } +} + main(); diff --git a/tools/generate-schema-types.ts b/tools/generate-schema-types.ts index 36f31e4ac..8bae218f4 100644 --- a/tools/generate-schema-types.ts +++ b/tools/generate-schema-types.ts @@ -5,6 +5,7 @@ * * Run from repo root: pnpm exec tsx tools/generate-schema-types.ts */ +import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; @@ -48,7 +49,24 @@ async function main(): Promise { fs.mkdirSync(path.dirname(OUT_PATH), { recursive: true }); fs.writeFileSync(OUT_PATH, result, "utf-8"); + formatWithBiome(OUT_PATH); console.log("Wrote", OUT_PATH); } +/** + * Run Biome on the generated file so its formatting matches the rest of the + * repo. Without this, every `pnpm build`/`pnpm dev` would leave the file dirty + * until `pnpm format` is run. + */ +function formatWithBiome(filePath: string): void { + const result = spawnSync( + "pnpm", + ["exec", "biome", "check", "--write", "--no-errors-on-unmatched", filePath], + { cwd: REPO_ROOT, stdio: "inherit" }, + ); + if (result.status !== 0) { + throw new Error(`biome check --write failed for ${filePath}`); + } +} + main(); From a6ffbe50ef8133a1b6942c388b9dece654374cca Mon Sep 17 00:00:00 2001 From: MarioCadenas Date: Wed, 29 Apr 2026 13:17:44 +0200 Subject: [PATCH 2/2] refactor: extract formatWithBiome into shared tools module Both generate-schema-types.ts and generate-registry-types.ts had the same helper for spawning `biome check --write`. Move it into a single tools/format-with-biome.ts module so both generators share one copy. --- tools/format-with-biome.ts | 22 ++++++++++++++++++++++ tools/generate-registry-types.ts | 18 +----------------- tools/generate-schema-types.ts | 18 +----------------- 3 files changed, 24 insertions(+), 34 deletions(-) create mode 100644 tools/format-with-biome.ts diff --git a/tools/format-with-biome.ts b/tools/format-with-biome.ts new file mode 100644 index 000000000..336e69b84 --- /dev/null +++ b/tools/format-with-biome.ts @@ -0,0 +1,22 @@ +import { spawnSync } from "node:child_process"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const REPO_ROOT = path.join(__dirname, ".."); + +/** + * Run Biome on a generated file so its formatting matches the rest of the + * repo. Without this, every `pnpm build`/`pnpm dev` would leave generated + * files dirty until `pnpm format` is run. + */ +export function formatWithBiome(filePath: string): void { + const result = spawnSync( + "pnpm", + ["exec", "biome", "check", "--write", "--no-errors-on-unmatched", filePath], + { cwd: REPO_ROOT, stdio: "inherit" }, + ); + if (result.status !== 0) { + throw new Error(`biome check --write failed for ${filePath}`); + } +} diff --git a/tools/generate-registry-types.ts b/tools/generate-registry-types.ts index 49205fe5c..531802260 100644 --- a/tools/generate-registry-types.ts +++ b/tools/generate-registry-types.ts @@ -4,10 +4,10 @@ * * Run from repo root: pnpm exec tsx tools/generate-registry-types.ts */ -import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import { formatWithBiome } from "./format-with-biome.ts"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = path.join(__dirname, ".."); @@ -154,20 +154,4 @@ function main(): void { console.log("Wrote", OUT_PATH); } -/** - * Run Biome on the generated file so its formatting matches the rest of the - * repo. Without this, every `pnpm build`/`pnpm dev` would leave the file dirty - * until `pnpm format` is run. - */ -function formatWithBiome(filePath: string): void { - const result = spawnSync( - "pnpm", - ["exec", "biome", "check", "--write", "--no-errors-on-unmatched", filePath], - { cwd: REPO_ROOT, stdio: "inherit" }, - ); - if (result.status !== 0) { - throw new Error(`biome check --write failed for ${filePath}`); - } -} - main(); diff --git a/tools/generate-schema-types.ts b/tools/generate-schema-types.ts index 8bae218f4..18360fb2f 100644 --- a/tools/generate-schema-types.ts +++ b/tools/generate-schema-types.ts @@ -5,11 +5,11 @@ * * Run from repo root: pnpm exec tsx tools/generate-schema-types.ts */ -import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { compileFromFile } from "json-schema-to-typescript"; +import { formatWithBiome } from "./format-with-biome.ts"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = path.join(__dirname, ".."); @@ -53,20 +53,4 @@ async function main(): Promise { console.log("Wrote", OUT_PATH); } -/** - * Run Biome on the generated file so its formatting matches the rest of the - * repo. Without this, every `pnpm build`/`pnpm dev` would leave the file dirty - * until `pnpm format` is run. - */ -function formatWithBiome(filePath: string): void { - const result = spawnSync( - "pnpm", - ["exec", "biome", "check", "--write", "--no-errors-on-unmatched", filePath], - { cwd: REPO_ROOT, stdio: "inherit" }, - ); - if (result.status !== 0) { - throw new Error(`biome check --write failed for ${filePath}`); - } -} - main();