diff --git a/install b/install index 761deaf..f117caa 100755 --- a/install +++ b/install @@ -6,7 +6,7 @@ set -e DEFAULT_CARTHAGE_VERSION="0.16.2" DEFAULT_SWIFTLINT_VERSION="0.9.2" -DEFAULT_XCODE_VERSION="7.3" +DEFAULT_XCODE_VERSION="10.1" generate_env_file () { @@ -48,6 +48,10 @@ generate_env_file () echo "" echo "What version of Xcode should we use? [$DEFAULT_XCODE_VERSION]" read required_xcode_version + if [ -z "$required_xcode_version" ] + then + required_xcode_version="$DEFAULT_XCODE_VERSION" + fi echo "" echo "Do you want to install githooks when bootstrapping the project? [Y/n]" @@ -62,8 +66,16 @@ generate_env_file () echo "" echo "What version of swiftlint should we use? [$DEFAULT_SWIFTLINT_VERSION]" read required_swiftlint_version + if [ -z "$required_swiftlint_version" ] + then + required_swiftlint_version="$DEFAULT_SWIFTLINT_VERSION" + fi fi + echo "" + echo "Do you want to install SwiftFormat? [N/y]" + read use_swiftformat + if [ -f $1/Cartfile ] || [ -f $1/Cartfile.private ] then echo "" @@ -128,7 +140,10 @@ XCODE_PROJECT=$xcode_project_file IOS_DESTINATION_VERSION=\${IOS_DESTINATION_VERSION:-\"$ios_destination_version\"} IOS_DESTINATION_SIMULATOR_NAME=\${IOS_DESTINATION_SIMULATOR_NAME:-\"$ios_destination_simulator_name\"} OSX_DESTINATION_ARCH=\${OSX_DESTINATION_ARCH:-\"$osx_destination_arch\"}" > "$1/script/.env" - + if [ "$use_swiftformat" == "y" ] + then + echo "USE_SWIFTFORMAT=true" >> "$1/script/.env" + fi if [ "$use_ssh" == "y" ] then echo "USE_SSH=true" >> "$1/script/.env" diff --git a/script/bootstrap b/script/bootstrap index bf7f45b..84ca499 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -152,6 +152,20 @@ install_swiftlint () fi } +install_swiftformat () +{ + source script/common/swiftformat + + if type swiftformat > /dev/null + then + echo "" + echo " ✔ SwiftFormat already installed!" + echo "" + else + force_install_swiftformat + fi +} + install_tailor () { source script/common/tailor @@ -199,6 +213,11 @@ main () then install_swiftlint fi + + if [ -n $USE_SWIFTFORMAT ] + then + install_swiftformat + fi if [ -f .tailor.yml ] then diff --git a/script/common/swiftformat b/script/common/swiftformat new file mode 100644 index 0000000..0323488 --- /dev/null +++ b/script/common/swiftformat @@ -0,0 +1,11 @@ +force_install_swiftformat () +{ + echo "" + echo " → Installing and configuring SwiftFormat..." + echo "" + brew update && brew install swiftformat + + echo "" + echo " SwiftFormat successfully installed" + echo "" +}