Developer Setup🔗
This describes how to set up the local development environment.
System Requirements🔗
If you are behind a proxy there are several things to do. In Linux/macOS several settings are required (e.g: wget, curl, git, pip, npm, /etc/enviroment....). Mostly in Windows you can set it once at the 'Enviroment Variables'. But the Linux tools (e.g Git Bash) you are using on Windows don't know them. So check where to set proxy setting for the program you are using. Here are also some hints:
Git🔗
Install git.
The git installation path (C:\Program Files\Git\bin\
by default) must be added to the system-wide PATH environment variable.
Firewall issues (optional)🔗
The git protocol may be blocked by firewalls. Should this be an issue, configure git to use https instead.
Git proxy (optional)🔗
If you're working from behind a corporate proxy, you may need to configure a proxy for both the normal and admin shell that is started with administrative rights.
$ git config --global http.proxy <proxy-url:port>
$ git config --global https.proxy <proxy-url:port>
Node.js🔗
Install Node.js.
The Node Package Manager (NPM) comes bundled with your Node.js installation. Please test the correct installation of these tools by executing node -v
and npm -v
in your command line; results should look like this:
Npm can be configured via command line. Configuration entries are added to the file C:\Users\<user>\.npmrc
that may also be edited directly. To view your complete configuration, run these lines:
Cache configuration (optional)🔗
Npm will use a package cache to avoid overly reloading packages. By default, this cache is in C:\Users\<user>\AppData\Roaming\npm-cache
. Depending on your system, this folder may be synchronized within a roaming profile and slow down the process of logging in/out. In such circumstances it is advised to change the cache path by either editing the .npmrc
file, or via cmd
and cmd
with administrator rights with e.g. this line:
Proxy configuration (optional)🔗
Only relevant when a proxy is in use.
Run in cmd
:
Windows and *nix platforms (incl. e.g Git-Bash, WSL) for YOUR User. Saves in
~/.npmrc
by default:
Windows cmd
with administrative rights these lines
For changes to take effect, close and reopen all your command lines. The setx
lines will also add the proxies to your system variables. Please mind that other tools reading these variables may be affected.
Globally install npm packages with administrative rights (optional)🔗
Some npm packages for the setup require global admin installation to be runnable via command line with your user account. To prepare this step, run a cmd
with administrative rights:
⚠️ Please determine the correct system path before running this line. The example path is taken from a german Windows 10 installation.
Globally installed packages will be stored in that path. For more information refer to the npm folder documentation.
Masterportal Installation🔗
Open a Git Bash shell with administrative rights and navigate to the folder in which you want to clone the repository.
$ git clone https://bitbucket.org/geowerkstatt-hamburg/masterportal.git
$ cd masterportal
Now all npm dependencies are installed.
In case add-ons are to be used, please refer to the add-ons documentation for further assistance.
Python Dependencies🔗
The documentation of this software is generated with mkdocs-material, a tool written in Python. To prevent conflicts between Python packages on the system and project level, a virtual environment (venv) is recommended.
- Run
python -m venv .venv
in the root folder of the cloned project to create a new virtual Python environment. - Activate the venv by running either
source .venv/bin/activate
on Linux orcall .venv/Scripts/activate.bat
on Windows. - Now run
pip install -r .\python-dependencies.txt
to install the required Python packages. You may need to pass a proxy configuration to pip if you are behind a corporate firewall.
npm Commands🔗
npm start
🔗
This command starts a local development server.
- After compilation, you may open the following links for comprehensive demo applications:
- https://localhost:9001/portal/basic A portal with a simple configuration
- https://localhost:9001/portal/master Simple topic tree
- https://localhost:9001/portal/auto Default topic tree loading all WMS layers from the
services.json
file
npm run test
🔗
Executes unit tests. This also includes the unit tests of add-ons.
⚠️ If not available, the folder
portalconfigs/test
must be created. The test runner will also execute all tests in this folder.
- bundles all tests
- logs unit test results to the console
- after changing tested code or unit tests, the command
npm run test
must be re-run
npm run build
🔗
Creates the distributable source folder for all portals, ready for publication.
The created files are stored in the dist folder. The folder will be created automatically in the Masterportal folder root. The source code is bundled within the Mastercode folder with the current version.
npm run buildExamples
🔗
Creates a build from the example folder.
The produced examples.zip
and examples-x.x.x.zip
(versioned) both contain runnable Masterportal instances (Basic) including a resources folder.
Updating Dependencies🔗
This task belongs to the owner/ package maintainers. If you don't know: Dont call the command.
To update all NPM packages, run
Please refer to the npm update documentation on how caret and tilde prefixes to versions in the package.json
are handled by this step.
Set up debugging in Visual Studio Code🔗
- Install extension Firefox/Chrome-Debugger
- Switch to debugger view
- Open
launch.json
configuration
- Add a new Firefox configuration to the opened
launch.json
file
and/or a Chrome configuration.
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "https://localhost:9001/",
"webRoot": "${workspaceFolder}/build",
},
-
Start server
-
Choose (1) and start (2) a debugger
-
Set a breakpoint