Skip to content

Commit e7b24dd

Browse files
docs: use pnpm as the recommended package manager (#929)
Co-authored-by: meteorlxy <[email protected]>
1 parent b4e9ca6 commit e7b24dd

File tree

10 files changed

+245
-106
lines changed

10 files changed

+245
-106
lines changed

docs/README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ features:
1919
- title: Themes
2020
details: Providing a default theme out of the box. You can also choose a community theme or create your own one.
2121
- title: Plugins
22-
details: Flexible plugin API, allowing plugins to provide lots of plug-and-play features for your site.
22+
details: Flexible plugin API, allowing plugins to provide lots of plug-and-play features for your site.
2323
- title: Bundlers
2424
details: Default bundler is Vite, while Webpack is also supported. Choose the one you like!
2525
footer: MIT Licensed | Copyright © 2018-present Evan You
@@ -28,7 +28,25 @@ footer: MIT Licensed | Copyright © 2018-present Evan You
2828
### As Easy as 1, 2, 3
2929

3030
<CodeGroup>
31-
<CodeGroupItem title="YARN" active>
31+
<CodeGroupItem title="PNPM" active>
32+
33+
```bash
34+
# install in your project
35+
pnpm add -D vuepress@next @vuepress/client@next vue
36+
37+
# create a markdown file
38+
echo '# Hello VuePress' > README.md
39+
40+
# start writing
41+
pnpm vuepress dev
42+
43+
# build to static files
44+
pnpm vuepress build
45+
```
46+
47+
</CodeGroupItem>
48+
49+
<CodeGroupItem title="YARN">
3250

3351
```bash
3452
# install in your project

docs/guide/bundler.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ When using the [vuepress](https://www.npmjs.com/package/vuepress) package, Vite
99
If you want to use Webpack bundler instead, you can remove it and install the [vuepress-webpack](https://www.npmjs.com/package/vuepress-webpack) package instead:
1010

1111
<CodeGroup>
12-
<CodeGroupItem title="YARN" active>
12+
<CodeGroupItem title="PNPM" active>
13+
14+
```bash
15+
pnpm remove vuepress
16+
pnpm add -D vuepress-webpack@next
17+
```
18+
19+
</CodeGroupItem>
20+
21+
<CodeGroupItem title="YARN">
1322

1423
```bash
1524
yarn remove vuepress

docs/guide/deployment.md

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The following guides are based on some shared assumptions:
44

55
- You are placing your Markdown source files inside the `docs` directory of your project;
66
- You are using the default build output location (`.vuepress/dist`);
7-
- You are using [yarn classic](https://classic.yarnpkg.com/en/) as package manager, while npm is also supported;
7+
- You are using as [pnpm](https://pnpm.io) package manager, while npm and yarn are also supported;
88
- VuePress is installed as a local dependency in your project, and you have setup the following script in `package.json`:
99

1010
```json
@@ -19,13 +19,13 @@ The following guides are based on some shared assumptions:
1919

2020
1. Set the correct [base](../reference/config.md#base) config.
2121

22-
If you are deploying to `https://<USERNAME>.github.io/`, you can omit this step as `base` defaults to `"/"`.
22+
If you are deploying to `https://<USERNAME>.github.io/`, you can omit this step as `base` defaults to `"/"`.
2323

24-
If you are deploying to `https://<USERNAME>.github.io/<REPO>/`, for example your repository is at `https://github.com/<USERNAME>/<REPO>`, then set `base` to `"/<REPO>/"`.
24+
If you are deploying to `https://<USERNAME>.github.io/<REPO>/`, for example your repository is at `https://github.com/<USERNAME>/<REPO>`, then set `base` to `"/<REPO>/"`.
2525

2626
2. Choose your preferred CI tools. Here we take [GitHub Actions](https://github.com/features/actions) as an example.
2727

28-
Create `.github/workflows/docs.yml` to set up the workflow.
28+
Create `.github/workflows/docs.yml` to set up the workflow.
2929

3030
::: details Click to expand sample config
3131
```yaml
@@ -43,36 +43,30 @@ jobs:
4343
runs-on: ubuntu-latest
4444

4545
steps:
46-
- uses: actions/checkout@v2
46+
- uses: actions/checkout@v3
4747
with:
4848
# fetch all commits to get last updated time or other git log info
4949
fetch-depth: 0
5050

51-
- name: Setup Node.js
52-
uses: actions/setup-node@v1
51+
- name: Setup pnpm
52+
uses: pnpm/action-setup@v2
5353
with:
54-
# choose node.js version to use
55-
node-version: '14'
54+
# choose pnpm version to use
55+
version: 7
56+
# install deps with pnpm
57+
run_install: true
5658

57-
# cache node_modules
58-
- name: Cache dependencies
59-
uses: actions/cache@v2
60-
id: yarn-cache
59+
- name: Setup Node.js
60+
uses: actions/setup-node@v3
6161
with:
62-
path: |
63-
**/node_modules
64-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
65-
restore-keys: |
66-
${{ runner.os }}-yarn-
67-
68-
# install dependencies if the cache did not hit
69-
- name: Install dependencies
70-
if: steps.yarn-cache.outputs.cache-hit != 'true'
71-
run: yarn --frozen-lockfile
62+
# choose node.js version to use
63+
node-version: 18
64+
# cache deps for pnpm
65+
cache: pnpm
7266

7367
# run build script
7468
- name: Build VuePress site
75-
run: yarn docs:build
69+
run: pnpm docs:build
7670

7771
# please check out the docs of the workflow for more details
7872
# @see https://github.com/crazy-max/ghaction-github-pages
@@ -97,35 +91,43 @@ Please refer to [GitHub Pages official guide](https://pages.github.com/) for mor
9791
9892
1. Set the correct [base](../reference/config.md#base) config.
9993
100-
If you are deploying to `https://<USERNAME>.gitlab.io/`, you can omit `base` as it defaults to `"/"`.
94+
If you are deploying to `https://<USERNAME>.gitlab.io/`, you can omit `base` as it defaults to `"/"`.
10195

102-
If you are deploying to `https://<USERNAME>.gitlab.io/<REPO>/`, for example your repository is at `https://gitlab.com/<USERNAME>/<REPO>`, then set `base` to `"/<REPO>/"`.
96+
If you are deploying to `https://<USERNAME>.gitlab.io/<REPO>/`, for example your repository is at `https://gitlab.com/<USERNAME>/<REPO>`, then set `base` to `"/<REPO>/"`.
10397

10498
2. Create `.gitlab-ci.yml` to set up [GitLab CI](https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/) workflow.
10599

106100
::: details Click to expand sample config
107101
```yaml
108102
# choose a docker image to use
109-
image: node:14-buster
103+
image: node:18-buster
110104
111105
pages:
112106
# trigger deployment on every push to main branch
113107
only:
114-
- main
108+
- main
115109
116110
# cache node_modules
117111
cache:
112+
key:
113+
files:
114+
- pnpm-lock.yaml
118115
paths:
119-
- node_modules/
116+
- .pnpm-store
117+
118+
# Install pnpm
119+
before_script:
120+
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7
121+
- pnpm config set store-dir .pnpm-store
120122
121123
# install dependencies and run build script
122124
script:
123-
- yarn --frozen-lockfile
124-
- yarn docs:build --dest public
125+
- pnpm i --frozen-lockfile
126+
- pnpm docs:build --dest public
125127
126128
artifacts:
127129
paths:
128-
- public
130+
- public
129131
```
130132
:::
131133

@@ -160,7 +162,7 @@ Please refer to [GitLab Pages official guide](https://docs.gitlab.com/ce/user/pr
160162
}
161163
```
162164

163-
3. After running `yarn docs:build`, deploy using the command `firebase deploy`.
165+
3. After running `pnpm docs:build`, deploy using the command `firebase deploy`.
164166

165167
::: tip
166168
Please refer to [Firebase CLI official guide](https://firebase.google.com/docs/cli) for more details.
@@ -198,21 +200,21 @@ See [Layer0 Documentation > Framework Guides > VuePress](https://docs.layer0.co/
198200

199201
1. On [Netlify](https://netlify.com), set up a new project from GitHub with the following settings:
200202

201-
- **Build Command:** `yarn docs:build`
202-
- **Publish directory:** `docs/.vuepress/dist`
203+
- **Build Command:** `pnpm docs:build`
204+
- **Publish directory:** `docs/.vuepress/dist`
203205

204206
2. Set [Environment variables](https://docs.netlify.com/configure-builds/environment-variables) to choose node version:
205207

206-
- `NODE_VERSION`: 14
208+
- `NODE_VERSION`: 14
207209

208210
3. Hit the deploy button.
209211

210212
## Vercel
211213

212214
1. Go to [Vercel](https://vercel.com), set up a new project from GitHub with the following settings:
213215

214-
- **FRAMEWORK PRESET:** `Other`
215-
- **BUILD COMMAND:** `yarn docs:build`
216-
- **OUTPUT DIRECTORY:** `docs/.vuepress/dist`
217-
216+
- **FRAMEWORK PRESET:** `Other`
217+
- **BUILD COMMAND:** `pnpm docs:build`
218+
- **OUTPUT DIRECTORY:** `docs/.vuepress/dist`
219+
218220
2. Hit the deploy button.

docs/guide/getting-started.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ cd vuepress-starter
2828
- **Step 2**: Initialize your project
2929

3030
<CodeGroup>
31-
<CodeGroupItem title="YARN" active>
31+
<CodeGroupItem title="PNPM" active>
32+
33+
```bash
34+
git init
35+
pnpm init
36+
```
37+
38+
</CodeGroupItem>
39+
40+
<CodeGroupItem title="YARN">
3241

3342
```bash
3443
git init
@@ -50,7 +59,15 @@ npm init
5059
- **Step 3**: Install VuePress locally
5160

5261
<CodeGroup>
53-
<CodeGroupItem title="YARN" active>
62+
<CodeGroupItem title="PNPM" active>
63+
64+
```bash
65+
pnpm add -D vuepress@next @vuepress/client@next vue
66+
```
67+
68+
</CodeGroupItem>
69+
70+
<CodeGroupItem title="YARN">
5471

5572
```bash
5673
yarn add -D vuepress@next
@@ -96,7 +113,15 @@ echo '# Hello VuePress' > docs/README.md
96113
- **Step 7**: Serve the documentation site in the local server
97114

98115
<CodeGroup>
99-
<CodeGroupItem title="YARN" active>
116+
<CodeGroupItem title="PNPM" active>
117+
118+
```bash
119+
pnpm docs:dev
120+
```
121+
122+
</CodeGroupItem>
123+
124+
<CodeGroupItem title="YARN">
100125

101126
```bash
102127
yarn docs:dev
@@ -113,6 +138,6 @@ npm run docs:dev
113138
</CodeGroupItem>
114139
</CodeGroup>
115140

116-
VuePress will start a hot-reloading development server at [http://localhost:8080](http://localhost:8080). When you modify your markdown files, the content in the browser will be auto updated.
141+
VuePress will start a hot-reloading development server at [http://localhost:8080](http://localhost:8080). When you modify your markdown files, the content in the browser will be auto updated.
117142

118143
By now, you should have a basic but functional VuePress documentation site. Next, learn about the basics of [configuration](./configuration.md) in VuePress.

docs/reference/default-theme/components.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,18 @@
5959

6060
````md
6161
<CodeGroup>
62+
<CodeGroupItem title="PNPM">
63+
64+
```bash:no-line-numbers
65+
pnpm install
66+
```
67+
68+
</CodeGroupItem>
69+
6270
<CodeGroupItem title="YARN">
6371

6472
```bash:no-line-numbers
65-
yarn
73+
yarn install
6674
```
6775

6876
</CodeGroupItem>
@@ -80,10 +88,18 @@ npm install
8088
**Output**
8189

8290
<CodeGroup>
91+
<CodeGroupItem title="PNPM">
92+
93+
```bash:no-line-numbers
94+
pnpm install
95+
```
96+
97+
</CodeGroupItem>
98+
8399
<CodeGroupItem title="YARN">
84100

85101
```bash:no-line-numbers
86-
yarn
102+
yarn install
87103
```
88104

89105
</CodeGroupItem>

docs/zh/README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,25 @@ footer: MIT Licensed | Copyright © 2018-present Evan You
2828
### 像数 1, 2, 3 一样容易
2929

3030
<CodeGroup>
31-
<CodeGroupItem title="YARN" active>
31+
<CodeGroupItem title="PNPM" active>
32+
33+
```bash
34+
# 在你的项目中安装
35+
pnpm add -D vuepress@next @vuepress/client@next vue
36+
37+
# 新建一个 markdown 文件
38+
echo '# Hello VuePress' > README.md
39+
40+
# 开始写作
41+
pnpm vuepress dev
42+
43+
# 构建静态文件
44+
pnpm vuepress build
45+
```
46+
47+
</CodeGroupItem>
48+
49+
<CodeGroupItem title="YARN">
3250

3351
```bash
3452
# 在你的项目中安装

docs/zh/guide/bundler.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ VuePress 一直以来都在使用 [Webpack](https://webpack.js.org/) 作为打
99
如果你想改为使用 Webpack 打包工具,那么你可以移除它,改为安装 [vuepress-webpack](https://www.npmjs.com/package/vuepress-webpack) 包:
1010

1111
<CodeGroup>
12-
<CodeGroupItem title="YARN" active>
12+
<CodeGroupItem title="PNPM" active>
13+
14+
```bash
15+
pnpm uninstall vuepress
16+
pnpm add -D vuepress-webpack@next
17+
```
18+
19+
</CodeGroupItem>
20+
21+
<CodeGroupItem title="YARN">
1322

1423
```bash
1524
yarn remove vuepress

0 commit comments

Comments
 (0)