<commit_before>(function() {

    'use strict';

    var yeoman = require('yeoman-generator'),
        chalk = require('chalk'),
        path = require('path'),
        gift = require('gift'),
        scaffold = {},
        lodashOptions = {
            evaluate: /<#([\s\S]+?)#>/g,
            interpolate: /<#=([\s\S]+?)#>/g
        },
        hasComponent = function(component, components) {
            return components && components.indexOf(component) !== -1;
        };

    module.exports = yeoman.generators.Base.extend({

        constructor: function () {
            yeoman.generators.Base.apply(this, arguments);

            this.option('skip-welcome');

            scaffold = require('../../scaffold')(this);
        },

        initTask: function() {
            if (!this.options['skip-welcome']) {
                scaffold.welcomeMessage('Welcome to Scaffold Generator', 'I will guide you to generate your best workflow. Come with me...');
            }
        },

        promptTask: function() {
            var done = this.async(),
                choices = ['Mobile Only', 'Web Only', 'Responsive', 'Single Page', 'Single Page Mobile', 'Single Page Responsive'],
                prompts = [{
                    name: 'projectName',
                    message: 'What is the name of your project?',
                    validate: function(input) {
                        scaffold.validatePrompt({
                            done: this.async(),
                            input: input,
                            message: 'Hey dude! You forgot to enter the project name!'
                        });
                    }
                }, {
                    name: 'projectDescription',
                    message: 'What is the description?',
                    validate: function(input) {
                        scaffold.validatePrompt({
                            done: this.async(),
                            input: input,
                            message: 'You forgot the description. Write here.'
                        });
                    }
                }, {
                    name: 'projectMember',
                    message: 'What are people going to work on this project? (Separated by commas)',
                    validate: function(input) {
                        scaffold.validatePrompt({
                            done: this.async(),
                            input: input,
                            message: 'Hey man. Who will work with you on this? Write separating the names with commas.'
                        });
                    }
                }, {
                    type: 'list',
                    name: 'projectType',
                    message: 'What kind of project?',
                    choices: choices,
                    default: 0
                }, {
                    type: 'checkbox',
                    name: 'components',
                    message: 'What components do you like to include?',
                    choices: [{
                        name: 'Modernizr',
                        value: 'addModernizr',
                        checked: true
                    }, {
                        name: 'jQuery',
                        value: 'addjQuery',
                        checked: false
                    }, {
                        name: 'Angular',
                        value: 'addAngular',
                        checked: false
                    }]
                }, {
                    type: 'checkbox',
                    name: 'angularPackages',
                    message: 'What additional modules of Angular you want to include?',
                    when: function (answers) {
                        return hasComponent('addAngular', answers.components);
                    },
                    choices: [{
                        name: 'angular-animate',
                        value: 'angularAnimate',
                        checked: true
                    }, {
                        name: 'angular-cookies',
                        value: 'angularCookies',
                        checked: true
                    }, {
                        name: 'angular-loader',
                        value: 'angularLoader',
                        checked: false
                    }, {
                        name: 'angular-resource',
                        value: 'angularResource',
                        checked: false
                    }, {
                        name: 'angular-sanitize',
                        value: 'angularSanitize',
                        checked: false
                    }, {
                        name: 'angular-touch',
                        value: 'angularTouch',
                        checked: false
                    }, {
                        name: 'ui.router',
                        value: 'uiRouter',
                        checked: true
                    }]
                }, {
                    type: 'confirm',
                    name: 'hasGit',
                    message: 'Do you like to configure and init a git repository?',
                    default: 0
                }, {
                    name: 'gitUrl',
                    message: 'What is the git repository of the project? (Paste repository URL)',
                    when: function (answers) {
                        return answers.hasGit;
                    },
                    validate: function(input) {
                        scaffold.validatePrompt({
                            done: this.async(),
                            input: input,
                            message: 'Hey. Paste that URL dude!'
                        });
                    }
                }];

            this.prompt(prompts, function(answers) {
                var components = answers.components;

                for(var answer in answers) {
                    this[answer] = answers[answer];
                }

                this.hasAssemble = true;
                this.isSinglePage = false;
                this.needFastclick = false;
                this.createJs = false;

                switch (this.projectType) {
                    case choices[0]:
                        this.projectType = 'mobile';
                        this.needFastclick = true;
                        break;
                    case choices[1]:
                        this.projectType = 'web';
                        break;
                    case choices[2]:
                        this.projectType = 'responsive';
                        this.needFastclick = true;
                        break;
                    case choices[3]:
                        this.projectType = 'singlepage';
                        this.isSinglePage = true;
                        this.hasAssemble = false;
                        break;
                    case choices[4]:
                        this.projectType = 'singlepage-mobile';
                        this.needFastclick = true;
                        this.isSinglePage = true;
                        this.hasAssemble = false;
                        break;
                    case choices[5]:
                        this.projectType = 'singlepage-responsive';
                        this.needFastclick = true;
                        this.isSinglePage = true;
                        this.hasAssemble = false;
                        break;
                }

                this.addModernizr = hasComponent('addModernizr', components);
                this.addjQuery = hasComponent('addjQuery', components);
                this.addAngular = hasComponent('addAngular', components);

                var globals = {
                    Modernizr: this.addModernizr,
                    jQuery: this.addjQuery || this.addAngular,
                    angular: this.addAngular
                };

                this.globals = JSON.stringify(globals, null, 4);

                this.projectSlug = this._.slugify(this.projectName.toLowerCase());

                this.config.set({
                    'hasAssemble': this.hasAssemble
                });

                this.log(chalk.yellow(' \nGood! Now I will create and install everything you need. Time to take a coffee! \n \n'));

                done();
            }.bind(this));
        },

        corePath: function () {
            this.sourceRoot(path.join(__dirname, '../../templates/core/'));
        },

        core: function() {
            this.fs.copy(
                this.templatePath('grunt/**/*'),
                this.destinationPath('grunt')
            );
        },

        coreFiles: function() {
            this.fs.copy(
                this.templatePath('bowerrc'),
                this.destinationPath('.bowerrc')
            );
            this.fs.copy(
                this.templatePath('editorconfig'),
                this.destinationPath('.editorconfig')
            );
            this.fs.copy(
                this.templatePath('gitattributes'),
                this.destinationPath('.gitattributes')
            );
            this.fs.copy(
                this.templatePath('gitignore'),
                this.destinationPath('.gitignore')
            );
            this.fs.copy(
                this.templatePath('htmlhintrc'),
                this.destinationPath('.htmlhintrc')
            );
            this.fs.copy(
                this.templatePath('jsbeautifyrc'),
                this.destinationPath('.jsbeautifyrc')
            );
            this.fs.copyTpl(
                this.templatePath('jshintrc'),
                this.destinationPath('.jshintrc'),
                this
            );
            this.fs.copyTpl(
                this.templatePath('GruntFile.js'),
                this.destinationPath('GruntFile.js'),
                this,
                lodashOptions
            );
            this.fs.copyTpl(
                this.templatePath('_package.json'),
                this.destinationPath('package.json'),
                this
            );
        },

        bower: function() {
            var bower = {
                projectName: this.projectName,
                version: '0.0.0',
                name: this._.slugify(this.projectName.toLowerCase()),
                dependencies: {
                    'jquery': '~2.1.3',
                    'fastclick': '~1.0.6',
                    'modernizr': '~2.8.3',
                    'normalize-css': '~3.0.2'
                }
            };

            if (this.addAngular) {
                var components = this.angularPackages;

                bower.dependencies.angular = '~1.3.11';

                if (hasComponent('angularAnimate', components)) {
                    bower.dependencies['angular-animate'] = 'latest';
                }

                if (hasComponent('angularCookies', components)) {
                    bower.dependencies['angular-cookies'] = 'latest';
                }

                if (hasComponent('angularLoader', components)) {
                    bower.dependencies['angular-loader'] = 'latest';
                }

                if (hasComponent('angularResource', components)) {
                    bower.dependencies['angular-resource'] = 'latest';
                }

                if (hasComponent('angularSanitize', components)) {
                    bower.dependencies['angular-sanitize'] = 'latest';
                }

                if (hasComponent('angularTouch', components)) {
                    bower.dependencies['angular-touch'] = 'latest';
                }

                if (hasComponent('uiRouter', components)) {
                    bower.dependencies['angular-ui-router'] = 'latest';
                }
            } else {
                this.fs.delete(
                    this.destinationPath('options/ngAnnotate.js')
                );
            }

            if (!this.needFastclick) {
                delete bower.dependencies.fastclick;
            }

            if (!this.addjQuery || !this.addAngular) {
                delete bower.dependencies.jquery;
            }

            this.fs.write(
                this.destinationPath('bower.json'),
                JSON.stringify(bower, null, 2)
            );
        },

        grunt: function() {
            this.fs.delete(
                this.destinationPath('tasks/build.js')
            );
            this.fs.delete(
                this.destinationPath('tasks/default.js')
            );
            this.fs.delete(
                this.destinationPath('options/watch.js')
            );

            this.fs.copyTpl(
                this.templatePath('grunt/tasks/build.js'),
                this.destinationPath('grunt/tasks/build.js'),
                this
            );

            this.fs.copyTpl(
                this.templatePath('grunt/tasks/default.js'),
                this.destinationPath('grunt/tasks/default.js'),
                this
            );

            this.fs.copyTpl(
                this.templatePath('grunt/options/watch.js'),
                this.destinationPath('grunt/options/watch.js'),
                this,
                lodashOptions
            );
        },

        assemble: function() {
            if (this.isSinglePage) {
                this.fs.delete(
                    this.destinationPath('grunt/options/assemble.js')
                );
            }
        },

        modernizr: function() {
            if (!this.addModernizr) {
                this.fs.delete(
                    this.destinationPath('grunt/options/modernizr.js')
                );
            }
        },

        devPath: function () {
            this.sourceRoot(path.join(__dirname, '../../templates/', this.projectType));
        },

        dev: function() {
            this.mkdir('dev');

            if (this.hasAssemble) {
                this.mkdir('dev/partials');
            }
        },

        assets: function() {
            this.fs.copy(
                this.templatePath('../assets/**/*'),
                this.destinationPath('dev/assets')
            );
            this.mkdir('dev/assets/img');
        },

        less: function() {
            this.fs.copy(
                this.templatePath('assets/less/**/*'),
                this.destinationPath('dev/assets/less')
            );
            this.mkdir('dev/assets/less/components');
        },

        html: function() {
            if (this.hasAssemble) {
                this.fs.copyTpl(
                    this.templatePath('templates/default.html'),
                    this.destinationPath('dev/templates/default.html'),
                    this
                );
            }

            this.fs.copyTpl(
                this.templatePath('index.html'),
                this.destinationPath('dev/index.html'),
                this
            );
        },

        install: {
            setupGit: function() {
                if (this.hasGit) {
                    var repository,
                        yo = this,
                        done = yo.async();

                    yo.log(chalk.yellow('\n \nConfiguring git repository and commiting Scaffold'));

                    gift.init('.', function(err, repo) {
                        yo.log(chalk.green('  Init GIT repository'));

                        repository = repo;

                        repository.add('--all', function() {
                            yo.log(chalk.green('  Adding all files'));

                            repository.commit('Add Scaffold', function() {
                                yo.log(chalk.green('  Commiting'));

                                yo.spawnCommand('git', ['remote', 'add', 'origin', yo.gitUrl]).on('exit', function () {
                                    yo.log(chalk.green('  Add origin remote'));
                                });

                                yo.spawnCommand('git', ['config', 'credential.helper', 'store']).on('exit', function () {
                                    yo.log(chalk.green('  Configuring credentials'));

                                    repository.remote_push('origin', 'master', function() {
                                        yo.log(chalk.green('  Push commits'));
                                        done();
                                    });
                                });
                            });
                        });
                    });
                }
            },

            install: function() {
                this.installDependencies({ skipInstall: this.options.skipInstall });
            }
        },

        end: function() {
            var yo = this,
                glob = yo.spawnCommand('npm', ['install', 'glob']);

            glob.on('exit', function() {
                yo.log(chalk.cyan(' \n \n \n All done and no errors! Enjoy! \n \n \n'));

                this.composeWith('scaffold:run', {
                    options: {
                        'skip-welcome': true
                    }
                });
            });
        }

    });

})();
<commit_msg>Fancy validation!<commit_after>(function() {

    'use strict';

    var yeoman = require('yeoman-generator'),
        chalk = require('chalk'),
        path = require('path'),
        gift = require('gift'),
        scaffold = {},
        lodashOptions = {
            evaluate: /<#([\s\S]+?)#>/g,
            interpolate: /<#=([\s\S]+?)#>/g
        },
        hasComponent = function(component, components) {
            return components && components.indexOf(component) !== -1;
        };

    module.exports = yeoman.generators.Base.extend({

        constructor: function () {
            yeoman.generators.Base.apply(this, arguments);

            this.option('skip-welcome');

            scaffold = require('../../scaffold')(this);
        },

        initTask: function() {
            if (!this.options['skip-welcome']) {
                scaffold.welcomeMessage('Welcome to Scaffold Generator', 'I will guide you to generate your best workflow. Come with me...');
            }
        },

        promptTask: function() {
            var done = this.async(),
                choices = ['Mobile Only', 'Web Only', 'Responsive', 'Single Page', 'Single Page Mobile', 'Single Page Responsive'],
                prompts = [{
                    name: 'projectName',
                    message: 'What is the name of your project?',
                    validate: function(input) {
                        scaffold.validatePrompt({
                            done: this.async(),
                            input: input,
                            message: 'Hey dude! You forgot to enter the project name!'
                        });
                    }
                }, {
                    name: 'projectDescription',
                    message: 'What is the description?',
                    validate: function(input) {
                        scaffold.validatePrompt({
                            done: this.async(),
                            input: input,
                            message: 'You forgot the description. Write here.'
                        });
                    }
                }, {
                    name: 'projectMember',
                    message: 'What are people going to work on this project? (Separated by commas)',
                    validate: function(input) {
                        scaffold.validatePrompt({
                            done: this.async(),
                            input: input,
                            message: 'Hey man. Who will work with you on this? Write separating the names with commas.'
                        });
                    }
                }, {
                    type: 'list',
                    name: 'projectType',
                    message: 'What kind of project?',
                    choices: choices,
                    default: 0
                }, {
                    type: 'checkbox',
                    name: 'components',
                    message: 'What components do you like to include?',
                    choices: [{
                        name: 'Modernizr',
                        value: 'addModernizr',
                        checked: true
                    }, {
                        name: 'jQuery',
                        value: 'addjQuery',
                        checked: false
                    }, {
                        name: 'Angular',
                        value: 'addAngular',
                        checked: false
                    }]
                }, {
                    type: 'checkbox',
                    name: 'angularPackages',
                    message: 'What additional modules of Angular you want to include?',
                    when: function (answers) {
                        return hasComponent('addAngular', answers.components);
                    },
                    choices: [{
                        name: 'angular-animate',
                        value: 'angularAnimate',
                        checked: true
                    }, {
                        name: 'angular-cookies',
                        value: 'angularCookies',
                        checked: true
                    }, {
                        name: 'angular-loader',
                        value: 'angularLoader',
                        checked: false
                    }, {
                        name: 'angular-resource',
                        value: 'angularResource',
                        checked: false
                    }, {
                        name: 'angular-sanitize',
                        value: 'angularSanitize',
                        checked: false
                    }, {
                        name: 'angular-touch',
                        value: 'angularTouch',
                        checked: false
                    }, {
                        name: 'ui.router',
                        value: 'uiRouter',
                        checked: true
                    }]
                }, {
                    type: 'confirm',
                    name: 'hasGit',
                    message: 'Do you like to configure and init a git repository?',
                    default: 0
                }, {
                    name: 'gitUrl',
                    message: 'What is the git repository of the project? (Paste repository URL)',
                    when: function (answers) {
                        return answers.hasGit;
                    },
                    validate: function(input) {
                        scaffold.validatePrompt({
                            done: this.async(),
                            input: input,
                            message: 'Hey. Paste that URL!'
                        });
                    }
                }];

            this.prompt(prompts, function(answers) {
                var components = answers.components;

                for(var answer in answers) {
                    this[answer] = answers[answer];
                }

                this.hasAssemble = true;
                this.isSinglePage = false;
                this.needFastclick = false;
                this.createJs = false;

                switch (this.projectType) {
                    case choices[0]:
                        this.projectType = 'mobile';
                        this.needFastclick = true;
                        break;
                    case choices[1]:
                        this.projectType = 'web';
                        break;
                    case choices[2]:
                        this.projectType = 'responsive';
                        this.needFastclick = true;
                        break;
                    case choices[3]:
                        this.projectType = 'singlepage';
                        this.isSinglePage = true;
                        this.hasAssemble = false;
                        break;
                    case choices[4]:
                        this.projectType = 'singlepage-mobile';
                        this.needFastclick = true;
                        this.isSinglePage = true;
                        this.hasAssemble = false;
                        break;
                    case choices[5]:
                        this.projectType = 'singlepage-responsive';
                        this.needFastclick = true;
                        this.isSinglePage = true;
                        this.hasAssemble = false;
                        break;
                }

                this.addModernizr = hasComponent('addModernizr', components);
                this.addjQuery = hasComponent('addjQuery', components);
                this.addAngular = hasComponent('addAngular', components);

                var globals = {
                    Modernizr: this.addModernizr,
                    jQuery: this.addjQuery || this.addAngular,
                    angular: this.addAngular
                };

                this.globals = JSON.stringify(globals, null, 4);

                this.projectSlug = this._.slugify(this.projectName.toLowerCase());

                this.config.set({
                    'hasAssemble': this.hasAssemble
                });

                this.log(chalk.yellow(' \nGood! Now I will create and install everything you need. Time to take a coffee! \n \n'));

                done();
            }.bind(this));
        },

        corePath: function () {
            this.sourceRoot(path.join(__dirname, '../../templates/core/'));
        },

        core: function() {
            this.fs.copy(
                this.templatePath('grunt/**/*'),
                this.destinationPath('grunt')
            );
        },

        coreFiles: function() {
            this.fs.copy(
                this.templatePath('bowerrc'),
                this.destinationPath('.bowerrc')
            );
            this.fs.copy(
                this.templatePath('editorconfig'),
                this.destinationPath('.editorconfig')
            );
            this.fs.copy(
                this.templatePath('gitattributes'),
                this.destinationPath('.gitattributes')
            );
            this.fs.copy(
                this.templatePath('gitignore'),
                this.destinationPath('.gitignore')
            );
            this.fs.copy(
                this.templatePath('htmlhintrc'),
                this.destinationPath('.htmlhintrc')
            );
            this.fs.copy(
                this.templatePath('jsbeautifyrc'),
                this.destinationPath('.jsbeautifyrc')
            );
            this.fs.copyTpl(
                this.templatePath('jshintrc'),
                this.destinationPath('.jshintrc'),
                this
            );
            this.fs.copyTpl(
                this.templatePath('GruntFile.js'),
                this.destinationPath('GruntFile.js'),
                this,
                lodashOptions
            );
            this.fs.copyTpl(
                this.templatePath('_package.json'),
                this.destinationPath('package.json'),
                this
            );
        },

        bower: function() {
            var bower = {
                projectName: this.projectName,
                version: '0.0.0',
                name: this._.slugify(this.projectName.toLowerCase()),
                dependencies: {
                    'jquery': '~2.1.3',
                    'fastclick': '~1.0.6',
                    'modernizr': '~2.8.3',
                    'normalize-css': '~3.0.2'
                }
            };

            if (this.addAngular) {
                var components = this.angularPackages;

                bower.dependencies.angular = '~1.3.11';

                if (hasComponent('angularAnimate', components)) {
                    bower.dependencies['angular-animate'] = 'latest';
                }

                if (hasComponent('angularCookies', components)) {
                    bower.dependencies['angular-cookies'] = 'latest';
                }

                if (hasComponent('angularLoader', components)) {
                    bower.dependencies['angular-loader'] = 'latest';
                }

                if (hasComponent('angularResource', components)) {
                    bower.dependencies['angular-resource'] = 'latest';
                }

                if (hasComponent('angularSanitize', components)) {
                    bower.dependencies['angular-sanitize'] = 'latest';
                }

                if (hasComponent('angularTouch', components)) {
                    bower.dependencies['angular-touch'] = 'latest';
                }

                if (hasComponent('uiRouter', components)) {
                    bower.dependencies['angular-ui-router'] = 'latest';
                }
            } else {
                this.fs.delete(
                    this.destinationPath('options/ngAnnotate.js')
                );
            }

            if (!this.needFastclick) {
                delete bower.dependencies.fastclick;
            }

            if (!this.addjQuery || !this.addAngular) {
                delete bower.dependencies.jquery;
            }

            this.fs.write(
                this.destinationPath('bower.json'),
                JSON.stringify(bower, null, 2)
            );
        },

        grunt: function() {
            this.fs.delete(
                this.destinationPath('tasks/build.js')
            );
            this.fs.delete(
                this.destinationPath('tasks/default.js')
            );
            this.fs.delete(
                this.destinationPath('options/watch.js')
            );

            this.fs.copyTpl(
                this.templatePath('grunt/tasks/build.js'),
                this.destinationPath('grunt/tasks/build.js'),
                this
            );

            this.fs.copyTpl(
                this.templatePath('grunt/tasks/default.js'),
                this.destinationPath('grunt/tasks/default.js'),
                this
            );

            this.fs.copyTpl(
                this.templatePath('grunt/options/watch.js'),
                this.destinationPath('grunt/options/watch.js'),
                this,
                lodashOptions
            );
        },

        assemble: function() {
            if (this.isSinglePage) {
                this.fs.delete(
                    this.destinationPath('grunt/options/assemble.js')
                );
            }
        },

        modernizr: function() {
            if (!this.addModernizr) {
                this.fs.delete(
                    this.destinationPath('grunt/options/modernizr.js')
                );
            }
        },

        devPath: function () {
            this.sourceRoot(path.join(__dirname, '../../templates/', this.projectType));
        },

        dev: function() {
            this.mkdir('dev');

            if (this.hasAssemble) {
                this.mkdir('dev/partials');
            }
        },

        assets: function() {
            this.fs.copy(
                this.templatePath('../assets/**/*'),
                this.destinationPath('dev/assets')
            );
            this.mkdir('dev/assets/img');
        },

        less: function() {
            this.fs.copy(
                this.templatePath('assets/less/**/*'),
                this.destinationPath('dev/assets/less')
            );
            this.mkdir('dev/assets/less/components');
        },

        html: function() {
            if (this.hasAssemble) {
                this.fs.copyTpl(
                    this.templatePath('templates/default.html'),
                    this.destinationPath('dev/templates/default.html'),
                    this
                );
            }

            this.fs.copyTpl(
                this.templatePath('index.html'),
                this.destinationPath('dev/index.html'),
                this
            );
        },

        install: {
            setupGit: function() {
                if (this.hasGit) {
                    var repository,
                        yo = this,
                        done = yo.async();

                    yo.log(chalk.yellow('\n \nConfiguring git repository and commiting Scaffold'));

                    gift.init('.', function(err, repo) {
                        yo.log(chalk.green('  Init GIT repository'));

                        repository = repo;

                        repository.add('--all', function() {
                            yo.log(chalk.green('  Adding all files'));

                            repository.commit('Add Scaffold', function() {
                                yo.log(chalk.green('  Commiting'));

                                yo.spawnCommand('git', ['remote', 'add', 'origin', yo.gitUrl]).on('exit', function () {
                                    yo.log(chalk.green('  Add origin remote'));
                                });

                                yo.spawnCommand('git', ['config', 'credential.helper', 'store']).on('exit', function () {
                                    yo.log(chalk.green('  Configuring credentials'));

                                    repository.remote_push('origin', 'master', function() {
                                        yo.log(chalk.green('  Push commits'));
                                        done();
                                    });
                                });
                            });
                        });
                    });
                }
            },

            install: function() {
                this.installDependencies({ skipInstall: this.options.skipInstall });
            }
        },

        end: function() {
            var yo = this,
                glob = yo.spawnCommand('npm', ['install', 'glob']);

            glob.on('exit', function() {
                yo.log(chalk.cyan(' \n \n \n All done and no errors! Enjoy! \n \n \n'));

                this.composeWith('scaffold:run', {
                    options: {
                        'skip-welcome': true
                    }
                });
            });
        }

    });

})();
<|endoftext|>


<commit_before>'use strict'

const yeoman = require('yeoman-generator')
const chalk = require('chalk')
const npmName = require('npm-name')

function hubotStartSay () {
  return '                     _____________________________  ' + '\n' +
          '                    /                             \\ ' + '\n' +
          ' ' + chalk.cyan('  //\\') + '              |      Extracting input for    |' + '\n' +
          ' ' + chalk.cyan(' ////\\  ') + '  ' + chalk.yellow('_____') + '    |   self-replication process   |' + '\n' +
          ' ' + chalk.cyan('//////\\  ') + chalk.yellow('/') + chalk.cyan('_____') + chalk.yellow('\\') + '   \\                             / ' + '\n' +
          ' ' + chalk.cyan('=======') + chalk.yellow(' |') + chalk.cyan('[^_/\\_]') + chalk.yellow('|') + '   /----------------------------  ' + '\n' +
          '  ' + chalk.yellow('|   | _|___') + '@@' + chalk.yellow('__|__') + '                                ' + '\n' +
          '  ' + chalk.yellow('+===+/  ///     ') + chalk.cyan('\\_\\') + '                               ' + '\n' +
          '   ' + chalk.cyan('| |_') + chalk.yellow('\\ /// HUBOT/') + chalk.cyan('\\\\') + '                             ' + '\n' +
          '   ' + chalk.cyan('|___/') + chalk.yellow('\\//      /') + chalk.cyan('  \\\\') + '                            ' + '\n' +
          '         ' + chalk.yellow('\\      /   +---+') + '                            ' + '\n' +
          '          ' + chalk.yellow('\\____/    |   |') + '                            ' + '\n' +
          '           ' + chalk.cyan('| //|') + '    ' + chalk.yellow('+===+') + '                            ' + '\n' +
          '            ' + chalk.cyan('\\//') + '      |xx|                            ' +
          '\n'
}

function hubotEndSay () {
  return '                     _____________________________  ' + '\n' +
          ' _____              /                             \\ ' + '\n' +
          ' \\    \\             |   Self-replication process   |' + '\n' +
          ' |    |    ' + chalk.yellow('_____') + '    |          complete...         |' + '\n' +
          ' |__' + chalk.cyan('\\\\') + '|   ' + chalk.yellow('/') + chalk.cyan('_____') + chalk.yellow('\\') + '   \\     Good luck with that.    / ' + '\n' +
          '   ' + chalk.cyan('|//') + chalk.yellow('+  |') + chalk.cyan('[^_/\\_]') + chalk.yellow('|') + '   /----------------------------  ' + '\n' +
          '  ' + chalk.yellow('|   | _|___') + '@@' + chalk.yellow('__|__') + '                                ' + '\n' +
          '  ' + chalk.yellow('+===+/  ///     ') + chalk.cyan('\\_\\') + '                               ' + '\n' +
          '   ' + chalk.cyan('| |_') + chalk.yellow('\\ /// HUBOT/') + chalk.cyan('\\\\') + '                             ' + '\n' +
          '   ' + chalk.cyan('|___/') + chalk.yellow('\\//      /') + chalk.cyan('  \\\\') + '                            ' + '\n' +
          '         ' + chalk.yellow('\\      /   +---+') + '                            ' + '\n' +
          '          ' + chalk.yellow('\\____/    |   |') + '                            ' + '\n' +
          '           ' + chalk.cyan('| //|') + '    ' + chalk.yellow('+===+') + '                            ' + '\n' +
          '            ' + chalk.cyan('\\//') + '      |xx|                            ' +
          '\n'
}

const HubotGenerator = yeoman.generators.Base.extend({

  determineDefaultOwner: function () {
    let userName
    let userEmail

    if (typeof (this.user.git.name) === 'function') {
      userName = this.user.git.name()
    } else {
      userName = this.user.git.name
    }

    if (typeof (this.user.git.email) === 'function') {
      userEmail = this.user.git.email()
    } else {
      userEmail = this.user.git.email
    }

    if (userName && userEmail) {
      return userName + ' <' + userEmail + '>'
    } else {
      return 'User <user@example.com>'
    }
  },

  determineDefaultName: function () {
    return this._.slugify(this.appname)
  },

  defaultAdapter: 'campfire',
  defaultDescription: 'A simple helpful robot for your Company',

  constructor: function () {
    yeoman.generators.Base.apply(this, arguments)

    // FIXME add documentation to these
    this.option('owner', {
      desc: 'Name and email of the owner of new bot (ie Example <user@example.com>)',
      type: String
    })

    this.option('name', {
      desc: 'Name of new bot',
      type: String
    })

    this.option('description', {
      desc: 'Description of the new bot',
      type: String
    })

    this.option('adapter', {
      desc: 'Hubot adapter to use for new bot',
      type: String
    })

    this.option('defaults', {
      desc: "Accept defaults and don't prompt for user input",
      type: Boolean
    })

    if (this.options.defaults) {
      this.options.owner = this.options.owner || this.determineDefaultOwner()
      this.options.name = this.options.name || this.determineDefaultName()
      this.options.adapter = this.options.adapter || this.defaultAdapter
      this.options.description = this.options.description || this.defaultDescription
    }

    if (this.options.owner === true) {
      this.env.error('Missing owner. Make sure to specify it like --owner="<owner>"')
    }

    if (this.options.name === true) {
      this.env.error('Missing name. Make sure to specify it like --name="<name>"')
    }

    if (this.options.description === true) {
      this.env.error('Missing description. Make sure to specify it like --description="<description>"')
    }

    if (this.options.adapter === true) {
      this.env.error('Missing adapter name. Make sure to specify it like --adapter=<adapter>')
    }
  },

  initializing: function () {
    this.pkg = require('../../package.json')

    this.externalScripts = [
      'hubot-diagnostics',
      'hubot-help',
      'hubot-heroku-keepalive',
      'hubot-google-images',
      'hubot-google-translate',
      'hubot-pugme',
      'hubot-maps',
      'hubot-redis-brain',
      'hubot-rules',
      'hubot-shipit'
    ]
  },

  prompting: {
    askFor: function () {
      const done = this.async()
      const botOwner = this.determineDefaultOwner()

      const prompts = []
      if (!this.options.owner) {
        prompts.push({
          name: 'botOwner',
          message: 'Owner',
          default: botOwner
        })
      }

      this.log(hubotStartSay())
      this.prompt(prompts, function (props) {
        this.botOwner = this.options.owner || props.botOwner

        done()
      }.bind(this))
    },

    askForBotNameAndDescription: function () {
      const done = this.async()
      const botName = this.determineDefaultName()

      const prompts = []

      if (!this.options.name) {
        prompts.push({
          name: 'botName',
          message: 'Bot name',
          default: botName
        })
      }

      if (!this.options.description) {
        prompts.push({
          name: 'botDescription',
          message: 'Description',
          default: this.defaultDescription
        })
      }

      this.prompt(prompts, function (props) {
        this.botName = this.options.name || props.botName
        this.botDescription = this.options.description || props.botDescription

        done()
      }.bind(this))
    },

    askForBotAdapter: function () {
      const done = this.async()

      const prompts = []
      // FIXME validate argument like we do when prompting
      if (!this.options.adapter) {
        prompts.push({
          name: 'botAdapter',
          message: 'Bot adapter',
          default: this.defaultAdapter,
          validate: function (botAdapter) {
            const done = this.async()

            if (botAdapter === 'campfire') {
              done(null, true)
              return
            }

            const name = 'hubot-' + botAdapter
            npmName(name, function (error, unavailable) {
              if (error) throw error
              if (unavailable) {
                done("Can't find that adapter on NPM, try again?")
                return
              }

              done(null, true)
            })
          }
        })
      }

      this.prompt(prompts, function (props) {
        this.botAdapter = this.options.adapter || props.botAdapter

        done()
      }.bind(this))
    }
  },

  writing: {
    app: function () {
      this.mkdir('bin')
      this.copy('bin/hubot', 'bin/hubot')
      this.copy('bin/hubot.cmd', 'bin/hubot.cmd')

      this.template('Procfile', 'Procfile')
      this.template('README.md', 'README.md')

      this.write('external-scripts.json', JSON.stringify(this.externalScripts, undefined, 2))

      this.copy('gitignore', '.gitignore')
      this.template('_package.json', 'package.json')

      this.directory('scripts', 'scripts')
    }
  },

  end: function () {
    const packages = ['hubot', 'hubot-scripts'].concat(this.externalScripts)

    if (this.botAdapter !== 'campfire') {
      packages.push('hubot-' + this.botAdapter)
    }

    this.npmInstall(packages, {'save': true})

    this.log(hubotEndSay())
  }
})

module.exports = HubotGenerator
<commit_msg>fix: remove no longer unsupport scripts and hubot-scripts from default dependencies<commit_after>'use strict'

const yeoman = require('yeoman-generator')
const chalk = require('chalk')
const npmName = require('npm-name')

function hubotStartSay () {
  return '                     _____________________________  ' + '\n' +
          '                    /                             \\ ' + '\n' +
          ' ' + chalk.cyan('  //\\') + '              |      Extracting input for    |' + '\n' +
          ' ' + chalk.cyan(' ////\\  ') + '  ' + chalk.yellow('_____') + '    |   self-replication process   |' + '\n' +
          ' ' + chalk.cyan('//////\\  ') + chalk.yellow('/') + chalk.cyan('_____') + chalk.yellow('\\') + '   \\                             / ' + '\n' +
          ' ' + chalk.cyan('=======') + chalk.yellow(' |') + chalk.cyan('[^_/\\_]') + chalk.yellow('|') + '   /----------------------------  ' + '\n' +
          '  ' + chalk.yellow('|   | _|___') + '@@' + chalk.yellow('__|__') + '                                ' + '\n' +
          '  ' + chalk.yellow('+===+/  ///     ') + chalk.cyan('\\_\\') + '                               ' + '\n' +
          '   ' + chalk.cyan('| |_') + chalk.yellow('\\ /// HUBOT/') + chalk.cyan('\\\\') + '                             ' + '\n' +
          '   ' + chalk.cyan('|___/') + chalk.yellow('\\//      /') + chalk.cyan('  \\\\') + '                            ' + '\n' +
          '         ' + chalk.yellow('\\      /   +---+') + '                            ' + '\n' +
          '          ' + chalk.yellow('\\____/    |   |') + '                            ' + '\n' +
          '           ' + chalk.cyan('| //|') + '    ' + chalk.yellow('+===+') + '                            ' + '\n' +
          '            ' + chalk.cyan('\\//') + '      |xx|                            ' +
          '\n'
}

function hubotEndSay () {
  return '                     _____________________________  ' + '\n' +
          ' _____              /                             \\ ' + '\n' +
          ' \\    \\             |   Self-replication process   |' + '\n' +
          ' |    |    ' + chalk.yellow('_____') + '    |          complete...         |' + '\n' +
          ' |__' + chalk.cyan('\\\\') + '|   ' + chalk.yellow('/') + chalk.cyan('_____') + chalk.yellow('\\') + '   \\     Good luck with that.    / ' + '\n' +
          '   ' + chalk.cyan('|//') + chalk.yellow('+  |') + chalk.cyan('[^_/\\_]') + chalk.yellow('|') + '   /----------------------------  ' + '\n' +
          '  ' + chalk.yellow('|   | _|___') + '@@' + chalk.yellow('__|__') + '                                ' + '\n' +
          '  ' + chalk.yellow('+===+/  ///     ') + chalk.cyan('\\_\\') + '                               ' + '\n' +
          '   ' + chalk.cyan('| |_') + chalk.yellow('\\ /// HUBOT/') + chalk.cyan('\\\\') + '                             ' + '\n' +
          '   ' + chalk.cyan('|___/') + chalk.yellow('\\//      /') + chalk.cyan('  \\\\') + '                            ' + '\n' +
          '         ' + chalk.yellow('\\      /   +---+') + '                            ' + '\n' +
          '          ' + chalk.yellow('\\____/    |   |') + '                            ' + '\n' +
          '           ' + chalk.cyan('| //|') + '    ' + chalk.yellow('+===+') + '                            ' + '\n' +
          '            ' + chalk.cyan('\\//') + '      |xx|                            ' +
          '\n'
}

const HubotGenerator = yeoman.generators.Base.extend({

  determineDefaultOwner: function () {
    let userName
    let userEmail

    if (typeof (this.user.git.name) === 'function') {
      userName = this.user.git.name()
    } else {
      userName = this.user.git.name
    }

    if (typeof (this.user.git.email) === 'function') {
      userEmail = this.user.git.email()
    } else {
      userEmail = this.user.git.email
    }

    if (userName && userEmail) {
      return userName + ' <' + userEmail + '>'
    } else {
      return 'User <user@example.com>'
    }
  },

  determineDefaultName: function () {
    return this._.slugify(this.appname)
  },

  defaultAdapter: 'campfire',
  defaultDescription: 'A simple helpful robot for your Company',

  constructor: function () {
    yeoman.generators.Base.apply(this, arguments)

    // FIXME add documentation to these
    this.option('owner', {
      desc: 'Name and email of the owner of new bot (ie Example <user@example.com>)',
      type: String
    })

    this.option('name', {
      desc: 'Name of new bot',
      type: String
    })

    this.option('description', {
      desc: 'Description of the new bot',
      type: String
    })

    this.option('adapter', {
      desc: 'Hubot adapter to use for new bot',
      type: String
    })

    this.option('defaults', {
      desc: "Accept defaults and don't prompt for user input",
      type: Boolean
    })

    if (this.options.defaults) {
      this.options.owner = this.options.owner || this.determineDefaultOwner()
      this.options.name = this.options.name || this.determineDefaultName()
      this.options.adapter = this.options.adapter || this.defaultAdapter
      this.options.description = this.options.description || this.defaultDescription
    }

    if (this.options.owner === true) {
      this.env.error('Missing owner. Make sure to specify it like --owner="<owner>"')
    }

    if (this.options.name === true) {
      this.env.error('Missing name. Make sure to specify it like --name="<name>"')
    }

    if (this.options.description === true) {
      this.env.error('Missing description. Make sure to specify it like --description="<description>"')
    }

    if (this.options.adapter === true) {
      this.env.error('Missing adapter name. Make sure to specify it like --adapter=<adapter>')
    }
  },

  initializing: function () {
    this.pkg = require('../../package.json')

    this.externalScripts = [
      'hubot-diagnostics',
      'hubot-help',
      'hubot-redis-brain',
      'hubot-rules'
    ]
  },

  prompting: {
    askFor: function () {
      const done = this.async()
      const botOwner = this.determineDefaultOwner()

      const prompts = []
      if (!this.options.owner) {
        prompts.push({
          name: 'botOwner',
          message: 'Owner',
          default: botOwner
        })
      }

      this.log(hubotStartSay())
      this.prompt(prompts, function (props) {
        this.botOwner = this.options.owner || props.botOwner

        done()
      }.bind(this))
    },

    askForBotNameAndDescription: function () {
      const done = this.async()
      const botName = this.determineDefaultName()

      const prompts = []

      if (!this.options.name) {
        prompts.push({
          name: 'botName',
          message: 'Bot name',
          default: botName
        })
      }

      if (!this.options.description) {
        prompts.push({
          name: 'botDescription',
          message: 'Description',
          default: this.defaultDescription
        })
      }

      this.prompt(prompts, function (props) {
        this.botName = this.options.name || props.botName
        this.botDescription = this.options.description || props.botDescription

        done()
      }.bind(this))
    },

    askForBotAdapter: function () {
      const done = this.async()

      const prompts = []
      // FIXME validate argument like we do when prompting
      if (!this.options.adapter) {
        prompts.push({
          name: 'botAdapter',
          message: 'Bot adapter',
          default: this.defaultAdapter,
          validate: function (botAdapter) {
            const done = this.async()

            if (botAdapter === 'campfire') {
              done(null, true)
              return
            }

            const name = 'hubot-' + botAdapter
            npmName(name, function (error, unavailable) {
              if (error) throw error
              if (unavailable) {
                done("Can't find that adapter on NPM, try again?")
                return
              }

              done(null, true)
            })
          }
        })
      }

      this.prompt(prompts, function (props) {
        this.botAdapter = this.options.adapter || props.botAdapter

        done()
      }.bind(this))
    }
  },

  writing: {
    app: function () {
      this.mkdir('bin')
      this.copy('bin/hubot', 'bin/hubot')
      this.copy('bin/hubot.cmd', 'bin/hubot.cmd')

      this.template('Procfile', 'Procfile')
      this.template('README.md', 'README.md')

      this.write('external-scripts.json', JSON.stringify(this.externalScripts, undefined, 2))

      this.copy('gitignore', '.gitignore')
      this.template('_package.json', 'package.json')

      this.directory('scripts', 'scripts')
    }
  },

  end: function () {
    const packages = ['hubot'].concat(this.externalScripts)

    if (this.botAdapter !== 'campfire') {
      packages.push('hubot-' + this.botAdapter)
    }

    this.npmInstall(packages, {'save': true})

    this.log(hubotEndSay())
  }
})

module.exports = HubotGenerator
<|endoftext|>


<commit_before>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');

const tplCopy = function (name, to, props) {
  this.fs.copyTpl(
    this.templatePath(name),
    this.destinationPath(to || name),
    (props || this.props)
  );
};

const fileListCopy = function (files, dest) {
  const cpy = tplCopy.bind(this);
  files.forEach(filename => {
    cpy(filename, dest, this.props);
  });
};

const availableFeatures = [
  'redux'
];

module.exports = yeoman.Base.extend({
  prompting: function () {
    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the gnarly ' + chalk.red('generator-react-gen') + ' generator!'
    ));

    var prompts = [{
      type: 'input',
      name: 'title',
      message: 'App name',
      default: this.appname
    }, {
      type: 'input',
      name: 'authorName',
      message: 'Author name',
      default: 'Ari Lerner'
    }, {
      type: 'input',
      name: 'authorEmail',
      message: 'Author email',
      default: 'ari@fullstack.io'
    }];

    // feature options
    availableFeatures.forEach(feature => this.option(feature));

    return this.prompt(prompts)
    .then(function (props) {
      // To access props later use this.props.someAnswer;
      this.props = props;

      this.features = [];
      availableFeatures.forEach(feature => {
        if (this.options[feature]) {
          this.features.push(feature);
        }
      });
    }.bind(this));
  },

  writing: function () {
    // root files
    var copyFiles = fileListCopy.bind(this);
    var baseFiles = ['package.json',
      'tests.webpack.js',
      'webpack.config.js',
      'karma.conf.js',
      '.babelrc',
      '.gitignore',
      'src/',
      'config/'
    ];
    var dependencies = [
      'react', 'react-dom', 'classnames', 'font-awesome',
      'react-router', 'react-router-redux'
    ];
    var devDependencies = [
      'autoprefixer',
      'babel-core',
      'babel-loader',
      'babel-plugin-transform-es2015-modules-umd',
      'babel-polyfill',
      'babel-preset-es2015',
      'babel-preset-react',
      'babel-preset-react-hmre',
      'babel-preset-stage-0',
      'babel-register',
      'chai',
      'chai-enzyme',
      'cross-env',
      'css-loader',
      'cssnano',
      'dotenv',
      'enzyme',
      'expect',
      'file-loader',
      'hjs-webpack',
      'jasmine-core',
      'json-loader',
      'karma',
      'karma-chai',
      'karma-jasmine',
      'karma-mocha',
      'karma-phantomjs-launcher',
      'karma-sourcemap-loader',
      'karma-spec-reporter',
      'karma-webpack',
      'mocha',
      'phantomjs-polyfill',
      'phantomjs-prebuilt',
      'postcss-loader',
      'precss',
      'react-addons-test-utils',
      'sinon',
      'style-loader',
      'url-loader',
      'webpack'
    ];

    var featureFiles = {
      redux: {
        'src/': {
          dependencies: ['react-redux',
            'redux-module-builder', 'redux-thunk'],
          devDependencies: ['redux-devtools',
          'redux-devtools-log-monitor', 'redux-devtools-dock-monitor'],
          files: ['features/redux/']
        }
      }
    };

    copyFiles(baseFiles);
    const cp = tplCopy.bind(this);
    cp("env", ".env", this.props);
    cp("gitignore", ".gitignore", this.props);

    this.features.forEach(featureKey => {
      this.log(`======> Enabling ` + chalk.blue(featureKey));
      const feat = featureFiles[featureKey];
      Object.keys(feat)
      .forEach(key => {
        const dest = key;
        const feature = feat[key];
        const files = feature.files;
        copyFiles(files, dest);

        if (feature.dependencies) {
          dependencies = dependencies.concat(feature.dependencies);
        }
        if (feature.devDependencies) {
          devDependencies =
            devDependencies.concat(feature.devDependencies);
        }
      });
    });

    this.npmInstall(dependencies, {save: true});
    this.npmInstall(devDependencies, {saveDev: true});
  },

  install: function () {
    this.installDependencies();
  }
});
<commit_msg>Fixed gitignore bug<commit_after>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');

const tplCopy = function (name, to, props) {
  this.fs.copyTpl(
    this.templatePath(name),
    this.destinationPath(to || name),
    (props || this.props)
  );
};

const fileListCopy = function (files, dest) {
  const cpy = tplCopy.bind(this);
  files.forEach(filename => {
    cpy(filename, dest, this.props);
  });
};

const availableFeatures = [
  'redux'
];

module.exports = yeoman.Base.extend({
  prompting: function () {
    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the gnarly ' + chalk.red('generator-react-gen') + ' generator!'
    ));

    var prompts = [{
      type: 'input',
      name: 'title',
      message: 'App name',
      default: this.appname
    }, {
      type: 'input',
      name: 'authorName',
      message: 'Author name',
      default: 'Ari Lerner'
    }, {
      type: 'input',
      name: 'authorEmail',
      message: 'Author email',
      default: 'ari@fullstack.io'
    }];

    // feature options
    availableFeatures.forEach(feature => this.option(feature));

    return this.prompt(prompts)
    .then(function (props) {
      // To access props later use this.props.someAnswer;
      this.props = props;

      this.features = [];
      availableFeatures.forEach(feature => {
        if (this.options[feature]) {
          this.features.push(feature);
        }
      });
    }.bind(this));
  },

  writing: function () {
    // root files
    var copyFiles = fileListCopy.bind(this);
    var baseFiles = ['package.json',
      'tests.webpack.js',
      'webpack.config.js',
      'karma.conf.js',
      '.babelrc',
      'src/',
      'config/'
    ];
    var dependencies = [
      'react', 'react-dom', 'classnames', 'font-awesome',
      'react-router', 'react-router-redux'
    ];
    var devDependencies = [
      'autoprefixer',
      'babel-core',
      'babel-loader',
      'babel-plugin-transform-es2015-modules-umd',
      'babel-polyfill',
      'babel-preset-es2015',
      'babel-preset-react',
      'babel-preset-react-hmre',
      'babel-preset-stage-0',
      'babel-register',
      'chai',
      'chai-enzyme',
      'cross-env',
      'css-loader',
      'cssnano',
      'dotenv',
      'enzyme',
      'expect',
      'file-loader',
      'hjs-webpack',
      'jasmine-core',
      'json-loader',
      'karma',
      'karma-chai',
      'karma-jasmine',
      'karma-mocha',
      'karma-phantomjs-launcher',
      'karma-sourcemap-loader',
      'karma-spec-reporter',
      'karma-webpack',
      'mocha',
      'phantomjs-polyfill',
      'phantomjs-prebuilt',
      'postcss-loader',
      'precss',
      'react-addons-test-utils',
      'sinon',
      'style-loader',
      'url-loader',
      'webpack'
    ];

    var featureFiles = {
      redux: {
        'src/': {
          dependencies: ['react-redux',
            'redux-module-builder', 'redux-thunk'],
          devDependencies: ['redux-devtools',
          'redux-devtools-log-monitor', 'redux-devtools-dock-monitor'],
          files: ['features/redux/']
        }
      }
    };

    copyFiles(baseFiles);
    const cp = tplCopy.bind(this);
    cp("env", ".env", this.props);
    cp("gitignore", ".gitignore", this.props);

    this.features.forEach(featureKey => {
      this.log(`======> Enabling ` + chalk.blue(featureKey));
      const feat = featureFiles[featureKey];
      Object.keys(feat)
      .forEach(key => {
        const dest = key;
        const feature = feat[key];
        const files = feature.files;
        copyFiles(files, dest);

        if (feature.dependencies) {
          dependencies = dependencies.concat(feature.dependencies);
        }
        if (feature.devDependencies) {
          devDependencies =
            devDependencies.concat(feature.devDependencies);
        }
      });
    });

    this.npmInstall(dependencies, {save: true});
    this.npmInstall(devDependencies, {saveDev: true});
  },

  install: function () {
    this.installDependencies();
  }
});
<|endoftext|>


<commit_before>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var _ = require('lodash-fp');

module.exports = yeoman.generators.Base.extend({

  prompting: function() {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the magnificent ' + chalk.red(
        'generator-apidoc-play-service') + ' generator!'
    ));

    var prompts = [{
      type: 'input',
      name: 'organization',
      message: 'Organization',
      default: 'movio.cinema',
      store: true
    }, {
      type: 'input',
      name: 'projectName',
      message: 'Project name',
      default: 'members core'
    }, {
      type: 'input',
      name: 'appName',
      message: 'Application name (eg in github)',
      default: function(answers) {
        var abbrev = answers.organization.match(/\b(\w)/g).join('');
        return abbrev + '-' + _.kebabCase(answers.projectName) +
          '-svc';
      }
    }, {
      type: 'input',
      name: 'maxMemory',
      message: 'Max memory',
      default: '128'
    }, {
      type: 'input',
      name: 'jmxPort',
      message: 'JMX PORT',
      default: '5401'
    }, {
      type: 'input',
      name: 'rmiHostname',
      message: 'RMI Hostname',
      default: 'dockerhost'
    }, {
      type: 'confirm',
      name: 'useApidoc',
      message: 'Use apidoc',
      default: true
    }, {
      type: 'input',
      name: 'apidocOrg',
      message: 'apidoc organization',
      when: function(answers) {
        return answers.useApidoc;
      },
      default: function(answers) {
        return answers.organization;
      },
      store: true
    }, {
      type: 'input',
      name: 'apidocApp',
      message: 'apidoc application name',
      when: function(answers) {
        return answers.useApidoc;
      },
      default: function(answers) {
        return _.kebabCase(answers.projectName);
      }
    }, {
      type: 'input',
      name: 'apidocVersion',
      message: 'apidoc application version',
      when: function(answers) {
        return answers.useApidoc;
      },
      default: '0.1.0-SNAPSHOT'
    }];

    this.prompt(prompts, function(props) {
      // To access props later use this.props.someOption;
      this.props = props;

      props.orgAbbreviation = props.organization.match(/\b(\w)/g).join(
        '');
      props.appNameSpace = props.projectName.toLowerCase().split(' ')
        .join('.');

      done();
    }.bind(this));
  },

  writing: function() {
    // Add all files in the shared directory
    this.directory('shared', '.');
  },

  install: function() {
    this.installDependencies();
  }
});
<commit_msg>Add metric/unit to max memory<commit_after>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var _ = require('lodash-fp');

module.exports = yeoman.generators.Base.extend({

  prompting: function() {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the magnificent ' + chalk.red(
        'generator-apidoc-play-service') + ' generator!'
    ));

    var prompts = [{
      type: 'input',
      name: 'organization',
      message: 'Organization',
      default: 'movio.cinema',
      store: true
    }, {
      type: 'input',
      name: 'projectName',
      message: 'Project name',
      default: 'members core'
    }, {
      type: 'input',
      name: 'appName',
      message: 'Application name (eg in github)',
      default: function(answers) {
        var abbrev = answers.organization.match(/\b(\w)/g).join('');
        return abbrev + '-' + _.kebabCase(answers.projectName) +
          '-svc';
      }
    }, {
      type: 'input',
      name: 'maxMemory',
      message: 'Max memory',
      default: '128m'
    }, {
      type: 'input',
      name: 'jmxPort',
      message: 'JMX PORT',
      default: '5401'
    }, {
      type: 'input',
      name: 'rmiHostname',
      message: 'RMI Hostname',
      default: 'dockerhost'
    }, {
      type: 'confirm',
      name: 'useApidoc',
      message: 'Use apidoc',
      default: true
    }, {
      type: 'input',
      name: 'apidocOrg',
      message: 'apidoc organization',
      when: function(answers) {
        return answers.useApidoc;
      },
      default: function(answers) {
        return answers.organization;
      },
      store: true
    }, {
      type: 'input',
      name: 'apidocApp',
      message: 'apidoc application name',
      when: function(answers) {
        return answers.useApidoc;
      },
      default: function(answers) {
        return _.kebabCase(answers.projectName);
      }
    }, {
      type: 'input',
      name: 'apidocVersion',
      message: 'apidoc application version',
      when: function(answers) {
        return answers.useApidoc;
      },
      default: '0.1.0-SNAPSHOT'
    }];

    this.prompt(prompts, function(props) {
      // To access props later use this.props.someOption;
      this.props = props;

      props.orgAbbreviation = props.organization.match(/\b(\w)/g).join(
        '');
      props.appNameSpace = props.projectName.toLowerCase().split(' ')
        .join('.');

      done();
    }.bind(this));
  },

  writing: function() {
    // Add all files in the shared directory
    this.directory('shared', '.');
  },

  install: function() {
    this.installDependencies();
  }
});
<|endoftext|>


<commit_before>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
// var extend = require('deep-extend');
var changeCase = require('change-case');

module.exports = yeoman.generators.Base.extend({
  prompting: {
    greeting() {
      this.log(yosay('Welcome to the sensational ' + chalk.red('typings') + ' generator!'));
    },
    sourceUri() {
      var done = this.async();

      const uriExamples = [
        'facebook/react',
        'atom/atom',
        'microsoft/vscode',
        'angular/angular'
      ];

      this.prompt({
        type: 'input',
        name: 'sourceUri',
        message: `What is the ${chalk.green('source') } author/module name?`,
        default: () => uriExamples[Math.round(Math.random() * 4 - 0.5)],
        validate: (value) => value.length > 0
      }, (props) => {
        this.sourceUri = props.sourceUri;
        this.sourcePackageUrl = `https://github.com/${props.sourceUri}`;
        this.sourcePackageName = props.sourceUri.split('/')[1];
        this.prettyPackageName = changeCase.titleCase(this.sourcePackageName.replace('-', ' '));
        done();
      });
    },
    packageName() {
      var done = this.async();

      this.prompt({
        type: 'input',
        name: 'packageName',
        message: 'Can I name this project as',
        default: () => `typed-${this.sourcePackageName}`,
        validate: (value) => value.length > 0
      }, (props) => {
        this.packageName = props.packageName;
        done();
      });
    },
    username() {
      var done = this.async();

      this.prompt({
        type: 'input',
        name: 'username',
        message: 'And your GitHub username is...',
        validate: (value) => value.length > 0,
        store: true
      }, (props) => {
        this.username = props.username;
        done();
      });
    }
  },

  writing: {
    copyFiles() {
      this.fs.copy(
        this.templatePath('**/*'),
        this.destinationPath()
        );
      this.fs.copy(
        this.templatePath('**/.*'),
        this.destinationPath()
        );
    },
    createTypings() {
      var typings = { name: this.sourcePackageName, main: 'main.d.ts' };
      this.fs.writeJSON(this.destinationPath('typings.json'), typings);
    },
    createTsconfig() {
      var tsconfig = {
        compilerOptions: {
          module: 'commonjs',
          moduleResolution: 'node'
        },
        // TODO: add ambient source typings file
        files: ['main.d.ts', 'typings/main.d.ts']
      };
      this.fs.writeJSON(this.destinationPath('tsconfig.json'), tsconfig);
    },
    createREADME() {
      this.fs.write('README.md',
        `# Typed ${this.prettyPackageName}\n` +
        `The type definition for [${this.sourcePackageName }](${this.sourceUrl}).`);
    },
    createTest() {
      this.fs.write('test/test.ts',
        `import * as ${this.sourcePackageName} from '${this.sourcePackageName}'`);
    },
    updatePackageJson() {
      var pkg = this.fs.read(this.destinationPath('package.json'));
      console.log(this.packageName, this.sourcePackageUrl, this.sourcePackageName, this.username);
      pkg = pkg.replace('{username}', this.username);
      pkg = pkg.replace('{packageName}', this.packageName);
      pkg = pkg.replace('{sourcePackageName}', this.sourcePackageName);
      pkg = pkg.replace('{sourcePackageUrl}', this.sourcePackageUrl);
      this.fs.write(this.destinationPath('package.json'), pkg);

      // Don't know why it doesn't work.
      // var pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
      // extend(pkg, {
      //   packageName: this.packageName,
      //   sourcePackageUrl: this.sourcePackageUrl,
      //   sourcePackageName: this.sourcePackageName,
      //   username: this.username
      // });
      // this.fs.writeJSON(this.destinationPath('package.json'), pkg);
    },
    updateLICENSE() {
      var lic = this.fs.read(this.destinationPath('LICENSE'));
      lic = lic.replace('{username}', this.username);
      this.fs.write(this.destinationPath('LICENSE'), lic);
    }
  },
  install: {
    npm() {
      this.log(`Running ${chalk.green('npm install') }...`);
      this.spawnCommandSync('npm', ['install']);
    }
  },
  end: {
    goodbye() {
      this.log(`Almost ready! Run ${chalk.green(`typings install ${this.sourcePackageName} --ambient"`) }`);
      this.log('  to get a copy of the DefinitelyTyped file (if available)');
      this.log('  so you have something to start with!');
    }
  }
});
<commit_msg>Cosmetic<commit_after>'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
// var extend = require('deep-extend');
var changeCase = require('change-case');

module.exports = yeoman.generators.Base.extend({
  prompting: {
    greeting() {
      this.log(yosay('Welcome to the sensational ' + chalk.red('typings') + ' generator!'));
    },
    sourceUri() {
      var done = this.async();

      const uriExamples = [
        'facebook/react',
        'atom/atom',
        'microsoft/vscode',
        'angular/angular'
      ];

      this.prompt({
        type: 'input',
        name: 'sourceUri',
        message: `What is the ${chalk.green('source') } author/module name?`,
        default: () => uriExamples[Math.round(Math.random() * 4 - 0.5)],
        validate: (value) => value.length > 0
      }, (props) => {
        this.sourceUri = props.sourceUri;
        this.sourcePackageUrl = `https://github.com/${props.sourceUri}`;
        this.sourcePackageName = props.sourceUri.split('/')[1];
        this.prettyPackageName = changeCase.titleCase(this.sourcePackageName.replace('-', ' '));
        done();
      });
    },
    packageName() {
      var done = this.async();

      this.prompt({
        type: 'input',
        name: 'packageName',
        message: 'Can I name this project as...',
        default: () => `typed-${this.sourcePackageName}`,
        validate: (value) => value.length > 0
      }, (props) => {
        this.packageName = props.packageName;
        done();
      });
    },
    username() {
      var done = this.async();

      this.prompt({
        type: 'input',
        name: 'username',
        message: 'And your GitHub username is...',
        validate: (value) => value.length > 0,
        store: true
      }, (props) => {
        this.username = props.username;
        done();
      });
    }
  },

  writing: {
    copyFiles() {
      this.fs.copy(
        this.templatePath('**/*'),
        this.destinationPath()
        );
      this.fs.copy(
        this.templatePath('**/.*'),
        this.destinationPath()
        );
    },
    createTypings() {
      var typings = { name: this.sourcePackageName, main: 'main.d.ts' };
      this.fs.writeJSON(this.destinationPath('typings.json'), typings);
    },
    createTsconfig() {
      var tsconfig = {
        compilerOptions: {
          module: 'commonjs',
          moduleResolution: 'node'
        },
        // TODO: add ambient source typings file
        files: ['main.d.ts', 'typings/main.d.ts']
      };
      this.fs.writeJSON(this.destinationPath('tsconfig.json'), tsconfig);
    },
    createREADME() {
      this.fs.write('README.md',
        `# Typed ${this.prettyPackageName}\n` +
        `The type definition for [${this.sourcePackageName }](${this.sourceUrl}).`);
    },
    createTest() {
      this.fs.write('test/test.ts',
        `import * as ${this.sourcePackageName} from '${this.sourcePackageName}'`);
    },
    updatePackageJson() {
      var pkg = this.fs.read(this.destinationPath('package.json'));
      console.log(this.packageName, this.sourcePackageUrl, this.sourcePackageName, this.username);
      pkg = pkg.replace('{username}', this.username);
      pkg = pkg.replace('{packageName}', this.packageName);
      pkg = pkg.replace('{sourcePackageName}', this.sourcePackageName);
      pkg = pkg.replace('{sourcePackageUrl}', this.sourcePackageUrl);
      this.fs.write(this.destinationPath('package.json'), pkg);

      // Don't know why it doesn't work.
      // var pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
      // extend(pkg, {
      //   packageName: this.packageName,
      //   sourcePackageUrl: this.sourcePackageUrl,
      //   sourcePackageName: this.sourcePackageName,
      //   username: this.username
      // });
      // this.fs.writeJSON(this.destinationPath('package.json'), pkg);
    },
    updateLICENSE() {
      var lic = this.fs.read(this.destinationPath('LICENSE'));
      lic = lic.replace('{username}', this.username);
      this.fs.write(this.destinationPath('LICENSE'), lic);
    }
  },
  install: {
    npm() {
      this.log(`Running ${chalk.green('npm install') }...`);
      this.spawnCommandSync('npm', ['install']);
    }
  },
  end: {
    goodbye() {
      this.log('');
      this.log('Almost ready!');
      this.log(`Run ${chalk.green(`typings install ${this.sourcePackageName} --ambient"`) }`);
      this.log('  to get a copy of the DefinitelyTyped file (if available)');
      this.log('  so you have something to start with!');
    }
  }
});
<|endoftext|>


<commit_before>// imports

const generator = require('yeoman-generator');
const chalk = require('chalk');
const packagejs = require('../../package.json'); // gives access to the package.json data
const dbh = require('./db-helper-utility.js'); // db-helper utility functions

// constants

// Stores JHipster variables
const jhipsterVar = { moduleName: 'db-helper' };

// Stores JHipster functions
const jhipsterFunc = {};

module.exports = generator.extend({

    // check current project state, get configs, etc
    initializing: {
        compose() {
            // DEBUG : log where we are
            dbh.debugLog('initializing: compose');

            this.composeWith('jhipster:modules',
                { jhipsterVar, jhipsterFunc },
                this.options.testmode ? { local: require.resolve('generator-jhipster/generators/modules') } : null
            );
        },
        displayLogo() {
            // Have Yeoman greet the user.
            this.log(`${chalk.bold.yellow('JHipster db-helper')} generator ${chalk.yellow(`v${packagejs.version}\n`)}`);
        }
    },

    // prompt the user for options
    prompting() {
        const done = this.async();

        // DEBUG : log where we are
        dbh.debugLog('prompting');

        // user interaction on module call goes here
        const prompts = [
            {
                type: 'input',
                name: 'message',
                message: 'Please put something',
                default: 'hello world!'
            }
        ];

        // call the prompts
        this.prompt(prompts).then((props) => {
            this.props = props;
            // To access props later use this.props.someOption;

            done();
        });
    },

    // other Yeoman run steps would go here :
    // configuring() {}
    // default() {}

    // write the generator-specific files
    writing() {
        // DEBUG : log where we are
        dbh.debugLog('writing');

        // replace files with Spring's naming strategies
        dbh.replaceNamingStrategies();

        // function to use directly template
        this.template = function (source, destination) {
            this.fs.copyTpl(
                this.templatePath(source),
                this.destinationPath(destination),
                this
            );
        };

        this.baseName = jhipsterVar.baseName;
        this.packageName = jhipsterVar.packageName;
        this.angularAppName = jhipsterVar.angularAppName;
        this.clientFramework = jhipsterVar.clientFramework;
        this.clientPackageManager = jhipsterVar.clientPackageManager;
        const javaDir = jhipsterVar.javaDir;
        const resourceDir = jhipsterVar.resourceDir;
        const webappDir = jhipsterVar.webappDir;

        this.message = this.props.message;

        this.log('\n--- some config read from config ---');
        this.log(`baseName=${this.baseName}`);
        this.log(`packageName=${this.packageName}`);
        this.log(`angularAppName=${this.angularAppName}`);
        this.log(`clientFramework=${this.clientFramework}`);
        this.log(`clientPackageManager=${this.clientPackageManager}`);
        this.log(`javaDir=${javaDir}`);
        this.log(`resourceDir=${resourceDir}`);
        this.log(`webappDir=${webappDir}`);
        this.log(`\nmessage=${this.message}`);
        this.log('------\n');

        this.template('dummy.txt', 'dummy.txt');
        try {
            jhipsterFunc.registerModule('generator-jhipster-db-helper', 'entity', 'post', 'app', 'A JHipster module for already existing databases');
        } catch (err) {
            this.log(`${chalk.red.bold('WARN!')} Could not register as a jhipster entity post creation hook...\n`);
        }
    },

    // run installation (npm, bower, etc)
    install() {
        let logMsg =
            `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install`)}`;

        // DEBUG : log where we are
        dbh.debugLog('install');

        if (this.clientFramework === 'angular1') {
            logMsg =
                `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install & bower install`)}`;
        }
        const injectDependenciesAndConstants = (err) => {
            if (err) {
                this.warning('Install of dependencies failed!');
                this.log(logMsg);
            } else if (this.clientFramework === 'angular1') {
                this.spawnCommand('gulp', ['install']);
            }
        };
        const installConfig = {
            bower: this.clientFramework === 'angular1',
            npm: this.clientPackageManager !== 'yarn',
            yarn: this.clientPackageManager === 'yarn',
            callback: injectDependenciesAndConstants
        };
        this.installDependencies(installConfig);
    },

    // cleanup, say goodbye
    end() {
        // DEBUG : log where we are
        dbh.debugLog('end');

        this.log('End of db-helper generator');
    }
});
<commit_msg>move hook to post app rather than post entity<commit_after>// imports

const generator = require('yeoman-generator');
const chalk = require('chalk');
const packagejs = require('../../package.json'); // gives access to the package.json data
const dbh = require('./db-helper-utility.js'); // db-helper utility functions

// constants

// Stores JHipster variables
const jhipsterVar = { moduleName: 'db-helper' };

// Stores JHipster functions
const jhipsterFunc = {};

module.exports = generator.extend({

    // check current project state, get configs, etc
    initializing: {
        compose() {
            // DEBUG : log where we are
            dbh.debugLog('initializing: compose');

            this.composeWith('jhipster:modules',
                { jhipsterVar, jhipsterFunc },
                this.options.testmode ? { local: require.resolve('generator-jhipster/generators/modules') } : null
            );
        },
        displayLogo() {
            // Have Yeoman greet the user.
            this.log(`${chalk.bold.yellow('JHipster db-helper')} generator ${chalk.yellow(`v${packagejs.version}\n`)}`);
        }
    },

    // prompt the user for options
    prompting() {
        const done = this.async();

        // DEBUG : log where we are
        dbh.debugLog('prompting');

        // user interaction on module call goes here
        const prompts = [
            {
                type: 'input',
                name: 'message',
                message: 'Please put something',
                default: 'hello world!'
            }
        ];

        // call the prompts
        this.prompt(prompts).then((props) => {
            this.props = props;
            // To access props later use this.props.someOption;

            done();
        });
    },

    // other Yeoman run steps would go here :
    // configuring() {}
    // default() {}

    // write the generator-specific files
    writing() {
        // DEBUG : log where we are
        dbh.debugLog('writing');

        // replace files with Spring's naming strategies
        dbh.replaceNamingStrategies();

        // function to use directly template
        this.template = function (source, destination) {
            this.fs.copyTpl(
                this.templatePath(source),
                this.destinationPath(destination),
                this
            );
        };

        this.baseName = jhipsterVar.baseName;
        this.packageName = jhipsterVar.packageName;
        this.angularAppName = jhipsterVar.angularAppName;
        this.clientFramework = jhipsterVar.clientFramework;
        this.clientPackageManager = jhipsterVar.clientPackageManager;
        const javaDir = jhipsterVar.javaDir;
        const resourceDir = jhipsterVar.resourceDir;
        const webappDir = jhipsterVar.webappDir;

        this.message = this.props.message;

        this.log('\n--- some config read from config ---');
        this.log(`baseName=${this.baseName}`);
        this.log(`packageName=${this.packageName}`);
        this.log(`angularAppName=${this.angularAppName}`);
        this.log(`clientFramework=${this.clientFramework}`);
        this.log(`clientPackageManager=${this.clientPackageManager}`);
        this.log(`javaDir=${javaDir}`);
        this.log(`resourceDir=${resourceDir}`);
        this.log(`webappDir=${webappDir}`);
        this.log(`\nmessage=${this.message}`);
        this.log('------\n');

        this.template('dummy.txt', 'dummy.txt');
        try {
            jhipsterFunc.registerModule('generator-jhipster-db-helper', 'app', 'post', 'app', 'A JHipster module for already existing databases');
        } catch (err) {
            this.log(`${chalk.red.bold('WARN!')} Could not register as a jhipster entity post creation hook...\n`);
        }
    },

    // run installation (npm, bower, etc)
    install() {
        let logMsg =
            `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install`)}`;

        // DEBUG : log where we are
        dbh.debugLog('install');

        if (this.clientFramework === 'angular1') {
            logMsg =
                `To install your dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install & bower install`)}`;
        }
        const injectDependenciesAndConstants = (err) => {
            if (err) {
                this.warning('Install of dependencies failed!');
                this.log(logMsg);
            } else if (this.clientFramework === 'angular1') {
                this.spawnCommand('gulp', ['install']);
            }
        };
        const installConfig = {
            bower: this.clientFramework === 'angular1',
            npm: this.clientPackageManager !== 'yarn',
            yarn: this.clientPackageManager === 'yarn',
            callback: injectDependenciesAndConstants
        };
        this.installDependencies(installConfig);
    },

    // cleanup, say goodbye
    end() {
        // DEBUG : log where we are
        dbh.debugLog('end');

        this.log('End of db-helper generator');
    }
});
<|endoftext|>


<commit_before>"use strict";

const Base = require('yeoman-generator');
const path = require('path');
const yosay = require('yosay');

const QUESTIONS = [{
  type: 'input',
  name: 'module:name',
  message: 'Module name'
}, {
  type: 'input',
  name: 'module:description',
  message: 'Module description'
}, {
  type: 'input',
  name: 'module:author:nickname',
  message: 'Your GitHub username'
}, {
  type: 'input',
  name: 'module:author:fullName',
  message: 'Your full name'
}, {
  type: 'list',
  name: 'module:license',
  message: 'Choose a license',
  default: 'MIT',
  choices: [
    'Apache-2.0',
    'Artistic-2.0',
    'BSD-2-Clause',
    'BSD-3-Clause',
    'EPL-1.0',
    'GPL-2.0',
    'GPL-3.0',
    'ISC',
    'LGPL-2.1',
    'LGPL-3.0',
    'MIT',
    'MPL-2.0',
    'Unlicense'
  ]
}];

/**
 * Fetch license text from choosealicense.com
 * @param {String} license License ID
 * @param {Function} cb Callback function with license content as argument
 */
function fetchLicense(license, cb) {
  let username = 'github';
  let repository = 'choosealicense.com';
  let branch = 'gh-pages';
  let cacheRoot = this.cacheRoot();
  let sourceRoot = this.sourceRoot();

  this.remote(username, repository, branch, (error, remote) => {
    this.sourceRoot(path.join(cacheRoot, username, repository, branch));

    let content = this
      .read(['_licenses/', license.toLowerCase(), '.txt'].join(''))
      .replace(/-+[\d\D]*?-+\n\n/, '')
      .replace(/\[year\]/g, new Date().getFullYear())
      .replace(/\[fullname\]/g, this.answers['module:author:fullName']);

    this.sourceRoot(sourceRoot);

    cb(content);
  });
}

module.exports = class AppGenerator extends Base {
  constructor(args, options) {
    super(args, options);
  }

  prompting() {
    const done = this.async();

    this.log(yosay('Welcome to the extraordinary ES5 npm module generator!'));
    this.prompt(QUESTIONS, answers => {
      this.answers = answers;

      fetchLicense.call(this, this.answers['module:license'], content => {
        this.write('LICENSE', content);
        done();
      });
    });
  }

  writing() {
    this.directory('lib', 'lib');
    this.directory('test', 'test');
    this.copy('editorconfig', '.editorconfig');
    this.copy('gitignore', '.gitignore');
    this.copy('npmignore', '.npmignore');
    this.copy('package.json', 'package.json');
    this.copy('README.md', 'README.md');
    this.copy('travis.yml', '.travis.yml');
  }

  install() {
    this.npmInstall();
  }
};
<commit_msg>refactor(package): Remove unused constructor definition<commit_after>"use strict";

const Base = require('yeoman-generator');
const path = require('path');
const yosay = require('yosay');

const QUESTIONS = [{
  type: 'input',
  name: 'module:name',
  message: 'Module name'
}, {
  type: 'input',
  name: 'module:description',
  message: 'Module description'
}, {
  type: 'input',
  name: 'module:author:nickname',
  message: 'Your GitHub username'
}, {
  type: 'input',
  name: 'module:author:fullName',
  message: 'Your full name'
}, {
  type: 'list',
  name: 'module:license',
  message: 'Choose a license',
  default: 'MIT',
  choices: [
    'Apache-2.0',
    'Artistic-2.0',
    'BSD-2-Clause',
    'BSD-3-Clause',
    'EPL-1.0',
    'GPL-2.0',
    'GPL-3.0',
    'ISC',
    'LGPL-2.1',
    'LGPL-3.0',
    'MIT',
    'MPL-2.0',
    'Unlicense'
  ]
}];

/**
 * Fetch license text from choosealicense.com
 * @param {String} license License ID
 * @param {Function} cb Callback function with license content as argument
 */
function fetchLicense(license, cb) {
  const username = 'github';
  const repository = 'choosealicense.com';
  const branch = 'gh-pages';
  const cacheRoot = this.cacheRoot();
  const sourceRoot = this.sourceRoot();

  this.remote(username, repository, branch, (error, remote) => {
    this.sourceRoot(path.join(cacheRoot, username, repository, branch));

    const content = this
      .read(['_licenses/', license.toLowerCase(), '.txt'].join(''))
      .replace(/-+[\d\D]*?-+\n\n/, '')
      .replace(/\[year\]/g, new Date().getFullYear())
      .replace(/\[fullname\]/g, this.answers['module:author:fullName']);

    this.sourceRoot(sourceRoot);

    cb(content);
  });
}

module.exports = class AppGenerator extends Base {
  prompting() {
    const done = this.async();

    this.log(yosay('Welcome to the extraordinary ES5 npm module generator!'));
    this.prompt(QUESTIONS, answers => {
      this.answers = answers;

      fetchLicense.call(this, this.answers['module:license'], content => {
        this.write('LICENSE', content);
        done();
      });
    });
  }

  writing() {
    this.directory('lib', 'lib');
    this.directory('test', 'test');
    this.copy('editorconfig', '.editorconfig');
    this.copy('gitignore', '.gitignore');
    this.copy('npmignore', '.npmignore');
    this.copy('package.json', 'package.json');
    this.copy('README.md', 'README.md');
    this.copy('travis.yml', '.travis.yml');
  }

  install() {
    this.npmInstall();
  }
};
<|endoftext|>