From 057fd85a322bf9f0bdfe13bce8fae876da741aea Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Thu, 19 Dec 2019 21:27:31 +0100 Subject: [PATCH 1/4] Add gulp task to generate a standalone release zip from brouter repo --- .gitignore | 2 +- gulpfile.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++- package.json | 1 + yarn.lock | 5 +++++ 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3132bdf..349d0f9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,6 @@ nbproject/ /config.js /keys.js /dist -brouter-web.*.zip +brouter-web*.zip yarn-error.log package-lock.json diff --git a/gulpfile.js b/gulpfile.js index 20190fd..e6a479b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -26,6 +26,7 @@ var scanner = require('i18next-scanner'); var jsonConcat = require('gulp-json-concat'); var rename = require('gulp-rename'); var browserSync = require('browser-sync'); +var merge = require('merge-stream'); const server = browserSync.create(); @@ -73,6 +74,7 @@ var paths = { 'layers/config/geometry.js' ], layersConfigDestName: 'layersConf.js', + zip: ['dist/**', 'index.html', 'config.template.js', 'keys.template.js'], dest: 'dist', destName: 'brouter-web' }; @@ -336,16 +338,75 @@ gulp.task( cb(); }) ); + gulp.task('release:zip', function() { gutil.log(gutil.colors.green('Build brouter-web.' + nextVersion + '.zip')); return gulp - .src(['dist/**', 'index.html', 'config.template.js', 'keys.template.js'], { + .src(paths.zip, { base: '.' }) .pipe(zip('brouter-web.' + nextVersion + '.zip')) .pipe(gulp.dest('.')); }); +gulp.task('release:zip_standalone', function() { + var version = pkg.version; + var destName = 'brouter-web-standalone.' + version + '.zip'; + + gutil.log(gutil.colors.green('Build ' + destName)); + + var brouterWeb = gulp + .src(paths.zip, { + base: '.' + }) + .pipe( + rename(function(path) { + path.dirname = 'brouter-web/' + path.dirname; + }) + ); + + var serverRoot = gulp + .src( + [ + 'misc/readmes/profile_developers_guide.txt', + 'brouter-server/target/brouter-server-*-jar-with-dependencies.jar' + ], + { + cwd: path.join(process.cwd(), '../brouter') + } + ) + .pipe( + rename(function(path) { + if (path.basename.startsWith('brouter-server-')) { + path.basename = 'brouter'; + } + }) + ); + + var serverProfiles = gulp.src( + [ + 'profiles2/**', + '!profiles2/all.brf', + '!profiles2/car-eco-suspect_scan.brf', + '!profiles2/car-traffic_analysis.brf', + '!profiles2/softaccess.brf' + ], + { + cwd: path.join(process.cwd(), '../brouter/misc/'), + base: '../brouter/misc/' + } + ); + + var serverScripts = gulp.src(['standalone/**'], { + cwd: path.join(process.cwd(), '../brouter/misc/scripts/'), + base: '../brouter/misc/scripts/' + }); + + return merge(brouterWeb, serverRoot, serverProfiles, serverScripts) + .pipe(zip(destName)) + .pipe(gulp.dest('.')); +}); + gulp.task('release:publish', function() { return gulp.src('./brouter-web.' + nextVersion + '.zip').pipe( release({ diff --git a/package.json b/package.json index d6f4263..80205e3 100644 --- a/package.json +++ b/package.json @@ -105,6 +105,7 @@ "gulp-zip": "^4.0.0", "husky": "^2.3.0", "i18next-scanner": "^2.9.1", + "merge-stream": "^2.0.0", "node-fetch": "^2.3.0", "npmfiles": "^0.1.1", "prettier": "^1.17.1", diff --git a/yarn.lock b/yarn.lock index 7a3b170..7ab0983 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5278,6 +5278,11 @@ merge-stream@^1.0.0: dependencies: readable-stream "^2.0.1" +merge-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" + integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== + micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" From 7d0a4db059301d3b60bd21a64e72d71bb94e70b7 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Fri, 20 Dec 2019 19:27:22 +0100 Subject: [PATCH 2/4] Add npm script to build brouter and call standalone task --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 80205e3..bdab681 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "test": "gulp", "lint": "eslint .", "prettier": "prettier --write '**/*'", - "serve": "gulp serve watch" + "serve": "gulp serve watch", + "standalone": "mvn clean install -f ../brouter -pl '!brouter-routing-app' -Dmaven.javadoc.skip=true && ../brouter/misc/scripts/generate_profile_variants.sh && gulp release:zip_standalone" }, "husky": { "hooks": { From 5cc99949fd34e9b9466fe36b6af4d6d339cc6fa9 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Fri, 20 Dec 2019 19:28:19 +0100 Subject: [PATCH 3/4] Merge config profiles as we now include all in standalone zip --- config.template.js | 55 ++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/config.template.js b/config.template.js index c6dc1d2..4cead99 100644 --- a/config.template.js +++ b/config.template.js @@ -15,45 +15,11 @@ if (hostname.endsWith('brouter.de')) { // online service (brouter.de) configuration - BR.conf.profiles = [ - 'trekking', - 'fastbike', - 'car-eco', - 'car-fast', - 'safety', - 'shortest', - 'trekking-ignore-cr', - 'trekking-steep', - 'trekking-noferries', - 'trekking-nosteps', - 'moped', - 'rail', - 'river', - 'vm-forum-liegerad-schnell', - 'vm-forum-velomobil-schnell', - 'fastbike-lowtraffic', - 'fastbike-asia-pacific', - 'hiking-beta' - ]; - BR.conf.host = origin; BR.conf.profilesUrl = origin + '/brouter/profiles2/'; } else { // desktop configuration - BR.conf.profiles = [ - 'trekking', - 'fastbike', - 'car-eco', - 'car-fast', - 'shortest', - 'moped', - 'vm-forum-liegerad-schnell', - 'vm-forum-velomobil-schnell', - 'fastbike-lowtraffic', - 'fastbike-asia-pacific' - ]; - BR.conf.host = 'http://0.0.0.0:17777'; // Pre-loading selected profile disabled locally. Needs brouter-web to run on a @@ -64,6 +30,27 @@ //BR.conf.profilesUrl = 'file://YOUR_PATH_TO/profiles2/'; } + BR.conf.profiles = [ + 'trekking', + 'fastbike', + 'car-eco', + 'car-fast', + 'safety', + 'shortest', + 'trekking-ignore-cr', + 'trekking-steep', + 'trekking-noferries', + 'trekking-nosteps', + 'moped', + 'rail', + 'river', + 'vm-forum-liegerad-schnell', + 'vm-forum-velomobil-schnell', + 'fastbike-lowtraffic', + 'fastbike-asia-pacific', + 'hiking-beta' + ]; + // Removes default base layers when 'true'. Useful for only having custom layers (see below). BR.conf.clearBaseLayers = false; From 12c58b70fa0dcc9befb96c6072b751acd3476cf0 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Mon, 30 Dec 2019 20:52:55 +0100 Subject: [PATCH 4/4] Add standalone run.sh and configure localhost --- config.template.js | 4 ++-- gulpfile.js | 4 +++- resources/standalone/run.sh | 15 +++++++++++++++ resources/standalone/segments4/.gitignore | 4 ++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 resources/standalone/run.sh create mode 100644 resources/standalone/segments4/.gitignore diff --git a/config.template.js b/config.template.js index 4cead99..18510c0 100644 --- a/config.template.js +++ b/config.template.js @@ -20,13 +20,13 @@ } else { // desktop configuration - BR.conf.host = 'http://0.0.0.0:17777'; + BR.conf.host = 'http://localhost:17777'; // Pre-loading selected profile disabled locally. Needs brouter-web to run on a // local web server with the profiles in a subdirectory or allowing file access // in the Browser (security!), see // https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally - //BR.conf.profilesUrl = 'http://localhost:8000/profiles2/'; + BR.conf.profilesUrl = 'http://localhost:8000/profiles2/'; //BR.conf.profilesUrl = 'file://YOUR_PATH_TO/profiles2/'; } diff --git a/gulpfile.js b/gulpfile.js index e6a479b..c7bced2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -365,6 +365,8 @@ gulp.task('release:zip_standalone', function() { }) ); + var root = gulp.src(['resources/standalone/run.sh', 'resources/standalone/segments4']); + var serverRoot = gulp .src( [ @@ -402,7 +404,7 @@ gulp.task('release:zip_standalone', function() { base: '../brouter/misc/scripts/' }); - return merge(brouterWeb, serverRoot, serverProfiles, serverScripts) + return merge(brouterWeb, root, serverRoot, serverProfiles, serverScripts) .pipe(zip(destName)) .pipe(gulp.dest('.')); }); diff --git a/resources/standalone/run.sh b/resources/standalone/run.sh new file mode 100644 index 0000000..8938b1c --- /dev/null +++ b/resources/standalone/run.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +cd "$(dirname "$0")" + +# start script for standalone zip + +# start BRouter server on localhost +x-terminal-emulator -T "BRouter server" -e "./standalone/local.sh" + +# start HTTP server for current directory (for brouter-web and profiles) +#x-terminal-emulator -T "BRouter-Web HTTP server" -e "python -m SimpleHTTPServer 8000" +x-terminal-emulator -T "BRouter-Web HTTP server" -e "python3 -m http.server 8000 --bind localhost" + +# open BRouter-Web in default browser +xdg-open http://localhost:8000/brouter-web/ diff --git a/resources/standalone/segments4/.gitignore b/resources/standalone/segments4/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/resources/standalone/segments4/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore