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 `