From 2a7f7be738ebc5bd3a8461d8c88409b7679e6516 Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 2 Jul 2026 18:10:11 +0800 Subject: [PATCH] =?UTF-8?q?chore(docker,ci):=20Dockerfile=20=E4=B8=8E=20CI?= =?UTF-8?q?=20=E5=88=87=E6=8D=A2=20pnpm=20workspace,docs=20=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dockerfile: - Node 22 安装段追加 corepack enable + pnpm 11.8.0 - 缓存层从'只 tiptap 的 package.json'扩展为整个 workspace (libs/package.json + pnpm-workspace.yaml + pnpm-lock.yaml + 4 lib manifest), npm ci 改为 pnpm install --frozen-lockfile,覆盖全部 4 个 lib 的 Docker 层缓存 - 构建步骤 make build-editor 改为 make build-libs Gitea CI: - check job 的 Install Node 步骤加装 pnpm,新增 Biome lint 步骤 (cd libs && pnpm install --frozen-lockfile && pnpm exec biome check .) - build job 同步装 pnpm,make build 不变(Makefile 已改用 workspace) .dockerignore: 补齐其余 3 个 lib 的 public 产物 + workspace node_modules 模式 AGENTS.md: Development Commands 删 make clippy、新增 make lint/make fix 说明; Prerequisites 补 Biome;libs 段改为 pnpm workspace 模型;修正文档漂移 (tt-reveal→tt-expand,eval→Reflect::get) --- .dockerignore | 6 +++++- .gitea/workflows/ci.yaml | 9 +++++++-- AGENTS.md | 34 ++++++++++++++++++---------------- Dockerfile | 22 +++++++++++++++------- 4 files changed, 45 insertions(+), 26 deletions(-) diff --git a/.dockerignore b/.dockerignore index b09a6f9..bec6fc5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,12 +3,16 @@ target/ dist/ .dioxus/ node_modules/ -libs/tiptap-editor/node_modules/ +libs/node_modules/ +libs/*/node_modules/ # Generated assets are rebuilt inside the container. public/style.css public/highlight.css public/tiptap/ +public/codemirror/ +public/lightbox/ +public/yggdrasil-core/ # Uploads directory is created at runtime; only keep the gitkeep marker. uploads/* diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 69dfb7e..e161c12 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -35,10 +35,11 @@ jobs: done echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install Node.js + - name: Install Node.js & pnpm run: | apt-get update apt-get install -y nodejs npm + npm install -g pnpm - name: Install Rust target run: rustup target add wasm32-unknown-unknown @@ -55,6 +56,9 @@ jobs: - name: Run Clippy run: cargo clippy --all-targets --all-features -- -D warnings + - name: Biome lint (libs) + run: cd libs && pnpm install --frozen-lockfile && pnpm exec biome check . + - name: Run tests run: cargo test --all-features @@ -89,10 +93,11 @@ jobs: done echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install Node.js + - name: Install Node.js & pnpm run: | apt-get update apt-get install -y nodejs npm + npm install -g pnpm - name: Install Rust target run: rustup target add wasm32-unknown-unknown diff --git a/AGENTS.md b/AGENTS.md index 3dff274..ca27479 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -14,35 +14,37 @@ ## Development Commands ```bash -make dev # 增量构建 4 个 libs + tailwindcss watch + dx serve (needs PostgreSQL, SSR_CACHE_SECS=0) -make build # build-editor → build-lightbox → build-core → build-codemirror → highlight-css → tailwindcss → doc → dx build --release → restore-webp +make dev # 增量构建 4 个 libs (pnpm -r run build) + tailwindcss watch + dx serve (needs PostgreSQL, SSR_CACHE_SECS=0) +make build # pnpm install → build-libs → highlight-css → tailwindcss → doc → dx build --release → restore-webp make build-linux # 客户端 + 服务端分离构建,target x86_64-unknown-linux-musl make build-freebsd # cross-compile FreeBSD x86_64 server binary (clang + lld + sysroot, via cargo, not dx) make freebsd-sysroot # download/extract FreeBSD base.txz → .freebsd-sysroot/ (idempotent) make css # one-shot Tailwind build make css-watch # Tailwind watch mode -make test # cargo test + pnpm test in all 4 libs (tiptap-editor / lightbox / yggdrasil-core / codemirror-editor) +make test # cargo test + pnpm -r run test (all 4 libs: tiptap-editor / lightbox / yggdrasil-core / codemirror-editor) make doc # cargo doc (ayu 主题) → 拷贝到 public/doc/,随 build 发布 make doc-open # 同 doc,生成后自动用浏览器打开(本地预览,不拷贝) -make clippy # cargo clippy --all-targets --all-features -- -D warnings (严格模式,warning 即失败) -make fix # cargo fix --allow-dirty -make clean # cargo clean + rm public/{style.css,highlight.css,doc} + rm -rf uploads/.cache +make lint # Biome check (libs) + cargo clippy (严格模式,warning 即失败) +make fix # biome format --write (libs) + cargo fix --allow-dirty +make clean # cargo clean + rm public/{style.css,highlight.css,doc} + rm -rf uploads/.cache + rm -rf libs/node_modules libs/*/node_modules ``` -**Build order matters**: `make build` runs all 4 lib builds → `highlight-css` (`cargo run --bin generate_highlight_css`) → `tailwindcss --minify` → `doc` → `dx build --release` → `restore-webp`. Do not run `dx build --release` alone. +**Build order matters**: `make build` runs `pnpm install --frozen-lockfile` (in `libs/`) → `build-libs` (`pnpm -r run build`, all 4 libs in parallel) → `highlight-css` (`cargo run --bin generate_highlight_css`) → `tailwindcss --minify` → `doc` → `dx build --release` → `restore-webp`. Do not run `dx build --release` alone. **`restore-webp` workaround**: dx build 0.7.9 re-encodes `public/*.webp` into VP8L lossless stills (drops animation frames, 7-8× larger), contradicting the "verbatim copy" promise. `restore-webp` overwrites `.webp` in `target/dx/**/web/public/` from source `public/`. SVG/ICO are unaffected. Remove once upstream fixes it. -**Libs use pnpm, not npm**: every lib has `pnpm-lock.yaml`; Makefile recipes use `pnpm ci`/`pnpm install`/`pnpm run`. The `*-incremental` targets skip install (assume `node_modules` present) for faster `make dev`. +**JS workspace lives under `libs/`**: `libs/` is a pnpm workspace — root `libs/package.json` hoists the 4 shared devDeps (`happy-dom`/`typescript`/`vite`/`vitest`) + Biome; `libs/pnpm-workspace.yaml` lists `libs/*` packages; `libs/pnpm-lock.yaml` is the single lockfile. First-time setup: `cd libs && pnpm install`. All Makefile recipes `cd libs && pnpm ...`. Build a single lib: `make build-editor` (≈ `cd libs && pnpm --filter @yggdrasil/tiptap-editor run build`). ## Prerequisites - Rust 1.95+ with `wasm32-unknown-unknown` target - `dx` CLI (`cargo install dioxus-cli`) - `tailwindcss` CLI v4 — install via `npm install -g @tailwindcss/cli` (v4 splits the CLI into its own package; the `tailwindcss` core package has no `bin`), or use the standalone binary -- `pnpm` (all 4 `libs/` subprojects use it) +- `pnpm` 11+ (`libs/` is a pnpm workspace; vendored as a `devDependency` via corepack, but a global install is convenient) - PostgreSQL running locally +**Biome** (linter + formatter for `libs/`) is a `devDependency` in `libs/package.json` — no separate install. `make lint` runs `biome check` + `cargo clippy`; `make fix` runs `biome format --write` + `cargo fix`. Config in `libs/biome.json`. + ## Environment Create `.env` (not committed): @@ -152,16 +154,16 @@ src/codemirror_bridge.rs — wasm-bindgen bindings for CodeMirror editor (mirror ## Frontend Lib Subprojects -Four Vite-built IIFE libraries under `libs/`, each with `pnpm-lock.yaml`. Built artifacts go to `public//` — **do not edit `public//` files; they are build artifacts**. Each `build` script is `tsc --noEmit && vite build` (type-check before bundle). Output is IIFE because Dioxus `[web.resource] script` injects bare `