github.com/soulteary/pocket-bookcase@v0.0.0-20240428065142-0b5a9a0fc98a/docs/Contribute.md (about)

     1  # Contribute
     2  
     3  1. [Running the server locally](#running-the-server-locally)
     4  2. [Updating the API documentation](#updating-the-api-documentation)
     5  3. [Lint the code](#lint-the-code)
     6  4. [Running tests](#running-tests)
     7  
     8  ## Running the server locally
     9  
    10  To run the current development server with the defaults you can run the following command:
    11  
    12  ```bash
    13  make serve
    14  ```
    15  
    16  If you want to run the refactored server, you can run the following command:
    17  
    18  ```bash
    19  make run-server
    20  ```
    21  
    22  > **ℹ️ Note:** For more information into what the _refactored server_ means, please check this issue: https://github.com/soulteary/pocket-bookcase/issues/640
    23  
    24  ## Updating the API documentation
    25  
    26  > **ℹ️ Note:** This only applies for the Rest API documentation under the `internal/http` folder, **not** the one under `internal/webserver`.
    27  
    28  If you make any changes to the Rest API endpoints, you need to update the swagger documentation. In order to do that, you need to have installed [swag](https://github.com/swaggo/swag).
    29  
    30  Then, run the following command:
    31  
    32  ```bash
    33  make swagger
    34  ```
    35  
    36  ## Updating the frontend styles
    37  
    38  The styles that are bundled with Shiori are stored under `internal/view/assets/css/style.css` and `internal/view/assets/css/archive.css` and created from the less files under `internal/views/assets/less`.
    39  
    40  If you want to make frontend changes you need to do that under the less files and then compile them to css. In order to do that, you need to have installed [bun](https://bun.sh).
    41  
    42  Then, run the following command:
    43  
    44  ```bash
    45  make styles
    46  ```
    47  
    48  The `style.css`/`archive.css` will be updated and changes **needs to be committed** to the repository.
    49  
    50  ## Lint the code
    51  
    52  In order to lint the code, you need to have installed [golangci-lint](https://golangci-lint.run) and [swag](https://github.com/swaggo/swag).
    53  
    54  After that, run the following command:
    55  
    56  ```bash
    57  make lint
    58  ```
    59  
    60  If any errors are found please fix them before submitting your PR.
    61  
    62  ## Running tests
    63  
    64  In order to run the test suite, you need to have running a local instance of MariaDB and PostgreSQL.
    65  If you have docker, you can do this by running the following command with the compose file provided:
    66  
    67  ```bash
    68  docker-compose up -d mariadb postgres
    69  ```
    70  
    71  After that, provide the `SHIORI_TEST_PG_URL` and `SHIORI_TEST_MYSQL_URL` environment variables with the connection string to the databases:
    72  
    73  ```
    74  SHIORI_TEST_PG_URL=postgres://shiori:shiori@127.0.0.1:5432/shiori?sslmode=disable
    75  SHIORI_TEST_MYSQL_URL=shiori:shiori@tcp(127.0.0.1:3306)/shiori
    76  ```
    77  
    78  Finally, run the tests with the following command:
    79  
    80  ```bash
    81  make unittest
    82  ```