diff --git a/generators/upgrade/index.js b/generators/upgrade/index.js index 0de9b5a4617c..d153e0d8bacb 100644 --- a/generators/upgrade/index.js +++ b/generators/upgrade/index.js @@ -32,6 +32,7 @@ util.inherits(UpgradeGenerator, BaseGenerator); const GENERATOR_JHIPSTER = 'generator-jhipster'; const UPGRADE_BRANCH = 'jhipster_upgrade'; const GIT_VERSION_NOT_ALLOW_MERGE_UNRELATED_HISTORIES = '2.9.0'; +const GENERATOR_JHIPSTER_CLI_VERSION = '4.5.1'; module.exports = UpgradeGenerator.extend({ constructor: function (...args) { // eslint-disable-line object-shorthand @@ -74,7 +75,11 @@ module.exports = UpgradeGenerator.extend({ _generate(version, callback) { this.log(`Regenerating application with JHipster ${version}...`); - shelljs.exec('jhipster --with-entities --force --skip-install', { silent: this.silent }, (code, msg, err) => { + let generatorCommand = 'yo jhipster'; + if (semver.gte(version, GENERATOR_JHIPSTER_CLI_VERSION)) { + generatorCommand = this.clientPackageManager === 'yarn' ? '$(yarn bin)/jhipster' : '$(npm bin)/jhipster'; + } + shelljs.exec(`${generatorCommand} --with-entities --force --skip-install`, { silent: this.silent }, (code, msg, err) => { if (code === 0) this.log(chalk.green(`Successfully regenerated application with JHipster ${version}`)); else this.error(`Something went wrong while generating project! ${err}`); callback(); @@ -256,6 +261,11 @@ module.exports = UpgradeGenerator.extend({ insight.trackWithEvent('generator', 'upgrade'); }, + checkoutUpgradeBranch() { + const done = this.async(); + this._gitCheckout(UPGRADE_BRANCH, done); + }, + updateJhipster() { this.log(chalk.yellow(`Updating ${GENERATOR_JHIPSTER} to ${this.latestVersion} . This might take some time...`)); const done = this.async(); @@ -267,11 +277,6 @@ module.exports = UpgradeGenerator.extend({ }); }, - checkoutUpgradeBranch() { - const done = this.async(); - this._gitCheckout(UPGRADE_BRANCH, done); - }, - generateWithLatestVersion() { const done = this.async(); this._cleanUp();