diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 146e2f5..a30148e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,7 +68,5 @@ jobs: run: cd frontend && npm install - name: Install Playwright Browsers run: cd frontend && npx playwright install --with-deps - - name: Start Docker Databases - run: cd frontend && docker compose up -d --wait - name: Run E2E Tests - run: cd frontend && xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" npm run test:e2e + run: cd frontend && npm run test:e2e diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3fea0df..b21ad7a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,8 +9,11 @@ jobs: build: name: Build and Release strategy: + fail-fast: false matrix: - os: [macos-latest, windows-latest] + include: + - os: macos-latest + - os: windows-latest runs-on: ${{ matrix.os }} permissions: contents: write @@ -28,25 +31,27 @@ jobs: uses: actions/setup-go@v5 with: go-version: '1.24' + cache-dependency-path: backend/go.sum - - name: Install dependencies + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Rust cache + uses: swatinem/rust-cache@v2 + with: + workspaces: frontend/tauri -> target + + - name: Install frontend dependencies run: cd frontend && npm install - - name: Build Go Engine - run: | - mkdir -p frontend/engine - cd backend - if [ "$RUNNER_OS" == "Windows" ]; then - go build -o ../frontend/engine/vstable-engine.exe main.go - else - go build -o ../frontend/engine/vstable-engine main.go - fi - shell: bash - - - name: Build and Publish + - name: Build and Release + uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd frontend - npm run build - npx electron-builder --publish always + with: + tagName: v__VERSION__ # tauri-action will replace this with package.json version if needed, or use the tag + releaseName: "vstable v__VERSION__" + releaseBody: "See the assets below to download." + releaseDraft: true + prerelease: false + projectPath: frontend diff --git a/.gitignore b/.gitignore index d4c4298..6a52a48 100644 --- a/.gitignore +++ b/.gitignore @@ -13,29 +13,27 @@ yarn-debug.log* yarn-error.log* .pnpm-debug.log* backend/log.txt +tmp.prompt +.engine.pid # --- Environment --- .env* !.env.example -# --- Frontend (Node.js/Electron) --- +# --- Frontend (Node.js/Tauri) --- node_modules/ frontend/node_modules/ -frontend/out/ frontend/dist/ -frontend/release/ -frontend/.parcel-cache/ -frontend/.eslintcache -frontend/.vite/ -frontend/package-lock.json +frontend/out/ +frontend/tauri/target/ +frontend/tauri/bin/vstable-* +frontend/tauri/gen/ frontend/test-results/ frontend/playwright-report/ -frontend/blob-report/ -frontend/playwright/.cache/ frontend/*.tsbuildinfo # --- Backend (Go) --- -backend/engine +backend/vstable backend/vstable-engine backend/bin/ backend/vendor/ @@ -52,3 +50,4 @@ coverage/ docker-data/ *.db *.sqlite +dist/ diff --git a/AGENTS.md b/AGENTS.md index 90eece1..5515da6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,14 +2,16 @@ ## Quick commands -- `cd frontend && npm run dev` (拉起双端开发环境:Electron + Go Engine) +- `cd frontend && npm run dev` (拉起双端开发环境:Tauri + Go Engine) +- `cd frontend && npm run dev-frontend` (仅启动前端 Vite,不启动 Tauri/Go,适合纯 UI 调试) - `cd frontend && npm run build` (编译前端与后端二进制) - `cd frontend && npm run test` (Vitest 单元测试) - `cd frontend && npm run test:e2e` (Playwright 全链路测试,会先 build) - `cd frontend && npm run check` (Biome 格式化与静态检查) -- `cd backend && go test -v ./...` (后端集成测试,需 Docker) - `cd frontend && npm run docker:up` (启动测试所需的 PG/MySQL 容器) -- `cd backend && ./scripts/gen_proto.sh` (生成 gRPC 代码并同步协议文件到前端) +- `cd frontend && npm run docker:down` (停止并清理测试容器) +- `cd backend && go test -v ./...` (后端集成测试,需 Docker) +- `cd backend && ./scripts/gen_proto.sh` (生成 gRPC 代码) ## Project overview @@ -18,7 +20,7 @@ vstable 是一款专为开发者设计的现代数据库管理工具,支持可 ## Tech stack - **Frontend**: React 19 (TypeScript), TailwindCSS 4.0, Monaco Editor -- **Desktop Runtime**: Electron 40, electron-vite +- **Desktop Runtime**: Tauri 2.0 (Rust), Vite - **Backend Engine**: Go 1.24 (vstable-engine) - **Communication**: gRPC, Protocol Buffers (Strict types) - **Database Drivers**: `pgx/v5` (PostgreSQL), `go-sql-driver/mysql` (MySQL) @@ -29,22 +31,21 @@ vstable 是一款专为开发者设计的现代数据库管理工具,支持可 该项目采用解耦的三层架构: 1. **Frontend (React)**: 基于 React 19、TailwindCSS 4.0 和 Monaco Editor 构建的现代用户界面。负责处理用户交互、SQL 编辑以及可视化的表结构设计。 -2. **Desktop Runtime (Electron)**: 作为操作系统与 Web 内容之间的桥梁。主进程(Main process)负责管理 Go 引擎的生命周期、持久化存储、IPC 路由以及原生窗口管理。 -3. **Backend Engine (Go)**: 一个使用 Go 1.24 编写的高性能守护进程。它在本地运行并向 Electron 主进程暴露 gRPC API(定义于 `vstable.proto`)。它承担繁重的计算任务,包括数据库连接管理、AST 解析,以及基于状态对齐进行 Schema Diff 并生成精确的 DDL 语句。 +2. **Desktop Runtime (Tauri)**: 作为操作系统与 Web 内容之间的桥梁。基于 Rust 的核心层负责管理 Go 引擎(Sidecar)的生命周期、处理由前端发起的高性能 IPC 请求,并通过原生的能力(Capabilities)系统提供持久化存储和窗口管理。 +3. **Backend Engine (Go)**: 一个使用 Go 1.24 编写的高性能守护进程。它在本地作为 Tauri Sidecar 运行并向 Rust 核心暴露 gRPC API(定义于 `vstable.proto`)。它承担繁重的计算任务,包括数据库连接管理、AST 解析,以及基于状态对齐进行 Schema Diff 并生成精确的 DDL 语句。 ## Major modules and interfaces - **Go Engine (`backend/`)**: - `internal/ast`: 核心 Schema Diff 引擎。提供 AST 类型定义以及特定数据库方言(PostgreSQL/MySQL)的编译器,用于基于状态对齐生成精确的 DDL Diff。 - `internal/db`: 数据库连接管理器和驱动程序抽象。 - - `main.go`: 启动 gRPC Server,处理来自 Electron 主进程的远程过程调用。 - - `scripts/gen_proto.sh`: 构建脚本,用于从 `.proto` 文件生成 Go 代码,并同步协议定义到前端资源目录供运行时加载。 -- **Electron Main (`frontend/src/main/`)**: - - `daemon.ts`: 管理 Go 后端引擎进程的生命周期(启动、日志记录和停止)。 - - `grpcClient.ts`: 封装 gRPC 客户端,通过严格类型的 Protobuf 协议与后端引擎通信。 - - `index.ts`: 处理 IPC 路由(如 `db:connect`, `db:query`,并通过 `grpcClient` 调用 Go 引擎)以及窗口管理。 - - `store.ts`: 处理应用程序配置、加密凭据以及工作区状态(标签页、会话)的持久化。 -- **React Renderer (`frontend/src/renderer/`)**: + - `main.go`: 启动 gRPC Server,处理来自 Tauri Rust 核心的远程过程调用。 + - `scripts/gen_proto.sh`: 构建脚本,用于从 `.proto` 文件生成 Go 代码。 +- **Tauri Core (`frontend/tauri/`)**: + - `src/lib.rs`: Tauri 应用的核心库。初始化 gRPC 客户端池以通过严格类型的 Protobuf 协议与后端引擎通信;处理前端的 IPC 路由(如 `db_connect`, `db_query`),以及原生窗口控制和日志捕获。 + - `src/main.rs`: 桌面应用启动入口。 + - `tauri.conf.json`: 应用配置,包括构建指令、窗口属性以及 Sidecar (Go 引擎)的绑定声明。 +- **React Renderer (`frontend/src/`)**: - `features/`: 包含核心功能模块: - `connection`: 数据库连接表单和管理。 - `navigator`: 数据库和数据表树形视图。 @@ -58,11 +59,10 @@ vstable 是一款专为开发者设计的现代数据库管理工具,支持可 - `backend/`: Go 后端引擎源码。 - `internal/ast/`: AST 类型、Diff 逻辑以及数据库方言编译器。 - `internal/db/`: 数据库驱动实现。 -- `frontend/`: Electron 应用与 React 前端。 +- `frontend/`: Tauri 应用与 React 前端。 - `e2e/`: 用于全链路验证的 Playwright E2E 测试。 - - `src/main/`: Electron 主进程 (Node.js)。 - - `src/preload/`: 用于上下文隔离的 IPC 桥接脚本。 - - `src/renderer/`: React Web 应用。 + - `tauri/`: Tauri 胶水代码,将 frontend 和 backend 粘合在一起。 + - `src/`: React Web 应用。 - `components/`: 可复用的通用 UI 组件。 - `features/`: 特定领域的业务逻辑与视图。 - `hooks/`, `stores/`: 全局状态管理 (Zustand) 和自定义 React Hooks。 @@ -115,4 +115,4 @@ Allowed types: 7. 建立标签并推送: - `git tag v1.2.0` - `git push --tags` -8. GitHub Actions 或相关 CI/CD 流程在检测到 tag 推送后,自动构建双端产物(Electron Mac/Windows/Linux 与 Go Engine 二进制)并执行发布。 +8. GitHub Actions 或相关 CI/CD 流程在检测到 tag 推送后,自动构建双端产物(Tauri Mac/Windows/Linux 与 Go Engine 二进制)并执行发布。 diff --git a/README.md b/README.md index d101570..ae9808e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@
-
+
-
+