Skip to content

Commit b85b1c3

Browse files
authored
refactor: drop support for using bundler, theme and plugins by name (#843)
- fix: solve client code circular reference issue - build: move from yarn to pnpm - build: pre-bundler client and shared package BREAKING CHANGE: config `bundler` should import the bundler directly, and `bundlerConfig` has been removed BREAKING CHANGE: config `theme` should import the theme directly, and `themeConfig` has been removed BREAKING CHANGE: config `plugins` should import the plugins directly BREAKING CHANGE: theme API `plugins` should import the plugins directly BREAKING CHANGE: theme API `extends` should import the parent theme directly BREAKING CHANGE: plugin function and theme function should no longer accept user options as the first param, please check out the guide for how to write a plugin and a theme
1 parent 9d40851 commit b85b1c3

File tree

301 files changed

+12387
-15088
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

301 files changed

+12387
-15088
lines changed

.eslintignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
node_modules/
1+
!.vuepress/
2+
!.*.js
3+
.cache/
24
.temp/
5+
node_modules/
36
lib/
47
dist/
5-
!.vuepress/
6-
!.*.js

.eslintrc.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ module.exports = {
5555
rules: {
5656
'@typescript-eslint/explicit-function-return-type': 'off',
5757
'vue/one-component-per-file': 'off',
58-
'import/no-extraneous-dependencies': 'off',
59-
},
60-
},
61-
{
62-
files: ['docs/**'],
63-
rules: {
64-
'import/no-extraneous-dependencies': 'off',
58+
'import/no-extraneous-dependencies': [
59+
'error',
60+
{
61+
devDependencies: true,
62+
optionalDependencies: false,
63+
peerDependencies: false,
64+
},
65+
],
6566
},
6667
},
6768
],

.github/workflows/check-docs.yml

+10-5
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,31 @@ jobs:
1818
matrix:
1919
os: [ubuntu-latest, windows-latest, macos-latest]
2020
node: ['14', '16']
21-
bundler: ['@vuepress/vite', '@vuepress/webpack']
21+
bundler: ['vite', 'webpack']
2222

2323
runs-on: ${{ matrix.os }}
2424

2525
steps:
2626
- uses: actions/checkout@v3
2727

28+
- name: Install pnpm
29+
uses: pnpm/action-setup@v2
30+
with:
31+
version: 6
32+
2833
- name: Use Node.js ${{ matrix.node }}
2934
uses: actions/setup-node@v3
3035
with:
3136
node-version: ${{ matrix.node }}
32-
cache: yarn
37+
cache: pnpm
3338

3439
- name: Install dependencies
35-
run: yarn --frozen-lockfile
40+
run: pnpm install --frozen-lockfile
3641

3742
- name: Copy and build
38-
run: yarn copy && yarn build
43+
run: pnpm copy && pnpm build
3944

4045
- name: Build docs with ${{ matrix.bundler }}
41-
run: yarn docs:build
46+
run: pnpm docs:build
4247
env:
4348
DOCS_BUNDLER: ${{ matrix.bundler }}

.github/workflows/check.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,28 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v3
2626

27+
- name: Install pnpm
28+
uses: pnpm/action-setup@v2
29+
with:
30+
version: 6
31+
2732
- name: Use Node.js ${{ matrix.node }}
2833
uses: actions/setup-node@v3
2934
with:
3035
node-version: ${{ matrix.node }}
31-
cache: yarn
36+
cache: pnpm
3237

3338
- name: Install dependencies
34-
run: yarn --frozen-lockfile
39+
run: pnpm i --frozen-lockfile
3540

3641
- name: Lint
37-
run: yarn lint
42+
run: pnpm lint
3843

3944
- name: Copy
40-
run: yarn copy
45+
run: pnpm copy
4146

4247
- name: Build
43-
run: yarn build
48+
run: pnpm build
4449

4550
- name: Test
46-
run: yarn test
51+
run: pnpm test

.github/workflows/coverage.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,25 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v3
2424

25+
- name: Install pnpm
26+
uses: pnpm/action-setup@v2
27+
with:
28+
version: 6
29+
2530
- name: Setup Node.js
2631
uses: actions/setup-node@v3
2732
with:
2833
node-version: ${{ env.NODE_VERSION }}
29-
cache: yarn
34+
cache: pnpm
3035

3136
- name: Install dependencies
32-
run: yarn --frozen-lockfile
37+
run: pnpm install --frozen-lockfile
38+
39+
- name: Copy and build
40+
run: pnpm copy && pnpm build
3341

3442
- name: Test coverage
35-
run: yarn test:coverage
43+
run: pnpm test -- --coverage
3644

3745
- name: Coveralls
3846
uses: coverallsapp/github-action@master

.github/workflows/docs.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,22 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24+
- name: Install pnpm
25+
uses: pnpm/action-setup@v2
26+
with:
27+
version: 6
28+
2429
- name: Setup Node.js
2530
uses: actions/setup-node@v3
2631
with:
2732
node-version: ${{ env.NODE_VERSION }}
28-
cache: yarn
33+
cache: pnpm
2934

3035
- name: Install dependencies
31-
run: yarn --frozen-lockfile
36+
run: pnpm install --frozen-lockfile
3237

3338
- name: Build documentation site
34-
run: yarn docs:release
39+
run: pnpm docs:release
3540

3641
- name: Deploy to GitHub Pages
3742
uses: crazy-max/[email protected]

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ docs/.vuepress/.cache/
44
docs/.vuepress/dist/
55

66
# Dist files
7+
dist/
78
lib/
89

910
# Test temp files

.husky/commit-msg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn commitlint --edit $1
4+
pnpm commitlint --edit $1

.husky/pre-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn lint-staged
4+
pnpm lint-staged

.vscode/launch.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
"version": "0.2.0",
66
"configurations": [
77
{
8-
"type": "node",
9-
"request": "launch",
108
"name": "docs:dev",
11-
"program": "${workspaceFolder}/packages/vuepress/bin/vuepress.js",
12-
"args": ["dev", "docs"]
9+
"type": "node-terminal",
10+
"request": "launch",
11+
"command": "pnpm docs:dev"
1312
}
1413
]
1514
}

docs/.vuepress/config.ts

+64-76
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
import { viteBundler } from '@vuepress/bundler-vite'
2+
import { webpackBundler } from '@vuepress/bundler-webpack'
13
import { defineUserConfig } from '@vuepress/cli'
2-
import type { DefaultThemeOptions } from '@vuepress/theme-default'
4+
import { docsearchPlugin } from '@vuepress/plugin-docsearch'
5+
import { googleAnalyticsPlugin } from '@vuepress/plugin-google-analytics'
6+
import { registerComponentsPlugin } from '@vuepress/plugin-register-components'
7+
import { shikiPlugin } from '@vuepress/plugin-shiki'
8+
import { defaultTheme } from '@vuepress/theme-default'
39
import { path } from '@vuepress/utils'
410
import { navbar, sidebar } from './configs'
511

612
const isProd = process.env.NODE_ENV === 'production'
713

8-
export default defineUserConfig<DefaultThemeOptions>({
14+
export default defineUserConfig({
915
base: '/',
1016

1117
head: [
@@ -66,11 +72,9 @@ export default defineUserConfig<DefaultThemeOptions>({
6672

6773
bundler:
6874
// specify bundler via environment variable
69-
process.env.DOCS_BUNDLER ??
70-
// use vite by default
71-
'@vuepress/vite',
75+
process.env.DOCS_BUNDLER === 'webpack' ? webpackBundler() : viteBundler(),
7276

73-
themeConfig: {
77+
theme: defaultTheme({
7478
logo: '/images/hero.png',
7579

7680
repo: 'vuepress/vuepress-next',
@@ -141,7 +145,7 @@ export default defineUserConfig<DefaultThemeOptions>({
141145
// use shiki plugin in production mode instead
142146
prismjs: !isProd,
143147
},
144-
},
148+
}),
145149

146150
markdown: {
147151
importCode: {
@@ -154,81 +158,65 @@ export default defineUserConfig<DefaultThemeOptions>({
154158
},
155159

156160
plugins: [
157-
[
158-
'@vuepress/plugin-docsearch',
159-
{
160-
appId: '34YFD9IUQ2',
161-
apiKey: '9a9058b8655746634e01071411c366b8',
162-
indexName: 'vuepress',
163-
searchParameters: {
164-
facetFilters: ['tags:v2'],
165-
},
166-
locales: {
167-
'/zh/': {
168-
placeholder: '搜索文档',
169-
translations: {
170-
button: {
171-
buttonText: '搜索文档',
172-
buttonAriaLabel: '搜索文档',
161+
docsearchPlugin({
162+
appId: '34YFD9IUQ2',
163+
apiKey: '9a9058b8655746634e01071411c366b8',
164+
indexName: 'vuepress',
165+
searchParameters: {
166+
facetFilters: ['tags:v2'],
167+
},
168+
locales: {
169+
'/zh/': {
170+
placeholder: '搜索文档',
171+
translations: {
172+
button: {
173+
buttonText: '搜索文档',
174+
buttonAriaLabel: '搜索文档',
175+
},
176+
modal: {
177+
searchBox: {
178+
resetButtonTitle: '清除查询条件',
179+
resetButtonAriaLabel: '清除查询条件',
180+
cancelButtonText: '取消',
181+
cancelButtonAriaLabel: '取消',
182+
},
183+
startScreen: {
184+
recentSearchesTitle: '搜索历史',
185+
noRecentSearchesText: '没有搜索历史',
186+
saveRecentSearchButtonTitle: '保存至搜索历史',
187+
removeRecentSearchButtonTitle: '从搜索历史中移除',
188+
favoriteSearchesTitle: '收藏',
189+
removeFavoriteSearchButtonTitle: '从收藏中移除',
190+
},
191+
errorScreen: {
192+
titleText: '无法获取结果',
193+
helpText: '你可能需要检查你的网络连接',
173194
},
174-
modal: {
175-
searchBox: {
176-
resetButtonTitle: '清除查询条件',
177-
resetButtonAriaLabel: '清除查询条件',
178-
cancelButtonText: '取消',
179-
cancelButtonAriaLabel: '取消',
180-
},
181-
startScreen: {
182-
recentSearchesTitle: '搜索历史',
183-
noRecentSearchesText: '没有搜索历史',
184-
saveRecentSearchButtonTitle: '保存至搜索历史',
185-
removeRecentSearchButtonTitle: '从搜索历史中移除',
186-
favoriteSearchesTitle: '收藏',
187-
removeFavoriteSearchButtonTitle: '从收藏中移除',
188-
},
189-
errorScreen: {
190-
titleText: '无法获取结果',
191-
helpText: '你可能需要检查你的网络连接',
192-
},
193-
footer: {
194-
selectText: '选择',
195-
navigateText: '切换',
196-
closeText: '关闭',
197-
searchByText: '搜索提供者',
198-
},
199-
noResultsScreen: {
200-
noResultsText: '无法找到相关结果',
201-
suggestedQueryText: '你可以尝试查询',
202-
openIssueText: '你认为该查询应该有结果?',
203-
openIssueLinkText: '点击反馈',
204-
},
195+
footer: {
196+
selectText: '选择',
197+
navigateText: '切换',
198+
closeText: '关闭',
199+
searchByText: '搜索提供者',
200+
},
201+
noResultsScreen: {
202+
noResultsText: '无法找到相关结果',
203+
suggestedQueryText: '你可以尝试查询',
204+
reportMissingResultsText: '你认为该查询应该有结果?',
205+
reportMissingResultsLinkText: '点击反馈',
205206
},
206207
},
207208
},
208209
},
209210
},
210-
],
211-
[
212-
'@vuepress/plugin-google-analytics',
213-
{
214-
// we have multiple deployments, which would use different id
215-
id: process.env.DOCS_GA_ID,
216-
},
217-
],
218-
[
219-
'@vuepress/plugin-register-components',
220-
{
221-
componentsDir: path.resolve(__dirname, './components'),
222-
},
223-
],
211+
}),
212+
googleAnalyticsPlugin({
213+
// we have multiple deployments, which would use different id
214+
id: process.env.DOCS_GA_ID ?? '',
215+
}),
216+
registerComponentsPlugin({
217+
componentsDir: path.resolve(__dirname, './components'),
218+
}),
224219
// only enable shiki plugin in production mode
225-
[
226-
'@vuepress/plugin-shiki',
227-
isProd
228-
? {
229-
theme: 'dark-plus',
230-
}
231-
: false,
232-
],
220+
isProd ? shikiPlugin({ theme: 'dark-plus' }) : [],
233221
],
234222
})

docs/.vuepress/configs/meta.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { version } from '../../../lerna.json'
1+
export const { version } = require('@vuepress/core/package.json')

0 commit comments

Comments
 (0)