Upgrading to the newest version of JHipster

JHipster provides an "upgrade" sub-generator (http://www.jhipster.tech/upgrading-an-application/) to help you upgrade an application with a new JHipster version. It is quite useful as it automates a lot of manual steps for you and the only thing you need to do is resolve merge conflicts, if there are any, after the upgrade is complete. Let's upgrade our application.

In your Terminal, execute the jhipster upgrade command. The upgrade process will start if there is a new version of JHipster available; otherwise, the process will exit with an error message.

Once the process starts, you will see a detailed console log of what is going on. As you can see, this sub-generator uses the global JHipster version instead of the local one, unlike other sub-generators:

INFO! Using JHipster version installed globally
INFO! Executing jhipster:upgrade
INFO! Options: from-cli: true
Welcome to the JHipster Upgrade Sub-Generator
This will upgrade your current application codebase to the latest JHipster version
Checking for new blueprint versions
Done checking for new version of blueprints
Looking for latest generator-jhipster version...
Looking for latest generator-jhipster version...
6.3.1
New generator-jhipster version found: 6.3.1
info git rev-parse -q --is-inside-work-tree
true
Git repository detected
...
Switched to a new branch 'jhipster_upgrade'
Created branch jhipster_upgrade
...
Cleaned up project directory

Installing generator-jhipster 6.2.0 locally
...
+ [email protected]
added 417 packages from 159 contributors and audited 2754226 packages in 39.961s
found 9 vulnerabilities (3 moderate, 6 high)
run `npm audit fix` to fix them, or `npm audit` for details
Installed [email protected]
...
Committed with message "Generated with JHipster 6.2.0"
info git checkout -q master
Checked out branch "master"
info git --version
git version 2.21.0
info git merge --strategy=ours -q --no-edit --allow-unrelated-histories jhipster_upgrade
Current code has been generated with version 6.2.0
info git checkout -q jhipster_upgrade
Checked out branch "jhipster_upgrade"
...
Installed [email protected]
...
Successfully regenerated application with JHipster 6.3.1 and
info Removing src/main/resources/config/tls/keystore.p12
info git add -A
warning: LF will be replaced by CRLF in gradlew.bat.
The file will have its original line endings in your working directory
info git commit -q -m "Generated with JHipster 6.3.1 and " -a --allow-empty --no-verify
Committed with message "Generated with JHipster 6.3.1 and "
info git checkout -q master
Checked out branch "master"
...
Merge done!
...
Upgraded successfully.
...
INFO! Congratulations, JHipster execution is complete!

The sub-generator does the following, in order:

  1. Checks whether there is a new version of JHipster available (not applicable if you are using --force).
  2. Checks whether the application is already initialized as a Git repository; otherwise, JHipster will initialize one for you and commit the current code base to the master branch.
  3. Checks to ensure that there are no uncommitted local changes in the repository. The process will exit if it finds any uncommitted changes.
  4. Checks whether a jhipster_upgrade branch exists. If not, a branch is created.
  5. Checks out the jhipster_upgrade branch.
  6. Upgrades JHipster to the latest available version globally.
  7. Cleans the current project directory.
  8. Regenerates the application using the jhipster --force --with-entities command.
  9. Commits the generated code to the jhipster_upgrade branch.
  10. Merges the jhipster_upgrade branch back to the original branch from where the jhipster upgrade command was launched.

Let's see what has changed before we resolve the merge conflicts. Check the changes that have been staged. Carefully check the changes to make sure everything is in order, especially in the files where we made customizations earlier. My changelog looks like this; note that I truncated the bottom as there were 147 updated files:

Thankfully, I only have three conflicts, so they should be easy to resolve. The conflict in package.json arises from the change we made to integrate Bootswatch. Carefully resolve the conflict stage in the file and move on to the next file.

The result of the upgrade process depends on when the command is run, the version that was used to generate the application, and the latest JHipster release version available. Hence, the number of files that have changed and conflicts arising will vary greatly, depending on these variables. The conflict resolution needs to be carefully done while keeping this in mind. What I have shown here is just a sample.

Once all the conflicts have been resolved, stage the files and commit them, as shown here:

> git add --all
> git commit -am "update to latest JHipster version"

Ensure that everything works. Run the server-side and client-side tests using ./gradlew test integrationTest npm_test and start the application to verify this by running the ./gradlew clean bootRun command.

In the next section, we'll look at what deployment options are available for us.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.118.95