Commit 9e3c8f0e by liimin

docs: 重写 README 为完整项目文档

将原本简单的技术栈列表扩展为完整的项目文档,包含项目简介、技术栈、环境要求、快速开始指南、项目结构、可用脚本、代码规范、提交规范、构建输出说明和常见问题解答
1 parent d74cc81e
...@@ -4,3 +4,4 @@ addwords ...@@ -4,3 +4,4 @@ addwords
noneles noneles
rangestart rangestart
compileroptions compileroptions
lintstagedrc
\ No newline at end of file \ No newline at end of file
1.遇到问题2.解决方案3.技术选型4.技术实施5.呈现效果 # Venus Monorepo
类别 库名
核心引擎 eslint ## 简介
官方规则集 @eslint/js
全局变量支持 globals - 一个使用 `pnpm` 管理的前端/后端与组件库的 Monorepo。
TypeScript 支持 typescript-eslint - 包含应用层(`apps/frontend`, `apps/backend`)与多个可复用包(`packages/*`)。
类型定义(辅助) @types/node - 统一使用 `TypeScript` 与 `Rollup` 构建,配合 `ESLint`、`Prettier`、`Husky`、`lint-staged`、`Commitlint`、`Commitizen` 保持代码与提交规范。
Prettier 集成 eslint-plugin-prettier,eslint-config-prettier
Vue.js 支持 eslint-plugin-vue ## 技术栈
- 工作空间与包管理:`pnpm`(`pnpm-workspace.yaml`)
- 语言:`TypeScript`
- 框架:`Vue 3`(组件库)、可扩展到 React 等
- 构建:`Rollup`(统一打包脚本)
- 代码质量:`ESLint`(含 `vue-eslint-parser`)、`Prettier`、`CSpell`
- 提交规范:`Husky`、`lint-staged`、`Commitlint`、`Commitizen`
## 环境要求
- `Node >= 20`
- `pnpm >= 10.8.1`
## 快速开始
- 安装依赖:
- `pnpm install`
- 初始化 Husky(如未自动安装):
- `pnpm prepare`
- 构建所有包:
- `pnpm build`
- 开发模式(监听并增量打包 packages):
- `node scripts/dev.js`
- 单独构建某个包:
- `node scripts/buildSingle.js <packageName>`
- 示例:`node scripts/buildSingle.js components/vue`
## 项目结构
- `apps/frontend`:前端示例或入口(`tsconfig.json` 使用 `lib: [DOM, ESNext]`)
- `apps/backend`:后端示例或入口(`tsconfig.json` 使用 `types: [node]`)
- `packages/components/vue`:Vue 组件库(输出 `esm/cjs/iife`,`vue` 为 peer 依赖)
- `packages/tools` / `packages/charts` / `packages/cli`:工具、图表、CLI 辅助库
- `scripts/`:统一构建脚本(`build.js`/`dev.js`/`buildSingle.js`/`buildBase.js`)
## 可用脚本
- 格式化:`pnpm lint:prettier`
- 代码检查与修复:`pnpm lint:eslint`
- 拼写检查:`pnpm lint:spellcheck`
- 统一构建所有包:`pnpm build`
- 使用 `Commitizen` 提交:`pnpm commit`
- 预提交钩子:`pnpm precommit`(实际由 `husky` 在 `git commit` 时触发)
## 代码规范与 Lint
- `eslint.config.js`:
- 基础:`@eslint/js` + `typescript-eslint` + `eslint-config-prettier`
- 前端与包(`apps/frontend`、`packages/*`):启用 `eslint-plugin-vue` 的推荐规则;`parser: vue-eslint-parser`,并在 `<script lang="ts">` 使用 `typescript-eslint` 的解析器;`globals: browser`。
- 后端(`apps/backend`):`globals: node`。
- 已忽略:`dist`、`node_modules`、`scripts`、`*.d.ts`、`*.md`。
- `prettier.config.js` 与 `.prettierignore`:统一代码风格,忽略 `dist`、`node_modules` 等。
- `lint-staged`(`.lintstagedrc.js`):
- `*.{js,ts,tsx,jsx,vue}` → `prettier --write`、`eslint --fix`
- `*.{md,json,css,less,scss}` → `prettier --write`
- `CSpell`(`cspell.json`):
- 自定义词典:`./.cspell/custom-dictionary.txt`
- 常见目录与文件忽略(`node_modules`, `dist`, `*.d.ts`, `package.json` 等)
## 提交规范
- 使用 `pnpm commit` 进入交互式提交(`cz-git`),遵循 `commitlint` 规则。
- 可用类型包含:`feat`、`fix`、`docs`、`style`、`refactor`、`perf`、`test`、`build`、`ci`、`chore`、`revert`、`wip`、`workflow`、`types`、`release` 等。
- `husky` 预提交钩子会运行 `lint-staged`:自动执行 `prettier` 与 `eslint`,如失败将阻止提交。
## 构建与输出
- 统一构建脚本会扫描 `packages/*`:
- 仅对存在 `src/index.ts` 的包进行构建。
- Vue 组件包会作为外部依赖保留 `vue`,并在 `iife` 格式下使用 `globals: { vue: "Vue" }`。
- 输出目录:`dist/`,默认 `esm` 与 `cjs`,Vue 组件库可额外输出 `iife`。
## 常见问题
- 推送被拒(非快进):
- `git pull --rebase venus master` → 解决冲突 → `git push -u venus master`
- ESLint 报 `process 未定义`:
- 前端文件应使用浏览器环境,移除无用的 `process` 引用或在后端环境下处理。
- 拼写检查拦截:
- 将需保留的技术术语添加到 `./.cspell/custom-dictionary.txt`,并执行 `pnpm lint:spellcheck`。
## 许可
- `ISC`
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!