# Develop

For now Docker is a primary way of working on the repo.

## Installation

1. Install `virtualenv` package if it's not installed.

   ```sh
   pip install --user virtualenv
   ```

2. Create a virtual environment:

   ```sh
   virtualenv venv
   ```

2. Activate the virtual environment.

   ```sh
   #   Windows ➞ venv\Scripts\activate
   source venv/bin/activate
   ```

3. Install python packages.

   ```sh
   pip install --requirement requirements.txt
   ```

4. Install  `pre-commit`  hooks.

   ```sh
   pre-commit install --install-hooks
   ```

### Database

1.  Register an account.

2.  Visit  [`http://localhost:5000/development`]

3.  Click either seeded or random generation.

    _This will start a mock import process,_ <br>
    _which will also populate the database._

### Build

```sh
docker-compose build
docker-compose up --detach
```

In a browser, visit  [`http://localhost:8000/`]

## Manual

> **TODO** : Write installation and setup instructions

This assumes you have  `Python 3.8+`  &  `Node 12+`  installed <br>
as well as a running **PostgreSQL** server with **Pgroonga**.

```sh
#   Make sure your database is initialized
#   cd to kemono directory

pip install virtualenv
virtualenv venv

#   Windows ➞ venv\Scripts\activate
source venv/bin/activate

pip install \
    --requirement requirements.txt

cd client               \
    && npm install      \
    && npm run build    \
    && cd ..
```

## Git

Configure `git` to store credentials:

```sh
git config credential.helper store
```

After the next time creds are accepted, they will be saved on hard drive
as per rules listed in `man git-credential-store`and won't be asked again.

Alternatively they can be stored temporarily in memory:

```sh
git config credential.helper cache
```

The creds are stored as per rules in `man git-credential-cache`.

## IDE

_IDE specific instructions._

### VSCode

1.  Copy  `.code-workspace`  file.

    ```sh
    cp                                              \
        configs/workspace.code-workspace.example    \
        kemono-2.code-workspace
    ```

2.  Install the recommended extensions.

[`http://localhost:5000/development`]: http://localhost:5000/development
[`http://localhost:5000/`]: http://localhost:5000/
[`http://localhost:8000/`]: http://localhost:8000/
