<commit_before>/**
 * Copyright 2013-2018 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

const chalk = require('chalk');
const BaseGenerator = require('../generator-base');
const shelljs = require('shelljs');
const semver = require('semver');
const constants = require('../generator-constants');

/* Constants used throughout */
const GENERATOR_JHIPSTER = 'generator-jhipster';
const UPGRADE_BRANCH = 'jhipster_upgrade';
const GIT_VERSION_NOT_ALLOW_MERGE_UNRELATED_HISTORIES = '2.9.0';
const FIRST_CLI_SUPPORTED_VERSION = '4.5.1'; // The first version in which CLI support was added
const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR;

module.exports = class extends BaseGenerator {
    constructor(args, opts) {
        super(args, opts);
        this.force = this.options.force;
    }

    get initializing() {
        return {
            displayLogo() {
                this.log(chalk.green('Welcome to the JHipster Upgrade Sub-Generator'));
                this.log(chalk.green('This will upgrade your current application codebase to the latest JHipster version'));
            },

            loadConfig() {
                this.currentVersion = this.config.get('jhipsterVersion');
                this.clientPackageManager = this.config.get('clientPackageManager');
                this.clientFramework = this.config.get('clientFramework');
                this.skipInstall = this.options['skip-install'];
                this.silent = this.options.silent;
                this.targetVersion = this.options['target-version'];
            }
        };
    }

    _gitCheckout(branch, callback) {
        this.gitExec(['checkout', '-q', branch], { silent: this.silent }, (code, msg, err) => {
            if (code !== 0) this.error(`Unable to checkout branch ${branch}:\n${err}`);<commit_msg>add upgrade cli flag options to the help output<commit_after>/**
 * Copyright 2013-2018 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

const chalk = require('chalk');
const BaseGenerator = require('../generator-base');
const shelljs = require('shelljs');
const semver = require('semver');
const constants = require('../generator-constants');

/* Constants used throughout */
const GENERATOR_JHIPSTER = 'generator-jhipster';
const UPGRADE_BRANCH = 'jhipster_upgrade';
const GIT_VERSION_NOT_ALLOW_MERGE_UNRELATED_HISTORIES = '2.9.0';
const FIRST_CLI_SUPPORTED_VERSION = '4.5.1'; // The first version in which CLI support was added
const SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR;

module.exports = class extends BaseGenerator {
    constructor(args, opts) {
        super(args, opts);
        this.force = this.options.force;

        // This adds support for a `--target-version` flag
        this.option('target-version', {
            desc: 'Upgrade to a specific version instead of the latest',
            type: String
        });

        // This adds support for a `--skip-install` flag
        this.option('skip-install', {
            desc: 'Skips installing dependencies during the upgrade process',
            type: Boolean,
            defaults: false
        });

        // This adds support for a `--silent` flag
        this.option('silent', {
            desc: 'Hides output of the generation process',
            type: Boolean,
            defaults: false
        });

        this.targetVersion = this.options['target-version'];
        this.skipInstall = this.options['skip-install'];
        this.silent = this.options.silent;
    }

    get initializing() {
        return {
            displayLogo() {
                this.log(chalk.green('Welcome to the JHipster Upgrade Sub-Generator'));
                this.log(chalk.green('This will upgrade your current application codebase to the latest JHipster version'));
            },

            loadConfig() {
                this.currentVersion = this.config.get('jhipsterVersion');
                this.clientPackageManager = this.config.get('clientPackageManager');
                this.clientFramework = this.config.get('clientFramework');
            }
        };
    }

    _gitCheckout(branch, callback) {
        this.gitExec(['checkout', '-q', branch], { silent: this.silent }, (code, msg, err) => {
            if (code !== 0) this.error(`Unable to checkout branch ${branch}:\n${err}`);
{'fraction_non_alphanumeric': 0.1095550434320156, 'fraction_numerical': 0.006736394256337529, 'mean_word_length': 2.8538251366120218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5871210', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1500, 'n_words': 482}