Skip to content

Commit

Permalink
Merge pull request #25203 from mshima/upgrade
Browse files Browse the repository at this point in the history
simplify upgrade generator
  • Loading branch information
DanielFran committed Feb 15, 2024
2 parents dcfb360 + 74c056c commit 85e3e31
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 423 deletions.
14 changes: 4 additions & 10 deletions cli/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,10 @@ const __dirname = dirname(__filename);
const currentNodeVersion = process.versions.node;
const minimumNodeVersion = packageJson.engines.node;

if (!process.argv.includes('--skip-checks')) {
if (
!semver.satisfies(currentNodeVersion, minimumNodeVersion) &&
// Allow upgrade to be executed using node 16 due to https://github.com/jhipster/generator-jhipster/issues/20349
(!process.argv.includes('upgrade') || !semver.satisfies(currentNodeVersion, '^16.0.0'))
) {
logger.fatal(
`You are running Node version ${currentNodeVersion}\nJHipster requires Node version ${minimumNodeVersion}\nPlease update your version of Node.`,
);
}
if (!process.argv.includes('--skip-checks') && !semver.satisfies(currentNodeVersion, minimumNodeVersion)) {
logger.fatal(
`You are running Node version ${currentNodeVersion}\nJHipster requires Node version ${minimumNodeVersion}\nPlease update your version of Node.`,
);
}

const appFolderOrWorkspaceRoot = existsSync('../node_modules') ? join(process.cwd(), '..') : process.cwd();
Expand Down
15 changes: 15 additions & 0 deletions generators/upgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# upgrade sub-generador

Upgrades the application the a newer generator-jhipster version.

The upgrade process generates 4 commits.

- the reference application
- a merge commit with unrelated histories
- the upgrade application
- a merge commit to apply the upgrade commit to the existing application

## Upgrading from v7

To upgrade to v8 you need to upgrade to v7.9.4 before due to node v18/v20 compatibility.
If you use blueprint that uses jhipster v7, you need to use [jhipster-migrate](https://github.com/jhipster/generator-jhipster-migrate/).
9 changes: 5 additions & 4 deletions generators/upgrade/USAGE
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Description:
Updates JHipster version, and upgrades generated application
Upgrades generated application

Example:

jhipster upgrade

Assuming you have Git installed, and you run this command in the Git branch you are using for development, JHipster Upgrader will :
- checkout a "jhipster_upgrade" branch
- update generator-jhipster via npm
- regenerate your whole application
- switch back to your development branch, and start the merge
- generate a application upgrade reference
- apply the reference point to your application
- generate the upgraded application
- switch back to your original branch and merge the upgrade branch into it
10 changes: 0 additions & 10 deletions generators/upgrade/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ import { JHipsterCommandDefinition } from '../base/api.js';

const command: JHipsterCommandDefinition = {
options: {
targetJhipsterVersion: {
name: 'targetVersion',
description: 'Upgrade to a specific version instead of the latest',
type: String,
scope: 'generator',
},
targetBlueprintVersions: {
description: 'Upgrade to specific blueprint versions instead of the latest, e.g. --target-blueprint-versions foo@0.0.1,bar@1.0.2',
type: String,
},
silent: {
description: 'Hides output of the generation process',
type: Boolean,
Expand Down

0 comments on commit 85e3e31

Please sign in to comment.