From a777b79718da378f82ada577fa02e051452402d8 Mon Sep 17 00:00:00 2001
From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Date: Sat, 27 Jul 2024 19:35:46 -0700
Subject: [PATCH] Use biome CLI for formatting client types map (#914)

---
 scripts/generateClientTypesMap/index.ts | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/scripts/generateClientTypesMap/index.ts b/scripts/generateClientTypesMap/index.ts
index ac685b0a8..cb591d2aa 100644
--- a/scripts/generateClientTypesMap/index.ts
+++ b/scripts/generateClientTypesMap/index.ts
@@ -1,6 +1,7 @@
+import { exec } from "node:child_process";
 import { writeFile } from "node:fs/promises";
 import { join } from "node:path";
-import { format } from "prettier";
+import { promisify } from "node:util";
 
 import {
   CLIENT_NAMES,
@@ -11,8 +12,7 @@ import {
 import { getClientReqRespTypesMap } from "./getClientReqRespTypesMap";
 import { getClientTypesMap } from "./getClientTypesMap";
 
-const codegenComment = `// This file is generated by scripts/generateClientTypesMap/index.ts
-// Do not edit this file directly. Instead, edit the script and run it to regenerate this file.`;
+const execAsync = promisify(exec);
 
 (async () => {
   for (const [mapName, getTypesMap] of [
@@ -22,7 +22,9 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
     const filePath = join("src", "transforms", "v2-to-v3", "config", `${mapName}.ts`);
     const relativeFilePath = join(__dirname, "..", "..", filePath);
 
-    let fileContent = codegenComment;
+    let fileContent = "// This file is generated by scripts/generateClientTypesMap/index.ts\n";
+    fileContent +=
+      "// Do not edit this file directly. Instead, edit the script and run it to regenerate this file.\n";
 
     fileContent += "\n\n\n";
     fileContent += `export const ${mapName}: Record<string, Record<string, string>> = `;
@@ -37,11 +39,8 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
     }
 
     fileContent += JSON.stringify(clientTypesMap);
-    fileContent += ";\n";
 
-    await writeFile(
-      relativeFilePath,
-      await format(fileContent, { parser: "typescript", printWidth: 100 })
-    );
+    await writeFile(relativeFilePath, fileContent);
+    await execAsync(`yarn biome format --write ${relativeFilePath}`);
   }
 })();