diff --git a/package.json b/package.json index 375d5f7ac2..41983a9ca8 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,6 @@ "@types/fs-extra": "^9.0.7", "@types/getos": "^3.0.1", "@types/jest": "^29.5.3", - "@types/log-symbols": "^3.0.0", "@types/node": "^20.10.0", "@types/react": "^16.14.0", "@types/react-dom": "^16.9.11", @@ -131,7 +130,7 @@ "less": "^4.1.1", "less-loader": "^11.0.0", "lint-staged": "^15.2.7", - "log-symbols": "^4.0.0", + "log-symbols": "^6.0.0", "mini-css-extract-plugin": "^2.6.1", "monaco-editor-webpack-plugin": "2.1.0", "npm-run-all": "^4.1.5", diff --git a/tools/contributors.ts b/tools/contributors.ts index c20b80f27b..0d15380776 100644 --- a/tools/contributors.ts +++ b/tools/contributors.ts @@ -1,10 +1,7 @@ +import * as fs from 'node:fs'; import * as path from 'node:path'; import * as util from 'node:util'; -import fetch from 'cross-fetch'; -import fs from 'fs-extra'; -import logSymbols from 'log-symbols'; - const { GITHUB_TOKEN, GH_TOKEN } = process.env; const CONTRIBUTORS_FILE_PATH = path.join( __dirname, @@ -38,7 +35,12 @@ interface ContributorInfo { location: string; } +// Helper function to work around import issues with ESM module +const dynamicImport = new Function('specifier', 'return import(specifier)'); + export async function maybeFetchContributors(silent?: boolean): Promise { + const { default: logSymbols } = await dynamicImport('log-symbols'); + try { const stats = fs.statSync(CONTRIBUTORS_FILE_PATH); const mtime = new Date(util.inspect(stats.mtime)); @@ -54,7 +56,9 @@ export async function maybeFetchContributors(silent?: boolean): Promise { } await fetchAndWriteContributorsFile(); } else { - const contributors = await fs.readJson(CONTRIBUTORS_FILE_PATH); + const contributors = JSON.parse( + await fs.promises.readFile(CONTRIBUTORS_FILE_PATH, 'utf-8'), + ); if (contributors.length === 0) { // File exists, but is empty await fetchAndWriteContributorsFile(); @@ -157,6 +161,8 @@ function fetchContributors() { * Fetch the contributors and write the result to disk */ async function fetchAndWriteContributorsFile() { + const { default: logSymbols } = await dynamicImport('log-symbols'); + await new Promise((resolve) => { fs.access( CONTRIBUTORS_FILE_PATH, @@ -186,7 +192,10 @@ async function fetchAndWriteContributorsFile() { data = []; } - await fs.outputFile(CONTRIBUTORS_FILE_PATH, JSON.stringify(data)); + await fs.promises.writeFile( + CONTRIBUTORS_FILE_PATH, + JSON.stringify(data), + ); console.log(logSymbols.success, `${data.length} Contributors fetched`); resolve(); diff --git a/tools/fetch-releases.ts b/tools/fetch-releases.ts index 384f37926b..bb6c1cb22e 100644 --- a/tools/fetch-releases.ts +++ b/tools/fetch-releases.ts @@ -1,7 +1,7 @@ +import * as fs from 'node:fs'; import * as path from 'node:path'; import { ElectronVersions } from '@electron/fiddle-core'; -import fs from 'fs-extra'; const file = path.join(__dirname, '..', 'static', 'releases.json'); @@ -16,7 +16,7 @@ export async function populateReleases() { `Updating local releases.json with ${releases.length} versions.`, ); - await fs.outputJSON(file, releases); + await fs.promises.writeFile(file, JSON.stringify(releases)); } else if (process.env.CI) { throw new Error('Failed to fetch latest releases.json'); } else { diff --git a/yarn.lock b/yarn.lock index 13f3ee0dad..26e842c8d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2551,13 +2551,6 @@ dependencies: "@types/node" "*" -"@types/log-symbols@^3.0.0": - version "3.0.0" - resolved "https://registry.npmjs.org/@types/log-symbols/-/log-symbols-3.0.0.tgz" - integrity sha512-uW/AGf/41aZ1c1dhZ3s063Ii2OqT8EQooZu3t4VCRyR3dqyA2Bg46BcKyZpnWTY7wzm6cayq4jzylnruu4KqSA== - dependencies: - log-symbols "*" - "@types/mdast@^3.0.0": version "3.0.15" resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.15.tgz#49c524a263f30ffa28b71ae282f813ed000ab9f5" @@ -3847,7 +3840,7 @@ chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2: ansi-styles "^4.1.0" supports-color "^7.1.0" -chalk@~5.3.0: +chalk@^5.3.0, chalk@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385" integrity sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w== @@ -7263,10 +7256,10 @@ is-unicode-supported@^0.1.0: resolved "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz" integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== -is-unicode-supported@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.0.0.tgz" - integrity sha512-TfeaLetCvWAJ/QjG8zBbr0H2LXE0m/Oatp25w0kgU2T/N+Xd2VMV3ENm/h3H4/ajBG9euaK2gsqipL4aCz8lTQ== +is-unicode-supported@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz#d824984b616c292a2e198207d4a609983842f714" + integrity sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ== is-url@^1.1.0, is-url@^1.2.4: version "1.2.4" @@ -8278,14 +8271,6 @@ lodash@^4.17.11, lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17 resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== -log-symbols@*: - version "5.0.0" - resolved "https://registry.npmjs.org/log-symbols/-/log-symbols-5.0.0.tgz" - integrity sha512-zBsSKauX7sM0kcqrf8VpMRPqcWzU6a/Wi7iEl0QlVSCiIZ4CctaLdfVdiZUn6q2/nenyt392qJqpw9FhNAwqxQ== - dependencies: - chalk "^4.1.0" - is-unicode-supported "^1.0.0" - log-symbols@^4.0.0, log-symbols@^4.1.0: version "4.1.0" resolved "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz" @@ -8294,6 +8279,14 @@ log-symbols@^4.0.0, log-symbols@^4.1.0: chalk "^4.1.0" is-unicode-supported "^0.1.0" +log-symbols@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-6.0.0.tgz#bb95e5f05322651cac30c0feb6404f9f2a8a9439" + integrity sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw== + dependencies: + chalk "^5.3.0" + is-unicode-supported "^1.3.0" + log-update@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/log-update/-/log-update-4.0.0.tgz"