Xymorot 423df953fb | ||
---|---|---|
declarations | ||
mocks | ||
resources | ||
src | ||
templates | ||
tests | ||
.editorconfig | ||
.eslintignore | ||
.eslintrc.json | ||
.gitignore | ||
.mocharc.yml | ||
.nycrc.yml | ||
.prettierrc.yml | ||
README.md | ||
forge.config.js | ||
gulpfile.js | ||
ormconfig.yml | ||
package-lock.json | ||
package.json | ||
tsconfig.json | ||
tslint.json | ||
webpack.config.js |
README.md
レンアイ - Hentai Library Thingy
Development
Quickstart
npm install
, the postinstall runsnpm run rebuild
- might need to install some build tools depending on your platform
npm run watch
for code transpilation (starts watchers)npm run start
Git Commits
This project uses Conventional Commits with the following types:
feat
: features, if any part of your commit implements a new functionality or changes an existing one, use thisremove
: removal of existing code/functionalityfix
: bugfixesrefactor
: code refactoringupdate
: updating dependencies and associated code changestest
: any of the above, but with tests/mocksconfig
: changing configuration (linters, build process)doc
: documentation, including commentsreformat
: fixing code formatting
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.
Database Migrations
Migrations are stored in src/main/migrations and handled by typeorm. Migrations are run on app start inside database.ts.
To auto-generate a migration:
node_modules/.bin/typeorm migration:generate -n <migration name> -c <connection name>
To create an empty creation which can be filled with custom migration code:
node_modules/.bin/typeorm migration:create -n <migration name> -c <connection name>
To run migrations:
node_modules/.bin/typeorm migration:run -c <connection name>
This is also pre-defined in the npm script typeorm:migrate
.
Testing
The testing framework of choice is Mocha. Call npm run test
to run all tests. Tests are written in typescript and need to be transpiled before testing.
- assertion is (mainly) done by Chai
- Electron specific testing is done by Spectron
- spies, stubs and mocks are provided by Sinon.JS
- HTTP server mocking is done by nock
- property based testing is made possible by fast-check
Mocks
There are 2 ways in which mocks are defined/used:
- for external modules, in mocks, uses the rewiremock package; use this only when there is some magic happening like for electron which normally runs in its own node process
- for own modules, just beside their test file in tests; name the file
*.mock.ts
and use other files for orientation; use sparingly and only when not having a mock makes it more complex e.g. for modules which interact with the file system
Tagging
Mocha does not have a seperate tagging feature, but it can filter via title. Us the following tags in your test titles:
@slow
when the test is particularly slow
Coverage
Code coverage is provided by nyc. The detailed code coverage can be found here after running the tests (open in browser).