go.ketch.com/lib/goja@v0.0.1/scripts/check.sh (about) 1 #!/usr/bin/env sh 2 3 # Code generated by shipbuilder init 1.21.2. DO NOT EDIT. 4 5 check_installed() { 6 installed=$(which "$1") 7 8 if [ -z "$installed" ]; then 9 echo "ERROR: $1 is not installed." 10 if [ "$CI" = "true" ]; then 11 exit 1 12 fi 13 14 echo "Do you want to install and continue? Y/N" 15 read install 16 install=$(echo "$install" | tr "[:lower:]" "[:upper:]") 17 if [ "$install" = "Y" -o "$install" = "YES" ]; then 18 sh -c "$2" 19 fi 20 21 export installed=$(which "$1") 22 if [ -z "$installed" ]; then 23 echo "ERROR: $1 is not installed." 24 echo "Install $1 using '$2'." 25 exit 1 26 fi 27 fi 28 } 29 30 brew_installed() { 31 if [ "$CI" != "true" ]; then 32 check_installed brew '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' 33 brew=$installed 34 fi 35 } 36 37 brew_install() { 38 brew_installed 39 check_installed $1 "$brew install ${2:-$1}" 40 } 41 42 go_installed() { 43 brew_install go 44 go=$installed 45 } 46 47 go_install() { 48 go_installed 49 go get $1 50 go install $1 51 installed="go run $1" 52 } 53 54 node_installed() { 55 if [ -f "/usr/local/opt/nvm/nvm.sh" ]; then 56 . /usr/local/opt/nvm/nvm.sh 57 nvm use --lts 58 fi 59 60 if [ -z "$installed" ]; then 61 installed=$(which node) 62 fi 63 64 if [ -z "$installed" ]; then 65 echo "ERROR: node is not installed." 66 if [ "$CI" = "true" ]; then 67 exit 1 68 fi 69 70 echo "Do you want to install and continue? Y/N" 71 read install 72 install=$(echo "$install" | tr "[:lower:]" "[:upper:]") 73 if [ "$install" = "Y" -o "$install" = "YES" ]; then 74 brew_installed 75 76 $brew install nvm 77 . /usr/local/opt/nvm/nvm.sh 78 nvm install --lts --latest-npm 79 nvm use --lts 80 installed=$(which node) 81 fi 82 83 if [ -z "$installed" ]; then 84 echo "ERROR: node is not installed." 85 echo "Install node using '$brew install nvm'." 86 exit 1 87 fi 88 fi 89 90 nvm=nvm 91 node="$installed" 92 } 93 94 npm_installed() { 95 node_installed 96 check_installed npm "$nvm install-latest-npm" 97 npm="$installed" 98 } 99 100 npm_install() { 101 npm_installed 102 check_installed "$1" "$npm install --location=global ${2:-$1}" 103 } 104 105 github_installed() { 106 brew_install gh 107 github="$installed" 108 } 109 110 git_installed() { 111 brew_install git 112 git="$installed" 113 } 114 115 docker_installed() { 116 brew_install docker "homebrew/cask/docker" 117 docker="$installed" 118 } 119 120 yq_installed() { 121 brew_install yq 122 yq="$installed" 123 } 124 125 jq_installed() { 126 brew_install jq 127 jq="$installed" 128 } 129 130 ncu_installed() { 131 npm_install ncu npm-check-updates 132 ncu="$installed" 133 } 134 135 swagger_cli_installed() { 136 npm_install swagger-cli "@apidevtools/swagger-cli" 137 swagger_cli="$installed" 138 } 139 140 protoc_installed() { 141 brew_install protoc protobuf 142 protoc="$installed" 143 } 144 145 protoc_gen_go_installed() { 146 go_install "google.golang.org/protobuf/cmd/protoc-gen-go" 147 protoc_gen_go="$installed" 148 } 149 150 protoc_gen_go_grpc_installed() { 151 go_install "google.golang.org/grpc/cmd/protoc-gen-go-grpc" 152 protoc_gen_go_grpc="$installed" 153 } 154 155 protoc_gen_nats_installed() { 156 go_install "go.ketch.com/tool/proto-nats/cmd/protoc-gen-nats" 157 protoc_gen_nats="$installed" 158 } 159 160 shipbuilder_installed() { 161 go_installed 162 shipbuilder="$go run go.ketch.com/tool/shipbuilder/cmd/shipbuilder" 163 } 164 165 mockery_installed() { 166 go_installed 167 mockery="$go run github.com/vektra/mockery/v2" 168 } 169 170 check() { 171 for i in $*; do 172 "${i}_installed" 173 done 174 }