Skip to content

Commit

Permalink
Merge pull request nodester#1 from gradus/master
Browse files Browse the repository at this point in the history
Add ability to have dependencies_verify install missing NPM modules
  • Loading branch information
alejandro committed Mar 18, 2012
2 parents 60dea91 + 1f8407b commit 3f7ca07
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -10,12 +10,13 @@ Note: These scripts are still under development
We're not responsible for whatever injuries/damage you could get from/by this script. Included but not limited to fried cats, zombie relatives or your fiacee suddenly turning nerdy.

## Steps
Verify your environment dependencies by running "./dependencies_verify.sh"
Install all missing NPM modules using "npm install -g"
Verify your environment and/or install dependencies by running "./dependencies_verify.sh"
Install all missing NPM modules using "npm install -g" if electing not
to auto-install with dependencies_verify.sh
Run "sudo su"
Run "./env_creation.sh"

## Need Help?

* Hit us up in IRC at irc.freenode.net #nodester or http://irc.nodester.com
* You can also ask questions and provide feedback in our google group at http://groups.google.com/group/nodester
* You can also ask questions and provide feedback in our google group at http://groups.google.com/group/nodester
51 changes: 43 additions & 8 deletions dependencies_verify.sh
@@ -1,5 +1,5 @@
#!/bin/bash
# simple script to verify if youw system already has the needed binary for express
# simple script to verify if your system already has the needed binary for express

echo " _ _"
echo " | | | |"
Expand Down Expand Up @@ -45,12 +45,12 @@ do
echo ;
} \
|| {
DEP_KO="I need $sys_dep and but it is missing." ;
DEP_KO="I need $sys_dep but it is missing." ;
KO_MSG="KO - :(";
TRM_COL=$(tput cols) ; DEP_COL_KO=${#DEP_KO} ; KO_MSG_COL=${#KO_MSG} ;
COL_KO=$(( $TRM_COL - $DEP_COL_KO - $KO_MSG_COL )) ;
sys_dep="${BLDCYA}${sys_dep}${NOCOLR}"
DEP_KO="I need $sys_dep and but it is missing." ;
DEP_KO="I need $sys_dep but it is missing." ;
printf '%s%*s%s' "$DEP_KO" $COL_KO "[${BLDRED}${KO_MSG}${NOCOLR}]" >&2;
echo ;
new_len=$(( ${#sys_deps_not_ok[@]} + 1 ))
Expand All @@ -59,6 +59,8 @@ do
done
# checking npm dependencies
declare -a npm_deps_not_ok
declare -a npm_deps_to_install
npm_deps_to_install=()
npm_deps_not_ok=()
for npm_mod in ${npm_modules_dependencies[@]}
do
Expand All @@ -81,16 +83,20 @@ do
printf '%s%*s%s' "$DEP_OK" $COL_OK "[${BLDGRN}${OK_MSG}${NOCOLR}]" >&2;
echo ;
else
DEP_KO="I need $npm_mod and but it is missing." ;
DEP_KO="I need $npm_mod but it is missing." ;
KO_MSG="KO - :(";
TRM_COL=$(tput cols) ; DEP_COL_KO=${#DEP_KO} ; KO_MSG_COL=${#KO_MSG} ;
COL_KO=$(( $TRM_COL - $DEP_COL_KO - $KO_MSG_COL )) ;
COL_KO=$(( $TRM_COL - $DEP_COL_KO - $KO_MSG_COL )) ;
npm_mod_to_install="${npm_mod}"
npm_mod="${BLDVIO}${npm_mod}${NOCOLR}"
DEP_KO="I need $npm_mod and but it is missing." ;
DEP_KO="I need $npm_mod but it is missing." ;
printf '%s%*s%s' "$DEP_KO" $COL_KO "[${BLDRED}${KO_MSG}${NOCOLR}]" >&2;
echo ;
new_len=$(( ${#npm_deps_not_ok[@]} + 1 ))
npm_deps_not_ok[$new_len]=$npm_mod
new_install=$(( ${#npm_deps_to_install[@]} + 1 ))
npm_deps_to_install[$new_install]=$npm_mod_to_install

fi
done
# printing missing dependencies
Expand All @@ -105,13 +111,42 @@ then
fi
if [ "${#npm_deps_not_ok[@]}" -gt "0" ] ;
then
echo -n "NPM Components ${BLDYEL}not found${NOCOLR}: "
echo -n "NPM modules ${BLDYEL}not found${NOCOLR}: "
for i in "${npm_deps_not_ok[@]}"
do
echo -n "$i "
done
echo
echo ;
echo ;
echo -n "I can install these missing NPM modules for you."
echo ;
echo -n "Typing ${BLDYEL}yes${NOCOLR} will run ${BLDYEL}npm install${NOCOLR} ${BLDVIO}[missing module]${NOCOLR} ${BLDYEL}-g${NOCOLR}"
echo ;
echo -n "Would you like to install these dependencies globally? [type ${BLDYEL}yes${NOCOLR} to proceed]: "
read install_npm_modules
if [ "$install_npm_modules" == 'yes' ] ;
then
for i in "${npm_deps_to_install[@]}"
do
echo -n "installing npm module ${BLDVIO}$i${NOCOLR}"
echo ;
sh -c "npm install $i -g"
echo ;
done
echo ;
else
echo ;
echo -n "The following NPM modules will need to be installed manually before nodester can be installed" ;
echo ;
for i in "${npm_deps_not_ok[@]}"
do
echo -n "$i "
done
echo

fi
fi

if [ "${#sys_deps_not_ok[@]}" -gt "0" ] || [ "${#npm_deps_not_ok[@]}" -gt "0" ] ;
then
exit 1
Expand Down

0 comments on commit 3f7ca07

Please sign in to comment.