Commit 841bc804 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add npm install --production support

parent 9edc06af
...@@ -200,12 +200,20 @@ gear_update_from_tarball() ...@@ -200,12 +200,20 @@ gear_update_from_tarball()
fatal "can't import tarball '$TARBALL'" fatal "can't import tarball '$TARBALL'"
} }
# if we have rule for gear-sources
is_gear_sources() is_gear_sources()
{ {
cat $(get_root_git_dir)/.gear/rules | grep -q "^tar:.*\.gear/gear-sources" cat $(get_root_git_dir)/.gear/rules | grep -q "^tar:.*\.gear/gear-sources"
#fatal "missed tar:.gear/gear-sources in $(get_root_git_dir)/.gear/rules" #fatal "missed tar:.gear/gear-sources in $(get_root_git_dir)/.gear/rules"
} }
# if we have rule for gear-production
is_gear_production()
{
cat $(get_root_git_dir)/.gear/rules | grep -q "^tar:.*\.gear/gear-production"
#fatal "missed tar:.gear/gear-sources in $(get_root_git_dir)/.gear/rules"
}
# Args: tarball dir # Args: tarball dir
# Uses: RPMSOURCEDIR FORCEDOWNLOAD # Uses: RPMSOURCEDIR FORCEDOWNLOAD
commit_tarball_to_dir() commit_tarball_to_dir()
...@@ -251,7 +259,7 @@ commit_tarball() ...@@ -251,7 +259,7 @@ commit_tarball()
# FIXME: # FIXME:
# use real path for download # use real path for download
#is_gear_sources && CURNAME= #is_gear_sources && CURNAME=
is_gear_sources && CURNAME=$(get_root_git_dir)/$BASENAME #is_gear_sources && CURNAME=$(get_root_git_dir)/$BASENAME
#fatal "FIXME: fail with is_gear_sources in commit_tarball" #fatal "FIXME: fail with is_gear_sources in commit_tarball"
# hack: try detect dir for unpacking # hack: try detect dir for unpacking
...@@ -288,6 +296,44 @@ update_post_git_submodules() ...@@ -288,6 +296,44 @@ update_post_git_submodules()
docmd git commit $PSM -m "update source prepared with submodules for version $VERSION" docmd git commit $PSM -m "update source prepared with submodules for version $VERSION"
} }
update_gear_production()
{
is_gear_production || return
PSM=$(get_root_git_dir)/.gear/gear-production
local RGD=$(get_root_git_dir)
info "Detected npm install hook, run npm install --production"
# hack for subdir??
CURNAME=$BASENAME
# TODO: add support for git
rm -rf $PSM
cp -a $RGD/$CURNAME $PSM || fatal
cd $PSM || fatal
# CHECKME: drop postinstall due run dev scripts during install --production
# replace with fake commands?
if [ -s $RGD/.gear/npm-preinstall-hook ] ; then
sh $RGD/.gear/npm-preinstall-hook
fi
#subst "s|.*postinstall.*||g" package.json
a= npm install --production || fatal
# drop all exclude node_modules
# TODO: correct .* removing
rm -rf $(ls -1 | grep -v node_modules) .*
#epm assure jq || fatal
#(cd node_modules && rm -rf $(jq -r -c '.devDependencies | keys[]' ../package.json))
cd - >/dev/null
docmd git add -f $PSM
docmd git commit $PSM -m "update node_modules with npm install --production for $VERSION"
}
# note: for tarball based only now # note: for tarball based only now
# uses: BASENAME VERSION # uses: BASENAME VERSION
update_gear_sources() update_gear_sources()
...@@ -299,7 +345,9 @@ update_gear_sources() ...@@ -299,7 +345,9 @@ update_gear_sources()
local RGD=$(get_root_git_dir) local RGD=$(get_root_git_dir)
#if [ -d $PSM ] ; then #if [ -d $PSM ] ; then
info "Detected npm install hook, run npm install --production"
# only npm supported now
info "Detected npm install hook, run npm install"
# if [ -d $RGD/package ] && [ -s $RGD/package/package.json ] ; then # if [ -d $RGD/package ] && [ -s $RGD/package/package.json ] ; then
# info "Detected npm install hook" # info "Detected npm install hook"
...@@ -485,6 +533,7 @@ do ...@@ -485,6 +533,7 @@ do
update_post_git_submodules update_post_git_submodules
# TODO: make plugins # TODO: make plugins
update_gear_sources update_gear_sources
update_gear_production
#docmd gammit #docmd gammit
#docmd git commit -m "merge $FTB with rpmgs script" #docmd git commit -m "merge $FTB with rpmgs script"
...@@ -493,6 +542,7 @@ do ...@@ -493,6 +542,7 @@ do
commit_tarball "$FTB" commit_tarball "$FTB"
# TODO: make plugins # TODO: make plugins
update_gear_sources update_gear_sources
update_gear_production
DOWNLOADSOME=1 DOWNLOADSOME=1
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment