Created
May 9, 2019 20:08
-
-
Save kevinziegler/2851ab9fc56997eb8d2b2f548184720f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash | |
function vercomp() { | |
if [[ $1 == $2 ]] | |
then | |
return 0 | |
fi | |
local IFS=. | |
local i ver1=($1) ver2=($2) | |
# fill empty fields in ver1 with zeros | |
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) | |
do | |
ver1[i]=0 | |
done | |
for ((i=0; i<${#ver1[@]}; i++)) | |
do | |
if [[ -z ${ver2[i]} ]] | |
then | |
# fill empty fields in ver2 with zeros | |
ver2[i]=0 | |
fi | |
if ((10#${ver1[i]} > 10#${ver2[i]})) | |
then | |
return 1 | |
fi | |
if ((10#${ver1[i]} < 10#${ver2[i]})) | |
then | |
return 2 | |
fi | |
done | |
return 0 | |
} | |
# does the host have the right version of nodejs installed? | |
nodejs_version=`node -v` | |
min_nodejs_version='10.0' | |
max_nodejs_version='10.99' | |
echo "NodeJS version: ${nodejs_version:1}" | |
if [[ $(vercomp ${nodejs_version:1} ${min_nodejs_version}; echo $?) -gt 1 || $(vercomp ${max_nodejs_version} ${nodejs_version:1}; echo $?) -gt 1 ]]; then | |
echo "NodeJS version must > ${min_nodejs_version} and < ${max_nodejs_version} to continue. Try:" | |
echo "nvm use 8" | |
exit 1 | |
fi | |
# does the host have the right version of npm installed? | |
npm_version=`npm -v` | |
min_npm_version='6.4.1' | |
echo "NPM version: ${npm_version}" | |
if [[ $(vercomp ${npm_version} ${min_npm_version}; echo $?) -gt 1 ]]; then | |
echo "NPM version must be >= ${min_npm_version}. Try:" | |
echo "npm install npm@latest -g" | |
exit 1 | |
fi | |
# Clean out existing node modules to ensure we have a clean slate | |
rm -rf node_modules | |
# Install npm packages on host so we can pull private dependencies | |
npm install | |
# Build storybook | |
# npm run build-lib | |
# npm run build-storybook | |
npm run build | |
# Record the architecture used to build native modules. We'll check | |
# this in config/install.sh to see if we need to rebuild. | |
uname="$(uname -s) $(uname -m)" | |
echo $uname > .build_architecture | |
mkdir -p public/ | |
cp -R build/* public/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment