From 344abbea859cd392d81501d020b8447bb21acf20 Mon Sep 17 00:00:00 2001 From: Christian Neumann Date: Sun, 15 Nov 2020 15:08:09 +0100 Subject: [PATCH] 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": [