feat(): 配置发布npm
This commit is contained in:
parent
1ccbd4e872
commit
f67c787e07
41
README.md
41
README.md
|
|
@ -129,6 +129,47 @@ pnpm commit
|
||||||
|
|
||||||
提交时 husky 会自动运行 lint-staged 和 jest 测试。
|
提交时 husky 会自动运行 lint-staged 和 jest 测试。
|
||||||
|
|
||||||
|
## 发布
|
||||||
|
|
||||||
|
### 发布到私有 npm 仓库
|
||||||
|
|
||||||
|
项目已配置发布到私有 npm 仓库 `http://192.168.2.127:4873`。
|
||||||
|
|
||||||
|
#### Windows (PowerShell)
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 发布所有子包
|
||||||
|
powershell scripts/publish.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Linux/macOS (Bash)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 发布所有子包
|
||||||
|
bash scripts/publish.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
发布脚本会自动:
|
||||||
|
|
||||||
|
1. 构建所有子包
|
||||||
|
2. 依次发布 `@r-utils/common`、`@r-utils/vue3`、`@r-utils/uni-app`、`@r-utils/vue2`
|
||||||
|
|
||||||
|
### 安装已发布的包
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 配置 npm registry
|
||||||
|
npm config set registry http://192.168.2.127:4873
|
||||||
|
|
||||||
|
# 或在项目中使用 .npmrc 文件
|
||||||
|
echo "registry=http://192.168.2.127:4873" > .npmrc
|
||||||
|
|
||||||
|
# 安装包
|
||||||
|
pnpm add @r-utils/common
|
||||||
|
pnpm add @r-utils/vue3
|
||||||
|
pnpm add @r-utils/uni-app
|
||||||
|
pnpm add @r-utils/vue2
|
||||||
|
```
|
||||||
|
|
||||||
## 项目结构
|
## 项目结构
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@
|
||||||
"utils",
|
"utils",
|
||||||
"tools"
|
"tools"
|
||||||
],
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"registry": "http://192.168.2.127:4873"
|
||||||
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "CodiceFabbrica",
|
"name": "CodiceFabbrica",
|
||||||
"email": "randy1924@163.com",
|
"email": "randy1924@163.com",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@r-utils/common",
|
"name": "@r-utils/common",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": false,
|
||||||
"description": "js通用工具库",
|
"description": "js通用工具库",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.cjs",
|
"main": "dist/index.cjs",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@r-utils/uni-app",
|
"name": "@r-utils/uni-app",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": false,
|
||||||
"description": "uni-app工具库",
|
"description": "uni-app工具库",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.cjs",
|
"main": "dist/index.cjs",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@r-utils/vue2",
|
"name": "@r-utils/vue2",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": false,
|
||||||
"description": "Vue2工具库",
|
"description": "Vue2工具库",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.cjs",
|
"main": "dist/index.cjs",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@r-utils/vue3",
|
"name": "@r-utils/vue3",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
"private": false,
|
||||||
"description": "Vue3 工具",
|
"description": "Vue3 工具",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.cjs",
|
"main": "dist/index.cjs",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { ComponentInternalInstance, ComponentPublicInstance } from "vue";
|
import { ComponentPublicInstance } from "vue";
|
||||||
|
|
||||||
type CustomClassObj = Record<string, boolean>;
|
type CustomClassObj = Record<string, boolean>;
|
||||||
type CustomClass = string | Array<string> | CustomClassObj;
|
type CustomClass = string | Array<string> | CustomClassObj;
|
||||||
|
|
@ -72,7 +72,7 @@ export function convertCustomClass(sourceClass: CustomClass): CustomClassObj {
|
||||||
export function mergeClass(...customClass: CustomClass[]) {
|
export function mergeClass(...customClass: CustomClass[]) {
|
||||||
return customClass
|
return customClass
|
||||||
.map((cc) => convertCustomClass(cc))
|
.map((cc) => convertCustomClass(cc))
|
||||||
.reduce((a, b) => Object.assign(a, b));
|
.reduce((a, b) => Object.assign(a, b),{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -105,6 +105,6 @@ export function dispatch(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent.$emit.call(parent, eventName, params);
|
parent.$emit(eventName, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
# 发布所有子包到私有 npm 仓库
|
||||||
|
# 使用方法: powershell scripts/publish.ps1
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
$REGISTRY = "http://192.168.2.127:4873"
|
||||||
|
|
||||||
|
Write-Host "🚀 开始发布所有子包到 $REGISTRY" -ForegroundColor Green
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# 子包列表
|
||||||
|
$PACKAGES = @(
|
||||||
|
"packages/common",
|
||||||
|
"packages/vue3",
|
||||||
|
"packages/uni-app",
|
||||||
|
"packages/vue2"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 先构建所有包
|
||||||
|
Write-Host "📦 构建所有包..." -ForegroundColor Cyan
|
||||||
|
pnpm build
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# 发布每个包
|
||||||
|
foreach ($package in $PACKAGES) {
|
||||||
|
if (Test-Path $package) {
|
||||||
|
Write-Host "📤 发布 $package ..." -ForegroundColor Cyan
|
||||||
|
Push-Location $package
|
||||||
|
pnpm publish --registry="$REGISTRY" --no-git-checks
|
||||||
|
Pop-Location
|
||||||
|
Write-Host "✅ $package 发布成功" -ForegroundColor Green
|
||||||
|
Write-Host ""
|
||||||
|
} else {
|
||||||
|
Write-Host "⚠️ 跳过不存在的包: $package" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "🎉 所有包发布完成!" -ForegroundColor Green
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 发布所有子包到私有 npm 仓库
|
||||||
|
# 使用方法: bash scripts/publish.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
REGISTRY="http://192.168.2.127:4873"
|
||||||
|
|
||||||
|
echo "🚀 开始发布所有子包到 $REGISTRY"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 子包列表
|
||||||
|
PACKAGES=(
|
||||||
|
"packages/common"
|
||||||
|
"packages/vue3"
|
||||||
|
"packages/uni-app"
|
||||||
|
"packages/vue2"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 先构建所有包
|
||||||
|
echo "📦 构建所有包..."
|
||||||
|
pnpm build
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 发布每个包
|
||||||
|
for package in "${PACKAGES[@]}"; do
|
||||||
|
if [ -d "$package" ]; then
|
||||||
|
echo "📤 发布 $package ..."
|
||||||
|
cd "$package"
|
||||||
|
pnpm publish --registry="$REGISTRY" --no-git-checks
|
||||||
|
cd - > /dev/null
|
||||||
|
echo "✅ $package 发布成功"
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo "⚠️ 跳过不存在的包: $package"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "🎉 所有包发布完成!"
|
||||||
Loading…
Reference in New Issue