1
+ import { exec } from "node:child_process" ;
1
2
import { writeFile } from "node:fs/promises" ;
2
3
import { join } from "node:path" ;
3
- import { format } from "prettier " ;
4
+ import { promisify } from "node:util " ;
4
5
5
6
import {
6
7
CLIENT_NAMES ,
@@ -11,8 +12,7 @@ import {
11
12
import { getClientReqRespTypesMap } from "./getClientReqRespTypesMap" ;
12
13
import { getClientTypesMap } from "./getClientTypesMap" ;
13
14
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 ) ;
16
16
17
17
( async ( ) => {
18
18
for ( const [ mapName , getTypesMap ] of [
@@ -22,7 +22,9 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
22
22
const filePath = join ( "src" , "transforms" , "v2-to-v3" , "config" , `${ mapName } .ts` ) ;
23
23
const relativeFilePath = join ( __dirname , ".." , ".." , filePath ) ;
24
24
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" ;
26
28
27
29
fileContent += "\n\n\n" ;
28
30
fileContent += `export const ${ mapName } : Record<string, Record<string, string>> = ` ;
@@ -37,11 +39,8 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
37
39
}
38
40
39
41
fileContent += JSON . stringify ( clientTypesMap ) ;
40
- fileContent += ";\n" ;
41
42
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 } ` ) ;
46
45
}
47
46
} ) ( ) ;
0 commit comments