<commit_before>'use strict';

var path = require('path'),
    shelljs = require('shelljs'),
    crypto = require('crypto');

module.exports = {
    askForModuleName,
    askForServerSideOpts,
    askForOptionalItems,
    askFori18n
};

function askForModuleName() {
    if (this.baseName) return;

    this.askModuleName(this);

}

function askForServerSideOpts() {
    if (this.existingProject) return;

    var done = this.async();
    var getNumberedQuestion = this.getNumberedQuestion.bind(this);
    var applicationType = this.applicationType;
    var prompts = [
        {
            when: function (response) {
                return (applicationType === 'gateway' || applicationType === 'microservice' || applicationType === 'uaa');
            },
            type: 'input',
            name: 'serverPort',
            validate: function (input) {
                if (/^([0-9]*)$/.test(input)) return true;
                return 'This is not a valid port number.';
            },
            message: function (response) {
                return getNumberedQuestion('As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts.', applicationType === 'gateway' || applicationType === 'microservice' || applicationType === 'uaa');
            },
            default: applicationType === 'gateway' ? '8080' : applicationType === 'uaa' ? '9999' : '8081'
        },
        {
            type: 'input',
            name: 'packageName',
            validate: function (input) {
                if (/^([a-z_]{1}[a-z0-9_]*(\.[a-z_]{1}[a-z0-9_]*)*)$/.test(input)) return true;
                return 'The package name you have provided is not a valid Java package name.';
            },
            message: function (response) {
                return getNumberedQuestion('What is your default Java package name?', true);
            },
            default: 'com.mycompany.myapp',
            store: true
        },
        {
            when: function (response) {
                return applicationType === 'monolith';
            },
            type: 'list',
            name: 'authenticationType',
            message: function (response) {
                return getNumberedQuestion('Which *type* of authentication would you like to use?', applicationType === 'monolith');
            },
            choices: [
                {
                    value: 'session',
                    name: 'HTTP Session Authentication (stateful, default Spring Security mechanism)'
                },
                {
                    value: 'oauth2',
                    name: 'OAuth2 Authentication (stateless, with an OAuth2 server implementation)'
                },
                {
                    value: 'jwt',
                    name: 'JWT authentication (stateless, with a token)'
                }
            ],
            default: 0
        },
        {
            when: function (response) {
                return applicationType === 'gateway' || applicationType === 'microservice';
            },
            type: 'list',
            name: 'authenticationType',
            message: function (response) {
                return getNumberedQuestion('Which *type* of authentication would you like to use?', applicationType === 'gateway' || applicationType === 'microservice');
            },
            choices: [
                {
                    value: 'jwt',
                    name: 'JWT authentication (stateless, with a token)'
                },
                {
                    value: 'uaa',
                    name: '[BETA] Authentication with JHipster UAA server (the server must be generated separately)'
                }
            ],
            default: 0<commit_msg>Change the order of authentication questions, so JWT is on top of OAuth2 as it’s far more popular<commit_after>'use strict';

var path = require('path'),
    shelljs = require('shelljs'),
    crypto = require('crypto');

module.exports = {
    askForModuleName,
    askForServerSideOpts,
    askForOptionalItems,
    askFori18n
};

function askForModuleName() {
    if (this.baseName) return;

    this.askModuleName(this);

}

function askForServerSideOpts() {
    if (this.existingProject) return;

    var done = this.async();
    var getNumberedQuestion = this.getNumberedQuestion.bind(this);
    var applicationType = this.applicationType;
    var prompts = [
        {
            when: function (response) {
                return (applicationType === 'gateway' || applicationType === 'microservice' || applicationType === 'uaa');
            },
            type: 'input',
            name: 'serverPort',
            validate: function (input) {
                if (/^([0-9]*)$/.test(input)) return true;
                return 'This is not a valid port number.';
            },
            message: function (response) {
                return getNumberedQuestion('As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts.', applicationType === 'gateway' || applicationType === 'microservice' || applicationType === 'uaa');
            },
            default: applicationType === 'gateway' ? '8080' : applicationType === 'uaa' ? '9999' : '8081'
        },
        {
            type: 'input',
            name: 'packageName',
            validate: function (input) {
                if (/^([a-z_]{1}[a-z0-9_]*(\.[a-z_]{1}[a-z0-9_]*)*)$/.test(input)) return true;
                return 'The package name you have provided is not a valid Java package name.';
            },
            message: function (response) {
                return getNumberedQuestion('What is your default Java package name?', true);
            },
            default: 'com.mycompany.myapp',
            store: true
        },
        {
            when: function (response) {
                return applicationType === 'monolith';
            },
            type: 'list',
            name: 'authenticationType',
            message: function (response) {
                return getNumberedQuestion('Which *type* of authentication would you like to use?', applicationType === 'monolith');
            },
            choices: [
                {
                    value: 'session',
                    name: 'HTTP Session Authentication (stateful, default Spring Security mechanism)'
                },
                {
                    value: 'jwt',
                    name: 'JWT authentication (stateless, with a token)'
                },
                {
                    value: 'oauth2',
                    name: 'OAuth2 Authentication (stateless, with an OAuth2 server implementation)'
                }
            ],
            default: 0
        },
        {
            when: function (response) {
                return applicationType === 'gateway' || applicationType === 'microservice';
            },
            type: 'list',
            name: 'authenticationType',
            message: function (response) {
                return getNumberedQuestion('Which *type* of authentication would you like to use?', applicationType === 'gateway' || applicationType === 'microservice');
            },
            choices: [
                {
                    value: 'jwt',
                    name: 'JWT authentication (stateless, with a token)'
                },
                {
                    value: 'uaa',
                    name: '[BETA] Authentication with JHipster UAA server (the server must be generated separately)'
                }
            ],
            default: 0
{'fraction_non_alphanumeric': 0.11415168100078187, 'fraction_numerical': 0.007167057597081053, 'mean_word_length': 1.650207182320442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '941813', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1847, 'n_words': 544}