diff --git a/bin/build b/bin/build index cb7f8cf..260522e 100755 --- a/bin/build +++ b/bin/build @@ -37,25 +37,28 @@ nvm use deploy printf "Initializing Meteor environment.\n" cp -R /opt/home/.meteor $HOME -# Demeteorizer flags -# TODO Test for demeteorizer flags -# --json || --debug - cd $INPUT_DIR METEOR_VERSION=$(cat $INPUT_DIR/.meteor/release) printf "Using $METEOR_VERSION.\n" -if [[ -f $INPUT_DIR/package.json ]]; then - printf "Installing root package.json dependencies.\n" - npm install --production +FLAGS="--server-only --output $OUTPUT_DIR" + +if [[ $NPM ]]; then + printf "NPM version $NPM specified.\n" + FLAGS="$FLAGS --npm-version $NPM" fi -demeteorizer --server-only --output $OUTPUT_DIR +if [[ $NODE ]]; then + printf "Node version $NODE specified.\n" + FLAGS="$FLAGS --node-version $NODE" +fi -if [[ -d $INPUT_DIR/node_modules ]]; then - mv $INPUT_DIR/node_modules $OUTPUT_DIR +if [[ $DEBUG ]]; then + FLAGS="$FLAGS --debug" fi +demeteorizer $FLAGS + # Searches a directory top-down looking for a file. findFile() { find $2 -name $1 ! -path "*/node_modules/*" ! -path ".git/*" | \ @@ -65,15 +68,34 @@ findFile() { head -n 1 } -# Recursively search input directory for a package.json +# Recursively search output directory for a package.json PACKAGE_PATH=$(findFile "package.json" $OUTPUT_DIR/bundle/programs/server) +export PACKAGE_PATH -if [[ $PACKAGE_PATH ]]; then - export PACKAGE_PATH +NODE_VERSION=$(get-version --engine node $PACKAGE_PATH 2>/dev/null) || true +NPM_VERSION=$(get-version --engine npm $PACKAGE_PATH 2>/dev/null) || true - if [[ $NPM_USER ]] && [[ $NPM_PASSWORD ]] && [[ $NPM_EMAIL ]]; then - npm-login - fi +if [[ 'v$NODE_VERSION' != $(node -v) ]]; then + nvm install $NODE_VERSION > /dev/null 2>&1 +fi - npm-install +if [[ $NPM_VERSION != $(npm -v) ]]; then + npm install npm@$NPM_VERSION --global > /dev/null 2>&1 fi + +nvm alias deploy $(nvm current) + +if [[ $NPM_USER ]] && [[ $NPM_PASSWORD ]] && [[ $NPM_EMAIL ]]; then + npm-login +fi + +if [[ -f $INPUT_DIR/package.json ]]; then + printf "Installing root package.json dependencies.\n" + npm install --production +fi + +if [[ -d $INPUT_DIR/node_modules ]]; then + mv $INPUT_DIR/node_modules $OUTPUT_DIR +fi + +npm-install diff --git a/bootstrap.sh b/bootstrap.sh index 129e5df..8e824a3 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -10,9 +10,9 @@ export TMP_DIR=/tmp # Other environment variables export NVM_DIR=/opt/nvm export PROFILE=$HOME/.profile -export DEMETEORIZER_VERSION=3.1.0 -export NODE_VERSION=0.10.41 -export NPM_VERSION=3.9.6 +export DEMETEORIZER_VERSION=4.0.0 +export NODE_VERSION=4.4.7 +export NPM_VERSION=3.10.5 # Create $HOME/.profile and export environment variable if [[ ! -d $HOME ]]; then