#!/usr/bin/env bash
echo START

projectDir=`pwd`
rootFlutter=`which flutter`
rootDir=${rootFlutter%/*}


dif=debug
#dif=release
message=增加他人的专家页面


#====clean
cd ${projectDir}
${rootFlutter} clean
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
${rootFlutter} packages get

cd ${projectDir}/android
./gradlew assembleRelease

rm -rf /Users/apple/lsy/aar_update/
mkdir /Users/apple/lsy/aar_update/
rm -rf /Users/apple/lsy/update/
mkdir /Users/apple/lsy/update/
mkdir /Users/apple/lsy/update/android${message}${dif}/
mkdir /Users/apple/lsy/update/ios${message}${dif}/
cp -r /Users/apple/lsy/gmalpha_flutter/build/app/outputs/aar/app-release.aar /Users/apple/lsy/aar_update/app.zip
cd /Users/apple/lsy/aar_update/
unzip /Users/apple/lsy/aar_update/app.zip
cp -r /Users/apple/lsy/aar_update/jni/armeabi-v7a/* /Users/apple/lsy/update/androd${message}${dif}/

cd ${projectDir}
flutter build ios --release --no-codesign
cp -r /Users/apple/lsy/gmalpha_flutter/ios/Flutter/App.framework /Users/apple/lsy/update/ios${message}${dif}/
cp -r /Users/apple/lsy/gmalpha_flutter/ios/Flutter/Flutter.framework /Users/apple/lsy/update/ios${message}${dif}/
cd /Users/apple/lsy/update/
open .

