diff --git a/.cursor/rules/app.mdx b/.cursor/rules/app.mdx new file mode 100644 index 0000000..1531ad8 --- /dev/null +++ b/.cursor/rules/app.mdx @@ -0,0 +1,66 @@ +--- +description: "Thin Cursor rules for template apps with-lingui / basic — route by path and task to each app's .github/instructions (Approach A, single source of truth)" +globs: apps/with-lingui/{src,e2e}/**/*.{ts,tsx,css},apps/basic/{src,e2e}/**/*.{ts,tsx,css},apps/with-lingui/playwright.config.ts,apps/basic/playwright.config.ts +alwaysApply: false +--- + +# Template apps — AI rules (thin rule) + +This file at the **monorepo root** is the shared **Cursor thin rule** for `apps/with-lingui` and `apps/basic`. It only maps **which files you edit → which instruction file to follow**. Do **not** duplicate long guidance here. + +**Single source of truth** (on conflict, these win): + +- `apps/with-lingui/.github/instructions/*.instructions.md` +- `apps/basic/.github/instructions/*.instructions.md` + +For full text in chat, `@`-reference the path below. + +--- + +## General + +- When editing template app source or tests matched by `globs`, pick the row in the tables below, then follow that file’s **Do / Do Not / Validation**. +- **with-lingui** includes Lingui i18n; **basic** uses plain string literals in UI (default English; no bundled locale switcher or translation catalogs). +- When **frontend** and **refactor** both apply: **refactor intent** (dedupe, naming, structure, no behavior change) is governed by `refactor.instructions.md`; UI/interaction details still follow `frontend.instructions.md`. +- If you change an instruction file’s `applyTo`, keep this file’s frontmatter `globs` aligned so both apps’ TS/TSX/CSS/E2E paths stay covered. + +--- + +## apps/with-lingui + +| Scenario | Typical paths | Instruction file | +| --- | --- | --- | +| Frontend (UI, routes, components, styles, Ant Design, i18n copy) | `apps/with-lingui/src/**/*.{ts,tsx,css}` | `apps/with-lingui/.github/instructions/frontend.instructions.md` | +| API (clients, Zod, HTTP, MSW handlers) | `apps/with-lingui/src/api/**`, `apps/with-lingui/src/mocks/handlers/**`, `createHandler.ts` | `apps/with-lingui/.github/instructions/api.instructions.md` | +| Testing (Playwright, MSW, test config) | `apps/with-lingui/e2e/**`, `apps/with-lingui/src/mocks/**`, `playwright.config.ts` | `apps/with-lingui/.github/instructions/testing.instructions.md` | +| Refactor (behavior-preserving) | `apps/with-lingui/src/**/*.{ts,tsx}` | `apps/with-lingui/.github/instructions/refactor.instructions.md` | +| Add CRUD resource | `src/api/**`, `src/mocks/**`, `src/routes/_auth/**`, `e2e/**/*.spec.ts` | `apps/with-lingui/.github/instructions/add-resource.instructions.md` (mirror `users`) | + +**@ examples:** + +- `@apps/with-lingui/.github/instructions/frontend.instructions.md` +- `@apps/with-lingui/.github/instructions/add-resource.instructions.md` + +See also `apps/with-lingui/AGENTS.md` (Vite+ / `vp` workflow). + +--- + +## apps/basic + +| Scenario | Typical paths | Instruction file | +| --- | --- | --- | +| Frontend (UI, routes, components, styles, Ant Design, English copy) | `apps/basic/src/**/*.{ts,tsx,css}` | `apps/basic/.github/instructions/frontend.instructions.md` | +| API | `apps/basic/src/api/**`, `apps/basic/src/mocks/handlers/**`, `createHandler.ts` | `apps/basic/.github/instructions/api.instructions.md` | +| Testing | `apps/basic/e2e/**`, `apps/basic/src/mocks/**`, `playwright.config.ts` | `apps/basic/.github/instructions/testing.instructions.md` | +| Refactor | `apps/basic/src/**/*.{ts,tsx}` | `apps/basic/.github/instructions/refactor.instructions.md` | + +**@ example:** `@apps/basic/.github/instructions/frontend.instructions.md` + +See also `apps/basic/AGENTS.md`. + +--- + +## Maintenance + +- Humans and agents should **edit** each app’s `.github/instructions/` first; this file only maintains the routing table and `globs`. +- Comment language is still governed by `.cursor/rules/english-only-comments.md` (not UI copy or docs). diff --git a/.cursor/rules/with-lingui-add-resource.mdc b/.cursor/rules/with-lingui-add-resource.mdc deleted file mode 100644 index 7148017..0000000 --- a/.cursor/rules/with-lingui-add-resource.mdc +++ /dev/null @@ -1,15 +0,0 @@ ---- -description: "Add a new CRUD resource / scaffold (with-lingui)." -globs: apps/with-lingui/src/api/**/*.ts,apps/with-lingui/src/mocks/**/*.ts,apps/with-lingui/src/routes/_auth/**/*.tsx,apps/with-lingui/e2e/**/*.spec.ts -alwaysApply: false ---- - -# with-lingui · Add resource (thin rule) - -**Single source of truth:** - -`apps/with-lingui/.github/instructions/add-resource.instructions.md` - -When adding a resource, follow that recipe (mirror the `users` example). On conflict, the `.instructions.md` file wins. - -`@apps/with-lingui/.github/instructions/add-resource.instructions.md` diff --git a/.cursor/rules/with-lingui-api.mdc b/.cursor/rules/with-lingui-api.mdc deleted file mode 100644 index 3f0cd2c..0000000 --- a/.cursor/rules/with-lingui-api.mdc +++ /dev/null @@ -1,15 +0,0 @@ ---- -description: "API clients, Zod schemas, HTTP, MSW handlers (with-lingui)." -globs: apps/with-lingui/src/api/**/*.ts,apps/with-lingui/src/mocks/handlers/**/*.ts,apps/with-lingui/src/mocks/createHandler.ts -alwaysApply: false ---- - -# with-lingui · API(薄规则) - -**唯一细则来源**: - -`apps/with-lingui/.github/instructions/api.instructions.md` - -编辑符合 `globs` 的文件时,遵守该文件中的约定;冲突以 `.instructions.md` 为准。 - -`@apps/with-lingui/.github/instructions/api.instructions.md` diff --git a/.cursor/rules/with-lingui-frontend.mdc b/.cursor/rules/with-lingui-frontend.mdc deleted file mode 100644 index f848906..0000000 --- a/.cursor/rules/with-lingui-frontend.mdc +++ /dev/null @@ -1,15 +0,0 @@ ---- -description: "React UI, routes, components, styles, layout, i18n, Ant Design (with-lingui)." -globs: apps/with-lingui/src/**/*.{ts,tsx,css} -alwaysApply: false ---- - -# with-lingui · Frontend(薄规则) - -**唯一细则来源**(勿在此文件重复维护长文): - -`apps/with-lingui/.github/instructions/frontend.instructions.md` - -编辑符合 `globs` 的文件时,遵守该文件中的 Do / Do Not / Validation;如有冲突,以 `.instructions.md` 为准。 - -需要全文进上下文时,在对话里引用:`@apps/with-lingui/.github/instructions/frontend.instructions.md`。 diff --git a/.cursor/rules/with-lingui-refactor.mdc b/.cursor/rules/with-lingui-refactor.mdc deleted file mode 100644 index 5963e5c..0000000 --- a/.cursor/rules/with-lingui-refactor.mdc +++ /dev/null @@ -1,15 +0,0 @@ ---- -description: "Refactors without behavior change — dedupe, naming, structure (with-lingui)." -globs: apps/with-lingui/src/**/*.{ts,tsx} -alwaysApply: false ---- - -# with-lingui · Refactor(薄规则) - -**唯一细则来源**: - -`apps/with-lingui/.github/instructions/refactor.instructions.md` - -做行为保持式重构时遵守该文件;与 frontend 规则同时命中时,**重构意图**以本文件指向的 refactor 指令为准,其余 UI 细节仍以 `frontend.instructions.md` 为准。 - -`@apps/with-lingui/.github/instructions/refactor.instructions.md` diff --git a/.cursor/rules/with-lingui-testing.mdc b/.cursor/rules/with-lingui-testing.mdc deleted file mode 100644 index ea60c0a..0000000 --- a/.cursor/rules/with-lingui-testing.mdc +++ /dev/null @@ -1,15 +0,0 @@ ---- -description: "Playwright e2e, MSW mocks, test config (with-lingui)." -globs: apps/with-lingui/e2e/**/*.ts,apps/with-lingui/e2e/**/*.tsx,apps/with-lingui/src/mocks/**/*.ts,apps/with-lingui/playwright.config.ts -alwaysApply: false ---- - -# with-lingui · Testing(薄规则) - -**唯一细则来源**: - -`apps/with-lingui/.github/instructions/testing.instructions.md` - -编辑符合 `globs` 的文件时,遵守该文件中的约定;冲突以 `.instructions.md` 为准。 - -`@apps/with-lingui/.github/instructions/testing.instructions.md` diff --git a/.githooks/README.md b/.githooks/README.md index 7425e1f..327b238 100644 --- a/.githooks/README.md +++ b/.githooks/README.md @@ -1,26 +1,30 @@ -# Git hooks(仓库根) +# Git hooks (repository root) -本目录为 **monorepo 根级** Git 钩子。提交时根据暂存文件路径,在对应子项目目录执行检查(例如 `apps/with-lingui` 下执行 `vp staged`,以便正确读取该目录的 `vite.config.ts`)。 +This directory holds **monorepo root-level** Git hooks. On commit, checks run in the matching subproject based on staged file paths (for example, `vp staged` under `apps/with-lingui` so that directory’s `vite.config.ts` is loaded correctly). -模板应用目录内的 `.vite-hooks/`(如 `apps/with-lingui/.vite-hooks/`)留给 **模板单独拷贝出去使用**;在本仓库开发时请使用根级钩子,避免在仓库根执行 `vp staged` 找不到 `vite.config.ts`。 +Per-app `.vite-hooks/` under template apps (e.g. `apps/with-lingui/.vite-hooks/`) are for **copying a template out on its own**. When developing in this repo, use the root hooks so `vp staged` at the repo root does not fail to find `vite.config.ts`. -## 启用方式(一次性) +## Monorepo and `vp config` -在仓库根目录执行: +The root `package.json` `preinstall` sets `core.hooksPath=.githooks` before dependencies install and writes `vp.hooks.disabled=true` in **this clone** so parallel `prepare` scripts (`vp config`) from multiple workspaces do not fight over `.git/config` and cause lock conflicts. Template apps still use `"prepare": "vp config"`; when copied out alone they do not get the root `preinstall`. + +## Enabling (one-time) + +From the repository root: ```bash git config core.hooksPath .githooks ``` -或使用: +Or: ```bash pnpm run setup:git-hooks ``` -验证: +Verify: ```bash git config core.hooksPath -# 应输出:.githooks +# Expected: .githooks ``` diff --git a/.gitignore b/.gitignore index f63e72f..23920af 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,7 @@ yarn-error.log* # Git worktrees .worktrees/ -# Cursor:仅共享项目规则;其余本机数据仍忽略(方案 A — 细则单源在 apps/with-lingui/.github/instructions) +# Cursor: share project rules only (e.g. .cursor/rules/app.mdx); ignore other local Cursor data (instruction source of truth in each app’s .github/instructions) .cursor/* !.cursor/rules/ !.cursor/rules/** diff --git a/README.md b/README.md index 345d91d..298b1e9 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Antd Admin provides production-style admin templates with modern frontend toolin Available templates: -- `basic`: English-only setup -- `with-lingui`: Bilingual setup (`en` + `zh`) with Lingui +- `basic`: Admin template with plain-string UI copy (default English; no bundled Lingui) +- `with-lingui`: Lingui i18n workflow (`en` + `zh`) with locale switching Scaffolding CLI: @@ -61,6 +61,10 @@ pnpm dlx init-antd-admin@latest my-app --example with-lingui --skip-install For detailed CLI behavior, see `[packages/create/README.md](./packages/create/README.md)`. +### Working in this monorepo (Cursor) + +Template apps ship scoped guidance under each app’s `.github/instructions/` (see each app’s `README.md`). **Monorepo-only:** root [`.cursor/rules/app.mdx`](./.cursor/rules/app.mdx) is a thin router to those files when editing `apps/with-lingui` or `apps/basic`; it is **not** included in `init-antd-admin` output. + Production docs: [https://antd-admin-doc.zuiidea.top](https://antd-admin-doc.zuiidea.top) ## Links diff --git a/apps/basic/.github/instructions/frontend.instructions.md b/apps/basic/.github/instructions/frontend.instructions.md index 1f88597..4034cca 100644 --- a/apps/basic/.github/instructions/frontend.instructions.md +++ b/apps/basic/.github/instructions/frontend.instructions.md @@ -2,7 +2,7 @@ ## applyTo: "src/\*_/_.{ts,tsx,css}" -description: "Use when editing React UI, route pages, components, styles, layout, i18n text, or Ant Design behavior. Keywords: frontend, component, page, ui, layout, style, antd, i18n." +description: "Use when editing React UI, route pages, components, styles, layout, copy, or Ant Design behavior. Keywords: frontend, component, page, ui, layout, style, antd, english copy." # Frontend Instructions @@ -16,7 +16,7 @@ Keep frontend changes predictable, minimal, and reusable for AI-assisted edits. - Prefer reusable components and hooks over copy-paste logic. - Keep styles token-driven using existing theme/store patterns. - For Ant Design styling, follow this priority: component native API (`variant`/`type`/`size`/`styles`/`classNames`) -> `theme.useToken()` with inline `style` -> `className` + external CSS. -- Keep translations compatible with Lingui macros and catalogs. +- Keep user-facing copy in English as plain string literals (this template has no i18n layer). - Follow current folder conventions under src/components and src/routes. ## Do Not diff --git a/apps/basic/README.md b/apps/basic/README.md index 822450c..65e4eb8 100644 --- a/apps/basic/README.md +++ b/apps/basic/README.md @@ -8,7 +8,7 @@