Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# E2E 测试环境变量示例
# 环境变量示例
# 复制此文件为 .env.local 并填入真实值
# .env.local 文件不会被提交到 git

# ==================== E2E 测试 ====================

# 资金账号助记词 - 用于提供测试资金(24个中文词,空格分隔)
E2E_TEST_MNEMONIC="词1 词2 词3 词4 词5 词6 词7 词8 词9 词10 词11 词12 词13 词14 词15 词16 词17 词18 词19 词20 词21 词22 词23 词24"

# 钱包锁
E2E_TEST_PASSWORD="your-test-password"

# ==================== DWEB 发布 ====================

# SFTP 服务器地址(默认: sftp://iweb.xin:22022)
# DWEB_SFTP_URL="sftp://iweb.xin:22022"

# 正式版账号(用于 pnpm release 和 --stable 构建)
DWEB_SFTP_USER="keyapp"
DWEB_SFTP_PASS="your-password"

# 开发版账号(用于日常 CI/CD 和 beta 构建)
DWEB_SFTP_USER_DEV="keyapp-dev"
DWEB_SFTP_PASS_DEV="your-dev-password"
67 changes: 51 additions & 16 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ jobs:
fi

# 准备 webapp 目录
mkdir -p docs/public/webapp docs/public/webapp-beta
mkdir -p docs/public/webapp docs/public/webapp-dev
if [[ "$CHANNEL" == "stable" ]]; then
cp -r dist-web/* docs/public/webapp/
if gh release download --pattern 'bfmpay-web-beta.zip' --dir /tmp -R ${{ github.repository }} 2>/dev/null; then
unzip -q /tmp/bfmpay-web-beta.zip -d docs/public/webapp-beta/
unzip -q /tmp/bfmpay-web-beta.zip -d docs/public/webapp-dev/
else
cp -r dist-web/* docs/public/webapp-beta/
cp -r dist-web/* docs/public/webapp-dev/
fi
else
cp -r dist-web/* docs/public/webapp-beta/
cp -r dist-web/* docs/public/webapp-dev/
if gh release download --pattern 'bfmpay-web.zip' --dir /tmp -R ${{ github.repository }} 2>/dev/null; then
unzip -q /tmp/bfmpay-web.zip -d docs/public/webapp/
else
Expand Down Expand Up @@ -168,6 +168,21 @@ jobs:
cp release/bfmpay-dweb-beta.zip "release/bfmpay-dweb-${VERSION}-beta.zip"
fi

# 上传 DWEB 到 SFTP 服务器
- name: Upload DWEB to SFTP
env:
CHANNEL: ${{ steps.channel.outputs.channel }}
DWEB_SFTP_USER: ${{ secrets.DWEB_SFTP_USER }}
DWEB_SFTP_PASS: ${{ secrets.DWEB_SFTP_PASS }}
DWEB_SFTP_USER_DEV: ${{ secrets.DWEB_SFTP_USER_DEV }}
DWEB_SFTP_PASS_DEV: ${{ secrets.DWEB_SFTP_PASS_DEV }}
run: |
if [[ "$CHANNEL" == "stable" ]]; then
bun scripts/build.ts dweb --upload --stable --skip-typecheck --skip-test
else
bun scripts/build.ts dweb --upload --skip-typecheck --skip-test
fi

# 直接推送到 gh-pages 分支,避免使用 upload-pages-artifact(self-hosted 上容易卡住)
- name: Deploy to GitHub Pages
env:
Expand Down Expand Up @@ -197,7 +212,7 @@ jobs:

### 在线访问
- Web 应用 (stable): https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/webapp/
- Web 应用 (beta): https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/webapp-beta/
- Web 应用 (beta): https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/webapp-dev/
- 文档首页: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/

### DWEB 安装
Expand Down Expand Up @@ -250,6 +265,11 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: pnpm install --frozen-lockfile

Expand Down Expand Up @@ -314,20 +334,20 @@ jobs:
echo "Copied current build to docs/public/webapp/ (stable)"

# 尝试下载最新的 beta 版本(从 latest prerelease)
mkdir -p docs/public/webapp-beta
mkdir -p docs/public/webapp-dev
if gh release download --pattern 'bfmpay-web-beta.zip' --dir /tmp -R ${{ github.repository }} 2>/dev/null; then
unzip -q /tmp/bfmpay-web-beta.zip -d docs/public/webapp-beta/
unzip -q /tmp/bfmpay-web-beta.zip -d docs/public/webapp-dev/
echo "Downloaded beta version from release"
else
# 如果没有 beta release,使用当前构建
cp -r dist-web/* docs/public/webapp-beta/
echo "No beta release found, using current build for webapp-beta"
cp -r dist-web/* docs/public/webapp-dev/
echo "No beta release found, using current build for webapp-dev"
fi
else
# beta 构建:当前版本放 webapp-beta/,尝试下载 stable
mkdir -p docs/public/webapp-beta
cp -r dist-web/* docs/public/webapp-beta/
echo "Copied current build to docs/public/webapp-beta/ (beta)"
# beta 构建:当前版本放 webapp-dev/,尝试下载 stable
mkdir -p docs/public/webapp-dev
cp -r dist-web/* docs/public/webapp-dev/
echo "Copied current build to docs/public/webapp-dev/ (beta)"

# 尝试下载最新的 stable 版本
mkdir -p docs/public/webapp
Expand All @@ -344,8 +364,8 @@ jobs:
# 显示准备好的目录
echo "=== webapp directory ==="
ls -la docs/public/webapp/ | head -5
echo "=== webapp-beta directory ==="
ls -la docs/public/webapp-beta/ | head -5
echo "=== webapp-dev directory ==="
ls -la docs/public/webapp-dev/ | head -5

# ===== 构建 Storybook =====
- name: Build Storybook
Expand Down Expand Up @@ -414,6 +434,21 @@ jobs:
echo "=== Release artifacts ==="
ls -la release/

# ===== 上传 DWEB 到 SFTP 服务器 =====
- name: Upload DWEB to SFTP
env:
CHANNEL: ${{ steps.channel.outputs.channel }}
DWEB_SFTP_USER: ${{ secrets.DWEB_SFTP_USER }}
DWEB_SFTP_PASS: ${{ secrets.DWEB_SFTP_PASS }}
DWEB_SFTP_USER_DEV: ${{ secrets.DWEB_SFTP_USER_DEV }}
DWEB_SFTP_PASS_DEV: ${{ secrets.DWEB_SFTP_PASS_DEV }}
run: |
if [[ "$CHANNEL" == "stable" ]]; then
bun scripts/build.ts dweb --upload --stable --skip-typecheck --skip-test
else
bun scripts/build.ts dweb --upload --skip-typecheck --skip-test
fi

# ===== 上传构建产物 =====
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
Expand Down Expand Up @@ -470,7 +505,7 @@ jobs:

### 在线访问
- Web 应用 (stable): https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/webapp/
- Web 应用 (beta): https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/webapp-beta/
- Web 应用 (beta): https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/webapp-dev/
- 文档首页: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/

### DWEB 安装
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ storybook-static/
docs/.vitepress/dist
docs/.vitepress/cache
docs/public/webapp
docs/public/webapp-beta
docs/public/webapp-dev

# dependencies
node_modules
Expand Down
4 changes: 2 additions & 2 deletions CHAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ PDR文件不该包含过多的软件工程技术细节吧,反而应该专注
我们的build.ts脚本所实现的持续集成功能,其实默认生成的是“beta”渠道版本:

1. 这是每次git-push到main分支就会自动触发的。
2. beta版本的网页版链接应该是 `https://???.github.io/???/webapp-beta/`
2. beta版本的网页版链接应该是 `https://???.github.io/???/webapp-dev/`
1. 也就是说“stable”版本仍然在`https://???.github.io/???/webapp/`,这个我们可能需要从github-release找最近的一个stable版本
2. 如果要生成“stable”,那么需要本地执行`pnpm gen:stable`,这个脚本默认是在本地执行:
1. 它的目的是更新版本号,生成changelog,这是一个交互式的命令。
Expand All @@ -49,7 +49,7 @@ PDR文件不该包含过多的软件工程技术细节吧,反而应该专注

1. 我们需要vitepress作为我们页面的骨架
2. 不论是stable还是beta,默认都应该从github-release下载,如果下载不到,那么就使用本地构建的
3. download页面可以下载各种渠道的版本,目前有4个:webapp-stable/webapp-beta/dwebapp-stable/dwebapp-beta
3. download页面可以下载各种渠道的版本,目前有4个:webapp-stable/webapp-dev/dwebapp-stable/dwebapp-dev

---

Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineConfig({
base,

// webapp/storybook 目录由 CI 动态生成,忽略死链接检查
ignoreDeadLinks: [/\.\/webapp/, /\.\/webapp-beta/, /\.\/storybook/],
ignoreDeadLinks: [/\.\/webapp/, /\.\/webapp-dev/, /\.\/storybook/],

head: [
['link', { rel: 'icon', type: 'image/webp', href: '/logos/logo-64.webp' }],
Expand Down
8 changes: 4 additions & 4 deletions docs/.vitepress/plugins/webapp-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* VitePress 插件:在 dev/build 前准备 webapp 目录
*
* 流程:
* 1. 尝试从 GitHub Release 下载 webapp/webapp-beta
* 1. 尝试从 GitHub Release 下载 webapp/webapp-dev
* 2. 下载失败则检查本地 dist-web 是否存在
* 3. 都没有则运行本地构建
*/
Expand Down Expand Up @@ -161,7 +161,7 @@ async function prepareAllWebapps() {
// 并行准备两个版本
await Promise.all([
prepareWebapp('stable', join(DOCS_PUBLIC, 'webapp')),
prepareWebapp('beta', join(DOCS_PUBLIC, 'webapp-beta')),
prepareWebapp('beta', join(DOCS_PUBLIC, 'webapp-dev')),
])

log.success('webapp 目录准备完成')
Expand All @@ -186,8 +186,8 @@ export function webappLoaderPlugin(): Plugin {
server.middlewares.use((req, res, next) => {
const url = req.url || ''

// 处理 /webapp/ 和 /webapp-beta/ 路径
const match = url.match(/^\/(webapp|webapp-beta)(\/.*)?$/)
// 处理 /webapp/ 和 /webapp-dev/ 路径
const match = url.match(/^\/(webapp|webapp-dev)(\/.*)?$/)
if (match) {
const webappDir = match[1]
const subPath = match[2] || '/'
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ CI/CD 会自动构建以下产物:
|------|------|
| `/` | VitePress 文档站点 |
| `/webapp/` | Web 应用(稳定版) |
| `/webapp-beta/` | Web 应用(测试版) |
| `/webapp-dev/` | Web 应用(测试版) |
| `/storybook/` | Storybook 组件文档 |

## 开发规范
Expand Down
2 changes: 1 addition & 1 deletion docs/download.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<h3>Web 测试版</h3>
</div>
<p>包含最新功能,每次代码更新自动发布。</p>
<a href="./webapp-beta/" class="download-btn secondary">打开 Beta 版</a>
<a href="./webapp-dev/" class="download-btn secondary">打开 Beta 版</a>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ features:

| 平台 | 稳定版 | 测试版 |
|------|--------|--------|
| **Web** | <a href="./webapp/" target="_self">webapp/</a> | <a href="./webapp-beta/" target="_self">webapp-beta/</a> |
| **Web** | <a href="./webapp/" target="_self">webapp/</a> | <a href="./webapp-dev/" target="_self">webapp-dev/</a> |
| **DWEB** | [下载页面](./download) | [下载页面](./download) |

查看 [下载页面](./download) 了解更多版本信息。
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"gen:stable": "bun scripts/gen-stable.ts",
"release": "bun scripts/release.ts",
"set-secret": "bun scripts/set-secret.ts",
"gen:logo": "bun scripts/gen-logo.ts",
"i18n:extract": "bun scripts/i18n-extract.ts",
"i18n:check": "turbo run i18n:run --",
Expand Down Expand Up @@ -161,6 +163,7 @@
"semver": "^7.7.3",
"shadcn": "^3.6.1",
"sharp": "^0.34.5",
"ssh2-sftp-client": "^12.0.1",
"storybook": "^10.1.4",
"tailwindcss": "^4.0.0",
"turbo": "^2.7.1",
Expand Down
Loading