From 692c50fb1ffc3e0b319d815993ed747408530bb3 Mon Sep 17 00:00:00 2001 From: Doug <4741454+douglance@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:28:05 -0400 Subject: [PATCH] swap to prettier.format --- packages/scripts/package.json | 1 - packages/scripts/src/addOrbitChain/transforms.ts | 12 +++++++++--- yarn.lock | 12 ------------ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/scripts/package.json b/packages/scripts/package.json index c6d9c1298e..0c53feef3e 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -25,7 +25,6 @@ "zod": "^3.23.8" }, "devDependencies": { - "@actions/exec": "^1.1.1", "@types/node": "^22.7.1", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", diff --git a/packages/scripts/src/addOrbitChain/transforms.ts b/packages/scripts/src/addOrbitChain/transforms.ts index 4486c6f26f..49ebaeb43a 100644 --- a/packages/scripts/src/addOrbitChain/transforms.ts +++ b/packages/scripts/src/addOrbitChain/transforms.ts @@ -6,8 +6,7 @@ import { warning } from "@actions/core"; import axios from "axios"; import * as fs from "fs"; import sharp from "sharp"; -// @ts-expect-error - @actions/exec is not typed -import { exec } from "@actions/exec"; +import prettier from "prettier"; import { commitChanges, @@ -435,7 +434,14 @@ export const updateOrbitChainsFile = ( export async function runPrettier(targetJsonPath: string): Promise { try { - await exec("yarn", ["prettier:format", targetJsonPath]); + const fileContent = fs.readFileSync(targetJsonPath, "utf8"); + const prettierConfig = await prettier.resolveConfig(targetJsonPath); + const formattedContent = await prettier.format(fileContent, { + ...prettierConfig, + filepath: targetJsonPath, + }); + fs.writeFileSync(targetJsonPath, formattedContent); + console.log(`Prettier formatting applied to ${targetJsonPath}`); } catch (error) { warning(`Failed to run Prettier: ${error}`); } diff --git a/yarn.lock b/yarn.lock index 9b513558fe..30f2747718 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10,13 +10,6 @@ "@actions/http-client" "^2.0.1" uuid "^8.3.2" -"@actions/exec@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.1.1.tgz#2e43f28c54022537172819a7cf886c844221a611" - integrity sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w== - dependencies: - "@actions/io" "^1.0.1" - "@actions/github@^6.0.0": version "6.0.0" resolved "https://registry.npmjs.org/@actions/github/-/github-6.0.0.tgz" @@ -35,11 +28,6 @@ tunnel "^0.0.6" undici "^5.25.4" -"@actions/io@^1.0.1": - version "1.1.3" - resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.1.3.tgz#4cdb6254da7962b07473ff5c335f3da485d94d71" - integrity sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q== - "@adraffy/ens-normalize@1.10.0": version "1.10.0" resolved "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz"