Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Makefile #42

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0

CAPELLA_MODEL_EXPLORER_HOST_IP ?= 127.0.0.1
CAPELLA_MODEL_EXPLORER_PORT ?= 8000
MODEL ?= coffee-machine

# NOTE: Keep the 'help' target first, so that 'make' acts like 'make help'
.PHONY: help
help:
@echo 'Available make targets:'
@echo ''
@echo ' run MODEL=/some/model.aird'
@echo ' -- Run the backend with a model'
@echo ' build-frontend -- (Re-)Build the prod frontend files'
@echo ' dev-frontend -- Run the frontend in dev mode'
@echo ' storybook -- Run storybook for frontend development'
@echo ' clean-frontend -- Clean out all built/installed frontend files'

.PHONY: run
run: frontend/dist/static/env.js
sed -i "s|__ROUTE_PREFIX__||g" frontend/dist/static/env.js
MODE=production python frontend/fetch-version.py
python -c "from capellambse_context_diagrams import install_elk; install_elk()"
MODE=production python -m capella_model_explorer.backend "$$MODEL" ./templates

.PHONY: build-frontend
build-frontend: frontend/node_modules
cd frontend && npm run build

.PHONY: dev-frontend
dev-frontend: frontend/node_modules
cd frontend && npm run dev

.PHONY: storybook
storybook: frontend/node_modules
cd frontend && npm run storybook

.PHONY: clean-frontend
clean-frontend:
cd frontend && rm -rf dist node_modules

frontend/dist/static/env.js: frontend/node_modules
cd frontend && npm run build
touch -c frontend/dist/static/env.js

frontend/node_modules: frontend/package.json frontend/package-lock.json
cd frontend && npm install
touch -c frontend/node_modules
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,44 @@ pip install -e '.[docs,test]'
pre-commit install
```

# Front-end development
# Development

To develop the frontend:
This repo contains a Makefile with recipes for a few commonly needed tasks
during development. Run `make help` for more details.

## Developing the frontend

To develop frontend components, run:

```bash
cd frontend
npm install
make storybook
```

then, to develop components `npm run storybook` and to develop the whole app
`npm run dev`
To develop the app as a whole, run:

```bash
make dev-frontend
```

Note that this requires a running backend server, see the next section.

## Backend development

To run the backend, use the following command:

```bash
make run MODEL=../path/to/model.aird
```

This will start the API server on <http://localhost:8000>, where it will serve
the frontend in production mode. These static files can be rebuilt with `make
build-frontend`, although it is usually more convenient to run the frontend in
development mode with `make dev-frontend` (see above).

The MODEL parameter can be set to anything that
[`capellambse.loadcli`](https://dsd-dbs.github.io/py-capellambse/start/specifying-models.html)
understands, but some functionality requires a Git-backed model (e.g. using a
`git+https://` URL).

# Integration in the Capella Collaboration Manager

Expand Down