From 61089d7f3ce0fb33b59982563962af32d585bfed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tra=CC=82=CC=80n=20Quang=20Tie=CC=82=CC=81n?= Date: Thu, 22 Jun 2017 01:43:30 +0700 Subject: [PATCH 1/3] Fix automatic upgrade Fix #5883 --- generators/upgrade/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/generators/upgrade/index.js b/generators/upgrade/index.js index 0de9b5a4617c..022329cb56c8 100644 --- a/generators/upgrade/index.js +++ b/generators/upgrade/index.js @@ -74,7 +74,8 @@ 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) => { + const localBinPath = this.clientPackageManager === 'yarn' ? 'yarn bin' : 'npm bin'; + shelljs.exec(`$(${localBinPath})/jhipster --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 +257,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 +273,6 @@ module.exports = UpgradeGenerator.extend({ }); }, - checkoutUpgradeBranch() { - const done = this.async(); - this._gitCheckout(UPGRADE_BRANCH, done); - }, - generateWithLatestVersion() { const done = this.async(); this._cleanUp(); From c62966982148c6ec89ab337c96d91378cb9564fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tra=CC=82=CC=80n=20Quang=20Tie=CC=82=CC=81n?= Date: Thu, 22 Jun 2017 09:37:16 +0700 Subject: [PATCH 2/3] =?UTF-8?q?make=20it=20work=20with=20projects=20which?= =?UTF-8?q?=20don=E2=80=99t=20have=20jhipster=20cli?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generators/upgrade/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generators/upgrade/index.js b/generators/upgrade/index.js index 022329cb56c8..a147b117ac87 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,8 +75,11 @@ module.exports = UpgradeGenerator.extend({ _generate(version, callback) { this.log(`Regenerating application with JHipster ${version}...`); - const localBinPath = this.clientPackageManager === 'yarn' ? 'yarn bin' : 'npm bin'; - shelljs.exec(`$(${localBinPath})/jhipster --with-entities --force --skip-install`, { silent: this.silent }, (code, msg, err) => { + var 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(); From cd3ddaf20a2506f173f0e7a7215494eeda47317d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tra=CC=82=CC=80n=20Quang=20Tie=CC=82=CC=81n?= Date: Thu, 22 Jun 2017 14:53:34 +0700 Subject: [PATCH 3/3] polish lint --- generators/upgrade/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/upgrade/index.js b/generators/upgrade/index.js index a147b117ac87..d153e0d8bacb 100644 --- a/generators/upgrade/index.js +++ b/generators/upgrade/index.js @@ -32,7 +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" +const GENERATOR_JHIPSTER_CLI_VERSION = '4.5.1'; module.exports = UpgradeGenerator.extend({ constructor: function (...args) { // eslint-disable-line object-shorthand @@ -75,7 +75,7 @@ module.exports = UpgradeGenerator.extend({ _generate(version, callback) { this.log(`Regenerating application with JHipster ${version}...`); - var generatorCommand = 'yo jhipster'; + let generatorCommand = 'yo jhipster'; if (semver.gte(version, GENERATOR_JHIPSTER_CLI_VERSION)) { generatorCommand = this.clientPackageManager === 'yarn' ? '$(yarn bin)/jhipster' : '$(npm bin)/jhipster'; }