#!/bin/bash # # Flutter upgrade from a fresh install # version : 1.0 # Can be used in case of androidX migration. # ios, Android specific configruation are not copied ; use a git merge after execution # # Copy this file in /usr/local/bin/ and call it from root source of an existing flutter project. # It requires : jq, xq and yq installation # > brew install jq # > pip install yq xq # # > curl -o /usr/local/bin/flutter-upgrade.sh https://gist.github.com/ludoo0d0a/12c013739c19c6e0998a19192674ee3d/raw/flutter-upgrade.sh # > chmod +x /usr/local/bin/flutter-upgrade.sh # # set -x TMP=tmp_upgrade DIR=${PWD##*/} APP=`yq .name pubspec.yaml | tr -d '"'` DESC=`yq .description pubspec.yaml | tr -d '"'` PACKAGE=`xq .manifest[\"@package\"] android/app/src/main/AndroidManifest.xml | head -n1 | tr -d '"'` git checkout -b upgrade rm -rf $TMP mkdir $TMP cd $TMP flutter create --org "$PACKAGE" -i swift -a kotlin --description "$DESC" $APP cd $APP #Prepare content rm -rf lib cp -rf ../../lib lib rm -rf test cp -rf ../../test test rm -rf assets cp -rf ../../assets assets cp -rf ../../pubspec.yaml pubspec.yaml cp -rf ../../.gitignore .gitignore rm -f README.md #Copy content back cd ../.. rm -rf android rm -rf ios cp -rf $TMP/$APP/* . # Clean rm -rf $TMP rm -f .packages pwd # build flutter clean flutter packages get