Patron Client development
Setting up IntelliJ
The project uses a strict set of linting rules that may also choke on some formatting. To ensure a common style, formatting should be performed based on a standard config.
- Click Manage next to Scheme.
- Choose Import, then IntelliJ IDEA code style XML, and select Standard.xml.
- Press OK in the next dialog.
- Ensure that Standard is chosen as scheme.
The editor will give a code hint anywhere where semicolons are omitted. To fix this, click on the marking and press Alt+Enter, then disable the inspection from the meny that is displayed.
By default, IntelliJ will not use the correct language standard for Patron Client. To change this:
Patron Client non-Docker development
Patron Client can de developed without any local dependencies, but it is not efficient:
- Restarting node with changes requires running
- File watching (required for Hot Module Reloading (HMR)) has proven problematic for mounted volumes.
Essential npm scripts
verify: Run tests and linting.
lint: Run linting.
start: Starts the project, but
KOHA_API_PASSmust be provided.
test:watch: Start tests and watch for code changes. Will re-run tests on code changes.
es5: Compile all js to es5, useful for debugging unit tests in IntelliJ. See the Debugging tests section for more information.
dev: Convenience script, run npm start with port 8001 and with
devnode: Same as above, except it only runs node without compass. Useful when a lot of node restarts are required and no style changes are performed.
killcompass: Will print an error, but will kill stale compass instances (might sometimes happen on ctrl+c'ing from start or dev)
prodbuild: Build Patron Client for production
production: Run Patron Client in production mode. Must have been built for production previously.
Getting started with development outside Docker
- Be ready for ls.ext development.
- Install node.js.
- Install compass. Ruby is required.
- cd to Patron Client directory
- Ensure that the machine's host file has the hosts properly set. Add this line to /etc/hosts or /private/etc/hosts depending on OS:
127.0.0.1 services xkoha koha elasticsearch patron_client koha_mysql.
- You are now ready to run the npm scripts.
npm run devis usually a good start.
Debugging unit tests
Since the unit tests are written with import syntax not available in node.js, transpiling is required. IntelliJ is then set to run the tests from the transpiled (ES5) code, but thanks to source maps any breakpoint in the original code will hit.
npm run es5to start transpiling. This is a watcher and will update any changed files.
- In IntelliJ, press Run > Edit Configurations.
- Press the + sign and choose Mocha.
- In the settings for the Mocha config, change the lines according to the following screenshot: