Skip to content

Commit 79584d2

Browse files
committed
chore(scripts): attempt to programatically format
1 parent d1044a6 commit 79584d2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

scripts/generateClientTypesMap/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { writeFile } from "node:fs/promises";
22
import { join } from "node:path";
3+
import { Biome, Distribution } from "@biomejs/js-api";
34

45
import {
56
CLIENT_NAMES,
@@ -10,9 +11,6 @@ import {
1011
import { getClientReqRespTypesMap } from "./getClientReqRespTypesMap";
1112
import { getClientTypesMap } from "./getClientTypesMap";
1213

13-
const codegenComment = `// This file is generated by scripts/generateClientTypesMap/index.ts
14-
// Do not edit this file directly. Instead, edit the script and run it to regenerate this file.`;
15-
1614
(async () => {
1715
for (const [mapName, getTypesMap] of [
1816
["CLIENT_TYPES_MAP", getClientTypesMap],
@@ -21,7 +19,9 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
2119
const filePath = join("src", "transforms", "v2-to-v3", "config", `${mapName}.ts`);
2220
const relativeFilePath = join(__dirname, "..", "..", filePath);
2321

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

2626
fileContent += "\n\n\n";
2727
fileContent += `export const ${mapName}: Record<string, Record<string, string>> = `;
@@ -36,8 +36,11 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
3636
}
3737

3838
fileContent += JSON.stringify(clientTypesMap);
39-
fileContent += ";\n";
4039

41-
await writeFile(relativeFilePath, fileContent);
40+
const biome = await Biome.create({ distribution: Distribution.NODE });
41+
const formatted = biome.formatContent(fileContent, {
42+
filePath: relativeFilePath,
43+
});
44+
await writeFile(relativeFilePath, formatted.content);
4245
}
4346
})();

0 commit comments

Comments
 (0)