Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fix automatic upgrade #5966

Merged
merged 3 commits into from
Jun 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the current JHipster version, it's already in package.json and should be available (I'll have a look)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, I didn't understood correctly, this is good


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