Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 22 additions & 0 deletions tools/format-with-biome.ts
Original file line number Diff line number Diff line change
@@ -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}`);
}
}
2 changes: 2 additions & 0 deletions tools/generate-registry-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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, "..");
Expand Down Expand Up @@ -149,6 +150,7 @@ 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);
}

Expand Down
2 changes: 2 additions & 0 deletions tools/generate-schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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, "..");
Expand Down Expand Up @@ -48,6 +49,7 @@ async function main(): Promise<void> {

fs.mkdirSync(path.dirname(OUT_PATH), { recursive: true });
fs.writeFileSync(OUT_PATH, result, "utf-8");
formatWithBiome(OUT_PATH);
console.log("Wrote", OUT_PATH);
}

Expand Down
Loading