From 2f77a3d364f15483cb6831232a297128666e1708 Mon Sep 17 00:00:00 2001 From: june Date: Mon, 17 Mar 2025 22:27:18 +1300 Subject: [PATCH] meta: script handles spaces now --- script/app-to-cask.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/script/app-to-cask.sh b/script/app-to-cask.sh index ecbb2e0..83ae989 100755 --- a/script/app-to-cask.sh +++ b/script/app-to-cask.sh @@ -6,19 +6,20 @@ S3_BUCKET="https://dl.breadone.xyz/cask" # prod # S3_BUCKET="https://dl.breadone.xyz/homebrew/casks" # staging # get reported version of app, remove quotes, print just the version -version=$(mdls -name kMDItemVersion $APP_FILE | tr -d '"' | awk '{print $3}') +version=$(mdls -name kMDItemVersion "$APP_FILE" | tr -d '"' | awk '{print $3}') # just the app file name, eg Things3.app -FILENAME=$(basename $APP_FILE) +FILENAME=$(basename "$APP_FILE") # remove extension, eg Things3 -APP_NAME="${FILENAME%.app}" +APPNAME="${FILENAME%.app}" +APPNAME_TRIM=$(echo $APPNAME | sed 's/^[^=]*= //; s/"//g' | tr ' ' '-') # replace spaces with dashes # interpolate to final zip name, eg Things3-3.12.5.zip -ZIP_PATH="$APP_NAME-$version.zip" +ZIP_PATH="$APPNAME_TRIM-$version.zip" # Compress the file -ditto -c -k --sequesterRsrc --keepParent $APP_FILE $ZIP_PATH +ditto -c -k --sequesterRsrc --keepParent "$APP_FILE" $ZIP_PATH # Get hash of file hash=$(sha256 $ZIP_PATH | awk '{ print $4 }') @@ -29,14 +30,16 @@ curl -X PUT "$S3_BUCKET/$ZIP_PATH" \ --data-binary "@$ZIP_PATH" # output (mostly complete) cask file -echo 'cask "'$(echo "$APP_NAME" | tr '[:upper:]' '[:lower:]')'" do' # lowercase appname +echo 'cask "'$(echo "$APPNAME_TRIM" | tr '[:upper:]' '[:lower:]')'" do' # lowercase appname echo ' version "'$version'"' echo ' sha256 "'$hash'"' echo '' echo ' url "'$S3_BUCKET/$ZIP_PATH'"' -echo ' name "'$APP_NAME'"' +echo ' name "'$APPNAME'"' echo ' desc "ENTER_DESCRIPTION"' echo ' homepage "ENTER_HOMEPAGE"' echo '' echo ' app "'$FILENAME'"' -echo 'end' \ No newline at end of file +echo 'end' + +rm $ZIP_PATH \ No newline at end of file