From 25010d2b8719e8a7614bdd5c360a8ba6bfadb3b1 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Tue, 25 Oct 2022 18:12:19 +0200 Subject: [PATCH] chore(docs): use regular script for changelog page gen --- docs/src/.vitepress/config.ts | 3 +-- docs/src/.vitepress/plugins/changelog.ts | 32 +++++++++++------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/docs/src/.vitepress/config.ts b/docs/src/.vitepress/config.ts index 0d1f30db..7206aa7b 100644 --- a/docs/src/.vitepress/config.ts +++ b/docs/src/.vitepress/config.ts @@ -9,7 +9,7 @@ import Components from 'unplugin-vue-components/vite' import AutoImport from 'unplugin-auto-import/vite' import { useVueFlow } from '@vue-flow/core' import head from './head' -import { copyChangelogPlugin, copyVueFlowPlugin, files } from './plugins' +import { copyVueFlowPlugin, files } from './plugins' const { vueFlowVersion } = useVueFlow() @@ -72,7 +72,6 @@ export default defineConfigWithTheme({ }, plugins: [ copyVueFlowPlugin(), - copyChangelogPlugin(), AutoImport({ imports: ['vue', '@vueuse/core'], dts: resolve(__dirname, '../auto-imports.d.ts'), diff --git a/docs/src/.vitepress/plugins/changelog.ts b/docs/src/.vitepress/plugins/changelog.ts index 79c08341..c252be85 100644 --- a/docs/src/.vitepress/plugins/changelog.ts +++ b/docs/src/.vitepress/plugins/changelog.ts @@ -1,6 +1,5 @@ -import { copyFile, readdirSync, statSync } from 'fs' +import { copyFile, existsSync, mkdirSync, readdirSync, statSync } from 'fs' import { resolve } from 'path' -import type { Plugin } from 'vite' interface ChangelogFile { path: string @@ -27,21 +26,18 @@ const getAllFiles = function (dirPath: string, needle?: string, arrayOfFiles: Ch export const files = getAllFiles(resolve(__dirname, '../../../../packages'), 'CHANGELOG') -export function copyChangelogPlugin(): Plugin { - return { - name: 'copy-changelog-files', - config() { - files.forEach(({ path, pkgName }) => { - const isCore = pkgName === 'core' +const changelogDirPath = resolve(__dirname, `../../changelog/`) - const filePath = resolve(__dirname, `${path}`) - - copyFile(filePath, resolve(__dirname, `../../changelog/${isCore ? 'index' : pkgName}.md`), () => {}) - - console.log(`Copied ${filePath} to ${resolve(__dirname, `../../changelog/${isCore ? 'index' : pkgName}.md`)}`) - }) - - console.log('Copied changelog files') - }, - } +if (!existsSync(changelogDirPath)) { + mkdirSync(changelogDirPath) } + +files.forEach(({ path, pkgName }) => { + const isCore = pkgName === 'core' + + const filePath = resolve(__dirname, `${path}`) + + copyFile(filePath, `${changelogDirPath}/${isCore ? 'index' : pkgName}.md`, () => {}) + + console.log(`Copied ${filePath} to ${changelogDirPath}/${isCore ? 'index' : pkgName}.md`) +})