From 344abbea859cd392d81501d020b8447bb21acf20 Mon Sep 17 00:00:00 2001 From: Christian Neumann Date: Sun, 15 Nov 2020 15:08:09 +0100 Subject: [PATCH 1/5] Fix missing file problem when starting server in fresh repository. --- README.md | 12 ++++++------ createLayouts.ts | 8 +++++++- deploy.sh | 3 --- package.json | 9 ++++++--- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index bb8e6b9..797ba4a 100644 --- a/README.md +++ b/README.md @@ -84,16 +84,16 @@ To develop: 0. Make a fork and clone the repository. 1. Install `npm`. Linux: `sudo apt install npm` (or your favourite package manager), Windows: install nodeJS: https://nodejs.org/en/download/ -2. Run `npm install` to install the dependencies -3. Run `npm run start` to host a local testversion at http://localhost:1234/index.html -4. By default, the 'bookcases'-theme is loaded. In order to load another theme, use `layout=themename` or `userlayout=true#`. Note that the custom URLs (e.g. `bookcases.html`, `aed.html`, ...) _don't_ exist on the development version. (These are automatically generated from a template on the server). +2. Run `npm install` to install the package dependencies +3. Run `npm run generate` to generate some additional dependencies +4. Run `npm run start` to host a local testversion at http://localhost:1234/index.html +5. By default, the 'bookcases'-theme is loaded. In order to load another theme, use `layout=themename` or `userlayout=true#`. Note that the custom URLs (e.g. `bookcases.html`, `aed.html`, ...) _don't_ exist on the development version. (These are automatically generated from a template on the server). To deploy: 0. `rm -rf dist/` to remove the local build -1. `ts-node createLayouts.ts` to generate the custom htmls, (such as `aed.html`, `bookcases.html`) -2. `npm run build` -3. copy the entire `dist` folder to where you host your website. Visiting `index.html` gives you the website +1. `npm run build` +2. Copy the entire `dist` folder to where you host your website. Visiting `index.html` gives you the website ## Translating MapComplete diff --git a/createLayouts.ts b/createLayouts.ts index b32d8c9..8f0711a 100644 --- a/createLayouts.ts +++ b/createLayouts.ts @@ -5,7 +5,7 @@ Img.runningFromConsole = true; UIElement.runningFromConsole = true; import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; -import {readFileSync, writeFile, writeFileSync} from "fs"; +import {existsSync, mkdirSync, readFileSync, writeFile, writeFileSync} from "fs"; import Locale from "./UI/i18n/Locale"; import svg2img from 'promise-svg2img'; import Translations from "./UI/i18n/Translations"; @@ -244,6 +244,12 @@ let wikiPage = "{|class=\"wikitable sortable\"\n" + "! Name, link !! Genre !! Covered region !! Language !! Description !! Free materials !! Image\n" + "|-"; + +const generatedDir = "./assets/generated"; +if (! existsSync(generatedDir)) { + mkdirSync("./assets/generated") +} + for (const layoutName in all) { if (blacklist.indexOf(layoutName.toLowerCase()) >= 0) { console.log(`Skipping a layout with name${layoutName}, it is on the blacklist`); diff --git a/deploy.sh b/deploy.sh index 222470c..e4927a6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,8 +1,5 @@ #! /bin/bash -cd assets/ && wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json -cd .. - mkdir -p assets/generated ts-node createLayouts.ts || { echo 'Creating layouts failed' ; exit 1; } find -name '*.png' | parallel optipng '{}' diff --git a/package.json b/package.json index e4a5655..91ec398 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,12 @@ ] }, "scripts": { - "start": "parcel *.html UI/** Logic/** assets/** vendor/* vendor/*/*", - "generate": "ts-node createLayouts.ts", - "build": "rm -rf dist/ && ts-node generateIncludedImages.ts && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", + "start": "parcel *.html UI/** Logic/** assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", + "generate:editor-layer-index": "cd assets/ && wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json", + "generate:included-images": "ts-node generateIncludedImages.ts", + "generate:layouts": "ts-node createLayouts.ts", + "generate": "npm run generate:included-images && npm run generate:layouts && npm run generate:editor-layer-index", + "build": "rm -rf dist/ npm run generate && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", "test": "ts-node test/*" }, "keywords": [ From a72d0b2abe02577a97441afa71543f925462c68e Mon Sep 17 00:00:00 2001 From: Christian Neumann Date: Sun, 15 Nov 2020 15:13:08 +0100 Subject: [PATCH 2/5] Use variable instead of repeated strings for path. --- createLayouts.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/createLayouts.ts b/createLayouts.ts index 8f0711a..6bd9802 100644 --- a/createLayouts.ts +++ b/createLayouts.ts @@ -247,7 +247,7 @@ let wikiPage = "{|class=\"wikitable sortable\"\n" + const generatedDir = "./assets/generated"; if (! existsSync(generatedDir)) { - mkdirSync("./assets/generated") + mkdirSync(generatedDir) } for (const layoutName in all) { @@ -275,7 +275,7 @@ for (const layoutName in all) { wikiPage += "|}" -writeFile("./assets/generated/wikiIndex", wikiPage, (err) => { +writeFile(generatedDir + "/wikiIndex", wikiPage, (err) => { if (err !== null) { console.log("Could not save wikiindex", err); } From 432ee8c34b86eb0d24079e069a9d6146a83c7271 Mon Sep 17 00:00:00 2001 From: Christian Neumann Date: Sun, 15 Nov 2020 15:33:18 +0100 Subject: [PATCH 3/5] Fix generator text. --- UI/CustomGenerator/CustomGeneratorPanel.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/UI/CustomGenerator/CustomGeneratorPanel.ts b/UI/CustomGenerator/CustomGeneratorPanel.ts index d8c1999..a7c1189 100644 --- a/UI/CustomGenerator/CustomGeneratorPanel.ts +++ b/UI/CustomGenerator/CustomGeneratorPanel.ts @@ -105,10 +105,9 @@ export default class CustomGeneratorPanel extends UIElement { } if (ud.csCount <= State.userJourney.themeGeneratorReadOnlyUnlock) { return new Combine([ - "

Too little experience/h3>", - `Creating your own (readonly) themes can only be done if you have more then ${State.userJourney.themeGeneratorReadOnlyUnlock} changesets made`, - `Making a theme including survey options can be done at ${State.userJourney.themeGeneratorFullUnlock} changesets`, - this.loginButton + "

Too little experience

", + `

Creating your own (readonly) themes can only be done if you have more then ${State.userJourney.themeGeneratorReadOnlyUnlock} changesets made

`, + `

Making a theme including survey options can be done at ${State.userJourney.themeGeneratorFullUnlock} changesets

` ]).Render(); } return this.mainPanel.Render() From 40efa744aa1b6cd6f434824c12277ef3b11771a2 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sun, 15 Nov 2020 16:30:26 +0100 Subject: [PATCH 4/5] Move scripts into package.json --- State.ts | 2 +- clean.sh | 29 ----------------------------- deploy.sh | 39 --------------------------------------- package.json | 9 ++++++++- 4 files changed, 9 insertions(+), 70 deletions(-) delete mode 100755 clean.sh delete mode 100755 deploy.sh diff --git a/State.ts b/State.ts index d76608e..d739d42 100644 --- a/State.ts +++ b/State.ts @@ -22,7 +22,7 @@ export default class State { // The singleton of the global state public static state: State; - public static vNumber = "0.1.2f"; + public static vNumber = "0.1.2g"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/clean.sh b/clean.sh deleted file mode 100755 index e9b039e..0000000 --- a/clean.sh +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/bash - -# clean up the mess we made - # rm *.js - # rm Logic/*.js - # rm Logic/*.js - # rm Logic/*/*.js - # rm Logic/*/*/*.js - # rm UI/*.js - # rm UI/*/*.js - # rm UI/*/*/*.js - # rm Customizations/*.js - # rm Customizations/*/*.js - # rm Customizations/*/*/*.js - -rm *.webmanifest - -# rm assets/generated/* - -for f in ./*.html; do - if [[ "$f" == "./index.html" ]] || [[ "$f" == "./land.html" ]] || [[ "$f" == "./test.html" ]] || [[ "$f" == "./preferences.html" ]] || [[ "$f" == "./customGenerator.html" ]] - then - echo "Not removing $f" - else - rm $f - fi -done - -rm -rf .cache \ No newline at end of file diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index e4927a6..0000000 --- a/deploy.sh +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/bash - -mkdir -p assets/generated -ts-node createLayouts.ts || { echo 'Creating layouts failed' ; exit 1; } -find -name '*.png' | parallel optipng '{}' -npm run build || { echo 'Npm build failed' ; exit 1; } - -rm -rf .cache - -if [[ $1 == "groen" ]] -then - echo "DEPLOYING TO BUURTNATUUR!" - mv /home/pietervdvn/git/buurtnatuur.github.io/CNAME /home/pietervdvn/git/ - mv /home/pietervdvn/git/buurtnatuur.github.io/.git /home/pietervdvn/git/ - rm -rf /home/pietervdvn/git/buurtnatuur.github.io/* - cp -r dist/* /home/pietervdvn/git/buurtnatuur.github.io/ - mv /home/pietervdvn/git/CNAME /home/pietervdvn/git/buurtnatuur.github.io/ - mv /home/pietervdvn/git/.git /home/pietervdvn/git/buurtnatuur.github.io/ - cd /home/pietervdvn/git/buurtnatuur.github.io/ -elif [[ $1 == "production" ]] -then - echo "DEPLOYING TO MAPCOMPLETE" - rm -rf /home/pietervdvn/git/pietervdvn.github.io/MapComplete/* - cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ - cd /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ -else - echo "Testversion deploy" - rm -rf /home/pietervdvn/git/pietervdvn.github.io/Staging/* - cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/Staging/ - cd /home/pietervdvn/git/pietervdvn.github.io/Staging/ -fi - -git add * -git commit -am "New mapcomplete version" -git push -cd - -./clean.sh - -echo "DEPLOYED $1" diff --git a/package.json b/package.json index 91ec398..c40c351 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,19 @@ }, "scripts": { "start": "parcel *.html UI/** Logic/** assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", + "test": "ts-node test/*", "generate:editor-layer-index": "cd assets/ && wget https://osmlab.github.io/editor-layer-index/imagery.geojson --output-document=editor-layer-index.json", "generate:included-images": "ts-node generateIncludedImages.ts", "generate:layouts": "ts-node createLayouts.ts", + "optimize-images": "cd assets/generated/ && find -name '*.png' -exec optipng '{}' \\; && echo 'PNGs are optimized'", "generate": "npm run generate:included-images && npm run generate:layouts && npm run generate:editor-layer-index", "build": "rm -rf dist/ npm run generate && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", - "test": "ts-node test/*" + "prepare-deploy": "npm run generate && npm run build && rm -rf .cache", + "deploy:staging": "npm run prepare-deploy && rm -rf /home/pietervdvn/git/pietervdvn.github.io/Staging/* && cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/Staging/ && cd /home/pietervdvn/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean", + "deploy:production": "npm run prepare-deploy && rm -rf /home/pietervdvn/git/pietervdvn.github.io/MapComplete/* && cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ && cd /home/pietervdvn/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean", + + "clean": "rm *.webmanifest && find *.html | grep -v \"\\(index\\|land\\|test\\|preferences\\|customGenerator\\).html\" | xargs rm" + }, "keywords": [ "OpenStreetMap", From f5218e79e7a267da0b731b646e4a1ddc25b22599 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sun, 15 Nov 2020 16:35:23 +0100 Subject: [PATCH 5/5] Add optimize-images to package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c40c351..712eac5 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "build": "rm -rf dist/ npm run generate && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*", "prepare-deploy": "npm run generate && npm run build && rm -rf .cache", "deploy:staging": "npm run prepare-deploy && rm -rf /home/pietervdvn/git/pietervdvn.github.io/Staging/* && cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/Staging/ && cd /home/pietervdvn/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean", - "deploy:production": "npm run prepare-deploy && rm -rf /home/pietervdvn/git/pietervdvn.github.io/MapComplete/* && cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ && cd /home/pietervdvn/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean", + "deploy:production": "npm run prepare-deploy && npm run optimize-images && rm -rf /home/pietervdvn/git/pietervdvn.github.io/MapComplete/* && cp -r dist/* /home/pietervdvn/git/pietervdvn.github.io/MapComplete/ && cd /home/pietervdvn/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean", "clean": "rm *.webmanifest && find *.html | grep -v \"\\(index\\|land\\|test\\|preferences\\|customGenerator\\).html\" | xargs rm"