From 2ac6439bb44d7396ec23dd60de5941029cd61f57 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Tue, 23 May 2017 14:21:11 +0100 Subject: [PATCH] check bundles script --- scripts/README.md | 12 +++++ scripts/npm-check-bundles.sh | 88 ++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100755 scripts/npm-check-bundles.sh diff --git a/scripts/README.md b/scripts/README.md index 1499321e95..8d66781ed8 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -210,3 +210,15 @@ For development environment configuration please refer to [project docs](../demo | --- | --- | | -h or --help | show the help | | -sd or --skipDemo | skip the demo folder clean | + +# npm-check-bundles.sh + +***npm-check-bundles.sh*** check the bundles in the package npm are present + +## Options + +| Option | Description | +| --- | --- | +| -h or --help | show the help | +| -r or --registry | against which register you want do this check | +| -v or --version | the version of the components to check | diff --git a/scripts/npm-check-bundles.sh b/scripts/npm-check-bundles.sh new file mode 100755 index 0000000000..ced47e5f66 --- /dev/null +++ b/scripts/npm-check-bundles.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +eval VERSION="" + +eval projects=( "ng2-alfresco-core" + "ng2-alfresco-datatable" + "ng2-activiti-diagrams" + "ng2-activiti-analytics" + "ng2-activiti-form" + "ng2-activiti-tasklist" + "ng2-activiti-processlist" + "ng2-alfresco-documentlist" + "ng2-alfresco-login" + "ng2-alfresco-search" + "ng2-alfresco-social" + "ng2-alfresco-tag" + "ng2-alfresco-social" + "ng2-alfresco-upload" + "ng2-alfresco-viewer" + "ng2-alfresco-webscript" + "ng2-alfresco-userinfo" ) + +show_help() { + echo "Usage: npm-check-bundles.sh" + echo "-r or -registry to check -r 'http://npm.local.me:8080/' " + echo "-v or -version to check -v 1.4.0 " + echo "" +} + +change_registry() { + echo $1 + npm set registry $1 +} + +set_npm_registry() { + npm set registry https://registry.npmjs.org/ +} + +version() { + VERSION=$1 +} + +error_out() { + printf '\033[%sm%s\033[m\n' "$@" + # usage color "31;5" "string" + # 0 default + # 5 blink, 1 strong, 4 underlined + # fg: 31 red, 32 green, 33 yellow, 34 blue, 35 purple, 36 cyan, 37 white + # bg: 40 black, 41 red, 44 blue, 45 purple + } + +while [[ $1 == -* ]]; do + case "$1" in + -h|--help|-\?) show_help; exit 0;; + -r) change_registry $2; shift 2;; + -v|--version) version $2; shift 2;; + -*) echo "invalid option: $1" 1>&2; show_help; exit 1;; + esac +done + +rm -rf temp +mkdir temp +cd temp + +for PACKAGE in ${projects[@]} +do + mkdir $PACKAGE + cd $PACKAGE + npm pack $PACKAGE@$VERSION + tar zxf $PACKAGE-$VERSION.tgz + if [ ! -f package/bundles/$PACKAGE.js ]; then + error_out '31;1' "$PACKAGE bundles not found!" >&2 + cd $DIR + rm -rf temp + exit 1 + else + echo "bundles ok!" + fi + cd .. +done + +cd $DIR +rm -rf temp + +set_npm_registry +