diff --git a/package.json b/package.json index 1b34398..48d0c0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-maui", - "version": "0.1.0", + "version": "0.1.1", "description": "React Native UI Library", "main": "src/index", "scripts": { diff --git a/publish.sh b/publish.sh new file mode 100644 index 0000000..224d16a --- /dev/null +++ b/publish.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# 检查是否以root用户运行 +if [ "$(id -u)" -eq 0 ]; then + echo "This script should not be run as root" + exit 1 +fi + +# 切换到npm官方源 +echo "Switching npm registry to https://registry.npmjs.org/" +npm config set registry https://registry.npmjs.org/ + +# 验证是否切换成功 +current_registry=$(npm config get registry) +if [ "$current_registry" != "https://registry.npmjs.org/" ]; then + echo "Failed to switch npm registry to https://registry.npmjs.org/" + exit 1 +fi + +echo "npm registry has been switched to https://registry.npmjs.org/" + +# 执行npm publish命令 +echo "Executing npm publish..." +npm publish +publish_status=$? + +# 检查publish命令是否成功 +if [ $publish_status -ne 0 ]; then + echo "npm publish failed" + # 切换回npmmirror源之前先退出脚本,避免进一步操作 + exit $publish_status +fi + +echo "npm publish succeeded" + +# 切换到npmmirror源 +echo "Switching npm registry back to https://registry.npmmirror.com/" +npm config set registry https://registry.npmmirror.com/ + +# 验证是否切换成功 +current_registry=$(npm config get registry) +if [ "$current_registry" != "https://registry.npmmirror.com/" ]; then + echo "Failed to switch npm registry to https://registry.npmmirror.com/" + exit 1 +fi + +echo "npm registry has been switched back to https://registry.npmmirror.com/" + +echo "Script execution completed successfully" +exit 0 \ No newline at end of file