From 262d4ab25322995ff5e559000643c928cc458b86 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Fri, 31 May 2019 17:55:49 +1000 Subject: [PATCH 01/17] add wip routing --- buildprocess/generate-init-routes.js | 35 +++++++++++++++++++++++ buildprocess/webpack.config.js | 24 +++++++++++++++- lib/Styles/loader.css | 3 ++ package.json | 2 ++ wwwroot/index.html | 3 +- wwwroot/index_prerender.html | 42 ++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 buildprocess/generate-init-routes.js create mode 100644 wwwroot/index_prerender.html diff --git a/buildprocess/generate-init-routes.js b/buildprocess/generate-init-routes.js new file mode 100644 index 000000000..b31ba6ecb --- /dev/null +++ b/buildprocess/generate-init-routes.js @@ -0,0 +1,35 @@ +var fs = require("fs"); +var path = require("path"); + +const rootGroupName = "Root Group"; + +const getNameFromItem = item => item.id || item.name; + +const resUrl = url => + path.resolve(__dirname, "..", "wwwroot", "init", `${url}.json`); + +const getCatalogFromInitName = initName => resUrl(initName); + +const getRoutes = (topCatalogItem, currentRoute = rootGroupName) => + topCatalogItem.reduce((acc, catalogItem) => { + const nameForCurrentItem = getNameFromItem(catalogItem); + const finalRoute = `${currentRoute}/${nameForCurrentItem}`; + const items = catalogItem.items && getRoutes(catalogItem.items, finalRoute); + + if (items) { + return [...acc, ...items, finalRoute]; + } + return [...acc, finalRoute]; + }, []); + +function generateRoutes(initUrls) { + return initUrls.reduce((acc, initName) => { + const fsPathForInit = getCatalogFromInitName(initName); + const data = fs.readFileSync(fsPathForInit, "utf8"); + const literal = JSON.parse(data).catalog; + + return [...acc, ...getRoutes(literal, rootGroupName)]; + }, []); +} + +module.exports = generateRoutes; diff --git a/buildprocess/webpack.config.js b/buildprocess/webpack.config.js index d13883cae..757588bec 100644 --- a/buildprocess/webpack.config.js +++ b/buildprocess/webpack.config.js @@ -3,6 +3,9 @@ /*global require*/ var configureWebpackForTerriaJS = require('terriajs/buildprocess/configureWebpack'); var MiniCssExtractPlugin = require('mini-css-extract-plugin'); +var generateRoutes = require("./generate-init-routes"); +var PrerenderSPAPlugin = require("prerender-spa-plugin"); +var Renderer = PrerenderSPAPlugin.PuppeteerRenderer; var path = require('path'); module.exports = function(devMode, hot) { @@ -100,7 +103,26 @@ module.exports = function(devMode, hot) { ] }, plugins: [ - new MiniCssExtractPlugin({filename: "TerriaMap.css", disable: hot, ignoreOrder: true, allChunks: true}) + new MiniCssExtractPlugin({filename: "TerriaMap.css", disable: hot, ignoreOrder: true, allChunks: true}), + new PrerenderSPAPlugin({ + staticDir: path.resolve(__dirname, '..', "wwwroot/"), + indexPath: path.resolve(__dirname, '..', "wwwroot/", 'index_prerender.html'), + // routes: [ + // "/", + // "/catalog/", + // "/catalog/Root%20Group%2FExample%20Datasets%2FChart%20examples%2FStar%20Stations", + // "/catalog/Root%20Group%2FExample%20Datasets%2FChart%20examples%2FTime%20series", + // ], + // routes: generateRoutes(require('../wwwroot/config.json')), + routes: generateRoutes(["terria"]), + renderer: new Renderer({ + // renderAfterDocumentEvent: 'some terria catalog loaded event', + // renderAfterElementExists: 'some element? instead of event?', + // renderAfterTime: 5000, + maxConcurrentRoutes: 4, + // headless: false, // set to false for debugging + }), + }), ], resolve: { alias: {}, diff --git a/lib/Styles/loader.css b/lib/Styles/loader.css index b72b5d973..6e2fa393d 100644 --- a/lib/Styles/loader.css +++ b/lib/Styles/loader.css @@ -1,3 +1,6 @@ + .tjs-explorer-window__modal-wrapper { + z-index:10000 !important; + } .loader-ui-right img{ display: block; margin: calc(50vh - 150px) auto; diff --git a/package.json b/package.json index e7401f01b..b5b98dd52 100644 --- a/package.json +++ b/package.json @@ -48,10 +48,12 @@ "node-notifier": "^5.1.2", "node-sass": "^4.11.0", "plugin-error": "^1.0.1", + "prerender-spa-plugin": "^3.4.0", "prop-types": "^15.6.0", "raw-loader": "^1.0.0", "react": "^16.3.2", "react-dom": "^16.3.2", + "react-router-dom": "^5.0.0", "redbox-react": "^1.3.6", "resolve-url-loader": "^3.0.1", "sass-loader": "^7.1.0", diff --git a/wwwroot/index.html b/wwwroot/index.html index 8589c96b3..ea51a55f6 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -1,6 +1,7 @@ + @@ -36,6 +37,6 @@
- + diff --git a/wwwroot/index_prerender.html b/wwwroot/index_prerender.html new file mode 100644 index 000000000..ea51a55f6 --- /dev/null +++ b/wwwroot/index_prerender.html @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Terria Map + + + + + + + + +
+ + + From b817dc2a8244ee5f296652d46b262c87d5722e53 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Mon, 3 Jun 2019 13:42:53 +1000 Subject: [PATCH 02/17] Add prettier deps --- .prettierignore | 10 ++++ package-lock.json | 145 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 + yarn.lock | 95 ++++++++++++++++++++++++++---- 4 files changed, 235 insertions(+), 17 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..ca3832430 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,10 @@ +# Ignore everything +* + +# Unignore directories (to all depths) and unignore code and style files +!lib/**/ +!lib/**/*.js +!lib/**/*.jsx +!lib/**/*.ts +!lib/**/*.tsx +!lib/**/*.scss diff --git a/package-lock.json b/package-lock.json index ce0537d24..933c0ea36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1724,6 +1724,12 @@ "typical": "^2.6.1" } }, + "array-differ": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-2.1.0.tgz", + "integrity": "sha512-KbUpJgx909ZscOc/7CLATBFam7P1Z1QRQInvgT0UztM9Q72aGKCunKASAl7WNW0tnPmPyEMeMhdsfWhfmW037w==", + "dev": true + }, "array-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", @@ -1831,6 +1837,12 @@ "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=" }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, "asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", @@ -8562,6 +8574,12 @@ "run-queue": "^1.0.3" } }, + "mri": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.1.4.tgz", + "integrity": "sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w==", + "dev": true + }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -8583,6 +8601,18 @@ "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=", "dev": true }, + "multimatch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/multimatch/-/multimatch-3.0.0.tgz", + "integrity": "sha512-22foS/gqQfANZ3o+W7ST2x25ueHDVNWl/b9OlGcLpy/iKxjCpvcNCM51YCenUi7Mt/jAjjqv8JwZRs8YP5sRjA==", + "dev": true, + "requires": { + "array-differ": "^2.0.3", + "array-union": "^1.0.2", + "arrify": "^1.0.1", + "minimatch": "^3.0.4" + } + }, "mustache": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/mustache/-/mustache-2.3.2.tgz", @@ -9607,11 +9637,6 @@ "sha.js": "^2.4.8" } }, - "pell": { - "version": "git://github.com/TerriaJS/pell.git#7cd23a55cdfd130fedf3679433991bb7d958fc42", - "from": "git://github.com/TerriaJS/pell.git#master", - "dev": true - }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -9949,6 +9974,12 @@ "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" }, + "prettier": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.17.0.tgz", + "integrity": "sha512-sXe5lSt2WQlCbydGETgfm1YBShgOX4HxQkFPvbxkcwgDvGDeqVau8h+12+lmSVlP3rHPz0oavfddSZg/q+Szjw==", + "dev": true + }, "pretty-error": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.1.tgz", @@ -9965,6 +9996,103 @@ "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", "dev": true }, + "pretty-quick": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/pretty-quick/-/pretty-quick-1.11.0.tgz", + "integrity": "sha512-hy0yOSnqVykrgoHcCcB72p3B5ERQJcjQI6ExeSGSTFE2cDrPwCQtFb3kXA1F+jUPrbt7orra8U+fjS/Emjgpuw==", + "dev": true, + "requires": { + "chalk": "^2.3.0", + "execa": "^0.8.0", + "find-up": "^2.1.0", + "ignore": "^3.3.7", + "mri": "^1.1.0", + "multimatch": "^3.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "execa": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz", + "integrity": "sha1-2NdrvBtVIX7RkP1t1J08d07PyNo=", + "dev": true, + "requires": { + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", + "dev": true + }, + "ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", + "dev": true + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + } + } + }, "private": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", @@ -12765,7 +12893,6 @@ "mustache": "^2.2.1", "mutationobserver-shim": "^0.3.1", "pbf": "^3.0.1", - "pell": "git://github.com/TerriaJS/pell.git#7cd23a55cdfd130fedf3679433991bb7d958fc42", "point-in-polygon": "^1.0.1", "proj4": "^2.4.4", "prop-types": "^15.6.0", @@ -12791,6 +12918,12 @@ "url-loader": "^1.1.2", "webpack": "^4.29.5", "worker-loader": "^2.0.0" + }, + "dependencies": { + "pell": { + "version": "git://github.com/TerriaJS/pell.git#7cd23a55cdfd130fedf3679433991bb7d958fc42", + "from": "git://github.com/TerriaJS/pell.git#7cd23a55cdfd130fedf3679433991bb7d958fc42" + } } }, "terriajs-catalog-editor": { diff --git a/package.json b/package.json index e7401f01b..4a8f2ea57 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,8 @@ "node-notifier": "^5.1.2", "node-sass": "^4.11.0", "plugin-error": "^1.0.1", + "prettier": "1.17.0", + "pretty-quick": "^1.10.0", "prop-types": "^15.6.0", "raw-loader": "^1.0.0", "react": "^16.3.2", diff --git a/yarn.lock b/yarn.lock index 2c220c6eb..c2573ea3d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1246,6 +1246,11 @@ array-back@^3.0.1: resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== +array-differ@^2.0.3: + version "2.1.0" + resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-2.1.0.tgz#4b9c1c3f14b906757082925769e8ab904f4801b1" + integrity sha512-KbUpJgx909ZscOc/7CLATBFam7P1Z1QRQInvgT0UztM9Q72aGKCunKASAl7WNW0tnPmPyEMeMhdsfWhfmW037w== + array-each@^1.0.0, array-each@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/array-each/-/array-each-1.0.1.tgz#a794af0c05ab1752846ee753a1f211a05ba0c44f" @@ -1303,7 +1308,7 @@ array-sort@^1.0.0: get-value "^2.0.6" kind-of "^5.0.2" -array-union@^1.0.1: +array-union@^1.0.1, array-union@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" integrity sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk= @@ -1320,6 +1325,11 @@ array-unique@^0.3.2: resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= +arrify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= + asap@~2.0.3: version "2.0.6" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" @@ -1995,7 +2005,7 @@ chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.1.0, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -3648,6 +3658,19 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" +execa@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.8.0.tgz#d8d76bbc1b55217ed190fd6dd49d3c774ecfc8da" + integrity sha1-2NdrvBtVIX7RkP1t1J08d07PyNo= + dependencies: + cross-spawn "^5.0.1" + get-stream "^3.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + execa@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" @@ -4765,6 +4788,11 @@ ignore-walk@^3.0.1: dependencies: minimatch "^3.0.4" +ignore@^3.3.7: + version "3.3.10" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" + integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug== + ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" @@ -6107,6 +6135,11 @@ move-concurrently@^1.0.1: rimraf "^2.5.4" run-queue "^1.0.3" +mri@^1.1.0: + version "1.1.4" + resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.4.tgz#7cb1dd1b9b40905f1fac053abe25b6720f44744a" + integrity sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w== + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -6130,6 +6163,16 @@ multicast-dns@^6.0.1: dns-packet "^1.3.1" thunky "^1.0.2" +multimatch@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-3.0.0.tgz#0e2534cc6bc238d9ab67e1b9cd5fcd85a6dbf70b" + integrity sha512-22foS/gqQfANZ3o+W7ST2x25ueHDVNWl/b9OlGcLpy/iKxjCpvcNCM51YCenUi7Mt/jAjjqv8JwZRs8YP5sRjA== + dependencies: + array-differ "^2.0.3" + array-union "^1.0.2" + arrify "^1.0.1" + minimatch "^3.0.4" + mustache@^2.2.1: version "2.3.2" resolved "https://registry.yarnpkg.com/mustache/-/mustache-2.3.2.tgz#a6d4d9c3f91d13359ab889a812954f9230a3d0c5" @@ -6919,6 +6962,10 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" +"pell@git://github.com/TerriaJS/pell#master": + version "1.0.6" + resolved "git://github.com/TerriaJS/pell#7cd23a55cdfd130fedf3679433991bb7d958fc42" + performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" @@ -7193,6 +7240,11 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= +prettier@1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.17.0.tgz#53b303676eed22cc14a9f0cec09b477b3026c008" + integrity sha512-sXe5lSt2WQlCbydGETgfm1YBShgOX4HxQkFPvbxkcwgDvGDeqVau8h+12+lmSVlP3rHPz0oavfddSZg/q+Szjw== + pretty-error@^2.0.2: version "2.1.1" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3" @@ -7206,6 +7258,18 @@ pretty-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" integrity sha1-t+PqQkNaTJsnWdmeDyAesZWALuE= +pretty-quick@^1.10.0: + version "1.11.0" + resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-1.11.0.tgz#d0bf997f3eb7de3d1bac5ffeb9c335f404d844c8" + integrity sha512-hy0yOSnqVykrgoHcCcB72p3B5ERQJcjQI6ExeSGSTFE2cDrPwCQtFb3kXA1F+jUPrbt7orra8U+fjS/Emjgpuw== + dependencies: + chalk "^2.3.0" + execa "^0.8.0" + find-up "^2.1.0" + ignore "^3.3.7" + mri "^1.1.0" + multimatch "^3.0.0" + private@^0.1.6: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -7629,6 +7693,13 @@ react-responsive@^5.0.0: matchmediaquery "^0.3.0" prop-types "^15.6.1" +react-swipeable@^5.1.0: + version "5.2.3" + resolved "https://registry.yarnpkg.com/react-swipeable/-/react-swipeable-5.2.3.tgz#392d6cba328090d10fcb25a06047f5ad808f7e6c" + integrity sha512-J92RJNIZ7wE5czNWtVUTnTTOdgsnWXcj5fcKiEhf7ZU5JYSh5wOFosKWu8FyTFa6FXwmHKMzhaKUC/p9L2n2Lw== + dependencies: + prop-types "^15.6.2" + react@^16.3.2: version "16.8.6" resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe" @@ -9028,10 +9099,10 @@ terriajs-catalog-editor@^0.2.0: resolved "https://registry.yarnpkg.com/terriajs-catalog-editor/-/terriajs-catalog-editor-0.2.0.tgz#d9c6679e53c4d92e87a531af896c6148888ed8e4" integrity sha1-2cZnnlPE2S6HpTGviWxhSIiO2OQ= -terriajs-cesium@1.57.0: - version "1.57.0" - resolved "https://registry.yarnpkg.com/terriajs-cesium/-/terriajs-cesium-1.57.0.tgz#0d75a703daee23cd99b91c4e234557b3e36c2d5d" - integrity sha512-kJXyAMfo/hUnlQqgvg+K0KxvDocP8ystyyFax1VCw0B3XkVyzkLhO8BS3JwfUN9WdyxRHL4aWddtHsu3XfiqnA== +terriajs-cesium@1.57.2: + version "1.57.2" + resolved "https://registry.yarnpkg.com/terriajs-cesium/-/terriajs-cesium-1.57.2.tgz#519117a24c422c7d15e34b12b4798563f5e35ff5" + integrity sha512-dDZ0u7SpcX3I6hpwPHnEq8nNmW8jLiCD4NThUsLaH6M+ILHmPBX1uU6S46a1DJxkzP98r/rJsnh9rchhGTXh5w== dependencies: deamdify "^0.1.1" dompurify "^1.0.2" @@ -9090,10 +9161,10 @@ terriajs-server@^3.0.0: when "^3.7.7" yargs "^13.2.4" -terriajs@7.4.1: - version "7.4.1" - resolved "https://registry.yarnpkg.com/terriajs/-/terriajs-7.4.1.tgz#f1e01486061a2f5d49e107bc19adb9cf2ab9d52e" - integrity sha512-JiRNGQGnmGFkrE/zKOb67JhQY1I/X6UmfFa1+k+NCvEYSrhGrVFAnrKqjVsXvE12OJLdnLasrPCu5ZPWt8FnKA== +terriajs@7.5.1: + version "7.5.1" + resolved "https://registry.yarnpkg.com/terriajs/-/terriajs-7.5.1.tgz#17eb2ff441bbc5beaeafe38ed4dbae6411198013" + integrity sha512-H/IOh+LhuYp+DUrwTMgiAifiYPuc3Z8vQBmuZZnKKCAQo26eX/8zGFj7PI71E9qhEuwNOHqCS/tnpTkfKj6cEA== dependencies: "@babel/core" "^7.3.3" "@babel/plugin-transform-modules-commonjs" "^7.2.0" @@ -9138,6 +9209,7 @@ terriajs@7.4.1: mustache "^2.2.1" mutationobserver-shim "^0.3.1" pbf "^3.0.1" + pell "git://github.com/TerriaJS/pell#master" point-in-polygon "^1.0.1" proj4 "^2.4.4" prop-types "^15.6.0" @@ -9149,6 +9221,7 @@ terriajs@7.4.1: react-datepicker "0.53.0" react-dom "^16.3.2" react-responsive "^5.0.0" + react-swipeable "^5.1.0" resolve-url-loader "^3.0.1" retry "^0.12.0" sass-loader "^7.1.0" @@ -9156,7 +9229,7 @@ terriajs@7.4.1: string-replace-webpack-plugin "^0.1.3" style-loader "^0.23.1" svg-sprite-loader "4.1.3" - terriajs-cesium "1.57.0" + terriajs-cesium "1.57.2" terriajs-html2canvas "1.0.0-alpha.12-terriajs-1" urijs "^1.18.12" url-loader "^1.1.2" From a9bbb6092d79646313899e74f3e9ba3026289650 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Mon, 3 Jun 2019 13:44:34 +1000 Subject: [PATCH 03/17] Add scripts --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4a8f2ea57..0bb5bc285 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,9 @@ "deploy": "aws --profile $npm_package_config_awsProfile s3 ls && npm ci && npm run deploy-without-reinstall", "deploy-without-reinstall": "gulp clean && gulp release && npm run deploy-current", "deploy-current": "npm run get-deploy-overrides && gulp make-package --serverConfigOverride ./privateserverconfig.json --clientConfigOverride ./wwwroot/privateconfig.json && cd deploy/aws && ./stack create && cd ../..", - "get-deploy-overrides": "aws s3 --profile $npm_package_config_awsProfile cp $npm_package_config_awsS3ServerConfigOverridePath ./privateserverconfig.json && aws s3 --profile $npm_package_config_awsProfile cp $npm_package_config_awsS3ClientConfigOverridePath ./wwwroot/privateconfig.json" + "get-deploy-overrides": "aws s3 --profile $npm_package_config_awsProfile cp $npm_package_config_awsS3ServerConfigOverridePath ./privateserverconfig.json && aws s3 --profile $npm_package_config_awsProfile cp $npm_package_config_awsS3ClientConfigOverridePath ./wwwroot/privateconfig.json", + "prettier": "prettier --write \"**/*\"", + "pretty-quick": "pretty-quick", + "prettier-check": "prettier --check \"**/*\"" } } From db434c7f8896a17ae9b6e5375efab5bef66e06ec Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Mon, 3 Jun 2019 13:45:30 +1000 Subject: [PATCH 04/17] Add husky --- .editorconfig | 15 +++++ package.json | 6 ++ yarn.lock | 163 ++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 179 insertions(+), 5 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..7df700c04 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[*.scss] +indent_size = 2 diff --git a/package.json b/package.json index 0bb5bc285..ce95c0ae0 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "fs-extra": "^7.0.1", "generate-terriajs-schema": "^1.4.0", "gulp": "^4.0.0", + "husky": "^2.2.0", "json5": "^2.1.0", "node-notifier": "^5.1.2", "node-sass": "^4.11.0", @@ -88,5 +89,10 @@ "prettier": "prettier --write \"**/*\"", "pretty-quick": "pretty-quick", "prettier-check": "prettier --check \"**/*\"" + }, + "husky": { + "hooks": { + "pre-commit": "pretty-quick --staged" + } } } diff --git a/yarn.lock b/yarn.lock index c2573ea3d..3ae57981b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -812,6 +812,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.48.tgz#e385073561643a9ba6199a1985ffc03530f90781" integrity sha512-c35YEBTkL4rzXY2ucpSKy+UYHjUBIIkuJbWYbsGIrKLEWU5dgJMmLkkIb3qeC3O3Tpb1ZQCwecscvJTDjDjkRw== +"@types/normalize-package-data@^2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" + integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA== + "@webassemblyjs/ast@1.8.5": version "1.8.5" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359" @@ -1924,6 +1929,25 @@ cache-point@^0.4.1: fs-then-native "^2.0.0" mkdirp2 "^1.0.3" +caller-callsite@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/caller-callsite/-/caller-callsite-2.0.0.tgz#847e0fce0a223750a9a027c54b33731ad3154134" + integrity sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ= + dependencies: + callsites "^2.0.0" + +caller-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-2.0.0.tgz#468f83044e369ab2010fac5f06ceee15bb2cb1f4" + integrity sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ= + dependencies: + caller-callsite "^2.0.0" + +callsites@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50" + integrity sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA= + callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -2074,6 +2098,11 @@ chrome-trace-event@^1.0.0: dependencies: tslib "^1.9.0" +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" @@ -2540,6 +2569,16 @@ cors@^2.7.1: object-assign "^4" vary "^1" +cosmiconfig@^5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.2.1.tgz#040f726809c591e77a17c0a3626ca45b4f168b1a" + integrity sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA== + dependencies: + import-fresh "^2.0.0" + is-directory "^0.3.1" + js-yaml "^3.13.1" + parse-json "^4.0.0" + crc32-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-2.0.0.tgz#e3cdd3b4df3168dd74e3de3fbbcb7b297fe908f4" @@ -3316,7 +3355,7 @@ errno@^0.1.3, errno@~0.1.7: dependencies: prr "~1.0.1" -error-ex@^1.2.0: +error-ex@^1.2.0, error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== @@ -3971,6 +4010,13 @@ find-up@^3.0.0: dependencies: locate-path "^3.0.0" +find-up@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.0.0.tgz#c367f8024de92efb75f2d4906536d24682065c3a" + integrity sha512-zoH7ZWPkRdgwYCDVoQTzqjG8JSPANhtvLhh4KVUHyKnaUJJrNeFmWIkTcNuJmR3GLMEmGYEf2S2bjgx26JTF+Q== + dependencies: + locate-path "^5.0.0" + findit@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/findit/-/findit-2.0.0.tgz#6509f0126af4c178551cfa99394e032e13a4d56e" @@ -4234,6 +4280,11 @@ get-stdin@^4.0.1: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= +get-stdin@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-7.0.0.tgz#8d5de98f15171a125c5e516643c7a6d0ea8a96f6" + integrity sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ== + get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -4735,6 +4786,22 @@ https-proxy-agent@^2.2.1: agent-base "^4.1.0" debug "^3.1.0" +husky@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/husky/-/husky-2.3.0.tgz#8b78ed24d763042df7fd899991985d65a976dd13" + integrity sha512-A/ZQSEILoq+mQM3yC3RIBSaw1bYXdkKnyyKVSUiJl+iBjVZc5LQEXdGY1ZjrDxC4IzfRPiJ0IqzEQGCN5TQa/A== + dependencies: + cosmiconfig "^5.2.0" + execa "^1.0.0" + find-up "^3.0.0" + get-stdin "^7.0.0" + is-ci "^2.0.0" + pkg-dir "^4.1.0" + please-upgrade-node "^3.1.1" + read-pkg "^5.1.1" + run-node "^1.0.0" + slash "^3.0.0" + hyphenate-style-name@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.0.3.tgz#097bb7fa0b8f1a9cf0bd5c734cf95899981a9b48" @@ -4803,6 +4870,14 @@ image-size@^0.5.1: resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.5.5.tgz#09dfd4ab9d20e29eb1c3e80b8990378df9e3cb9c" integrity sha1-Cd/Uq50g4p6xw+gLiZA3jfnjy5w= +import-fresh@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546" + integrity sha1-2BNVwVYS04bGH53dOSLUMEgipUY= + dependencies: + caller-path "^2.0.0" + resolve-from "^3.0.0" + import-fresh@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.0.0.tgz#a3d897f420cab0e671236897f75bc14b4885c390" @@ -5005,6 +5080,13 @@ is-callable@^1.1.4: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== +is-ci@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== + dependencies: + ci-info "^2.0.0" + is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -5042,6 +5124,11 @@ is-descriptor@^1.0.0, is-descriptor@^1.0.2: is-data-descriptor "^1.0.0" kind-of "^6.0.2" +is-directory@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1" + integrity sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE= + is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" @@ -5278,7 +5365,7 @@ js-levenshtein@^1.1.3: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-yaml@^3.13.0: +js-yaml@^3.13.0, js-yaml@^3.13.1: version "3.13.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== @@ -5366,7 +5453,7 @@ jsesc@~0.5.0: resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= -json-parse-better-errors@^1.0.2: +json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== @@ -5610,6 +5697,13 @@ locate-path@^3.0.0: p-locate "^3.0.0" path-exists "^3.0.0" +locate-path@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" + integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + dependencies: + p-locate "^4.1.0" + lodash._getnative@^3.0.0: version "3.9.1" resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" @@ -6405,7 +6499,7 @@ nopt@~1.0.10: dependencies: abbrev "1" -normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== @@ -6733,7 +6827,7 @@ p-limit@^1.1.0: dependencies: p-try "^1.0.0" -p-limit@^2.0.0: +p-limit@^2.0.0, p-limit@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ== @@ -6754,6 +6848,13 @@ p-locate@^3.0.0: dependencies: p-limit "^2.0.0" +p-locate@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" + integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + dependencies: + p-limit "^2.2.0" + p-map@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/p-map/-/p-map-2.1.0.tgz#310928feef9c9ecc65b68b17693018a665cea175" @@ -6855,6 +6956,14 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + parse-node-version@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parse-node-version/-/parse-node-version-1.0.1.tgz#e2b5dbede00e7fa9bc363607f53327e8b073189b" @@ -7012,6 +7121,20 @@ pkg-dir@^3.0.0: dependencies: find-up "^3.0.0" +pkg-dir@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + +please-upgrade-node@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.1.1.tgz#ed320051dfcc5024fae696712c8288993595e8ac" + integrity sha512-KY1uHnQ2NlQHqIJQpnh/i54rKkuxCEBx+voJIS/Mvb+L2iYd2NMotwduhKTMjfC1uKoX3VXOxLjIYG66dfJTVQ== + dependencies: + semver-compare "^1.0.0" + plugin-error@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-1.0.1.tgz#77016bd8919d0ac377fdcdd0322328953ca5781c" @@ -7727,6 +7850,16 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" +read-pkg@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-5.1.1.tgz#5cf234dde7a405c90c88a519ab73c467e9cb83f5" + integrity sha512-dFcTLQi6BZ+aFUaICg7er+/usEoqFdQxiEBsEMNGoipenihtxxtdrQuBXvyANCEI8VuUIVYFgeHGx9sLLvim4w== + dependencies: + "@types/normalize-package-data" "^2.4.0" + normalize-package-data "^2.5.0" + parse-json "^4.0.0" + type-fest "^0.4.1" + read@^1.0.4: version "1.0.7" resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" @@ -8186,6 +8319,11 @@ run-async@^2.2.0: dependencies: is-promise "^2.1.0" +run-node@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/run-node/-/run-node-1.0.0.tgz#46b50b946a2aa2d4947ae1d886e9856fd9cabe5e" + integrity sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A== + run-queue@^1.0.0, run-queue@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/run-queue/-/run-queue-1.0.3.tgz#e848396f057d223f24386924618e25694161ec47" @@ -8299,6 +8437,11 @@ selfsigned@^1.10.4: dependencies: node-forge "0.7.5" +semver-compare@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" + integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w= + semver-greatest-satisfied-range@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/semver-greatest-satisfied-range/-/semver-greatest-satisfied-range-1.1.0.tgz#13e8c2658ab9691cb0cd71093240280d36f77a5b" @@ -8483,6 +8626,11 @@ simple-statistics@^7.0.1: resolved "https://registry.yarnpkg.com/simple-statistics/-/simple-statistics-7.0.2.tgz#46671f45cb6f9b68207dccd6a3c4f7e745e6e638" integrity sha512-wqTjlmbiaL6Fqaw28tSjQrthjxVV17MMfi/H/qvE0jAvtLspB2S7gEtcR27uvhSRAa64LhjhoO169rX8sFW3pg== +slash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" + integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== + slice-ansi@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" @@ -9492,6 +9640,11 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" +type-fest@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.4.1.tgz#8bdf77743385d8a4f13ba95f610f5ccd68c728f8" + integrity sha512-IwzA/LSfD2vC1/YDYMv/zHP4rDF1usCwllsDpbolT3D4fUepIO7f9K70jjmUewU/LmGUKJcwcVtDCpnKk4BPMw== + type-is@~1.6.16, type-is@~1.6.17: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" From 32f68521e4b7c2da8c91504a94e48d3da3de8e20 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Mon, 3 Jun 2019 13:45:48 +1000 Subject: [PATCH 05/17] Apply prettier --- lib/Styles/variables.scss | 4 +- lib/ViewModels/PreviewLinkViewModel.js | 25 +-- lib/Views/AboutButton.jsx | 8 +- lib/Views/RelatedMaps.jsx | 239 +++++++++++++++---------- lib/Views/UserInterface.jsx | 79 ++++---- lib/Views/global.scss | 23 ++- lib/Views/related-maps.scss | 6 +- lib/Views/render.jsx | 25 ++- 8 files changed, 237 insertions(+), 172 deletions(-) diff --git a/lib/Styles/variables.scss b/lib/Styles/variables.scss index f27276e68..3a48a97e4 100644 --- a/lib/Styles/variables.scss +++ b/lib/Styles/variables.scss @@ -1,4 +1,4 @@ -@import '~terriajs/lib/Sass/common/_variables.scss'; +@import "~terriajs/lib/Sass/common/_variables.scss"; // To customise the look of your map, uncomment and change values here and in lib/Views/global.scss /* @@ -24,4 +24,4 @@ $dark-lighter: hsl(0,30%,50%); $color-primary-light:lighten($color-primary,10%); $color-primary-dark:darken($color-primary,10%); $dark-darker: hsl(0,30%,15%); -*/ \ No newline at end of file +*/ diff --git a/lib/ViewModels/PreviewLinkViewModel.js b/lib/ViewModels/PreviewLinkViewModel.js index e7574e6f9..30c4e7477 100644 --- a/lib/ViewModels/PreviewLinkViewModel.js +++ b/lib/ViewModels/PreviewLinkViewModel.js @@ -1,26 +1,29 @@ -'use strict'; +"use strict"; /*global require*/ -var knockout = require('terriajs-cesium/Source/ThirdParty/knockout'); -var loadView = require('terriajs/lib/Core/loadView'); -var URI = require('urijs'); +var knockout = require("terriajs-cesium/Source/ThirdParty/knockout"); +var loadView = require("terriajs/lib/Core/loadView"); +var URI = require("urijs"); function PreviewLinkViewModel(options) { - this.terria = options.terria; + this.terria = options.terria; - this.isShown = window.location && window.location.href && new URI(window.location.href).hash().length === 0; + this.isShown = + window.location && + window.location.href && + new URI(window.location.href).hash().length === 0; - knockout.track(this, ['isShown']); + knockout.track(this, ["isShown"]); } PreviewLinkViewModel.prototype.hide = function(container) { - this.isShown = false; + this.isShown = false; }; PreviewLinkViewModel.create = function(options) { - var viewModel = new PreviewLinkViewModel(options); - loadView(require('../Views/PreviewLink.html'), options.container, viewModel); - return viewModel; + var viewModel = new PreviewLinkViewModel(options); + loadView(require("../Views/PreviewLink.html"), options.container, viewModel); + return viewModel; }; module.exports = PreviewLinkViewModel; diff --git a/lib/Views/AboutButton.jsx b/lib/Views/AboutButton.jsx index 8500d3bda..15e426961 100644 --- a/lib/Views/AboutButton.jsx +++ b/lib/Views/AboutButton.jsx @@ -1,5 +1,7 @@ -import React from 'react'; +import React from "react"; -import MenuButton from 'terriajs/lib/ReactViews/Map/MenuButton'; +import MenuButton from "terriajs/lib/ReactViews/Map/MenuButton"; -export default function AboutButton() { return ()}; \ No newline at end of file +export default function AboutButton() { + return ; +} diff --git a/lib/Views/RelatedMaps.jsx b/lib/Views/RelatedMaps.jsx index 8f1fc87ff..f25b8331b 100644 --- a/lib/Views/RelatedMaps.jsx +++ b/lib/Views/RelatedMaps.jsx @@ -1,103 +1,152 @@ -import React from 'react'; -import PropTypes from 'prop-types'; +import React from "react"; +import PropTypes from "prop-types"; -import MenuPanel from 'terriajs/lib/ReactViews/StandardUserInterface/customizable/MenuPanel.jsx'; -import PanelStyles from 'terriajs/lib/ReactViews/Map/Panels/panel.scss'; -import Styles from './related-maps.scss'; -import classNames from 'classnames'; +import MenuPanel from "terriajs/lib/ReactViews/StandardUserInterface/customizable/MenuPanel.jsx"; +import PanelStyles from "terriajs/lib/ReactViews/Map/Panels/panel.scss"; +import Styles from "./related-maps.scss"; +import classNames from "classnames"; function RelatedMaps(props) { - const dropdownTheme = { - inner: Styles.dropdownInner, - icon: 'gallery' - - }; - - return ( - -
- -
- -

- Clicking on a map below will open it in a separate window or tab. -

- -
- - AREMI - - - AREMI - -

- AREMI provides access to Australian spatial data relevant to the Renewable Energy industry, - sourced from Government, Industry and Research. -

-
- -
- - Northern Australia - - - Northern - Australia - -

- The Northern Australia NationalMap forms part of the Government's commitment to developing - northern Australia by providing easy access to authoritative and other spatial data on northern - Australia to governments, business and the public. - - More information on the Government's White Paper on Developing Northern Australia is available - here: - https://northernaustralia.dpmc.gov.au. -

-
- -
- - NEII Viewer - - - NEII Viewer - -

- The National Environmental Information Infrastructure (NEII) is an information platform designed - to improve discovery, access and re-use of nationally significant environmental data. More - information on the NEII is available here: - neii.gov.au/data-viewer. -

-
- -
- - AURIN Map - - - AURIN Map - -

- AURIN Map provides access to datasets on urban infrastructure for urban researchers, policy and - decision makers. -

-
-
- ); + const dropdownTheme = { + inner: Styles.dropdownInner, + icon: "gallery" + }; + + return ( + +
+ +
+ +

Clicking on a map below will open it in a separate window or tab.

+ +
+ + AREMI + + + + AREMI + + +

+ AREMI provides access to Australian spatial data relevant to the + Renewable Energy industry, sourced from Government, Industry and + Research. +

+
+ +
+ + Northern Australia + + + + Northern Australia + + +

+ The Northern Australia NationalMap forms part of the Government's + commitment to developing northern Australia by providing easy access + to authoritative and other spatial data on northern Australia to + governments, business and the public. More information on the + Government's White Paper on Developing Northern Australia is available + here:{" "} + + https://northernaustralia.dpmc.gov.au + + . +

+
+ +
+ + NEII Viewer + + + + NEII Viewer + + +

+ The National Environmental Information Infrastructure (NEII) is an + information platform designed to improve discovery, access and re-use + of nationally significant environmental data. More information on the + NEII is available here:{" "} + + neii.gov.au/data-viewer + + . +

+
+ +
+ + AURIN Map + + + + AURIN Map + + +

+ AURIN Map provides access to datasets on urban infrastructure for + urban researchers, policy and decision makers. +

+
+
+ ); } RelatedMaps.propTypes = { - viewState: PropTypes.object.isRequired, - smallScreen: PropTypes.bool + viewState: PropTypes.object.isRequired, + smallScreen: PropTypes.bool }; -export default RelatedMaps; \ No newline at end of file +export default RelatedMaps; diff --git a/lib/Views/UserInterface.jsx b/lib/Views/UserInterface.jsx index 90705ad37..44cc194f0 100644 --- a/lib/Views/UserInterface.jsx +++ b/lib/Views/UserInterface.jsx @@ -1,46 +1,59 @@ -import { Menu, Nav, ExperimentalMenu } from 'terriajs/lib/ReactViews/StandardUserInterface/customizable/Groups'; -import MeasureTool from 'terriajs/lib/ReactViews/Map/Navigation/MeasureTool'; -import MenuItem from 'terriajs/lib/ReactViews/StandardUserInterface/customizable/MenuItem'; -import PropTypes from 'prop-types'; -import React from 'react'; -import RelatedMaps from './RelatedMaps'; -import SplitPoint from 'terriajs/lib/ReactViews/SplitPoint'; -import StandardUserInterface from 'terriajs/lib/ReactViews/StandardUserInterface/StandardUserInterface.jsx'; -import version from '../../version'; +import { + Menu, + Nav, + ExperimentalMenu +} from "terriajs/lib/ReactViews/StandardUserInterface/customizable/Groups"; +import MeasureTool from "terriajs/lib/ReactViews/Map/Navigation/MeasureTool"; +import MenuItem from "terriajs/lib/ReactViews/StandardUserInterface/customizable/MenuItem"; +import PropTypes from "prop-types"; +import React from "react"; +import RelatedMaps from "./RelatedMaps"; +import SplitPoint from "terriajs/lib/ReactViews/SplitPoint"; +import StandardUserInterface from "terriajs/lib/ReactViews/StandardUserInterface/StandardUserInterface.jsx"; +import version from "../../version"; -import './global.scss'; +import "./global.scss"; function loadAugmentedVirtuality(callback) { - require.ensure('terriajs/lib/ReactViews/Map/Navigation/AugmentedVirtualityTool', () => { - const AugmentedVirtualityTool = require('terriajs/lib/ReactViews/Map/Navigation/AugmentedVirtualityTool'); - callback(AugmentedVirtualityTool); - }, 'AugmentedVirtuality'); + require.ensure( + "terriajs/lib/ReactViews/Map/Navigation/AugmentedVirtualityTool", + () => { + const AugmentedVirtualityTool = require("terriajs/lib/ReactViews/Map/Navigation/AugmentedVirtualityTool"); + callback(AugmentedVirtualityTool); + }, + "AugmentedVirtuality" + ); } function isBrowserSupportedAV() { - return /Android|iPhone|iPad/i.test(navigator.userAgent); + return /Android|iPhone|iPad/i.test(navigator.userAgent); } export default function UserInterface(props) { - return ( - - - - - - - - - - - - - ); + return ( + + + + + + + + + + + + + ); } UserInterface.propTypes = { - terria: PropTypes.object, - viewState: PropTypes.object + terria: PropTypes.object, + viewState: PropTypes.object }; diff --git a/lib/Views/global.scss b/lib/Views/global.scss index 412c140ea..271d493c7 100644 --- a/lib/Views/global.scss +++ b/lib/Views/global.scss @@ -2,21 +2,21 @@ @import "~terriajs/lib/Sass/global/global"; body { - margin: 0; - overflow: hidden; + margin: 0; + overflow: hidden; } :global { - @media print { - .nationalmap-print-disclaimer { - color: #000; - display: block; - } + @media print { + .nationalmap-print-disclaimer { + color: #000; + display: block; } + } - // To customise the look of your Terria Map, uncomment this section and make changes to your heart's content - // You will also want to uncomment and change values in lib/Styles/variables.scss - /* + // To customise the look of your Terria Map, uncomment this section and make changes to your heart's content + // You will also want to uncomment and change values in lib/Styles/variables.scss + /* // Import any custom fonts here //@import url(https://fonts.googleapis.com/css?family=Josefin+Sans:300,400,700); @@ -152,5 +152,4 @@ body { color:$color-secondary; } */ - -} \ No newline at end of file +} diff --git a/lib/Views/related-maps.scss b/lib/Views/related-maps.scss index aefc788e2..fe0ffa5c4 100644 --- a/lib/Views/related-maps.scss +++ b/lib/Views/related-maps.scss @@ -5,7 +5,7 @@ } .section { - composes: clearfix from '~terriajs/lib/Sass/common/_base.scss'; + composes: clearfix from "~terriajs/lib/Sass/common/_base.scss"; margin-bottom: 10px; padding: 0; } @@ -19,5 +19,5 @@ } .link { - composes: link from '~terriajs/lib/Sass/common/_base.scss'; -} \ No newline at end of file + composes: link from "~terriajs/lib/Sass/common/_base.scss"; +} diff --git a/lib/Views/render.jsx b/lib/Views/render.jsx index 8a8afc37c..21522be85 100644 --- a/lib/Views/render.jsx +++ b/lib/Views/render.jsx @@ -1,25 +1,24 @@ -import ReactDOM from 'react-dom'; -import RedBox from 'redbox-react'; -import React from 'react'; +import ReactDOM from "react-dom"; +import RedBox from "redbox-react"; +import React from "react"; export default function renderUi(terria, allBaseMaps, viewState) { let render = () => { - const UI = require('./UserInterface').default; - ReactDOM.render(, document.getElementById('ui')); + const UI = require("./UserInterface").default; + ReactDOM.render( + , + document.getElementById("ui") + ); }; if (module.hot && process.env.NODE_ENV !== "production") { // Support hot reloading of components // and display an overlay for runtime errors const renderApp = render; - const renderError = (error) => { + const renderError = error => { console.error(error); console.error(error.stack); - ReactDOM.render( - , - document.getElementById('ui') - ); + ReactDOM.render(, document.getElementById("ui")); }; render = () => { try { @@ -28,10 +27,10 @@ export default function renderUi(terria, allBaseMaps, viewState) { renderError(error); } }; - module.hot.accept('./UserInterface', () => { + module.hot.accept("./UserInterface", () => { setTimeout(render); }); } render(); -} \ No newline at end of file +} From 0b046c346ace4bd96b654ec8b17f1f2d6c3cdc39 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Thu, 6 Jun 2019 11:27:11 +1000 Subject: [PATCH 06/17] Move prerendered routes into /prerender/ --- .gitignore | 1 + buildprocess/generate-init-routes.js | 34 ++++++++++++++----- buildprocess/webpack.config.js | 49 ++++++++++++++++------------ 3 files changed, 55 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index ca012eda8..38291549d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ .idea/ wwwroot/build/ wwwroot/doc/ +wwwroot/prerendered/ npm-debug.log version.js wwwroot/init/nm.json diff --git a/buildprocess/generate-init-routes.js b/buildprocess/generate-init-routes.js index b31ba6ecb..67d79d300 100644 --- a/buildprocess/generate-init-routes.js +++ b/buildprocess/generate-init-routes.js @@ -1,19 +1,20 @@ var fs = require("fs"); var path = require("path"); +var URI = require("urijs"); +var CATALOG_ROUTE = require("terriajs/lib/ReactViewModels/TerriaRouting").CATALOG_ROUTE; const rootGroupName = "Root Group"; -const getNameFromItem = item => item.id || item.name; +const getNameFromItem = item => item.name; +const getIdFromItem = item => item.id; -const resUrl = url => - path.resolve(__dirname, "..", "wwwroot", "init", `${url}.json`); - -const getCatalogFromInitName = initName => resUrl(initName); const getRoutes = (topCatalogItem, currentRoute = rootGroupName) => topCatalogItem.reduce((acc, catalogItem) => { const nameForCurrentItem = getNameFromItem(catalogItem); - const finalRoute = `${currentRoute}/${nameForCurrentItem}`; + // Id is used for uniqueid, so disregard any pathing + const idFromItem = getIdFromItem(catalogItem); + const finalRoute = idFromItem || `${currentRoute}/${nameForCurrentItem}`; const items = catalogItem.items && getRoutes(catalogItem.items, finalRoute); if (items) { @@ -21,15 +22,30 @@ const getRoutes = (topCatalogItem, currentRoute = rootGroupName) => } return [...acc, finalRoute]; }, []); - +/** + * Given an array of init names for files in wwwroot/init/, traverse the catalog + * and generate a list of routes to be prerendered at build time + * + * @param {Array} initUrls + */ function generateRoutes(initUrls) { - return initUrls.reduce((acc, initName) => { + const resUrl = url => + path.resolve(__dirname, "..", "wwwroot", "init", `${url}.json`); + + const getCatalogFromInitName = initName => resUrl(initName); + + const routesFromInitCatalogs = initUrls.reduce((acc, initName) => { const fsPathForInit = getCatalogFromInitName(initName); const data = fs.readFileSync(fsPathForInit, "utf8"); const literal = JSON.parse(data).catalog; - return [...acc, ...getRoutes(literal, rootGroupName)]; + return [...acc, ...getRoutes(literal, `${rootGroupName}`)]; }, []); + + const encodedRoutes = routesFromInitCatalogs.map(route => `${CATALOG_ROUTE}${URI.encode(route)}`); + + // Make sure we also prerender /catalog/ incase user reloads on it? or serve up in terriajs server? + return [CATALOG_ROUTE, ...encodedRoutes]; } module.exports = generateRoutes; diff --git a/buildprocess/webpack.config.js b/buildprocess/webpack.config.js index 757588bec..eb9723cd6 100644 --- a/buildprocess/webpack.config.js +++ b/buildprocess/webpack.config.js @@ -1,12 +1,14 @@ 'use strict'; /*global require*/ +var fs = require('fs'); var configureWebpackForTerriaJS = require('terriajs/buildprocess/configureWebpack'); var MiniCssExtractPlugin = require('mini-css-extract-plugin'); var generateRoutes = require("./generate-init-routes"); var PrerenderSPAPlugin = require("prerender-spa-plugin"); var Renderer = PrerenderSPAPlugin.PuppeteerRenderer; var path = require('path'); +var json5 = require("json5"); module.exports = function(devMode, hot) { var config = { @@ -103,26 +105,7 @@ module.exports = function(devMode, hot) { ] }, plugins: [ - new MiniCssExtractPlugin({filename: "TerriaMap.css", disable: hot, ignoreOrder: true, allChunks: true}), - new PrerenderSPAPlugin({ - staticDir: path.resolve(__dirname, '..', "wwwroot/"), - indexPath: path.resolve(__dirname, '..', "wwwroot/", 'index_prerender.html'), - // routes: [ - // "/", - // "/catalog/", - // "/catalog/Root%20Group%2FExample%20Datasets%2FChart%20examples%2FStar%20Stations", - // "/catalog/Root%20Group%2FExample%20Datasets%2FChart%20examples%2FTime%20series", - // ], - // routes: generateRoutes(require('../wwwroot/config.json')), - routes: generateRoutes(["terria"]), - renderer: new Renderer({ - // renderAfterDocumentEvent: 'some terria catalog loaded event', - // renderAfterElementExists: 'some element? instead of event?', - // renderAfterTime: 5000, - maxConcurrentRoutes: 4, - // headless: false, // set to false for debugging - }), - }), + new MiniCssExtractPlugin({filename: "TerriaMap.css", disable: hot, ignoreOrder: true, allChunks: true}) ], resolve: { alias: {}, @@ -130,5 +113,31 @@ module.exports = function(devMode, hot) { } }; config.resolve.alias['terriajs-variables'] = require.resolve('../lib/Styles/variables.scss'); + + if (!devMode) { + var configJsonPath = fs.readFileSync(path.resolve(__dirname, '..','wwwroot', 'config.json'), 'utf8'); + var configJson = json5.parse(configJsonPath); + var prerenderRoutes = + (configJson && + configJson.initializationUrls && + configJson.initializationUrls.length > 0 && + generateRoutes(configJson.initializationUrls)) || + []; + console.log('The following routes generated from config.json\'s initializationUrls will be prerendered:'); + console.log(prerenderRoutes); + config.plugins = [...config.plugins, new PrerenderSPAPlugin({ + staticDir: path.resolve(__dirname, '..', 'wwwroot', ), + outputDir: path.resolve(__dirname, '..', 'wwwroot', 'prerendered'), + indexPath: path.resolve(__dirname, '..', 'wwwroot', 'index_prerender.html'), + routes: prerenderRoutes, + renderer: new Renderer({ + // renderAfterDocumentEvent: 'some terria catalog loaded event', + // renderAfterElementExists: 'some element? instead of event?', + renderAfterTime: 13000, + maxConcurrentRoutes: 8, + // headless: false, // set to false for debugging + }), + })]; + } return configureWebpackForTerriaJS(path.dirname(require.resolve('terriajs/package.json')), config, devMode, hot, MiniCssExtractPlugin); }; From 5c1ff17ab45619ddee9522e0e564ac4c810b81a6 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Thu, 6 Jun 2019 12:37:14 +1000 Subject: [PATCH 07/17] Ensure there are no multiple meta description tags --- wwwroot/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wwwroot/index.html b/wwwroot/index.html index ea51a55f6..b194eba4e 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -5,7 +5,7 @@ - + From 3ae279e24bcf4796ced7b4fd7cd1c668f75eb044 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Thu, 6 Jun 2019 12:40:32 +1000 Subject: [PATCH 08/17] Remove seperate prerender index to ejs --- devserverconfig.json | 2 ++ gulpfile.js | 8 ++++++++ wwwroot/{index_prerender.html => index.ejs} | 6 +++--- 3 files changed, 13 insertions(+), 3 deletions(-) rename wwwroot/{index_prerender.html => index.ejs} (94%) diff --git a/devserverconfig.json b/devserverconfig.json index c42498ddf..a34226cd1 100644 --- a/devserverconfig.json +++ b/devserverconfig.json @@ -1,6 +1,8 @@ { "port": 3001, + "baseHref": "/", + "allowProxyFor" : [ "nicta.com.au", "gov.au", diff --git a/gulpfile.js b/gulpfile.js index 800971262..ddd430fd1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -250,6 +250,14 @@ function mergeConfigs(original, override) { gulp.task('render-datasource-templates', function(done) { var ejs = require('ejs'); var JSON5 = require('json5'); + var serverConfig = JSON5.parse(fs.readFileSync('devserverconfig.json', 'utf8')); + + var index = fs.readFileSync('wwwroot/index.ejs', 'utf8'); + var baseHrefFromConfig = serverConfig.baseHref; + var indexResult = ejs.render(index, { baseHref: baseHrefFromConfig || "/"}); + + fs.writeFileSync(path.join('wwwroot', 'index.html'), new Buffer(indexResult)); + var templateDir = 'datasources'; try { fs.accessSync(templateDir); diff --git a/wwwroot/index_prerender.html b/wwwroot/index.ejs similarity index 94% rename from wwwroot/index_prerender.html rename to wwwroot/index.ejs index ea51a55f6..c91bcdf60 100644 --- a/wwwroot/index_prerender.html +++ b/wwwroot/index.ejs @@ -1,11 +1,11 @@ - + - + @@ -37,6 +37,6 @@
- + From b67a03fa3ea91c7deb72c01abca1372e4fa0facc Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Thu, 6 Jun 2019 16:19:49 +1000 Subject: [PATCH 09/17] Update proper path for index --- buildprocess/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildprocess/webpack.config.js b/buildprocess/webpack.config.js index eb9723cd6..59722c753 100644 --- a/buildprocess/webpack.config.js +++ b/buildprocess/webpack.config.js @@ -128,7 +128,7 @@ module.exports = function(devMode, hot) { config.plugins = [...config.plugins, new PrerenderSPAPlugin({ staticDir: path.resolve(__dirname, '..', 'wwwroot', ), outputDir: path.resolve(__dirname, '..', 'wwwroot', 'prerendered'), - indexPath: path.resolve(__dirname, '..', 'wwwroot', 'index_prerender.html'), + indexPath: path.resolve(__dirname, '..', 'wwwroot', 'index.html'), routes: prerenderRoutes, renderer: new Renderer({ // renderAfterDocumentEvent: 'some terria catalog loaded event', From d6da6aa04b007e496b46cd6719ce0cf2326b44bb Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Thu, 6 Jun 2019 16:48:10 +1000 Subject: [PATCH 10/17] wip remote stash --- deploy/docker/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile index 85813c388..648e3c19d 100644 --- a/deploy/docker/Dockerfile +++ b/deploy/docker/Dockerfile @@ -2,6 +2,8 @@ FROM node:8 RUN apt-get update && apt-get install -y gdal-bin +RUN apt-get -qq -y install gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget + RUN mkdir -p /usr/src/app && mkdir -p /etc/config/client WORKDIR /usr/src/app/component From 253162db2fb7ad342c4188621be4d4dd743fc331 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Wed, 19 Jun 2019 17:54:22 +1000 Subject: [PATCH 11/17] Add sitemap generator --- buildprocess/generate-terria-sitemap.js | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 buildprocess/generate-terria-sitemap.js diff --git a/buildprocess/generate-terria-sitemap.js b/buildprocess/generate-terria-sitemap.js new file mode 100644 index 000000000..de6a0379a --- /dev/null +++ b/buildprocess/generate-terria-sitemap.js @@ -0,0 +1,35 @@ +const generateUrl = (loc, lastmod, changefreq, priority) => (` + + ${loc} + ${lastmod} + ${changefreq} + ${priority} + +`); + +/** + * Generate a sitemap to be written out during build + * + * @param {string} baseUrl absolute URL to where your map is going to be deployed to, with a trailing slash + * @param {array} catalogRoutes list of routes, e.g. ['/catalog', '/catalog/someId'] + */ +const generateTerriaSitemap = (baseUrl, catalogRoutes) => { + if (typeof baseUrl !== 'string') { + throw 'baseUrl passed to generateTerriaSitemap is not a string?'; + } + if (baseUrl.substr(0,4) !== 'http') { + throw 'baseUrl does not look absolute, check that it begins with http or https'; + } + const baseUrlWithoutTrailingSlash = (baseUrl.substr(-1) === '/') ? baseUrl.slice(0,-1) : baseUrl; + const date = new Date().toISOString().substr(0, 10); + + const start = ''; + const urlsetStart = ''; + const urlsetEnd = ``; + const homeUrl = generateUrl(baseUrl, date, 'daily', '0.9'); + const routeUrls = catalogRoutes.map(route => generateUrl(`${baseUrlWithoutTrailingSlash}${route}`, date, 'weekly', '0.5')); + + return `${start}${urlsetStart}${homeUrl}${routeUrls.join('')}${urlsetEnd}`; +}; + +module.exports = generateTerriaSitemap; From 4f525fcb7398e48373dda7c66b2e2546ebc8e00a Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Thu, 20 Jun 2019 19:29:51 +1000 Subject: [PATCH 12/17] Add sitemap generation --- .gitignore | 1 + buildprocess/webpack.config.js | 28 +++++++++++++++++++++++----- wwwroot/config.json | 4 ++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 38291549d..97267eb02 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ datasources/00_National_Data_Sets.json /error.log /output.log privateserverconfig.json +wwwroot/sitemap.xml wwwroot/privateconfig.json deploy/packages/ deploy/work/ diff --git a/buildprocess/webpack.config.js b/buildprocess/webpack.config.js index 59722c753..5837de9a9 100644 --- a/buildprocess/webpack.config.js +++ b/buildprocess/webpack.config.js @@ -5,6 +5,7 @@ var fs = require('fs'); var configureWebpackForTerriaJS = require('terriajs/buildprocess/configureWebpack'); var MiniCssExtractPlugin = require('mini-css-extract-plugin'); var generateRoutes = require("./generate-init-routes"); +var generateTerriaSitemap = require("./generate-terria-sitemap"); var PrerenderSPAPlugin = require("prerender-spa-plugin"); var Renderer = PrerenderSPAPlugin.PuppeteerRenderer; var path = require('path'); @@ -118,13 +119,30 @@ module.exports = function(devMode, hot) { var configJsonPath = fs.readFileSync(path.resolve(__dirname, '..','wwwroot', 'config.json'), 'utf8'); var configJson = json5.parse(configJsonPath); var prerenderRoutes = - (configJson && - configJson.initializationUrls && - configJson.initializationUrls.length > 0 && - generateRoutes(configJson.initializationUrls)) || - []; + (configJson && + configJson.initializationUrls && + configJson.initializationUrls.length > 0 && + generateRoutes(configJson.initializationUrls)) || + []; + var appBaseUrl = + (configJson && + configJson.appBaseUrl && + configJson.appBaseUrl.length > 0 && + configJson.appBaseUrl); + console.log('The following routes generated from config.json\'s initializationUrls will be prerendered:'); console.log(prerenderRoutes); + + if (appBaseUrl) { + try { + var sitemap = generateTerriaSitemap(appBaseUrl, prerenderRoutes); + var sitemapPath = path.resolve(__dirname, '..', 'wwwroot', 'sitemap.xml'); + fs.writeFileSync(sitemapPath, new Buffer(sitemap)); + console.log('Wrote out sitemap to: ' + sitemapPath); + } catch (e) { + console.error("Couldn't generate sitemap?", e); + } + } config.plugins = [...config.plugins, new PrerenderSPAPlugin({ staticDir: path.resolve(__dirname, '..', 'wwwroot', ), outputDir: path.resolve(__dirname, '..', 'wwwroot', 'prerendered'), diff --git a/wwwroot/config.json b/wwwroot/config.json index e304798fd..9d81e074d 100644 --- a/wwwroot/config.json +++ b/wwwroot/config.json @@ -4,6 +4,10 @@ "terria" ], parameters: { + // For sitemap.xml generation, specify the protocol + fully qualified domain + // name + path of where you'll be serving your site, e.g.: + appBaseUrl: "https://nationalmap.gov.au/", + googleUrlShortenerKey: null, googleAnalyticsKey: null, googleAnalyticsOptions: null, From 9f5de411dbaadc3e82c3faf6acf5c00822f2b2ea Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Fri, 21 Jun 2019 17:56:18 +1000 Subject: [PATCH 13/17] Fix sitemap generation, speed up prerendering Also remove appBaseUrl default --- buildprocess/webpack.config.js | 16 +++++++++------- wwwroot/config.json | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/buildprocess/webpack.config.js b/buildprocess/webpack.config.js index 5837de9a9..c329c283d 100644 --- a/buildprocess/webpack.config.js +++ b/buildprocess/webpack.config.js @@ -126,15 +126,17 @@ module.exports = function(devMode, hot) { []; var appBaseUrl = (configJson && - configJson.appBaseUrl && - configJson.appBaseUrl.length > 0 && - configJson.appBaseUrl); + configJson.parameters && + configJson.parameters.appBaseUrl && + configJson.parameters.appBaseUrl.length > 0 && + configJson.parameters.appBaseUrl); console.log('The following routes generated from config.json\'s initializationUrls will be prerendered:'); console.log(prerenderRoutes); if (appBaseUrl) { try { + console.log('Attempting to write sitemap with appBaseUrl: ', appBaseUrl); var sitemap = generateTerriaSitemap(appBaseUrl, prerenderRoutes); var sitemapPath = path.resolve(__dirname, '..', 'wwwroot', 'sitemap.xml'); fs.writeFileSync(sitemapPath, new Buffer(sitemap)); @@ -142,6 +144,8 @@ module.exports = function(devMode, hot) { } catch (e) { console.error("Couldn't generate sitemap?", e); } + } else { + console.warn("Warning - no appBaseUrl specified, no sitemap will be generated.") } config.plugins = [...config.plugins, new PrerenderSPAPlugin({ staticDir: path.resolve(__dirname, '..', 'wwwroot', ), @@ -149,10 +153,8 @@ module.exports = function(devMode, hot) { indexPath: path.resolve(__dirname, '..', 'wwwroot', 'index.html'), routes: prerenderRoutes, renderer: new Renderer({ - // renderAfterDocumentEvent: 'some terria catalog loaded event', - // renderAfterElementExists: 'some element? instead of event?', - renderAfterTime: 13000, - maxConcurrentRoutes: 8, + renderAfterDocumentEvent: 'prerender-end', + maxConcurrentRoutes: 12, // headless: false, // set to false for debugging }), })]; diff --git a/wwwroot/config.json b/wwwroot/config.json index 9d81e074d..23e129935 100644 --- a/wwwroot/config.json +++ b/wwwroot/config.json @@ -6,7 +6,7 @@ parameters: { // For sitemap.xml generation, specify the protocol + fully qualified domain // name + path of where you'll be serving your site, e.g.: - appBaseUrl: "https://nationalmap.gov.au/", + // appBaseUrl: "https://nationalmap.gov.au/", googleUrlShortenerKey: null, googleAnalyticsKey: null, From 81b96163ae5cd7192851b50fea731d8c87e966c7 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Mon, 24 Jun 2019 20:01:01 +1000 Subject: [PATCH 14/17] Use named export --- lib/Views/UserInterface.jsx | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Views/UserInterface.jsx b/lib/Views/UserInterface.jsx index 44cc194f0..2a99f6fe3 100644 --- a/lib/Views/UserInterface.jsx +++ b/lib/Views/UserInterface.jsx @@ -9,7 +9,7 @@ import PropTypes from "prop-types"; import React from "react"; import RelatedMaps from "./RelatedMaps"; import SplitPoint from "terriajs/lib/ReactViews/SplitPoint"; -import StandardUserInterface from "terriajs/lib/ReactViews/StandardUserInterface/StandardUserInterface.jsx"; +import { StandardUserInterface } from "terriajs/lib/ReactViews/StandardUserInterface/StandardUserInterface.jsx"; import version from "../../version"; import "./global.scss"; diff --git a/package.json b/package.json index 8bfe5114d..622923689 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "semver": "^5.0.0", "style-loader": "^0.23.1", "svg-sprite-loader": "4.1.3", - "terriajs": "7.6.2", + "terriajs": "7.6.3", "terriajs-catalog-editor": "^0.2.0", "terriajs-cesium": "1.58.1", "terriajs-schema": "latest", From f1a4ebc9fdedbd7bc369ea4357e3c66791373533 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Tue, 25 Jun 2019 18:49:57 +1000 Subject: [PATCH 15/17] Make sure disclaimer gets shown on top, on load --- entry.js | 25 ++++++++++++++++++++++--- lib/Styles/loader.css | 4 +--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/entry.js b/entry.js index ef714c98d..46f39095a 100644 --- a/entry.js +++ b/entry.js @@ -13,6 +13,19 @@ function loadMainScript() { } function createLoader() { + // We only want this briefly so the explorer-window modal can be displayed + // until we load in other modal-like-things like disclaimer windows, + // but also other notification windows like error messages + // So, reset it back to app defaults after + const catalogzIndexOverride = document.createElement('style'); + catalogzIndexOverride.setAttribute('type', 'text/css'); + catalogzIndexOverride.innerHTML = ` + .tjs-explorer-window__modal-wrapper { + z-index:10000 !important; + } + `; + document.body.appendChild(catalogzIndexOverride); + const loaderDiv = document.createElement('div'); loaderDiv.classList.add("loader-ui"); const loaderGif = document.createElement('img'); @@ -34,10 +47,16 @@ function createLoader() { loadMainScript().catch(() => { // Ignore errors and try to show the map anyway }).then(() => { - loaderDiv.classList.add('loader-ui-hide'); - setTimeout(()=> { + const removeLoaderElements = () => { document.body.removeChild(loaderDiv); - }, 2000); + document.body.removeChild(catalogzIndexOverride); + }; + loaderDiv.classList.add('loader-ui-hide'); + setTimeout(() => document.body.removeChild(catalogzIndexOverride), 300); + loaderDiv.addEventListener('transitionend', removeLoaderElements); + // also fallback with setTimeout here + // so we can remove the elements anyway in case of transitionend event failure + setTimeout(removeLoaderElements, 2000); }); } diff --git a/lib/Styles/loader.css b/lib/Styles/loader.css index 6e2fa393d..2cde8699f 100644 --- a/lib/Styles/loader.css +++ b/lib/Styles/loader.css @@ -1,6 +1,3 @@ - .tjs-explorer-window__modal-wrapper { - z-index:10000 !important; - } .loader-ui-right img{ display: block; margin: calc(50vh - 150px) auto; @@ -47,6 +44,7 @@ .loader-ui{ transition: opacity, 2s; + transition-timing-function: cubic-bezier(.2,1.22,.83,.89); opacity: 1; height: 100vh; width: 100vw; From 8704431fc0f24fb8d1d08be492fb0050dea34e2d Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Wed, 26 Jun 2019 10:59:52 +1000 Subject: [PATCH 16/17] Use safer puppeteer concurrent route # --- buildprocess/webpack.config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/buildprocess/webpack.config.js b/buildprocess/webpack.config.js index c329c283d..2d9ff3462 100644 --- a/buildprocess/webpack.config.js +++ b/buildprocess/webpack.config.js @@ -153,8 +153,9 @@ module.exports = function(devMode, hot) { indexPath: path.resolve(__dirname, '..', 'wwwroot', 'index.html'), routes: prerenderRoutes, renderer: new Renderer({ - renderAfterDocumentEvent: 'prerender-end', - maxConcurrentRoutes: 12, + renderAfterDocumentEvent: 'prerender-end', + // If you run out of memory, try a lower value here + maxConcurrentRoutes: 8, // headless: false, // set to false for debugging }), })]; From fcdb65541e109715b4f66bc9150b1429e8f69ec5 Mon Sep 17 00:00:00 2001 From: Wing Ho Date: Wed, 26 Jun 2019 11:04:46 +1000 Subject: [PATCH 17/17] Update travis for prerender test --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index f995813f3..41920ac80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,15 @@ language: node_js +dist: trusty +addons: + apt: + packages: + - libnss3 node_js: - '8' script: - gulp lint release env: - NODE_OPTIONS=--max_old_space_size=2048 +before_install: + # Enable user namespace cloning + - "sysctl kernel.unprivileged_userns_clone=1"