Skip to content

Commit ee55f73

Browse files
committed
Merge branch 'dev' of https://github.com/wll8/mockm into dev
2 parents dfc75c2 + ec152e3 commit ee55f73

File tree

7 files changed

+67
-62
lines changed

7 files changed

+67
-62
lines changed

.github/workflows/deploy.yml

Lines changed: 30 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,6 @@ concurrency:
1515
cancel-in-progress: false
1616

1717
jobs:
18-
# 构建文档 - 使用现有 docker-compose.yml
19-
build-docs:
20-
runs-on: ubuntu-latest
21-
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v4
24-
with:
25-
fetch-depth: 0
26-
27-
- name: Build documentation using docker-compose
28-
run: |
29-
# 检查并使用合适的 docker compose 命令
30-
if command -v docker-compose &> /dev/null; then
31-
DOCKER_COMPOSE="docker-compose"
32-
else
33-
DOCKER_COMPOSE="docker compose"
34-
fi
35-
36-
# 使用现有的 docker-compose.yml 构建 mockm-dev 服务
37-
$DOCKER_COMPOSE build mockm-dev
38-
39-
# 运行文档构建命令
40-
$DOCKER_COMPOSE run --rm mockm-dev \
41-
sh -c "git config --global --add safe.directory /workspace && cd doc && rm -rf .vuepress/dist && GITHUB_ACTIONS=true pnpm run build"
42-
43-
- name: Copy test resources
44-
run: |
45-
mkdir -p doc/.vuepress/dist/case
46-
cp -r test/res/* doc/.vuepress/dist/case/ || true
47-
48-
- name: Upload Pages artifact
49-
uses: actions/upload-pages-artifact@v3
50-
with:
51-
path: doc/.vuepress/dist
52-
53-
# 部署到 GitHub Pages
54-
deploy-pages:
55-
environment:
56-
name: github-pages
57-
url: ${{ steps.deployment.outputs.page_url }}
58-
runs-on: ubuntu-latest
59-
needs: build-docs
60-
steps:
61-
- name: Deploy to GitHub Pages
62-
id: deployment
63-
uses: actions/deploy-pages@v4
64-
6518
# 构建和发布包 - 使用现有 docker-compose.yml
6619
build-and-release:
6720
runs-on: ubuntu-latest
@@ -87,9 +40,15 @@ jobs:
8740
$DOCKER_COMPOSE run --rm mockm-client \
8841
sh -c "cd client && yarn build"
8942
90-
# 构建服务端包
43+
# 运行测试并生成报告
9144
$DOCKER_COMPOSE run --rm mockm-dev \
92-
sh -c "git config --global --add safe.directory /workspace && cd release && pnpm run build"
45+
sh -c "npm run test:dev"
46+
47+
# 构建生产内容:包、文档、复制测试报告
48+
$DOCKER_COMPOSE run --rm \
49+
-e GITHUB_ACTIONS=true \
50+
mockm-dev \
51+
sh -c "git config --global --add safe.directory /workspace && npm run build:serve"
9352
9453
- name: Get package info
9554
run: |
@@ -98,9 +57,10 @@ jobs:
9857
echo "PACKAGE_NAME=mockm" >> $GITHUB_ENV
9958
10059
- name: Create Release
101-
uses: softprops/action-gh-release@v1
60+
uses: mini-bomba/create-github-release@v1.2.0
10261
with:
103-
tag_name: v${{ env.VERSION }}
62+
token: ${{ secrets.GITHUB_TOKEN }}
63+
tag: v${{ env.VERSION }}
10464
name: Release v${{ env.VERSION }}
10565
body: |
10666
## Changes in v${{ env.VERSION }}
@@ -115,12 +75,11 @@ jobs:
11575
11676
### Download
11777
- [mockm-${{ env.VERSION }}.tgz](https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/mockm-${{ env.VERSION }}.tgz)
118-
draft: false
11978
prerelease: false
79+
draft: false
12080
files: |
12181
dist/*.tgz
122-
env:
123-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
clear_attachments: true
12483

12584
- name: Cleanup Docker resources
12685
if: always()
@@ -134,3 +93,20 @@ jobs:
13493
13594
$DOCKER_COMPOSE down --volumes --remove-orphans || true
13695
docker system prune -f || true
96+
97+
- name: Upload Pages artifact
98+
uses: actions/upload-pages-artifact@v3
99+
with:
100+
path: doc/.vuepress/dist
101+
102+
# 部署到 GitHub Pages
103+
deploy-pages:
104+
environment:
105+
name: github-pages
106+
url: ${{ steps.deployment.outputs.page_url }}
107+
runs-on: ubuntu-latest
108+
needs: build-and-release
109+
steps:
110+
- name: Deploy to GitHub Pages
111+
id: deployment
112+
uses: actions/deploy-pages@v4

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
<p align="center">
55
<a href="https://github.com/wll8/mockm/blob/dev/README.md">中文</a> |
6-
<a href="https://github.com/wll8/mockm/blob/dev/README.en.md">English</a>
6+
<a href="https://github.com/wll8/mockm/blob/dev/README.en.md">English</a> |
7+
<a href="https://wll8.github.io/mockm/">文档</a>
78
</p>
89
<p align="center">
910
<a href="https://www.npmjs.com/package/mockm"><img src="https://img.shields.io/npm/dt/mockm" alt="Downloads"></a>

doc/.vuepress/config.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
const path = require('path')
22

33
// 检测是否为GitHub Pages环境
4-
const isGitHubPages = process.env.GITHUB_ACTIONS === 'true' || process.env.NODE_ENV === 'github'
4+
const isGitHubPages = process.env.GITHUB_ACTIONS === 'true'
5+
6+
console.log('VuePress Build Environment:', {
7+
GITHUB_ACTIONS: process.env.GITHUB_ACTIONS,
8+
isGitHubPages: isGitHubPages
9+
})
510

611
// 统一的链接替换函数
712
function replaceHongqiyeLinks(url) {
813
if (!url || typeof url !== 'string') return url
9-
return url.replace(/https?:\/\/(www\.)?hongqiye\.com\/doc\/mockm/g, '/mockm')
14+
return url.replace(/https?:\/\/(www\.)?hongqiye\.com\/doc\/mockm/g, '')
1015
}
1116

1217
// 基础配置
@@ -97,7 +102,7 @@ const baseConfig = {
97102
nav: [
98103
{ text: '版本 v1.1.26', link: '/' },
99104
{ text: '配置项', link: '/config/option.md' },
100-
{ text: '更多示例', link: isGitHubPages ? '/mockm/case/' : 'https://www.hongqiye.com/doc/mockm/case/' },
105+
{ text: '更多示例', link: isGitHubPages ? '/case/' : 'https://www.hongqiye.com/doc/mockm/case/' },
101106
{ text: 'mockjs', link: 'https://wll8.github.io/mockjs-examples/' },
102107
// { text: 'QQ答疑群', link: 'https://qm.qq.com/cgi-bin/qm/qr?k=4rvOknpHyqs5wd3c2kEt34Eysx83djEZ&jump_from=webapi' },
103108
{ text: 'github', link: 'https://github.com/wll8/mockm' },

doc/dev/change_log.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@
99

1010
:::
1111

12+
## 2025 年 07 月
13+
- 🔧更新辅助工具:
14+
- 添加 Docker 支持和容器化部署
15+
- 添加 GitHub Actions 自动化部署和发布
16+
- 切换到 pnpm 包管理器,提升安装和构建速度
17+
- 优化 VuePress 配置,修复 GitHub Pages 部署问题
18+
- 🐛修复缺陷:
19+
- 修复跨盘符数据存储兼容性问题
20+
- 优化代理功能内存使用
21+
- ✨添加功能:
22+
- 支持使用 Docker Compose 进行开发和部署
23+
- 自动化版本发布和文档部署流程
24+
- 📝更新文档:
25+
- 添加项目实现原理文档
26+
27+
## 2025 年 06 月
28+
- 🔧更新辅助工具:
29+
- 更新项目依赖版本
30+
31+
## 2025 年 04 月
32+
- 🧪测试优化:
33+
- 修复测试用例中的 DNS 解析问题
34+
- 优化测试用例的稳定性
35+
1236
## 2025 年 03 月
1337
- 🔧更新辅助工具:
1438
- 使用 httpolyglot@2.2.2

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.8'
2-
31
services:
42
mockm-client:
53
build:

release/gulpfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ gulp.task(`pushDoc`, (cb) => { // 发布文档
4242
const cmdList = `
4343
cd ../ && npm run doc:build
4444
cd ../ && npx shx cp -r test/res/ ./doc/.vuepress/dist/case
45-
cd ../doc/.vuepress/ && scp -r dist/** root@hongqiye.com:/app/mockm/mm/www/doc/mockm/
45+
echo cd ../doc/.vuepress/ && scp -r dist/** root@hongqiye.com:/app/mockm/mm/www/doc/mockm/
4646
`.split(`\n`).map(item => item.trim()).filter(item => item)
4747
cmdList.forEach(cmd => {
4848
console.log(`run: ${cmd}`)
@@ -143,6 +143,7 @@ gulp.task(
143143
gulp.series(
144144
`clear`,
145145
gulp.parallel(`copyServer`),
146+
`pushDoc`,
146147
gulp.series(`uglify`, `setBuildInfo`, `tar`, done => done())
147148
),
148149
)

release/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"description": "mockm 发布脚本",
55
"scripts": {
6-
"build": "gulp"
6+
"build": "npx gulp"
77
},
88
"keywords": [],
99
"author": "",

0 commit comments

Comments
 (0)