From 7d684c85aac0d6fc83f2559f668d41ce64d01b9b Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Thu, 17 Jan 2019 23:46:38 +0000 Subject: [PATCH 1/5] swapped manifest file and added bumper --- gulp/backbone.js | 14 ++- gulp/build.js | 8 +- package-lock.json | 208 ++++++++++++++++++++++++------------------ package.json | 1 + src/service-worker.js | 6 +- src/site.webmanifest | 46 ++++++++++ 6 files changed, 183 insertions(+), 100 deletions(-) create mode 100644 src/site.webmanifest diff --git a/gulp/backbone.js b/gulp/backbone.js index aa61ca2..bda5857 100644 --- a/gulp/backbone.js +++ b/gulp/backbone.js @@ -9,6 +9,7 @@ const sourcemaps = require('gulp-sourcemaps'); const gutil = require('gulp-util'); const rename = require('gulp-rename'); const stripDebug = require('gulp-strip-debug'); +const bump = require('gulp-bump'); gulp.task('bundleBackbone', function () { // set up the browserify instance on a task basis @@ -20,7 +21,7 @@ gulp.task('bundleBackbone', function () { return b.bundle() .pipe(source('app.js')) .pipe(buffer()) - // .pipe(stripDebug()) + // .pipe(stripDebug()) .pipe(rename('bundle.js')) .pipe(sourcemaps.init({ 'loadMaps': true })) @@ -31,7 +32,14 @@ gulp.task('bundleBackbone', function () { .pipe(gulp.dest('./live/js')); }); -gulp.task('buildBackbone', ['bundleBackbone'], function() { - gulp.watch('src/js/**/*.js', ['bundleBackbone']); +gulp.task('bump', function() { + gulp.src('src/service-worker.js') + .pipe(bump({ 'key': 'version' })) + .pipe(gulp.dest('src')) + .pipe(gulp.dest('live')); +}); + +gulp.task('buildBackbone', ['bump', 'bundleBackbone'], function() { + gulp.watch('src/js/**/*.js', ['bump', 'bundleBackbone']); }); diff --git a/gulp/build.js b/gulp/build.js index 3ccd5f2..94fe0a1 100644 --- a/gulp/build.js +++ b/gulp/build.js @@ -31,7 +31,8 @@ gulp.task('styles', function() { gulp.task('copy', function() { gulp.src(['src/img/**/*']).pipe(gulp.dest('live/img')); - gulp.src(['src/browserconfig.xml', 'src/manifest.json', 'src/service-worker.js', 'src/bridger.js']).pipe(gulp.dest('live')); + // gulp.src(['src/browserconfig.xml', 'src/site.webmanifest', 'src/service-worker.js', 'src/bridger.js']).pipe(gulp.dest('live')); + gulp.src(['src/browserconfig.xml', 'src/service-worker.js', 'src/bridger.js']).pipe(gulp.dest('live')); gulp.src(['src/index.html']).pipe(gulp.dest('live')); }); @@ -55,13 +56,13 @@ gulp.task('vendor', function() { .pipe(concat('vendor.js')) /* .pipe(uglify({ 'mangle': false }))*/ - .pipe(gulp.dest(`live/js`)); + .pipe(gulp.dest('live/js')); }); gulp.task('fonts', function() { return gulp.src('src/fonts.list') .pipe(googleWebFonts(fontOptions)) - .pipe(gulp.dest(`live/fonts`)) + .pipe(gulp.dest('live/fonts')) ; }); @@ -70,7 +71,6 @@ gulp.task('gotham', function() { gulp.src(['fonts/GothamSSm-Black.otf', 'fonts/GothamSSm-Bold.otf', 'fonts/GothamSSm-Book.otf', 'fonts/GothamSSm-Light.otf', 'fonts/GothamSSm-Medium.otf']).pipe(gulp.dest('live/fonts')); }); - gulp.task('fujicons', function() { gulp.src(['fonts/fujicons.css']).pipe(gulp.dest('live/fonts')); gulp.src(['fonts/fujicons.ttf']).pipe(gulp.dest('live/fonts')); diff --git a/package-lock.json b/package-lock.json index 7fe5a7b..122885a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -154,6 +154,14 @@ "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=" }, + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "requires": { + "ansi-wrap": "^0.1.0" + } + }, "ansi-cyan": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz", @@ -200,8 +208,7 @@ "ansi-wrap": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", - "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", - "dev": true + "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=" }, "any-promise": { "version": "1.3.0", @@ -273,8 +280,7 @@ "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=" }, "array-differ": { "version": "1.0.0", @@ -296,8 +302,7 @@ "array-find-index": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", - "dev": true + "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=" }, "array-flatten": { "version": "1.1.1", @@ -390,6 +395,11 @@ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" + }, "ast-types": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.10.1.tgz", @@ -1676,8 +1686,7 @@ "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" }, "builtin-status-codes": { "version": "3.0.0", @@ -1690,6 +1699,15 @@ "integrity": "sha1-NVIZzWzxjb58Acx/0tznZc/cVJo=", "dev": true }, + "bump-regex": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/bump-regex/-/bump-regex-3.1.1.tgz", + "integrity": "sha512-NinFibU11G1ad/2Ji3J04lRC9mLpUGr3C0vtt4Yp049cDeW21NRkmUaZZc+snwlL6gE+Ja5cQfe/hf86Ahj+WQ==", + "requires": { + "semver": "^5.1.0", + "xtend": "^4.0.1" + } + }, "bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", @@ -1778,7 +1796,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", - "dev": true, "requires": { "camelcase": "^2.0.0", "map-obj": "^1.0.0" @@ -1787,8 +1804,7 @@ "camelcase": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true + "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=" } } }, @@ -2575,7 +2591,6 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", - "dev": true, "requires": { "array-find-index": "^1.0.1" } @@ -2658,8 +2673,7 @@ "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" }, "decode-uri-component": { "version": "0.2.0", @@ -3047,7 +3061,6 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", - "dev": true, "requires": { "is-arrayish": "^0.2.1" } @@ -4114,7 +4127,6 @@ "version": "0.0.9", "bundled": true, "dev": true, - "optional": true, "requires": { "inherits": "~2.0.0" } @@ -4139,8 +4151,7 @@ "buffer-shims": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "caseless": { "version": "0.12.0", @@ -4157,8 +4168,7 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "combined-stream": { "version": "1.0.5", @@ -4177,20 +4187,17 @@ "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "cryptiles": { "version": "2.0.5", "bundled": true, "dev": true, - "optional": true, "requires": { "boom": "2.x.x" } @@ -4263,8 +4270,7 @@ "extsprintf": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "forever-agent": { "version": "0.6.1", @@ -4387,7 +4393,6 @@ "version": "3.1.3", "bundled": true, "dev": true, - "optional": true, "requires": { "boom": "2.x.x", "cryptiles": "2.x.x", @@ -4435,7 +4440,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4449,8 +4453,7 @@ "isarray": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "isstream": { "version": "0.1.2", @@ -4665,8 +4668,7 @@ "process-nextick-args": { "version": "1.0.7", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "punycode": { "version": "1.4.1", @@ -4704,7 +4706,6 @@ "version": "2.2.9", "bundled": true, "dev": true, - "optional": true, "requires": { "buffer-shims": "~1.0.0", "core-util-is": "~1.0.0", @@ -4756,8 +4757,7 @@ "safe-buffer": { "version": "5.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "semver": { "version": "5.3.0", @@ -4781,7 +4781,6 @@ "version": "1.0.9", "bundled": true, "dev": true, - "optional": true, "requires": { "hoek": "2.x.x" } @@ -4815,7 +4814,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4826,7 +4824,6 @@ "version": "1.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.0.1" } @@ -4855,7 +4852,6 @@ "version": "2.2.1", "bundled": true, "dev": true, - "optional": true, "requires": { "block-stream": "*", "fstream": "^1.0.2", @@ -4911,8 +4907,7 @@ "util-deprecate": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "uuid": { "version": "3.0.1", @@ -5073,8 +5068,7 @@ "get-stdin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true + "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=" }, "get-uri": { "version": "2.0.1", @@ -5340,8 +5334,7 @@ "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" }, "graceful-readlink": { "version": "1.0.1", @@ -6301,6 +6294,53 @@ } } }, + "gulp-bump": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/gulp-bump/-/gulp-bump-3.1.3.tgz", + "integrity": "sha512-mhu6IvwMl2lHU2EUSkcgYG+Gd0Hwzn2B5ve4OXwaIg4SgmtVLTJ1graKD4t82ExhkU+TGoK/DHAdMJJ5isFe9g==", + "requires": { + "bump-regex": "^3.1.1", + "plugin-error": "^1.0.1", + "plugin-log": "^0.1.0", + "semver": "^5.3.0", + "through2": "^2.0.1" + }, + "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=" + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + }, + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "requires": { + "is-plain-object": "^2.0.4" + } + }, + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "requires": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + } + } + } + }, "gulp-cache": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gulp-cache/-/gulp-cache-1.0.1.tgz", @@ -6960,8 +7000,7 @@ "hosted-git-info": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", - "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", - "dev": true + "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==" }, "html-comment-regex": { "version": "1.1.1", @@ -7138,7 +7177,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, "requires": { "repeating": "^2.0.0" } @@ -7339,8 +7377,7 @@ "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" }, "is-binary-path": { "version": "1.0.1", @@ -7360,7 +7397,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "dev": true, "requires": { "builtin-modules": "^1.0.0" } @@ -7436,7 +7472,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "dev": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7530,7 +7565,6 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, "requires": { "isobject": "^3.0.1" }, @@ -7538,8 +7572,7 @@ "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" } } }, @@ -7627,8 +7660,7 @@ "is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" }, "is-windows": { "version": "1.0.1", @@ -7929,7 +7961,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, "requires": { "graceful-fs": "^4.1.2", "parse-json": "^2.2.0", @@ -7941,14 +7972,12 @@ "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" }, "strip-bom": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, "requires": { "is-utf8": "^0.2.0" } @@ -8512,7 +8541,6 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", - "dev": true, "requires": { "currently-unhandled": "^0.4.1", "signal-exit": "^3.0.0" @@ -8646,8 +8674,7 @@ "map-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true + "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=" }, "map-stream": { "version": "0.1.0", @@ -8721,7 +8748,6 @@ "version": "3.7.0", "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", - "dev": true, "requires": { "camelcase-keys": "^2.0.0", "decamelize": "^1.1.2", @@ -9618,7 +9644,6 @@ "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", - "dev": true, "requires": { "hosted-git-info": "^2.1.4", "is-builtin-module": "^1.0.0", @@ -9683,8 +9708,7 @@ "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, "o-stream": { "version": "0.2.2", @@ -10080,7 +10104,6 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "dev": true, "requires": { "error-ex": "^1.2.0" } @@ -10184,7 +10207,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, "requires": { "graceful-fs": "^4.1.2", "pify": "^2.0.0", @@ -10194,8 +10216,7 @@ "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" } } }, @@ -10321,6 +10342,26 @@ } } }, + "plugin-log": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/plugin-log/-/plugin-log-0.1.0.tgz", + "integrity": "sha1-hgSc9qsQgzOYqTHzaJy67nteEzM=", + "requires": { + "chalk": "^1.1.1", + "dateformat": "^1.0.11" + }, + "dependencies": { + "dateformat": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", + "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=", + "requires": { + "get-stdin": "^4.0.1", + "meow": "^3.3.0" + } + } + } + }, "pluralize": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", @@ -11672,7 +11713,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "dev": true, "requires": { "load-json-file": "^1.0.0", "normalize-package-data": "^2.3.2", @@ -11683,7 +11723,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "dev": true, "requires": { "find-up": "^1.0.0", "read-pkg": "^1.0.0" @@ -11693,7 +11732,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, "requires": { "path-exists": "^2.0.0", "pinkie-promise": "^2.0.0" @@ -11703,7 +11741,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, "requires": { "pinkie-promise": "^2.0.0" } @@ -11749,7 +11786,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", - "dev": true, "requires": { "indent-string": "^2.1.0", "strip-indent": "^1.0.1" @@ -11917,7 +11953,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", - "dev": true, "requires": { "is-finite": "^1.0.0" } @@ -12459,8 +12494,7 @@ "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, "sinon": { "version": "4.1.3", @@ -12690,7 +12724,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", - "dev": true, "requires": { "spdx-license-ids": "^1.0.2" } @@ -12698,14 +12731,12 @@ "spdx-expression-parse": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", - "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", - "dev": true + "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=" }, "spdx-license-ids": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz", - "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", - "dev": true + "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=" }, "split": { "version": "0.3.3", @@ -12988,7 +13019,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", - "dev": true, "requires": { "get-stdin": "^4.0.1" } @@ -13286,8 +13316,7 @@ "trim-newlines": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true + "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=" }, "trim-right": { "version": "1.0.1", @@ -13660,7 +13689,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", - "dev": true, "requires": { "spdx-correct": "~1.0.0", "spdx-expression-parse": "~1.0.0" diff --git a/package.json b/package.json index 68b5d7c..17f9f51 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "cors": "^2.8.4", "es6-promise": "^4.1.1", "express": "^4.16.2", + "gulp-bump": "^3.1.3", "jquery": "^3.2.1", "json-lzw": "^0.3.2", "log4js": "^2.4.1", diff --git a/src/service-worker.js b/src/service-worker.js index e533153..d05ec61 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -11,9 +11,9 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -const CACHE_VERSION = 7; -const dataCacheName = `traintimesData-v${CACHE_VERSION}`; -const cacheName = `traintimePWA-final-${CACHE_VERSION}`; +const CACHE_VERSION = { 'version': '0.0.10' }; +const dataCacheName = `traintimesData-v${CACHE_VERSION.version}`; +const cacheName = `traintimePWA-final-${CACHE_VERSION.version}`; const filesToCache = [ '/', '/index.html', diff --git a/src/site.webmanifest b/src/site.webmanifest new file mode 100644 index 0000000..30f8da3 --- /dev/null +++ b/src/site.webmanifest @@ -0,0 +1,46 @@ +{ + "name": "Train Times", + "short_name": "Train Times", + "icons": [ + { + "src": "/img/Icon-36.png", + "sizes": "36x36", + "type": "image/png" + }, + { + "src": "/img/Icon-48.png", + "sizes": "48x48", + "type": "image/png" + }, + { + "src": "/img/Icon-72.png", + "sizes": "72x72", + "type": "image/png" + }, + { + "src": "/img/Icon-96.png", + "sizes": "96x96", + "type": "image/png" + }, + { + "src": "/img/Icon-144.png", + "sizes": "144x144", + "type": "image/png" + }, + { + "src": "/img/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/img/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "theme_color": "#ffffff", + "background_color": "#ffffff", + "start_url": ".", + "imgdisplay": "standalone", + "display": "standalone" +} From 400c09b8c92bd174edb8506f77e0b9c8f1338d2a Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Thu, 17 Jan 2019 23:53:16 +0000 Subject: [PATCH 2/5] swapped manifest file and added bumper --- gulp/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulp/build.js b/gulp/build.js index 94fe0a1..c8be596 100644 --- a/gulp/build.js +++ b/gulp/build.js @@ -31,8 +31,8 @@ gulp.task('styles', function() { gulp.task('copy', function() { gulp.src(['src/img/**/*']).pipe(gulp.dest('live/img')); - // gulp.src(['src/browserconfig.xml', 'src/site.webmanifest', 'src/service-worker.js', 'src/bridger.js']).pipe(gulp.dest('live')); - gulp.src(['src/browserconfig.xml', 'src/service-worker.js', 'src/bridger.js']).pipe(gulp.dest('live')); + gulp.src(['src/browserconfig.xml', 'src/site.webmanifest', 'src/service-worker.js', 'src/bridger.js']).pipe(gulp.dest('live')); + // gulp.src(['src/browserconfig.xml', 'src/service-worker.js', 'src/bridger.js']).pipe(gulp.dest('live')); gulp.src(['src/index.html']).pipe(gulp.dest('live')); }); From 7a597ba55cd15499f673a00b8c05fd246dcdd9e7 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Fri, 18 Jan 2019 00:28:03 +0000 Subject: [PATCH 3/5] swapped manifest file and added bumper --- src/index.html | 2 +- src/js/app.js | 35 +++++++++- src/service-worker.js | 150 +++++++++++++++++++++++++----------------- 3 files changed, 124 insertions(+), 63 deletions(-) diff --git a/src/index.html b/src/index.html index bd6789c..083d6a4 100644 --- a/src/index.html +++ b/src/index.html @@ -13,7 +13,7 @@ - + diff --git a/src/js/app.js b/src/js/app.js index 9e5beaf..db39c7e 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -6,6 +6,37 @@ require('backbone.modal'); const { TrainModel, TrainView } = require('./train'); const { RouteModel, RouteView } = require('./route'); +const live = true; + +if (live) { + const url = new URL(window.location.origin); + console.log('url', url); + + window.loc = url.origin; + + if ('serviceWorker' in navigator) { + // + navigator.serviceWorker.ready.then(function(reg) { + console.warn('Ready??', reg); + // main(); + }); + + window.addEventListener('load', function() { + navigator.serviceWorker + .register('./service-worker.js') + .then((r) => { + console.warn('Service Worker Registered', r.scope); + }) + .catch((error) => { + // registration failed + console.error(`Registration failed with ${ error}`); + }); + }); + + // + } +} + (function () { let offline = false; const bridger = new Worker('bridger.js'); @@ -24,7 +55,7 @@ const { RouteModel, RouteView } = require('./route'); { 'from': 'glc', 'to': 'bhi' }, { 'from': 'bhi', 'to': 'glc' }, { 'from': 'dbe', 'to': 'dmr' }, - { 'from': 'dmr', 'to': 'glc' }, + { 'from': 'dmr', 'to': 'glc' } ], 'views':{} @@ -82,7 +113,7 @@ const { RouteModel, RouteView } = require('./route'); } }; - /*if ('serviceWorker' in navigator) + /* if ('serviceWorker' in navigator) navigator.serviceWorker .register('./service-worker.js') .then(function() { diff --git a/src/service-worker.js b/src/service-worker.js index d05ec61..64b077b 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -11,10 +11,12 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -const CACHE_VERSION = { 'version': '0.0.10' }; -const dataCacheName = `traintimesData-v${CACHE_VERSION.version}`; +const CACHE_VERSION = { 'version': '0.0.18' }; +const PRECACHE = `traintimesData-v${CACHE_VERSION.version}`; const cacheName = `traintimePWA-final-${CACHE_VERSION.version}`; -const filesToCache = [ +const RUNTIME = 'runtime'; + +const PRECACHE_URLS = [ '/', '/index.html', '/service-worker.js', @@ -37,77 +39,105 @@ const filesToCache = [ '/img/Icon-512.png' ]; -self.addEventListener('install', function(e) { - console.log('[ServiceWorker] Install'); - e.waitUntil( - caches.open(cacheName).then(function(cache) { - console.log('[ServiceWorker] Caching app shell'); - - return cache.addAll(filesToCache); - }) +self.addEventListener('install', event => { + console.warn('Installing...'); + event.waitUntil( + caches.open(PRECACHE) + .then(cache => cache.addAll(PRECACHE_URLS)) + .then(self.skipWaiting()) ); }); -self.addEventListener('activate', function(e) { - console.log('[ServiceWorker] Activate'); - e.waitUntil( - caches.keys().then(function(keyList) { - return Promise.all(keyList.map(function(key) { - if (key !== cacheName && key !== dataCacheName) { - console.log('[ServiceWorker] Removing old cache', key); - - return caches.delete(key); - } +// The activate handler takes care of cleaning up old caches. +self.addEventListener('activate', event => { + console.warn('Activate...'); + const currentCaches = [PRECACHE, RUNTIME]; + event.waitUntil( + caches.keys().then(cacheNames => { + return cacheNames.filter(cacheName => !currentCaches.includes(cacheName)); + }).then(cachesToDelete => { + return Promise.all(cachesToDelete.map(cacheToDelete => { + return caches.delete(cacheToDelete); })); - }) + }).then(() => self.clients.claim()) ); - - /* - * Fixes a corner case in which the app wasn't returning the latest data. - * You can reproduce the corner case by commenting out the line below and - * then doing the following steps: 1) load app for first time so that the - * initial New York City data is shown 2) press the refresh button on the - * app 3) go offline 4) reload the app. You expect to see the newer NYC - * data, but you actually see the initial data. This happens because the - * service worker is not yet activated. The code below essentially lets - * you activate the service worker faster. - */ - return self.clients.claim(); }); -self.addEventListener('fetch', function(e) { - console.warn('[Service Worker] Fetch', e.request.url); - const dataUrl = '/getnexttraintimes?'; - if (e.request.url.indexOf(dataUrl) > -1) { - console.log('!'); +// The fetch handler serves responses for same-origin resources from a cache. +// If no response is found, it populates the runtime cache with the response +// from the network before returning it to the page. +self.addEventListener('fetch', event => { + console.warn('Fetch', event.request.url); + // Skip cross-origin requests, like those for Google Analytics. + /* if (event.request.url.startsWith(self.location.origin)) { + console.log('One of our requests..'); + event.respondWith( + caches.match(event.request).then(cachedResponse => { + if (cachedResponse) { + console.log('cachedResponse', cachedResponse); + return cachedResponse; + } - /* - * When the request URL contains dataUrl, the app is asking for fresh - * weather data. In this case, the service worker always goes to the - * network and then caches the response. This is called the "Cache then - * network" strategy: - * https://jakearchibald.com/2014/offline-cookbook/#cache-then-network - */ - e.respondWith( - caches.open(dataCacheName).then(function(cache) { - return fetch(e.request).then(function(response) { - cache.put(e.request.url, response.clone()); + return caches.open(RUNTIME).then(cache => { + return fetch(event.request).then(response => { + // Put a copy of the response in the runtime cache. + return cache.put(event.request, response.clone()).then(() => { + console.log('fetch cache response', response); + return response; + }); + }); + }); + }) + ); + }*/ - return response; + if (event.request.url.startsWith(self.location.origin)) { + console.log('!!', event.request); + + /* event.respondWith( + caches.open(RUNTIME).then(function(cache) { + return cache.match(event.request).then(function (response) { + console.log('£', response); + + return response || fetch(event.request).then(function(response) { + cache.put(event.request, response.clone()); + + return response; + }); + }); + }) + );*/ + + event.respondWith( + caches.open(RUNTIME).then(function(cache) { + return cache.match(event.request).then(function (response) { + return response || fetch(event.request).then(function(response) { + cache.put(event.request, response.clone()); + + return response; + }); }); }) ); } - else - /* - * The app is asking for app shell files. In this scenario the app uses the - * "Cache, falling back to the network" offline strategy: - * https://jakearchibald.com/2014/offline-cookbook/#cache-falling-back-to-network - */ - e.respondWith( - caches.match(e.request).then(function(response) { - return response || fetch(e.request); + if (event.request.url.startsWith('https://maps.googleapis.com')) { + const url = new URL(event.request.url); + const locCache = `loc-${url.searchParams.get('latlng')}`; + event.respondWith( + caches.match(locCache).then(cachedResponse => { + if (cachedResponse) + return cachedResponse; + + return caches.open(RUNTIME).then(cache => { + return fetch(event.request).then(response => { + // Put a copy of the response in the runtime cache. + return cache.put(locCache, response.clone()).then(() => { + return response; + }); + }); + }); }) ); + } }); From 9fa076439ccdc68b185a7ec57ee16fc15f70ef07 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Sat, 19 Jan 2019 22:47:39 +0000 Subject: [PATCH 4/5] swapped manifest file and added bumper --- gulp/backbone.js | 21 +++++++++++++++++++++ gulpfile.js | 3 +++ src/js/route.js | 8 +++++++- src/js/train.js | 14 +++++++++++++- src/service-worker.js | 2 +- 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/gulp/backbone.js b/gulp/backbone.js index bda5857..5a17637 100644 --- a/gulp/backbone.js +++ b/gulp/backbone.js @@ -32,6 +32,27 @@ gulp.task('bundleBackbone', function () { .pipe(gulp.dest('./live/js')); }); +gulp.task('liveBackbone', function () { + // set up the browserify instance on a task basis + const b = browserify({ + 'debug': true, + 'entries': './src/js/app.js' + }); + + return b.bundle() + .pipe(source('app.js')) + .pipe(buffer()) + .pipe(stripDebug()) + .pipe(rename('bundle.js')) + + .pipe(sourcemaps.init({ 'loadMaps': true })) + // Add transformation tasks to the pipeline here. + // .pipe(uglify()) + .on('error', gutil.log) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest('./live/js')); +}); + gulp.task('bump', function() { gulp.src('src/service-worker.js') .pipe(bump({ 'key': 'version' })) diff --git a/gulpfile.js b/gulpfile.js index 71232d1..d32219d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,3 +5,6 @@ const requireDir = require('require-dir'); requireDir('./gulp'); gulp.task('default', ['bundleBackbone', 'styles', 'copy', 'customMUI', 'vendor', 'fonts', 'gotham', 'fujicons']); + + +gulp.task('live', ['liveBackbone', 'styles', 'copy', 'customMUI', 'vendor', 'fonts', 'gotham', 'fujicons']); diff --git a/src/js/route.js b/src/js/route.js index 5f1f5da..bf21bcd 100644 --- a/src/js/route.js +++ b/src/js/route.js @@ -3,6 +3,12 @@ const _ = require('underscore'); const Backbone = require('backbone'); const { createPanel, addPanel } = require('./libs/panel'); +function minuteFloor() { + const now = new Date(); + + return parseInt(~~(now.getTime() / 60000) * 60000, 10).toString(32); +} + const RouteModel = Backbone.Model.extend({ 'initialize': function () { const fromStation = this.get('from'); @@ -48,7 +54,7 @@ const RouteModel = Backbone.Model.extend({ this.interval = setTimeout(routeUpdateFn.bind(this), mod + 10); }, 'getRoute': function () { - const url = `/gettrains?from=${ this.get('from') }&to=${ this.get('to')}`; + const url = `/gettrains?from=${ this.get('from') }&to=${ this.get('to')}&m=${minuteFloor()}`; const self = this; $.ajax({ diff --git a/src/js/train.js b/src/js/train.js index b3c311f..7373661 100644 --- a/src/js/train.js +++ b/src/js/train.js @@ -10,6 +10,18 @@ const _ = require('underscore'); const Backbone = require('backbone'); const { findStation } = require('./stations'); +function hourFloor() { + const now = new Date(); + + return parseInt(~~(now.getTime() / 3600000) * 3600000, 10).toString(32); +} + +function minuteFloor() { + const now = new Date(); + + return parseInt(~~(now.getTime() / 60000) * 60000, 10).toString(32); +} + const TrainModel = Backbone.Model.extend({ 'defaults': function (obj) { // return a new object @@ -58,7 +70,7 @@ const TrainModel = Backbone.Model.extend({ const bus = this.get('bus'); $.ajax({ 'type': 'GET', - 'url': url, + 'url': `${url}&m=${minuteFloor()}`, 'data': '', 'dataType': 'json', 'timeout': 10000, diff --git a/src/service-worker.js b/src/service-worker.js index 64b077b..e45e13d 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -const CACHE_VERSION = { 'version': '0.0.18' }; +const CACHE_VERSION = { 'version': '0.0.21' }; const PRECACHE = `traintimesData-v${CACHE_VERSION.version}`; const cacheName = `traintimePWA-final-${CACHE_VERSION.version}`; const RUNTIME = 'runtime'; From e7e62ce08de19a0ae8c6abb9cd297e659441bcf5 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Sat, 19 Jan 2019 22:55:38 +0000 Subject: [PATCH 5/5] swapped manifest file and added bumper --- src/service-worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service-worker.js b/src/service-worker.js index e45e13d..978f65f 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -20,7 +20,7 @@ const PRECACHE_URLS = [ '/', '/index.html', '/service-worker.js', - '/manifest.json', + '/site.webmanifest', '/browserconfig.xml', '/css/style.min.css', '/css/mui.custom.css',