Skip to content

Instantly share code, notes, and snippets.

@ewieberappc
Last active September 15, 2018 04:41
Show Gist options
  • Save ewieberappc/155cb57c66cd8923ac48 to your computer and use it in GitHub Desktop.
Save ewieberappc/155cb57c66cd8923ac48 to your computer and use it in GitHub Desktop.
Print out your Appc CLI environment
USAGE:
$ whatami [options] - Prints your Appcelerator environment
OPTIONS:
-t, --ticket - Prints a shorter format of your versions (local only) and copies the output to your clipboard for posting in tickets.
-p, --print - Prints the output from the last time the '--ticket' option was used
-c, --compare - Compares your current environment to your past environment (the last time the '--ticket' option was used)
INSTALLATION:
1. Download the executable file to a folder (recommended '~/bin')
2. Add the path to the folder to your PATH in your .bash_profile (export PATH=$PATH:~/bin)
3. Restart your terminal or run '. ~/.bash_profile'
NOTES:
- Only looks in ~/Library/Application Support/Titanium for SDKs
FAIL=false; LOGIN=$(appc ti --no-banner 2>/dev/null); 2>/dev/null || FAIL=true; if $FAIL; then echo -e $'\e[31m''\tNo Appc CLI installed; Aborting'$'\e[0m'; exit; fi; if [[ $LOGIN == *"Login required"* ]]; then echo -e $'\e[31m''\tNot logged in to CLI; Please log in and try again'$'\e[0m'; appc login --no-banner; echo -ne $'\e[33m''\n\tTrying again... '$'\e[0m'; ${FUNCNAME[0]} $1; exit; fi; case "$1" in -h|--help) echo -ne '\t'$'\e[37m''For help, see: https://gist.github.com/ewieberappc/155cb57c66cd8923ac48\n'$'\e[0m'; exit;; --ticket|-t) echo 'MacOS '$(sw_vers -productVersion)' ('$(sw_vers -buildVersion)')' | tee ~/.whatamiExport; echo 'Studio '$(sed -n 's/.*<string>\([0-9\.]\{18,\}\)<\/string>/\1/1p' /Applications/AppceleratorStudio.app/Contents/Info.plist 2>/dev/null || echo 'None or not in default location') | tee -a ~/.whatamiExport; echo -n 'Ti SDK ' | tee -a ~/.whatamiExport; if [ -e ~/Library/Application\ Support/Titanium ]; then echo $(appc ti sdk -o json | sed -n 's/.*\"activeSDK\": \"\(.*\)\",/\1/1p') | tee -a ~/.whatamiExport; else echo 'None' | tee -a ~/.whatamiExport; fi; echo 'Appc NPM '$(npm ls -g -s -json | sed -n 's/.*\/appcelerator-\(.*\)\.tgz\",/\1/1p') | tee -a ~/.whatamiExport; echo 'Appc CLI '$(appc -v) | tee -a ~/.whatamiExport; echo 'Alloy '$(appc alloy -v) | tee -a ~/.whatamiExport; xcode-select -p 1>/dev/null | tee -a ~/.whatamiExport; if [[ $? -eq 0 ]]; then echo $(xcodebuild -version | sed 's/Build version /\(/g')')' | tee -a ~/.whatamiExport; fi; cat ~/.whatamiExport | pbcopy; echo -e '\n\tOutput copied to Clipboard\n';; --print|-p) if [[ -e ~/.whatamiExport ]]; then cat ~/.whatamiExport; else echo -e "No past environment saved!\nRun 'whatami -t' first"; fi;; --compare|-c) if [[ -e ~/.whatamiExport ]]; then echo -e $'\e[37m''Current:\t\t\tPast: '$(stat -f "%m%t%Sm %N" ~/.whatamiExport | cut -c12-31)$'\e[0m' 2>/dev/null; whatami -p > ~/.whatamiExport2; whatami -t 1>/dev/null; cat ~/.whatamiExport ~/.whatamiExport2 | column -s "\n" -c 75; mv ~/.whatamiExport2 ~/.whatamiExport; else echo -e "No past environment saved!\nRun 'whatami -t' first"; fi;; "") echo -e $'\e[36m''\nAppcelerator'; echo -ne $'\e[0m''\tStudio\t= '$'\e[35m'; sed -n 's/.*<string>\([0-9\.]\{18,\}\)<\/string>/\1/1p' /Applications/AppceleratorStudio.app/Contents/Info.plist 2>/dev/null || echo $'\e[31m''None or not in default location'; echo -ne $'\e[0m''\tTi SDK\t= '$'\e[35m'; if [ -e ~/Library/Application\ Support/Titanium ]; then appc ti sdk -o json | sed -n 's/.*\"activeSDK\": \"\(.*\)\",/\1/1p'; else echo $'\e[31m''None'; fi; echo -e $'\e[36m''Appc CLI'; echo -ne $'\e[0m''\tNPM\t= '$'\e[35m'; npm ls -g -json -s | sed -n 's/.*\/appcelerator-\(.*\)\.tgz",/\1/1p'; echo -ne $'\e[0m''\tCore\t= '$'\e[35m'; APPCV=$(appc -v); echo $APPCV; echo -ne $'\e[0m''\tArrow\t= '$'\e[35m'; sed -n 's/.*"version": "\(.*\)"/\1/1p' ~/.appcelerator/install/$APPCV/package/node_modules/arrow/package.json; echo -ne $'\e[0m''\tEnv\t= '$'\e[35m'; appc config -o json | sed -n 's/.*"name": "\(.*\)",/\1/1p' | tail -1; echo -ne $'\e[36m''Titanium CLI\n'$'\e[0m''\tLocal\t= '$'\e[35m'; TiV=$(appc ti -v); echo $TiV; echo -ne $'\e[0m''\tGlobal\t= '$'\e[35m'; ti -v 2>/dev/null || echo $'\e[31m''None'; echo -ne $'\e[36m''Alloy\n'$'\e[0m''\tLocal\t= '$'\e[35m'; alloyV+=$(appc alloy -v); echo $alloyV; echo -ne $'\e[0m''\tGlobal\t= '$'\e[35m'; alloy -v 2>/dev/null || echo $'\e[31m''None'; echo -e $'\e[36m''Misc'; echo -ne $'\e[0m''\tMacOS\t= '$'\e[35m'; echo $(sw_vers -productVersion)' ('$(sw_vers -buildVersion)')'; echo -ne $'\e[0m''\tNode\t= '$'\e[35m'; node -v; echo -ne $'\e[0m''\tNPM\t= '$'\e[35m'; npm -v; echo -ne $'\e[0m''\tJava\t= '$'\e[35m'; echo "$(java -version 2>&1)" | grep "java version" | awk '{ print substr($3, 2, length($3)-2); }'; xcode-select -p 1>/dev/null; if [[ $? -eq 0 ]]; then echo -ne $'\e[0m''\tXcode\t= '$'\e[35m'; echo -n $(xcodebuild -version | sed 's/Xcode //g' | sed 's/Build version /\(/g'); echo ')'; fi; echo -e $'\e[0m';; esac;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment