Skip to content

Commit a777b79

Browse files
authored
Use biome CLI for formatting client types map (#914)
1 parent 8ae9bf1 commit a777b79

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

scripts/generateClientTypesMap/index.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { exec } from "node:child_process";
12
import { writeFile } from "node:fs/promises";
23
import { join } from "node:path";
3-
import { format } from "prettier";
4+
import { promisify } from "node:util";
45

56
import {
67
CLIENT_NAMES,
@@ -11,8 +12,7 @@ import {
1112
import { getClientReqRespTypesMap } from "./getClientReqRespTypesMap";
1213
import { getClientTypesMap } from "./getClientTypesMap";
1314

14-
const codegenComment = `// This file is generated by scripts/generateClientTypesMap/index.ts
15-
// Do not edit this file directly. Instead, edit the script and run it to regenerate this file.`;
15+
const execAsync = promisify(exec);
1616

1717
(async () => {
1818
for (const [mapName, getTypesMap] of [
@@ -22,7 +22,9 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
2222
const filePath = join("src", "transforms", "v2-to-v3", "config", `${mapName}.ts`);
2323
const relativeFilePath = join(__dirname, "..", "..", filePath);
2424

25-
let fileContent = codegenComment;
25+
let fileContent = "// This file is generated by scripts/generateClientTypesMap/index.ts\n";
26+
fileContent +=
27+
"// Do not edit this file directly. Instead, edit the script and run it to regenerate this file.\n";
2628

2729
fileContent += "\n\n\n";
2830
fileContent += `export const ${mapName}: Record<string, Record<string, string>> = `;
@@ -37,11 +39,8 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
3739
}
3840

3941
fileContent += JSON.stringify(clientTypesMap);
40-
fileContent += ";\n";
4142

42-
await writeFile(
43-
relativeFilePath,
44-
await format(fileContent, { parser: "typescript", printWidth: 100 })
45-
);
43+
await writeFile(relativeFilePath, fileContent);
44+
await execAsync(`yarn biome format --write ${relativeFilePath}`);
4645
}
4746
})();

0 commit comments

Comments
 (0)