Skip to content

Commit

Permalink
auto create versions file from all installed modules
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed May 5, 2018
1 parent 88af93c commit 574071b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 26 deletions.
10 changes: 5 additions & 5 deletions addon_files/node-red/node-red
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ case "$1" in
source $ADDON_DIR/versions
echo "Info: <b>Node-RED CCU Addon</b><br>"
echo "Info: <table><tr><td>Node.js</td><td>$NODE_VERSION</td></tr>"
echo "Info: <tr><td>npm</td><td>$NPM_VERSION</td></tr>"
echo "Info: <tr><td>Node-RED</td><td>$RED_VERSION</td></tr>"
echo "Info: <tr><td>Node-RED Dashboard</td><td>$DASHBOARD_VERSION</td></tr>"
echo "Info: <tr><td>node-red-contrib-ccu</td><td>$RED_CCU_VERSION</td></tr></table>"
echo "Info: <tr><td>npm</td><td>$VERSION_npm</td></tr>"
echo "Info: <tr><td>Node-RED</td><td>$VERSION_nodered</td></tr>"
echo "Info: <tr><td>Node-RED Dashboard</td><td>$VERSION_nodereddashboard</td></tr>"
echo "Info: <tr><td>node-red-contrib-ccu</td><td>$VERSION_noderedcontribccu</td></tr></table>"
echo "Info: <ul><li><a href="https://github.com/hobbyquaker/ccu-addon-node-red">ccu-addon-node-red on Github</a></li></ul>"
echo "Name: Node-RED"
echo "Version: $ADDON_VERSION"
echo "Version: $VERSION_ADDON"
echo "Update: /addons/check_update_node_red.cgi"
echo "Operations: restart uninstall"
;;
Expand Down
71 changes: 50 additions & 21 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,61 @@ sed "s/util\.log/console.log/g" $ADDON_TMP/node-red/lib/node_modules/node-red/re
cd $BUILD_DIR


echo "creating version file"
ADDON_VERSION=`jq -r '.version' package.json`
NPM_VERSION=`jq -r '.version' $ADDON_TMP/node-red/lib/node_modules/npm/package.json`
RED_VERSION=`jq -r '.version' $ADDON_TMP/node-red/lib/node_modules/node-red/package.json`
DASHBOARD_VERSION=`jq -r '.version' $ADDON_TMP/node-red/lib/node_modules/node-red-dashboard/package.json`
RED_CCU_VERSION=`jq -r '.version' $ADDON_TMP/node-red/lib/node_modules/node-red-contrib-ccu/package.json`
echo "creating version files"
MODULES_DIR=$ADDON_TMP/node-red/lib/node_modules
VERSION_FILE=$ADDON_TMP/node-red/versions
VERSION_ADDON=`jq -r '.version' package.json`

cat >$ADDON_TMP/node-red/versions <<EOL
export ADDON_VERSION=$ADDON_VERSION
cat > $VERSION_FILE <<EOL
export NODE_VERSION=$NODE_VERSION
export NPM_VERSION=$NPM_VERSION
export RED_VERSION=$RED_VERSION
export DASHBOARD_VERSION=$DASHBOARD_VERSION
export RED_CCU_VERSION=$RED_CCU_VERSION
export VERSION_ADDON=$VERSION_ADDON
EOL


echo "creating changelog file"
cat >CHANGELOG.md <<EOL
### Module Versions
Module | Version
------ | -------
EOL

links() {
case $1 in
'npm')
URL=https://github.com/npm/npm/releases
;;
'node-red')
URL=https://nodered.org/
;;
'node-red-dashboard')
URL=https://github.com/node-red/node-red-dashboard/releases
;;
'node-red-contrib-ccu')
URL=https://github.com/hobbyquaker/node-red-contrib-ccu
;;
*)
URL=
esac

echo "export VERSION_`echo $1 | sed -e 's/-//g'`=$2" >> $VERSION_FILE

if [ $URL ]; then
echo "[$URL]($1) | $2" >> CHANGELOG.md
else
echo "$1 | $2" >> CHANGELOG.md
fi
}

for DIR in $(find $MODULES_DIR/ -type d -maxdepth 1 -not -name "node_modules" -not -name ".bin" -exec basename {} \; | sort -t '\0' -n)
do
VERSION=$(jq -r '.version' $MODULES_DIR/$DIR/package.json)
links $DIR $VERSION
done

* Node.js $NODE_VERSION
* npm $NPM_VERSION
* Node-RED $RED_VERSION
* Node-RED Dashboard $DASHBOARD_VERSION
* node-red-contrib-ccu $RED_CCU_VERSION
RED_VERSION=`jq -r '.version' $ADDON_TMP/node-red/lib/node_modules/node-red/package.json`
DASHBOARD_VERSION=`jq -r '.version' $ADDON_TMP/node-red/lib/node_modules/node-red-dashboard/package.json`
RED_CCU_VERSION=`jq -r '.version' $ADDON_TMP/node-red/lib/node_modules/node-red-contrib-ccu/package.json`


echo "creating changelog file"
cat >>CHANGELOG.md <<EOL
### Changelog
Expand All @@ -78,7 +107,7 @@ git log `git describe --tags --abbrev=0`..HEAD --pretty=format:'* %h @%an %s' >>


echo "compressing addon package $ADDON_FILE ..."
ADDON_FILE=ccu-addon-node-red-$ADDON_VERSION.tar.gz
ADDON_FILE=ccu-addon-node-red-$VERSION_ADDON.tar.gz
mkdir $BUILD_DIR/dist 2> /dev/null
cd $ADDON_TMP
tar --exclude=.DS_Store -czf $BUILD_DIR/dist/$ADDON_FILE *
Expand Down

0 comments on commit 574071b

Please sign in to comment.