diff --git a/HOW_TO_RELEASE.md b/HOW_TO_RELEASE.md index d21c823..cca45a5 100644 --- a/HOW_TO_RELEASE.md +++ b/HOW_TO_RELEASE.md @@ -1,9 +1,9 @@ -1. Update version in package.json - * Use semantic versioning "X.Y.Z" -2. Re-build project (js/css bundling and minification in the ./dist folder) -3. Commit & push to develop -4. Merge develop to master -5. Create tag & release at https://github.com/gnpis/trait-ontology-widget/releases/new +Starting from develop (with all fixes, features etc. already merged and tested) + +0. Make sure you have updated the built bundle (in the ./dist folder) running `./build.sh` +1. Merge develop into master +2. Update project version using `npm version [major|minor|patch]` (will also commit and create a tag) +3. Release at https://github.com/gnpis/trait-ontology-widget/releases/new * Use the version in package.json as the release name & tag name * Add changelogs in release description -6. Re-deploy JSS & CSS were used (ex: https://urgi.versailles.inra.fr/files/ephesis/trait-ontology/widget-v2/) +4. Re-deploy JSS & CSS were used (ex: https://urgi.versailles.inra.fr/files/ephesis/trait-ontology/widget-v2/) diff --git a/build.sh b/build.sh index 957c0f2..3e1397f 100755 --- a/build.sh +++ b/build.sh @@ -2,6 +2,9 @@ set -e SOURCE_FOLDER="./src" +JS_SOURCE=${SOURCE_FOLDER}"/js/main.js" +LESS_SOURCE="${SOURCE_FOLDER}/less/cropOntologyWidget.less" + BUILD_FOLDER="./dist" MODULES="./node_modules" @@ -10,44 +13,68 @@ MODULES="./node_modules" exit 1; } -build() { - [ -d "${BUILD_FOLDER}" ] && rm -rf "${BUILD_FOLDER}"/* - mkdir -p "${BUILD_FOLDER}" +build_module() { + # Prepare NPM module to be imported in GPDS + MODULE_FOLDER="${BUILD_FOLDER}/module" + mkdir -p "${MODULE_FOLDER}" + DEST_MODULE="${MODULE_FOLDER}/cropOntologyWidget.module" + + echo "NPM module:" + + # JS (export widget for ES6 import) + echo -e "[JS]\t ${JS_SOURCE} => ${DEST_MODULE}.js " + "${MODULES}/browserify/bin/cmd.js" "${JS_SOURCE}" -t babelify --debug -o "${DEST_MODULE}.js" -s CropOntologyWidget - JS_FILES=${SOURCE_FOLDER}"/js/main.js" - LESS_FILES="$(ls ${SOURCE_FOLDER}/less/*.less)" + # CSS + echo -e "[CSS]\t ${LESS_SOURCE} => ${DEST_MODULE}.css " + cp "${DEST_FILE}.css" "${DEST_MODULE}.css" + # Style images + cp ${MODULES}/jstree/dist/themes/default/*.{png,gif} "${MODULE_FOLDER}" + + echo "" +} + +build_bundle() { # Run browserify => Bundle widget and its dependencies into one file echo "Bundling:" DEST_FILE="${BUILD_FOLDER}/cropOntologyWidget" - echo -ne "[JS]\t" - echo " ${JS_FILES} => ${DEST_FILE}.js " - "${MODULES}/browserify/bin/cmd.js" "${JS_FILES}" -t babelify --debug -o "${DEST_FILE}.js" & + echo -e "[JS]\t ${JS_SOURCE} => ${DEST_FILE}.js " + "${MODULES}/browserify/bin/cmd.js" "${JS_SOURCE}" -t babelify --debug -o "${DEST_FILE}.js" & # the '--debug' option adds source mapping for easier debugging in web inspector - echo -ne "[CSS]\t" - echo " ${LESS_FILES} => ${DEST_FILE}.css " - #"${MODULES}/npm-css/bin/npm-css" "${LESS_FILES}" -o "${DEST_FILE}.css" - "${MODULES}/less/bin/lessc" "${LESS_FILES}" "${DEST_FILE}.css" & - wait + echo -e "[CSS]\t ${LESS_SOURCE} => ${DEST_FILE}.css " + "${MODULES}/less/bin/lessc" "${LESS_SOURCE}" "${DEST_FILE}.css" & echo "" + wait +} +build_minify() { # Run uglify => Reduce file size echo "Minifying:" DEST_MIN_FILE="${BUILD_FOLDER}/cropOntologyWidget.min" - echo -ne "[JS]\t" - echo " ${DEST_FILE}.js => ${DEST_MIN_FILE}.js " + echo -e "[JS]\t ${DEST_FILE}.js => ${DEST_MIN_FILE}.js " "${MODULES}/.bin/uglifyjs" "${DEST_FILE}.js" -o "${DEST_MIN_FILE}.js" & - echo -ne "[CSS]\t" - echo " ${DEST_FILE}.css => ${DEST_MIN_FILE}.css " + echo -e "[CSS]\t ${DEST_FILE}.css => ${DEST_MIN_FILE}.css " "${MODULES}/.bin/cleancss" "${DEST_FILE}.css" -o "${DEST_MIN_FILE}.css" & wait echo "" +} + +build() { + [ -d "${BUILD_FOLDER}" ] && rm -rf "${BUILD_FOLDER}"/* + mkdir -p "${BUILD_FOLDER}" + + build_bundle + + build_minify + + build_module cp -R ./demo/* "${BUILD_FOLDER}" } diff --git a/demo/index.html b/demo/index.html index c6b25bf..4a686ea 100644 --- a/demo/index.html +++ b/demo/index.html @@ -19,9 +19,9 @@