Upgrading an application
WARNING At the moment, this only works with the technologies used with JHipster 3.x (to be more precise: if you use NPM and AngularJS 1.x). If you are using JHipster 4.x (with Yarn and/or Angular 2+), this sub-generator will not work. If you want to help on this, check #5116.
When a new version of JHipster is released, the JHipster upgrade sub-generator helps upgrading an existing application to this new version, without erasing your changes.
This is helpful to:
- Have the latest JHipster features in an existing application
- Get the changes when there is an important bug fix or security update
- Retain your changes in your codebase, and easily merge them with newly generated code
Please read this page carefully before doing an upgrade, to understand how the upgrade process works
Requirements
For this sub-generator to work you need to have git
installed from http://git-scm.com.
Running the upgrade sub-generator
Go into the application’s root directory:
cd myapplication/
To upgrade your application, type:
yo jhipster:upgrade
If you want to run the upgrade sub-generator even if no new JHipster version is available, type:
yo jhipster:upgrade --force
Graphical view of the upgrade process
Here is how the upgrade process works graphically (read the sections below to have a textual explanation):
(this image comes from JSFiddle )
Please note that the jhipster_upgrade
branch will be created orphan on your project, although it doesn’t display correctly on the above graph.
Step-by-step explanation of the upgrade process
Below are the steps processed by the JHipster upgrade sub-generator:
- Check if there is a new version of JHipster available (not applicable if you are using
--force
). - Check if the application is already initialized as a
git
repository, or else JHipster will initialize one for you and commit the current codebase to the master branch. - Check to ensure that there are no un-committed local changes in the repository. The process will exit if there are un-committed changes found.
- Check if a
jhipster_upgrade
branch exists. If not, a branch is created: details about this step is provided in the “Specific steps executed on first upgrade” section. - Checkout the
jhipster_upgrade
branch. - Upgrade JHipster to the latest available version globally.
- Clean the current project directory.
- Re-generate the application using the
yo jhipster --force --with-entities
command. - Commit the generated code to the
jhipster_upgrade
branch. - Merge the
jhipster_upgrade
branch back to the original branch from where theyo jhipster:upgrade
command was launched. - Now you just need to proceed with resolving merge conflicts if there are any.
Congratulations, your application is now upgraded with the latest version of JHipster!
Specific steps executed on first upgrade
On the first execution of the JHipster upgrade sub-generator, in order to avoid erasing all your changes, some additional steps are run:
- A
jhipster_upgrade
branch is created orphan (it has no parent) - The whole application is generated (using your current JHipster version).
- A block-merge commit is made on the
master
branch: no alteration is made on your codebase on themaster
branch; this is just a practical way to record in Git that the HEAD ofmaster
is up-to-date with the current JHipster version.
Advice
Don’t commit anything on the jhipster_upgrade
branch. This branch is dedicated to the JHipster upgrade sub-generator: each time the sub-generator is run, a new commit will be created.