From 170cfe8723fb108589ca67e938ce19267bdc30ee Mon Sep 17 00:00:00 2001 From: Robin van der Linde Date: Tue, 5 Jul 2022 15:20:27 +0200 Subject: [PATCH 1/2] Update VScode settings --- Docs/Development_deployment.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Docs/Development_deployment.md b/Docs/Development_deployment.md index 3f5abe7f40..09313fd7df 100644 --- a/Docs/Development_deployment.md +++ b/Docs/Development_deployment.md @@ -55,17 +55,24 @@ Raw installation To use the WSL in Visual Studio Code: -0. Make sure you have installed the [Remote - WSL]() extension and it's dependencies. -1. Open a remote WSL window using the button in the bottom left. -2. Make a fork and clone the repository. -3. Install `npm` using `sudo apt install npm`. -4. Run `npm run init` and generate some additional dependencies and generated files. Note that it'll install the +1. Install a WSL Distribution (e.g. Ubuntu) +2. Install basic dependencies `sudo apt install make g++` +3. Install NVM `wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash` +4. Use NVM to install node 16.x: `nvm install 16.9.1` +5. Activate the node version: `nvm use 16.9.1` +6. Install `npm` using `sudo apt install npm`. +7. Install the [Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension and it's dependencies. +8. Open a remote WSL window using the button in the bottom left. +9. Make a fork and clone the repository. +10. Run `npm run init` and generate some additional dependencies and generated files. Note that it'll install the dependencies too -5. Run `npm run start` to host a local testversion at http://localhost:1234/index.html -6. By default, a landing page with available themes is served. In order to load a single theme, use `layout=themename` +11. Run `npm run start` to host a local testversion at http://localhost:1234/index.html +12. By default, a landing page with available themes is served. In order to load a single theme, use `layout=themename` or `userlayout=true#` as [Query parameter](URL_Parameters.md). Note that the shorter URLs ( e.g. `bookcases.html`, `aed.html`, ...) _don't_ exist on the development version. +To use WSL without Visual Studio Code you can replace steps 7 and 8 by opening up a WSL terminal + Automatic deployment -------------------- From 13579e6c979946796d2de03a9494b88c1ffeb6c7 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Tue, 5 Jul 2022 16:59:40 +0200 Subject: [PATCH 2/2] Fix link in docs, add 'localhost' and gitpod to non-caching version of serviceworkers --- Docs/Making_Your_Own_Theme.md | 2 +- package.json | 4 ++-- service-worker.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Docs/Making_Your_Own_Theme.md b/Docs/Making_Your_Own_Theme.md index 80c27a7f4b..b7c2e349c7 100644 --- a/Docs/Making_Your_Own_Theme.md +++ b/Docs/Making_Your_Own_Theme.md @@ -322,7 +322,7 @@ Every field is documented in the source code itself - you can find them here: - [The top level `LayoutConfig`](https://github.com/pietervdvn/MapComplete/blob/master/Models/ThemeConfig/Json/LayoutConfigJson.ts) - [A layer object `LayerConfig`](https://github.com/pietervdvn/MapComplete/blob/master/Models/ThemeConfig/Json/LayerConfigJson.ts) -- [The `TagRendering`](https://github.com/pietervdvn/MapComplete/blob/master/Models/ThemeConfig/Json/TagRenderingConfigJson.ts) +- [The `TagRendering`](https://github.com/pietervdvn/MapComplete/blob/master/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.ts) - At last, the exact semantics of tags are documented [here](Tags_format.md) A JSON schema file is available in `Docs/Schemas` - use `LayoutConfig.schema.json` to validate a theme file. diff --git a/package.json b/package.json index 05c73c9a0a..58c8dabfa8 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "generate:service-worker": "tsc service-worker.ts && git_hash=$(git rev-parse HEAD) && sed -i \"s/GITHUB-COMMIT/$git_hash/\" service-worker.js", "optimize-images": "cd assets/generated/ && find -name '*.png' -exec optipng '{}' \\; && echo 'PNGs are optimized'", "reset:layeroverview": "echo {\\\"layers\\\":[], \\\"themes\\\":[]} > ./assets/generated/known_layers_and_themes.json && echo {\\\"layers\\\": []} > ./assets/generated/known_layers.json", - "generate": "mkdir -p ./assets/generated ; npm run reset:layeroverview ; npm run generate:images ; npm run generate:charging-stations ; npm run generate:translations ; npm run generate:licenses ; npm run generate:layeroverview ; npm run generate:service-worker", + "generate": "mkdir -p ./assets/generated; npm run reset:layeroverview; npm run generate:images; npm run generate:charging-stations; npm run generate:translations; npm run generate:licenses; npm run generate:layeroverview; npm run generate:service-worker", "generate:charging-stations": "cd ./assets/layers/charging_station && ts-node csvToJson.ts && cd -", "prepare-deploy": "npm run generate:service-worker && ./scripts/build.sh", "gittag": "ts-node scripts/printVersion.ts | bash", @@ -48,7 +48,7 @@ "script": "ts-node", "weblate-merge": "./scripts/automerge-translations.sh", "weblate-add-upstream": "git remote add weblate-github git@github.com:weblate/MapComplete.git", - "weblate-fix": "git remote update weblate-github ; git merge weblate-github/weblate-mapcomplete-core; git merge weblate-github/weblate-mapcomplete-layers ; git merge weblate-github/weblate-mapcomplete-layer-translations", + "weblate-fix": "git remote update weblate-github; git merge weblate-github/weblate-mapcomplete-core; git merge weblate-github/weblate-mapcomplete-layers; git merge weblate-github/weblate-mapcomplete-layer-translations", "weblate-fix-heavy": "git remote rm weblate-layers; git remote add weblate-layers https://hosted.weblate.org/git/mapcomplete/layers/; git remote update weblate-layers; git merge weblate-layers/master", "housekeeping": "npm run generate && npm run generate:docs && npm run generate:contributor-list && git add Docs/* && git commit assets/ langs/ Docs/ -m 'Housekeeping...'", "parseSchools": "ts-node scripts/schools/amendSchoolData.ts", diff --git a/service-worker.ts b/service-worker.ts index 29b69697e7..56e006a4e1 100644 --- a/service-worker.ts +++ b/service-worker.ts @@ -71,7 +71,7 @@ self.addEventListener('fetch', event.respondWith(new Response(JSON.stringify({"service-worker-version": version}))); return } - const shouldBeCached = origin.host === requestUrl.host && origin.host !== "127.0.0.1:1234" + const shouldBeCached = origin.host === requestUrl.host && origin.host !== "127.0.0.1:1234" && origin.host !== "localhost" && !origin.host.endsWith(".gitpod.io") if (!shouldBeCached) { console.log("Not intercepting ", requestUrl.toString(), origin.host, requestUrl.host) // We return _without_ calling event.respondWith, which signals the browser that it'll have to handle it himself