Skip to content

Commit 8dc7092

Browse files
committed
chore: switch to pnpm and add preview fixture
- Update GitHub Actions to use pnpm and the new lockfile - Add an isolated Hexo preview site with local worktree helpers - Exclude the preview fixture from published npm packages
1 parent f4954a8 commit 8dc7092

73 files changed

Lines changed: 10644 additions & 1465 deletions

Some content is hidden

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

.github/workflows/build-and-commit.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ jobs:
2626
with:
2727
node-version: '20.x' # Specify your Node.js version
2828

29+
- name: Set up pnpm
30+
uses: pnpm/action-setup@v4
31+
with:
32+
version: 10.29.3
33+
2934
- name: Install Dependencies
30-
run: npm install
35+
run: pnpm install --frozen-lockfile
3136

3237
- name: Build Project
33-
run: npm run build
38+
run: pnpm run build
3439

3540
- name: Configure Git
3641
run: |

.github/workflows/dev-deploy.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ jobs:
2828
with:
2929
node-version: '20.x' # Specify your required Node.js version
3030

31+
- name: Set up pnpm
32+
uses: pnpm/action-setup@v4
33+
with:
34+
version: 10.29.3
35+
3136
- name: Clone Hexo site repository
3237
run: git clone https://github.com/EvanNotFound/redefine-demo.git hexo-site
3338

@@ -77,26 +82,26 @@ jobs:
7782
- name: Build theme assets
7883
run: |
7984
cd hexo-site/themes/redefine
80-
npm install
81-
npm run build
85+
pnpm install --frozen-lockfile
86+
pnpm run build
8287
8388
- name: Install dependencies
8489
run: |
8590
cd hexo-site
86-
npm install
91+
pnpm install --no-frozen-lockfile
8792
8893
- name: Build Hexo
8994
run: |
9095
cd hexo-site
91-
npm uninstall hexo-theme-redefine
92-
npm run build
96+
pnpm remove hexo-theme-redefine
97+
pnpm run build
9398
9499
- name: Change directory to hexo-site
95100
run: echo "HEXO_SITE_DIR=${{ github.workspace }}/hexo-site" >> $GITHUB_ENV
96101

97102
# Install Vercel CLI first to avoid bug with next step
98103
- name: Install Vercel CLI
99-
run: npm install -g vercel@latest
104+
run: pnpm add --global vercel@latest
100105

101106
- name: Deploy to Vercel Action
102107
id: deploy-to-vercel

.github/workflows/npm-publish.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ jobs:
2424
node-version: '20.x'
2525
registry-url: https://registry.npmjs.org/
2626

27-
- name: Ensure npm >= 11.5.1
28-
run: npm install -g npm@latest
27+
- name: Set up pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: 10.29.3
2931

30-
- run: npm ci
32+
- run: pnpm install --frozen-lockfile
3133

32-
- run: npm run build
34+
- run: pnpm run build
3335

3436
- run: npm publish

.github/workflows/pr-build-check.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ on:
1010
- 'source/css/**'
1111
- 'scripts/**'
1212
- 'package.json'
13-
- 'package-lock.json'
13+
- 'pnpm-lock.yaml'
14+
- 'pnpm-workspace.yaml'
15+
- 'dev/**'
1416

1517
jobs:
1618
build:
@@ -37,8 +39,13 @@ jobs:
3739
with:
3840
node-version: '20.x'
3941

42+
- name: Set up pnpm
43+
uses: pnpm/action-setup@v4
44+
with:
45+
version: 10.29.3
46+
4047
- name: Install Dependencies
41-
run: npm install
48+
run: pnpm install --frozen-lockfile
4249

4350
- name: Build Project
44-
run: npm run build
51+
run: pnpm run build

.github/workflows/pr-preview-build.yml

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,22 @@ jobs:
1919
steps:
2020
- name: Checkout Theme Repository
2121
uses: actions/checkout@v6
22-
with:
23-
path: theme
2422

2523
- name: Set up Node.js
2624
uses: actions/setup-node@v6
2725
with:
2826
node-version: "20.x"
2927

28+
- name: Set up pnpm
29+
uses: pnpm/action-setup@v4
30+
with:
31+
version: 10.29.3
32+
3033
- name: Set up Python
3134
uses: actions/setup-python@v6
3235
with:
3336
python-version: "3.x"
3437

35-
- name: Clone Hexo Site Repository
36-
run: git clone https://github.com/EvanNotFound/redefine-demo.git hexo-site
37-
38-
- name: Move Theme into Hexo Site
39-
run: |
40-
mkdir -p hexo-site/themes
41-
rm -rf hexo-site/themes/redefine
42-
mv theme hexo-site/themes/redefine
43-
4438
- name: Enable Developer Mode and Disable CDN
4539
run: |
4640
python -m pip install --upgrade pip
@@ -49,7 +43,7 @@ jobs:
4943
import yaml
5044
from pathlib import Path
5145
52-
config_path = Path("hexo-site/_config.redefine.yml")
46+
config_path = Path("dev/site/_config.redefine.yml")
5347
data = yaml.safe_load(config_path.read_text()) or {}
5448
data.setdefault("developer", {})
5549
data["developer"]["enable"] = True
@@ -60,42 +54,23 @@ jobs:
6054
)
6155
PY
6256
63-
- name: Install Theme Dependencies
64-
working-directory: hexo-site/themes/redefine
65-
run: |
66-
if [ -f package-lock.json ]; then
67-
npm ci
68-
else
69-
npm install
70-
fi
57+
- name: Install Dependencies
58+
run: pnpm install --frozen-lockfile
7159

7260
- name: Build Theme Assets
73-
working-directory: hexo-site/themes/redefine
74-
run: npm run build
75-
76-
- name: Install Hexo Dependencies
77-
working-directory: hexo-site
78-
run: |
79-
if [ -f package-lock.json ]; then
80-
npm ci
81-
else
82-
npm install
83-
fi
61+
run: pnpm run build
8462

8563
- name: Build Hexo Site
86-
working-directory: hexo-site
87-
run: |
88-
npm uninstall hexo-theme-redefine
89-
npm run build
64+
run: pnpm run preview:generate -- --output-dir dev/site/public
9065

9166
- name: Prepare Vercel Prebuilt Output
9267
run: |
93-
mkdir -p hexo-site/.vercel/output/static
94-
printf '{"version":3}' > hexo-site/.vercel/output/config.json
95-
cp -R hexo-site/public/. hexo-site/.vercel/output/static/
68+
mkdir -p dev/site/.vercel/output/static
69+
printf '{"version":3}' > dev/site/.vercel/output/config.json
70+
cp -R dev/site/public/. dev/site/.vercel/output/static/
9671
9772
- name: Package Vercel Prebuilt Output
98-
run: tar -C hexo-site -czf vercel-prebuilt.tgz .vercel/output
73+
run: tar -C dev/site -czf vercel-prebuilt.tgz .vercel/output
9974

10075
- name: Upload Vercel Prebuilt Artifact
10176
uses: actions/upload-artifact@v4

.github/workflows/pr-preview-deploy.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ jobs:
2424
url: ${{ steps.deploy-to-vercel.outputs.PREVIEW_URL }}
2525

2626
steps:
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v6
29+
with:
30+
node-version: '20.x'
31+
32+
- name: Set up pnpm
33+
uses: pnpm/action-setup@v4
34+
with:
35+
version: 10.29.3
36+
2737
- name: Resolve PR Info
2838
id: pr
2939
uses: actions/github-script@v9
@@ -96,7 +106,7 @@ jobs:
96106
97107
# Install Vercel CLI first to avoid bug with next step
98108
- name: Install Vercel CLI
99-
run: npm install -g vercel@latest
109+
run: pnpm add --global vercel@latest
100110

101111

102112
- name: Deploy to Vercel

.github/workflows/prod-deploy.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
with:
2727
node-version: '20.x' # Specify your required Node.js version
2828

29+
- name: Set up pnpm
30+
uses: pnpm/action-setup@v4
31+
with:
32+
version: 10.29.3
33+
2934
- name: Clone Hexo site repository
3035
run: git clone https://github.com/EvanNotFound/redefine-demo.git hexo-site
3136

@@ -36,20 +41,20 @@ jobs:
3641
- name: Install dependencies
3742
run: |
3843
cd hexo-site
39-
npm install
44+
pnpm install --no-frozen-lockfile
4045
4146
- name: Build Hexo
4247
run: |
4348
cd hexo-site
44-
npm install
45-
npm uninstall hexo-theme-redefine
46-
npm run build
49+
pnpm install --no-frozen-lockfile
50+
pnpm remove hexo-theme-redefine
51+
pnpm run build
4752
4853
- name: Change directory to hexo-site
4954
run: echo "HEXO_SITE_DIR=${{ github.workspace }}/hexo-site" >> $GITHUB_ENV
5055

5156
- name: Install Vercel CLI
52-
run: npm install -g vercel@latest
57+
run: pnpm add --global vercel@latest
5358

5459
- name: Deploy to Vercel Action
5560
uses: EvanNotFound/vercel-deployment-for-github-actions@v1.2.2

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ yarn.lock
2727

2828
# misc
2929
/.sass-cache
30+
/dev/site/db.json
31+
/dev/site/public
32+
/dev/site/.source
33+
/dev/site/node_modules
3034
/connect.lock
3135
/coverage
3236
/libpeerconnection.log

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/.github/FUNDING.yml
2+
/dev
3+
/.zed
4+
/pnpm-workspace.yaml

.zed/tasks.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[
2+
{
3+
"label": "Redefine worktree setup",
4+
"command": "pnpm",
5+
"args": ["install", "--frozen-lockfile", "--prefer-offline"],
6+
"cwd": "$ZED_WORKTREE_ROOT",
7+
"hooks": ["create_worktree"],
8+
"reveal": "no_focus",
9+
"hide": "on_success",
10+
"save": "none"
11+
},
12+
{
13+
"label": "Redefine preview",
14+
"command": "pnpm",
15+
"args": ["run", "preview"],
16+
"cwd": "$ZED_WORKTREE_ROOT",
17+
"use_new_terminal": true,
18+
"reveal": "always",
19+
"save": "all"
20+
},
21+
{
22+
"label": "Redefine preview generate",
23+
"command": "pnpm",
24+
"args": ["run", "preview:generate"],
25+
"cwd": "$ZED_WORKTREE_ROOT",
26+
"reveal": "always",
27+
"save": "all"
28+
}
29+
]

0 commit comments

Comments
 (0)