Skip to content

Commit

Permalink
Merge pull request #5966 from tientq/fix-automatic-upgrade
Browse files Browse the repository at this point in the history
WIP: Fix automatic upgrade
  • Loading branch information
jdubois authored Jun 23, 2017
2 parents d307b92 + cd3ddaf commit 4187509
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions generators/upgrade/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 4187509

Please sign in to comment.