2019-07-26 22:18:56 +02:00
![Renai ](resources/logo.png 'Renai' )
# レンアイ - Hentai Library Thingy
2019-06-23 02:30:24 +02:00
## Development
2019-03-10 20:29:25 +01:00
2019-07-02 21:44:13 +02:00
### Quickstart
2019-06-23 18:16:09 +02:00
- `npm install` , the postinstall runs
- `npm run rebuild`
- might need to install some build tools depending on your platform
2019-10-02 22:42:27 +02:00
- `npm run watch` for code transpilation (starts watchers)
- `npm run start`
2019-07-02 21:44:13 +02:00
### Git Commits
This project uses [Conventional Commits ](https://www.conventionalcommits.or ) with the following types:
2019-07-26 22:19:28 +02:00
2019-11-20 23:29:58 +01:00
| type | description |
| ---------- | --------------------------------------------------------------------------------------- |
| `feat` | implementing a new feature or changes an existing one |
| `remove` | removing an existing feature |
| `fix` | repairing a feature which does not work correctly |
| `refactor` | reworking code so that its function does not change (but could have in unexpected ways) |
| `update` | updating dependencies and associated code changes |
| `test` | any of the above, but with tests/mocks |
| `config` | changing configuration (npm scripts, linters, build process) |
2019-11-20 23:39:35 +01:00
| `meta` | updating something not directly related to function or documentation (e.g. branding) |
2019-11-20 23:29:58 +01:00
| `doc` | updating documentation, including code comments |
| `reformat` | rewriting code in a way in which it is impossible for function to change |
2019-07-02 21:44:13 +02:00
2019-07-05 22:56:43 +02:00
Always try to split up your changes into coherent commits, a single commit should do a single thing. If your commit needs to do more than one thing it should be labeled with the type coming first in this list.
2019-06-23 02:30:24 +02:00
2019-06-23 03:33:48 +02:00
### Database Migrations
2019-10-03 02:09:45 +02:00
Migrations are stored in [src/main/migrations ](src/main/migrations ) and handled by typeorm. Migrations are run on app start inside [database.ts ](src/main/services/database.ts ).
2019-06-23 03:33:48 +02:00
To auto-generate a migration:
2019-06-23 15:35:57 +02:00
`node_modules/.bin/typeorm migration:generate -n <migration name> -c <connection name>`
2019-06-23 03:33:48 +02:00
To create an empty creation which can be filled with custom migration code:
2019-06-23 15:35:57 +02:00
`node_modules/.bin/typeorm migration:create -n <migration name> -c <connection name>`
2019-06-23 03:33:48 +02:00
To run migrations:
`node_modules/.bin/typeorm migration:run -c <connection name>`
This is also pre-defined in the npm script `typeorm:migrate` .
2019-10-05 03:09:34 +02:00
2019-10-10 23:47:13 +02:00
### Testing
2019-10-05 03:09:34 +02:00
2019-10-10 23:47:13 +02:00
The testing framework of choice is [Mocha ](https://mochajs.org/ ). Call `npm run test` to run all tests. Tests are written in typescript and need to be transpiled before testing.
2019-10-12 02:21:27 +02:00
- assertion is (mainly) done by [Chai ](https://www.chaijs.com/ )
- Electron specific testing is done by [Spectron ](https://electronjs.org/spectron )
- spies, stubs and mocks are provided by [Sinon.JS ](https://sinonjs.org/ )
- HTTP server mocking is done by [nock ](https://github.com/nock/nock )
2019-10-12 02:22:30 +02:00
- property based testing is made possible by [fast-check ](https://github.com/dubzzz/fast-check )
2019-10-12 02:21:27 +02:00
2019-11-18 22:38:51 +01:00
#### Mocks
There are 2 ways in which mocks are defined/used:
2019-11-22 21:31:10 +01:00
0. for external modules, in [mocks ](mocks )
- uses the [rewiremock ](https://github.com/theKashey/rewiremock ) package
- use this only when there is some magic happening like for electron which normally runs in its own node process
1. for own modules, just beside their test file in [tests ](tests )
- name the file `*.mock.ts` and use existing mock files for orientation on how to build them
- use sparingly and only when not having a mock makes it more complex e.g. for modules which interact with the file system
2019-11-18 22:38:51 +01:00
2019-10-10 23:47:13 +02:00
#### Tagging
Mocha does [not have a seperate tagging feature ](https://github.com/mochajs/mocha/wiki/Tagging ), but it can filter via title. Us the following tags in your test titles:
- `@slow` when the test is particularly slow
2019-10-13 01:37:38 +02:00
#### Coverage
Code coverage is provided by [nyc ](https://github.com/istanbuljs/nyc ). The detailed code coverage can be found [here ](.nyc_output/coverage/index.html ) after running the tests (open in browser).