chore: update dependencies and documentation, optimize build toolchain (#6060)

* chore: update packageManager version to pnpm@10.9.0 for compatibility improvements

* chore: Update dependent versions and configurations to improve compatibility and stability

- Update Node version to 22.1.0
- Updated pnpm version to 10.10.0
- Fixed syntax error in prettier command in lintstagedrc
- Update dependent versions in pnpm-lock.yaml to ensure consistency
- Update format and content in README documents to improve readability

* fix: lint error
pull/86/head^2
Vben 2025-04-28 23:08:05 +08:00 committed by GitHub
parent 681c1dc267
commit dd833ca56b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 3229 additions and 1523 deletions

View File

@ -15,6 +15,6 @@ export default {
],
'package.json': ['prettier --cache --write'],
'{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': [
'prettier --cache --write--parser json',
'prettier --cache --write --parser json',
],
};

View File

@ -1 +1 @@
20.14.0
22.1.0

View File

@ -14,7 +14,7 @@
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.cursorBlinking": "expand",
"editor.largeFileOptimizations": false,
"editor.largeFileOptimizations": true,
"editor.accessibilitySupport": "off",
"editor.cursorSmoothCaretAnimation": "on",
"editor.guides.bracketPairs": "active",
@ -91,6 +91,7 @@
"**/bower_components": true,
"**/.turbo": true,
"**/.idea": true,
"**/.vitepress": true,
"**/tmp": true,
"**/.git": true,
"**/.svn": true,
@ -112,6 +113,8 @@
"**/yarn.lock": true
},
"typescript.tsserver.exclude": ["**/node_modules", "**/dist", "**/.turbo"],
// search
"search.searchEditor.singleClickBehaviour": "peekDefinition",
"search.followSymlinks": false,

View File

@ -1,11 +1,22 @@
<div align="center"> <a href="https://github.com/anncwb/vue-vben-admin"> <img alt="VbenAdmin Logo" width="215" src="https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp"> </a> <br> <br>
<div align="center">
<a href="https://github.com/anncwb/vue-vben-admin">
<img alt="VbenAdmin Logo" width="215" src="https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp">
</a>
<br>
<br>
[![license](https://img.shields.io/github/license/anncwb/vue-vben-admin.svg)](LICENSE)
<h1>Vue Vben Admin</h1>
<h1>Vue Vben Admin</h1>
</div>
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vbenjs_vue-vben-admin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin) ![codeql](https://github.com/vbenjs/vue-vben-admin/actions/workflows/codeql.yml/badge.svg) ![build](https://github.com/vbenjs/vue-vben-admin/actions/workflows/build.yml/badge.svg) ![ci](https://github.com/vbenjs/vue-vben-admin/actions/workflows/ci.yml/badge.svg) ![deploy](https://github.com/vbenjs/vue-vben-admin/actions/workflows/deploy.yml/badge.svg)
<div align="center">
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vbenjs_vue-vben-admin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin)
![codeql](https://github.com/vbenjs/vue-vben-admin/actions/workflows/codeql.yml/badge.svg)
![build](https://github.com/vbenjs/vue-vben-admin/actions/workflows/build.yml/badge.svg)
![ci](https://github.com/vbenjs/vue-vben-admin/actions/workflows/ci.yml/badge.svg)
![deploy](https://github.com/vbenjs/vue-vben-admin/actions/workflows/deploy.yml/badge.svg)
</div>
**日本語** | [English](./README.md) | [中文](./README.zh-CN.md)
@ -15,27 +26,27 @@ Vue Vben Adminは、最新の`vue3`、`vite`、`TypeScript`などの主流技術
## アップグレード通知
これは最新バージョン5.0であり、以前のバージョンとは互換性がありません。新しいプロジェクトを開始する場合は、最新バージョンを使用することをお勧めします。古いバージョンを表示したい場合は、[v2ブランチ](https://github.com/vbenjs/vue-vben-admin/tree/v2)を使用してください。
これは最新バージョン `5.0` であり、以前のバージョンとは互換性がありません。新しいプロジェクトを開始する場合は、最新バージョンを使用することをお勧めします。古いバージョンを表示したい場合は、[v2ブランチ](https://github.com/vbenjs/vue-vben-admin/tree/v2)を使用してください。
## 特徴
- **最新技術スタック**: Vue 3やViteなどの最先端フロントエンド技術で開発
- **TypeScript**: アプリケーション規模のJavaScriptのための言語
- **テーマ**: 複数のテーマカラーが利用可能で、カスタマイズオプションも豊富
- **国際化**: 完全な内蔵国際化サポート
- **権限管理**: 動的ルートベースの権限生成ソリューションを内蔵
- **最新技術スタック**Vue 3やViteなどの最先端フロントエンド技術で開発
- **TypeScript**アプリケーション規模のJavaScriptのための言語
- **テーマ**複数のテーマカラーが利用可能で、カスタマイズオプションも豊富
- **国際化**完全な内蔵国際化サポート
- **権限管理**動的ルートベースの権限生成ソリューションを内蔵
## プレビュー
- [Vben Admin](https://vben.pro/) - フルバージョンの中国語サイト
テストアカウント: vben/123456
テストアカウントvben/123456
<p align="center">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview1.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview2.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview3.png">
</p>
<div align="center">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview1.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview2.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview3.png">
</div>
### Gitpodを使用
@ -49,30 +60,27 @@ GitpodGitHub用の無料オンライン開発環境でプロジェクト
## インストールと使用
- プロジェクトコードを取得
1. プロジェクトコードを取得
```bash
git clone https://github.com/vbenjs/vue-vben-admin.git
```
- 依存関係のインストール
2. 依存関係のインストール
```bash
cd vue-vben-admin
npm i -g corepack
pnpm install
```
- 実行
3. 実行
```bash
pnpm dev
```
- ビルド
4. ビルド
```bash
pnpm build
@ -86,40 +94,39 @@ pnpm build
ご参加をお待ちしております![Issueを提出](https://github.com/anncwb/vue-vben-admin/issues/new/choose)するか、Pull Requestを送信してください。
**Pull Request:**
**Pull Request プロセス:**
1. コードをフォーク
2. 自分のブランチを作成: `git checkout -b feat/xxxx`
3. 変更をコミット: `git commit -am 'feat(function): add xxxxx'`
4. ブランチをプッシュ: `git push origin feat/xxxx`
1. コードをフォーク
2. 自分のブランチを作成`git checkout -b feat/xxxx`
3. 変更をコミット`git commit -am 'feat(function): add xxxxx'`
4. ブランチをプッシュ`git push origin feat/xxxx`
5. `pull request`を送信
## Git貢献提出規則
- 参考 [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) 規則 ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
参考 [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) 規則 ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
- `feat` 新機能の追加
- `fix` 問題/バグの修正
- `style` コードスタイルに関連し、実行結果に影響しない
- `perf` 最適化/パフォーマンス向上
- `refactor` リファクタリング
- `revert` 変更の取り消し
- `test` テスト関連
- `docs` ドキュメント/注釈
- `chore` 依存関係の更新/スキャフォールディング設定の変更など
- `ci` 継続的インテグレーション
- `types` 型定義ファイルの変更
- `wip` 開発中
- `feat` 新機能の追加
- `fix` 問題/バグの修正
- `style` コードスタイルに関連し、実行結果に影響しない
- `perf` 最適化/パフォーマンス向上
- `refactor` リファクタリング
- `revert` 変更の取り消し
- `test` テスト関連
- `docs` ドキュメント/注釈
- `chore` 依存関係の更新/スキャフォールディング設定の変更など
- `ci` 継続的インテグレーション
- `types` 型定義ファイルの変更
## ブラウザサポート
ローカル開発には`Chrome 80+`ブラウザを推奨します
ローカル開発には `Chrome 80+` ブラウザを推奨します
モダンブラウザをサポートし、IEはサポートしません
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: | :-: |
| サポートしない | 最新2バージョン | 最新2バージョン | 最新2バージョン | 最新2バージョン |
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: |
| 最新2バージョン | 最新2バージョン | 最新2バージョン | 最新2バージョン |
## メンテナー
@ -140,8 +147,7 @@ pnpm build
## 貢献者
<a href="https://github.com/vbenjs/vue-vben-admin/graphs/contributors">
<img alt="Contributors"
src="https://opencollective.com/vbenjs/contributors.svg?button=false" />
<img alt="Contributors" src="https://opencollective.com/vbenjs/contributors.svg?button=false" />
</a>
## Discord

View File

@ -1,11 +1,22 @@
<div align="center"> <a href="https://github.com/anncwb/vue-vben-admin"> <img alt="VbenAdmin Logo" width="215" src="https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp"> </a> <br> <br>
<div align="center">
<a href="https://github.com/anncwb/vue-vben-admin">
<img alt="VbenAdmin Logo" width="215" src="https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp">
</a>
<br>
<br>
[![license](https://img.shields.io/github/license/anncwb/vue-vben-admin.svg)](LICENSE)
<h1>Vue Vben Admin</h1>
<h1>Vue Vben Admin</h1>
</div>
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vbenjs_vue-vben-admin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin) ![codeql](https://github.com/vbenjs/vue-vben-admin/actions/workflows/codeql.yml/badge.svg) ![build](https://github.com/vbenjs/vue-vben-admin/actions/workflows/build.yml/badge.svg) ![ci](https://github.com/vbenjs/vue-vben-admin/actions/workflows/ci.yml/badge.svg) ![deploy](https://github.com/vbenjs/vue-vben-admin/actions/workflows/deploy.yml/badge.svg)
<div align="center">
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vbenjs_vue-vben-admin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin)
![codeql](https://github.com/vbenjs/vue-vben-admin/actions/workflows/codeql.yml/badge.svg)
![build](https://github.com/vbenjs/vue-vben-admin/actions/workflows/build.yml/badge.svg)
![ci](https://github.com/vbenjs/vue-vben-admin/actions/workflows/ci.yml/badge.svg)
![deploy](https://github.com/vbenjs/vue-vben-admin/actions/workflows/deploy.yml/badge.svg)
</div>
**English** | [中文](./README.zh-CN.md) | [日本語](./README.ja-JP.md)
@ -17,7 +28,7 @@ Vue Vben Admin is a free and open source middle and back-end template. Using the
This is the latest version, 5.0, and it is not compatible with previous versions. If you are starting a new project, it is recommended to use the latest version. If you wish to view the old version, please use the [v2 branch](https://github.com/vbenjs/vue-vben-admin/tree/v2).
## Feature
## Features
- **Latest Technology Stack**: Developed with cutting-edge front-end technologies like Vue 3 and Vite
- **TypeScript**: A language for application-scale JavaScript
@ -31,11 +42,11 @@ This is the latest version, 5.0, and it is not compatible with previous versions
Test Account: vben/123456
<p align="center">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview1.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview2.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview3.png">
</p>
<div align="center">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview1.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview2.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview3.png">
</div>
### Use Gitpod
@ -47,31 +58,29 @@ Open the project in Gitpod (free online dev environment for GitHub) and start co
[Document](https://doc.vben.pro/)
## Install and use
## Install and Use
- Get the project code
1. Get the project code
```bash
git clone https://github.com/vbenjs/vue-vben-admin.git
```
- Installation dependencies
2. Install dependencies
```bash
cd vue-vben-admin
npm i -g corepack
pnpm install
```
- run
3. Run
```bash
pnpm dev
```
- build
4. Build
```bash
pnpm build
@ -81,44 +90,43 @@ pnpm build
[CHANGELOG](https://github.com/vbenjs/vue-vben-admin/releases)
## How to contribute
## How to Contribute
You are very welcome to join[Raise an issue](https://github.com/anncwb/vue-vben-admin/issues/new/choose) Or submit a Pull Request。
You are very welcome to join! [Raise an issue](https://github.com/anncwb/vue-vben-admin/issues/new/choose) or submit a Pull Request.
**Pull Request:**
**Pull Request Process:**
1. Fork code!
2. Create your own branch: `git checkout -b feat/xxxx`
1. Fork the code
2. Create your branch: `git checkout -b feat/xxxx`
3. Submit your changes: `git commit -am 'feat(function): add xxxxx'`
4. Push your branch: `git push origin feat/xxxx`
5. submit`pull request`
5. Submit `pull request`
## Git Contribution submission specification
## Git Contribution Submission Specification
- reference [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) specification ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
Reference [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) specification ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
- `feat` Add new features
- `fix` Fix the problem/BUG
- `style` The code style is related and does not affect the running result
- `perf` Optimization/performance improvement
- `refactor` Refactor
- `revert` Undo edit
- `test` Test related
- `docs` Documentation/notes
- `chore` Dependency update/scaffolding configuration modification etc.
- `ci` Continuous integration
- `types` Type definition file changes
- `wip` In development
- `feat` Add new features
- `fix` Fix the problem/BUG
- `style` The code style is related and does not affect the running result
- `perf` Optimization/performance improvement
- `refactor` Refactor
- `revert` Undo edit
- `test` Test related
- `docs` Documentation/notes
- `chore` Dependency update/scaffolding configuration modification etc.
- `ci` Continuous integration
- `types` Type definition file changes
## Browser support
## Browser Support
The `Chrome 80+` browser is recommended for local development
Support modern browsers, not IE
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: | :-: |
| not support | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: |
| last 2 versions | last 2 versions | last 2 versions | last 2 versions |
## Maintainer
@ -136,11 +144,10 @@ If you think this project is helpful to you, you can help the author buy a cup o
<a style="display: block;width: 100px;height: 50px;line-height: 50px; color: #fff;text-align: center; background: #408aee;border-radius: 4px;" href="https://www.paypal.com/paypalme/cvvben">Paypal Me</a>
## Contributor
## Contributors
<a href="https://github.com/vbenjs/vue-vben-admin/graphs/contributors">
<img alt="Contributors"
src="https://opencollective.com/vbenjs/contributors.svg?button=false" />
<img alt="Contributors" src="https://opencollective.com/vbenjs/contributors.svg?button=false" />
</a>
## Discord

View File

@ -1,11 +1,22 @@
<div align="center"> <a href="https://github.com/anncwb/vue-vben-admin"> <img alt="VbenAdmin Logo" width="215" src="https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp"> </a> <br> <br>
<div align="center">
<a href="https://github.com/anncwb/vue-vben-admin">
<img alt="VbenAdmin Logo" width="215" src="https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp">
</a>
<br>
<br>
[![license](https://img.shields.io/github/license/anncwb/vue-vben-admin.svg)](LICENSE)
<h1>Vue Vben Admin</h1>
<h1>Vue Vben Admin</h1>
</div>
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vbenjs_vue-vben-admin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin) ![codeql](https://github.com/vbenjs/vue-vben-admin/actions/workflows/codeql.yml/badge.svg) ![build](https://github.com/vbenjs/vue-vben-admin/actions/workflows/build.yml/badge.svg) ![ci](https://github.com/vbenjs/vue-vben-admin/actions/workflows/ci.yml/badge.svg) ![deploy](https://github.com/vbenjs/vue-vben-admin/actions/workflows/deploy.yml/badge.svg)
<div align="center">
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vbenjs_vue-vben-admin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin)
![codeql](https://github.com/vbenjs/vue-vben-admin/actions/workflows/codeql.yml/badge.svg)
![build](https://github.com/vbenjs/vue-vben-admin/actions/workflows/build.yml/badge.svg)
![ci](https://github.com/vbenjs/vue-vben-admin/actions/workflows/ci.yml/badge.svg)
![deploy](https://github.com/vbenjs/vue-vben-admin/actions/workflows/deploy.yml/badge.svg)
</div>
**中文** | [English](./README.md) | [日本語](./README.ja-JP.md)
@ -15,31 +26,31 @@ Vue Vben Admin 是 Vue Vben Admin 的升级版本。作为一个免费开源的
## 升级提示
该版本为最新版本`5.0`, 与其他版本不兼容,如果你是新项目,建议使用最新版本。如果你想查看旧版本,请使用 [v2 分支](https://github.com/vbenjs/vue-vben-admin/tree/v2)
该版本为最新版本 `5.0`与其他版本不兼容,如果你是新项目,建议使用最新版本。如果你想查看旧版本,请使用 [v2 分支](https://github.com/vbenjs/vue-vben-admin/tree/v2)
## 特性
- **最新技术栈**:使用 Vue3/vite 等前端前沿技术开发
- **TypeScript**: 应用程序级 JavaScript 的语言
- **TypeScript**应用程序级 JavaScript 的语言
- **主题**:提供多套主题色彩,可配置自定义主题
- **国际化**:内置完善的国际化方案
- **权限** 内置完善的动态路由权限生成方案
- **权限**内置完善的动态路由权限生成方案
## 预览
- [Vben Admin](https://vben.pro/) - 完整版中文站点
测试账号: vben/123456
测试账号vben/123456
<p align="center">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview1.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview2.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview3.png">
</p>
<div align="center">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview1.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview2.png">
<img alt="VbenAdmin Logo" width="100%" src="https://anncwb.github.io/anncwb/images/preview3.png">
</div>
### 使用 Gitpod
在 Gitpod适用于 GitHub 的免费在线开发环境)中打开项目,并立即开始编码.
在 Gitpod适用于 GitHub 的免费在线开发环境)中打开项目,并立即开始编码
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/vbenjs/vue-vben-admin)
@ -49,29 +60,27 @@ Vue Vben Admin 是 Vue Vben Admin 的升级版本。作为一个免费开源的
## 安装使用
- 获取项目代码
1. 获取项目代码
```bash
git clone https://github.com/vbenjs/vue-vben-admin.git
```
- 安装依赖
2. 安装依赖
```bash
cd vue-vben-admin
npm i -g corepack
pnpm install
```
- 运行
3. 运行
```bash
pnpm dev
```
- 打包
4. 打包
```bash
pnpm build
@ -85,68 +94,66 @@ pnpm build
非常欢迎你的加入![提一个 Issue](https://github.com/anncwb/vue-vben-admin/issues/new/choose) 或者提交一个 Pull Request。
**Pull Request:**
**Pull Request 流程:**
1. Fork 代码!
2. 创建自己的分支: `git checkout -b feature/xxxx`
3. 提交你的修改: `git commit -am 'feat(function): add xxxxx'`
4. 推送您的分支: `git push origin feature/xxxx`
5. 提交`pull request`
1. Fork 代码
2. 创建自己的分支`git checkout -b feature/xxxx`
3. 提交你的修改`git commit -am 'feat(function): add xxxxx'`
4. 推送您的分支`git push origin feature/xxxx`
5. 提交 `pull request`
## Git 贡献提交规范
- 参考 [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) 规范 ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
参考 [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) 规范 ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
- `feat` 增加新功能
- `fix` 修复问题/BUG
- `style` 代码风格相关无影响运行结果的
- `perf` 优化/性能提升
- `refactor` 重构
- `revert` 撤销修改
- `test` 测试相关
- `docs` 文档/注释
- `chore` 依赖更新/脚手架配置修改等
- `ci` 持续集成
- `types` 类型定义文件更改
- `wip` 开发中
- `feat` 增加新功能
- `fix` 修复问题/BUG
- `style` 代码风格相关无影响运行结果的
- `perf` 优化/性能提升
- `refactor` 重构
- `revert` 撤销修改
- `test` 测试相关
- `docs` 文档/注释
- `chore` 依赖更新/脚手架配置修改等
- `ci` 持续集成
- `types` 类型定义文件更改
## 浏览器支持
本地开发推荐使用`Chrome 80+` 浏览器
本地开发推荐使用 `Chrome 80+` 浏览器
支持现代浏览器, 不支持 IE
支持现代浏览器不支持 IE
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: | :-: |
| not support | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: |
| last 2 versions | last 2 versions | last 2 versions | last 2 versions |
## 维护者
[@Vben](https://github.com/anncwb)
## Star History
## Star 历史
[![Star History Chart](https://api.star-history.com/svg?repos=vbenjs/vue-vben-admin&type=Date)](https://star-history.com/#vbenjs/vue-vben-admin&Date)
## 捐赠
如果你觉得这个项目对你有帮助,你可以帮作者买一杯咖啡表示支持!
如果你觉得这个项目对你有帮助,你可以帮作者买一杯咖啡表示支持
![donate](https://unpkg.com/@vbenjs/static-source@0.1.7/source/sponsor.png)
<a style="display: block;width: 100px;height: 50px;line-height: 50px; color: #fff;text-align: center; background: #408aed;border-radius: 4px;" href="https://www.paypal.com/paypalme/cvvben">Paypal Me</a>
## Contributor
## 贡献者
<a href="https://github.com/vbenjs/vue-vben-admin/graphs/contributors">
<img alt="Contributors"
src="https://opencollective.com/vbenjs/contributors.svg?button=false" />
<img alt="Contributors" src="https://opencollective.com/vbenjs/contributors.svg?button=false" />
</a>
## Discord
- [Github Discussions](https://github.com/anncwb/vue-vben-admin/discussions)
## License
## 许可证
[MIT © Vben-2020](./LICENSE)

View File

@ -3,149 +3,328 @@ import type { ConfigEnv, PluginOption, UserConfig } from 'vite';
import type { PluginOptions } from 'vite-plugin-dts';
import type { Options as PwaPluginOptions } from 'vite-plugin-pwa';
/**
* ImportMap
* @description
* @example
* ```typescript
* {
* imports: {
* 'vue': 'https://unpkg.com/vue@3.2.47/dist/vue.esm-browser.js'
* },
* scopes: {
* 'https://site.com/': {
* 'vue': 'https://unpkg.com/vue@3.2.47/dist/vue.esm-browser.js'
* }
* }
* }
* ```
*/
interface IImportMap {
/** 模块导入映射 */
imports?: Record<string, string>;
/** 作用域特定的导入映射 */
scopes?: {
[scope: string]: Record<string, string>;
};
}
/**
*
* @description
*/
interface PrintPluginOptions {
/**
*
*
* @description
* @example
* ```typescript
* {
* 'App Version': '1.0.0',
* 'Build Time': '2024-01-01'
* }
* ```
*/
infoMap?: Record<string, string | undefined>;
}
/**
* Nitro Mock
* @description Nitro Mock
*/
interface NitroMockPluginOptions {
/**
* mock server
* Mock
* @default '@vbenjs/nitro-mock'
*/
mockServerPackage?: string;
/**
* mock
* Mock
* @default 3000
*/
port?: number;
/**
* mock
* Mock
* @default false
*/
verbose?: boolean;
}
/**
*
* @description
*/
interface ArchiverPluginOptions {
/**
*
* @default dist
* @default 'dist'
*/
name?: string;
/**
*
* @default .
* @default '.'
*/
outputDir?: string;
}
/**
* importmap
* ImportMap
* @description CDN
*/
interface ImportmapPluginOptions {
/**
* CDN
* @default jspm.io
* @default 'jspm.io'
* @description esm.sh jspm.io CDN
*/
defaultProvider?: 'esm.sh' | 'jspm.io';
/** importmap 配置 */
/**
* ImportMap
* @description CDN
* @example
* ```typescript
* [
* { name: 'vue' },
* { name: 'pinia', range: '^2.0.0' }
* ]
* ```
*/
importmap?: Array<{ name: string; range?: string }>;
/** 手动配置importmap */
/**
* ImportMap
* @description ImportMap
*/
inputMap?: IImportMap;
}
/**
*
*
* @description
*/
interface ConditionPlugin {
// 判断条件
/**
*
* @description true
*/
condition?: boolean;
// 插件对象
/**
*
* @description Promise
*/
plugins: () => PluginOption[] | PromiseLike<PluginOption[]>;
}
/**
*
* @description
*/
interface CommonPluginOptions {
/** 是否开启devtools */
/**
*
* @default false
*/
devtools?: boolean;
/** 环境变量 */
/**
*
* @description
*/
env?: Record<string, any>;
/** 是否注入metadata */
/**
*
* @default true
*/
injectMetadata?: boolean;
/** 是否构建模式 */
/**
*
* @default false
*/
isBuild?: boolean;
/** 构建模式 */
/**
*
* @default 'development'
*/
mode?: string;
/** 开启依赖分析 */
/**
*
* @default false
* @description 使 rollup-plugin-visualizer
*/
visualizer?: boolean | PluginVisualizerOptions;
}
/**
*
* @description
*/
interface ApplicationPluginOptions extends CommonPluginOptions {
/** 开启后会在打包dist同级生成dist.zip */
/**
*
* @default false
* @description zip
*/
archiver?: boolean;
/** 压缩归档插件配置 */
/**
*
* @description
*/
archiverPluginOptions?: ArchiverPluginOptions;
/** 开启 gzip|brotli 压缩 */
/**
*
* @default false
* @description gzip brotli
*/
compress?: boolean;
/** 压缩类型 */
/**
*
* @default ['gzip']
* @description
*/
compressTypes?: ('brotli' | 'gzip')[];
/** 在构建的时候抽离配置文件 */
/**
*
* @default false
* @description
*/
extraAppConfig?: boolean;
/** 是否开启html插件 */
/**
* HTML
* @default true
*/
html?: boolean;
/** 是否开启i18n */
/**
*
* @default false
*/
i18n?: boolean;
/** 是否开启 importmap CDN */
/**
* ImportMap CDN
* @default false
*/
importmap?: boolean;
/** importmap 插件配置 */
/**
* ImportMap
*/
importmapOptions?: ImportmapPluginOptions;
/** 是否注入app loading */
/**
*
* @default true
*/
injectAppLoading?: boolean;
/** 是否注入全局scss */
/**
* SCSS
* @default true
*/
injectGlobalScss?: boolean;
/** 是否注入版权信息 */
/**
*
* @default true
*/
license?: boolean;
/** 是否开启nitro mock */
/**
* Nitro Mock
* @default false
*/
nitroMock?: boolean;
/** nitro mock 插件配置 */
/**
* Nitro Mock
*/
nitroMockOptions?: NitroMockPluginOptions;
/** 开启控制台自定义打印 */
/**
*
* @default false
*/
print?: boolean;
/** 打印插件配置 */
/**
*
*/
printInfoMap?: PrintPluginOptions['infoMap'];
/** 是否开启pwa */
/**
* PWA
* @default false
*/
pwa?: boolean;
/** pwa 插件配置 */
/**
* PWA
*/
pwaOptions?: Partial<PwaPluginOptions>;
/** 是否开启vxe-table懒加载 */
/**
* VXE Table
* @default false
*/
vxeTableLazyImport?: boolean;
}
/**
*
* @description
*/
interface LibraryPluginOptions extends CommonPluginOptions {
/** 开启 dts 输出 */
/**
* DTS
* @default true
* @description TypeScript
*/
dts?: boolean | PluginOptions;
}
/**
*
*/
type ApplicationOptions = ApplicationPluginOptions;
/**
*
*/
type LibraryOptions = LibraryPluginOptions;
/**
*
* @description
*/
type DefineApplicationOptions = (config?: ConfigEnv) => Promise<{
/** 应用插件配置 */
application?: ApplicationOptions;
/** Vite 配置 */
vite?: UserConfig;
}>;
/**
*
* @description
*/
type DefineLibraryOptions = (config?: ConfigEnv) => Promise<{
/** 库插件配置 */
library?: LibraryOptions;
/** Vite 配置 */
vite?: UserConfig;
}>;
/**
*
* @description
*/
type DefineConfig = DefineApplicationOptions | DefineLibraryOptions;
export type {

View File

@ -99,7 +99,7 @@
"node": ">=20.10.0",
"pnpm": ">=9.12.0"
},
"packageManager": "pnpm@9.15.9",
"packageManager": "pnpm@10.10.0",
"pnpm": {
"peerDependencyRules": {
"allowedVersions": {

View File

@ -42,9 +42,7 @@ async function generateAccessible(
delete route.component;
}
// 根据router name判断如果路由已经存在则不再添加
if (!names?.includes(route.name)) {
root.children?.push(route);
} else {
if (names?.includes(route.name)) {
// 找到已存在的路由索引并更新不更新会造成切换用户时一级目录未更新homePath 在二级目录导致的404问题
const index = root.children?.findIndex(
(item) => item.name === route.name,
@ -52,6 +50,8 @@ async function generateAccessible(
if (index !== undefined && index !== -1 && root.children) {
root.children[index] = route;
}
} else {
root.children?.push(route);
}
} else {
router.addRoute(route);

File diff suppressed because it is too large Load Diff

View File

@ -30,13 +30,13 @@ catalog:
'@intlify/unplugin-vue-i18n': ^6.0.8
'@jspm/generator': ^2.5.1
'@manypkg/get-packages': ^2.2.2
'@nolebase/vitepress-plugin-git-changelog': ^2.16.0
'@nolebase/vitepress-plugin-git-changelog': ^2.17.0
'@playwright/test': ^1.52.0
'@pnpm/workspace.read-manifest': ^1000.1.4
'@stylistic/stylelint-plugin': ^3.1.2
'@tailwindcss/nesting': 0.0.0-insiders.565cd3e
'@tailwindcss/typography': ^0.5.16
'@tanstack/vue-query': ^5.74.6
'@tanstack/vue-query': ^5.74.7
'@tanstack/vue-store': ^0.7.0
'@types/archiver': ^6.0.3
'@types/eslint': ^9.6.1
@ -108,7 +108,7 @@ catalog:
find-up: ^7.0.0
get-port: ^7.1.0
globals: ^16.0.0
h3: ^1.15.1
h3: ^1.15.3
happy-dom: ^17.4.4
html-minifier-terser: ^7.2.0
husky: ^9.1.7
@ -123,7 +123,7 @@ catalog:
lucide-vue-next: ^0.503.0
medium-zoom: ^1.1.0
naive-ui: ^2.41.0
nitropack: ^2.11.9
nitropack: ^2.11.11
nprogress: ^0.2.0
ora: ^8.2.0
pinia: ^3.0.2
@ -174,7 +174,7 @@ catalog:
vite-plugin-html: ^3.2.2
vite-plugin-lazy-import: ^1.0.7
vite-plugin-pwa: ^1.0.0
vite-plugin-vue-devtools: ^7.7.5
vite-plugin-vue-devtools: ^7.7.6
vitepress: ^1.6.3
vitepress-plugin-group-icons: ^1.5.2
vitest: ^3.1.2
@ -186,7 +186,7 @@ catalog:
vue-tippy: ^6.7.0
vue-tsc: 2.1.10
vxe-pc-ui: ^4.5.14
vxe-table: ^4.12.5
vxe-table: ^4.13.14
watermark-js-plus: ^1.6.0
zod: ^3.24.3
zod-defaults: ^0.1.3

View File

@ -1,31 +1,33 @@
import { promises as fs } from 'node:fs';
import { join } from 'node:path';
import { join, normalize } from 'node:path';
const rootDir = process.cwd();
/**
* 递归查找并删除目标目录
* @param {string} currentDir - 当前遍历的目录路径
* @param {string[]} targets - 要删除的目标列表
*/
async function cleanTargetsRecursively(currentDir, targets) {
const items = await fs.readdir(currentDir);
for (const item of items) {
try {
const itemPath = join(currentDir, item);
const itemPath = normalize(join(currentDir, item));
const stat = await fs.lstat(itemPath);
if (targets.includes(item)) {
// 匹配到目标目录或文件时直接删除
await fs.rm(itemPath, { force: true, recursive: true });
console.log(`Deleted: ${itemPath}`);
}
const stat = await fs.lstat(itemPath);
if (stat.isDirectory()) {
} else if (stat.isDirectory()) {
// 只对目录进行递归处理
await cleanTargetsRecursively(itemPath, targets);
}
} catch {
// console.error(
// `Error handling item ${item} in ${currentDir}: ${error.message}`,
// );
} catch (error) {
console.error(
`Error handling item ${item} in ${currentDir}: ${error.message}`,
);
}
}
}
@ -33,9 +35,9 @@ async function cleanTargetsRecursively(currentDir, targets) {
(async function startCleanup() {
// 要删除的目录及文件名称
const targets = ['node_modules', 'dist', '.turbo', 'dist.zip'];
const deleteLockFile = process.argv.includes('--del-lock');
const cleanupTargets = [...targets];
if (deleteLockFile) {
cleanupTargets.push('pnpm-lock.yaml');
}
@ -46,8 +48,9 @@ async function cleanTargetsRecursively(currentDir, targets) {
try {
await cleanTargetsRecursively(rootDir, cleanupTargets);
console.log('Cleanup process completed.');
console.log('Cleanup process completed successfully.');
} catch (error) {
console.error(`Unexpected error during cleanup: ${error.message}`);
process.exit(1);
}
})();

View File

@ -1,4 +1,4 @@
FROM node:20-slim AS builder
FROM node:22-slim AS builder
# --max-old-space-size
ENV PNPM_HOME="/pnpm"
@ -13,6 +13,7 @@ WORKDIR /app
# copy package.json and pnpm-lock.yaml to workspace
COPY . /app
# 安装依赖
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build --filter=\!./docs
@ -20,12 +21,17 @@ RUN echo "Builder Success 🎉"
FROM nginx:stable-alpine AS production
RUN echo "types { application/javascript js mjs; }" > /etc/nginx/conf.d/mjs.conf
# 配置 nginx
RUN echo "types { application/javascript js mjs; }" > /etc/nginx/conf.d/mjs.conf \
&& rm -rf /etc/nginx/conf.d/default.conf
# 复制构建产物
COPY --from=builder /app/playground/dist /usr/share/nginx/html
# 复制 nginx 配置
COPY --from=builder /app/scripts/deploy/nginx.conf /etc/nginx/nginx.conf
EXPOSE 8080
# start nginx
# 启动 nginx
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,3 +1,59 @@
# @vben/turbo-run
turbo-run is a command line tool that allows you to run multiple commands in parallel.
`turbo-run` 是一个命令行工具,允许你在多个包中并行运行命令。它提供了一个交互式的界面,让你可以选择要运行命令的包。
## 特性
- 🚀 交互式选择要运行的包
- 📦 支持 monorepo 项目结构
- 🔍 自动检测可用的命令
- 🎯 精确过滤目标包
## 安装
```bash
pnpm add -D @vben/turbo-run
```
## 使用方法
基本语法:
```bash
turbo-run [script]
```
例如,如果你想运行 `dev` 命令:
```bash
turbo-run dev
```
工具会自动检测哪些包有 `dev` 命令,并提供一个交互式界面让你选择要运行的包。
## 示例
假设你的项目中有以下包:
- `@vben/app`
- `@vben/admin`
- `@vben/website`
当你运行:
```bash
turbo-run dev
```
工具会:
1. 检测哪些包有 `dev` 命令
2. 显示一个交互式选择界面
3. 让你选择要运行命令的包
4. 使用 `pnpm --filter` 在选定的包中运行命令
## 注意事项
- 确保你的项目使用 pnpm 作为包管理器
- 确保目标包在 `package.json` 中定义了相应的脚本命令
- 该工具需要在 monorepo 项目的根目录下运行

View File

@ -25,7 +25,7 @@ export async function run(options: RunOptions) {
let selectPkg: string | symbol;
if (selectPkgs.length > 1) {
selectPkg = await select<any, string>({
selectPkg = await select<string>({
message: `Select the app you need to run [${command}]:`,
options: selectPkgs.map((item) => ({
label: item?.packageJson.name,

View File

@ -1,3 +1,56 @@
# @vben/vsh
shell 脚本工具集合
一个 Shell 脚本工具集合,用于 Vue Vben Admin 项目的开发和管理。
## 功能特性
- 🚀 基于 Node.js 的现代化 Shell 工具
- 📦 支持模块化开发和按需加载
- 🔍 提供依赖检查和分析功能
- 🔄 支持循环依赖扫描
- 📝 提供包发布检查功能
## 安装
```bash
# 使用 pnpm 安装
pnpm add -D @vben/vsh
# 或者使用 npm
npm install -D @vben/vsh
# 或者使用 yarn
yarn add -D @vben/vsh
```
## 使用方法
### 全局安装
```bash
# 全局安装
pnpm add -g @vben/vsh
# 使用 vsh 命令
vsh [command]
```
### 本地使用
```bash
# 在 package.json 中添加脚本
{
"scripts": {
"vsh": "vsh"
}
}
# 运行命令
pnpm vsh [command]
```
## 命令列表
- `vsh check-deps`: 检查项目依赖
- `vsh scan-circular`: 扫描循环依赖
- `vsh publish-check`: 检查包发布配置

View File

@ -4,77 +4,167 @@ import { extname } from 'node:path';
import { getStagedFiles } from '@vben/node-utils';
import { circularDepsDetect, printCircles } from 'circular-dependency-scanner';
import { circularDepsDetect } from 'circular-dependency-scanner';
const IGNORE_DIR = [
'dist',
'.turbo',
'output',
'.cache',
'scripts',
'internal',
'packages/effects/request/src/',
'packages/@core/ui-kit/menu-ui/src/',
'packages/@core/ui-kit/popup-ui/src/',
].join(',');
// 默认配置
const DEFAULT_CONFIG = {
allowedExtensions: ['.cjs', '.js', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
ignoreDirs: [
'dist',
'.turbo',
'output',
'.cache',
'scripts',
'internal',
'packages/effects/request/src/',
'packages/@core/ui-kit/menu-ui/src/',
'packages/@core/ui-kit/popup-ui/src/',
],
threshold: 0, // 循环依赖的阈值
} as const;
const IGNORE = [`**/{${IGNORE_DIR}}/**`];
// 类型定义
type CircularDependencyResult = string[];
interface CheckCircularConfig {
allowedExtensions?: string[];
ignoreDirs?: string[];
threshold?: number;
}
interface CommandOptions {
config?: CheckCircularConfig;
staged: boolean;
verbose: boolean;
}
async function checkCircular({ staged, verbose }: CommandOptions) {
const results = await circularDepsDetect({
absolute: staged,
cwd: process.cwd(),
ignore: IGNORE,
// 缓存机制
const cache = new Map<string, CircularDependencyResult[]>();
/**
*
* @param circles -
*/
function formatCircles(circles: CircularDependencyResult[]): void {
if (circles.length === 0) {
console.log('✅ No circular dependencies found');
return;
}
console.log('⚠️ Circular dependencies found:');
circles.forEach((circle, index) => {
console.log(`\nCircular dependency #${index + 1}:`);
circle.forEach((file) => console.log(`${file}`));
});
}
if (staged) {
let files = await getStagedFiles();
/**
*
* @param options -
* @param options.staged -
* @param options.verbose -
* @param options.config -
* @returns Promise<void>
*/
async function checkCircular({
config = {},
staged,
verbose,
}: CommandOptions): Promise<void> {
try {
// 合并配置
const finalConfig = {
...DEFAULT_CONFIG,
...config,
};
const allowedExtensions = new Set([
'.cjs',
'.js',
'.jsx',
'.mjs',
'.ts',
'.tsx',
'.vue',
]);
// 生成忽略模式
const ignorePattern = `**/{${finalConfig.ignoreDirs.join(',')}}/**`;
// 过滤文件列表
files = files.filter((file) => allowedExtensions.has(extname(file)));
// 检查缓存
const cacheKey = `${staged}-${process.cwd()}-${ignorePattern}`;
if (cache.has(cacheKey)) {
const cachedResults = cache.get(cacheKey);
if (cachedResults) {
verbose && formatCircles(cachedResults);
}
return;
}
const circularFiles: string[][] = [];
// 检测循环依赖
const results = await circularDepsDetect({
absolute: staged,
cwd: process.cwd(),
ignore: [ignorePattern],
});
for (const file of files) {
for (const result of results) {
const resultFiles = result.flat();
if (resultFiles.includes(file)) {
circularFiles.push(result);
if (staged) {
let files = await getStagedFiles();
const allowedExtensions = new Set(finalConfig.allowedExtensions);
// 过滤文件列表
files = files.filter((file) => allowedExtensions.has(extname(file)));
const circularFiles: CircularDependencyResult[] = [];
for (const file of files) {
for (const result of results) {
const resultFiles = result.flat();
if (resultFiles.includes(file)) {
circularFiles.push(result);
}
}
}
// 更新缓存
cache.set(cacheKey, circularFiles);
verbose && formatCircles(circularFiles);
} else {
// 更新缓存
cache.set(cacheKey, results);
verbose && formatCircles(results);
}
verbose && printCircles(circularFiles);
} else {
verbose && printCircles(results);
// 如果发现循环依赖,只输出警告信息
if (results.length > 0) {
console.log(
'\n⚠ Warning: Circular dependencies found, please check and fix',
);
}
} catch (error) {
console.error(
'❌ Error checking circular dependencies:',
error instanceof Error ? error.message : error,
);
}
}
function defineCheckCircularCommand(cac: CAC) {
/**
*
* @param cac - CAC
*/
function defineCheckCircularCommand(cac: CAC): void {
cac
.command('check-circular')
.option(
'--staged',
'Whether it is the staged commit mode, in which mode, if there is a circular dependency, an alarm will be given.',
)
.usage(`Analysis of project circular dependencies.`)
.action(async ({ staged }) => {
await checkCircular({ staged, verbose: true });
.option('--staged', 'Only check staged files')
.option('--verbose', 'Show detailed information')
.option('--threshold <number>', 'Threshold for circular dependencies', {
default: 0,
})
.option('--ignore-dirs <dirs>', 'Directories to ignore, comma separated')
.usage('Analyze project circular dependencies')
.action(async ({ ignoreDirs, staged, threshold, verbose }) => {
const config: CheckCircularConfig = {
threshold: Number(threshold),
...(ignoreDirs && { ignoreDirs: ignoreDirs.split(',') }),
};
await checkCircular({
config,
staged,
verbose: verbose ?? true,
});
});
}
export { defineCheckCircularCommand };
export { type CheckCircularConfig, defineCheckCircularCommand };

View File

@ -4,82 +4,192 @@ import { getPackages } from '@vben/node-utils';
import depcheck from 'depcheck';
async function runDepcheck() {
const { packages } = await getPackages();
await Promise.all(
packages.map(async (pkg) => {
if (
[
'@vben/backend-mock',
'@vben/commitlint-config',
'@vben/eslint-config',
'@vben/lint-staged-config',
'@vben/node-utils',
'@vben/prettier-config',
'@vben/stylelint-config',
'@vben/tailwind-config',
'@vben/tsconfig',
'@vben/vite-config',
'@vben/vite-config',
'@vben/vsh',
].includes(pkg.packageJson.name)
) {
return;
}
// 默认配置
const DEFAULT_CONFIG = {
// 需要忽略的依赖匹配
ignoreMatches: [
'vite',
'vitest',
'unbuild',
'@vben/tsconfig',
'@vben/vite-config',
'@vben/tailwind-config',
'@types/*',
'@vben-core/design',
],
// 需要忽略的包
ignorePackages: [
'@vben/backend-mock',
'@vben/commitlint-config',
'@vben/eslint-config',
'@vben/lint-staged-config',
'@vben/node-utils',
'@vben/prettier-config',
'@vben/stylelint-config',
'@vben/tailwind-config',
'@vben/tsconfig',
'@vben/vite-config',
'@vben/vsh',
],
// 需要忽略的文件模式
ignorePatterns: ['dist', 'node_modules', 'public'],
};
const unused = await depcheck(pkg.dir, {
ignoreMatches: [
'vite',
'vitest',
'unbuild',
'@vben/tsconfig',
'@vben/vite-config',
'@vben/tailwind-config',
'@types/*',
'@vben-core/design',
],
ignorePatterns: ['dist', 'node_modules', 'public'],
});
// 删除file:前缀的依赖提示,该依赖是本地依赖
Reflect.deleteProperty(unused.missing, 'file:');
Object.keys(unused.missing).forEach((key) => {
unused.missing[key] = (unused.missing[key] || []).filter(
(item: string) => !item.startsWith('/'),
);
if (unused.missing[key].length === 0) {
Reflect.deleteProperty(unused.missing, key);
}
});
if (
Object.keys(unused.missing).length === 0 &&
unused.dependencies.length === 0 &&
unused.devDependencies.length === 0
) {
return;
}
console.error(
'\n',
pkg.packageJson.name,
'\n missing:',
unused.missing,
'\n dependencies:',
unused.dependencies,
'\n devDependencies:',
unused.devDependencies,
);
}),
);
interface DepcheckResult {
dependencies: string[];
devDependencies: string[];
missing: Record<string, string[]>;
}
function defineDepcheckCommand(cac: CAC) {
interface DepcheckConfig {
ignoreMatches?: string[];
ignorePackages?: string[];
ignorePatterns?: string[];
}
interface PackageInfo {
dir: string;
packageJson: {
name: string;
};
}
/**
*
* @param unused -
*/
function cleanDepcheckResult(unused: DepcheckResult): void {
// 删除file:前缀的依赖提示,该依赖是本地依赖
Reflect.deleteProperty(unused.missing, 'file:');
// 清理路径依赖
Object.keys(unused.missing).forEach((key) => {
unused.missing[key] = (unused.missing[key] || []).filter(
(item: string) => !item.startsWith('/'),
);
if (unused.missing[key].length === 0) {
Reflect.deleteProperty(unused.missing, key);
}
});
}
/**
*
* @param pkgName -
* @param unused -
*/
function formatDepcheckResult(pkgName: string, unused: DepcheckResult): void {
const hasIssues =
Object.keys(unused.missing).length > 0 ||
unused.dependencies.length > 0 ||
unused.devDependencies.length > 0;
if (!hasIssues) {
return;
}
console.log('\n📦 Package:', pkgName);
if (Object.keys(unused.missing).length > 0) {
console.log('❌ Missing dependencies:');
Object.entries(unused.missing).forEach(([dep, files]) => {
console.log(` - ${dep}:`);
files.forEach((file) => console.log(`${file}`));
});
}
if (unused.dependencies.length > 0) {
console.log('⚠️ Unused dependencies:');
unused.dependencies.forEach((dep) => console.log(` - ${dep}`));
}
if (unused.devDependencies.length > 0) {
console.log('⚠️ Unused devDependencies:');
unused.devDependencies.forEach((dep) => console.log(` - ${dep}`));
}
}
/**
*
* @param config -
*/
async function runDepcheck(config: DepcheckConfig = {}): Promise<void> {
try {
const finalConfig = {
...DEFAULT_CONFIG,
...config,
};
const { packages } = await getPackages();
let hasIssues = false;
await Promise.all(
packages.map(async (pkg: PackageInfo) => {
// 跳过需要忽略的包
if (finalConfig.ignorePackages.includes(pkg.packageJson.name)) {
return;
}
const unused = await depcheck(pkg.dir, {
ignoreMatches: finalConfig.ignoreMatches,
ignorePatterns: finalConfig.ignorePatterns,
});
cleanDepcheckResult(unused);
const pkgHasIssues =
Object.keys(unused.missing).length > 0 ||
unused.dependencies.length > 0 ||
unused.devDependencies.length > 0;
if (pkgHasIssues) {
hasIssues = true;
formatDepcheckResult(pkg.packageJson.name, unused);
}
}),
);
if (!hasIssues) {
console.log('\n✅ Dependency check completed, no issues found');
}
} catch (error) {
console.error(
'❌ Dependency check failed:',
error instanceof Error ? error.message : error,
);
}
}
/**
*
* @param cac - CAC
*/
function defineDepcheckCommand(cac: CAC): void {
cac
.command('check-dep')
.usage(`Analysis of project circular dependencies.`)
.action(async () => {
await runDepcheck();
.option(
'--ignore-packages <packages>',
'Packages to ignore, comma separated',
)
.option(
'--ignore-matches <matches>',
'Dependency patterns to ignore, comma separated',
)
.option(
'--ignore-patterns <patterns>',
'File patterns to ignore, comma separated',
)
.usage('Analyze project dependencies')
.action(async ({ ignoreMatches, ignorePackages, ignorePatterns }) => {
const config: DepcheckConfig = {
...(ignorePackages && { ignorePackages: ignorePackages.split(',') }),
...(ignoreMatches && { ignoreMatches: ignoreMatches.split(',') }),
...(ignorePatterns && { ignorePatterns: ignorePatterns.split(',') }),
};
await runDepcheck(config);
});
}
export { defineDepcheckCommand };
export { defineDepcheckCommand, type DepcheckConfig };

View File

@ -2,40 +2,73 @@ import { colors, consola } from '@vben/node-utils';
import { cac } from 'cac';
import { version } from '../package.json';
import { defineCheckCircularCommand } from './check-circular';
import { defineDepcheckCommand } from './check-dep';
import { defineCodeWorkspaceCommand } from './code-workspace';
import { defineLintCommand } from './lint';
import { definePubLintCommand } from './publint';
try {
const vsh = cac('vsh');
// 命令描述
const COMMAND_DESCRIPTIONS = {
'check-circular': 'Check for circular dependencies',
'check-dep': 'Check for unused dependencies',
'code-workspace': 'Manage VS Code workspace settings',
lint: 'Run linting on the project',
publint: 'Check package.json files for publishing standards',
} as const;
// vsh lint
defineLintCommand(vsh);
/**
* Initialize and run the CLI
*/
async function main(): Promise<void> {
try {
const vsh = cac('vsh');
// vsh publint
definePubLintCommand(vsh);
// Register commands
defineLintCommand(vsh);
definePubLintCommand(vsh);
defineCodeWorkspaceCommand(vsh);
defineCheckCircularCommand(vsh);
defineDepcheckCommand(vsh);
// vsh code-workspace
defineCodeWorkspaceCommand(vsh);
// Handle invalid commands
vsh.on('command:*', ([cmd]) => {
consola.error(
colors.red(`Invalid command: ${cmd}`),
'\n',
colors.yellow('Available commands:'),
'\n',
Object.entries(COMMAND_DESCRIPTIONS)
.map(([cmd, desc]) => ` ${colors.cyan(cmd)} - ${desc}`)
.join('\n'),
);
process.exit(1);
});
// vsh check-circular
defineCheckCircularCommand(vsh);
// Set up CLI
vsh.usage('vsh <command> [options]');
vsh.help();
vsh.version(version);
// vsh check-dep
defineDepcheckCommand(vsh);
// Invalid command
vsh.on('command:*', () => {
consola.error(colors.red('Invalid command!'));
// Parse arguments
vsh.parse();
} catch (error) {
consola.error(
colors.red('An unexpected error occurred:'),
'\n',
error instanceof Error ? error.message : error,
);
process.exit(1);
});
vsh.usage('vsh');
vsh.help();
vsh.parse();
} catch (error) {
consola.error(error);
process.exit(1);
}
}
// Run the CLI
main().catch((error) => {
consola.error(
colors.red('Failed to start CLI:'),
'\n',
error instanceof Error ? error.message : error,
);
process.exit(1);
});