2023-02-19 10:06:52 +01:00
# Ghostfolio Development Guide
2024-08-20 11:43:17 +02:00
## Development Environment
### Prerequisites
- [Docker ](https://www.docker.com/products/docker-desktop )
- [Node.js ](https://nodejs.org/en/download ) (version 20+)
- Create a local copy of this Git repository (clone)
- Copy the file `.env.dev` to `.env` and populate it with your data (`cp .env.dev .env` )
### Setup
1. Run `npm install`
1. Run `docker compose --env-file ./.env -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL ](https://www.postgresql.org ) and [Redis ](https://redis.io )
1. Run `npm run database:setup` to initialize the database schema
2024-08-22 19:17:28 +02:00
1. Start the [server ](#start-server ) and the [client ](#start-client )
2024-08-20 11:43:17 +02:00
1. Open https://localhost:4200/en in your browser
1. Create a new user via _Get Started_ (this first user will get the role `ADMIN` )
### Start Server
#### Debug
Run `npm run watch:server` and click _Debug API_ in [Visual Studio Code ](https://code.visualstudio.com )
#### Serve
Run `npm run start:server`
### Start Client
Run `npm run start:client` and open https://localhost:4200/en in your browser
### Start _Storybook_
Run `npm run start:storybook`
### Migrate Database
With the following command you can keep your database schema in sync:
```bash
npm run database:push
```
## Testing
Run `npm test`
2023-10-21 10:25:05 +02:00
## Experimental Features
New functionality can be enabled using a feature flag switch from the user settings.
### Backend
Remove permission in `UserService` using `without()`
### Frontend
2024-07-02 11:58:13 +02:00
Use `@if (user?.settings?.isExperimentalFeatures) {}` in HTML template
2023-10-21 10:25:05 +02:00
2023-02-19 10:06:52 +01:00
## Git
### Rebase
`git rebase -i --autosquash main`
## Dependencies
2023-11-04 11:59:49 +01:00
### Angular
#### Upgrade (minor versions)
1. Run `npx npm-check-updates --upgrade --target "minor" --filter "/@angular.*/"`
2023-02-19 10:06:52 +01:00
### Nx
#### Upgrade
2024-07-29 23:38:43 +05:30
1. Run `npx nx migrate latest`
1. Make sure `package.json` changes make sense and then run `npm install`
1. Run `npx nx migrate --run-migrations`
2023-02-19 10:06:52 +01:00
### Prisma
2023-10-04 08:48:50 +02:00
#### Access database via GUI
2024-07-29 23:38:43 +05:30
Run `npm run database:gui`
2023-10-04 08:48:50 +02:00
https://www.prisma.io/studio
2023-04-23 11:02:12 +02:00
#### Synchronize schema with database for prototyping
2024-07-29 23:38:43 +05:30
Run `npm run database:push`
2023-04-23 11:02:12 +02:00
https://www.prisma.io/docs/concepts/components/prisma-migrate/db-push
#### Create schema migration
2023-02-19 10:06:52 +01:00
2024-07-29 23:38:43 +05:30
Run `npm run prisma migrate dev --name added_job_title`
2023-02-19 10:06:52 +01:00
https://www.prisma.io/docs/concepts/components/prisma-migrate#getting -started-with-prisma-migrate