diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c5b28cdd..d2959617 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -29,5 +29,5 @@ jobs: - name: Linter run: | - pnpm run lint + pnpm run lint:check pnpm run lint:css diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 6517952b..f0fa3ae2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,8 @@ { "recommendations": [ "vue.volar", - "dbaeumer.vscode-eslint" + "dbaeumer.vscode-eslint", + "stylelint.vscode-stylelint", + "DavidAnson.vscode-markdownlint" ] } diff --git a/.vscode/launch.json b/.vscode/launch.json index c349b76f..7d29fa0a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "name": "docs:dev", "type": "node-terminal", "request": "launch", - "command": "pnpm run docs" + "command": "pnpm run docs:dev" }, { "name": "docs:build", diff --git a/.vscode/settings.json b/.vscode/settings.json index 91ebc9bc..d5c8a932 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -82,8 +82,6 @@ "twoslash", "vite", "vuepress", - "vueuse", - "Windi", - "Windicss" + "vueuse" ] } diff --git a/docs/3.更新说明/73-77.md b/docs/3.更新说明/73-77.md index eb413305..5345dc74 100644 --- a/docs/3.更新说明/73-77.md +++ b/docs/3.更新说明/73-77.md @@ -16,7 +16,7 @@ sticky: 3 - 移除 `@vuepress-plume/plugin-notes-data` 插件 - 移除 `@vuepress-plume/plugin-auto-frontmatter` 插件 -以上插件的功能全部移动到 `vuepress-theme-plugin` 主题包内部重新实现。原因是,单独的主题配置文件, +以上插件的功能全部移动到 `vuepress-theme-plume` 主题包内部重新实现。原因是,单独的主题配置文件, 在异步加载完配置、以及配置热更新时,需要对这些插件所实现的功能进行重载,为了使流程更加清晰可控, 在主题内重新实现了这些功能,并移除了相关插件。 diff --git a/docs/package.json b/docs/package.json index b43e0c30..7ef8b6ac 100644 --- a/docs/package.json +++ b/docs/package.json @@ -20,7 +20,7 @@ "http-server": "^14.1.1", "mermaid": "^10.9.1", "vue": "^3.4.31", - "vuepress-theme-plume": "workspace:~" + "vuepress-theme-plume": "workspace:*" }, "devDependencies": { "@types/express": "^4.17.21" diff --git a/eslint.config.js b/eslint.config.js index 79b2984a..dda5695f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,10 +1,6 @@ import config from '@pengzhanbo/eslint-config-vue' export default config({ - // todo: 正则校验 - // 当前项目中的 正则 还并不能完全通过 规则,存在 53 个问题 - // 但处理起来比较麻烦,因此将会作为一项比较长期的工作来完成。 - regexp: false, ignores: [ 'lib', 'docs/notes/theme/snippet/code-block.snippet.md', diff --git a/package.json b/package.json index 2cfdc816..24a5bda9 100644 --- a/package.json +++ b/package.json @@ -14,28 +14,26 @@ "vuepress-theme-plume" ], "engines": { - "node": "^18 || >=20.0.0", + "node": "^18.20.0 || >=20.0.0", "pnpm": ">=9" }, "scripts": { - "build": "pnpm run clean && pnpm run build:package", - "build:package": "pnpm --filter=!docs run -r --stream build", - "clean": "pnpm --filter=!docs run -r --stream clean", - "dev": "concurrently \"pnpm run dev:package\" \"pnpm run docs\"", - "dev:package": "pnpm --filter=!docs --parallel dev", - "dev:theme": "concurrently \"pnpm --filter=vuepress-theme-plume dev\" \"pnpm run docs\"", - "docs": "pnpm --filter=docs docs:dev", - "docs:build": "pnpm --filter=docs docs:build", - "docs:clean": "pnpm --filter=docs docs:clean", - "docs:serve": "pnpm --filter=docs docs:serve", - "commit": "cz", - "lint": "eslint .", + "build": "pnpm clean && pnpm build:package", + "build:package": "pnpm -r --stream build", + "clean": "pnpm -r --stream clean", + "dev": "pnpm --stream '/(dev:package|docs:dev)/'", + "dev:package": "pnpm --parallel dev", + "docs:dev": "wait-on -d 100 theme/lib/node/index.js && pnpm -F=docs docs:dev", + "docs:build": "pnpm -F=docs docs:build", + "docs:clean": "pnpm -F=docs docs:clean", + "docs:serve": "pnpm -F=docs docs:serve", + "lint": "pnpm lint:check && pnpm lint:css", + "lint:check": "eslint .", "lint:css": "stylelint **/*.{css,scss,vue}", "prepare": "husky", - "release": "pnpm release:check && pnpm release:version && pnpm release:publish", + "release": "pnpm release:check && pnpm release:version && pnpm -r publish", "release:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", - "release:check": "pnpm lint && pnpm lint:css && pnpm build", - "release:publish": "pnpm -r publish", + "release:check": "pnpm lint && pnpm build", "release:version": "bumpp package.json plugins/*/package.json theme/package.json --execute=\"pnpm release:changelog\" --commit \"build: publish v%s\" --all --tag --push" }, "devDependencies": { @@ -48,7 +46,6 @@ "@types/webpack-env": "^1.18.5", "bumpp": "^9.4.1", "commitizen": "^4.3.0", - "concurrently": "^8.2.2", "conventional-changelog-cli": "^5.0.0", "cpx2": "^7.0.1", "cz-conventional-changelog": "^3.3.0", @@ -58,7 +55,9 @@ "rimraf": "^6.0.1", "stylelint": "^16.7.0", "tsconfig-vuepress": "^4.5.0", - "typescript": "^5.5.3" + "tsup": "^8.1.2", + "typescript": "^5.5.3", + "wait-on": "^7.2.0" }, "lint-staged": { "*": "eslint --fix" diff --git a/plugins/plugin-baidu-tongji/LICENSE b/plugins/plugin-baidu-tongji/LICENSE deleted file mode 100644 index 9f677c90..00000000 --- a/plugins/plugin-baidu-tongji/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (C) 2021 - PRESENT by pengzhanbo - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/plugins/plugin-baidu-tongji/README.md b/plugins/plugin-baidu-tongji/README.md deleted file mode 100644 index e4a565b2..00000000 --- a/plugins/plugin-baidu-tongji/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# `@vuepress-plume/plugin-baidu-tongji` - -在vuepress中接入百度统计 - -## Install - -```sh -npm install @vuepress-plume/plugin-baidu-tongji -# or -pnpm add @vuepress-plume/plugin-baidu-tongji -# or -yarn add @vuepress-plume/plugin-baidu-tongji -``` - -## Usage - -``` js -// .vuepress/config.[jt]s -import { baiduTongjiPlugin } from '@vuepress-plume/plugin-baidu-tongji' - -export default { - // ... - plugins: [ - baiduTongjiPlugin({ - key: '', // 百度统计使用的 key - }) - ] - // ... -} -``` diff --git a/plugins/plugin-baidu-tongji/package.json b/plugins/plugin-baidu-tongji/package.json deleted file mode 100644 index 7526b8a6..00000000 --- a/plugins/plugin-baidu-tongji/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "@vuepress-plume/plugin-baidu-tongji", - "type": "module", - "version": "1.0.0-rc.80", - "description": "The Plugin for VuePress 2 - baidu tongji", - "author": "pengzhanbo (https://github.com/pengzhanbo/)", - "license": "MIT", - "homepage": "https://github.com/pengzhanbo/vuepress-theme-plume#readme", - "repository": { - "type": "git", - "url": "git+https://github.com/pengzhanbo/vuepress-theme-plume.git", - "directory": "plugins/plugin-baidu-tongji" - }, - "bugs": { - "url": "https://github.com/pengzhanbo/vuepress-theme-plume/issues" - }, - "exports": { - ".": { - "types": "./lib/node/index.d.ts", - "import": "./lib/node/index.js" - }, - "./package.json": "./package.json" - }, - "main": "lib/node/index.js", - "types": "./lib/node/index.d.ts", - "files": [ - "lib" - ], - "scripts": { - "build": "pnpm run copy && pnpm run ts", - "clean": "rimraf --glob ./lib ./*.tsbuildinfo", - "copy": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png}\" lib", - "ts": "tsc -b tsconfig.build.json" - }, - "peerDependencies": { - "vuepress": "2.0.0-rc.14" - }, - "publishConfig": { - "access": "public" - }, - "keyword": [ - "VuePress", - "vuepress plugin", - "baiduTongji", - "vuepress-plugin-baidu-tongji" - ] -} diff --git a/plugins/plugin-baidu-tongji/src/client/composables/index.ts b/plugins/plugin-baidu-tongji/src/client/composables/index.ts deleted file mode 100644 index 52ad390c..00000000 --- a/plugins/plugin-baidu-tongji/src/client/composables/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { watch } from 'vue' -import { usePageData } from 'vuepress/client' - -declare global { - interface Window { - _hmt?: [name: string, options: any][] - } -} - -/** - * Add baidu analytics to the site - * - * @see https://tongji.baidu.com/ - * @see https://tongji.baidu.com/holmes/Analytics/%E7%99%BE%E5%BA%A6%E7%BB%9F%E8%AE%A1%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C - * @see https://tongji.baidu.com/holmes/Analytics/%E6%8A%80%E6%9C%AF%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97/JS%20API/JS%20API%E6%8A%80%E6%9C%AF%E6%96%87%E6%A1%A3/_trackPageview - */ -export function useBaiduTongji(): void { - if (!window._hmt) - return - - const page = usePageData() - - watch( - () => page.value.path, - (newLocation) => { - window._hmt?.push(['_trackPageview', newLocation]) - }, - ) -} diff --git a/plugins/plugin-baidu-tongji/src/client/config.ts b/plugins/plugin-baidu-tongji/src/client/config.ts deleted file mode 100644 index 93a9accf..00000000 --- a/plugins/plugin-baidu-tongji/src/client/config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { defineClientConfig } from 'vuepress/client' -import type { ClientConfig } from 'vuepress/client' -import { useBaiduTongji } from './composables/index.js' - -declare const __VUEPRESS_SSR__: boolean - -export default defineClientConfig({ - setup() { - if (__VUEPRESS_SSR__) - return - - useBaiduTongji() - }, -}) as ClientConfig diff --git a/plugins/plugin-baidu-tongji/src/node/index.ts b/plugins/plugin-baidu-tongji/src/node/index.ts deleted file mode 100644 index 50b31d98..00000000 --- a/plugins/plugin-baidu-tongji/src/node/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { baiduTongjiPlugin } from './plugin.js' - -export * from './plugin.js' - -export default baiduTongjiPlugin diff --git a/plugins/plugin-baidu-tongji/src/node/plugin.ts b/plugins/plugin-baidu-tongji/src/node/plugin.ts deleted file mode 100644 index a4370bfd..00000000 --- a/plugins/plugin-baidu-tongji/src/node/plugin.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { Plugin, PluginObject } from 'vuepress/core' -import { getDirname, path } from 'vuepress/utils' - -export interface BaiduTongjiOptions { - key?: string -} - -const __dirname = getDirname(import.meta.url) - -export function baiduTongjiPlugin({ key = '' }: BaiduTongjiOptions): Plugin { - return (app) => { - const plugin: PluginObject = { - name: '@vuepress-plume/plugin-baidu-tongji', - } - - if (app.env.isDev) - return plugin - - return { - ...plugin, - clientConfigFile: path.resolve(__dirname, '../client/config.js'), - extendsPage: (page) => { - page.frontmatter.head ??= [] - page.frontmatter.head?.push([ - 'script', - { type: 'text/javascript' }, - 'window._hmt = window._hmt || []', - ]) - page.frontmatter.head?.push([ - 'script', - { src: `https://hm.baidu.com/hm.js?${key}`, async: true }, - ]) - }, - } - } -} diff --git a/plugins/plugin-baidu-tongji/tsconfig.build.json b/plugins/plugin-baidu-tongji/tsconfig.build.json deleted file mode 100644 index 8445d924..00000000 --- a/plugins/plugin-baidu-tongji/tsconfig.build.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "composite": true, - "rootDir": "./src", - "outDir": "./lib" - }, - "files": [], - "include": ["./src"] -} diff --git a/plugins/plugin-content-update/package.json b/plugins/plugin-content-update/package.json index f553fb77..6565d470 100644 --- a/plugins/plugin-content-update/package.json +++ b/plugins/plugin-content-update/package.json @@ -31,10 +31,10 @@ "lib" ], "scripts": { - "build": "pnpm run copy && pnpm run ts", - "clean": "rimraf --glob ./lib ./*.tsbuildinfo", + "build": "pnpm run copy && pnpm run tsup", + "clean": "rimraf --glob ./lib", "copy": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png}\" lib", - "ts": "tsc -b tsconfig.build.json" + "tsup": "tsup --config tsup.config.ts" }, "peerDependencies": { "vuepress": "2.0.0-rc.14" diff --git a/plugins/plugin-content-update/src/client/clientConfig.ts b/plugins/plugin-content-update/src/client/config.ts similarity index 100% rename from plugins/plugin-content-update/src/client/clientConfig.ts rename to plugins/plugin-content-update/src/client/config.ts diff --git a/plugins/plugin-content-update/src/node/plugin.ts b/plugins/plugin-content-update/src/node/plugin.ts index 6d041dee..cff5534a 100644 --- a/plugins/plugin-content-update/src/node/plugin.ts +++ b/plugins/plugin-content-update/src/node/plugin.ts @@ -6,6 +6,6 @@ const __dirname = getDirname(import.meta.url) export function contentUpdatePlugin(): Plugin { return { name: '@vuepress-plume/plugin-content-update', - clientConfigFile: path.resolve(__dirname, '../client/clientConfig.js'), + clientConfigFile: path.resolve(__dirname, '../client/config.js'), } } diff --git a/plugins/plugin-content-update/tsconfig.build.json b/plugins/plugin-content-update/tsconfig.build.json deleted file mode 100644 index 6bf67375..00000000 --- a/plugins/plugin-content-update/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../tsconfig.build.json", - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib" - }, - "include": ["./src"] -} diff --git a/plugins/plugin-content-update/tsup.config.ts b/plugins/plugin-content-update/tsup.config.ts new file mode 100644 index 00000000..82f5d4ea --- /dev/null +++ b/plugins/plugin-content-update/tsup.config.ts @@ -0,0 +1,52 @@ +import { type Options, defineConfig } from 'tsup' + +const clientExternal: (string | RegExp)[] = [ + /.*\.vue$/, + /.*\.css$/, +] + +export default defineConfig(() => { + const DEFAULT_OPTIONS: Options = { + dts: true, + sourcemap: false, + splitting: false, + format: 'esm', + } + return [ + // node + { + ...DEFAULT_OPTIONS, + entry: ['./src/node/index.ts'], + outDir: './lib/node', + target: 'node18', + }, + // client/composables/index.js + { + ...DEFAULT_OPTIONS, + entry: ['./src/client/composables/index.ts'], + outDir: './lib/client/composables', + external: clientExternal, + }, + // client/components/index.js + { + ...DEFAULT_OPTIONS, + entry: ['./src/client/components/Content.ts'], + outDir: './lib/client/components', + external: [...clientExternal, '../composables/index.js'], + }, + // client/config.js + { + ...DEFAULT_OPTIONS, + entry: ['./src/client/config.ts'], + outDir: './lib/client', + external: [...clientExternal, './components/Content.js'], + }, + // client/index.js + { + ...DEFAULT_OPTIONS, + entry: ['./src/client/index.ts'], + outDir: './lib/client', + external: [...clientExternal, './components/Content.js', './composables/index.js'], + }, + ] +}) diff --git a/plugins/plugin-fonts/package.json b/plugins/plugin-fonts/package.json index f2fa3be5..f6b633ec 100644 --- a/plugins/plugin-fonts/package.json +++ b/plugins/plugin-fonts/package.json @@ -27,10 +27,10 @@ "lib" ], "scripts": { - "build": "pnpm run copy && pnpm run ts", - "clean": "rimraf --glob ./lib ./*.tsbuildinfo", + "build": "pnpm run copy && pnpm run tsup", + "clean": "rimraf --glob ./lib", "copy": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png,woff2}\" lib", - "ts": "tsc -b tsconfig.build.json" + "tsup": "tsup --config tsup.config.ts" }, "peerDependencies": { "vuepress": "2.0.0-rc.14" diff --git a/plugins/plugin-fonts/tsconfig.build.json b/plugins/plugin-fonts/tsconfig.build.json deleted file mode 100644 index 6bf67375..00000000 --- a/plugins/plugin-fonts/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../tsconfig.build.json", - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib" - }, - "include": ["./src"] -} diff --git a/plugins/plugin-fonts/tsup.config.ts b/plugins/plugin-fonts/tsup.config.ts new file mode 100644 index 00000000..5ee9cc4e --- /dev/null +++ b/plugins/plugin-fonts/tsup.config.ts @@ -0,0 +1,31 @@ +import { type Options, defineConfig } from 'tsup' + +const clientExternal: (string | RegExp)[] = [ + /.*\.vue$/, + /.*\.css$/, +] + +export default defineConfig(() => { + const DEFAULT_OPTIONS: Options = { + dts: true, + sourcemap: false, + splitting: false, + format: 'esm', + } + return [ + // node + { + ...DEFAULT_OPTIONS, + entry: ['./src/node/index.ts'], + outDir: './lib/node', + target: 'node18', + }, + // client/config.js + { + ...DEFAULT_OPTIONS, + entry: ['./src/client/config.ts'], + outDir: './lib/client', + external: clientExternal, + }, + ] +}) diff --git a/plugins/plugin-iconify/package.json b/plugins/plugin-iconify/package.json index 76abd91a..bad94e23 100644 --- a/plugins/plugin-iconify/package.json +++ b/plugins/plugin-iconify/package.json @@ -19,10 +19,6 @@ "types": "./lib/node/index.d.ts", "import": "./lib/node/index.js" }, - "./client": { - "types": "./lib/client/index.d.ts", - "import": "./lib/client/index.js" - }, "./package.json": "./package.json" }, "main": "lib/node/index.js", @@ -31,10 +27,10 @@ "lib" ], "scripts": { - "build": "pnpm run copy && pnpm run ts", - "clean": "rimraf --glob ./lib ./*.tsbuildinfo", + "build": "pnpm run copy && pnpm run tsup", + "clean": "rimraf --glob ./lib", "copy": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png}\" lib", - "ts": "tsc -b tsconfig.build.json" + "tsup": "tsup --config tsup.config.ts" }, "peerDependencies": { "vuepress": "2.0.0-rc.14" diff --git a/plugins/plugin-iconify/src/client/components/Iconify.vue b/plugins/plugin-iconify/src/client/components/Iconify.vue index 977b8dc6..cd675ccb 100644 --- a/plugins/plugin-iconify/src/client/components/Iconify.vue +++ b/plugins/plugin-iconify/src/client/components/Iconify.vue @@ -4,7 +4,7 @@ import { ClientOnly } from 'vuepress/client' import type { IconifyRenderMode } from '@iconify/vue' import type { StyleValue } from 'vue' import { computed, toRefs } from 'vue' -import { useIconify } from '../composables/iconify.js' +import { useIconify } from '../composables/index.js' const props = withDefaults( defineProps<{ @@ -31,13 +31,13 @@ const { name } = toRefs(props) const { icon, loaded } = useIconify(name) const size = computed(() => { - const size = props.size || __VUEPRESS_PLUGIN_ICONIFY_DEFAULT_SIZE__ + const size = props.size || __VP_ICONIFY_SIZE__ if (String(Number(size)) === size) return `${size}px` return size }) -const color = computed(() => props.color || __VUEPRESS_PLUGIN_ICONIFY_DEFAULT_COLOR__) +const color = computed(() => props.color || __VP_ICONIFY_COLOR__) const bind = computed(() => ({ icon: icon.value, @@ -55,8 +55,8 @@ const bind = computed(() => ({