Skip to content

Commit

Permalink
feat: Add a Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuestengecko committed Sep 24, 2024
1 parent 8b00ea9 commit bd281a0
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 6 deletions.
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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

.PHONY: help
help:
@echo 'Available make targets:'
@echo ''
@echo ' run MODEL=/some/model.aird'
@echo ' -- Run the backend with a model'
@echo ' build-frontend -- Build the prod frontend files'
@echo ' dev-frontend -- Run the frontend in dev mode'
@echo ' storybook -- Run storybook for frontend development'

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

.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: dev-frontend
dev-frontend: frontend/node_modules
cd frontend && npm run dev

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

frontend/node_modules: frontend/package-lock.json
cd frontend && npm install

frontend/dist/static/env.js: build-frontend
34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,39 @@ 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
make storybook
```

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
cd frontend
npm install
make run MODEL=../path/to/model.aird
```

then, to develop components `npm run storybook` and to develop the whole app
`npm run dev`
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).

# Integration in the Capella Collaboration Manager

Expand Down

0 comments on commit bd281a0

Please sign in to comment.