<commit_before>'use strict';
var util = require('util');
var fs = require('fs');
var path = require('path');
var yeoman = require('yeoman-generator');
var mout = require('mout').string;
var cordova = require('cordova');
var chalk = require('chalk');
var xml2js = require('xml2js');

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

  this.argument('appName', { type: String, required: false });
  this.appName = this.appName || path.basename(process.cwd());
  this.appName = mout.pascalCase(this.appName);
  this.appPath = 'app';
  this.root = process.cwd();

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

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

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

IonicGenerator.prototype.cordovaInit = function cordovaInit() {
  cordova.create('.', this.appName, this.appName);
  console.log(chalk.yellow('Creating a new cordova project with name "' + this.appName + '" and id "' + this.appName));
};

IonicGenerator.prototype.setupEnv = function setupEnv() {
  // Copies the contents of the generator example app
  // directory into your users new application path
  this.sourceRoot(path.join(__dirname, '../templates/'));
  this.directory('common/root', '.', true);
};

IonicGenerator.prototype.packageFiles = function packageFiles() {
  this.template('common/_bower.json', 'bower.json');
  this.template('common/_bowerrc', '.bowerrc');
  this.template('common/_package.json', 'package.json');
  this.template('common/Gruntfile.js', 'Gruntfile.js');
  this.template('common/_gitignore', '.gitignore');
};

IonicGenerator.prototype.appFiles = function appFiles() {
  this.template('javascript/app.js', 'app/scripts/app.js');
  this.template('javascript/controllers.js', 'app/scripts/controllers.js');
  this.template('javascript/services.js', 'app/scripts/services.js');
  this.template('views/index.html', 'app/index.html');
  this.template('styles/main.sass', 'app/styles/main.sass');
};

// TODO: See if these options that the ionic seed project set config.xml are really needed
IonicGenerator.prototype.updateCordovaConfig = function updateCordovaConfig() {
  console.log(chalk.yellow('Attemping to overwrite Cordova generated files with example app skeleton.'));
  console.log(chalk.yellow('Type "y" and hit Enter to confirm overwrites:'));
  var parser = new xml2js.Parser({ normalize: true });
  var builder = new xml2js.Builder();
  var configPath = path.join(this.root, 'config.xml');
  var done = this.async();

  fs.readFile(configPath, function(err, data) {
    parser.parseString(data, function(err, config) {
      config.widget.preference = [
        { '$': { name: 'fullscreen', value: 'true' } },
        { '$': { name: 'webviewbounce', value: 'false' } },
        { '$': { name: 'UIWebViewBounce', value: 'false' } },
        { '$': { name: 'DisallowOverscroll', value: 'true' } }
      ];
      this.write(configPath, builder.buildObject(config));
      done();
    }.bind(this));
  }.bind(this));
};

<commit_msg>small correction<commit_after>'use strict';
var util = require('util');
var fs = require('fs');
var path = require('path');
var yeoman = require('yeoman-generator');
var mout = require('mout').string;
var cordova = require('cordova');
var chalk = require('chalk');
var xml2js = require('xml2js');

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

  this.argument('appName', { type: String, required: false });
  this.appName = this.appName || path.basename(process.cwd());
  this.appName = mout.pascalCase(this.appName);
  this.appPath = 'app';
  this.root = process.cwd();

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

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

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

IonicGenerator.prototype.cordovaInit = function cordovaInit() {
  cordova.create('.', this.appName, this.appName);
  console.log(chalk.yellow('Creating a new cordova project with name "' + this.appName + '" and id "' + this.appName));
};

IonicGenerator.prototype.setupEnv = function setupEnv() {
  // Copies the contents of the generator example app
  // directory into your users new application path
  this.sourceRoot(path.join(__dirname, '../templates/'));
  this.directory('common/root', '.', true);
};

IonicGenerator.prototype.packageFiles = function packageFiles() {
  this.template('common/_bower.json', 'bower.json');
  this.template('common/_bowerrc', '.bowerrc');
  this.template('common/_package.json', 'package.json');
  this.template('common/Gruntfile.js', 'Gruntfile.js');
  this.template('common/_gitignore', '.gitignore');
};

IonicGenerator.prototype.appFiles = function appFiles() {
  this.template('javascript/app.js', 'app/scripts/app.js');
  this.template('javascript/controllers.js', 'app/scripts/controllers.js');
  this.template('javascript/services.js', 'app/scripts/services.js');
  this.template('views/index.html', 'app/index.html');
};

// TODO: See if these options that the ionic seed project set config.xml are really needed
IonicGenerator.prototype.updateCordovaConfig = function updateCordovaConfig() {
  console.log(chalk.yellow('Attemping to overwrite Cordova generated files with example app skeleton.'));
  console.log(chalk.yellow('Type "y" and hit Enter to confirm overwrites:'));
  var parser = new xml2js.Parser({ normalize: true });
  var builder = new xml2js.Builder();
  var configPath = path.join(this.root, 'config.xml');
  var done = this.async();

  fs.readFile(configPath, function(err, data) {
    parser.parseString(data, function(err, config) {
      config.widget.preference = [
        { '$': { name: 'fullscreen', value: 'true' } },
        { '$': { name: 'webviewbounce', value: 'false' } },
        { '$': { name: 'UIWebViewBounce', value: 'false' } },
        { '$': { name: 'DisallowOverscroll', value: 'true' } }
      ];
      this.write(configPath, builder.buildObject(config));
      done();
    }.bind(this));
  }.bind(this));
};

<|endoftext|>


<commit_before>'use strict';
var util = require('util'),
    path = require('path'),
    yeoman = require('yeoman-generator'),
    gitconfig = require('git-config');
var fs     = require('fs')
var pkg    = require('../package.json')

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

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

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

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

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

  // have Yeoman greet the user.
//  console.log(this.yeoman);
  console.log(pkg.description + ' v' + pkg.version)

  var config      = gitconfig.sync();
  config.github   = config.github || {}
  config.user     = config.user   || {}
  var localGit    = process.cwd() + '/.git/config'
  var localConfig = (fs.existsSync(localGit)) ? gitconfig.sync(localGit) : {}
  localConfig.user        = localConfig.user || {}
  localConfig.github      = localConfig.github || {}
  localConfig.github.user = localConfig.github.user || {}
  var ghuser   = config.github.user || localConfig.github.user.name
  var username = config.user.name   || localConfig.user.name        || config.github.name  || localConfig.github.name  || ''
//  var email    = config.user.email  || localConfig.user.email       || config.github.email || localConfig.github.email || ''

  var keywords = this._.humanize(path.basename(process.cwd())) + ''
  keywords = keywords.toLowerCase()
  keywords = keywords.split(' ')

  function CapitalizeFirst(str) {
    return str.substr(0,1) + str.substr(1, str.length-1)
  }

  var prompts = [
    {
      type: 'input',
      name: 'moduleName',
      message: 'node.js module name:',
      default: this._.slugify(path.basename(process.cwd()))
    },
    {
      type: 'input',
      name: 'moduleDesc',
      message: 'Module description',
      default: this._.humanize(path.basename(process.cwd()))
    },
    {
      type: 'input',
      name: 'keywords',
      message: 'Module keywords',
      default: keywords,
      filter:
        function (value) {
          if (typeof value === 'string') {
            value = value.split(',');
          }
          return value
            .map(function (val) {
              return val.trim();
            })
            .filter(function (val) {
              return val.length > 0;
            })
        }
    },
    {
      type: 'list',
      name: 'moduleType',
      message: 'Module Type',
      choices: ['basic', 'cli', 'middleware'],
      default: 'basic'
    },
    {
      type: 'confirm',
      name: 'useGrunt',
      message: 'Use grunt?',
      default: false
    },
    {
      type: 'list',
      name: 'testFramework',
      message: 'Testing framework',
      choices: ['mocha', 'tape', 'redtape'],
      default: 'mocha'
    },
    {
      type: 'list',
      name: 'assertionLibrary',
      message: 'Assertion Library',
      choices: ['chai.expect', 'chai.should', 'expect.js', 'none'],
      default: 'chai.expect'
    },
    {
      type: 'input',
      name: 'githubName',
      message: 'Your github username',
      default: ghuser || username
    },
    {
      type: 'input',
      name: 'author',
      message: 'Author name',
      default: CapitalizeFirst(username)
    }
  ];

  this.prompt(prompts, function (props) {
    this.moduleName = this._.slugify(props.moduleName);
    this.moduleVarName = this._.camelize(props.moduleName);
    this.moduleErrName = CapitalizeFirst(this.moduleVarName) + 'Error'
    this.moduleType    = props.moduleType
    this.moduleNameHuman = this._.humanize(props.moduleName);
    this.moduleDesc = props.moduleDesc;
    this.keywords = props.keywords;
    this.githubName = props.githubName;
    this.author = props.author;
    this.copyrightName = props.author.replace(/<[^>]*?>/gm, '').trim();
    this.testFramework = props.testFramework;
    this.assertionLibrary = props.assertionLibrary;
    this.useGrunt = props.useGrunt;
    this.builtByName = pkg.name;
    this.builtByVersion = pkg.version;
    this.builtByUrl = pkg.homepage;
    this.license = 'MIT';
    this.year = new Date().getFullYear();

    this.dequote = function (str) {
      return str.replace(/\"/gm, '\\"');
    };

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

NodejsGenerator.prototype.build = function build() {
  this.template('_package.json', 'package.json');

  if (this.useGrunt) {
    this.template('Gruntfile.js', 'Gruntfile.js');
  }
  this.copy('jshintrc', '.jshintrc');
  this.copy('jshintignore', '.jshintignore');
  this.copy('travis.yml', '.travis.yml');
  this.copy('gitignore', '.gitignore');
  this.template('LICENSE', 'LICENSE');
  this.template('README.md', 'README.md');
};

NodejsGenerator.prototype.testFrameworks = function mocha() {
  this.mkdir('test');
  this.mkdir('test/fixtures');
  if (this.moduleType == 'cli') {
    this.mkdir('bin')
    this.template('modules/basic.js', 'index.js'); // cli is a basic module plus a bin component
    this.template('modules/cli.js',   'bin/cli.js');
  } else {
    this.template('modules/' + this.moduleType + '.js', 'index.js');
  }

  switch (this.testFramework) {
    case 'mocha':
      this.template('mocha_test/' + this.assertionLibrary + '.js', 'test/index.js');
      break;

    case 'tape':
      this.template('test-tape.js', 'test/index.js');
      break;

    case 'redtape':
      this.template('test-redtape.js', 'test/index.js');
      break;

    default:
      break;
  }
};
<commit_msg>captialize fix<commit_after>'use strict';
var util = require('util'),
    path = require('path'),
    yeoman = require('yeoman-generator'),
    gitconfig = require('git-config');
var fs     = require('fs')
var pkg    = require('../package.json')

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

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

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

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

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

  // have Yeoman greet the user.
//  console.log(this.yeoman);
  console.log(pkg.description + ' v' + pkg.version)

  var config      = gitconfig.sync();
  config.github   = config.github || {}
  config.user     = config.user   || {}
  var localGit    = process.cwd() + '/.git/config'
  var localConfig = (fs.existsSync(localGit)) ? gitconfig.sync(localGit) : {}
  localConfig.user        = localConfig.user || {}
  localConfig.github      = localConfig.github || {}
  localConfig.github.user = localConfig.github.user || {}
  var ghuser   = config.github.user || localConfig.github.user.name
  var username = config.user.name   || localConfig.user.name        || config.github.name  || localConfig.github.name  || ''
//  var email    = config.user.email  || localConfig.user.email       || config.github.email || localConfig.github.email || ''

  var keywords = this._.humanize(path.basename(process.cwd())) + ''
  keywords = keywords.toLowerCase()
  keywords = keywords.split(' ')

  var prompts = [
    {
      type: 'input',
      name: 'moduleName',
      message: 'node.js module name:',
      default: this._.slugify(path.basename(process.cwd()))
    },
    {
      type: 'input',
      name: 'moduleDesc',
      message: 'Module description',
      default: this._.humanize(path.basename(process.cwd()))
    },
    {
      type: 'input',
      name: 'keywords',
      message: 'Module keywords',
      default: keywords,
      filter:
        function (value) {
          if (typeof value === 'string') {
            value = value.split(',');
          }
          return value
            .map(function (val) {
              return val.trim();
            })
            .filter(function (val) {
              return val.length > 0;
            })
        }
    },
    {
      type: 'list',
      name: 'moduleType',
      message: 'Module Type',
      choices: ['basic', 'cli', 'middleware'],
      default: 'basic'
    },
    {
      type: 'confirm',
      name: 'useGrunt',
      message: 'Use grunt?',
      default: false
    },
    {
      type: 'list',
      name: 'testFramework',
      message: 'Testing framework',
      choices: ['mocha', 'tape', 'redtape'],
      default: 'mocha'
    },
    {
      type: 'list',
      name: 'assertionLibrary',
      message: 'Assertion Library',
      choices: ['chai.expect', 'chai.should', 'expect.js', 'none'],
      default: 'chai.expect'
    },
    {
      type: 'input',
      name: 'githubName',
      message: 'Your github username',
      default: ghuser || username
    },
    {
      type: 'input',
      name: 'author',
      message: 'Author name',
      default: username
    }
  ];

  this.prompt(prompts, function (props) {
    this.moduleName = this._.slugify(props.moduleName);
    this.moduleVarName = this._.camelize(props.moduleName);
    this.moduleErrName = this._.capitalize(this.moduleVarName) + 'Error'
    this.moduleType    = props.moduleType
    this.moduleNameHuman = this._.humanize(props.moduleName);
    this.moduleDesc = props.moduleDesc;
    this.keywords = props.keywords;
    this.githubName = props.githubName;
    this.author = props.author;
    this.copyrightName = this._.capitalize(props.author.trim());
    this.testFramework = props.testFramework;
    this.assertionLibrary = props.assertionLibrary;
    this.useGrunt = props.useGrunt;
    this.builtByName = pkg.name;
    this.builtByVersion = pkg.version;
    this.builtByUrl = pkg.homepage;
    this.license = 'MIT';
    this.year = new Date().getFullYear();

    this.dequote = function (str) {
      return str.replace(/\"/gm, '\\"');
    };

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

NodejsGenerator.prototype.build = function build() {
  this.template('_package.json', 'package.json');

  if (this.useGrunt) {
    this.template('Gruntfile.js', 'Gruntfile.js');
  }
  this.copy('jshintrc', '.jshintrc');
  this.copy('jshintignore', '.jshintignore');
  this.copy('travis.yml', '.travis.yml');
  this.copy('gitignore', '.gitignore');
  this.template('LICENSE', 'LICENSE');
  this.template('README.md', 'README.md');
};

NodejsGenerator.prototype.testFrameworks = function mocha() {
  this.mkdir('test');
  this.mkdir('test/fixtures');
  if (this.moduleType == 'cli') {
    this.mkdir('bin')
    this.template('modules/basic.js', 'index.js'); // cli is a basic module plus a bin component
    this.template('modules/cli.js',   'bin/cli.js');
  } else {
    this.template('modules/' + this.moduleType + '.js', 'index.js');
  }

  switch (this.testFramework) {
    case 'mocha':
      this.template('mocha_test/' + this.assertionLibrary + '.js', 'test/index.js');
      break;

    case 'tape':
      this.template('test-tape.js', 'test/index.js');
      break;

    case 'redtape':
      this.template('test-redtape.js', 'test/index.js');
      break;

    default:
      break;
  }
};
<|endoftext|>


<commit_before>if (process.env.NODE_ENV !== 'production') {
  require('dotenv').load();
}

var mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URL);

let worker = require('./worker');

module.exports = main;

function main() {
  if (process.argv.length > 2 && process.argv[2] === 'ungeocoded') {
    worker.getUnprocessedData().then((incidents) => {
      console.log('Address,Location');
      incidents.forEach((incident) => console.log(`${incident.address},${incident.location}`));
      process.exit();
    });
  }

  else if (process.argv.length > 2 && process.argv[2] === 'run') {
    setInterval(() => {
      worker.scrapeData().then(incidents => {
        console.log(`Geocoded ${incidents.length} incidents`);
      });
    });
  }

  else {
    worker.scrapeData().then((incidents) => {
      console.log(`Geocoded ${incidents.length} incidents`);
      process.exit();
    });
  }
}

if (require.main === module) {
  main();
}
<commit_msg>Forgot to put a timer in @_@.<commit_after>if (process.env.NODE_ENV !== 'production') {
  require('dotenv').load();
}

var mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URL);

let worker = require('./worker');

module.exports = main;

function main() {
  if (process.argv.length > 2 && process.argv[2] === 'ungeocoded') {
    worker.getUnprocessedData().then((incidents) => {
      console.log('Address,Location');
      incidents.forEach((incident) => console.log(`${incident.address},${incident.location}`));
      process.exit();
    });
  }

  else if (process.argv.length > 2 && process.argv[2] === 'run') {
    setInterval(() => {
      worker.scrapeData().then(incidents => {
        console.log(`Geocoded ${incidents.length} incidents`);
      });
    }, 60000);
  }

  else {
    worker.scrapeData().then((incidents) => {
      console.log(`Geocoded ${incidents.length} incidents`);
      process.exit();
    });
  }
}

if (require.main === module) {
  main();
}
<|endoftext|>


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

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

  // set source root path to templates
  this.sourceRoot(path.join(__dirname, 'templates'));

  // init extension manifest data
  this.manifest = {
    permissions:{}
  };

  // setup the test-framework property, Gruntfile template will need this
  this.testFramework = options['test-framework'] || 'mocha';
  this.coffee = options.coffee;
  this.compass = options.compass;

  // copy script with js or coffee extension
  this.copyjs = function copyjs(src, dest) {
    var ext = this.coffee ? '.coffee' : '.js';

    src = src + ext;
    dest = dest ? dest + ext : src;
    this.copy((this.coffee ? 'coffees/' : 'scripts/') + src, 'app/scripts/' + dest);
  };

  // for hooks to resolve on mocha by default
  options['test-framework'] = this.testFramework;

  // resolved to mocha by default (could be switched to jasmine for instance)
  this.hookFor('test-framework', {
    as: 'app',
    options: {
      options: {
        'skip-install': options['skip-install-message'],
        'skip-message': options['skip-install']
      }
    }
  });

  this.options = options;

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

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

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

  var prompts = [
    {
      name: 'name',
      message: 'What would you like to call this extension?',
      default: (this.appname) ? this.appname : 'myChromeApp'
    },
    {
      name: 'description',
      message: 'How would you like to describe this extension?',
      default: 'My Chrome Extension'
    },
    {
      type: 'list',
      name: 'action',
      message: 'Would you like to use UI Action?',
      choices:[
        'No',
        'Browser',
        'Page'
      ]
    },
    {
      type: 'checkbox',
      name: 'uifeatures',
      message: 'Would you like more UI Features?',
      choices: [{
        value: 'options',
        name: 'Options Page',
        checked: false
      }, {
        value: 'contentscript',
        name: 'Content Scripts',
        checked: false
      }, {
        value: 'omnibox',
        name: 'Omnibox',
        checked: false
      }]
    },
    {
      type: 'checkbox',
      name: 'permissions',
      message: 'Would you like to use permissions?',
      choices: [{
        value: 'tabs',
        name: 'Tabs',
        checked: false
      }, {
        value: 'bookmark',
        name: 'Bookmarks',
        checked: false
      }, {
        value: 'cookie',
        name: 'Cookies',
        checked: false
      }, {
        value: 'history',
        name: 'History',
        checked: false
      }, {
        value: 'management',
        name: 'Management',
        checked: false
      }]
    }
  ];

  this.prompt( prompts , function(answers) {
    var isChecked = function (choices, value) { return choices.indexOf(value) > -1; };

    this.appname = this.manifest.name = answers.name.replace(/\"/g, '\\"');
    this.manifest.description = answers.description.replace(/\"/g, '\\"');
    this.manifest.action = (answers.action === 'No') ? 0 : (answers.action === 'Browser') ? 1 : 2;
    this.manifest.options = isChecked(answers.uifeatures, 'options');
    this.manifest.omnibox = isChecked(answers.uifeatures, 'omnibox');
    this.manifest.contentscript = isChecked(answers.uifeatures, 'contentscript');
    this.manifest.permissions.tabs = isChecked(answers.permissions, 'tabs');
    this.manifest.permissions.bookmarks = isChecked(answers.permissions, 'bookmarks');
    this.manifest.permissions.cookies = isChecked(answers.permissions, 'cookies');
    this.manifest.permissions.history = isChecked(answers.permissions, 'history');
    this.manifest.permissions.management = isChecked(answers.permissions, 'management');

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

ChromeExtensionGenerator.prototype.app = function app() {
  this.mkdir('app');
  this.mkdir('app/bower_components');
};

ChromeExtensionGenerator.prototype.gruntfile = function gruntfile() {
  this.template('Gruntfile.js');
};

ChromeExtensionGenerator.prototype.packageJSON = function packageJSON() {
  this.template('_package.json', 'package.json');
};

ChromeExtensionGenerator.prototype.git = function git() {
  this.copy('gitignore', '.gitignore');
  this.copy('gitattributes', '.gitattributes');
};

ChromeExtensionGenerator.prototype.bower = function bower() {
  this.copy('bowerrc', '.bowerrc');
  this.copy('_bower.json', 'bower.json');
};

ChromeExtensionGenerator.prototype.jshint = function jshint() {
  this.copy('jshintrc', '.jshintrc');
};

ChromeExtensionGenerator.prototype.editorConfig = function editorConfig() {
  this.copy('editorconfig', '.editorconfig');
};

ChromeExtensionGenerator.prototype.manifest = function manifest() {
  var manifest = {};
  var permissions = [];
  var items = [];

  // add browser / page action field
  if (this.manifest.action > 0) {
    var action = {
      default_icon: { 19: 'images/icon-19.png', 38: 'images/icon-38.png' },
      default_title: this.manifest.name,
      default_popup: 'popup.html'
    };
    var title = (this.manifest.action === 1) ? 'browser_action' : 'page_action';
    manifest[title] = JSON.stringify(action, null, 2).replace(/\n/g, '\n  ');
  }

  // add options page field.
  if (this.manifest.options) {
    manifest.options_page = '"options.html"';
  }

  // add omnibox keyword field.
  if (this.manifest.omnibox) {
    manifest.omnibox = JSON.stringify({ keyword: this.manifest.name }, null, 2).replace(/\n/g, '\n  ');
  }

  // add contentscript field.
  if (this.manifest.contentscript) {
    var contentscript = [{
      matches: ['http://*/*', 'https://*/*'],
      css: ['styles/main.css'],
      js: ['scripts/contentscript.js'],
      run_at: 'document_end',
      all_frames: false
    }];

    manifest.content_scripts = JSON.stringify(contentscript, null, 2).replace(/\n/g, '\n  ');
  }

  // add generate permission field.
  for (var p in this.manifest.permissions) {
    if (this.manifest.permissions[p]) {
      permissions.push(p);
    }
  }

  // add generic match pattern field.
  if (this.manifest.permissions.tabs) {
    permissions.push('http://*/*');
    permissions.push('https://*/*');
  }

  if (permissions.length > 0) {
    manifest.permissions = JSON.stringify(permissions, null, 2).replace(/\n/g, '\n  ');
  }

  for (var i in manifest) {
    items.push(['  "', i, '": ', manifest[i]].join(''));
  }

  this.manifest.items = (items.length > 0) ? ',\n' + items.join(',\n') : '';

  this.template('manifest.json', 'app/manifest.json');
};

ChromeExtensionGenerator.prototype.actions = function popup() {
  if (this.manifest.action === 0) {
    return;
  }

  this.copy('popup.html', 'app/popup.html');
  this.copyjs('popup');
  this.copy('images/icon-19.png', 'app/images/icon-19.png');
  this.copy('images/icon-38.png', 'app/images/icon-38.png');
};

ChromeExtensionGenerator.prototype.eventpage = function extensions() {
  var backgroundjs = 'background';

  if (this.manifest.action === 2) {
    backgroundjs = 'background.pageaction';
  } else if (this.manifest.action === 1) {
    backgroundjs = 'background.browseraction';
  }

  this.copyjs(backgroundjs, 'background');
  this.copyjs('chromereload');
};

ChromeExtensionGenerator.prototype.options = function options() {
  if (!this.manifest.options) {
    return;
  }

  this.copy('options.html', 'app/options.html');
  this.copyjs('options');
};

ChromeExtensionGenerator.prototype.contentscript = function contentscript() {
  if (!this.manifest.contentscript) {
    return;
  }

  this.copyjs('contentscript');
};

ChromeExtensionGenerator.prototype.mainStylesheet = function mainStylesheet() {
  if (this.manifest.action === 0 && !this.manifest.options) {
    return;
  }

  var css = 'styles/main.' + (this.compass ? 's' : '') + 'css';
  this.copy(css, 'app/' + css);
};

ChromeExtensionGenerator.prototype.assets = function assets() {
  this.template('_locales/en/messages.json', 'app/_locales/en/messages.json');
  this.copy('images/icon-16.png', 'app/images/icon-16.png');
  this.copy('images/icon-128.png', 'app/images/icon-128.png');
};

ChromeExtensionGenerator.prototype.install = function () {
  if (this.options['skip-install']) {
    return;
  }

  var done = this.async();
  this.installDependencies({
    skipMessage: this.options['skip-install-message'],
    skipInstall: this.options['skip-install'],
    callback: done
  });
}
<commit_msg>Update index.js file structure<commit_after>'use strict';
var path = require('path');
var util = require('util');
var spawn = require('child_process').spawn;
var yeoman = require('yeoman-generator');

module.exports = yeoman.generators.Base.extend({
  constructor: function (args, options, config) {
    yeoman.generators.Base.apply(this, arguments);

    // set source root path to templates
    this.sourceRoot(path.join(__dirname, 'templates'));

    // init extension manifest data
    this.manifest = {
      permissions:{}
    };

    // setup the test-framework property, Gruntfile template will need this
    this.testFramework = options['test-framework'] || 'mocha';
    this.coffee = options.coffee;
    this.compass = options.compass;

    // copy script with js or coffee extension
    this.copyjs = function copyjs(src, dest) {
      var ext = this.coffee ? '.coffee' : '.js';

      src = src + ext;
      dest = dest ? dest + ext : src;
      this.copy((this.coffee ? 'coffees/' : 'scripts/') + src, 'app/scripts/' + dest);
    };

    // for hooks to resolve on mocha by default
    options['test-framework'] = this.testFramework;

    // resolved to mocha by default (could be switched to jasmine for instance)
    this.hookFor('test-framework', {
      as: 'app',
      options: {
        options: {
          'skip-install': options['skip-install-message'],
          'skip-message': options['skip-install']
        }
      }
    });

    this.options = options;

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

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

    var prompts = [
      {
        name: 'name',
        message: 'What would you like to call this extension?',
        default: (this.appname) ? this.appname : 'myChromeApp'
      },
      {
        name: 'description',
        message: 'How would you like to describe this extension?',
        default: 'My Chrome Extension'
      },
      {
        type: 'list',
        name: 'action',
        message: 'Would you like to use UI Action?',
        choices:[
          'No',
          'Browser',
          'Page'
        ]
      },
      {
        type: 'checkbox',
        name: 'uifeatures',
        message: 'Would you like more UI Features?',
        choices: [{
          value: 'options',
          name: 'Options Page',
          checked: false
        }, {
          value: 'contentscript',
          name: 'Content Scripts',
          checked: false
        }, {
          value: 'omnibox',
          name: 'Omnibox',
          checked: false
        }]
      },
      {
        type: 'checkbox',
        name: 'permissions',
        message: 'Would you like to use permissions?',
        choices: [{
          value: 'tabs',
          name: 'Tabs',
          checked: false
        }, {
          value: 'bookmark',
          name: 'Bookmarks',
          checked: false
        }, {
          value: 'cookie',
          name: 'Cookies',
          checked: false
        }, {
          value: 'history',
          name: 'History',
          checked: false
        }, {
          value: 'management',
          name: 'Management',
          checked: false
        }]
      }
    ];

    this.prompt( prompts , function(answers) {
      var isChecked = function (choices, value) { return choices.indexOf(value) > -1; };

      this.appname = this.manifest.name = answers.name.replace(/\"/g, '\\"');
      this.manifest.description = answers.description.replace(/\"/g, '\\"');
      this.manifest.action = (answers.action === 'No') ? 0 : (answers.action === 'Browser') ? 1 : 2;
      this.manifest.options = isChecked(answers.uifeatures, 'options');
      this.manifest.omnibox = isChecked(answers.uifeatures, 'omnibox');
      this.manifest.contentscript = isChecked(answers.uifeatures, 'contentscript');
      this.manifest.permissions.tabs = isChecked(answers.permissions, 'tabs');
      this.manifest.permissions.bookmarks = isChecked(answers.permissions, 'bookmarks');
      this.manifest.permissions.cookies = isChecked(answers.permissions, 'cookies');
      this.manifest.permissions.history = isChecked(answers.permissions, 'history');
      this.manifest.permissions.management = isChecked(answers.permissions, 'management');

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

  app: function () {
    this.mkdir('app');
    this.mkdir('app/bower_components');
  },

  gruntfile: function () {
    this.template('Gruntfile.js');
  },

  packageJSON: function () {
    this.template('_package.json', 'package.json');
  },

  git: function () {
    this.copy('gitignore', '.gitignore');
    this.copy('gitattributes', '.gitattributes');
  },

  bower: function () {
    this.copy('bowerrc', '.bowerrc');
    this.copy('_bower.json', 'bower.json');
  },

  jshint: function () {
    this.copy('jshintrc', '.jshintrc');
  },

  editorConfig: function () {
    this.copy('editorconfig', '.editorconfig');
  },

  manifest: function () {
    var manifest = {};
    var permissions = [];
    var items = [];

    // add browser / page action field
    if (this.manifest.action > 0) {
      var action = {
        default_icon: { 19: 'images/icon-19.png', 38: 'images/icon-38.png' },
        default_title: this.manifest.name,
        default_popup: 'popup.html'
      };
      var title = (this.manifest.action === 1) ? 'browser_action' : 'page_action';
      manifest[title] = JSON.stringify(action, null, 2).replace(/\n/g, '\n  ');
    }

    // add options page field.
    if (this.manifest.options) {
      manifest.options_page = '"options.html"';
    }

    // add omnibox keyword field.
    if (this.manifest.omnibox) {
      manifest.omnibox = JSON.stringify({ keyword: this.manifest.name }, null, 2).replace(/\n/g, '\n  ');
    }

    // add contentscript field.
    if (this.manifest.contentscript) {
      var contentscript = [{
        matches: ['http://*/*', 'https://*/*'],
        css: ['styles/main.css'],
        js: ['scripts/contentscript.js'],
        run_at: 'document_end',
        all_frames: false
      }];

      manifest.content_scripts = JSON.stringify(contentscript, null, 2).replace(/\n/g, '\n  ');
    }

    // add generate permission field.
    for (var p in this.manifest.permissions) {
      if (this.manifest.permissions[p]) {
        permissions.push(p);
      }
    }

    // add generic match pattern field.
    if (this.manifest.permissions.tabs) {
      permissions.push('http://*/*');
      permissions.push('https://*/*');
    }

    if (permissions.length > 0) {
      manifest.permissions = JSON.stringify(permissions, null, 2).replace(/\n/g, '\n  ');
    }

    for (var i in manifest) {
      items.push(['  "', i, '": ', manifest[i]].join(''));
    }

    this.manifest.items = (items.length > 0) ? ',\n' + items.join(',\n') : '';

    this.template('manifest.json', 'app/manifest.json');
  },

  actions: function () {
    if (this.manifest.action === 0) {
      return;
    }

    this.copy('popup.html', 'app/popup.html');
    this.copyjs('popup');
    this.copy('images/icon-19.png', 'app/images/icon-19.png');
    this.copy('images/icon-38.png', 'app/images/icon-38.png');
  },

  eventpage: function () {
    var backgroundjs = 'background';

    if (this.manifest.action === 2) {
      backgroundjs = 'background.pageaction';
    } else if (this.manifest.action === 1) {
      backgroundjs = 'background.browseraction';
    }

    this.copyjs(backgroundjs, 'background');
    this.copyjs('chromereload');
  },

  options: function () {
    if (!this.manifest.options) {
      return;
    }

    this.copy('options.html', 'app/options.html');
    this.copyjs('options');
  },

  contentscript: function () {
    if (!this.manifest.contentscript) {
      return;
    }

    this.copyjs('contentscript');
  },

  mainStylesheet: function () {
    if (this.manifest.action === 0 && !this.manifest.options) {
      return;
    }

    var css = 'styles/main.' + (this.compass ? 's' : '') + 'css';
    this.copy(css, 'app/' + css);
  },

  assets: function () {
    this.template('_locales/en/messages.json', 'app/_locales/en/messages.json');
    this.copy('images/icon-16.png', 'app/images/icon-16.png');
    this.copy('images/icon-128.png', 'app/images/icon-128.png');
  },

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

    var done = this.async();
    this.installDependencies({
      skipMessage: this.options['skip-install-message'],
      skipInstall: this.options['skip-install'],
      callback: done
    });
  }
});
<|endoftext|>


<commit_before>'use strict';

var React = require('react');
var Router = require('react-router');

var routes = require('./routes.jsx');

// XXX: yields Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
// when developing
routes().then(function(routeDefinition) {
    Router.run(routeDefinition, Router.HistoryLocation, function(Application) {
        React.render(<Application />, document.body);
    });
}).catch(function(res) {
    console.error(res);
});
<commit_msg>Remove XXX<commit_after>'use strict';

var React = require('react');
var Router = require('react-router');

var routes = require('./routes.jsx');

routes().then(function(routeDefinition) {
    Router.run(routeDefinition, Router.HistoryLocation, function(Application) {
        React.render(<Application />, document.body);
    });
}).catch(function(res) {
    console.error(res);
});
<|endoftext|>


<commit_before>'use strict';
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import App from './containers/App';
import configureStore from './stores/configureStore';

const store = configureStore();

render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
);
<commit_msg>update<commit_after>import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import App from './containers/App';
import configureStore from './stores/configureStore';

const store = configureStore();

render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
);
<|endoftext|>


<commit_before>'use strict';
var yeoman = require('yeoman-generator'),
    fs = require('fs'),
    util = require('util'),
    path = require('path'),
    yosay = require('yosay'),
    chalk = require('chalk'),
    shell = require('shelljs');

var smacssGenerator = yeoman.generators.Base.extend({
    constructor: function () {
        // note: arguments and options should be defined in the constructor.
        yeoman.generators.Base.apply(this, arguments);

        this.option('app-suffix', {
            desc: 'Allow a custom suffix to be added to the module name',
            type: String,
            required: 'false'
        });
        this.env.options['app-suffix'] = this.options['app-suffix'];

        this.option('skip-welcome-message', {
            desc: 'Skips the welcome message',
            type: Boolean
        });

        this.option('skip-install', {
            desc: 'Skips the installation of dependencies',
            type: Boolean
        });

        this.option('skip-install-message', {
            desc: 'Skips the message after the installation of dependencies',
            type: Boolean
        });

        // This method adds support for a `--coffee` flag
        this.option('coffee');
        // And you can then access it later on this way; e.g.
        this.scriptSuffix = (this.options.coffee ? ".coffee": ".js");
    },
});

smacssGenerator.prototype.initializing = function initializing() {
    this.pkg = require('../package.json');
};

smacssGenerator.prototype.welcome = function welcome() {
    if (!this.options['skip-welcome-message']) {
        this.log(yosay('Yo! Welcome to SMACSS'));
        this.log(chalk.magenta.bold('You\'re using the perfectionist generator for frontend.'));
        this.log(chalk.gray('================================================================'));
        this.log(chalk.gray('Answer simple questions to kick start your project'));
    }
};

smacssGenerator.prototype.askAppType = function askAppType() {
    var done = this.async();

    var prompts = [{
        name: 'appName',
        message: 'What would you like to name your app/site?',
        default: process.cwd().split(path.sep).pop()
        },{
        name: 'appType',
        message: 'Kind of app/site you are trying to build?',
        type: 'list',
        choices:[{
            name: 'Simple Web App',
            value: 'typeSimpleWebApp',
            checked: false
        },{
            name: 'Full Pack Web App',
            value: 'typeFullPackWebApp',
            checked: false
        },{
            name: 'Angular App',
            value: 'typeAngularApp',
            checked: false
        }],
        default: 1
    }];
    this.prompt(prompts, function (answers) {
        var type = answers.type;

        this.appName = this._.camelize(this._.slugify(this._.humanize(answers.appName)));
        this.appType = answers.appType;

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

smacssGenerator.prototype.askAppFeatures = function askAppFeatures() {
    if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
        var done = this.async();
        var prompts = [{
            name: 'appFeatures',
            message: 'How about some additional features',
            type: 'checkbox',
            choices:[{
                name: ' jQuery',
                value: 'includeQuery',
                checked: true
            },{
                name: ' Modernizr',
                value: 'includeModernizr',
                checked: false
            }]
        }];
        this.prompt(prompts, function (answers) {
            var appFeatures = answers.appFeatures;

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

            this.includeQuery = hasFeature('includeQuery');
            this.includeModernizr = hasFeature('includeModernizr');

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

smacssGenerator.prototype.askAngularModules = function askAngularModules() {
    if(this.appType === 'typeAngularApp') {
        var done = this.async();
        var prompts = [{
            name: 'angularModules',
            message: 'How about including some angular modules',
            type: 'checkbox',
            choices:[{
                name: ' Angular Route',
                value: 'includeRouteModule',
                checked: true
            },{
                name: ' Angular Resource',
                value: 'includeResourceModule',
                checked: false
            },{
                name: ' Angular Sanitize',
                value: 'includeSanitizeModule',
                checked: false
            },{
                name: ' Angular Animate',
                value: 'includeAnimateModule',
                checked: false
            }]
        }];
        this.prompt(prompts, function (answers) {

            var hasModule = function (mod) {
                return answers.angularModules.indexOf(mod) !== -1;
            };

            this.includeRouteModule = hasModule('includeRouteModule');
            this.includeResourceModule = hasModule('includeResourceModule');
            this.includeSanitizeModule = hasModule('includeSanitizeModule');
            this.includeAnimateModule = hasModule('includeAnimateModule');

            var angMods = [];

            if (this.includeRouteModule) {
              angMods.push("'ngRoute'");
            }
            if (this.includeResourceModule) {
              angMods.push("'ngResource'");
            }
            if (this.includeSanitizeModule) {
              angMods.push("'ngSanitize'");
            }
            if (this.includeAnimateModule) {
              angMods.push("'ngAnimate'");
            }

            if (angMods.length) {
              this.env.options.angularDeps = '\n    ' + angMods.join(',\n    ') + '\n  ';
            }

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

smacssGenerator.prototype.scaffoldFolders = function scaffoldFolders() {
    this.log(chalk.gray('================================================================'));
    this.log(chalk.gray('Creating the project structure'));

    // Common Scaffolding for all projets
    this.mkdir(this.appName + '/app');
    this.mkdir(this.appName + '/app/css');
    this.mkdir(this.appName + '/app/scss');
    this.mkdir(this.appName + '/app/js');
    this.mkdir(this.appName + '/app/images');
    this.mkdir(this.appName + '/app/fonts');

    if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
        this.mkdir(this.appName + '/app/partials');
        this.mkdir(this.appName + '/build');
    }
};

smacssGenerator.prototype.copyMainFiles = function copyMainFiles() {
    // Underscore templating context to replace placeholders
    smacssGenerator.context = {
        site_name: this.appName,
    };

    // HTML
    if(this.appType === 'typeSimpleWebApp') {
        this.template("simple-web-app/_index.html", this.appName + "/app/index.html", smacssGenerator.context);
    }
    else if(this.appType === 'typeFullPackWebApp') {
        this.template("full-pack-web-app/_index.html", this.appName + "/app/index.html", smacssGenerator.context);
    }
    else if(this.appType === 'typeAngularApp') {
        this.template("angular-app/_index.html", this.appName + "/app/index.html", smacssGenerator.context);
    }

    // Partial File Include
    if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
        this.template("partials/_header.html", this.appName + "/app/partials/_header.html", smacssGenerator.context);
        this.template("partials/_footer.html", this.appName + "/app/partials/_footer.html", smacssGenerator.context);
    }

    // CSS
    this.copy("_master.css", this.appName + "/app/css/master.css");

    // SMACSS - SCSS Structure
    // TODO: Update structure based on ticket #7
    this.copy("scss/_master.scss", this.appName + "/app/scss/master.scss");
    this.copy("scss/_base.scss", this.appName + "/app/scss/base.scss");
    this.copy("scss/_layout.scss", this.appName + "/app/scss/layout.scss");
    this.copy("scss/_reset.scss", this.appName + "/app/scss/reset.scss");
    this.copy("scss/_variables.scss", this.appName + "/app/scss/variables.scss");
    this.copy("scss/_mixins.scss", this.appName + "/app/scss/mixins.scss");
    this.copy("scss/_module.scss", this.appName + "/app/scss/modules/module.scss");
    this.copy("scss/_page_landing.scss", this.appName + "/app/scss/pages/page-landing.scss");

    if (this.appType === 'typeAngularApp') {
        this.template("js/_angular_application.js", this.appName + "/app/js/application.js", smacssGenerator.context);
    }
    else {
        this.copy("js/_application.js", this.appName + "/app/js/application.js");
    }
};

smacssGenerator.prototype.projectfiles = function projectfiles() {
    if(this.appType === 'typeSimpleWebApp') {
        this.template("simple-web-app/_gulpfile.js", this.appName + "/gulpfile.js", smacssGenerator.context);
        this.template("simple-web-app/_package.json", this.appName + "/package.json", smacssGenerator.context);
    }
    else {
        this.template("_gulpfile.js", this.appName + "/gulpfile.js", smacssGenerator.context);
        this.template("_package.json", this.appName + "/package.json", smacssGenerator.context);
        this.template("root/_jshintrc", this.appName + "/.jshintrc", smacssGenerator.context);
    }

    // Root Files
    this.copy("root/_gitignore", this.appName + "/.gitignore");
    this.copy("root/_gitattributes", this.appName + "/.gitattributes");
    this.copy("root/_robots.txt", this.appName + "/robots.txt");
    this.copy("root/_favicon.ico", this.appName + "/app/favicon.ico");
};

smacssGenerator.prototype.injectDependencies = function injectDependencies() {
    // Bower is supported only in full & angular app types
    if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
        var bower = {
            name: this.appName,
            private: true,
            dependencies: {}
        };
        this.copy('root/_bowerrc', this.appName + '/.bowerrc');

        if(this.appType === 'typeFullPackWebApp') {
            this.template('root/_full_pack_bower.json', this.appName + '/bower.json');
        }
        else {
            this.template('root/_angular_bower.json', this.appName + '/bower.json');
        }
    }
};

smacssGenerator.prototype.install = function install() {
    // Installation context object
    var installContext = {};
    installContext.appPath = process.cwd() + "/"+ this.appName;

    // Assign context based on app types
    if(this.appType === 'typeSimpleWebApp') {
        installContext.helpCommand = 'npm install';
        installContext.includeNpm = true;
        installContext.includeBower = false;
    }
    else {
        installContext.helpCommand = 'npm install & bower install';
        installContext.includeNpm = true;
        installContext.includeBower = true;
    }

    // activating app directory for installation
    process.chdir(installContext.appPath);

    // Skip Install
    if (this.options['skip-install']) {
        this.log(chalk.gray('================================================================'));
        this.log(chalk.gray('Follow the instructions below'));

        if(this.appType === 'typeSimpleWebApp') {
            this.log(
              'Next Steps:' +
              '\n1) Now '+ chalk.yellow.bold('cd '+ this.appName +'') + ' into your project folder' +
              '\n2) Install dependencies by typing '+ chalk.yellow.bold(installContext.helpCommand) +
              '\n3) Run the server using: ' + chalk.yellow.bold('gulp')
            )
        }
        else if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
            this.log(
              'Next Steps:' +
              '\n1) Now '+ chalk.yellow.bold('cd '+ this.appName +'') + ' into your project folder' +
              '\n2) Install dependencies by typing '+ chalk.yellow.bold(installContext.helpCommand) +
              '\n3) Run the server using: ' + chalk.yellow.bold('gulp')
            );
        }
    }
    else {
        this.log(chalk.gray('================================================================'));
        this.log(chalk.gray('Installing Dependencies, please wait...'));

        this.on('end', function () {
            this.installDependencies({
                bower: installContext.includeBower,
                npm: installContext.includeNpm,
                callback: function () {
                    this.emit('dependenciesInstalled');
                }.bind(this)
            });
        });

        this.on('dependenciesInstalled', function() {
            this.log(chalk.gray('================================================================'));
            this.log(chalk.gray('Dependencies Installed, please wait we start the server...'));

            shell.cd(installContext.appPath);
            shell.exec('gulp'); // trigger the server using gulp command
        });
    }
};

smacssGenerator.prototype.helper = function helper() {
    //this.log('App Helper functions and methods');
};

smacssGenerator.prototype.errorHanding = function errorHanding() {
    //this.log('Something has gone wrong! Handle errors in this section');
};

smacssGenerator.prototype.paths = function paths() {
    //this.log('Path Handling');
};

module.exports = smacssGenerator;
<commit_msg>CLI formatting updates<commit_after>'use strict';
var yeoman = require('yeoman-generator'),
    fs = require('fs'),
    util = require('util'),
    path = require('path'),
    yosay = require('yosay'),
    chalk = require('chalk'),
    shell = require('shelljs');

var smacssGenerator = yeoman.generators.Base.extend({
    constructor: function () {
        // note: arguments and options should be defined in the constructor.
        yeoman.generators.Base.apply(this, arguments);

        this.option('app-suffix', {
            desc: 'Allow a custom suffix to be added to the module name',
            type: String,
            required: 'false'
        });
        this.env.options['app-suffix'] = this.options['app-suffix'];

        this.option('skip-welcome-message', {
            desc: 'Skips the welcome message',
            type: Boolean
        });

        this.option('skip-install', {
            desc: 'Skips the installation of dependencies',
            type: Boolean
        });

        this.option('skip-install-message', {
            desc: 'Skips the message after the installation of dependencies',
            type: Boolean
        });

        // This method adds support for a `--coffee` flag
        this.option('coffee');
        // And you can then access it later on this way; e.g.
        this.scriptSuffix = (this.options.coffee ? ".coffee": ".js");
    },
});

smacssGenerator.prototype.initializing = function initializing() {
    this.pkg = require('../package.json');
};

smacssGenerator.prototype.welcome = function welcome() {
    if (!this.options['skip-welcome-message']) {
        this.log(yosay('Yo! Welcome to SMACSS'));
        this.log(chalk.yellow('┌──────────────────────────────────────────────────────────────┐'));
        this.log(chalk.yellow('| Answer simple questions to kick start your project           |'));
        this.log(chalk.yellow('└──────────────────────────────────────────────────────────────┘'));
    }
};

smacssGenerator.prototype.askAppType = function askAppType() {
    var done = this.async();

    var prompts = [{
        name: 'appName',
        message: 'What would you like to name your app/site?',
        default: process.cwd().split(path.sep).pop()
        },{
        name: 'appType',
        message: 'Kind of app/site you are trying to build?',
        type: 'list',
        choices:[{
            name: 'Simple Web App',
            value: 'typeSimpleWebApp',
            checked: false
        },{
            name: 'Full Pack Web App',
            value: 'typeFullPackWebApp',
            checked: false
        },{
            name: 'Angular App',
            value: 'typeAngularApp',
            checked: false
        }],
        default: 1
    }];
    this.prompt(prompts, function (answers) {
        var type = answers.type;

        this.appName = this._.camelize(this._.slugify(this._.humanize(answers.appName)));
        this.appType = answers.appType;

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

smacssGenerator.prototype.askAppFeatures = function askAppFeatures() {
    if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
        var done = this.async();
        var prompts = [{
            name: 'appFeatures',
            message: 'How about some additional features',
            type: 'checkbox',
            choices:[{
                name: ' jQuery',
                value: 'includeQuery',
                checked: true
            },{
                name: ' Modernizr',
                value: 'includeModernizr',
                checked: false
            }]
        }];
        this.prompt(prompts, function (answers) {
            var appFeatures = answers.appFeatures;

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

            this.includeQuery = hasFeature('includeQuery');
            this.includeModernizr = hasFeature('includeModernizr');

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

smacssGenerator.prototype.askAngularModules = function askAngularModules() {
    if(this.appType === 'typeAngularApp') {
        var done = this.async();
        var prompts = [{
            name: 'angularModules',
            message: 'How about including some angular modules',
            type: 'checkbox',
            choices:[{
                name: ' Angular Route',
                value: 'includeRouteModule',
                checked: true
            },{
                name: ' Angular Resource',
                value: 'includeResourceModule',
                checked: false
            },{
                name: ' Angular Sanitize',
                value: 'includeSanitizeModule',
                checked: false
            },{
                name: ' Angular Animate',
                value: 'includeAnimateModule',
                checked: false
            }]
        }];
        this.prompt(prompts, function (answers) {

            var hasModule = function (mod) {
                return answers.angularModules.indexOf(mod) !== -1;
            };

            this.includeRouteModule = hasModule('includeRouteModule');
            this.includeResourceModule = hasModule('includeResourceModule');
            this.includeSanitizeModule = hasModule('includeSanitizeModule');
            this.includeAnimateModule = hasModule('includeAnimateModule');

            var angMods = [];

            if (this.includeRouteModule) {
              angMods.push("'ngRoute'");
            }
            if (this.includeResourceModule) {
              angMods.push("'ngResource'");
            }
            if (this.includeSanitizeModule) {
              angMods.push("'ngSanitize'");
            }
            if (this.includeAnimateModule) {
              angMods.push("'ngAnimate'");
            }

            if (angMods.length) {
              this.env.options.angularDeps = '\n    ' + angMods.join(',\n    ') + '\n  ';
            }

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

smacssGenerator.prototype.scaffoldFolders = function scaffoldFolders() {
    this.log(chalk.gray('────────────────────────────────────────────────────────────────'));
    this.log(chalk.yellow('Creating the project structure'));

    // Common Scaffolding for all projets
    this.mkdir(this.appName + '/app');
    this.mkdir(this.appName + '/app/css');
    this.mkdir(this.appName + '/app/scss');
    this.mkdir(this.appName + '/app/js');
    this.mkdir(this.appName + '/app/images');
    this.mkdir(this.appName + '/app/fonts');

    if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
        this.mkdir(this.appName + '/app/partials');
        this.mkdir(this.appName + '/build');
    }
};

smacssGenerator.prototype.copyMainFiles = function copyMainFiles() {
    // Underscore templating context to replace placeholders
    smacssGenerator.context = {
        site_name: this.appName,
    };

    // HTML
    if(this.appType === 'typeSimpleWebApp') {
        this.template("simple-web-app/_index.html", this.appName + "/app/index.html", smacssGenerator.context);
    }
    else if(this.appType === 'typeFullPackWebApp') {
        this.template("full-pack-web-app/_index.html", this.appName + "/app/index.html", smacssGenerator.context);
    }
    else if(this.appType === 'typeAngularApp') {
        this.template("angular-app/_index.html", this.appName + "/app/index.html", smacssGenerator.context);
    }

    // Partial File Include
    if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
        this.template("partials/_header.html", this.appName + "/app/partials/_header.html", smacssGenerator.context);
        this.template("partials/_footer.html", this.appName + "/app/partials/_footer.html", smacssGenerator.context);
    }

    // CSS
    this.copy("_master.css", this.appName + "/app/css/master.css");

    // SMACSS - SCSS Structure
    // TODO: Update structure based on ticket #7
    this.copy("scss/_master.scss", this.appName + "/app/scss/master.scss");
    this.copy("scss/_base.scss", this.appName + "/app/scss/base.scss");
    this.copy("scss/_layout.scss", this.appName + "/app/scss/layout.scss");
    this.copy("scss/_reset.scss", this.appName + "/app/scss/reset.scss");
    this.copy("scss/_variables.scss", this.appName + "/app/scss/variables.scss");
    this.copy("scss/_mixins.scss", this.appName + "/app/scss/mixins.scss");
    this.copy("scss/_module.scss", this.appName + "/app/scss/modules/module.scss");
    this.copy("scss/_page_landing.scss", this.appName + "/app/scss/pages/page-landing.scss");

    if (this.appType === 'typeAngularApp') {
        this.template("js/_angular_application.js", this.appName + "/app/js/application.js", smacssGenerator.context);
    }
    else {
        this.copy("js/_application.js", this.appName + "/app/js/application.js");
    }
};

smacssGenerator.prototype.projectfiles = function projectfiles() {
    if(this.appType === 'typeSimpleWebApp') {
        this.template("simple-web-app/_gulpfile.js", this.appName + "/gulpfile.js", smacssGenerator.context);
        this.template("simple-web-app/_package.json", this.appName + "/package.json", smacssGenerator.context);
    }
    else {
        this.template("_gulpfile.js", this.appName + "/gulpfile.js", smacssGenerator.context);
        this.template("_package.json", this.appName + "/package.json", smacssGenerator.context);
        this.template("root/_jshintrc", this.appName + "/.jshintrc", smacssGenerator.context);
    }

    // Root Files
    this.copy("root/_gitignore", this.appName + "/.gitignore");
    this.copy("root/_gitattributes", this.appName + "/.gitattributes");
    this.copy("root/_robots.txt", this.appName + "/robots.txt");
    this.copy("root/_favicon.ico", this.appName + "/app/favicon.ico");
};

smacssGenerator.prototype.injectDependencies = function injectDependencies() {
    // Bower is supported only in full & angular app types
    if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
        var bower = {
            name: this.appName,
            private: true,
            dependencies: {}
        };
        this.copy('root/_bowerrc', this.appName + '/.bowerrc');

        if(this.appType === 'typeFullPackWebApp') {
            this.template('root/_full_pack_bower.json', this.appName + '/bower.json');
        }
        else {
            this.template('root/_angular_bower.json', this.appName + '/bower.json');
        }
    }
};

smacssGenerator.prototype.install = function install() {
    // Installation context object
    var installContext = {};
    installContext.appPath = process.cwd() + "/"+ this.appName;

    // Assign context based on app types
    if(this.appType === 'typeSimpleWebApp') {
        installContext.helpCommand = 'npm install';
        installContext.includeNpm = true;
        installContext.includeBower = false;
    }
    else {
        installContext.helpCommand = 'npm install & bower install';
        installContext.includeNpm = true;
        installContext.includeBower = true;
    }

    // activating app directory for installation
    process.chdir(installContext.appPath);

    // Skip Install
    if (this.options['skip-install']) {
        this.log(chalk.gray('────────────────────────────────────────────────────────────────'));
        this.log(chalk.gray('Follow the instructions below'));

        if(this.appType === 'typeSimpleWebApp') {
            this.log(
              'Next Steps:' +
              '\n1) Now '+ chalk.yellow.bold('cd '+ this.appName +'') + ' into your project folder' +
              '\n2) Install dependencies by typing '+ chalk.yellow.bold(installContext.helpCommand) +
              '\n3) Run the server using: ' + chalk.yellow.bold('gulp')
            )
        }
        else if(this.appType === 'typeFullPackWebApp' || this.appType === 'typeAngularApp') {
            this.log(
              'Next Steps:' +
              '\n1) Now '+ chalk.yellow.bold('cd '+ this.appName +'') + ' into your project folder' +
              '\n2) Install dependencies by typing '+ chalk.yellow.bold(installContext.helpCommand) +
              '\n3) Run the server using: ' + chalk.yellow.bold('gulp')
            );
        }
    }
    else {
        this.log(chalk.gray('Project structure created successfully!'));
        this.log(chalk.gray('────────────────────────────────────────────────────────────────'));
        this.log(chalk.yellow('Installing Dependencies, please wait...'));

        this.on('end', function () {
            this.installDependencies({
                bower: installContext.includeBower,
                npm: installContext.includeNpm,
                callback: function () {
                    this.emit('dependenciesInstalled');
                }.bind(this)
            });
        });

        this.on('dependenciesInstalled', function() {
             this.log(chalk.gray('Dependencies installed successfully!'));
            this.log(chalk.gray('────────────────────────────────────────────────────────────────'));
            this.log(chalk.yellow('Please wait while we start the server...'));

            shell.cd(installContext.appPath);
            shell.exec('gulp'); // trigger the server using gulp command
        });
    }
};

smacssGenerator.prototype.helper = function helper() {
    //this.log('App Helper functions and methods');
};

smacssGenerator.prototype.errorHanding = function errorHanding() {
    //this.log('Something has gone wrong! Handle errors in this section');
};

smacssGenerator.prototype.paths = function paths() {
    //this.log('Path Handling');
};

module.exports = smacssGenerator;
<|endoftext|>


<commit_before>'use strict'

var normalizeUrl = require('normalize-url'),
  humanizeUrl = require('humanize-url'),
  yeoman = require('yeoman-generator'),
  camelCase = require('lodash/string/camelCase'),
  kebabCase = require('lodash/string/kebabCase')

module.exports = yeoman.generators.Base.extend({
  init: function () {
    var done = this.async()

    this.prompt([{
      name: 'moduleName',
      message: 'What do you want to name your module?',
      default: this.appname.replace(/\s/g, '-'),
      filter: kebabCase
    }, {
      name: 'githubUsername',
      message: 'What is your GitHub username?',
      store: true,
      validate: function (val) {
        return val.length > 0 ? true : 'You have to provide a username'
      }
    }, {
      name: 'website',
      message: 'What is the URL of your website?',
      store: true,
      validate: function (val) {
        return val.length > 0 ? true : 'You have to provide a website URL'
      },
      filter: normalizeUrl
    }], function (props) {
      this.moduleName = props.moduleName
      this.camelModuleName = camelCase(props.moduleName)
      this.githubUsername = props.githubUsername
      this.name = this.user.git.name()
      this.email = this.user.git.email()
      this.website = props.website
      this.humanizedWebsite = humanizeUrl(this.website)

      this.template('editorconfig', '.editorconfig')
      this.template('gitignore', '.gitignore')
      this.template('travis.yml', '.travis.yml')
      this.template('src/index.js')
      this.template('test/test.js')
      this.template('LICENSE')
      this.template('README.md')
      // needed so npm doesn't try to use it and fail
      this.template('_package.json', 'package.json')

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

  install: function () {
    this.npmInstall()
  }
})
<commit_msg>Hopefully fix tests on CI<commit_after>'use strict'

var normalizeUrl = require('normalize-url'),
  humanizeUrl = require('humanize-url'),
  yeoman = require('yeoman-generator'),
  camelCase = require('lodash/string/camelCase'),
  kebabCase = require('lodash/string/kebabCase')

module.exports = yeoman.generators.Base.extend({
  init: function () {
    var done = this.async()

    this.prompt([{
      name: 'moduleName',
      message: 'What do you want to name your module?',
      default: this.appname.replace(/\s/g, '-'),
      filter: function (val) {
        return kebabCase(val)
      }
    }, {
      name: 'githubUsername',
      message: 'What is your GitHub username?',
      store: true,
      validate: function (val) {
        return val.length > 0 ? true : 'You have to provide a username'
      }
    }, {
      name: 'website',
      message: 'What is the URL of your website?',
      store: true,
      validate: function (val) {
        return val.length > 0 ? true : 'You have to provide a website URL'
      },
      filter: function (val) {
        return normalizeUrl(val)
      }
    }], function (props) {
      this.moduleName = props.moduleName
      this.camelModuleName = camelCase(props.moduleName)
      this.githubUsername = props.githubUsername
      this.name = this.user.git.name()
      this.email = this.user.git.email()
      this.website = props.website
      this.humanizedWebsite = humanizeUrl(this.website)

      this.template('editorconfig', '.editorconfig')
      this.template('gitignore', '.gitignore')
      this.template('travis.yml', '.travis.yml')
      this.template('src/index.js')
      this.template('test/test.js')
      this.template('LICENSE')
      this.template('README.md')
      // needed so npm doesn't try to use it and fail
      this.template('_package.json', 'package.json')

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

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


<commit_before><commit_msg>Setup Babel<commit_after><|endoftext|>


<commit_before>'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var GitHubApi = require('github');
var cordova = require('cordova');
var Q = require('q');

var githubOptions = {
  version: '3.0.0'
};
var github = new GitHubApi(githubOptions);

var githubUserInfo = function (name, cb) {
  github.user.getFrom({
    user: name
  }, function (err, res) {
    if (err) {
      throw err;
    }
    cb(JSON.parse(JSON.stringify(res)));
  });
};

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

  this.on('end', function () {
    this.installDependencies({
        npm: true,
        bower: false
    });
  });

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

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

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

  var prompts = [{
    type:'input',
    name:'githubUser',
    message:'What is your github username?',
    default:null
  },{
    type:'input',
    name:'appName',
    message:'What is the name of the mobile App?',
    default: path.basename(process.cwd())
  },{
    type:'input',
    name:'appId',
    message:'What is the ID of the mobile App (reverse-domain-style package name, like com.foo.myapp)?',
    validate: function (input) {
        return input.match(/(^[a-z0-9]+\.[a-z0-9]+\.[a-z0-9]+$)/g) ? true : "Need an Id like com.foo.myapp!";
    }
  },
  {
    type:'input',
    name:'appDescription',
    message:'Can you give a description of your mobile App?',
    default: ""
  },
  {
    type:'input',
    name:'dependencies',
    message:'Do you want to add dependencies? (sepatate modules with comma)',
    default: ""
  },
  {
    type:'checkbox',
    name:'targets',
    choices:[{
        name:'ios',
        value:'ios'
    },{
        name:'Android',
        value:'android'
    }],
    message:'Which targets do you want to support ?',
    validate: function (input) {
        return input instanceof Array && input.length > 0 ? true : "One minimum target is required";
    }
  }];

  this.prompt(prompts, function (props) {
    this.githubUser = props.githubUser;
    this.appName = props.appName;
    this.appId = props.appId;
    this.appDescription = props.appDescription;
    this.dependencies = props.dependencies.split(',')
        .filter(function (dep) {
            return dep.length > 0;
        });
    this.targets = props.targets;
    cb();
  }.bind(this));
};

ModuleGenerator.prototype.userInfo = function userInfo() {
  var done = this.async();

  githubUserInfo(this.githubUser, function (res) {
    this.realname = res.name;
    this.email = res.email;
    this.githubUrl = res.html_url;
    done();
  }.bind(this));
};

ModuleGenerator.prototype.cordova = function app() {
  var cb = this.async();

  cordova.create('.', this.appId, this.appName, function () {
    this.log.write().ok('Raw app created');
    cb();
  }.bind(this));
};

ModuleGenerator.prototype.target = function app() {
  var cb = this.async();

  cordova.platform('add', this.targets, function () {
    this.log.ok('Targets added: ' + this.targets.concat()).write();
    cb();
  }.bind(this));
};

ModuleGenerator.prototype.app = function app() {
  this.mkdir('app');
  this.template('app/_index.js', 'app/index.js');
  this.template('_package.json', 'package.json');
  this.template('_README.md', 'README.md');
  this.template('_LICENSE', 'LICENSE');
  this.copy('gitignore', '.gitignore');
};
<commit_msg>add cordova official plugins<commit_after>'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var GitHubApi = require('github');
var cordova = require('cordova');
var Q = require('q');

var githubOptions = {
  version: '3.0.0'
};
var github = new GitHubApi(githubOptions);

var githubUserInfo = function (name, cb) {
  github.user.getFrom({
    user: name
  }, function (err, res) {
    if (err) {
      throw err;
    }
    cb(JSON.parse(JSON.stringify(res)));
  });
};

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

  this.on('end', function () {
    this.installDependencies({
        npm: true,
        bower: false
    });
  });

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

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

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

  var prompts = [{
    type:'input',
    name:'githubUser',
    message:'What is your github username?',
    default:null
  },{
    type:'input',
    name:'appName',
    message:'What is the name of the mobile App?',
    default: path.basename(process.cwd())
  },{
    type:'input',
    name:'appId',
    message:'What is the ID of the mobile App (reverse-domain-style package name, like com.foo.myapp)?',
    validate: function (input) {
        return input.match(/(^[a-z0-9]+\.[a-z0-9]+\.[a-z0-9]+$)/g) ? true : "Need an Id like com.foo.myapp!";
    }
  },
  {
    type:'input',
    name:'appDescription',
    message:'Can you give a description of your mobile App?',
    default: ""
  },
  {
    type:'input',
    name:'dependencies',
    message:'Do you want to add dependencies? (sepatate modules with comma)',
    default: ""
  },
  {
    type:'checkbox',
    name:'targets',
    choices:[{
        name:'ios',
        value:'ios'
    },{
        name:'Android',
        value:'android'
    }],
    message:'Which targets do you want to support ?',
    validate: function (input) {
        return input instanceof Array && input.length > 0 ? true : "One minimum target is required";
    }
  },
  {
    type:'checkbox',
    name:'plugins',
    choices:[{
        name:'Battery Status',
        value:'org.apache.cordova.battery-status'
    },{
        name:'Camera',
        value:'org.apache.cordova.camera'
    },{
        name:'Console',
        value:'org.apache.cordova.console'
    },{
        name:'Contacts',
        value:'org.apache.cordova.contacts'
    },{
        name:'Device',
        value:'org.apache.cordova.device'
    },{
        name:'Device Motion',
        value:'org.apache.cordova.device-motion'
    },{
        name:'Device Orientation',
        value:'org.apache.cordova.device-orientation'
    },{
        name:'Dialogs',
        value:'org.apache.cordova.dialogs'
    },{
        name:'File',
        value:'org.apache.cordova.file'
    },{
        name:'File Transfer',
        value:'org.apache.cordova.file-transfer'
    },{
        name:'Geolocation',
        value:'org.apache.cordova.geolocation'
    },{
        name:'Globalization',
        value:'org.apache.cordova.globalization'
    },{
        name:'In App Browser',
        value:'org.apache.cordova.inappbrowser'
    },{
        name:'Media',
        value:'org.apache.cordova.media'
    },{
        name:'Media Capture',
        value:'org.apache.cordova.media-capture'
    },{
        name:'Network Information',
        value:'org.apache.cordova.network-information'
    },{
        name:'Splashscreen',
        value:'org.apache.cordova.splashscreen'
    },{
        name:'Vibration',
        value:'org.apache.cordova.vibration'
    }],
    message:'With which Cordova official plugins to you want to start?'
  }];

  this.prompt(prompts, function (props) {
    this.githubUser = props.githubUser;
    this.appName = props.appName;
    this.appId = props.appId;
    this.appDescription = props.appDescription;
    this.dependencies = props.dependencies.split(',')
        .filter(function (dep) {
            return dep.length > 0;
        });
    this.targets = props.targets;
    this.plugins = props.plugins;
    cb();
  }.bind(this));
};

ModuleGenerator.prototype.userInfo = function userInfo() {
  var done = this.async();

  githubUserInfo(this.githubUser, function (res) {
    this.realname = res.name;
    this.email = res.email;
    this.githubUrl = res.html_url;
    done();
  }.bind(this));
};

ModuleGenerator.prototype.cordova = function app() {
  var cb = this.async();

  cordova.create('.', this.appId, this.appName, function () {
    this.log.write().ok('Raw app created');
    cb();
  }.bind(this));
};

ModuleGenerator.prototype.target = function app() {
  var cb = this.async();

  cordova.platform('add', this.targets, function () {
    this.log.ok('Targets added: ' + this.targets.join(', ')).write();
    cb();
  }.bind(this));
};

ModuleGenerator.prototype.cordovaplugins = function app() {
  var cb = this.async();

  cordova.plugins('add', this.plugins, function () {
    this.log.ok('Plugins added: ' + this.plugins.join(', ')).write();
    cb();
  }.bind(this));
};

ModuleGenerator.prototype.app = function app() {
  this.mkdir('app');
  this.template('app/_index.js', 'app/index.js');
  this.template('_package.json', 'package.json');
  this.template('_README.md', 'README.md');
  this.template('_LICENSE', 'LICENSE');
  this.copy('gitignore', '.gitignore');
};
<|endoftext|>