From cb3982de7e5f0b563afe16cc18430ada75c90ef2 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 2 May 2023 14:16:35 +0530 Subject: [PATCH] Remove unnecessary dependencies Co-authored-by: Alois Klink --- cSpell.json | 1 - package.json | 1 - packages/mermaid/.gitignore | 1 + .../src/docs/.vitepress/components.d.ts | 15 ---- .../docs/.vitepress/scripts/fetch-avatars.ts | 26 +++--- .../.vitepress/scripts/fetch-contributors.ts | 21 +++-- packages/mermaid/src/docs/package.json | 2 - pnpm-lock.yaml | 80 ------------------- 8 files changed, 20 insertions(+), 127 deletions(-) delete mode 100644 packages/mermaid/src/docs/.vitepress/components.d.ts diff --git a/cSpell.json b/cSpell.json index dd1ee1db8..6e091ac3d 100644 --- a/cSpell.json +++ b/cSpell.json @@ -80,7 +80,6 @@ "mkdocs", "mmorel", "mult", - "ohmyfetch", "orlandoni", "pathe", "pbrolin", diff --git a/package.json b/package.json index 400104b97..a86f8908f 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,6 @@ "jest": "^29.5.0", "jison": "^0.4.18", "js-yaml": "^4.1.0", - "ohmyfetch": "^0.4.21", "jsdom": "^21.1.1", "lint-staged": "^13.2.1", "path-browserify": "^1.0.1", diff --git a/packages/mermaid/.gitignore b/packages/mermaid/.gitignore index 2d71b0dd3..91c74fe7d 100644 --- a/packages/mermaid/.gitignore +++ b/packages/mermaid/.gitignore @@ -3,3 +3,4 @@ src/docs/config/setup README.* src/docs/public/user-avatars/ src/docs/.vitepress/cache +src/docs/.vitepress/components.d.ts diff --git a/packages/mermaid/src/docs/.vitepress/components.d.ts b/packages/mermaid/src/docs/.vitepress/components.d.ts deleted file mode 100644 index e554b4c4d..000000000 --- a/packages/mermaid/src/docs/.vitepress/components.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-disable */ -/* prettier-ignore */ -// @ts-nocheck -// Generated by unplugin-vue-components -// Read more: https://github.com/vuejs/core/pull/3399 -import '@vue/runtime-core' - -export {}; - -declare module '@vue/runtime-core' { - export interface GlobalComponents { - Contributors: typeof import('./components/Contributors.vue')['default']; - HomePage: typeof import('./components/HomePage.vue')['default']; - } -} diff --git a/packages/mermaid/src/docs/.vitepress/scripts/fetch-avatars.ts b/packages/mermaid/src/docs/.vitepress/scripts/fetch-avatars.ts index 286e4a94f..732373354 100644 --- a/packages/mermaid/src/docs/.vitepress/scripts/fetch-avatars.ts +++ b/packages/mermaid/src/docs/.vitepress/scripts/fetch-avatars.ts @@ -1,28 +1,28 @@ -import fs from 'fs-extra'; +import { mkdir, writeFile, readFile } from 'node:fs/promises'; +import { existsSync } from 'node:fs'; import { fileURLToPath } from 'url'; -import { $fetch } from 'ohmyfetch'; const pathContributors = new URL('../contributor-names.json', import.meta.url); const getAvatarPath = (name: string) => new URL(`../../public/user-avatars/${name}.png`, import.meta.url); -// const dirSponsors = resolve(docsDir, 'public/sponsors/') let contributors: string[] = []; async function download(url: string, fileName: URL) { - if (fs.existsSync(fileName)) return; + if (existsSync(fileName)) { + return; + } // eslint-disable-next-line no-console console.log('downloading', fileName); try { - const image = await $fetch(url, { responseType: 'arrayBuffer' }); - await fs.writeFile(fileName, Buffer.from(image)); + const image = await fetch(url); + await writeFile(fileName, Buffer.from(await image.arrayBuffer())); } catch {} } async function fetchAvatars() { - await fs.ensureDir(fileURLToPath(new URL('..', getAvatarPath('none')))); - contributors = JSON.parse(await fs.readFile(pathContributors, { encoding: 'utf-8' })); - + await mkdir(fileURLToPath(new URL('..', getAvatarPath('none'))), { recursive: true }); + contributors = JSON.parse(await readFile(pathContributors, { encoding: 'utf-8' })); await Promise.allSettled( contributors.map((name) => download(`https://github.com/${name}.png?size=100`, getAvatarPath(name)) @@ -30,12 +30,4 @@ async function fetchAvatars() { ); } -// async function fetchSponsors() { -// await fs.ensureDir(dirSponsors) -// await download('https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg', join(dirSponsors, 'antfu.svg')) -// await download('https://cdn.jsdelivr.net/gh/patak-dev/static/sponsors.svg', join(dirSponsors, 'patak-dev.svg')) -// await download('https://cdn.jsdelivr.net/gh/sheremet-va/static/sponsors.svg', join(dirSponsors, 'sheremet-va.svg')) -// } - fetchAvatars(); -// fetchSponsors() diff --git a/packages/mermaid/src/docs/.vitepress/scripts/fetch-contributors.ts b/packages/mermaid/src/docs/.vitepress/scripts/fetch-contributors.ts index 33513e690..360cbd259 100644 --- a/packages/mermaid/src/docs/.vitepress/scripts/fetch-contributors.ts +++ b/packages/mermaid/src/docs/.vitepress/scripts/fetch-contributors.ts @@ -1,7 +1,6 @@ // Adapted from https://github.dev/vitest-dev/vitest/blob/991ff33ab717caee85ef6cbe1c16dc514186b4cc/scripts/update-contributors.ts#L6 import { writeFile } from 'node:fs/promises'; -import { $fetch } from 'ohmyfetch'; const pathContributors = new URL('../contributor-names.json', import.meta.url); @@ -14,16 +13,16 @@ async function fetchContributors() { let page = 1; let data: Contributor[] = []; do { - data = - (await $fetch( - `https://api.github.com/repos/mermaid-js/mermaid/contributors?per_page=100&page=${page}`, - { - method: 'get', - headers: { - 'content-type': 'application/json', - }, - } - )) || []; + const response = await fetch( + `https://api.github.com/repos/mermaid-js/mermaid/contributors?per_page=100&page=${page}`, + { + method: 'GET', + headers: { + 'content-type': 'application/json', + }, + } + ); + data = await response.json(); collaborators.push(...data.map((i) => i.login)); page++; } while (data.length === 100); diff --git a/packages/mermaid/src/docs/package.json b/packages/mermaid/src/docs/package.json index 21b9ae634..d87944cfa 100644 --- a/packages/mermaid/src/docs/package.json +++ b/packages/mermaid/src/docs/package.json @@ -20,13 +20,11 @@ }, "devDependencies": { "@iconify-json/carbon": "^1.1.16", - "@types/fs-extra": "^11.0.1", "@unocss/reset": "^0.51.8", "@vite-pwa/vitepress": "^0.0.5", "@vitejs/plugin-vue": "^4.2.1", "esno": "^0.16.3", "fast-glob": "^3.2.12", - "fs-extra": "^11.1.1", "https-localhost": "^4.7.1", "pathe": "^1.1.0", "unocss": "^0.51.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 63ac7b8c5..27abae958 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -391,9 +391,6 @@ importers: '@iconify-json/carbon': specifier: ^1.1.16 version: 1.1.16 - '@types/fs-extra': - specifier: ^11.0.1 - version: 11.0.1 '@unocss/reset': specifier: ^0.51.8 version: 0.51.8 @@ -409,70 +406,6 @@ importers: fast-glob: specifier: ^3.2.12 version: 3.2.12 - fs-extra: - specifier: ^11.1.1 - version: 11.1.1 - https-localhost: - specifier: ^4.7.1 - version: 4.7.1 - pathe: - specifier: ^1.1.0 - version: 1.1.0 - unocss: - specifier: ^0.51.8 - version: 0.51.8(postcss@8.4.23)(rollup@2.79.1)(vite@4.3.3) - unplugin-vue-components: - specifier: ^0.24.1 - version: 0.24.1(rollup@2.79.1)(vue@3.2.47) - vite: - specifier: ^4.3.3 - version: 4.3.3(@types/node@18.16.0) - vite-plugin-pwa: - specifier: ^0.14.7 - version: 0.14.7(vite@4.3.3)(workbox-build@6.5.4)(workbox-window@6.5.4) - vitepress: - specifier: 1.0.0-alpha.74 - version: 1.0.0-alpha.74(@algolia/client-search@4.14.2)(@types/node@18.16.0) - workbox-window: - specifier: ^6.5.4 - version: 6.5.4 - - packages/mermaid/src/vitepress: - dependencies: - '@vueuse/core': - specifier: ^10.1.0 - version: 10.1.0(vue@3.2.47) - jiti: - specifier: ^1.18.2 - version: 1.18.2 - vue: - specifier: ^3.2.47 - version: 3.2.47 - devDependencies: - '@iconify-json/carbon': - specifier: ^1.1.16 - version: 1.1.16 - '@types/fs-extra': - specifier: ^11.0.1 - version: 11.0.1 - '@unocss/reset': - specifier: ^0.51.8 - version: 0.51.8 - '@vite-pwa/vitepress': - specifier: ^0.0.5 - version: 0.0.5(vite-plugin-pwa@0.14.7) - '@vitejs/plugin-vue': - specifier: ^4.2.1 - version: 4.2.1(vite@4.3.3)(vue@3.2.47) - esno: - specifier: ^0.16.3 - version: 0.16.3 - fast-glob: - specifier: ^3.2.12 - version: 3.2.12 - fs-extra: - specifier: ^11.1.1 - version: 11.1.1 https-localhost: specifier: ^4.7.1 version: 4.7.1 @@ -4181,13 +4114,6 @@ packages: resolution: {integrity: sha512-HXwADeHEP4exXkCIwy2n1+i0f1ilP1ETQOH5KDOugjkTFZPntWo0Gr8stZOaebkxsdx+k0X/K6obU/+it07ocg==} dev: true - /@types/fs-extra@11.0.1: - resolution: {integrity: sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==} - dependencies: - '@types/jsonfile': 6.1.1 - '@types/node': 18.16.0 - dev: true - /@types/geojson@7946.0.10: resolution: {integrity: sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==} dev: true @@ -4240,12 +4166,6 @@ packages: resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} dev: true - /@types/jsonfile@6.1.1: - resolution: {integrity: sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==} - dependencies: - '@types/node': 18.16.0 - dev: true - /@types/keyv@3.1.4: resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} dependencies: