Skip to content

Commit ae88104

Browse files
authored
Merge pull request #222 from zhangxichang/branch-1
feat: 分离Web发布工作流并支持多环境发布
2 parents e2861ac + 7675d3e commit ae88104

5 files changed

Lines changed: 238 additions & 27 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: 发布
22
on:
33
push:
4-
branches:
5-
- release
4+
branches: [release, beta, alpha]
65
permissions:
76
contents: read
87
jobs:
@@ -45,23 +44,6 @@ jobs:
4544
- uses: ./.github/actions/initialize-project
4645
- name: 应用测试
4746
run: bun run test
48-
build-release-web:
49-
name: 构建发布到 Web
50-
needs: [app-test, check-release]
51-
runs-on: ubuntu-latest
52-
steps:
53-
- uses: ./.github/actions/initialize-project
54-
- name: 构建
55-
run: |
56-
echo ${{needs.check-release.outputs.version}} > public/version
57-
bun run build
58-
- name: 发布
59-
uses: cloudflare/wrangler-action@v3
60-
with:
61-
wranglerVersion: latest
62-
packageManager: bun
63-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
64-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
6547
build-relay:
6648
name: 构建中继服务程序
6749
needs: app-test

.github/workflows/web-release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Web发布
2+
on:
3+
push:
4+
branches:
5+
- web
6+
permissions:
7+
contents: read
8+
jobs:
9+
app-test:
10+
name: 应用测试
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: ./.github/actions/initialize-project
14+
- name: 应用测试
15+
run: bun run test
16+
release:
17+
name: 发布
18+
needs: app-test
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: ./.github/actions/initialize-project
22+
- name: 构建
23+
run: bun run build
24+
- name: 发布
25+
uses: cloudflare/wrangler-action@v3
26+
with:
27+
wranglerVersion: latest
28+
packageManager: bun
29+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
30+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}

.releaserc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
2-
"branches": ["release"],
2+
"branches": [
3+
"release",
4+
{ "name": "beta", "prerelease": true },
5+
{ "name": "alpha", "prerelease": true }
6+
],
37
"plugins": [
48
["@semantic-release/commit-analyzer", { "preset": "conventionalcommits" }],
59
[

AGENTS.md

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# Agent Guidelines for Pupu Project
2+
3+
This document provides guidelines for AI agents working on the Pupu codebase. It covers build commands, linting, testing, code style, and project conventions.
4+
5+
## Build Commands
6+
7+
### Prerequisites
8+
- [Bun](https://bun.sh) (JavaScript runtime)
9+
- [Rust](https://rust-lang.org) (with `wasm32-unknown-unknown` target)
10+
- [wasm-pack](https://rustwasm.github.io/wasm-pack/)
11+
- [Tauri prerequisites](https://v2.tauri.app/start/prerequisites)
12+
- [uv](https://docs.astral.sh/uv/) (Python tool)
13+
- [Android SDK](https://developer.android.com/studio) (for Android builds)
14+
15+
### Initialization
16+
```bash
17+
bun run install:pre # Build WASM endpoint
18+
bun install # Install npm dependencies
19+
bun run install:post # Generate icons, IPC bindings, database schema, install Playwright
20+
```
21+
22+
### Development
23+
```bash
24+
# Web development
25+
bun run dev
26+
27+
# Native desktop development (Tauri)
28+
bun run native:dev
29+
30+
# Android development
31+
bun run android:dev
32+
```
33+
34+
### Production Builds
35+
```bash
36+
# Web
37+
bun run build
38+
39+
# Native desktop
40+
bun run native:build
41+
42+
# Android APK
43+
bun run android:build
44+
```
45+
46+
### Web Preview
47+
```bash
48+
bun run preview # Runs wrangler dev on Cloudflare Workers
49+
```
50+
51+
### WASM Build
52+
```bash
53+
bun run wasm:build
54+
```
55+
56+
## Linting and Testing
57+
58+
### TypeScript/JavaScript
59+
```bash
60+
# Type checking and ESLint
61+
bun run check
62+
63+
# Run Playwright end‑to‑end tests
64+
bun run test
65+
66+
# Run a single Playwright test file
67+
bun run test tests/auth.test.ts
68+
69+
# Run tests matching a title pattern
70+
bun run test -- --grep "登录表单验证"
71+
```
72+
73+
### Rust
74+
```bash
75+
# Format check
76+
cargo fmt --check
77+
78+
# Linting with Clippy
79+
cargo clippy --workspace
80+
81+
# Run all Rust unit tests
82+
cargo test --workspace
83+
84+
# Run tests for a specific crate
85+
cargo test -p utils
86+
87+
# Build in release mode
88+
cargo build --release
89+
```
90+
91+
## Code Style Guidelines
92+
93+
### Naming Conventions
94+
- **Functions and variables**: `snake_case` (applies to both Rust and TypeScript)
95+
- **Class names**: `PascalCase`
96+
- **Interface/trait names**: `PascalCase`
97+
- **Module names**: `snake_case`
98+
- **Constants**: `SCREAMING_SNAKE_CASE`
99+
- **Type parameters**: `T`, `U`, `V` or descriptive camelCase (`TResult`)
100+
101+
### TypeScript / SolidJS
102+
- Use strict TypeScript (`strict: true` in tsconfig.json)
103+
- No unused locals or parameters (`noUnusedLocals`, `noUnusedParameters`)
104+
- Use `type` imports for type‑only imports:
105+
```ts
106+
import type { Person } from "~/lib/types";
107+
import { createSignal } from "solid‑js";
108+
```
109+
- Prefer `async`/`await` over raw promises
110+
- Use `Uint8Array` for binary data
111+
- Use `bigint` for large integers (matching Rust `i64`/`u64`)
112+
- Use `snake_case` for method names and properties (matching Rust IPC)
113+
- Class methods that return promises should be marked `async`
114+
- Use SolidJS reactive primitives (`createSignal`, `createEffect`, `createMemo`)
115+
116+
### Rust
117+
- Edition 2024
118+
- Use `eyre::Result` for internal error handling
119+
- Convert to `Result<T, String>` for IPC via the `.mse()` extension
120+
- Use `serde_json::Value` for JSON values crossing the IPC boundary
121+
- Derive `Serialize`/`Deserialize` with `serde` for IPC types
122+
- Use `taurpc` procedural macros for defining IPC endpoints
123+
- Use `#[derive(Default)]` where appropriate
124+
- Use `Arc<Slab<...>>` for handle‑based resource pools
125+
- Use `tokio` for async runtime
126+
127+
### Imports Organization
128+
1. Standard library / external crates
129+
2. Internal modules
130+
3. Type‑only imports
131+
4. Relative imports
132+
133+
Example:
134+
```rust
135+
use std::sync::Arc;
136+
use eyre::eyre;
137+
use tauri::{Runtime, Window};
138+
use crate::error::MapStringError;
139+
```
140+
141+
### Error Handling
142+
- **Rust**: Use `eyre::Result` and `eyre!` macro for internal errors. Convert to `String` with `.mse()` when returning over IPC.
143+
- **TypeScript**: Use `try`/`catch` with `async` functions. Throw `Error` objects.
144+
- **Playwright tests**: Use `expect` assertions; failures are reported as test failures.
145+
146+
### Project Structure
147+
```
148+
pupu/
149+
├── Cargo.toml (workspace)
150+
├── package.json
151+
├── src/ (TypeScript frontend – SolidJS)
152+
├── native/ (Tauri backend)
153+
├── wasm/endpoint/ (Rust WebAssembly)
154+
├── crates/ (shared Rust libraries)
155+
├── cli/ (standalone relay binary)
156+
├── tests/ (Playwright end‑to‑end tests)
157+
├── public/ (static assets)
158+
├── scripts/ (Python utilities)
159+
└── docs/ (project documentation)
160+
```
161+
162+
### Commit Messages
163+
Follow [Conventional Commits](https://www.conventionalcommits.org/):
164+
- `fix:` for bug fixes
165+
- `feat:` for new features
166+
- `docs:` for documentation changes
167+
- `chore:` for maintenance tasks
168+
169+
### Key Technologies
170+
- **Database**: Prisma for schema definition, Kysely for type‑safe SQL queries, SQLite via `tokio‑rusqlite`
171+
- **IPC**: Tauri‑RPC with `#[taurpc::procedures]` traits, `#[taurpc::resolvers]` implementations, TypeScript bindings via `export_config`
172+
- **WebAssembly**: Built with `wasm‑pack`, imported as `@pupu/endpoint`, functions exposed via `#[wasm_bindgen]`
173+
- **Android**: Keystore in `keystore.properties`, build with `tauri android build`, icons from `public/icon.svg`
174+
175+
176+
177+
### Editor / Tooling
178+
- No Cursor rules (`.cursorrules`) or Copilot instructions (`.github/copilot-instructions.md`) are present.
179+
180+
## Quick Reference
181+
| Task | Command |
182+
|------|---------|
183+
| Type check | `bun run check` |
184+
| Run all tests | `bun run test` & `cargo test --workspace` |
185+
| Lint Rust | `cargo clippy --workspace` |
186+
| Format Rust | `cargo fmt` |
187+
| Start web dev | `bun run dev` |
188+
| Start native dev | `bun run native:dev` |
189+
| Build web | `bun run build` |
190+
| Build native | `bun run native:build` |
191+
| Build Android | `bun run android:build` |

src/components/modal/about.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import { UserIcon } from "lucide-solid";
99

1010
export default function AboutModal() {
1111
const version = createAsync(async () => {
12-
const version = await fetch("/version");
13-
const content_type = version.headers.get("Content-Type");
14-
if (content_type !== "text/html") {
15-
return await version.text();
12+
if (import.meta.env.TAURI_ENV_PLATFORM !== undefined) {
13+
const version = await fetch("/version");
14+
const content_type = version.headers.get("Content-Type");
15+
if (content_type !== "text/html") {
16+
return await version.text();
17+
}
1618
}
1719
});
1820
const contributors = createAsync(async () => {
@@ -69,9 +71,11 @@ export default function AboutModal() {
6971
>
7072
源码仓库
7173
</span>
72-
<span class="text-sm text-base-content/60">
73-
版本号:{version() ?? "开发版本"}
74-
</span>
74+
<Show when={import.meta.env.TAURI_ENV_PLATFORM !== undefined}>
75+
<span class="text-sm text-base-content/60">
76+
版本号:{version() ?? "开发版本"}
77+
</span>
78+
</Show>
7579
</div>
7680
</div>
7781
</div>

0 commit comments

Comments
 (0)