Skip to content

Loading…

Add ability to have dependencies_verify install missing NPM modules #1

Merged
merged 1 commit into from

2 participants

@gradus

Give user option of allowing dependencies_verify.sh to install missing modules by typing yes after checking dependencies or they can elect to still manually install.

@alejandro
Collaborator

Hi @gradus! The changes look great. I'll read them with more time.

Thanks for your patches and help!

@gradus

@alejandromg thanks for taking the time to review.
I think this feature would be a nice addition to the installer.
Please provide any suggestions or feedback and I am happy to work more on it.
Right now, the only thing I am a little uncertain about at this point is line 133
Not entirely sure if you would prefer sh -c "sudo npm install $i -g" or sh -c "npm install $i -g" ?
I added sudo as that is the way I install modules globally on my system.

@alejandro
Collaborator

Well Have you heard|read of What, no sudo?. Personally I would like to run it without sudo. You can instead chown the global local folder wher node_modules dir lives:

sudo chown -R $USER /usr/local
@gradus

@alejandromg Thanks for the read. That was helpful and makes sense to me. I have removed sudo from the npm install command and rebased into a single commit.

Let me know if you see any other issues or have any additional feedback.

@alejandro
Collaborator

OH! I thought that I have already answered you.

*np! I'll merge it! If you want you can add the chown thing, but that it's low priority :)

Again. Thanks....

@alejandro alejandro merged commit 3f7ca07 into nodester:master
@gradus
@gradus

I jacked the formatting of the readme on my last commit.
Opening another pull request to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 47 additions and 11 deletions.
  1. +4 −3 README.md
  2. +43 −8 dependencies_verify.sh
View
7 README.md
@@ -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
View
51 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 " | | | |"
@@ -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 ))
@@ -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
@@ -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
@@ -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
Something went wrong with that request. Please try again.