generator-jhipster-db-helper
This is a JHipster module, meant to be used in a JHipster application.
JHipster was created with the purpose to generate pristine new applications.
It enforces conventions which makes it hard to use it with messy existing databases.
However some of us still want create a JHipster applications with such databases.
generator-jhipster-db-helper
makes it easy.
Usage
- Install our module from JHipster Marketplace or using your favourite package manager.
yarn add generator-jhipster-db-helper
- Run the main generator on your already created JHipster application.
yo generator-jhipster-db-helper
- Answer our module's questions after creating or regenerating an entity
Our module do all the necessary modifications (see below some of them)
- Profit
Check this application to see all the modifications our module do.
Installation
Prerequisites
As this is a JHipster module, we expect you have JHipster and its related tools already installed:
Create a new JHipster app and choose a SQL database.
With Yarn
To install this module: yarn global add generator-jhipster-db-helper
To update this module: yarn global upgrade generator-jhipster-db-helper
With NPM
To install this module: npm install -g generator-jhipster-db-helper
To update this module: npm update -g generator-jhipster-db-helper
How this module works
Upon running the main generator, it changes the naming convention to a more flexible one, registers itself as a post app hook and registers the 'fix-entity' sub-generator as a post-entity hook.
When you create or regenerate an entity, the sub-generator fix-entity
will run after jhipster:entity
has finished running.
It receives information from jhipster:entity
and uses it to find out what must be modified.
It asks the user what values it must use as replacements for the entity and liquibase files with. It offers jhipster default values or user previous values if any as default answers.
It then match correspond values and replaces them with user input using regexes.
It stores your answer in the entity configuration file .jhipster/Entity.json
and makes the necessary replacements in both ORM and changelog files.
Contributing
Development
- Set up your local copy
- Fork this module
- Clone your fork on your working machine
- Install dependencies by running
yarn
- Create a branch from master (see section Branching below)
- Develop new stuff
- Use your local copy
- Register your local copy by running
yarn link
inside your clone directory - Create an application to test your modifications
- Link the application with your local copy by running
yarn link generator-jhipster-db-helper
inside your application directory - Use the module (see section Usage above)
- Register your local copy by running
You can edit your local repository and test the changes in the application directly. There is no need to rebuild the app.
An easy way to get an application with many entities and all relationship types is to:
- Copy the whole
travis
directory. - Edit the script
run-test-case.sh
to modifyJHIPSTER_VERSION
variable. - Run the script from the
travis
directory, not thetest-case
directory. - The application will be created inside the
test-case
Branching
When submitting changes, please do so from a new branch, not the master branch. Please name your branch according these rules :
- descriptive name :
fork
is bad,bugfix/entity-name-validation
is good. - all characters must be lowercase
- use dash
-
as a word separator. - use a prefix to describe the branch's type :
feature/
: New thing or improvementbugfix/xx-
: Repairing something that wasn't working correctly- replace xx with the number of the issue. Always open an issue about discovered bugs.
Integration testing
We use Travis CI for integration testing. If you want our module to support another type of database, another application configuration or another set up of entities, the first thing you should do is adding your test case to the travis build.
General guidelines
We aligned ourselves on the guidelines of jhipster/generator-jhipster
, if you don't know them, please read them.
Contact
License
Apache-2.0 © Adrien Horgnies & Bastien Michaux