Merge branch 'release' of gitee.com:starlock-cn/app-starlock into release

This commit is contained in:
吴亚茜 2024-06-24 13:41:11 +08:00
commit 5cbb6b0fc1

View File

@ -4,22 +4,54 @@
# 首次使用记得安装jq brew install jq
#
###############################################################
############## 正常情况下只需要修改配置,不需要修改代码 ###############
###############################################################
# 设置
environment="xhj"
main_file="lib/main_xhj_full.dart"
version_string="1.0.51"
version_string="1.0.52"
file_path="lib/network/api.dart"
urls=$(curl -s -X POST -d "version=$version_string" 'https://lock.xhjcn.ltd/api/app/getDeprecatedApiList' | jq -r '.data[].url')
###############################################################
###############################################################
# 判断执行环境
case $environment in
dev)
api_prefix='https://dev.lock.star-lock.cn'
;;
pre)
api_prefix='https://pre.lock.star-lock.cn'
;;
sky)
api_prefix='https://lock.skychip.top'
;;
xhj)
api_prefix='https://lock.xhjcn.ltd'
;;
*)
echo "错误: flavor[$environment] apiPrefix not found"
exit 1
;;
esac
echo "API 前缀为: $api_prefix"
urls=$(curl -s -X POST -d "version=$version_string" "$environment/api/app/getDeprecatedApiList" | jq -r '.data[].url')
echo "* 成功获取废弃 api 数据"
# 解析 api 文件数据
string_array=()
# 使用egrep搜索被单引号包裹的字符串
while IFS= read -r line; do
string_array+=("$line")
done < <(egrep -o "'[^']*'" "$file_path")
echo "* 解析 api 文件数据,开始对比"
# 进度条初始化
total_urls=$(echo "$urls" | wc -l | tr -d ' ')
current_url=0
# 比较urls和string_array中的元素
for url in $urls; do
for string in "${string_array[@]}"; do
@ -30,10 +62,16 @@ for url in $urls; do
exit 1
fi
done
# 更新进度条
let current_url++
let progress=(current_url*100/total_urls)
printf "\r进度: [%-50s] %d%%" $(printf '%*s' $((progress/2)) | tr ' ' '#') $progress
done
echo "* 没有发现 废弃 api开始编译"
# 新的输出从新行开始
echo -e "\n* 没有发现废弃 API开始编译"
# 编译命令
flutter clean && flutter pub get
flutter build apk --flavor $environment -t $main_file
flutter build ios --flavor $environment -t $main_file