Skip to content

Commit

Permalink
Update readme and add new dev-build script
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoila committed Nov 8, 2024
1 parent d807f59 commit 1710ae4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
31 changes: 13 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,25 @@ Minimum implementation is planned to be finished by 2023 and the software with f

## Development

- Steps required when running for the first time
- `cp backend/.template.env backend/.env`
- See the `.template.env` file to check if you need to replace or fill some initial values
### Initial project setup

When `backend/.env` is properly set, start the development by running:
_Steps required when running for the first time_

```sh
$ docker compose up -d
```
- `cp backend/.template.env backend/.env`
- See the `.template.env` file to check if you need to replace or fill some initial values
- Note that georaster proxy envs are needed in order to display map background layers
- Ensure that the node version is the same as required by the project (see package.json)
- When `backend/.env` is properly set, ensure that docker is up and running and start the development by running the following command in the root of the project:

Project contains workspace settings and `.devcontainer` configurations to VSCode users which has some extensions preconfigured such as:
```sh
$ npm run dev-build
```

- sqlfluff for SQL file formatting and linting
- ESLint for linting TypeScript
- Prettier for code formatting and import organization
- SonarLint for additional linting rules for TypeScript, HTML etc.
- SQLLit for inline SQL highlighting
- EditorConfig
- The command above installs project dependencies, builds and starts docker containers and runs database migrations.

```sh
$ code frontend && code backend

# Running the DB migrations:
### Running DB migrations

```sh
# Using the docker compose exec:
$ docker compose exec backend npm run db-migrate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
getGeoJSONFeaturesString,
} from '@frontend/components/Map/mapInteractions';
import { mapOptions, treMunicipalityGeometry } from '@frontend/components/Map/mapOptions';
import { DRAW_LAYER_Z_INDEX, projectAreaStyle } from '@frontend/components/Map/styles';
import { projectAreaStyle } from '@frontend/components/Map/styles';
import { TooltipLinkTab } from '@frontend/components/TooltipLinkTab';
import { useNotifications } from '@frontend/services/notification';
import { asyncUserAtom } from '@frontend/stores/auth';
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"scripts": {
"dev-build": "scripts/clean_start_dev_environment.sh -d"
},
"devDependencies": {
"@prettier/plugin-xml": "^3.2.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
Expand Down
22 changes: 21 additions & 1 deletion scripts/clean_start_dev_environment.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/bin/bash

# Get flags provided

while getopts "d" flag; do
case $flag in
d)
init_db=true
;;
\?)
echo "Invalid flags provided"
exit 1
;;
esac
done



# Function to execute a command and check its status
execute() {
"$@"
Expand All @@ -11,5 +27,9 @@ execute() {
return $status
}

execute find . -type f -name "package.json" -depth 2 -execdir sh -c 'rm -rf node_modules && npm i' \; &&
execute find . -type f -name "package.json" -maxdepth 2 -execdir sh -c 'rm -rf node_modules && npm i' \; &&
execute docker compose build --no-cache && docker compose up -d

if [ "$init_db" = true ]; then
execute docker compose exec -it backend npm run db-migrate
fi

0 comments on commit 1710ae4

Please sign in to comment.