Files
cstb-next/scripts/README.md
2025-11-08 23:57:26 +08:00

94 lines
2.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 生成 latest.json 脚本使用说明
## 概述
`generate-latest-json.js` 脚本用于生成 Tauri 更新器所需的 `latest.json` 文件。该文件包含版本信息、更新说明、下载链接和签名信息。
## 使用方法
### 基本用法
```bash
npm run generate-latest -- --base-url https://your-server.com/releases
```
### 完整示例
```bash
npm run generate-latest -- --base-url https://your-server.com/releases --version 0.0.6-beta.6 --notes "修复了已知问题"
```
### 参数说明
- `--base-url` (必需): 更新文件的基 URL例如 `https://your-server.com/releases`
- `--version` (可选): 版本号,如果不提供,将从 `tauri.conf.json` 读取
- `--notes` (可选): 更新说明,支持 Markdown 格式
## 工作流程
1. **构建应用**: 首先确保已经构建了应用
```bash
npm run build
```
2. **生成 latest.json**: 运行脚本生成 `latest.json` 文件
```bash
npm run generate-latest -- --base-url https://your-server.com/releases
```
3. **上传文件**: 将以下文件上传到服务器:
- 安装包文件(如 `.exe`, `.dmg`, `.AppImage`
- 签名文件(`.sig`
- `latest.json` 文件
## 文件结构
生成的 `latest.json` 文件格式:
```json
{
"version": "0.0.6-beta.6",
"notes": "版本 0.0.6-beta.6 更新",
"pub_date": "2025-01-15T10:00:00.000Z",
"platforms": {
"windows-x86_64": {
"url": "https://your-server.com/releases/CS工具箱_0.0.6-beta.6_x64-setup.exe",
"signature": "签名内容..."
}
}
}
```
## 注意事项
1. **构建产物**: 脚本会自动查找构建产物目录中的文件,确保已经完成构建
2. **签名文件**: 如果存在 `.sig` 文件,脚本会自动读取并包含在 `latest.json` 中
3. **版本匹配**: 脚本会根据版本号匹配文件,确保文件名包含版本号
4. **平台支持**: 脚本支持 Windows、macOS 和 Linux 平台
## 故障排查
### 未找到构建产物
如果脚本提示"未找到任何构建产物"
1. 确保已经运行 `npm run build` 完成构建
2. 检查 `src-tauri/target/release/bundle` 目录是否存在
3. 确认构建产物文件名包含版本号
### 签名文件缺失
如果签名文件缺失:
1. 确保设置了 `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` 环境变量
2. 确保 `tauri.conf.json` 中 `createUpdaterArtifacts` 设置为 `true`
3. 重新构建应用
### 上传到服务器
将以下文件上传到服务器:
- 安装包文件
- 签名文件(`.sig`
- `latest.json` 文件
确保服务器上的 URL 路径与 `--base-url` 参数匹配。