* Use correct path to tool-versions Signed-off-by: Robbert Gurdeep Singh <git@beardhatcode.be> * Add python3 to install steps Signed-off-by: Robbert Gurdeep Singh <git@beardhatcode.be> * Use consistent markdown Signed-off-by: Robbert Gurdeep Singh <git@beardhatcode.be> * Mention that nix-env is for Nix users Signed-off-by: Robbert Gurdeep Singh <git@beardhatcode.be> * Add note on how to install python3 Signed-off-by: Robbert Gurdeep Singh <git@beardhatcode.be>
7.3 KiB
Development and deployment
There are various scripts to help setup MapComplete for deployment and develop-deployment.
This documents attempts to shed some light on these scripts.
Note: these scripts change every now and then - if the documentation here is incorrect or you run into troubles, do leave a message in the issue tracker
Architecture overview
At its core, MapComplete is a static (!) website. There are no servers to host.
The data is fetched from Overpass/OSM/Wikidata/Wikipedia/Mapillary/... and written there directly. This means that any static file server will do to create a self-hosted version of MapComplete.
Development
Windows users: All scripts are made for linux devices. Use the Ubuntu terminal for Windows (or even better - make the switch ;) ). If you are using Visual Studio Code you can use a WSL Remote window, or use the Devcontainer (see more details later).
To develop and build MapComplete, you
- Make a fork and clone the repository. (We recommend a shallow clone with
git clone --filter=blob:none <repo>) - Install
python3if you do not have it already- On linux:
sudo apt install python3 - On windows: find the latest download on the Python Releases for Windows page
- On linux:
- Install the nodejs version specified in /.tool-versions
- On linux: install npm first
sudo apt install npm, then installnusing npm:npm install -g n, which can then install node withn install <node-version> - You can use asdf to manage your runtime versions.
- On linux: install npm first
- Install
npm. Linux:sudo apt install npm(or your favourite package manager), Windows: install nodeJS: https://nodejs.org/en/download/ - Run
npm run initwhich …- runs
npm install - generates some additional dependencies and files
- runs
- Run
npm run startto host a local testversion at http://localhost:1234/index.html - By default, a landing page with available themes is served. In order to load a single theme, use
layout=themenameoruserlayout=true#<layout configuration>as Query parameter. Note that the shorter URLs ( e.g.bookcases.html,aed.html, ...) don't exist on the development version.
Development using Windows
For Windows you can use the devcontainer, or the WSL subsystem.
To use the devcontainer in Visual Studio Code:
- Make sure you have installed the Remote - Containers extension and it's dependencies.
- Make a fork and clone the repository.
- After cloning, Visual Studio Code will ask you if you want to use the devcontainer.
- Then you can either clone it again in a volume (for better performance), or open the current folder in a container.
- By now, you should be able to run
npm run startto host a local testversion at http://localhost:1234/index.html - By default, a landing page with available themes is served. In order to load a single theme, use
layout=themenameoruserlayout=true#<layout configuration>as Query parameter. Note that the shorter URLs ( e.g.bookcases.html,aed.html, ...) don't exist on the development version.
To use the WSL in Visual Studio Code:
- Make sure you have installed the Remote - WSL extension and it's dependencies.
- Open a remote WSL window using the button in the bottom left.
- Make a fork and clone the repository.
- Install
npmusingsudo apt install npm. - Run
npm run initand generate some additional dependencies and generated files. Note that it'll install the dependencies too - Run
npm run startto host a local testversion at http://localhost:1234/index.html - By default, a landing page with available themes is served. In order to load a single theme, use
layout=themenameoruserlayout=true#<layout configuration>as Query parameter. Note that the shorter URLs ( e.g.bookcases.html,aed.html, ...) don't exist on the development version.
Dependencies
make , python3 g++
(Nix users may run nix-env -iA nixos.gnumake nixos.gdc nixos.python3)
Automatic deployment
Currently, the master branch is automatically deployed to 'mapcomplete.osm.be' by a github action.
Every branch is automatically built (upon push) to 'pietervdvn.github.io/mc/' by a github action.
Deploying a fork
A script creates a webpage for every theme automatically, with some customizations in order to:
- to have shorter urls
- have individual social images
- have individual web manifests
This script can be invoked with npm run prepare-deploy
If you want to deploy your fork:
npm run prepare-deploynpm run build- Copy the entire
distfolder to where you host your website. Visitingindex.htmlgives you the landing page, visitingyourwebsite/<theme>should bring you to the appropriate theme.
Weird errors
Try removing node_modules, package-lock.json and .cache
Misc setup
The json-git-merger is used to quickly merge translation
files, documentation here.
This merge driver is broken and would sometimes drop new questions or duplicate them... Not a good idea!
Overview of package.json-scripts
increase-memory: this is a big (and memory-intensive) project to build and run, so we give nodejs some more RAM.start: start a development server.test: run the unit testsinit: Generates and downloads various assets which are needed to compilegenerate:editor-layer-index: downloads the editor-layer-index-json from osmlab.github.iogenerate:images: compiles the SVG's into an assetgenerate:translations: compiles the translation file into a javascript filegenerate:layouts: usesindex.htmlas template to create all the theme index pages. You'll want to runcleanwhen donegenerate:docs: generates various documents, such as information about available metatags, information to put on the OSM-wiki,...generate:report: downloads statistics from OsmCha, compiles neat graphsgenerate:cache:speelplekken: creates an offline copy of all the data required for one specific (paid for) themegenerate:layeroverview: reads all the theme- and layerconfigurations, compiles them into a single JSON.reset:layeroverview: if something is wrong with the layeroverview, creates an empty onegenerate:licenses: compiles all the license info of images into a single jsonoptimize:images: attempts to make smaller pngs - optional to run before a deploymentgenerate: run all the necesary generate-scriptsbuild: actually bundle all the files into a singledist/-folderprepare-deploy: create the layoutsdeploy:staging,deploy:pietervdvn,deploy:production: deploy the latest code on various locationslint: get depressed by the amount of warningsclean: remove some generated files which are annoying in the repo