diff --git a/.gitignore b/.gitignore index 78a09cc0fddf6a5df8b83f762a55c96a25f888bd..5bd2d8af3276d30225062d5cddfe237c0578176d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ # dependencies /node_modules /src/date_revision.ts +/ngsw-config.json # IDEs and editors /.idea diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0ff5191b950de080294be0f3e7535a68cb136e46..ed146e000f40c2e3b3874a3c1241896787708e44 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,7 +91,7 @@ build: paths: - dist/ script: - - npm run build -- --base-href=/cassiopee/$CI_COMMIT_REF_NAME/ + - npm run build clean-stale-branches: stage: clean-stale-branches diff --git a/ngsw-config.json b/ngsw-config-template.json similarity index 100% rename from ngsw-config.json rename to ngsw-config-template.json diff --git a/package.json b/package.json index 1a21cb21d20dcf170515f86947fc56fa2eb1a9a3..4624a5f6faaa8a5e9f2d37644f109a70fbc378a8 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "mkdocs": "bash scripts/prepare_mkdocs.sh; cd build; python3 -m mkdocs build -f mkdocs-fr.yml && python3 -m mkdocs build -f mkdocs-en.yml && cd .. && node scripts/mkdocs-postprocess.js", "mkdocs2pdf": "node scripts/extract-nghyd-version.js build/cassiopee_version.tex && python3 scripts/mkdocs2pdf.py && node scripts/mkdocs2pdf-postprocess.js", "clean": "rm -rf build dist release src/date_revision.ts src/assets/docs", - "preprocess": "mkdir -p build; node scripts/preprocessors.js", + "preprocess": "mkdir -p build; node scripts/preprocessors.js; npm run service-worker-version", "start": "npm run preprocess && npm run mkdocs && npm run ng serve -- --host 0.0.0.0 --poll 5000", "build-no-pdf": "npm run preprocess && npm run mkdocs && npm run ng build -- --configuration production", "build": "npm run preprocess && npm run mkdocs && npm run ng build -- --configuration production && npm run mkdocs2pdf", @@ -32,8 +32,9 @@ "release-all": "node scripts/clean_release.js && npm run build-no-pdf && npm run update-dist-index-mimetypes && \"node_modules/.bin/electron-builder\" && \"node_modules/.bin/electron-builder\" --mac && \"node_modules/.bin/electron-builder\" --win", "compodoc": "node \"node_modules/@compodoc/compodoc/bin/index-cli.js\" -p src/tsconfig.app.json -s --language fr-FR -d compodoc-fr", "viz": "tsviz -recursive src/ nghyd_class_diagram.png", - "webapp-nocompile" : "\"node_modules/.bin/http-server\" dist", - "webapp" : "npm run build-no-pdf && npm run webapp-nocompile" + "webapp-nocompile": "\"node_modules/.bin/http-server\" dist", + "webapp": "npm run build-no-pdf && npm run webapp-nocompile", + "service-worker-version": "./scripts/update-service-worker-config.sh" }, "private": true, "dependencies": { diff --git a/scripts/deploy-new-stable-version.sh b/scripts/deploy-new-stable-version.sh index 92733055ec7e96cab769b35875b8710919a7e7cb..18a5f53fa838f07309e5bb9b776f44906fae25e5 100755 --- a/scripts/deploy-new-stable-version.sh +++ b/scripts/deploy-new-stable-version.sh @@ -19,6 +19,9 @@ then exit 1 fi +# Angular service worker configuration file +NGSW_CONF=ngsw-config.json + # 0. changelog read -p "Avez-vous rempli jalhyd_branch, et les CHANGELOG de JaLHyd et NgHyd pour la version $VERSION ? (o/N) " -n 1 -r echo @@ -28,8 +31,8 @@ then exit 2 fi -if [[ ! -f ngsw-config.json ]]; then - echo "Fichier de configuration du service worker ngsw-config.json non trouvé" >&2 +if [[ ! -f $NGSW_CONF ]]; then + echo "Fichier de configuration du service worker $NGSW_CONF non trouvé" >&2 exit 1 fi @@ -73,11 +76,7 @@ git push --tags --force echo "BUILDING NGHYD" cd .. -# 2.1 service worker configuration (application version) - -sed -i "/\"version\": \"/s/\": \".*/\": \"$VERSION\"/" ngsw-config.json - -# 2.2 update Git repository +# 2.1 update Git repository git checkout master git pull --rebase npm install @@ -87,7 +86,7 @@ then git commit -a -m "verify dependencies (npm install) before deploying version $VERSION" fi -# 2.3 version in package.* +# 2.2 version in package.* npm version "$VERSION" --allow-same-version --git-tag-version=false if [ ! -z "$(git status --untracked-files=no --porcelain)" ] then @@ -95,13 +94,13 @@ then git commit -a -m "update package.* to version $VERSION" fi -# 2.4 tags +# 2.3 tags echo "setting tags to $VERSION version" git tag -fa stable -m "stable version" sleep 1 git tag -fa "$VERSION" -m "release version $VERSION" -# 2.5 push code, push tags +# 2.4 push code, push tags git push git push --tags --force diff --git a/scripts/deploy-version.sh b/scripts/deploy-version.sh index 4f05359f918d7669d96fdac20650d999cb946951..4221e281bf9a84801c54b96417c6fb24955543e7 100755 --- a/scripts/deploy-version.sh +++ b/scripts/deploy-version.sh @@ -15,19 +15,43 @@ LOGIN="$2" HOST="$3" DIR="$4" +LOCAL_DIR=dist + +function display_local_href() +{ + echo "base href in local index.html :" + grep "\<base" $LOCAL_DIR/index.html +} + +function display_remote_href() +{ + local dir=$1 + echo "base href in deployed index.html (host=$HOST) :" + ssh $LOGIN@$HOST "grep \<base $dir/index.html" +} + echo "$(basename $0): deploying version $VERSION in $LOGIN@$HOST:$DIR" if [[ $VERSION == "prod" || $VERSION == "prod-devel" ]]; then + display_local_href + + # Modification du dossier base href -> / + echo "updating index.html base href to /" + sed -i '/<base/s/href="[^"]*"/href="\/"/' $LOCAL_DIR/index.html + # Copie de la branche production - rsync -a --delete --exclude=cassiopee-releases -e "ssh -o StrictHostKeyChecking=no" dist/ ${LOGIN}@${HOST}:${DIR}/ - # Modification du dossier base href - echo "updating index.html" - if [[ $VERSION == "prod" ]]; then - ssh $LOGIN@$HOST "sed -i 's:/cassiopee/stable/:/:g' $DIR/index.html" - else - ssh $LOGIN@$HOST "sed -i 's:/cassiopee/devel/:/:g' $DIR/index.html" - fi + rsync -a --delete --exclude=cassiopee-releases -e "ssh -o StrictHostKeyChecking=no" $LOCAL_DIR/ ${LOGIN}@${HOST}:${DIR}/ + + display_remote_href $DIR else + display_local_href + + # Modification du dossier base href -> /cassiopee/version/ + echo "updating index.html base href to /cassiopee/$VERSION/" + sed -i "/<base/s/href=\"[^\"]*\"/href=\"\/cassiopee\/$VERSION\/\"/" $LOCAL_DIR/index.html + # Copie de la branche / du tag - rsync -a --delete --exclude=cassiopee-releases -e "ssh -o StrictHostKeyChecking=no" "dist/" "$LOGIN@$HOST:$DIR/$VERSION" + rsync -a --delete --exclude=cassiopee-releases -e "ssh -o StrictHostKeyChecking=no" $LOCAL_DIR/ "$LOGIN@$HOST:$DIR/$VERSION" + + display_remote_href $DIR/$VERSION fi diff --git a/scripts/update-service-worker-config.sh b/scripts/update-service-worker-config.sh new file mode 100755 index 0000000000000000000000000000000000000000..aebfee18394b8cec1cb1f364ad7837b245f4d41e --- /dev/null +++ b/scripts/update-service-worker-config.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# update ngsw-config.json from template and "git describe" output + +# error on unset variables +set -o nounset + +# exit on error +set -o errexit + +# Angular service worker configuration file +NGSW_CONF=ngsw-config.json + +# Angular service worker configuration template +NGSW_CONF_TMPL=ngsw-config-template.json + +echo "updating version in Angular service worker configuration" >&2 + +VERSION=$(git describe) + +cp $NGSW_CONF_TMPL $NGSW_CONF + +sed -i "/\"version\": \"/s/\": \".*/\": \"$VERSION\"/" $NGSW_CONF +# check +if [[ -z $(grep version $NGSW_CONF | grep $VERSION) ]]; then + echo "error updating version in service worker configuration file $NGSW_CONF" >&2 + exit 1 +fi diff --git a/src/manifest.webmanifest b/src/manifest.webmanifest index 4d0eb567531bbbf0bd9842b500a40f5598aa3ce1..996eabf17c23c3cdc6e967fa128322766dc6ff70 100644 --- a/src/manifest.webmanifest +++ b/src/manifest.webmanifest @@ -11,49 +11,49 @@ "src": "assets/icons/favicon-72x72.png", "sizes": "72x72", "type": "image/png", - "purpose": "maskable any" + "purpose": "any" }, { "src": "assets/icons/favicon-96x96.png", "sizes": "96x96", "type": "image/png", - "purpose": "maskable any" + "purpose": "any" }, { "src": "assets/icons/favicon-128x128.png", "sizes": "128x128", "type": "image/png", - "purpose": "maskable any" + "purpose": "any" }, { "src": "assets/icons/favicon-144x144.png", "sizes": "144x144", "type": "image/png", - "purpose": "maskable any" + "purpose": "any" }, { "src": "assets/icons/favicon-152x152.png", "sizes": "152x152", "type": "image/png", - "purpose": "maskable any" + "purpose": "any" }, { "src": "assets/icons/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png", - "purpose": "maskable any" + "purpose": "any" }, { "src": "assets/icons/favicon-384x384.png", "sizes": "384x384", "type": "image/png", - "purpose": "maskable any" + "purpose": "any" }, { "src": "assets/icons/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png", - "purpose": "maskable any" + "purpose": "any" } ] }