Skip to content
This repository
Browse code

Merge pull request #429 from hemanth/patch-1

Code re-factor
  • Loading branch information...
commit 3df5476d358aa93a07fcff6b2d172168d81ea65c 2 parents 1e1aedc + 799e2e6
Paul Irish paulirish authored

Showing 1 changed file with 152 additions and 0 deletions. Show diff stats Hide diff stats

  1. +152 0 setup/audit.sh
152 setup/audit.sh
... ... @@ -0,0 +1,152 @@
  1 +#!/bin/bash
  2 +
  3 +# audit.sh: audit system and check dependencies
  4 +
  5 +# logic
  6 +# 1 = installed, correct version.
  7 +# 0 = not installed.
  8 +# 2 = installed, wrong version.
  9 +
  10 +# todo
  11 +# display results
  12 +
  13 +# requirements (versions required for yeoman)
  14 +reqnode=0.8.0
  15 +reqruby=1.8.7
  16 +reqcompass=0.12.1
  17 +
  18 +# check os
  19 +os=$(uname -s)
  20 +
  21 +if [[ "$os" == "darwin" ]]; then
  22 + mac=1
  23 +elif [[ "$os" == "linux" ]]; then
  24 + linux=1
  25 +else
  26 + echo "os not supproted!"
  27 + exit 1
  28 +fi
  29 +
  30 +# dependency checks
  31 +curlfile=$(command -v curl)
  32 +gitfile=$(command -v git)
  33 +rubyfile=$(command -v ruby)
  34 +nodefile=$(command -v node)
  35 +gemfile=$(command -v gem)
  36 +compassfile=$(command -v compass)
  37 +brewfile=$(command -v brew)
  38 +phantomjsfile=$(command -v phantomjs)
  39 +jpegturbofile=$(command -v jpegtran)
  40 +clangfile=$(command -v clang)
  41 +
  42 +
  43 +check_set(){
  44 + [ -z "$1" ] && echo 1 || echo 0
  45 +}
  46 +# audit \o/
  47 +
  48 +echo "wotcha! well, hello! below is a quick audit i have run to see if everything is in place for yeoman......
  49 +it will take some time, so please grab some coffee ;)"
  50 +
  51 +if [[ $mac = 1 ]]; then
  52 + # xcode cli test.
  53 + cli=$(check_set $clangfile)
  54 +
  55 + # brew test.
  56 + brew=$(check_set $brewfile)
  57 +fi
  58 +
  59 +if [[ $linux = 1 ]]; then
  60 + # curl test.
  61 + curl=$(check_set $curlfile)
  62 +fi
  63 +
  64 +# git test
  65 +git=$(check_set $gitfile)
  66 +
  67 +# node test
  68 +node=$(check_set $nodefile)
  69 +if [[ $node == 1 ]]; then
  70 + nodever=$(node -e 'console.log(process.versions.node);')
  71 + # node version check
  72 + if [[ "$nodever" < "$reqnode" ]]; then
  73 + node=2
  74 + fi
  75 +fi
  76 +
  77 +# ruby test
  78 +ruby=$(check_set $rubyfile)
  79 +if [[ $ruby == 1 ]]; then
  80 + rubyver=$(ruby -e 'print ruby_version')
  81 + # ruby version check
  82 + if [[ "$rubyver" < "$reqruby" ]]; then
  83 + ruby=2
  84 + fi
  85 +fi
  86 +
  87 +# gem test
  88 +gem=$(check_set $gemfile)
  89 +
  90 +# compass test
  91 +compass=$(check_set $compassfile)
  92 +if [[ $compass == 1 ]];then
  93 + compassver=$(compass -qv)
  94 + # compass version check
  95 + if [[ "$compassver" < "$reqcompass" ]]; then
  96 + compass=2
  97 + fi
  98 +fi
  99 +
  100 +# phantomjs test
  101 +phantomjs=$(check_set $phantomjsfile)
  102 +
  103 +# jpeg-turbo test
  104 +jpegturbo=$(check_set $jpegturbofile)
  105 +
  106 +# display results
  107 +#
  108 +# results logic
  109 +# passes first
  110 +# fails second
  111 +
  112 +echo ""
  113 +
  114 +# passes
  115 +if [[ "$mac" = 1 ]]; then
  116 + [ "$cli" -eq 1 ] && echo "✓ *xcode cli tools* are installed." \
  117 + || echo "✘ *xcode cli tools* are not installed, please check the installation docs for assistance."
  118 +
  119 + [ "$brew" -eq 1 ] && echo "✓ *homebrew* is installed." \
  120 + || echo "✘ *homebrew* is not installed, please check the installation docs for assistance."
  121 +fi
  122 +
  123 +if [[ "$linux" = 1 ]]; then
  124 + [ "$curl" -eq 1 ] && echo "✓ *curl* is present, whew." \
  125 + || echo "✘ *curl* is not installed, please check the installation docs for assistance."
  126 +fi
  127 +
  128 +[ "$git" -eq 1 ] && echo "✓ *git* is installed, nice one." \
  129 +|| echo "✘ *git* is not installed, please check the installation docs for assistance."
  130 +
  131 +[ "$node" -eq 1 ] && echo "✓ *nodejs* is installed." \
  132 +|| echo "✘ *nodejs* is not installed, please check the installation docs for assistance."
  133 +
  134 +[ "$ruby" -eq 1 ] && echo "✓ *ruby* is installed." \
  135 +|| echo "✘ *ruby* is not installed, please check the installation docs for assistance."
  136 +
  137 +[ "$gem" -eq 1 ] && echo "✓ *rubygems* is installed." \
  138 +|| echo "✘ *rubygems* is not installed, please check the installation docs for assistance."
  139 +
  140 +[ "$compass" -eq 1 ] && echo "✓ *compass* is installed." \
  141 +|| echo "✘ *compass* is not installed, please check the installation docs for assistance."
  142 +
  143 +
  144 +[ "$phantomjs" -eq 1 ] && echo "✓ *phantomjs* is installed." \
  145 +|| echo "✘ *phantomjs* is not installed, please check the installation docs for assistance."
  146 +
  147 +
  148 +[ "$jpegturbo" -eq 1 ] && echo "✓ *jpeg-turbo* is installed." \
  149 +|| echo "✘ *jpeg-turbo* is not installed, please check the installation docs for assistance."
  150 +
  151 +echo ""
  152 +echo "please ensure all of the above tests have passed before trying to install yeoman."

0 comments on commit 3df5476

Please sign in to comment.
Something went wrong with that request. Please try again.