diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 471b207c748b459ba033b05690440b89e655fa09..64ff53c6668f0ce7f6798779d97f28c30db5c4be 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -1647,6 +1647,7 @@ class project extends base { . 'export GIT_SSH="'.$this->_aConfig['appRootDir'].'/shellscripts/gitsshwrapper.sh";' . 'export DIR_SSH_KEYS="'.$this->_aConfig['dataDir'].'/sshkeys";' . 'export DIR_APPROOT="'.$sTempBuildDir.'";' + . 'export NVMINIT="'.$this->_aConfig['appRootDir'].'/shellscripts/nvm_init.sh";' . (isset($this->_aConfig['build']['env']) ? $this->_aConfig['build']['env'] : '') ; diff --git a/shellscripts/nvm_init.sh b/shellscripts/nvm_init.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea013258d619e951469f80353f0c300f5904d0cb --- /dev/null +++ b/shellscripts/nvm_init.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# ====================================================================== +# +# NVM INIT +# +# This is a helper tool for build processes with nodejs. +# It installs nvm and offers a method to remove nvm again. +# +# ---------------------------------------------------------------------- +# 2019-06-18 first lines <axel.hahn@iml.unibe.ch> +# ====================================================================== + +# ---------------------------------------------------------------------- +# CONFIG +# ---------------------------------------------------------------------- +NVM_REPO=https://github.com/nvm-sh/nvm.git + + +# ---------------------------------------------------------------------- +# FUNCTIONS +# ---------------------------------------------------------------------- +function nvmremove(){ + echo "REMOVE NVM ..." + + if [ -z $NVM_DIR ]; then + echo ERROR: sorry, NVM_DIR is empty. + exit 1 + fi + + echo -n "Removing NVM from build directory: [$NVM_DIR] ..." + rm -rf "$NVM_DIR" || exit 3 + echo OK + + echo -n "unload ... " + nvm unload || exit 2 + echo OK +} + +# ---------------------------------------------------------------------- +# MAIN +# ---------------------------------------------------------------------- + +echo +echo ===== NVM INIT ===== +echo + +if [ -z $DIR_APPROOT ]; then + echo ERROR: this script runs in a onbuilt process only. + echo Currently here is no DIR_APPROOT to define a temporary working dir. + exit 1 +fi + +# INSTALL NVM ... see +# https://github.com/nvm-sh/nvm#manual-install +export NVM_DIR="$DIR_APPROOT/.nvm" && ( + git clone $NVM_REPO "$NVM_DIR" + cd "$NVM_DIR" + git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` +) && . "$NVM_DIR/nvm.sh" || exit 1