1
1
import { writeFile } from "node:fs/promises" ;
2
2
import { join } from "node:path" ;
3
+ import { Biome , Distribution } from "@biomejs/js-api" ;
3
4
4
5
import {
5
6
CLIENT_NAMES ,
@@ -10,9 +11,6 @@ import {
10
11
import { getClientReqRespTypesMap } from "./getClientReqRespTypesMap" ;
11
12
import { getClientTypesMap } from "./getClientTypesMap" ;
12
13
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
-
16
14
( async ( ) => {
17
15
for ( const [ mapName , getTypesMap ] of [
18
16
[ "CLIENT_TYPES_MAP" , getClientTypesMap ] ,
@@ -21,7 +19,9 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
21
19
const filePath = join ( "src" , "transforms" , "v2-to-v3" , "config" , `${ mapName } .ts` ) ;
22
20
const relativeFilePath = join ( __dirname , ".." , ".." , filePath ) ;
23
21
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" ;
25
25
26
26
fileContent += "\n\n\n" ;
27
27
fileContent += `export const ${ mapName } : Record<string, Record<string, string>> = ` ;
@@ -36,8 +36,11 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
36
36
}
37
37
38
38
fileContent += JSON . stringify ( clientTypesMap ) ;
39
- fileContent += ";\n" ;
40
39
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 ) ;
42
45
}
43
46
} ) ( ) ;
0 commit comments