[ADF-570] Script for Pushing to Registry (#1875)

* change prepublish to build only
add .npmrc in the gitignore and npmignore
clean .npmrc during the clean task
change registry during publish with npmrc file
add rimraf install in npm publish

* add option to link an alfresco-js-api from github

* npm build on develop branch will use the alfresco-js-api from develop

* modify script after review
add -gitjsapi to starts.sh to change jsapi pointing
add -vjsapi to starts.sh to change jsapi pointing

* start dist demo shell script option
This commit is contained in:
Eugenio Romano
2017-05-12 15:12:24 +01:00
committed by Eugenio Romano
parent 1fadfa8166
commit 72704cad57
70 changed files with 351 additions and 54 deletions

View File

@@ -3,7 +3,9 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
eval FORCE_PUBLISH=false
eval NPM_REGISTRY=""
eval EXEC_CHANGE_REGISTRY=false
eval NPM_REGISTRY=false
eval TOKEN_REGISTRY=""
eval OPTIONS=""
cd "$DIR/../demo-shell-ng2"
@@ -13,6 +15,7 @@ show_help() {
echo ""
echo "-f or -force publish the package with force"
echo "-r or -registry to publish in an alternative npm registry -registry 'http://npm.local.me:8080/' "
echo "-token auth token for publish in the npm registry"
echo "-t or -tag to add a tag when publish a package"
}
@@ -20,6 +23,21 @@ enable_force(){
OPTIONS="$OPTIONS -force"
}
enable_change_registry(){
NPM_REGISTRY=$1
EXEC_CHANGE_REGISTRY=true
}
get_token_registry(){
TOKEN_REGISTRY=$1
if [[ "${TOKEN_REGISTRY}" == "" ]]
then
echo "token missing -token"
exit 0
fi
}
add_tag(){
eval TAG=$1
@@ -34,8 +52,6 @@ add_tag(){
}
change_registry(){
NPM_REGISTRY=$1
if [[ "${NPM_REGISTRY}" == "" ]]
then
echo "NPM registry required WITH OPTION -r | -registry"
@@ -43,7 +59,10 @@ change_registry(){
fi
echo "====== CHANGE REGISTRY: ${NPM_REGISTRY} ====="
npm config set registry ${NPM_REGISTRY}
touch .npmrc
echo 'strict-ssl=false' >> .npmrc
echo 'registry=http://'${NPM_REGISTRY} >> .npmrc
echo '//'${NPM_REGISTRY}'/:_authToken="'${TOKEN_REGISTRY}'"' >> .npmrc
}
while [[ $1 == -* ]]; do
@@ -51,7 +70,7 @@ while [[ $1 == -* ]]; do
-h|--help|-\?) show_help; exit 0;;
-t|--tag) add_tag $2; shift 2;;
-f|--force) enable_force; shift;;
-r|--registry) change_registry $2; shift 2;;
-r|--registry) get_token_registry $2; shift 2;;
-*) echo "invalid option: $1" 1>&2; show_help; exit 0;;
esac
done
@@ -75,10 +94,23 @@ for PACKAGE in \
ng2-alfresco-userinfo
do
DESTDIR="$DIR/../ng2-components/${PACKAGE}"
echo "====== PUBLISHING: ${DESTDIR} ===== npm publish ${OPTIONS}"
echo "====== MOVE DIR: ${DESTDIR} ===== "
cd ${DESTDIR}
echo "====== INSTALL AND CLEAN ===== "
npm install rimraf
npm run clean
npm install
if $EXEC_CHANGE_REGISTRY == true; then
change_registry
fi
echo "====== PUBLISHING: ${DESTDIR} ===== npm publish ${OPTIONS}"
npm publish ${OPTIONS}
if $EXEC_CHANGE_REGISTRY == true; then
npm run rimraf .npmrc
fi
cd ${DIR}
done