<commit_before>'use strict'
var util = require('util');
var path = require('path');
var chalk = require('chalk');
var yeoman = require('yeoman-generator');
var globule = require('globule');
var shelljs = require('shelljs');

var JekyllizedGenerator = yeoman.generators.Base.extend({
    init: function () {

        var dependenciesInstalled = ['bundle', 'ruby'].every(function (depend) {
            return shelljs.which(depend);
        });

        if (!dependenciesInstalled) {
            this.log('MISSING DEPENDENCIES:' +
                '\nEither ' + chalk.white('Ruby') + ' or ' + chalk.white('Bundler') + ' is not installed or missing from $PATH.' +
                '\nMake sure that they are either installed or added to $PATH.');
            shelljs.exit(1);
        };

        this.testFramework = this.options['test-framework'] || 'mocha';

        this.on('end', function () {
            if (!this.options['skip-install']) {
                this.spawnCommand('bundle', ['install']);
                this.installDependencies();
            }
        });

        this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
    },

    projectPrompting: function () {
        var cb = this.async();

        this.log(this.yeoman);
        this.log('\n' +
            chalk.blue('     ____        ___                 ___ ___')  + chalk.yellow('                            ___\n') +
            chalk.blue('     `MM         `MM                 `MM `MM')  + chalk.yellow(' 68b                        `MM\n') +
            chalk.blue('      MM          MM                  MM  MM')  + chalk.yellow(' Y89                         MM\n') +
            chalk.blue('      MM   ____   MM   __ ____    ___ MM  MM')  + chalk.yellow(' ___ _________  ____     ____MM\n') +
            chalk.blue('      MM  6MMMMb  MM   d` `MM(    )M` MM  MM')  + chalk.yellow(' `MM MMMMMMMMP 6MMMMb   6MMMMMM\n') +
            chalk.blue('      MM 6M`  `Mb MM  d`   `Mb    d`  MM  MM')  + chalk.yellow('  MM /    dMP 6M`  `Mb 6M`  `MM\n') +
            chalk.blue('      MM MM    MM MM d`     YM.  ,P   MM  MM')  + chalk.yellow('  MM     dMP  MM    MM MM    MM\n') +
            chalk.blue('      MM MMMMMMMM MMdM.      MM  M    MM  MM')  + chalk.yellow('  MM    dMP   MMMMMMMM MM    MM\n') +
            chalk.blue('(8)   MM MM       MMPYM.     `Mbd`    MM  MM')  + chalk.yellow('  MM   dMP    MM       MM    MM\n') +
            chalk.blue('((   ,M9 YM    d9 MM  YM.     YMP     MM  MM')  + chalk.yellow('  MM  dMP    /YM    d9 YM.  ,MM\n') +
            chalk.blue(' YMMMM9   YMMMM9 _MM_  YM._    M     _MM__MM')  + chalk.yellow('__MM_dMMMMMMMM YMMMM9   YMMMMMM_\n') +
            chalk.blue('                              d`            ')  + chalk.yellow('\n') +
            chalk.blue('                          (8),P             ')  + chalk.yellow('\n') +
            chalk.blue('                           YMM              ')  + chalk.yellow('\n')
        );

        this.log(chalk.magenta('\nIt\'s time to get Jekyllized!'));
        this.log(chalk.yellow('\nTell me a little about your project »'));

        var prompts = [{
            name: 'projectName',
            message: 'What is the name of your project?'
        }, {
            name: 'projectDescription',
            message: 'Describe your project for me:'
        }, {
            name: 'projectTagline',
            message: 'What is the tagline for your project?'
        }, {
            name: 'projectUrl',
            message: 'What will the URL for your project be?'
        }];

        this.prompt(prompts, function (props) {
            this.projectName        = props.projectName;
            this.projectDescription = props.projectDescription;
            this.projectTagline     = props.projectTagline;
            this.projectUrl         = props.projectUrl;

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

    ownerPrompting: function () {
        var cb = this.async();

        this.log(chalk.yellow('\nNow it\'s time to tell me about you. »'));

        var prompts = [{
            name: 'ownerName',
            message: 'What is your name?',
        }, {
            name: 'ownerEmail',
            message: 'What is your email?',
        }, {
            name: 'ownerBio',
            message: 'Write a short description of yourself:'
        }, {
            name: 'ownerTwitter',
            message: 'Your Twitter URL:'
        }];

        this.prompt(prompts, function (props) {
            this.ownerName      = props.ownerName;
            this.ownerEmail     = props.ownerEmail;
            this.ownerBio       = props.ownerBio;
            this.ownerTwitter   = props.ownerTwitter;

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

    jekyllPrompting: function () {
        var cb = this.async();

        this.log(chalk.yellow('\nNow on to set some Jekyll settings: »') +
                chalk.red('\nYou can change all of this later in the _config.yml file'));

        var prompts = [{
            name: 'jekyllPermalinks',
            type: 'list',
            message: 'Permalink style' +
                (chalk.red(
                           '\n  pretty: /:categories:/:year/:month/:day/:title/' +
                           '\n  date:   /:categories/:year/:month/:day/:title.html' +
                           '\n  none:   /:categories/:title.html')),
            choices: ['pretty', 'date', 'none']
        }, {
            name: 'jekyllPaginate',
            message: 'How many posts do you want to show on your front page?',
            default: 10,
            validate: function (input) {
                if (/^[0-9]*$/.test(input)) {
                    return true;
                }
                if (/^all*$/i.test(input)) {
                    return true;
                }
                return 'Must be a number or \'all\'';
            }
        }];

        this.prompt(prompts, function (props) {
            this.jekyllPermalinks   = props.jekyllPermalinks;
            this.jekyllPaginate     = /^all$/i.test(props.jekyllPaginate) ? false: props.jekyllPaginate;

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

    uploadPrompting: function () {
        var cb = this.async();

        this.log(chalk.yellow('\nIf you want to we can configure how to upload your site. You can do this either via Amazon S3/Cloudfront or Rsync to your own server: »') +
                chalk.red('\nNOTE: This is a one time choice, you\'ll have to check the source of jekyllized to change this later on'));

        var prompts = [{
            name: 'uploadChoices',
            type: 'list',
            message: 'How would you like to host/upload your site?',
            choices: [{
                name: 'Amazon S3 + Cloudfront',
                value: 'amazonCloudfrontS3',
            }, {
                name: 'Rsync',
                value: 'rsync',
            }, {
                name: 'Neither',
                value: 'noUpload'
            }]
        }];

        this.prompt(prompts, function (answers, props) {
            var features = answers.uploadChoices;

            var hasFeature = function (feat) {
                return features.indexOf(feat) !== -1;
            }

            this.amazonCloudfrontS3 = hasFeature('amazonCloudfrontS3');
            this.rsync              = hasFeature('rsync');

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

    secretPrompting: function () {
        var cb = this.async();

        this.log(chalk.yellow('\nNow we only need some details about how to upload your site: »') +
                chalk.red('\nNOTE: Take whatever time you need to get these right/fill them in later in either aws-credentials.json or rsync-credentials.json.'));

        var prompts = [{
            name: 'amazonKey',
            message: 'What is your key to AWS?',
            when: function (answers) {
                return answers.uploadChoices === 'amazonCloudfrontS3';
            }
        }, {
            name: 'amazonSecret',
            message: 'What is your secret?',
            when: function (answers) {
                return answers.uploadChoices === 'amazonCloudfrontS3';
            }
        }, {
            name: 'amazonBucket',
            message: 'What do you want your S3 bucket to be called?',
            when: function (answers) {
                return answers.uploadChoices === 'amazonCloudfrontS3';
            }
        }, {
            name: 'rsyncServer',
            message: 'Where do you want your site to be uploaded? Include both the address for the server and the folder, eg. 192.168.1.1:/srv/site/public_html/',
            when: function (answers) {
                return answers.uploadChoices === 'rsync';
            }
        }];

        this.prompt(prompts, function (props) {
            this.amazonKey      = props.amazonKey;
            this.amazonSecret   = props.amazonSecret;
            this.amazonBucket   = props.amazonBucket;

            this.rsyncServer    = props.rsyncServer;

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

    scaffolding: function () {
        this.copy('Gemfile', 'Gemfile');
        this.copy('bowerrc', '.bowerrc');
        this.copy('_bower.json', 'bower.json');
        this.template('_package.json', 'package.json');
        this.template('_config.yml', '_config.yml');
        this.template('_config.build.yml', '_config.build.yml');
        this.template('_README.md', 'README.md');
        this.copy('gulpfile.js', 'gulpfile.js');
        this.copy('gitignore', '.gitignore');
        this.copy('gitattributes', 'gitattributes');
        this.copy('jshintrc', '.jshintrc');
        this.copy('editorconfig', '.editorconfig');
        this.directory('app', 'src');

        if (this.amazonCloudfrontS3) {
            this.template('conditionals/_aws-credentials.json', 'aws-credentials.json');
        }
        else if (this.uploadChoices === 'rsync') {
            this.template('conditionals/_rsync-credentials.json', 'rsync-dredentials.json');
        }
    }
});

module.exports = JekyllizedGenerator;
<commit_msg>The index.js file is now complete<commit_after>'use strict'
var util = require('util');
var path = require('path');
var chalk = require('chalk');
var yeoman = require('yeoman-generator');
var globule = require('globule');
var shelljs = require('shelljs');

var JekyllizedGenerator = yeoman.generators.Base.extend({
    init: function () {

        var dependenciesInstalled = ['bundle', 'ruby'].every(function (depend) {
            return shelljs.which(depend);
        });

        if (!dependenciesInstalled) {
            this.log('MISSING DEPENDENCIES:' +
                '\nEither ' + chalk.white('Ruby') + ' or ' + chalk.white('Bundler') + ' is not installed or missing from $PATH.' +
                '\nMake sure that they are either installed or added to $PATH.');
            shelljs.exit(1);
        };

        this.testFramework = this.options['test-framework'] || 'mocha';

        this.on('end', function () {
            if (!this.options['skip-install']) {
                this.spawnCommand('bundle', ['install']);
                this.installDependencies();
            }
        });

        this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
    },

    projectPrompting: function () {
        var cb = this.async();

        this.log(this.yeoman);
        this.log('\n' +
            chalk.blue('     ____        ___                 ___ ___')  + chalk.yellow('                            ___\n') +
            chalk.blue('     `MM         `MM                 `MM `MM')  + chalk.yellow(' 68b                        `MM\n') +
            chalk.blue('      MM          MM                  MM  MM')  + chalk.yellow(' Y89                         MM\n') +
            chalk.blue('      MM   ____   MM   __ ____    ___ MM  MM')  + chalk.yellow(' ___ _________  ____     ____MM\n') +
            chalk.blue('      MM  6MMMMb  MM   d` `MM(    )M` MM  MM')  + chalk.yellow(' `MM MMMMMMMMP 6MMMMb   6MMMMMM\n') +
            chalk.blue('      MM 6M`  `Mb MM  d`   `Mb    d`  MM  MM')  + chalk.yellow('  MM /    dMP 6M`  `Mb 6M`  `MM\n') +
            chalk.blue('      MM MM    MM MM d`     YM.  ,P   MM  MM')  + chalk.yellow('  MM     dMP  MM    MM MM    MM\n') +
            chalk.blue('      MM MMMMMMMM MMdM.      MM  M    MM  MM')  + chalk.yellow('  MM    dMP   MMMMMMMM MM    MM\n') +
            chalk.blue('(8)   MM MM       MMPYM.     `Mbd`    MM  MM')  + chalk.yellow('  MM   dMP    MM       MM    MM\n') +
            chalk.blue('((   ,M9 YM    d9 MM  YM.     YMP     MM  MM')  + chalk.yellow('  MM  dMP    /YM    d9 YM.  ,MM\n') +
            chalk.blue(' YMMMM9   YMMMM9 _MM_  YM._    M     _MM__MM')  + chalk.yellow('__MM_dMMMMMMMM YMMMM9   YMMMMMM_\n') +
            chalk.blue('                              d`            ')  + chalk.yellow('\n') +
            chalk.blue('                          (8),P             ')  + chalk.yellow('\n') +
            chalk.blue('                           YMM              ')  + chalk.yellow('\n')
        );

        this.log(chalk.magenta('\nIt\'s time to get Jekyllized!'));
        this.log(chalk.yellow('\nTell me a little about your project »'));

        var prompts = [{
            name: 'projectName',
            message: 'What is the name of your project?'
        }, {
            name: 'projectDescription',
            message: 'Describe your project for me:'
        }, {
            name: 'projectTagline',
            message: 'What is the tagline for your project?'
        }, {
            name: 'projectUrl',
            message: 'What will the URL for your project be?'
        }];

        this.prompt(prompts, function (props) {
            this.projectName        = props.projectName;
            this.projectDescription = props.projectDescription;
            this.projectTagline     = props.projectTagline;
            this.projectUrl         = props.projectUrl;

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

    ownerPrompting: function () {
        var cb = this.async();

        this.log(chalk.yellow('\nNow it\'s time to tell me about you. »'));

        var prompts = [{
            name: 'ownerName',
            message: 'What is your name?',
        }, {
            name: 'ownerEmail',
            message: 'What is your email?',
        }, {
            name: 'ownerBio',
            message: 'Write a short description of yourself:'
        }, {
            name: 'ownerTwitter',
            message: 'Your Twitter URL:'
        }];

        this.prompt(prompts, function (props) {
            this.ownerName      = props.ownerName;
            this.ownerEmail     = props.ownerEmail;
            this.ownerBio       = props.ownerBio;
            this.ownerTwitter   = props.ownerTwitter;

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

    jekyllPrompting: function () {
        var cb = this.async();

        this.log(chalk.yellow('\nNow on to set some Jekyll settings: »') +
                chalk.red('\nYou can change all of this later in the _config.yml file'));

        var prompts = [{
            name: 'jekyllPermalinks',
            type: 'list',
            message: 'Permalink style' + (chalk.red(
                           '\n  pretty: /:categories:/:year/:month/:day/:title/' +
                           '\n  date:   /:categories/:year/:month/:day/:title.html' +
                           '\n  none:   /:categories/:title.html')) + '\n',
            choices: ['pretty', 'date', 'none']
        }, {
            name: 'jekyllPaginate',
            message: 'How many posts do you want to show on your front page?',
            default: 10,
            validate: function (input) {
                if (/^[0-9]*$/.test(input)) {
                    return true;
                }
                if (/^all*$/i.test(input)) {
                    return true;
                }
                return 'Must be a number or \'all\'';
            }
        }];

        this.prompt(prompts, function (props) {
            this.jekyllPermalinks   = props.jekyllPermalinks;
            this.jekyllPaginate     = /^all$/i.test(props.jekyllPaginate) ? false: props.jekyllPaginate;

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

    uploadPrompting: function () {
        var cb = this.async();

        var prompts = [{
            name: 'uploadChoices',
            type: 'list',
            message: 'How would you like to host/upload your site?',
            choices: [{
                name: 'Amazon S3 + Cloudfront',
                value: 'amazonCloudfrontS3',
            }, {
                name: 'Rsync',
                value: 'rsync',
            }, {
                name: 'Neither',
                value: 'noUpload'
            }]
        }, {
            name: 'amazonKey',
            message: chalk.yellow('\n\nIf you want to we can configure how to upload your site. You can do this either via Amazon S3/Cloudfront or Rsync to your own server: »') +
                chalk.red('\nNOTE: This is a one time choice, you\'ll have to check the source of jekyllized to change this later on') + '\nWhat is your key to AWS?',
            when: function (answers) {
                return answers.uploadChoices === 'amazonCloudfrontS3';
            }
        }, {
            name: 'amazonSecret',
            message: 'What is your secret?',
            when: function (answers) {
                return answers.uploadChoices === 'amazonCloudfrontS3';
            }
        }, {
            name: 'amazonBucket',
            message: 'What do you want your S3 bucket to be called?',
            when: function (answers) {
                return answers.uploadChoices === 'amazonCloudfrontS3';
            }
        }, {
            name: 'rsyncServer',
            message: 'Where do you want your site to be uploaded? Include both the address for the server and the folder, eg. 192.168.1.1:/srv/site/public_html/',
            when: function (answers) {
                return answers.uploadChoices === 'rsync';
            }
        }];

        this.log(chalk.yellow('\nNow we only need some details about how to upload your site: »') +
                chalk.red('\nNOTE: Take whatever time you need to get these right/fill them in later in either aws-credentials.json or rsync-credentials.json.'));
        this.prompt(prompts, function (props) {
            var features = props.uploadChoices;

            var hasFeature = function (feat) {
                return features.indexOf(feat) !== -1;
            }

            this.amazonCloudfrontS3 = hasFeature('amazonCloudfrontS3');
            this.rsync              = hasFeature('rsync');

            this.amazonKey      = props.amazonKey;
            this.amazonSecret   = props.amazonSecret;
            this.amazonBucket   = props.amazonBucket;

            this.rsyncServer    = props.rsyncServer;

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

    scaffolding: function () {
        this.copy('Gemfile', 'Gemfile');
        this.copy('bowerrc', '.bowerrc');
        this.copy('_bower.json', 'bower.json');
        this.template('_package.json', 'package.json');
        this.template('_config.yml', '_config.yml');
        this.template('_config.build.yml', '_config.build.yml');
        this.template('_README.md', 'README.md');
        this.copy('gulpfile.js', 'gulpfile.js');
        this.copy('gitignore', '.gitignore');
        this.copy('gitattributes', 'gitattributes');
        this.copy('jshintrc', '.jshintrc');
        this.copy('editorconfig', '.editorconfig');
        this.directory('app', 'src');

        if (this.amazonCloudfrontS3) {
            this.template('conditionals/_aws-credentials.json', 'aws-credentials.json');
        }
        else if (this.rsync) {
            this.template('conditionals/_rsync-credentials.json', 'rsync-dredentials.json');
        }
    }
});

module.exports = JekyllizedGenerator;
<|endoftext|>


<commit_before>'use strict';

var fs     = require('fs')
  , util   = require('util')
  , path   = require('path')
  , chalk  = require('chalk')
  , yeoman = require('yeoman-generator');

var Generator = module.exports = function () {
  yeoman.generators.Base.apply(this, arguments);

  this.pkg = yeoman.file.readJSON(path.join(__dirname, '../package.json'));

  this.option('skip-install', {
    desc: 'Do not install eventual dependecies',
    type: String,
    required: false
  });

  this.option('skip-welcome-message', {
    desc: 'Do not show the Yeoman welcome message',
    type: String,
    required: false
  });

  if (fs.existsSync(this.dest._base + '/package.json')) {
    this.addon = this.dest.readJSON('package.json');
  } else {
    this.addon = {author: false, repository: false};
  }

  this.on('end', function () {
    if (!this.options['skip-install']) {
      this.npmInstall();
    }

    if (!this.options['skip-welcome-message']) {
      console.log(chalk.yellow(
        '\nThat was it! Open up this folder in your favorite editor\n' +
        'and start hacking away.\n'
      ));
    }
  });
};

util.inherits(Generator, yeoman.generators.Base);

Generator.prototype.welcome = function () {
  // Have Yeoman greet the user
  if (!this.options['skip-welcome-message']) {
    console.log(this.yeoman);
    console.log(chalk.yellow(
      'I\'m here to guide you through the process of setting up\n' +
      'a basic Addon for Vanilla. You can start by telling me a\n' +
      'little bit about yourself. I will store this information\n' +
      'in your addon so you only have to enter it once...\n'
    ));
  }
};

Generator.prototype.askForAuthor = function () {
  var next = this.async()
    , prompts = [{
      type: 'input'
    , name: 'author'
    , message: 'What is your full name?'
    , default: this.addon.author.name
    }, {
      type: 'input'
    , name: 'email'
    , message: 'I would also like your email'
    , default: this.addon.author.email
    }, {
      type: 'input'
    , name: 'url'
    , message: 'Optionally, enter your website'
    , default: this.addon.author.url
    }];

  this.prompt(prompts, function (props) {
    this.author = {
      name: props.author
    , email: props.email
    , url: props.url
    };

    next();
  }.bind(this));
};

Generator.prototype.askForLicense = function () {
  if (!this.options['skip-welcome-message']) {
    console.log(chalk.yellow(
      '\nNow for a bit of information about your addon...\n'
    ));
  }

  var next = this.async()
    , prompts = [{
      type: 'list'
    , name: 'license'
    , message: 'Which license would you like to use?'
    , default: this.addon.license || 'MIT'
    , choices: [{
        name: 'None'
      , value: false
      }, 'MIT', 'GPLv2', 'GPLv3', 'Apache']
    }];

  this.prompt(prompts, function (props) {
    this.license = props.license;

    next();
  }.bind(this));
};

Generator.prototype.askForAddon = function () {
  var next = this.async()
    , prompts = [{
      type: 'list'
    , name: 'type'
    , message: 'What kind of addon is this?'
    , choices: ['Application', 'Plugin', 'Theme']
    }, {
      type: 'input'
    , name: 'name'
    , message: 'Enter the name of your addon'
    , default: this.addon.title
    }, {
      type: 'input'
    , name: 'description'
    , message: 'Describe your addon in a sentence or two'
    , default: this.addon.description
    }, {
      type: 'input'
    , name: 'url'
    , message: 'Optionally, enter the addons website'
    , default: this.addon.repository.url
    }, {
      type: 'checkbox'
    , name: 'extras'
    , message: 'Optional files to include in your application'
    , choices: [
        'class.hooks.php'
      , 'configuration.php'
      , 'bootstrap.php'
      , 'structure.php'
      ]
    , when: function (props) {
        return props.type === 'Application';
      }
    }, {
      type: 'checkbox'
    , name: 'extras'
    , message: 'Optional files to include in your theme'
    , choices: [
        'class.themehooks.php'
      ]
    , when: function (props) {
        return props.type === 'Theme';
      }
    }];

  this.prompt(prompts, function (props) {
    this.type = props.type;
    this.name = props.name;
    this.description = props.description;
    this.url = props.url;
    this.extras = props.extras || [];

    next();
  }.bind(this));
};

Generator.prototype.createFiles = function () {
  var self  = this
    , today = new Date();

  this.year      = today.getFullYear();
  this.directory = path.basename(this.dest._base);

  this.copy('editorconfig', '.editorconfig');
  this.template('_package.json', 'package.json');

  if (this.license) {
    this.template('licenses/' + this.license + '.md', 'LICENSE.md');
  } else {
    this.license = 'Proprietary';
  }

  var extra = function (template, dest) {
      if (self.extras.indexOf(template) !== -1) {
        self.template(template, dest);
      }
    };

  switch (this.type) {
  case 'Application':
    this.template('about.php', 'settings/about.php');

    // Optional application files
    extra('class.hooks.php', 'settings/class.hooks.php');
    extra('configuration.php', 'settings/configuration.php');
    extra('bootstrap.php', 'settings/bootstrap.php');
    extra('structure.php', 'settings/structure.php');
    break;

  case 'Plugin':
    this.template(
      'class.plugin.php',
      'class.' + this.directory.toLowerCase() + '.plugin.php'
    );
    break;

  case 'Theme':
    this.copy('default.master.tpl', 'views/default.master.tpl');
    this.template('about.php', 'about.php');

    // Optional theme files
    extra('class.themehooks.php', 'class.themehooks.php');
    break;
  }
};
<commit_msg>Clean up app.js<commit_after>'use strict';

var fs     = require('fs')
  , util   = require('util')
  , path   = require('path')
  , chalk  = require('chalk')
  , yeoman = require('yeoman-generator');

var Generator = module.exports = yeoman.generators.Base.extend({
  init: function () {
    this.pkg = yeoman.file.readJSON(path.join(__dirname, '../package.json'));

    this.option('skip-install', {
      desc: 'Do not install eventual dependecies',
      type: String,
      required: false
    });

    this.option('skip-welcome-message', {
      desc: 'Do not show the Yeoman welcome message',
      type: String,
      required: false
    });

    if (fs.existsSync(this.dest._base + '/package.json')) {
      this.addon = this.dest.readJSON('package.json');
    } else {
      this.addon = {author: false, repository: false};
    }

    this.on('end', function () {
      if (!this.options['skip-install']) {
        this.npmInstall();
      }

      if (!this.options['skip-welcome-message']) {
        console.log(chalk.yellow(
          '\nThat was it! Open up this folder in your favorite editor\n' +
          'and start hacking away.\n'
        ));
      }
    });
  },

  welcome: function () {
    // Have Yeoman greet the user
    if (!this.options['skip-welcome-message']) {
      console.log(this.yeoman);
      console.log(chalk.yellow(
        'I\'m here to guide you through the process of setting up\n' +
        'a basic Addon for Vanilla. You can start by telling me a\n' +
        'little bit about yourself. I will store this information\n' +
        'in your addon so you only have to enter it once...\n'
      ));
    }
  },

  askForAuthor: function () {
    var next = this.async()
      , prompts = [{
        type: 'input'
      , name: 'author'
      , message: 'What is your full name?'
      , default: this.addon.author.name
      }, {
        type: 'input'
      , name: 'email'
      , message: 'I would also like your email'
      , default: this.addon.author.email
      }, {
        type: 'input'
      , name: 'url'
      , message: 'Optionally, enter your website'
      , default: this.addon.author.url
      }];

    this.prompt(prompts, function (props) {
      this.author = {
        name: props.author
      , email: props.email
      , url: props.url
      };

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

  askForLicense: function () {
    if (!this.options['skip-welcome-message']) {
      console.log(chalk.yellow(
        '\nNow for a bit of information about your addon...\n'
      ));
    }

    var next = this.async()
      , prompts = [{
        type: 'list'
      , name: 'license'
      , message: 'Which license would you like to use?'
      , default: this.addon.license || 'MIT'
      , choices: [{
          name: 'None'
        , value: false
        }, 'MIT', 'GPLv2', 'GPLv3', 'Apache']
      }];

    this.prompt(prompts, function (props) {
      this.license = props.license;

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

  askForAddon: function () {
    var next = this.async()
      , prompts = [{
        type: 'list'
      , name: 'type'
      , message: 'What kind of addon is this?'
      , choices: ['Application', 'Plugin', 'Theme']
      }, {
        type: 'input'
      , name: 'name'
      , message: 'Enter the name of your addon'
      , default: this.addon.title
      }, {
        type: 'input'
      , name: 'description'
      , message: 'Describe your addon in a sentence or two'
      , default: this.addon.description
      }, {
        type: 'input'
      , name: 'url'
      , message: 'Optionally, enter the addons website'
      , default: this.addon.repository.url
      }, {
        type: 'checkbox'
      , name: 'extras'
      , message: 'Optional files to include in your application'
      , choices: [
          'class.hooks.php'
        , 'configuration.php'
        , 'bootstrap.php'
        , 'structure.php'
        ]
      , when: function (props) {
          return props.type === 'Application';
        }
      }, {
        type: 'checkbox'
      , name: 'extras'
      , message: 'Optional files to include in your theme'
      , choices: [
          'class.themehooks.php'
        ]
      , when: function (props) {
          return props.type === 'Theme';
        }
      }];

    this.prompt(prompts, function (props) {
      this.type = props.type;
      this.name = props.name;
      this.description = props.description;
      this.url = props.url;
      this.extras = props.extras || [];

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

  createFiles: function () {
    var self  = this
      , today = new Date();

    this.year      = today.getFullYear();
    this.directory = path.basename(this.dest._base);

    this.copy('editorconfig', '.editorconfig');
    this.template('_package.json', 'package.json');

    if (this.license) {
      this.template('licenses/' + this.license + '.md', 'LICENSE.md');
    } else {
      this.license = 'Proprietary';
    }

    var extra = function (template, dest) {
        if (self.extras.indexOf(template) !== -1) {
          self.template(template, dest);
        }
      };

    switch (this.type) {
    case 'Application':
      this.template('about.php', 'settings/about.php');

      // Optional application files
      extra('class.hooks.php', 'settings/class.hooks.php');
      extra('configuration.php', 'settings/configuration.php');
      extra('bootstrap.php', 'settings/bootstrap.php');
      extra('structure.php', 'settings/structure.php');
      break;

    case 'Plugin':
      this.template(
        'class.plugin.php',
        'class.' + this.directory.toLowerCase() + '.plugin.php'
      );
      break;

    case 'Theme':
      this.copy('default.master.tpl', 'views/default.master.tpl');
      this.template('about.php', 'about.php');

      // Optional theme files
      extra('class.themehooks.php', 'class.themehooks.php');
      break;
    }
  }
});
<|endoftext|>


<commit_before>'use strict';
var util    = require('util');
var path    = require('path');
var yeoman  = require('yeoman-generator');
var fs      = require('fs-extra');
var chalk   = require('chalk');

var TestGeneratorGenerator = yeoman.generators.Base.extend({
  init: function () {
    this.prompts  = [];
    this.pkg      = require('../package.json');

    this.on('end', function () {
      this.config.save();
      this.log.info('Running ' + chalk.yellow('bower install') + ' & ' + chalk.yellow('npm install') + ' for you to install the required dependencies. If this fails, try running the command yourself.');
      this.installDependencies({
        bower:        true,
        npm:          true,
        skipMessage:  true,
        callback:     function() {
          this.log.ok('All done! Run ' + chalk.yellow('grunt build:dev') + ' and ' + chalk.yellow('grunt watch') + ' to get started!');
        }.bind(this)
      });
    });
  },
  promptForName: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.name;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      required: true,
      type:     'text',
      name:     'projName',
      message:  'Project Name (e.g. MySite)',
      default:  function() {
        return existing() || path.basename(this.env.cwd);
      }.bind(this)
    });
  },
  promptForShortName: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.shortName;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      required: true,
      type:     'text',
      name:     'projShortName',
      message:  'Project short name (e.g. ms)',
      default:  function() {
        return existing() || path.basename(this.env.cwd).replace(/[^A-Z]/g, '').toLowerCase();
      }.bind(this)
    });
  },
  promptForAuthorName: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.author.name;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      type:     'text',
      name:     'authorName',
      message:  'Author Name (e.g. John Smith)',
      default:  function() {
        return existing() || '';
      }.bind(this)
    });
  },
  promptForAuthorURI: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.author.url
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      type:     'text',
      name:     'authorURI',
      message:  'Author URI (e.g. www.johnsmith.com)',
      default:  function() {
        return existing() || '';
      }.bind(this)
    });
  },
  promptForDescription: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.description;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      type:     'text',
      name:     'projDescription',
      message:  'Project Description',
      default:  function() {
        return existing() || '';
      }.bind(this)
    });
  },
  promptForVersion: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.version;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      type:     'text',
      name:     'projVersion',
      message:  'Project version',
      default:  function() {
        return existing() || '0.1.0';
      }.bind(this)
    });
  },
  promptForWeb: function() {
    this.prompts.push({
      type:     'text',
      name:     'web',
      message:  'WordPress directory',
      default:  'web'
    });
  },
  promptForChild: function() {

    var existing = function(response) {
      var childLoc = path.join(response.web, 'wp-content/themes/', response.projShortName + '-theme');

      try {
        var style = this.readFileAsString(path.join(childLoc, 'style.css'));

        if (style.length) {
          return true;
        }
      } catch(e) {}
    }.bind(this);

    this.prompts.push({
      when:     function(response) {
        return existing(response);
      },
      type:     'confirm',
      name:     'writeChild',
      message:  'Overwrite existing child theme?',
      default:  'no'
    });
  },
  ask: function() {
    var done = this.async();

    // have Yeoman greet the user.
    console.log(this.yeoman);

    this.prompt(this.prompts, function(props) {
      this.props = props;

      done();
    }.bind(this));
  },
  ready: function() {
    this.log.write('\n');
    this.log.info( chalk.green('Here we go!') );
  },
  writeProjectFiles: function() {
    this.log.info('Writing project files...');

    this.copy('Gruntfile.js', 'Gruntfile.js');

    this.template('editorconfig', '.editorconfig');
    this.template('gitignore',    '.gitignore');
    this.template('jshintrc',     '.jshintrc');
    this.template('bower.json',   'bower.json');
    this.template('package.json', 'package.json');
    //this.template('README.md',    'README.md');
  },
  writeThemeFiles:  function() {
    this.log.info('Writing theme files...');

    var existing = function(location) {
      try {
        var style = this.readFileAsString(path.join(location, 'style.css'));

        if (style.length) {
          return true;
        } else {
          return false;
        }
      } catch(e) {}
    }.bind(this);

    var parLoc      = path.join(this.props.web, 'wp-content/themes/genesis-parent-theme');
    var childLoc    = path.join(this.props.web, 'wp-content/themes/', this.props.projShortName + '-theme');
    var writeChild  = !existing(childLoc) || this.props.writeChild;

    this.directory('themes/genesis-parent-theme', parLoc);

    if (writeChild) {
      this.directory('themes/genesis-child-theme', childLoc);
    }
  },
  cleanUp: function() {
    this.log.info('Cleaning up...');

    var root  = path.join(this.props.web, 'wp-content/themes/', this.props.projShortName + '-theme');
    var files = this.expandFiles('**/.gitkeep', {dot: true, cwd: root});

    for (var i = 0; i < files.length; i++) {
      var file = path.join(root, files[i]);

      fs.remove(file, function(err) {
        if (err) return this.log.info( chalk.red(err) );
      });
    }
  }
});

module.exports = TestGeneratorGenerator;<commit_msg>Wrapping installDeps in option condition keeps it from running while testing<commit_after>'use strict';
var util    = require('util');
var path    = require('path');
var yeoman  = require('yeoman-generator');
var fs      = require('fs-extra');
var chalk   = require('chalk');

var TestGeneratorGenerator = yeoman.generators.Base.extend({
  init: function () {
    this.prompts  = [];
    this.pkg      = require('../package.json');

    this.on('end', function () {
      this.config.save();
      this.log.info('Running ' + chalk.yellow('bower install') + ' & ' + chalk.yellow('npm install') + ' for you to install the required dependencies. If this fails, try running the command yourself.');
      if (!this.options['skip-install']) {
        this.installDependencies({
          bower:        true,
          npm:          true,
          skipMessage:  true,
          callback:     function() {
            this.log.ok('All done! Run ' + chalk.yellow('grunt build:dev') + ' and ' + chalk.yellow('grunt watch') + ' to get started!');
          }.bind(this)
        });
      }
    });
  },
  promptForName: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.name;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      required: true,
      type:     'text',
      name:     'projName',
      message:  'Project Name (e.g. MySite)',
      default:  function() {
        return existing() || path.basename(this.env.cwd);
      }.bind(this)
    });
  },
  promptForShortName: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.shortName;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      required: true,
      type:     'text',
      name:     'projShortName',
      message:  'Project short name (e.g. ms)',
      default:  function() {
        return existing() || path.basename(this.env.cwd).replace(/[^A-Z]/g, '').toLowerCase();
      }.bind(this)
    });
  },
  promptForAuthorName: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.author.name;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      type:     'text',
      name:     'authorName',
      message:  'Author Name (e.g. John Smith)',
      default:  function() {
        return existing() || '';
      }.bind(this)
    });
  },
  promptForAuthorURI: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.author.url
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      type:     'text',
      name:     'authorURI',
      message:  'Author URI (e.g. www.johnsmith.com)',
      default:  function() {
        return existing() || '';
      }.bind(this)
    });
  },
  promptForDescription: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.description;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      type:     'text',
      name:     'projDescription',
      message:  'Project Description',
      default:  function() {
        return existing() || '';
      }.bind(this)
    });
  },
  promptForVersion: function() {
    var existing = function() {
      try {
        var bower    = require(path.join(this.env.cwd, 'bower.json'));

        return bower.version;
      } catch(e) {};
    }.bind(this);

    this.prompts.push({
      type:     'text',
      name:     'projVersion',
      message:  'Project version',
      default:  function() {
        return existing() || '0.1.0';
      }.bind(this)
    });
  },
  promptForWeb: function() {
    this.prompts.push({
      type:     'text',
      name:     'web',
      message:  'WordPress directory',
      default:  'web'
    });
  },
  promptForChild: function() {

    var existing = function(response) {
      var childLoc = path.join(response.web, 'wp-content/themes/', response.projShortName + '-theme');

      try {
        var style = this.readFileAsString(path.join(childLoc, 'style.css'));

        if (style.length) {
          return true;
        }
      } catch(e) {}
    }.bind(this);

    this.prompts.push({
      when:     function(response) {
        return existing(response);
      },
      type:     'confirm',
      name:     'writeChild',
      message:  'Overwrite existing child theme?',
      default:  'no'
    });
  },
  ask: function() {
    var done = this.async();

    // have Yeoman greet the user.
    console.log(this.yeoman);

    this.prompt(this.prompts, function(props) {
      this.props = props;

      done();
    }.bind(this));
  },
  ready: function() {
    this.log.write('\n');
    this.log.info( chalk.green('Here we go!') );
  },
  writeProjectFiles: function() {
    this.log.info('Writing project files...');

    this.copy('Gruntfile.js', 'Gruntfile.js');

    this.template('editorconfig', '.editorconfig');
    this.template('gitignore',    '.gitignore');
    this.template('jshintrc',     '.jshintrc');
    this.template('bower.json',   'bower.json');
    this.template('package.json', 'package.json');
    //this.template('README.md',    'README.md');
  },
  writeThemeFiles:  function() {
    this.log.info('Writing theme files...');

    var existing = function(location) {
      try {
        var style = this.readFileAsString(path.join(location, 'style.css'));

        if (style.length) {
          return true;
        } else {
          return false;
        }
      } catch(e) {}
    }.bind(this);

    var parLoc      = path.join(this.props.web, 'wp-content/themes/genesis-parent-theme');
    var childLoc    = path.join(this.props.web, 'wp-content/themes/', this.props.projShortName + '-theme');
    var writeChild  = !existing(childLoc) || this.props.writeChild;

    this.directory('themes/genesis-parent-theme', parLoc);

    if (writeChild) {
      this.directory('themes/genesis-child-theme', childLoc);
    }
  },
  cleanUp: function() {
    this.log.info('Cleaning up...');

    var root  = path.join(this.props.web, 'wp-content/themes/', this.props.projShortName + '-theme');
    var files = this.expandFiles('**/.gitkeep', {dot: true, cwd: root});

    for (var i = 0; i < files.length; i++) {
      var file = path.join(root, files[i]);

      fs.remove(file, function(err) {
        if (err) return this.log.info( chalk.red(err) );
      });
    }
  }
});

module.exports = TestGeneratorGenerator;<|endoftext|>


<commit_before>'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');

var NglueGenerator = module.exports = function NglueGenerator(args, options, config) {
  yeoman.generators.Base.apply(this, arguments);

  if (this.hasOwnProperty('name')) {
    this.hookFor('nglue:module', {
        args: args
    });
  }

  this.on('end', function () {
    this.installDependencies({ skipInstall: options['skip-install'] });
  });

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};

util.inherits(NglueGenerator, yeoman.generators.Base);

NglueGenerator.prototype.askFor = function askFor() {
  var cb = this.async();

  // have Yeoman greet the user.
  console.log(this.yeoman);

  var prompts = [{
    type: 'moduleName',
    name: 'projectName',
    message: 'What\'s your project\'s name?',
  }];

  this.prompt(prompts, function (props) {

    if (props.hasOwnProperty('moduleName')) {
      this.moduleName = props.moduleName;
    }

    this.projectName = props.projectName;

    cb();
  }.bind(this));
};

NglueGenerator.prototype.app = function app() {
  this.mkdir('code_base');
  this.mkdir('code_base/apps');
  this.mkdir('code_base/assets');
  this.mkdir('code_base/assets/bower_components');
  this.mkdir('code_base/assets/components');
  this.mkdir('code_base/assets/styles');
  this.mkdir('code_base/assets/fonts');
  this.mkdir('code_base/assets/images');
  this.mkdir('code_base/modules');
  this.mkdir('compile');
  this.mkdir('code_base/dist');
  this.mkdir('dist');

  this.copy('_.bowerrc', '.bowerrc');

  this.template('_package.json', 'package.json');
  this.template('_bower.json', 'bower.json');
  this.template('_nglue.json', 'code_base/assets/nglue.json');
  this.copy('_Gruntfile.js', 'Gruntfile.js');
  this.copy('_gitignore', '.gitignore');
  this.template('_base.less', 'code_base/assets/styles/base.less');

  // readme files
  this.template('_README.md', 'README.md');
  this.template('_README_DIST.md', 'code_base/dist/README.md');
  this.template('_README_DIST.md', 'dist/README.md');
};

NglueGenerator.prototype.projectfiles = function projectfiles() {
  this.copy('editorconfig', '.editorconfig');
  this.copy('jshintrc', '.jshintrc');
};
<commit_msg>remove compile folder and minor changes<commit_after>'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');

var NglueGenerator = module.exports = function NglueGenerator(args, options, config) {
  yeoman.generators.Base.apply(this, arguments);

  if (this.hasOwnProperty('name')) {
    this.hookFor('nglue:module', {
        args: args
    });
  }

  this.on('end', function () {
    this.installDependencies({ skipInstall: options['skip-install'] });
  });

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};

util.inherits(NglueGenerator, yeoman.generators.Base);

NglueGenerator.prototype.askFor = function askFor() {
  var cb = this.async();

  // have Yeoman greet the user.
  console.log(this.yeoman);

  var prompts = [{
    type: 'moduleName',
    name: 'projectName',
    message: 'What\'s your project\'s name?',
  }];

  this.prompt(prompts, function (props) {

    if (props.hasOwnProperty('moduleName')) {
      this.moduleName = props.moduleName;
    }

    this.projectName = props.projectName;

    cb();
  }.bind(this));
};

NglueGenerator.prototype.app = function app() {
  this.mkdir('code_base');
  this.mkdir('code_base/apps');
  this.mkdir('code_base/assets');
  this.mkdir('code_base/assets/bower_components');
  this.mkdir('code_base/assets/components');
  this.mkdir('code_base/assets/styles');
  this.mkdir('code_base/assets/fonts');
  this.mkdir('code_base/assets/images');
  this.mkdir('code_base/modules');
  this.mkdir('code_base/dist');
  this.mkdir('dist');

  this.copy('_.bowerrc', '.bowerrc');

  this.template('_package.json', 'package.json');
  this.template('_bower.json', 'bower.json');
  this.template('_nglue.json', 'code_base/assets/nglue.json');
  this.copy('_Gruntfile.js', 'Gruntfile.js');
  this.copy('_gitignore', '.gitignore');
  this.template('_base.less', 'code_base/assets/styles/base.less');

  // readme files
  this.template('_README.md', 'README.md');
  this.template('_README_DIST.md', 'code_base/dist/README.md');
  this.template('_README_DIST.md', 'dist/README.md');
};

NglueGenerator.prototype.projectfiles = function projectfiles() {
  this.copy('editorconfig', '.editorconfig');
  this.copy('jshintrc', '.jshintrc');
};
<|endoftext|>


<commit_before>// CPB Boilerplate Generator
//  JavaScript
//    1. Modules - which can be added or removed via Bower
//    2. Pattern Guide
//    3. Frameworks
//        i.   Angular
//        ii.  Backbone (default)
//        iii. Ember
//  CSS
//    1. SASS
//    2. Pattern Guide
//    3. Function Documentation
//    4. Sprites

'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');

// begin the adventure of a lifetime
var CpbGenerator = module.exports = function CpbGenerator(args, options, config) {
  yeoman.generators.Base.apply(this, arguments); // wire up the base

  this.on('end', function () { // listen to the end event
    this.installDependencies({ skipInstall: options['skip-install'] }); // install all dependancies
  });

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); // get access to package.json file
};

util.inherits(CpbGenerator, yeoman.generators.Base);

// the ask, every one of these methods will be called in order from top to bottom of this file, get to know it
// the only time these wont run is if they are private methods
// in order to determine a private method, please name the methods starting with an underscore:
// Example: CpbGenerator.prototype._dontRunMe

CpbGenerator.prototype.askFor = function askFor() {
  var cb = this.async(); // creates an instance for Async functions

  // have Yeoman greet the user.
  console.log(this.yeoman);

  // setup Promps to Determine if the User wants something in the Boilerplate
  var prompts = [{
    name: 'siteName',
    message: 'What do you want to call this project?',
    default: 'CP+B Boilderplate'
  }];

  this.prompt(prompts, function (props) {
     this.siteName = props.siteName;
    cb();
  }.bind(this));
};

CpbGenerator.prototype.app = function app() {
  // create the directories needed for the app
  this.mkdir('build');
  this.mkdir('build/config');
  this.mkdir('www');
  this.mkdir('www/images');
  this.mkdir('www/js');
  this.mkdir('www/js/app');
  this.mkdir('www/js/helpers');
  this.mkdir('www/js/lib');
  this.mkdir('www/js/min');
  this.mkdir('www/js/app/collection');
  this.mkdir('www/js/app/model');
  this.mkdir('www/js/app/template');
  this.mkdir('www/js/app/view');
  this.mkdir('www/css');
  this.mkdir('www/css/fonts');
  this.mkdir('www/css/min');
  this.mkdir('www/css/generated');

  // using markdown templates generate the html needed
  this.template('_index.md', 'www/index.html');

  // copy over styles and JS
  this.copy('Gruntfile.js', 'Gruntfile.js');
  this.copy('build/config/jshint.js', 'build/config/jshint.js');
  this.copy('build/config/requirejs.js', 'build/config/requirejs.js');
  this.copy('build/config/watch.js', 'build/config/watch.js');
  this.copy('build/config/yuidoc.js', 'build/config/yuidoc.js');
  this.copy('www/robots.txt', 'www/robots.txt');
  this.copy('www/js/app/main.js', 'www/js/app/main.js');
  this.copy('www/js/helpers/analytics.js', 'www/js/helpers/analytics.js');
  this.copy('www/js/helpers/console.js', 'www/js/helpers/console.js');
  this.copy('www/js/helpers/events.js', 'www/js/helpers/events.js');
  this.copy('www/js/helpers/utilities.js', 'www/js/helpers/utilities.js');
  this.copy('www/js/app/router.js', 'www/js/app/router.js');
  this.copy('www/js/app/master/app.js', 'www/js/app/master/app.js');
  this.copy('www/js/app/master/template/Example.html', 'www/js/app/master/template/Example.html');
  this.copy('www/js/app/master/view/example.js', 'www/js/app/master/view/example.js');
  this.copy('www/js/app/master/view/subExample.js', 'www/js/app/master/view/subExample.js');
  this.copy('www/js/lib/backbone-min.js', 'www/js/lib/backbone-min.js');
  this.copy('www/js/lib/lodash.min.js', 'www/js/lib/lodash.min.js');
  this.copy('www/js/lib/modernizr-2.6.2.min.js', 'www/js/lib/modernizr-2.6.2.min.js');
  this.copy('www/js/lib/swig.min.js', 'www/js/lib/swig.min.js');
  this.copy('www/js/lib/enquire.min.js', 'www/js/lib/enquire.min.js');
  this.copy('www/js/lib/jquery-1.9.1.min.js', 'www/js/lib/jquery-1.9.1.min.js');
  this.copy('www/js/lib/require.js', 'www/js/lib/require.js');
  this.copy('www/js/lib/text.js', 'www/js/lib/text.js');
  this.copy('www/css/app/00._global.scss', 'www/css/app/00._global.scss');
  this.copy('www/css/app/01._typography.scss', 'www/css/app/01._typography.scss');
  this.copy('www/css/app/02._widgets.scss', 'www/css/app/02._widgets.scss');
  this.copy('www/css/app/02.widgets.header.scss', 'www/css/app/02.widgets.header.scss');
  this.copy('www/css/app/03._pages.scss', 'www/css/app/03._pages.scss');
  this.copy('www/css/app/04._utilities.scss', 'www/css/app/04._utilities.scss');
  this.copy('www/css/app/05._shame.scss', 'www/css/app/05._shame.scss');
  this.copy('www/css/app/06._print.scss', 'www/css/app/06._print.scss');
  this.copy('www/css/app/_modules/_mixins.scss', 'www/css/app/_modules/_mixins.scss');
  this.copy('www/css/app/_modules/_variables.scss', 'www/css/app/_modules/_variables.scss');
  this.copy('www/css/app/_vendor/_grid.generator.scss', 'www/css/app/_vendor/_grid.generator.scss');
  this.copy('www/css/app/_vendor/_normalize.scss', 'www/css/app/_vendor/_normalize.scss');

  // files within the user's root directory
  this.template('_package.json', 'package.json');
  this.template('_config.json', 'config.json');
  this.template('_bower.json', 'bower.json');
};

CpbGenerator.prototype.projectfiles = function projectfiles() {
  // move files within the user's root directory
  this.copy('bowerrc', '.bowerrc');
  this.copy('editorconfig', '.editorconfig');
  this.copy('jshintrc', '.jshintrc');
};
<commit_msg>fixing index.js<commit_after>// CPB Boilerplate Generator
//  JavaScript
//    1. Modules - which can be added or removed via Bower
//    2. Pattern Guide
//    3. Frameworks
//        i.   Angular
//        ii.  Backbone (default)
//        iii. Ember
//  CSS
//    1. SASS
//    2. Pattern Guide
//    3. Function Documentation
//    4. Sprites

'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');

// begin the adventure of a lifetime
var CpbGenerator = module.exports = function CpbGenerator(args, options, config) {
  yeoman.generators.Base.apply(this, arguments); // wire up the base

  this.on('end', function () { // listen to the end event
    this.installDependencies({ skipInstall: options['skip-install'] }); // install all dependancies
  });

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); // get access to package.json file
};

util.inherits(CpbGenerator, yeoman.generators.Base);

// the ask, every one of these methods will be called in order from top to bottom of this file, get to know it
// the only time these wont run is if they are private methods
// in order to determine a private method, please name the methods starting with an underscore:
// Example: CpbGenerator.prototype._dontRunMe

CpbGenerator.prototype.askFor = function askFor() {
  var cb = this.async(); // creates an instance for Async functions

  // have Yeoman greet the user.
  console.log(this.yeoman);

  // setup Promps to Determine if the User wants something in the Boilerplate
  var prompts = [{
    name: 'siteName',
    message: 'What do you want to call this project?',
    default: 'CP+B Boilderplate'
  }];

  this.prompt(prompts, function (props) {
     this.siteName = props.siteName;
    cb();
  }.bind(this));
};

CpbGenerator.prototype.app = function app() {
  // create the directories needed for the app
  this.mkdir('build');
  this.mkdir('build/config');
  this.mkdir('www');
  this.mkdir('www/images');
  this.mkdir('www/js');
  this.mkdir('www/js/app');
  this.mkdir('www/js/helpers');
  this.mkdir('www/js/lib');
  this.mkdir('www/js/min');
  this.mkdir('www/js/app/collection');
  this.mkdir('www/js/app/model');
  this.mkdir('www/js/app/template');
  this.mkdir('www/js/app/view');
  this.mkdir('www/css');
  this.mkdir('www/css/fonts');
  this.mkdir('www/css/min');
  this.mkdir('www/css/generated');

  // using markdown templates generate the html needed
  this.template('_index.md', 'www/index.html');

  // copy over styles and JS
  this.copy('Gruntfile.js', 'Gruntfile.js');
  this.copy('build/config/clean.js', 'build/config/clean.js');
  this.copy('build/config/compass.js', 'build/config/compass.js');
  this.copy('build/config/imagemin.js', 'build/config/imagemin.js');
  this.copy('build/config/jshint.js', 'build/config/jshint.js');
  this.copy('build/config/requirejs.js', 'build/config/requirejs.js');
  this.copy('build/config/watch.js', 'build/config/watch.js');
  this.copy('www/robots.txt', 'www/robots.txt');
  this.copy('www/js/app/main.js', 'www/js/app/main.js');
  this.copy('www/js/helpers/analytics.js', 'www/js/helpers/analytics.js');
  this.copy('www/js/helpers/console.js', 'www/js/helpers/console.js');
  this.copy('www/js/helpers/events.js', 'www/js/helpers/events.js');
  this.copy('www/js/helpers/utilities.js', 'www/js/helpers/utilities.js');
  this.copy('www/js/app/router.js', 'www/js/app/router.js');
  this.copy('www/js/app/master/app.js', 'www/js/app/master/app.js');
  this.copy('www/js/app/master/template/Example.html', 'www/js/app/master/template/Example.html');
  this.copy('www/js/app/master/view/example.js', 'www/js/app/master/view/example.js');
  this.copy('www/js/app/master/view/subExample.js', 'www/js/app/master/view/subExample.js');
  this.copy('www/js/lib/backbone-min.js', 'www/js/lib/backbone-min.js');
  this.copy('www/js/lib/lodash.min.js', 'www/js/lib/lodash.min.js');
  this.copy('www/js/lib/modernizr-2.6.2.min.js', 'www/js/lib/modernizr-2.6.2.min.js');
  this.copy('www/js/lib/swig.min.js', 'www/js/lib/swig.min.js');
  this.copy('www/js/lib/enquire.min.js', 'www/js/lib/enquire.min.js');
  this.copy('www/js/lib/jquery-1.9.1.min.js', 'www/js/lib/jquery-1.9.1.min.js');
  this.copy('www/js/lib/require.js', 'www/js/lib/require.js');
  this.copy('www/js/lib/text.js', 'www/js/lib/text.js');
  this.copy('www/css/app/00._global.scss', 'www/css/app/00._global.scss');
  this.copy('www/css/app/01._typography.scss', 'www/css/app/01._typography.scss');
  this.copy('www/css/app/02._widgets.scss', 'www/css/app/02._widgets.scss');
  this.copy('www/css/app/02.widgets.header.scss', 'www/css/app/02.widgets.header.scss');
  this.copy('www/css/app/03._pages.scss', 'www/css/app/03._pages.scss');
  this.copy('www/css/app/04._utilities.scss', 'www/css/app/04._utilities.scss');
  this.copy('www/css/app/05._shame.scss', 'www/css/app/05._shame.scss');
  this.copy('www/css/app/06._print.scss', 'www/css/app/06._print.scss');
  this.copy('www/css/app/_modules/_mixins.scss', 'www/css/app/_modules/_mixins.scss');
  this.copy('www/css/app/_modules/_variables.scss', 'www/css/app/_modules/_variables.scss');
  this.copy('www/css/app/_vendor/_grid.generator.scss', 'www/css/app/_vendor/_grid.generator.scss');
  this.copy('www/css/app/_vendor/_normalize.scss', 'www/css/app/_vendor/_normalize.scss');

  // files within the user's root directory
  this.template('_package.json', 'package.json');
  this.template('_config.json', 'config.json');
  this.template('_bower.json', 'bower.json');
};

CpbGenerator.prototype.projectfiles = function projectfiles() {
  // move files within the user's root directory
  this.copy('bowerrc', '.bowerrc');
  this.copy('editorconfig', '.editorconfig');
  this.copy('jshintrc', '.jshintrc');
};
<|endoftext|>


<commit_before>'use strict';

var path = require('path');
var npmName = require('npm-name');
var yeoman = require('yeoman-generator');

module.exports = yeoman.generators.Base.extend({
    init: function () {
        this.pkg = require('../package.json');
        this.log(
            this.yeoman +
            '\nThe name of your project shouldn\'t contain "node" or "js" and' +
            '\nshould be a unique ID not already in use at search.npmjs.org.');
    },
    askForModuleName: function () {
       var done = this.async();

       var prompts = [{
         name: 'name',
         message: 'Module Name',
         default: path.basename(process.cwd()),
       }, {
         type: 'confirm',
         name: 'pkgName',
         message: 'The name above already exists on npm, choose another?',
         default: true,
         when: function(answers) {
           var done = this.async();

           npmName(answers.name, function (err, available) {
             if (!available) {
               done(true);
             }

             done(false);
           });
         }
       }];

       this.prompt(prompts, function (props) {
         if (props.pkgName) {
           return this.askForModuleName();
         }

         this.slugname = this._.slugify(props.name);
         this.safeSlugname = this.slugname.replace(
           /-+([a-zA-Z0-9])/g,
           function (g) { return g[1].toUpperCase(); }
         );

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

     askFor: function () {
       var cb = this.async();

       var prompts = [{
         name: 'description',
         message: 'Description',
         default: 'The best module ever.'
       }, {
         name: 'homepage',
         message: 'Homepage'
       }, {
         name: 'license',
         message: 'License',
         default: 'MIT'
       }, {
         name: 'githubUsername',
         message: 'GitHub username'
       }, {
         name: 'authorName',
         message: 'Author\'s Name'
       }, {
         name: 'authorEmail',
         message: 'Author\'s Email'
       }, {
         name: 'authorUrl',
         message: 'Author\'s Homepage'
       }, {
         name: 'keywords',
         message: 'Key your keywords (comma to split)'
       }, {
         type: 'confirm',
         name: 'cli',
         message: 'Do you need cli tools?',
         default: true
       }, {
         type: 'confirm',
         name: 'browser',
         message: 'Do you need browserify?',
         default: 'true'
       }];

       this.currentYear = (new Date()).getFullYear();

       this.prompt(prompts, function (props) {
         if(props.githubUsername){
           this.repoUrl = 'https://github.com/' + props.githubUsername + '/' + this.slugname;
         } else {
           this.repoUrl = 'user/repo';
         }

         if (!props.homepage) {
           props.homepage = this.repoUrl;
         }

         this.keywords = props.keywords.split(',');

         this.props = props;

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

    app: function () {
        this.config.save();
        this.copy('jshintrc', '.jshintrc');
        this.copy('gitignore', '.gitignore');
        this.copy('travis.yml', '.travis.yml');

        this.template('_README.md', 'README.md');
        this.template('_Gruntfile.js', 'Gruntfile.js');
        this.template('_package.json', 'package.json');

        if (this.props.cli) {
            this.template('_cli.js', 'cli.js');
        }
    },

    projectfiles: function () {
        this.mkdir('lib');
        this.template('lib/name.js', 'lib/' + this.slugname + '.js');
        this.mkdir('test');
        this.template('test/name_test.js', 'test/' + this.slugname + '_test.js');
        this.mkdir('example');
        this.template('example/name_example.js', 'example/' + this.slugname + '_example.js');
    },

    install: function () {
        this.installDependencies({
            bower: false,
            skipInstall: this.options['skip-install']
        });
    }
});
<commit_msg>Fixed boolean options being ignored<commit_after>'use strict';

var path = require('path');
var npmName = require('npm-name');
var yeoman = require('yeoman-generator');

module.exports = yeoman.generators.Base.extend({
    init: function () {
        this.pkg = require('../package.json');
        this.log(
            this.yeoman +
            '\nThe name of your project shouldn\'t contain "node" or "js" and' +
            '\nshould be a unique ID not already in use at search.npmjs.org.');
    },
    askForModuleName: function () {
       var done = this.async();

       var prompts = [{
         name: 'name',
         message: 'Module Name',
         default: path.basename(process.cwd()),
       }, {
         type: 'confirm',
         name: 'pkgName',
         message: 'The name above already exists on npm, choose another?',
         default: true,
         when: function(answers) {
           var done = this.async();

           npmName(answers.name, function (err, available) {
             if (!available) {
               done(true);
             }

             done(false);
           });
         }
       }];

       this.prompt(prompts, function (props) {
         if (props.pkgName) {
           return this.askForModuleName();
         }

         this.slugname = this._.slugify(props.name);
         this.safeSlugname = this.slugname.replace(
           /-+([a-zA-Z0-9])/g,
           function (g) { return g[1].toUpperCase(); }
         );

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

     askFor: function () {
       var cb = this.async();

       var prompts = [{
         name: 'description',
         message: 'Description',
         default: 'The best module ever.'
       }, {
         name: 'homepage',
         message: 'Homepage'
       }, {
         name: 'license',
         message: 'License',
         default: 'MIT'
       }, {
         name: 'githubUsername',
         message: 'GitHub username'
       }, {
         name: 'authorName',
         message: 'Author\'s Name'
       }, {
         name: 'authorEmail',
         message: 'Author\'s Email'
       }, {
         name: 'authorUrl',
         message: 'Author\'s Homepage'
       }, {
         name: 'keywords',
         message: 'Key your keywords (comma to split)'
       }, {
         type: 'confirm',
         name: 'cli',
         message: 'Do you need cli tools?'
       }, {
         type: 'confirm',
         name: 'browser',
         message: 'Do you need browserify?'
       }];

       this.currentYear = (new Date()).getFullYear();

       this.prompt(prompts, function (props) {
         if(props.githubUsername){
           this.repoUrl = 'https://github.com/' + props.githubUsername + '/' + this.slugname;
         } else {
           this.repoUrl = 'user/repo';
         }

         if (!props.homepage) {
           props.homepage = this.repoUrl;
         }

         this.keywords = props.keywords.split(',');

         this.props = props;

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

    app: function () {
        this.config.save();
        this.copy('jshintrc', '.jshintrc');
        this.copy('gitignore', '.gitignore');
        this.copy('travis.yml', '.travis.yml');

        this.template('_README.md', 'README.md');
        this.template('_Gruntfile.js', 'Gruntfile.js');
        this.template('_package.json', 'package.json');

        if (this.props.cli) {
            this.template('_cli.js', 'cli.js');
        }
    },

    projectfiles: function () {
        this.mkdir('lib');
        this.template('lib/name.js', 'lib/' + this.slugname + '.js');
        this.mkdir('test');
        this.template('test/name_test.js', 'test/' + this.slugname + '_test.js');
        this.mkdir('example');
        this.template('example/name_example.js', 'example/' + this.slugname + '_example.js');
    },

    install: function () {
        this.installDependencies({
            bower: false,
            skipInstall: this.options['skip-install']
        });
    }
});
<|endoftext|>


<commit_before>'use strict';

var util = require('util'),
    fs = require('fs'),
    path = require('path'),
    chalk = require('chalk'),
    yeoman = require('yeoman-generator'),
    pkgName = require('pkg-name'),
    updateNotifier = require('update-notifier'),
    compareVersion = require('compare-version'),
    stringLength = require('string-length'),
    _ = require('underscore.string'),
    mkdirp = require('mkdirp'),
    childProcess = require('child_process'),
    pkg = require('../package.json'),
    templateName = 'freekerneljs-basic-app-md',
    generatorRoot = '',
    templatePath = '';

var exec = childProcess.exec;

function getDirectories(srcpath) {
    return fs.readdirSync(srcpath).filter(function (file) {
        return fs.statSync(path.join(srcpath, file)).isDirectory();
    });
}

var freekerneljsGenerator = yeoman.generators.Base.extend({
    constructor: function () {
        yeoman.generators.Base.apply(this, arguments);

        this.on('end', function () {
            console.log('Running Grunt tasks now...');

            if (templateName == 'freekerneljs-basic-app') {
                var done = this.async();
                exec('grunt copy:bootstrap-fonts --project=' + this.slugname, function (err) {
                    if (err) {
                        this.log.error('Error: Grunt "copy:bootstrap-fonts" task.');
                        this.abort = true;
                    }
                    done();
                }.bind(this));
            }

            var done = this.async();
            exec('grunt default --project=' + this.slugname, function (err) {
                if (err) {
                    this.log.error('Error: Grunt "default" task.');
                    this.abort = true;
                }
                done();
            }.bind(this));

            var done = this.async();
            exec('grunt clean-workspace', function (err) {
                if (err) {
                    this.log.error('Error: Grunt "clean-workspace" task.');
                    this.abort = true;
                }
                done();
            }.bind(this));
        });

        this.appname = 'freekerneljs-project';

        //this.appname = this.appname || path.basename(process.cwd());
        //this.appname = this.appname.replace(/\s+/g, '-');
    },

    initializing: function () {
        generatorRoot = this.templatePath('../../');
        templatePath = this.templatePath();

        var done = this.async();
        updateNotifier({
            pkg: pkg,
            callback: function (err, update) {
                if (err) {
                    console.log(err);
                }
                else if (compareVersion(update.latest, update.current) == 1) {
                    var fill = function (str, count) {
                        return Array(count + 1).join(str);
                    };

                    var line1 = ' Update available: ' + chalk.green.bold(update.latest) + chalk.dim(' (current: ' + update.current + ')') + ' ',
                        line2 = ' Run ' + chalk.magenta('npm update -g ' + pkg.name) + ' to update. ',
                        contentWidth = Math.max(stringLength(line1), stringLength(line2)),
                        line1rest = contentWidth - stringLength(line1),
                        line2rest = contentWidth - stringLength(line2),
                        top = chalk.yellow('┌' + fill('─', contentWidth) + '┐'),
                        bottom = chalk.yellow('└' + fill('─', contentWidth) + '┘'),
                        side = chalk.yellow('│'),
                        updateMessage = '\n\n' + top + '\n' + side + line1 + fill(' ', line1rest) + side + '\n' + side + line2 + fill(' ', line2rest) + side + '\n' + bottom + '\n';

                    console.log(updateMessage);
                }

                done();
            }
        })
    },

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

        var welcomeMsg = '\n' +
          '+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+\n' +
          '|F|r|e|e|K|e|r|n|e|l|J|S| |G|e|n|e|r|a|t|o|r|\n' +
          '+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+\n' +
          '\n'

        console.log(welcomeMsg);

        var prompts = [{
            when: function (response) {
                if (getDirectories(templatePath).length > 1)
                    return true

                return false
            },
            type: 'list',
            name: 'template',
            message: 'Select a template',
            choices: getDirectories(templatePath),
            default: 'freekerneljs-basic-app-md'
        }, {
            when: function (response) {
                if (response.template == 'freekerneljs-basic-app')
                    return true

                return false
            },
            type: 'checkbox',
            name: 'modules',
            message: 'Which packages would you like to include?',
            choices: [{
                value: 'cookiesModule',
                name: 'angular-cookies',
                checked: false
            }, {
                value: 'resourceModule',
                name: 'angular-resource',
                checked: false
            }, {
                value: 'messagesModule',
                name: 'angular-messages',
                checked: false
            }, {
                value: 'sanitizeModule',
                name: 'angular-sanitize',
                checked: false
            }, {
                value: 'touchModule',
                name: 'angular-touch',
                checked: false
            }]
        }, {
            when: function (response) {
                if (response.template == 'freekerneljs-basic-app-md')
                    return true

                return false
            },
            type: 'checkbox',
            name: 'modules',
            message: 'Which packages would you like to include?',
            choices: [{
                value: 'cookiesModule',
                name: 'angular-cookies',
                checked: false
            }, {
                value: 'resourceModule',
                name: 'angular-resource',
                checked: false
            }, {
                value: 'messagesModule',
                name: 'angular-messages',
                checked: false
            }, {
                value: 'sanitizeModule',
                name: 'angular-sanitize',
                checked: false
            }, {
                value: 'touchModule',
                name: 'angular-touch',
                checked: false
            }, {
                value: 'iconicFont',
                name: 'material-design-iconic-font',
                checked: false
            }]
        }, {
            when: function (response) {
                //if (response.template)

                this.appname = 'response.template;'

                //global.project_name = 'FreeKernel.js ' + global.project_skeleton + ' ' + global.skeleton_type + ' ' + 'project ' +
                //    Math.floor((Math.random() * 1000000) + 1).toString();

                return true
            },
            type: 'input',
            name: 'name',
            message: 'Project name',
            default: this.appname
        }, {
            type: 'input',
            name: 'title',
            message: 'Title',
            default: 'FreeKernelJS App'
        }, {
            type: 'input',
            name: 'description',
            message: 'Description',
            default: 'A FreeKernelJS project'
        }, {
            type: 'input',
            name: 'version',
            message: 'Version',
            default: '1.0.0'
        }, {
            type: 'input',
            name: 'license',
            message: 'License',
            default: 'MIT'
        }, {
            type: 'input',
            name: 'repository',
            message: 'Repository',
            default: 'none'
        }, {
            type: 'input',
            name: 'author_name',
            message: 'Author name'
        }, {
            type: 'input',
            name: 'author_email',
            message: 'Author email'
        }, {
            type: 'input',
            name: 'author_url',
            message: 'Author url'
        }, {
            type: 'input',
            name: 'homepage',
            message: 'Home page'
        }];

        this.prompt(prompts, function (props) {
            this.props = props;

            if (props.template) {
                templateName = props.template;
            }

            // For easier access in the templates.
            this.slugname = _.slugify(props.name);

            var hasMod = function (mod) {
                return props.modules.indexOf(mod) !== -1;
            };

            // Common modules.
            this.angularModule = true;
            this.mocksModule = true;
            this.routeModule = true;
            this.scriptjsModule = true;
            this.angularTranslateModule = true;
            this.angularTranslateLoaderStaticFilesModule = true;
            this.cookiesModule = hasMod('cookiesModule');
            this.resourceModule = hasMod('resourceModule');
            this.messagesModule = hasMod('messagesModule');
            this.sanitizeModule = hasMod('sanitizeModule');
            this.touchModule = hasMod('touchModule');

            switch (templateName) {
                case 'freekerneljs-basic-app':
                    this.bootstrapModule = true;
                    break;
                case 'freekerneljs-basic-app-md':
                    this.materialModule = true;
                    this.iconicFont = hasMod('iconicFont');
                    break;
                default:
            }

            mkdirp(this.slugname);

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

    configuration: function () {
        // Workspace
        this.template(templateName + '/_package.json', 'package.json');
        this.template(templateName + '/_bower.json', 'bower.json');
        this.template('_bowerrc', '.bowerrc');
        this.copy('Gruntfile.js', 'Gruntfile.js');

        // Project folder
        this.template(templateName + '/_package.json', this.slugname + '/package.json');
        this.template(templateName + '/_bower.json', this.slugname + '/bower.json');
        this.copy('Gruntfile.js', this.slugname + '/Gruntfile.js');
        this.copy(templateName + '/gitignore', this.slugname + '/.gitignore');
        this.copy(templateName + '/bowerrc', this.slugname + '/.bowerrc');
    },

    app: function () {
        this.copy(templateName + '/app/_app.bootstrap.js', this.slugname + '/app/app.bootstrap.js');
        this.copy(templateName + '/app/_app.module.js', this.slugname + '/app/app.module.js');
        this.copy(templateName + '/app/_app.routes.js', this.slugname + '/app/app.routes.js');
        this.copy(templateName + '/app/_index.html', this.slugname + '/app/index.html');
        this.bulkDirectory(templateName + '/app/assets/images', this.slugname + '/app/assets/images');
        this.bulkDirectory(templateName + '/app/assets/scss', this.slugname + '/app/assets/scss');
        this.bulkDirectory(templateName + '/app/assets/css', this.slugname + '/app/assets/css');
        this.bulkDirectory(templateName + '/app/views', this.slugname + '/app/views');
        this.bulkDirectory(templateName + '/app/widgets', this.slugname + '/app/widgets');
        this.bulkDirectory(templateName + '/app/services', this.slugname + '/app/services');
        this.bulkDirectory(templateName + '/app/data', this.slugname + '/app/data');
    },

    writing: function () {
        this.copy(templateName + '/README.md', this.slugname + '/README.md');
        this.copy(templateName + '/README.md', 'README.md');
    },

    test: function () {
        this.bulkDirectory(templateName + '/app/_test', this.slugname + '/app/_test');
    },

    install: function () {
        this.installDependencies({
            skipInstall: this.options['skip-install']
        });
    }
});

module.exports = freekerneljsGenerator;<commit_msg>Project name default set to selected template + random number<commit_after>'use strict';

var util = require('util'),
    fs = require('fs'),
    path = require('path'),
    chalk = require('chalk'),
    yeoman = require('yeoman-generator'),
    pkgName = require('pkg-name'),
    updateNotifier = require('update-notifier'),
    compareVersion = require('compare-version'),
    stringLength = require('string-length'),
    _ = require('underscore.string'),
    mkdirp = require('mkdirp'),
    childProcess = require('child_process'),
    pkg = require('../package.json'),
    templateName = 'freekerneljs-basic-app-md',
    generatorRoot = '',
    templatePath = '';

var exec = childProcess.exec;

function getDirectories(srcpath) {
    return fs.readdirSync(srcpath).filter(function (file) {
        return fs.statSync(path.join(srcpath, file)).isDirectory();
    });
}

var freekerneljsGenerator = yeoman.generators.Base.extend({
    constructor: function () {
        yeoman.generators.Base.apply(this, arguments);

        this.on('end', function () {
            console.log('Running Grunt tasks now...');

            if (templateName == 'freekerneljs-basic-app') {
                var done = this.async();
                exec('grunt copy:bootstrap-fonts --project=' + this.slugname, function (err) {
                    if (err) {
                        this.log.error('Error: Grunt "copy:bootstrap-fonts" task.');
                        this.abort = true;
                    }
                    done();
                }.bind(this));
            }

            var done = this.async();
            exec('grunt default --project=' + this.slugname, function (err) {
                if (err) {
                    this.log.error('Error: Grunt "default" task.');
                    this.abort = true;
                }
                done();
            }.bind(this));

            var done = this.async();
            exec('grunt clean-workspace', function (err) {
                if (err) {
                    this.log.error('Error: Grunt "clean-workspace" task.');
                    this.abort = true;
                }
                done();
            }.bind(this));
        });
    },

    initializing: function () {
        generatorRoot = this.templatePath('../../');
        templatePath = this.templatePath();

        var done = this.async();
        updateNotifier({
            pkg: pkg,
            callback: function (err, update) {
                if (err) {
                    console.log(err);
                }
                else if (compareVersion(update.latest, update.current) == 1) {
                    var fill = function (str, count) {
                        return Array(count + 1).join(str);
                    };

                    var line1 = ' Update available: ' + chalk.green.bold(update.latest) + chalk.dim(' (current: ' + update.current + ')') + ' ',
                        line2 = ' Run ' + chalk.magenta('npm update -g ' + pkg.name) + ' to update. ',
                        contentWidth = Math.max(stringLength(line1), stringLength(line2)),
                        line1rest = contentWidth - stringLength(line1),
                        line2rest = contentWidth - stringLength(line2),
                        top = chalk.yellow('┌' + fill('─', contentWidth) + '┐'),
                        bottom = chalk.yellow('└' + fill('─', contentWidth) + '┘'),
                        side = chalk.yellow('│'),
                        updateMessage = '\n\n' + top + '\n' + side + line1 + fill(' ', line1rest) + side + '\n' + side + line2 + fill(' ', line2rest) + side + '\n' + bottom + '\n';

                    console.log(updateMessage);
                }

                done();
            }
        })
    },

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

        var welcomeMsg = '\n' +
          '+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+\n' +
          '|F|r|e|e|K|e|r|n|e|l|J|S| |G|e|n|e|r|a|t|o|r|\n' +
          '+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+\n' +
          '\n'

        console.log(welcomeMsg);

        var prompts = [{
            when: function (response) {
                if (getDirectories(templatePath).length > 1)
                    return true

                return false
            },
            type: 'list',
            name: 'template',
            message: 'Select a template',
            choices: getDirectories(templatePath),
            default: 'freekerneljs-basic-app-md'
        }, {
            when: function (response) {
                return response.template === 'freekerneljs-basic-app';
            },
            type: 'checkbox',
            name: 'modules',
            message: 'Which packages would you like to include?',
            choices: [{
                value: 'cookiesModule',
                name: 'angular-cookies',
                checked: false
            }, {
                value: 'resourceModule',
                name: 'angular-resource',
                checked: false
            }, {
                value: 'messagesModule',
                name: 'angular-messages',
                checked: false
            }, {
                value: 'sanitizeModule',
                name: 'angular-sanitize',
                checked: false
            }, {
                value: 'touchModule',
                name: 'angular-touch',
                checked: false
            }]
        }, {
            when: function (response) {
                return response.template === 'freekerneljs-basic-app-md';
            },
            type: 'checkbox',
            name: 'modules',
            message: 'Which packages would you like to include?',
            choices: [{
                value: 'cookiesModule',
                name: 'angular-cookies',
                checked: false
            }, {
                value: 'resourceModule',
                name: 'angular-resource',
                checked: false
            }, {
                value: 'messagesModule',
                name: 'angular-messages',
                checked: false
            }, {
                value: 'sanitizeModule',
                name: 'angular-sanitize',
                checked: false
            }, {
                value: 'touchModule',
                name: 'angular-touch',
                checked: false
            }, {
                value: 'iconicFont',
                name: 'material-design-iconic-font',
                checked: false
            }]
        }, {
            type: 'input',
            name: 'name',
            message: 'Project name',
            default: function (response) {
                //var name = this.appname || path.basename(process.cwd());
                //return name.replace(/\s+/g, '-');
                return response.template + '-' + Math.floor((Math.random() * 1000000) + 1).toString();
            }
        }, {
            type: 'input',
            name: 'title',
            message: 'Title',
            default: 'FreeKernelJS App'
        }, {
            type: 'input',
            name: 'description',
            message: 'Description',
            default: 'A FreeKernelJS project'
        }, {
            type: 'input',
            name: 'version',
            message: 'Version',
            default: '1.0.0'
        }, {
            type: 'input',
            name: 'license',
            message: 'License',
            default: 'MIT'
        }, {
            type: 'input',
            name: 'repository',
            message: 'Repository',
            default: 'none'
        }, {
            type: 'input',
            name: 'author_name',
            message: 'Author name'
        }, {
            type: 'input',
            name: 'author_email',
            message: 'Author email'
        }, {
            type: 'input',
            name: 'author_url',
            message: 'Author url'
        }, {
            type: 'input',
            name: 'homepage',
            message: 'Home page'
        }];

        this.prompt(prompts, function (props) {
            this.props = props;

            if (props.template) {
                templateName = props.template;
            }

            // For easier access in the templates.
            this.slugname = _.slugify(props.name);

            var hasMod = function (mod) {
                return props.modules.indexOf(mod) !== -1;
            };

            // Common modules.
            this.angularModule = true;
            this.mocksModule = true;
            this.routeModule = true;
            this.scriptjsModule = true;
            this.angularTranslateModule = true;
            this.angularTranslateLoaderStaticFilesModule = true;
            this.cookiesModule = hasMod('cookiesModule');
            this.resourceModule = hasMod('resourceModule');
            this.messagesModule = hasMod('messagesModule');
            this.sanitizeModule = hasMod('sanitizeModule');
            this.touchModule = hasMod('touchModule');

            switch (templateName) {
                case 'freekerneljs-basic-app':
                    this.bootstrapModule = true;
                    break;
                case 'freekerneljs-basic-app-md':
                    this.materialModule = true;
                    this.iconicFont = hasMod('iconicFont');
                    break;
                default:
            }

            mkdirp(this.slugname);

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

    configuration: function () {
        // Workspace
        this.template(templateName + '/_package.json', 'package.json');
        this.template(templateName + '/_bower.json', 'bower.json');
        this.template('_bowerrc', '.bowerrc');
        this.copy('Gruntfile.js', 'Gruntfile.js');

        // Project folder
        this.template(templateName + '/_package.json', this.slugname + '/package.json');
        this.template(templateName + '/_bower.json', this.slugname + '/bower.json');
        this.copy('Gruntfile.js', this.slugname + '/Gruntfile.js');
        this.copy(templateName + '/gitignore', this.slugname + '/.gitignore');
        this.copy(templateName + '/bowerrc', this.slugname + '/.bowerrc');
    },

    app: function () {
        this.copy(templateName + '/app/_app.bootstrap.js', this.slugname + '/app/app.bootstrap.js');
        this.copy(templateName + '/app/_app.module.js', this.slugname + '/app/app.module.js');
        this.copy(templateName + '/app/_app.routes.js', this.slugname + '/app/app.routes.js');
        this.copy(templateName + '/app/_index.html', this.slugname + '/app/index.html');
        this.bulkDirectory(templateName + '/app/assets/images', this.slugname + '/app/assets/images');
        this.bulkDirectory(templateName + '/app/assets/scss', this.slugname + '/app/assets/scss');
        this.bulkDirectory(templateName + '/app/assets/css', this.slugname + '/app/assets/css');
        this.bulkDirectory(templateName + '/app/views', this.slugname + '/app/views');
        this.bulkDirectory(templateName + '/app/widgets', this.slugname + '/app/widgets');
        this.bulkDirectory(templateName + '/app/services', this.slugname + '/app/services');
        this.bulkDirectory(templateName + '/app/data', this.slugname + '/app/data');
    },

    writing: function () {
        this.copy(templateName + '/README.md', this.slugname + '/README.md');
        this.copy(templateName + '/README.md', 'README.md');
    },

    test: function () {
        this.bulkDirectory(templateName + '/app/_test', this.slugname + '/app/_test');
    },

    install: function () {
        this.installDependencies({
            skipInstall: this.options['skip-install']
        });
    }
});

module.exports = freekerneljsGenerator;<|endoftext|>