diff --git a/app/README.md b/app/README.md index 24e4ccf..ef4a67d 100644 --- a/app/README.md +++ b/app/README.md @@ -1,3 +1,8 @@ Development notes: -- logo icons are 20px black/white for theme and 100% vs 50% for active inactive (inside bit only.) \ No newline at end of file +- logo icons are 20px black/white for theme and 100% vs 50% for active inactive (inside bit only.) +- deploy new version: + - Update version in `package.json` + - `npm run build` + - Create new [release](https://github.com/actuallymentor/battery/releases) + - Update [brew formula](https://github.com/Homebrew/homebrew-cask/blob/master/Casks/battery.rb) diff --git a/app/modules/battery.js b/app/modules/battery.js index 018aaf7..8540a36 100644 --- a/app/modules/battery.js +++ b/app/modules/battery.js @@ -67,6 +67,14 @@ const update_or_install_battery = async () => { try { + // Check if xcode build tools are installed + const xcode_installed = await exec_async( `${ path_fix } which git` ).catch( () => false ) + if( !xcode_installed ) { + alert( `The Battery tool needs Xcode to be installed, please accept the terms and conditions for installation` ) + await exec_async( `${ path_fix } xcode-select --install` ) + alert( `Please restart the Battery app after Xcode finished installing` ) + } + // Check if battery is installed const is_installed = await exec_async( `${ path_fix } which battery` ).catch( () => false ) log( 'Is installed? ', is_installed ) diff --git a/app/package.json b/app/package.json index 5b333fa..ad61f67 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "battery", - "version": "1.0.3", + "version": "1.0.4", "description": "A battery charge limiter for M1 Mac devices", "main": "main.js", "build": { diff --git a/setup.sh b/setup.sh index c8a0117..396a458 100755 --- a/setup.sh +++ b/setup.sh @@ -17,32 +17,44 @@ configfolder=/Users/$calling_user/.battery pidfile=$configfolder/battery.pid logfile=$configfolder/battery.log + # Ask for sudo once, in most systems this will cache the permissions for a bit sudo echo "šŸ”‹ Starting battery installation" -echo -e "\n[ 1/9 ] Superuser permissions acquired." +# Check if git is installed, and if not, install it +if ! which git &> /dev/null; then + echo -e "\n[ 1/10 ] Xcode build tools are not installed, please accept the xcode dialog" + xcode-select --install + if ! which git; then + echo "Build tools not installed, please run this script again" + fi +else + echo -e "\n[ 1/10 ] Xcode build tools are installed, continuing" +fi + +echo -e "[ 2/10 ] Superuser permissions acquired." # Get smc source and build it smcfolder="$tempfolder/smc" -echo "[ 2/9 ] Cloning fan control version of smc" +echo "[ 3/10 ] Cloning fan control version of smc" rm -rf $smcfolder git clone --depth 1 https://github.com/hholtmann/smcFanControl.git $smcfolder &> /dev/null cd $smcfolder/smc-command -echo "[ 3/9 ] Building smc from source" +echo "[ 4/10 ] Building smc from source" make &> /dev/null # Move built file to bin folder -echo "[ 4/9 ] Move smc to executable folder" +echo "[ 5/10 ] Move smc to executable folder" sudo mkdir -p $binfolder sudo mv $smcfolder/smc-command/smc $binfolder sudo chmod u+x $binfolder/smc # Write battery function as executable batteryfolder="$tempfolder/battery" -echo "[ 5/9 ] Cloning battery repository" +echo "[ 6/10 ] Cloning battery repository" git clone --depth 1 https://github.com/actuallymentor/battery.git $batteryfolder &> /dev/null -echo "[ 6/9 ] Writing script to $binfolder/battery for user $calling_user" +echo "[ 7/10 ] Writing script to $binfolder/battery for user $calling_user" sudo cp $batteryfolder/battery.sh $binfolder/battery # Set permissions for battery executables @@ -65,12 +77,12 @@ sudo chmod 755 $pidfile sudo chown $calling_user $binfolder/battery sudo bash $batteryfolder/battery.sh visudo -echo "[ 7/9 ] Set up visudo declarations" +echo "[ 8/10 ] Set up visudo declarations" # Remove tempfiles cd ../.. -echo "[ 8/9 ] Removing temp folder $tempfolder" +echo "[ 9/10 ] Removing temp folder $tempfolder" rm -rf $tempfolder -echo "[ 9/9 ] Removed temporary build files" +echo "[ 10/10 ] Removed temporary build files" echo -e "\nšŸŽ‰ Battery tool installed. Type \"battery help\" for instructions.\n"