Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Simplify the 'how to release' documentation.
  Generate a NPM module in dist folder when running build.
  Export global only when available.
  • Loading branch information
gcornut committed Jan 9, 2019
2 parents adc1832 + 1803755 commit b23bacc
Show file tree
Hide file tree
Showing 16 changed files with 20,777 additions and 399 deletions.
14 changes: 7 additions & 7 deletions HOW_TO_RELEASE.md
Original file line number Diff line number Diff line change
@@ -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/)
61 changes: 44 additions & 17 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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}"
}
Expand Down
4 changes: 2 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<script type="text/javascript">
var widget = new CropOntologyWidget("#trait-ontology-widget", {
// Breeding API server
//"breedingAPIEndpoint": "https://urgi.versailles.inra.fr/ws/webresources/brapi/v1/",
"breedingAPIEndpoint": "https://urgi.versailles.inra.fr/ws/webresources/brapi/v1/",
//"breedingAPIEndpoint": "http://urgi.versailles.inra.fr/gnpis-core-srv/brapi/v1/",
"breedingAPIEndpoint": "http://urgi148:8080/gnpis-core-srv/brapi/v1/",
//"breedingAPIEndpoint": "http://urgi148:8080/gnpis-core-srv/brapi/v1/",
// options
"showCheckBoxes": true, "useSearchField": true
});
Expand Down
4 changes: 2 additions & 2 deletions dist/cropOntologyWidget.css
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cropOntologyWidget.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cropOntologyWidget.min.css
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cropOntologyWidget.min.js
Git LFS file not shown
Binary file added dist/module/32px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dist/module/40px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b23bacc

Please sign in to comment.