Skip to content

Commit

Permalink
chore: add pack script
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverEllipsis committed Sep 19, 2024
1 parent e369b0b commit d424329
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ backstop_data/html_report
/.ci
/.dumi/tmp
/.vscode

.tgz
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
47 changes: 47 additions & 0 deletions scripts/pack-packages.sh
Original file line number Diff line number Diff line change
@@ -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 "✅所有子包压缩完成!!"

0 comments on commit d424329

Please sign in to comment.