diff --git a/.gitignore b/.gitignore index 3ded152..37e1ab8 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ backstop_data/html_report /.ci /.dumi/tmp /.vscode + +.tgz diff --git a/package.json b/package.json index 035e40f..4503edd 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "build": "lerna run build --no-private", "docs:build": "dumi build && chmod +x ./scripts/copy-cname.sh && ./scripts/copy-cname.sh", "site:release": "chmod +x ./scripts/website-release.sh && ./scripts/website-release.sh 'update website'", + "package": "chmod +x ./scripts/pack-packages.sh && ./scripts/pack-packages.sh", "test": "jest --no-cache", "ci:test": "npm run test -- --coverage", "ci:eslint": "npm run lint:script -- -f json -o ./.ci/eslint.json", diff --git a/scripts/pack-packages.sh b/scripts/pack-packages.sh new file mode 100755 index 0000000..ad830ce --- /dev/null +++ b/scripts/pack-packages.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# 设置 packages 目录路径 +PACKAGES_DIR="packages" + +if [ ! -d "$PACKAGES_DIR" ]; then + echo "$PACKAGES_DIR 目录不存在" + exit 1 +fi + +# 遍历每个包 +for package in "$PACKAGES_DIR"/*; do + if [ -d "$package" ]; then + package_name=$(basename "$package") + echo "🚀正在压缩: $package" + + # 检查特定包的构建产物 + case "$package_name" in + "bui-core"|"bui-icons"|"bui-utils") + [[ -d "$package/dist" && -d "$package/es" ]] || { + echo ">>>💔 $package 缺少构建产物dist或es目录,请确认是否执行构建命令: yarn build" + exit 1 + } + ;; + "bui-styles") + [[ -d "$package/dist" ]] || { + echo ">>>💔 $package 缺少构建产物dist目录,请确认是否执行构建命令: yarn build" + exit 1 + } + ;; + "bui-types") + # 不需要检查构建产物 + ;; + *) + continue + ;; + esac + + # 压缩包 + cd "$package" || continue + npm pack + # 返回上级目录 + cd - > /dev/null + fi +done + +echo "✅所有子包压缩完成!!"