feat(): 更新依赖

This commit is contained in:
CodiceFabbrica 2026-03-17 14:42:03 +08:00
parent f67c787e07
commit 5d38684c5c
18 changed files with 3142 additions and 5746 deletions

6
.claude/rules/scripts.md Normal file
View File

@ -0,0 +1,6 @@
---
paths:
- "scripts"
---
- 编写脚本文件时,注意换行符与文件编码。在`Windows`平台上`PowerShell`脚本应该是`UTF-8 with BOM`+`CRLF`

View File

@ -12,7 +12,14 @@
"Bash(pnpm build)",
"Bash(pnpm test)",
"Bash(printf 'npm run lint-staged\\\\nnpm test\\\\n')",
"Bash(printf 'npx commitlint --edit \"\"$1\"\"\\\\n')"
"Bash(printf 'npx commitlint --edit \"\"$1\"\"\\\\n')",
"Bash(npm view typescript version)",
"Bash(pnpm update typescript)",
"Bash(npm view @typescript-eslint/parser versions --json)",
"Bash(npm view @typescript-eslint/parser@latest peerDependencies)",
"Bash(npm view @typescript-eslint/parser@latest version)",
"Bash(pnpm list typescript)",
"Bash(pnpm list @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript-eslint)"
]
}
}

View File

@ -133,35 +133,51 @@ pnpm commit
### 发布到私有 npm 仓库
项目已配置发布到私有 npm 仓库 `http://192.168.2.127:4873`。
项目已配置发布到私有 npm 仓库 `http://npm.nps.yunvip123.cn`。
#### Windows (PowerShell)
```powershell
# 发布所有子包
# 发布所有子包(默认 patch 版本)
powershell scripts/publish.ps1
# 指定版本类型
powershell scripts/publish.ps1 patch # 1.0.0 -> 1.0.1
powershell scripts/publish.ps1 minor # 1.0.0 -> 1.1.0
powershell scripts/publish.ps1 major # 1.0.0 -> 2.0.0
```
#### Linux/macOS (Bash)
```bash
# 发布所有子包
# 发布所有子包(默认 patch 版本)
bash scripts/publish.sh
# 指定版本类型
bash scripts/publish.sh patch # 1.0.0 -> 1.0.1
bash scripts/publish.sh minor # 1.0.0 -> 1.1.0
bash scripts/publish.sh major # 1.0.0 -> 2.0.0
```
发布脚本会自动:
发布脚本会自动执行以下步骤
1. 构建所有子包
2. 依次发布 `@r-utils/common`、`@r-utils/vue3`、`@r-utils/uni-app`、`@r-utils/vue2`
1. 检查 Git 工作区状态
2. 运行测试(确保代码质量)
3. 更新所有子包的版本号
4. 构建所有子包
5. 提交版本更新到 Git
6. 依次发布 `@r-utils/common`、`@r-utils/vue3`、`@r-utils/uni-app`、`@r-utils/vue2`
7. 创建 Git 标签(如 `v1.0.1`
8. 询问是否推送到远程仓库
### 安装已发布的包
```bash
# 配置 npm registry
npm config set registry http://192.168.2.127:4873
npm config set registry http://npm.nps.yunvip123.cn
# 或在项目中使用 .npmrc 文件
echo "registry=http://192.168.2.127:4873" > .npmrc
echo "registry=http://npm.nps.yunvip123.cn" > .npmrc
# 安装包
pnpm add @r-utils/common

View File

@ -1,10 +1,8 @@
import { Config } from "jest";
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/
export default <Config>{
export default {
// All imported modules in your tests should be mocked automatically
// automock: false,

View File

@ -10,7 +10,7 @@
"tools"
],
"publishConfig": {
"registry": "http://192.168.2.127:4873"
"registry": "http://npm.nps.yunvip123.cn"
},
"author": {
"name": "CodiceFabbrica",
@ -45,33 +45,33 @@
"test": "jest"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@babel/preset-env": "^7.12.0",
"@babel/preset-typescript": "^7.21.4",
"@commitlint/config-conventional": "^19.8.1",
"@commitlint/cz-commitlint": "^19.8.1",
"@eslint/js": "^9.26.0",
"@jest/globals": "^29.5.0",
"@typescript-eslint/eslint-plugin": "^8.32.0",
"@typescript-eslint/parser": "^8.32.0",
"babel-jest": "^29.5.0",
"commitizen": "^4.3.0",
"eslint": "^9.26.0",
"eslint-config-prettier": "^10.1.3",
"@babel/core": "^7.29.0",
"@babel/preset-env": "^7.29.2",
"@babel/preset-typescript": "^7.28.5",
"@commitlint/config-conventional": "^20.5.0",
"@commitlint/cz-commitlint": "^20.5.0",
"@eslint/js": "^10.0.1",
"@jest/globals": "^30.3.0",
"@typescript-eslint/eslint-plugin": "^8.57.1",
"@typescript-eslint/parser": "^8.57.1",
"babel-jest": "^30.3.0",
"commitizen": "^4.3.1",
"eslint": "^10.0.3",
"eslint-config-prettier": "^10.1.8",
"eslint-define-config": "^1.18.0",
"eslint-plugin-prettier": "^5.4.0",
"globals": "^16.1.0",
"eslint-plugin-prettier": "^5.5.5",
"globals": "^17.4.0",
"husky": "^9.1.7",
"inquirer": "^12.6.0",
"jest": "^29.5.0",
"lint-staged": "^15.5.2",
"prettier": "^3.5.3",
"inquirer": "^13.3.2",
"jest": "^30.3.0",
"lint-staged": "^16.4.0",
"prettier": "^3.8.1",
"standard-version": "^9.5.0",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"typescript-eslint": "^8.32.0",
"vite": "^6.0.0",
"vite-plugin-dts": "^4.0.0"
"typescript": "^5.9.3",
"typescript-eslint": "^8.57.1",
"vite": "^8.0.0",
"vite-plugin-dts": "^4.5.4"
},
"overrides": {
"@types/lodash": "4.17.16",

View File

@ -1,23 +1,12 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["node_modules", "dist"],
"include": ["**/*.ts"],
"include": ["src/**/*.ts"],
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["dom", "esnext"],
// "types": ["@dcloudio/types"],
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
},
"allowJs": true,
"outDir": "./types"
"outDir": "./dist"
}
}

View File

@ -29,8 +29,10 @@
"test": "jest"
},
"dependencies": {
"@r-utils/common": "workspace:^",
"lodash": "^4.17.21"
"@r-utils/common": "workspace:^"
},
"peerDependencies": {
"vue": "^3.3.0"
},
"devDependencies": {
"@dcloudio/types": "^3.0.7",

View File

@ -1,22 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["node_modules", "dist"],
"include": ["src/**/*.ts", "src/**/*.js"],
"include": ["src/**/*.ts", "src/**/*.js", "types/**/*.d.ts"],
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["dom", "esnext"],
"types": ["@dcloudio/types"],
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
},
"allowJs": true
"outDir": "./dist"
}
}

View File

@ -25,7 +25,7 @@ export default defineConfig({
},
plugins: [
dts({
include: ['src'],
include: ['src', 'types'],
outDir: 'dist',
}),
],

View File

@ -28,8 +28,8 @@
"lint-staged": "lint-staged",
"test": "jest"
},
"dependencies": {
"lodash": "^4.17.21"
"peerDependencies": {
"vue": "^2.7.0"
},
"devDependencies": {
"vue": "^2.7.0"

View File

@ -1,21 +1,12 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["node_modules", "dist"],
"include": ["src/**/*.ts", "src/**/*.js"],
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["dom", "esnext"],
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
},
"allowJs": true
"outDir": "./dist"
}
}

View File

@ -29,26 +29,11 @@
"test": "jest"
},
"license": "ISC",
"dependencies": {
"lodash": "^4.17.21",
"peerDependencies": {
"vue": "^3.3.0"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@babel/preset-env": "^7.12.0",
"@babel/preset-typescript": "^7.21.4",
"@commitlint/config-conventional": "^17.6.1",
"@commitlint/cz-commitlint": "^17.5.0",
"@jest/globals": "^29.7.0",
"babel-jest": "^29.7.0",
"commitizen": "^4.3.0",
"eslint-define-config": "^1.18.0",
"husky": "^8.0.3",
"inquirer": "^8.0.0",
"jest": "^29.7.0",
"lint-staged": "^15.4.0",
"prettier": "^3.4.2",
"standard-version": "^9.5.0"
"vue": "^3.3.0"
},
"packageManager": "pnpm@8.15.6"
}

View File

@ -1,21 +1,12 @@
{
"extends": "../../tsconfig.base.json",
"exclude": ["node_modules", "dist"],
"include": ["src/**/*.ts", "src/**/*.js"],
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["dom", "esnext"],
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
},
"allowJs": true
"outDir": "./dist"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,21 @@
# 发布所有子包到私有 npm 仓库
# 使用方法: powershell scripts/publish.ps1
# 使用方法: powershell scripts/publish.ps1 [版本类型]
# 版本类型: major | minor | patch (默认 patch)
# 注意: 发布仓库地址使用各子包 package.json 中的 publishConfig.registry 配置
$ErrorActionPreference = "Stop"
$REGISTRY = "http://192.168.2.127:4873"
# 获取版本类型参数,默认为 patch
$VERSION_TYPE = if ($args.Count -gt 0) { $args[0] } else { "patch" }
Write-Host "🚀 开始发布所有子包到 $REGISTRY" -ForegroundColor Green
# 验证版本类型
if ($VERSION_TYPE -notin @("major", "minor", "patch")) {
Write-Host "❌ 无效的版本类型: $VERSION_TYPE" -ForegroundColor Red
Write-Host "使用方法: powershell scripts/publish.ps1 [major|minor|patch]" -ForegroundColor Yellow
exit 1
}
Write-Host "🚀 开始发布流程 (版本类型: $VERSION_TYPE)" -ForegroundColor Green
Write-Host ""
# 子包列表
@ -16,23 +26,103 @@ $PACKAGES = @(
"packages/vue2"
)
# 先构建所有包
Write-Host "📦 构建所有包..." -ForegroundColor Cyan
pnpm build
# 1. 检查工作区是否干净
Write-Host "🔍 检查 Git 工作区状态..." -ForegroundColor Cyan
$gitStatus = git status -s
if ($gitStatus) {
Write-Host "⚠️ 工作区有未提交的更改,请先提交或暂存" -ForegroundColor Yellow
git status -s
$continue = Read-Host "是否继续? (y/N)"
if ($continue -ne "y" -and $continue -ne "Y") {
exit 1
}
}
Write-Host ""
# 发布每个包
# 2. 运行测试
Write-Host "🧪 运行测试..." -ForegroundColor Cyan
pnpm test
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ 测试失败,停止发布" -ForegroundColor Red
exit 1
}
Write-Host ""
# 3. 更新版本号
Write-Host "📝 更新版本号 ($VERSION_TYPE)..." -ForegroundColor Cyan
foreach ($package in $PACKAGES) {
if (Test-Path $package) {
Write-Host "📤 发布 $package ..." -ForegroundColor Cyan
Write-Host " 更新 $package 版本号..." -ForegroundColor Gray
Push-Location $package
pnpm publish --registry="$REGISTRY" --no-git-checks
npm version $VERSION_TYPE --no-git-tag-version
Pop-Location
Write-Host "$package 发布成功" -ForegroundColor Green
}
}
Write-Host ""
# 4. 构建所有包
Write-Host "📦 构建所有包..." -ForegroundColor Cyan
pnpm build
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ 构建失败,停止发布" -ForegroundColor Red
exit 1
}
Write-Host ""
# 5. 更新 README 中的版本信息
Write-Host "📄 更新 README..." -ForegroundColor Cyan
$COMMON_VERSION = node -p "require('./packages/common/package.json').version"
Write-Host " 当前版本: $COMMON_VERSION" -ForegroundColor Gray
Write-Host ""
# 6. 提交版本更新
Write-Host "💾 提交版本更新..." -ForegroundColor Cyan
git add packages/*/package.json
git commit -m "chore(release): publish v$COMMON_VERSION"
if ($LASTEXITCODE -ne 0) {
Write-Host " 没有需要提交的更改" -ForegroundColor Gray
}
Write-Host ""
# 7. 发布每个包
Write-Host "📤 开始发布包到 npm..." -ForegroundColor Cyan
foreach ($package in $PACKAGES) {
if (Test-Path $package) {
Push-Location $package
$PACKAGE_NAME = node -p "require('./package.json').name"
$PACKAGE_VERSION = node -p "require('./package.json').version"
Write-Host "📤 发布 $PACKAGE_NAME@$PACKAGE_VERSION ..." -ForegroundColor Cyan
pnpm publish --no-git-checks
if ($LASTEXITCODE -ne 0) {
Pop-Location
Write-Host "$package 发布失败,停止后续发布" -ForegroundColor Red
exit 1
}
Pop-Location
Write-Host "$PACKAGE_NAME@$PACKAGE_VERSION 发布成功" -ForegroundColor Green
Write-Host ""
} else {
Write-Host "⚠️ 跳过不存在的包: $package" -ForegroundColor Yellow
}
}
Write-Host "🎉 所有包发布完成!" -ForegroundColor Green
# 8. 创建 Git 标签
Write-Host "🏷️ 创建 Git 标签..." -ForegroundColor Cyan
git tag "v$COMMON_VERSION"
Write-Host ""
# 9. 推送到远程仓库
Write-Host "🔼 推送到远程仓库..." -ForegroundColor Cyan
$push = Read-Host "是否推送到远程仓库? (y/N)"
if ($push -eq "y" -or $push -eq "Y") {
git push origin master
git push origin "v$COMMON_VERSION"
Write-Host "✅ 已推送到远程仓库" -ForegroundColor Green
} else {
Write-Host "⚠️ 跳过推送,请手动执行:" -ForegroundColor Yellow
Write-Host " git push origin master" -ForegroundColor Gray
Write-Host " git push origin v$COMMON_VERSION" -ForegroundColor Gray
}
Write-Host ""
Write-Host "🎉 所有包发布完成!版本: v$COMMON_VERSION" -ForegroundColor Green

View File

@ -1,13 +1,23 @@
#!/bin/bash
# 发布所有子包到私有 npm 仓库
# 使用方法: bash scripts/publish.sh
# 使用方法: bash scripts/publish.sh [版本类型]
# 版本类型: major | minor | patch (默认 patch)
# 注意: 发布仓库地址使用各子包 package.json 中的 publishConfig.registry 配置
set -e
REGISTRY="http://192.168.2.127:4873"
# 获取版本类型参数,默认为 patch
VERSION_TYPE=${1:-patch}
echo "🚀 开始发布所有子包到 $REGISTRY"
# 验证版本类型
if [[ ! "$VERSION_TYPE" =~ ^(major|minor|patch)$ ]]; then
echo "❌ 无效的版本类型: $VERSION_TYPE"
echo "使用方法: bash scripts/publish.sh [major|minor|patch]"
exit 1
fi
echo "🚀 开始发布流程 (版本类型: $VERSION_TYPE)"
echo ""
# 子包列表
@ -18,23 +28,97 @@ PACKAGES=(
"packages/vue2"
)
# 先构建所有包
echo "📦 构建所有包..."
pnpm build
# 1. 检查工作区是否干净
echo "🔍 检查 Git 工作区状态..."
if [[ -n $(git status -s) ]]; then
echo "⚠️ 工作区有未提交的更改,请先提交或暂存"
git status -s
read -p "是否继续? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
echo ""
# 发布每个包
# 2. 运行测试
echo "🧪 运行测试..."
if ! pnpm test; then
echo "❌ 测试失败,停止发布"
exit 1
fi
echo ""
# 3. 更新版本号
echo "📝 更新版本号 ($VERSION_TYPE)..."
for package in "${PACKAGES[@]}"; do
if [ -d "$package" ]; then
echo "📤 发布 $package ..."
echo " 更新 $package 版本号..."
cd "$package"
pnpm publish --registry="$REGISTRY" --no-git-checks
npm version $VERSION_TYPE --no-git-tag-version
cd - > /dev/null
echo "$package 发布成功"
fi
done
echo ""
# 4. 构建所有包
echo "📦 构建所有包..."
if ! pnpm build; then
echo "❌构建失败,停止发布"
exit 1
fi
echo ""
# 5. 更新 README 中的版本信息
echo "📄 更新 README..."
COMMON_VERSION=$(node -p "require('./packages/common/package.json').version")
echo " 当前版本: $COMMON_VERSION"
echo ""
# 6. 提交版本更新
echo "💾 提交版本更新..."
git add packages/*/package.json
git commit -m "chore(release): publish v$COMMON_VERSION" || echo " 没有需要提交的更改"
echo ""
# 7. 发布每个包
echo "📤 开始发布包到 npm..."
for package in "${PACKAGES[@]}"; do
if [ -d "$package" ]; then
PACKAGE_NAME=$(node -p "require('./$package/package.json').name")
PACKAGE_VERSION=$(node -p "require('./$package/package.json').version")
echo "📤 发布 $PACKAGE_NAME@$PACKAGE_VERSION ..."
cd "$package"
if ! pnpm publish --no-git-checks; then
echo "$package 发布失败,停止后续发布"
exit 1
fi
cd - > /dev/null
echo "$PACKAGE_NAME@$PACKAGE_VERSION 发布成功"
echo ""
else
echo "⚠️ 跳过不存在的包: $package"
fi
done
echo "🎉 所有包发布完成!"
# 8. 创建 Git 标签
echo "🏷️ 创建 Git 标签..."
git tag "v$COMMON_VERSION"
echo ""
# 9. 推送到远程仓库
echo "🔼 推送到远程仓库..."
read -p "是否推送到远程仓库? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
git push origin master
git push origin "v$COMMON_VERSION"
echo "✅ 已推送到远程仓库"
else
echo "⚠️ 跳过推送,请手动执行:"
echo " git push origin master"
echo " git push origin v$COMMON_VERSION"
fi
echo ""
echo "🎉 所有包发布完成!版本: v$COMMON_VERSION"

17
tsconfig.base.json Normal file
View File

@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["dom", "esnext"],
"allowJs": true,
"declaration": true,
"skipLibCheck": true
}
}

View File

@ -1,23 +1,8 @@
{
"exclude": ["node_modules", "dist"],
"extends": "./tsconfig.base.json",
"exclude": ["node_modules", "dist", "packages"],
"include": ["**/*.ts"],
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext"],
// "types": ["@dcloudio/types"],
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
},
"allowJs": true,
"outDir": "./types"
}
}