<commit_before>/*jshint globalstrict: false*/
"use strict";
/*jshint globalstrict: true*/
var util = require("util");
var path = require("path");
var yeoman = require("yeoman-generator");
var _ = require("underscore.string");

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

	this.on("end", function () {
		var self = this;
		this.installDependencies({
			skipInstall: options["skip-install"],
			callback: function () {
				console.log("Dependencies have been installed, point your browser to "+self.package+"/samples/"+self.widgetName+".html to run a simple sample showing your element");
			}
		});
	});

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

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

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

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

	// TODO:  which themes?, extend a deliteful widget?  Grunt

	this.prompt([
		{
			name: "package",
			message: "What is the name of your delite widget element package?",
			default: this.appname
		},
		{
			name: "elementName",
			message: "What do you want to call your delite widget element?",
			default: this.appname+"-element"
		},
		{
			type: "confirm",
			name: "templated",
			message: "Would you like your delite element to be built on a template?",
			default: true
		},
		{
			type: "confirm",
			name: "i18n",
			message: "Will your delite element require string internationalization?",
			default: true
		},
		{
			type: "confirm",
			name: "pointer",
			message: "Will your delite element require pointer management?",
			default: false
		}
	], function (props) {
		this.package = props.package;
		this.elementName = _.slugify(props.elementName);
		this.widgetName = this.elementName;
		if (this.elementName.indexOf("-") === 1) {
			// we have a single letter prefix like d-component-name
			// we strip it for the widget name
			// otherwise we keep it
			this.widgetName = this.widgetName.substring(2);
		}
		this.widgetName = _.classify(this.widgetName);
		this.templated = props.templated;
		this.i18n = props.i18n;
		this.pointer = props.pointer;
		cb();
	}.bind(this));
};

DeliteElementGenerator.prototype.generateElement = function app() {
	this.packge = "";
	this.mkdir("tests");
	this.mkdir("docs");
	this.mkdir(this.widgetName + "/themes/bootstrap");

	// this.template("Gruntfile.js", "Gruntfile.js");
	if (this.templated) {
		this.template("_Element.html", this.widgetName + "/" + this.widgetName + ".html");
		this.template("_Element.js.templated", this.widgetName + ".js");
	} else {
		this.template("_Element.js.hardcoded", this.widgetName + ".js");
	}
	this.template("_package.json", "package.json");
	this.template("_bower.json", "bower.json");
	this.template("_Element.css", this.widgetName + "/themes/bootstrap/" + this.widgetName + ".css");
	//this.template("_Test.js", "tests/" + this.widgetName + ".js");
	this.template("_Sample.html", "samples/" + this.widgetName + ".html");
	if (this.i18n) {
//		this.mkdir(this.widgetName + "/nls/en");
		this.mkdir(this.widgetName + "/nls/fr");
		this.copy("messages.js", this.widgetName + "/nls/messages.js");
		this.copy("messages.fr.js", this.widgetName + "/nls/fr/messages.js");

	}
};

DeliteElementGenerator.prototype.projectfiles = function projectfiles() {
	this.copy("jshintrc", ".jshintrc");
};
<commit_msg>force element name to contain a dash<commit_after>/*jshint globalstrict: false*/
"use strict";
/*jshint globalstrict: true*/
var util = require("util");
var path = require("path");
var yeoman = require("yeoman-generator");
var _ = require("underscore.string");

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

	this.on("end", function () {
		var self = this;
		this.installDependencies({
			skipInstall: options["skip-install"],
			callback: function () {
				console.log("Dependencies have been installed, point your browser to "+self.package+"/samples/"+self.widgetName+".html to run a simple sample showing your element");
			}
		});
	});

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

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

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

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

	// TODO:  which themes?, extend a deliteful widget?  Grunt

	this.prompt([
		{
			name: "package",
			message: "What is the name of your delite widget element package?",
			default: this.appname
		},
		{
			name: "elementName",
			message: "What do you want to call your delite widget element (must contain a dash)?",
			default: this.appname+"-element",
			validate: function (value) {
				if (value.indexOf("-") !== -1) {
					return true;
				} else {
					return "element name must contain a dash (-)"
				}
			}
		},
		{
			type: "confirm",
			name: "templated",
			message: "Would you like your delite element to be built on a template?",
			default: true
		},
		{
			type: "confirm",
			name: "i18n",
			message: "Will your delite element require string internationalization?",
			default: true
		},
		{
			type: "confirm",
			name: "pointer",
			message: "Will your delite element require pointer management?",
			default: false
		}
	], function (props) {
		this.package = props.package;
		this.elementName = _.slugify(props.elementName);
		this.widgetName = this.elementName;
		if (this.elementName.indexOf("-") === 1) {
			// we have a single letter prefix like d-component-name
			// we strip it for the widget name
			// otherwise we keep it
			this.widgetName = this.widgetName.substring(2);
		}
		this.widgetName = _.classify(this.widgetName);
		this.templated = props.templated;
		this.i18n = props.i18n;
		this.pointer = props.pointer;
		cb();
	}.bind(this));
};

DeliteElementGenerator.prototype.generateElement = function app() {
	this.packge = "";
	this.mkdir("tests");
	this.mkdir("docs");
	this.mkdir(this.widgetName + "/themes/bootstrap");

	// this.template("Gruntfile.js", "Gruntfile.js");
	if (this.templated) {
		this.template("_Element.html", this.widgetName + "/" + this.widgetName + ".html");
		this.template("_Element.js.templated", this.widgetName + ".js");
	} else {
		this.template("_Element.js.hardcoded", this.widgetName + ".js");
	}
	this.template("_package.json", "package.json");
	this.template("_bower.json", "bower.json");
	this.template("_Element.css", this.widgetName + "/themes/bootstrap/" + this.widgetName + ".css");
	//this.template("_Test.js", "tests/" + this.widgetName + ".js");
	this.template("_Sample.html", "samples/" + this.widgetName + ".html");
	if (this.i18n) {
//		this.mkdir(this.widgetName + "/nls/en");
		this.mkdir(this.widgetName + "/nls/fr");
		this.copy("messages.js", this.widgetName + "/nls/messages.js");
		this.copy("messages.fr.js", this.widgetName + "/nls/fr/messages.js");

	}
};

DeliteElementGenerator.prototype.projectfiles = function projectfiles() {
	this.copy("jshintrc", ".jshintrc");
};
<|endoftext|>


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

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

    this.on('end', function () {
        this.installDependencies({ skipInstall: true });
    });

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

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

AngularPhonegapSeedGenerator.prototype.greet = function greet() {
    // have Yeoman greet the user.
    console.log(this.yeoman);
};

AngularPhonegapSeedGenerator.prototype.phonegapCheck = function phonegapCheck() {
    // check this dir contains www
    var list = fs.readdirSync(process.cwd());

    // console.log("Angular-Phonegap-Seed");

    if (list.indexOf('www') === -1) {
        console.log('This generator must be run from the root of a PhoneGap project, but we don\'t seem to be in one.');
        console.log('You may stop running this generator with Ctrl+C in order to navigate to a PhoneGap project and try again.');
    }
};

AngularPhonegapSeedGenerator.prototype.askProjectName = function askProjectName() {
    // prompt for project name
    var cb = this.async(),
        prompts = [{
            type: 'input',
            name: 'appName',
            message: 'Please, enter a name for your Angular app.',
            default: 'myApp'
        }];

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

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

// AngularPhonegapSeedGenerator.prototype.app = function app() {
//     // dependencies
//     this.copy('_package.json', 'package.json');
//     this.copy('_bower.json', 'bower.json');
// };

AngularPhonegapSeedGenerator.prototype.makeDirs = function makeDirs() {
    // create lib and partials directories
    this.mkdir('www/lib/angular');
    this.mkdir('www/partials');
};

AngularPhonegapSeedGenerator.prototype.projectFiles = function projectFiles() {
    // copy project files
    this.template('_index.html', 'www/index.html');
    this.template('js/_app.js', 'www/js/app.js');
    this.template('js/_controllers.js', 'www/js/controllers.js');
    this.template('js/_services.js', 'www/js/services.js');

    this.copy('partials/main.html', 'www/partials/main.html');
    this.copy('partials/view.html', 'www/partials/view.html');
};

AngularPhonegapSeedGenerator.prototype.getAngularUnstable = function getAngularUnstable() {
    var cb = this.async();

    this.fetch('http://code.angularjs.org/1.2.0-rc.3/angular.js',
                'www/lib/angular/angular.js',
                function (err) {
                    if (err) {
                      console.log(err);
                    }

                    cb();
                });
};

AngularPhonegapSeedGenerator.prototype.getAngularRoute = function getAngularRoute() {
    var cb = this.async();

    this.fetch('http://code.angularjs.org/1.2.0-rc.3/angular-route.js',
                'www/lib/angular/angular-route.js',
                function (err) {
                    if (err) {
                        console.log(err);
                    }

                    cb();
                });
};

// AngularPhonegapSeedGenerator.prototype.runtime = function runtime() {
//     this.copy('bowerrc', '.bowerrc');
// };
<commit_msg>now pulls nightlies<commit_after>'use strict';
var util = require('util'),
    path = require('path'),
    fs = require('fs'),
    yeoman = require('yeoman-generator'),
    AngularPhonegapSeedGenerator;

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

    this.on('end', function () {
        this.installDependencies({ skipInstall: true });
    });

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

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

AngularPhonegapSeedGenerator.prototype.greet = function greet() {
    // have Yeoman greet the user.
    console.log(this.yeoman);
};

AngularPhonegapSeedGenerator.prototype.phonegapCheck = function phonegapCheck() {
    // check this dir contains www
    var list = fs.readdirSync(process.cwd());

    // console.log("Angular-Phonegap-Seed");

    if (list.indexOf('www') === -1) {
        console.log('This generator must be run from the root of a PhoneGap project, but we don\'t seem to be in one.');
        console.log('You may stop running this generator with Ctrl+C in order to navigate to a PhoneGap project and try again.');
    }
};

AngularPhonegapSeedGenerator.prototype.askProjectName = function askProjectName() {
    // prompt for project name
    var cb = this.async(),
        prompts = [{
            type: 'input',
            name: 'appName',
            message: 'Please, enter a name for your Angular app.',
            default: 'myApp'
        }];

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

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

// AngularPhonegapSeedGenerator.prototype.app = function app() {
//     // dependencies
//     this.copy('_package.json', 'package.json');
//     this.copy('_bower.json', 'bower.json');
// };

AngularPhonegapSeedGenerator.prototype.makeDirs = function makeDirs() {
    // create lib and partials directories
    this.mkdir('www/lib/angular');
    this.mkdir('www/partials');
};

AngularPhonegapSeedGenerator.prototype.projectFiles = function projectFiles() {
    // copy project files
    this.template('_index.html', 'www/index.html');
    this.template('js/_app.js', 'www/js/app.js');
    this.template('js/_controllers.js', 'www/js/controllers.js');
    this.template('js/_services.js', 'www/js/services.js');

    this.copy('partials/main.html', 'www/partials/main.html');
    this.copy('partials/view.html', 'www/partials/view.html');
};

AngularPhonegapSeedGenerator.prototype.getAngularUnstable = function getAngularUnstable() {
    var cb = this.async();

    this.fetch('http://ci.angularjs.org/job/angular.js-angular-master/lastSuccessfulBuild/artifact/build/angular.js',
                'www/lib/angular/angular.js',
                function (err) {
                    if (err) {
                      console.log(err);
                    }

                    cb();
                });
};

AngularPhonegapSeedGenerator.prototype.getAngularRoute = function getAngularRoute() {
    var cb = this.async();

    this.fetch('http://ci.angularjs.org/job/angular.js-angular-master/lastSuccessfulBuild/artifact/build/angular-route.js',
                'www/lib/angular/angular-route.js',
                function (err) {
                    if (err) {
                        console.log(err);
                    }

                    cb();
                });
};

// AngularPhonegapSeedGenerator.prototype.runtime = function runtime() {
//     this.copy('bowerrc', '.bowerrc');
// };
<|endoftext|>


<commit_before>'use strict';
var chalk = require('chalk')
  , genBase = require('../genBase')
  , mkdirp = require('mkdirp')
  , path = require('path')
  , utils = require('../utils')
  , yosay = require('yosay')
  , Generator;

Generator = module.exports = genBase.extend();

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

  this.log(yosay('Welcome to ngPoly!'));

  // ask for app name
  // get preferred langugaes
  this.prompt([
    {
      name: 'appName',
      message: 'What is the app\'s name?',
      validate: function (input) {
        // require an app name
        return !!input;
      }
    },
    {
      type: 'list',
      name: 'ngversion',
      message: 'Which version of Angular should be used?',
      default: '1.3.*',
      choices: [
        {
          name: '1.2.*',
          value: '1.2.*'
        },
        {
          name: '1.3.*',
          value: '1.3.*'
        }
      ]
    },
    {
      type: 'list',
      name: 'structure',
      message: 'Which structure should be used?',
      default: 'module-only',
      choices: [
        {
          name: ['app/',
                '├── module1/',
                '│   ├── module2/',
                '│   ├── module1.js',
                '│   └── module1-controller.js',
                '└── app.js'].join('\n'),
          value: 'module-only'
        },
        {
          name: ['app/',
                '├── module1/',
                '│   ├── controllers/',
                '│   │   └── module1-controller.js',
                '│   ├── module2/',
                '│   └── module1.js',
                '└── app.js'].join('\n'),
          value: 'module-type'
        }
      ]
    },
    {
      name: 'host',
      message: 'What host should the app run on?',
      default: 'localhost'
    },
    {
      name: 'port',
      message: 'Which port should the app run on?',
      default: 3000
    },
    {
      name: 'appDir',
      message: 'Which folder should the app be developed in?',
      default: 'app'
    },
    {
      type: 'list',
      name: 'markup',
      message: 'Which is the preferred markup language?',
      default: 'jade',
      choices: [
        {
          name: 'HAML',
          value: 'haml'
        },
        {
          name: 'HTML',
          value: 'html'
        },
        {
          name: 'Jade',
          value: 'jade'
        }
      ]
    },
    {
      type: 'list',
      name: 'appScript',
      message: 'Which is the preferred application scripting language?',
      default: 'js',
      choices: [
        {
          name: 'CoffeeScript',
          value: 'coffee'
        },
        {
          name: 'EcmaScript2015 (ES6) using Babel',
          value: 'es6'
        },
        {
          name: 'JavaScript (ES5)',
          value: 'js'
        },
        {
          name: 'TypeScript',
          value: 'ts'
        }
      ]
    },
    {
      type: 'confirm',
      name: 'controllerAs',
      message: 'Want to use Controller As syntax?',
      default: true
    },
    {
      type: 'confirm',
      name: 'skipController',
      message: 'By default, should the route generator create controllers?',
      default: true
    },
    {
      name: 'unitTestDir',
      message: 'Where should unit tests be saved?',
      default: 'app'
    },
    {
      type: 'list',
      name: 'testScript',
      message: 'Which is the preferred test scripting language?',
      default: 'js',
      choices: [
        {
          name: 'CoffeeScript',
          value: 'coffee'
        },
        {
          name: 'EcmaScript2015 (ES6) using Babel',
          value: 'es6'
        },
        {
          name: 'JavaScript (ES5)',
          value: 'js'
        },
        {
          name: 'TypeScript',
          value: 'ts'
        }
      ]
    },
    {
      type: 'list',
      name: 'testFramework',
      message: 'Which is the preferred unit testing framework?',
      default: 'jasmine',
      choices: [
        {
          name: 'Jasmine',
          value: 'jasmine'
        },
        {
          name: 'Mocha with Chai',
          value: 'mocha'
        }
      ]
    },
    {
      type: 'list',
      name: 'e2eTestFramework',
      message: 'Which is the preferred e2e testing framework?',
      default: 'jasmine',
      choices: [
        {
          name: 'Jasmine',
          value: 'jasmine'
        },
        {
          name: 'Mocha with Chai',
          value: 'mocha'
        }
      ]
    },
    {
      type: 'list',
      name: 'style',
      message: 'Which is the preferred style language?',
      default: 'less',
      choices: [
        {
          name: 'CSS',
          value: 'css'
        },
        {
          name: 'LESS',
          value: 'less'
        },
        {
          name: 'SCSS',
          value: 'scss'
        },
        {
          name: 'Stylus',
          value: 'styl'
        }
      ]
    },
    {
      type: 'confirm',
      name: 'polymer',
      message: 'Should Polymer support be enabled?',
      default: false
    },
    {
      type: 'list',
      name: 'framework',
      message: 'Should a framework be setup?',
      choices: function (answers) {
        var choices = [
          {
            name: 'none',
            value: 'none'
          },
          {
            name: 'Bootstrap with AngularStrap',
            value: 'angularstrap'
          },
          {
            name: 'Foundation with Angular Foundation',
            value: 'foundation'
          }
        ];

        if (answers.ngversion === '1.2.*') {
          choices.splice(2, 0, {
            name: 'Bootstrap with UI Bootstrap',
            value: 'uibootstrap'
          });
        } else {
          choices.splice(1, 0, {
            name: 'Angular Material',
            value: 'material'
          });
        }

        return choices;
      }

    },
    {
      type: 'confirm',
      name: 'ngRoute',
      message: 'Should ngRoute be used instead of UI Router?',
      default: false
    },
    {
      type: 'checkbox',
      name: 'bower',
      message: 'Which additional Bower components should be installed?',
      choices: function (answers) {
        var choices = [
          {
            name: 'Angular Animate',
            value: 'animate'
          },
          {
            name: 'Angular Cookies',
            value: 'cookies'
          },
          {
            name: 'Angular Resource',
            value: 'resource'
          },
          {
            name: 'Angular Sanitize',
            value: 'sanitize'
          },
          {
            name: 'Angular Touch',
            value: 'touch'
          },
          {
            name: 'Font Awesome',
            value: 'fontawesome'
          },
          {
            name: 'Lo-Dash',
            value: 'lodash'
          },
          {
            name: 'Restangular (installs Lo-Dash)',
            value: 'restangular'
          }
        ];

        if (answers.ngversion === '1.3.*') {
          choices.splice(1, 0, {
            name: 'Angular Aria',
            value: 'aria'
          });
          choices.splice(3, 0, {
            name: 'Angular Messages',
            value: 'messages'
          });
        }

        return choices;
      }
    }
  ], function (props) {
    this.appName = props.appName;
    this.ngversion = props.ngversion;
    this.structure = props.structure;
    this.appDir = props.appDir;
    this.host = props.host;
    this.port = props.port;
    this.markup = props.markup;
    this.appScript = props.appScript;
    this.controllerAs = props.controllerAs;
    this.skipController = !props.skipController;
    this.testScript = props.testScript;
    this.testFramework = props.testFramework;
    this.e2eTestFramework = props.e2eTestFramework;
    this.unitTestDir = props.unitTestDir;
    this.style = props.style;
    this.polymer = props.polymer;
    this.ngRoute = props.ngRoute;
    this.framework = props.framework;
    this.bower = props.bower.join(',');

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

Generator.prototype.configuring = function configuring() {
  // create a directory named `appName`
  this.destinationRoot(this.appName);

  // save config info
  this.config.set('structure', this.structure);
  this.config.set('markup', this.markup);
  this.config.set('appScript', this.appScript);
  this.config.set('controllerAs', this.controllerAs);
  this.config.set('skipController', this.skipController);
  this.config.set('testScript', this.testScript);
  this.config.set('testFramework', this.testFramework);
  this.config.set('e2eTestFramework', this.e2eTestFramework);
  this.config.set('style', this.style);
  this.config.set('ngRoute', this.ngRoute);
  this.config.set('lastUsedModule', 'home');

  this.context = {
    appName: this.appName,
    structure: this.structure,
    ngversion: this.ngversion,
    appDir: this.appDir,
    unitTestDir: this.unitTestDir,
    host: this.host,
    port: this.port,
    moduleName: utils.lowerCamel(this.appName),
    polymer: this.polymer,
    framework: this.framework,
    testFramework: this.testFramework,
    e2eTestFramework: this.e2eTestFramework,
    ngRoute: this.ngRoute,
    bower: this.bower
  };

  // copy over common project files
  this.copySimpleFile('.bowerrc');
  this.copySimpleFile('.editorconfig');
  this.copySimpleFile('.eslintrc');
  this.copySimpleFile('.jscsrc');
  this.copySimpleFile('.jshintrc');
  this.copySimpleFile('_bower.json');
  this.copySimpleFile('_build.config.js');
  this.copySimpleFile('_gulpfile.js', 'Gulpfile.js');
  this.copySimpleFile('_karma.config.js');
  this.copySimpleFile('_package.json');
  if (this.appScript === 'ts') {
    this.copySimpleFile('_tsd.json');
  }
  this.copySimpleFile('gitignore', '.gitignore');
  this.copySimpleFile('_protractor.config.js');
  this.copySimpleFile('_readme.md', 'README.md');

  // copy over gulp files
  this.copySimpleFile('gulp/analyze.js');
  this.copySimpleFile('gulp/_build.js');
  this.copySimpleFile('gulp/_test.js');
  this.copySimpleFile('gulp/watch.js');
};

Generator.prototype.writing = function writing() {
  // create main module and index.html
  this.copySimpleFile('_app.' + this.appScript, path.join(this.appDir, 'app.' + this.appScript));
  this.copySimpleFile('_index.' + this.markup, path.join(this.appDir, 'index.' + this.markup));

  mkdirp.sync(path.join(this.appDir, 'fonts'));
  mkdirp.sync(path.join(this.appDir, 'images'));
};

Generator.prototype.install = function install() {
  if (!this.options['skip-install']) {
    this.installDependencies();
    if (this.appScript === 'ts') {
      this.log('Running ' + chalk.yellow.bold('tsd reinstall && tsd rebundle') + '. If this fails run the commands ' +
        'yourself. Tsd must be installed via `npm install -g tsd@next`.');
      this.spawnCommand('tsd reinstall && tsd rebundle');
    }
  }
};

Generator.prototype.end = function end() {
  this.composeWith('ng-poly:module', {
    args: ['home'],
    options: {
      module: 'home',
      markup: this.markup,
      style: this.style,
      'test-dir': this.testDir,
      'test-script': this.testScript,
      'controller-as': this.controllerAs,
      'skip-controller': this.skipController,
      'ng-route': this.ngRoute
    }
  }, {
    local: require.resolve('../module'),
    link: 'strong'
  });
};
<commit_msg>feat(app) improve default answers<commit_after>'use strict';
var chalk = require('chalk')
  , genBase = require('../genBase')
  , mkdirp = require('mkdirp')
  , path = require('path')
  , utils = require('../utils')
  , yosay = require('yosay')
  , Generator;

Generator = module.exports = genBase.extend();

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

  this.log(yosay('Welcome to ngPoly!'));

  // ask for app name
  // get preferred langugaes
  this.prompt([
    {
      name: 'appName',
      message: 'What is the app\'s name?',
      validate: function (input) {
        // require an app name
        return !!input;
      }
    },
    {
      type: 'list',
      name: 'ngversion',
      message: 'Which version of Angular should be used?',
      default: '1.3.*',
      choices: [
        {
          name: '1.2.*',
          value: '1.2.*'
        },
        {
          name: '1.3.*',
          value: '1.3.*'
        }
      ]
    },
    {
      type: 'list',
      name: 'structure',
      message: 'Which structure should be used?',
      default: 'module-only',
      choices: [
        {
          name: ['app/',
                '├── module1/',
                '│   ├── module2/',
                '│   ├── module1.js',
                '│   └── module1-controller.js',
                '└── app.js'].join('\n'),
          value: 'module-only'
        },
        {
          name: ['app/',
                '├── module1/',
                '│   ├── controllers/',
                '│   │   └── module1-controller.js',
                '│   ├── module2/',
                '│   └── module1.js',
                '└── app.js'].join('\n'),
          value: 'module-type'
        }
      ]
    },
    {
      name: 'host',
      message: 'What host should the app run on?',
      default: 'localhost'
    },
    {
      name: 'port',
      message: 'Which port should the app run on?',
      default: 3000
    },
    {
      name: 'appDir',
      message: 'Which folder should the app be developed in?',
      default: 'app'
    },
    {
      type: 'list',
      name: 'markup',
      message: 'Which is the preferred markup language?',
      default: 'jade',
      choices: [
        {
          name: 'HAML',
          value: 'haml'
        },
        {
          name: 'HTML',
          value: 'html'
        },
        {
          name: 'Jade',
          value: 'jade'
        }
      ]
    },
    {
      type: 'list',
      name: 'appScript',
      message: 'Which is the preferred application scripting language?',
      default: 'js',
      choices: [
        {
          name: 'CoffeeScript',
          value: 'coffee'
        },
        {
          name: 'EcmaScript2015 (ES6) using Babel',
          value: 'es6'
        },
        {
          name: 'JavaScript (ES5)',
          value: 'js'
        },
        {
          name: 'TypeScript',
          value: 'ts'
        }
      ]
    },
    {
      type: 'confirm',
      name: 'controllerAs',
      message: 'Want to use Controller As syntax?',
      default: true
    },
    {
      type: 'confirm',
      name: 'skipController',
      message: 'By default, should the route generator create controllers?',
      default: true
    },
    {
      name: 'unitTestDir',
      message: 'Where should unit tests be saved?',
      default: 'app'
    },
    {
      type: 'list',
      name: 'testScript',
      message: 'Which is the preferred test scripting language?',
      default: function (answers) {
        return answers.appScript;
      },
      choices: [
        {
          name: 'CoffeeScript',
          value: 'coffee'
        },
        {
          name: 'EcmaScript2015 (ES6) using Babel',
          value: 'es6'
        },
        {
          name: 'JavaScript (ES5)',
          value: 'js'
        },
        {
          name: 'TypeScript',
          value: 'ts'
        }
      ]
    },
    {
      type: 'list',
      name: 'testFramework',
      message: 'Which is the preferred unit testing framework?',
      default: 'jasmine',
      choices: [
        {
          name: 'Jasmine',
          value: 'jasmine'
        },
        {
          name: 'Mocha with Chai',
          value: 'mocha'
        }
      ]
    },
    {
      type: 'list',
      name: 'e2eTestFramework',
      message: 'Which is the preferred e2e testing framework?',
      default: function (answers) {
        return answers.testFramework;
      },
      choices: [
        {
          name: 'Jasmine',
          value: 'jasmine'
        },
        {
          name: 'Mocha with Chai',
          value: 'mocha'
        }
      ]
    },
    {
      type: 'list',
      name: 'style',
      message: 'Which is the preferred style language?',
      default: 'less',
      choices: [
        {
          name: 'CSS',
          value: 'css'
        },
        {
          name: 'LESS',
          value: 'less'
        },
        {
          name: 'SCSS',
          value: 'scss'
        },
        {
          name: 'Stylus',
          value: 'styl'
        }
      ]
    },
    {
      type: 'confirm',
      name: 'polymer',
      message: 'Should Polymer support be enabled?',
      default: false
    },
    {
      type: 'list',
      name: 'framework',
      message: 'Should a framework be setup?',
      choices: function (answers) {
        var choices = [
          {
            name: 'none',
            value: 'none'
          },
          {
            name: 'Bootstrap with AngularStrap',
            value: 'angularstrap'
          },
          {
            name: 'Foundation with Angular Foundation',
            value: 'foundation'
          }
        ];

        if (answers.ngversion === '1.2.*') {
          choices.splice(2, 0, {
            name: 'Bootstrap with UI Bootstrap',
            value: 'uibootstrap'
          });
        } else {
          choices.splice(1, 0, {
            name: 'Angular Material',
            value: 'material'
          });
        }

        return choices;
      }

    },
    {
      type: 'confirm',
      name: 'ngRoute',
      message: 'Should ngRoute be used instead of UI Router?',
      default: false
    },
    {
      type: 'checkbox',
      name: 'bower',
      message: 'Which additional Bower components should be installed?',
      choices: function (answers) {
        var choices = [
          {
            name: 'Angular Animate',
            value: 'animate'
          },
          {
            name: 'Angular Cookies',
            value: 'cookies'
          },
          {
            name: 'Angular Resource',
            value: 'resource'
          },
          {
            name: 'Angular Sanitize',
            value: 'sanitize'
          },
          {
            name: 'Angular Touch',
            value: 'touch'
          },
          {
            name: 'Font Awesome',
            value: 'fontawesome'
          },
          {
            name: 'Lo-Dash',
            value: 'lodash'
          },
          {
            name: 'Restangular (installs Lo-Dash)',
            value: 'restangular'
          }
        ];

        if (answers.ngversion === '1.3.*') {
          choices.splice(1, 0, {
            name: 'Angular Aria',
            value: 'aria'
          });
          choices.splice(3, 0, {
            name: 'Angular Messages',
            value: 'messages'
          });
        }

        return choices;
      }
    }
  ], function (props) {
    this.appName = props.appName;
    this.ngversion = props.ngversion;
    this.structure = props.structure;
    this.appDir = props.appDir;
    this.host = props.host;
    this.port = props.port;
    this.markup = props.markup;
    this.appScript = props.appScript;
    this.controllerAs = props.controllerAs;
    this.skipController = !props.skipController;
    this.testScript = props.testScript;
    this.testFramework = props.testFramework;
    this.e2eTestFramework = props.e2eTestFramework;
    this.unitTestDir = props.unitTestDir;
    this.style = props.style;
    this.polymer = props.polymer;
    this.ngRoute = props.ngRoute;
    this.framework = props.framework;
    this.bower = props.bower.join(',');

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

Generator.prototype.configuring = function configuring() {
  // create a directory named `appName`
  this.destinationRoot(this.appName);

  // save config info
  this.config.set('structure', this.structure);
  this.config.set('markup', this.markup);
  this.config.set('appScript', this.appScript);
  this.config.set('controllerAs', this.controllerAs);
  this.config.set('skipController', this.skipController);
  this.config.set('testScript', this.testScript);
  this.config.set('testFramework', this.testFramework);
  this.config.set('e2eTestFramework', this.e2eTestFramework);
  this.config.set('style', this.style);
  this.config.set('ngRoute', this.ngRoute);
  this.config.set('lastUsedModule', 'home');

  this.context = {
    appName: this.appName,
    structure: this.structure,
    ngversion: this.ngversion,
    appDir: this.appDir,
    unitTestDir: this.unitTestDir,
    host: this.host,
    port: this.port,
    moduleName: utils.lowerCamel(this.appName),
    polymer: this.polymer,
    framework: this.framework,
    testFramework: this.testFramework,
    e2eTestFramework: this.e2eTestFramework,
    ngRoute: this.ngRoute,
    bower: this.bower
  };

  // copy over common project files
  this.copySimpleFile('.bowerrc');
  this.copySimpleFile('.editorconfig');
  this.copySimpleFile('.eslintrc');
  this.copySimpleFile('.jscsrc');
  this.copySimpleFile('.jshintrc');
  this.copySimpleFile('_bower.json');
  this.copySimpleFile('_build.config.js');
  this.copySimpleFile('_gulpfile.js', 'Gulpfile.js');
  this.copySimpleFile('_karma.config.js');
  this.copySimpleFile('_package.json');
  if (this.appScript === 'ts') {
    this.copySimpleFile('_tsd.json');
  }
  this.copySimpleFile('gitignore', '.gitignore');
  this.copySimpleFile('_protractor.config.js');
  this.copySimpleFile('_readme.md', 'README.md');

  // copy over gulp files
  this.copySimpleFile('gulp/analyze.js');
  this.copySimpleFile('gulp/_build.js');
  this.copySimpleFile('gulp/_test.js');
  this.copySimpleFile('gulp/watch.js');
};

Generator.prototype.writing = function writing() {
  // create main module and index.html
  this.copySimpleFile('_app.' + this.appScript, path.join(this.appDir, 'app.' + this.appScript));
  this.copySimpleFile('_index.' + this.markup, path.join(this.appDir, 'index.' + this.markup));

  mkdirp.sync(path.join(this.appDir, 'fonts'));
  mkdirp.sync(path.join(this.appDir, 'images'));
};

Generator.prototype.install = function install() {
  if (!this.options['skip-install']) {
    this.installDependencies();
    if (this.appScript === 'ts') {
      this.log('Running ' + chalk.yellow.bold('tsd reinstall && tsd rebundle') + '. If this fails run the commands ' +
        'yourself. Tsd must be installed via `npm install -g tsd@next`.');
      this.spawnCommand('tsd reinstall && tsd rebundle');
    }
  }
};

Generator.prototype.end = function end() {
  this.composeWith('ng-poly:module', {
    args: ['home'],
    options: {
      module: 'home',
      markup: this.markup,
      style: this.style,
      'test-dir': this.testDir,
      'test-script': this.testScript,
      'controller-as': this.controllerAs,
      'skip-controller': this.skipController,
      'ng-route': this.ngRoute
    }
  }, {
    local: require.resolve('../module'),
    link: 'strong'
  });
};
<|endoftext|>


<commit_before>'use strict';

var path = require('path');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');
var cordova = require('cordova-lib').cordova.raw; // get the promise version of all methods
var fs = require('fs');

// local modules
var utils = require('../utils/utils.js');
var config = require('../utils/config.js');
var bowerConfig = require('./sources/bower-config.js');
var cordovaConfig = require('./sources/cordova-config.js');
var sampleAnswers = require('./sources/sample-answers.js');

var MGenerator = yeoman.generators.Base.extend({
  initializing: function () {
    // get package.json content
    this.pkg = require('../package.json');
    // non-empty dir?
    this.fileCount = fs.readdirSync('.').length;
    // read .yo-rc
    this.answers = this.config.getAll().answers;
    // is update?
    this.update = this.answers ? true : false;

    // abort when directory is not empty on first run
    if (!this.update && this.fileCount > 0) {
      this.log(chalk.red('Non-empty directory. Cordova needs an empty directory to set up project'));
      process.exit(1);
    }
  },

  prompting: function () {
    if (this.update) {
      return;
    }
    // say hello
    if (!this.options['skip-welcome-message']) { // for use with generator-m-server
      this.log(yosay(
        'Welcome to the polished M generator!'
      ));
    }

    // Set appName when generator was called with `--appName=HelloApp`
    if (this.options['app-name']) {
      this.appName = this.options['app-name'];
    }

    var prompts = [
      // appName
      {
        type: 'input',
        name: 'appName',
        message: 'state a name for your project (this name will be displayed below the app icon)',
        validate: utils.validateAppName,
        when: function () {
          // Show this prompt only if appName is not already set
          return !this.appName;
        }.bind(this)
      },
      // appId
      {
        type: 'input',
        name: 'appId',
        message: 'state a bundle identifier for your project (e.g. com.company.project)',
        validate: utils.validateAppId
      },
      // bower packages
      {
        type: 'checkbox',
        name: 'bowerPackages',
        message: 'Choose all bower packages in addition to angular, ionic, angular-ui-router, cordova and ngCordova:',
        choices: bowerConfig.optional
      },
      // select platforms
      {
        type: 'checkbox',
        name: 'platforms',
        message: 'Select all platforms you want to support:',
        choices: cordovaConfig.platforms
      },
      // select plugins
      {
        type: 'checkbox',
        name: 'plugins',
        message: 'Select all cordova plugins you want to install',
        choices: cordovaConfig.plugins
      },
    ];

    // prompt and save results in this.answers
    if (!this.options['skip-prompts']) {
      // tell yeoman we're doing asynchronous stuff here
      // so it can wait with subsequent tasks
      var done = this.async();

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

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

  configuring: function () {

    // debugging
    if (this.options['skip-prompts']) {
      this.answers = sampleAnswers.getStandard({
        'ios-only': this.options['ios-only'],
        'android-only': this.options['android-only'],
        'cordova': this.options.cordova
      });
      this.log(chalk.inverse(JSON.stringify(this.answers, null, '  ')));
    }

    // manipulate answers
    if (this.appName) { // save when name was provided in app-name option
      this.answers.appName = this.appName;
    }
    // save appModule in answers
    this.answers.appModule = utils.moduleName(this.answers.appName);

    // store answers in .yo-rc.json
    this.config.set('answers', this.answers);
  },

  writing: {

    cordova: function () {
      if (this.update) {
        return true;
      }

      var done = this.async(); // wait with subsequent tasks since cordova needs an empty folder
      // cordova project
      cordova.create('.', this.answers.appId, this.answers.appName)
      // add platforms
      .then(function () {
        this.log(chalk.green('Created cordova project'));
        if (this.options['skip-sdk'] || !this.answers.platforms.length) {
          return true;
        }
        else {
          return cordova.platform('add', this.answers.platforms);
        }
      }.bind(this))
      // add plugins
      .then(function () {
        this.log(chalk.green('Added platforms: ' + this.answers.platforms.join(', ')));
        if (this.options['skip-sdk'] || !this.answers.plugins.length) {
          return true;
        }
        else {
          return cordova.plugins('add', this.answers.plugins);
        }
      }.bind(this))
      // all
      .then(function () {
        this.log(chalk.green('Added plugins: ' + this.answers.plugins.join(', ')));
        this.log(chalk.green('Cordova project was set up successfully! Project Name: '), chalk.bgGreen(this.answers.appName));
        done();
      }.bind(this))
      .catch(function (err) {
        this.log(chalk.red('Couldn\'t finish generator: \n' + err));
        process.exit(1);
      }.bind(this));
    },

    app: function () {
      // prepare bower.json
      var bowerJSON = bowerConfig.bowerJSON;
      // include selected packages
      for (var i = 0, bowerPackage; (bowerPackage = this.answers.bowerPackages[i]); i++) {
        bowerPackage = bowerPackage.split('#');
        bowerJSON.dependencies[bowerPackage[0]] = bowerPackage[1];
      }

      // add other properties
      bowerJSON.name = this.answers.appName;
      bowerJSON.private = true;

      // dependencies
      this.write('bower.json', JSON.stringify(bowerJSON, null, 2));
      this.template('_package.json', 'package.json');

      // app files
      // add random color to navbar
      this.barColor = utils.barColor();
      this.template('_index.html', 'app/index.html');
      this.template('_app.js', 'app/app.js');

      // other files
      this.template('_gulpfile.js', 'gulpfile.js');
      this.directory('gulp_tasks', 'gulp_tasks');
      this.copy('bowerrc', '.bowerrc');
      this.copy('editorconfig', '.editorconfig');
      this.copy('gitattributes', '.gitattributes');
      this.copy('gitignore', '.gitignore');
      this.copy('jenkins.sh', 'jenkins.sh');
      this.copy('.travis.yml', '.travis.yml');
      this.copy('jscsrc', '.jscsrc');
      this.copy('jshintrc', '.jshintrc');
      this.copy('jshintignore', '.jshintignore');
      this.copy(path.join(__dirname, '../', 'README.md'), 'README.md');
    },

    subgenerators: function () {
      this.composeWith('m:module', {
        arguments: config.DEFAULT_MODULE,
        options: {sample: 'start'}
      });
    }
  },

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

  end: function () {
    this.log(yosay(
      'All done! See your app in all it\'s glory by running:\n' +
      chalk.green('gulp watch ')
    ));
  }
});

module.exports = MGenerator;
<commit_msg>work on #151 - yosay: version and bit.ly link<commit_after>'use strict';

var path = require('path');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');
var cordova = require('cordova-lib').cordova.raw; // get the promise version of all methods
var fs = require('fs');

// local modules
var utils = require('../utils/utils.js');
var config = require('../utils/config.js');
var bowerConfig = require('./sources/bower-config.js');
var cordovaConfig = require('./sources/cordova-config.js');
var sampleAnswers = require('./sources/sample-answers.js');

var MGenerator = yeoman.generators.Base.extend({
  initializing: function () {
    // get package.json content
    this.pkg = require('../package.json');
    // non-empty dir?
    this.fileCount = fs.readdirSync('.').length;
    // read .yo-rc
    this.answers = this.config.getAll().answers;
    // is update?
    this.update = this.answers ? true : false;

    // abort when directory is not empty on first run
    if (!this.update && this.fileCount > 0) {
      this.log(chalk.red('Non-empty directory. Cordova needs an empty directory to set up project'));
      process.exit(1);
    }
  },

  prompting: function () {
    if (this.update) {
      return;
    }
    // say hello
    if (!this.options['skip-welcome-message']) { // for use with generator-m-server
      this.log(yosay(
        'Welcome to the polished Generator-M! v.' + this.pkg.version
      ));
    }

    // Set appName when generator was called with `--appName=HelloApp`
    if (this.options['app-name']) {
      this.appName = this.options['app-name'];
    }

    var prompts = [
      // appName
      {
        type: 'input',
        name: 'appName',
        message: 'state a name for your project (this name will be displayed below the app icon)',
        validate: utils.validateAppName,
        when: function () {
          // Show this prompt only if appName is not already set
          return !this.appName;
        }.bind(this)
      },
      // appId
      {
        type: 'input',
        name: 'appId',
        message: 'state a bundle identifier for your project (e.g. com.company.project)',
        validate: utils.validateAppId
      },
      // bower packages
      {
        type: 'checkbox',
        name: 'bowerPackages',
        message: 'Choose all bower packages in addition to angular, ionic, angular-ui-router, cordova and ngCordova:',
        choices: bowerConfig.optional
      },
      // select platforms
      {
        type: 'checkbox',
        name: 'platforms',
        message: 'Select all platforms you want to support:',
        choices: cordovaConfig.platforms
      },
      // select plugins
      {
        type: 'checkbox',
        name: 'plugins',
        message: 'Select all cordova plugins you want to install',
        choices: cordovaConfig.plugins
      },
    ];

    // prompt and save results in this.answers
    if (!this.options['skip-prompts']) {
      // tell yeoman we're doing asynchronous stuff here
      // so it can wait with subsequent tasks
      var done = this.async();

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

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

  configuring: function () {

    // debugging
    if (this.options['skip-prompts']) {
      this.answers = sampleAnswers.getStandard({
        'ios-only': this.options['ios-only'],
        'android-only': this.options['android-only'],
        'cordova': this.options.cordova
      });
      this.log(chalk.inverse(JSON.stringify(this.answers, null, '  ')));
    }

    // manipulate answers
    if (this.appName) { // save when name was provided in app-name option
      this.answers.appName = this.appName;
    }
    // save appModule in answers
    this.answers.appModule = utils.moduleName(this.answers.appName);

    // store answers in .yo-rc.json
    this.config.set('answers', this.answers);
  },

  writing: {

    cordova: function () {
      if (this.update) {
        return true;
      }

      var done = this.async(); // wait with subsequent tasks since cordova needs an empty folder
      // cordova project
      cordova.create('.', this.answers.appId, this.answers.appName)
      // add platforms
      .then(function () {
        this.log(chalk.green('Created cordova project'));
        if (this.options['skip-sdk'] || !this.answers.platforms.length) {
          return true;
        }
        else {
          return cordova.platform('add', this.answers.platforms);
        }
      }.bind(this))
      // add plugins
      .then(function () {
        this.log(chalk.green('Added platforms: ' + this.answers.platforms.join(', ')));
        if (this.options['skip-sdk'] || !this.answers.plugins.length) {
          return true;
        }
        else {
          return cordova.plugins('add', this.answers.plugins);
        }
      }.bind(this))
      // all
      .then(function () {
        this.log(chalk.green('Added plugins: ' + this.answers.plugins.join(', ')));
        this.log(chalk.green('Cordova project was set up successfully! Project Name: '), chalk.bgGreen(this.answers.appName));
        done();
      }.bind(this))
      .catch(function (err) {
        this.log(chalk.red('Couldn\'t finish generator: \n' + err));
        process.exit(1);
      }.bind(this));
    },

    app: function () {
      // prepare bower.json
      var bowerJSON = bowerConfig.bowerJSON;
      // include selected packages
      for (var i = 0, bowerPackage; (bowerPackage = this.answers.bowerPackages[i]); i++) {
        bowerPackage = bowerPackage.split('#');
        bowerJSON.dependencies[bowerPackage[0]] = bowerPackage[1];
      }

      // add other properties
      bowerJSON.name = this.answers.appName;
      bowerJSON.private = true;

      // dependencies
      this.write('bower.json', JSON.stringify(bowerJSON, null, 2));
      this.template('_package.json', 'package.json');

      // app files
      // add random color to navbar
      this.barColor = utils.barColor();
      this.template('_index.html', 'app/index.html');
      this.template('_app.js', 'app/app.js');

      // other files
      this.template('_gulpfile.js', 'gulpfile.js');
      this.directory('gulp_tasks', 'gulp_tasks');
      this.copy('bowerrc', '.bowerrc');
      this.copy('editorconfig', '.editorconfig');
      this.copy('gitattributes', '.gitattributes');
      this.copy('gitignore', '.gitignore');
      this.copy('jenkins.sh', 'jenkins.sh');
      this.copy('.travis.yml', '.travis.yml');
      this.copy('jscsrc', '.jscsrc');
      this.copy('jshintrc', '.jshintrc');
      this.copy('jshintignore', '.jshintignore');
      this.copy(path.join(__dirname, '../', 'README.md'), 'README.md');
    },

    subgenerators: function () {
      this.composeWith('m:module', {
        arguments: config.DEFAULT_MODULE,
        options: {sample: 'start'}
      });
    }
  },

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

  end: function () {
    this.log(yosay(
      'All done! See your app in all it\'s glory by running:\n' +
      chalk.green('gulp watch \n') +
      'More info: http://bit.ly/1DXy7MJ'
    ));
  }
});

module.exports = MGenerator;
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import { StyleSheet } from 'react-native';
import { Provider } from 'react-redux';
import { applyMiddleware, createStore } from 'redux';
import createLogger from 'redux-logger';
import thunkMiddleware from 'redux-thunk';

import App from './containers/app';
import reducers from './reducers';
import styles from './styles'

const logger = createLogger({
  colors: { action: false, error: false, nextState: false, prevState: false, title: false },
  duration: true,
  level: 'info',
  predicate: (getState, action) => __DEV__
});

const middleware = applyMiddleware(thunkMiddleware, logger);
const store = createStore(reducers, {}, middleware);

import { loadHistory } from  './statsStorage'
loadHistory(store.dispatch)

export default () => (
  <Provider store={ store }>
    <App />
  </Provider>
);
<commit_msg>Upgrade redux-logger 2.6.1 -> 3.0.6<commit_after>import React, { Component } from 'react';
import { StyleSheet } from 'react-native';
import { Provider } from 'react-redux';
import { applyMiddleware, createStore } from 'redux';
import { createLogger } from 'redux-logger';
import thunkMiddleware from 'redux-thunk';

import App from './containers/app';
import reducers from './reducers';
import styles from './styles'

const logger = createLogger({
  colors: { action: false, error: false, nextState: false, prevState: false, title: false },
  duration: true,
  level: 'info',
  predicate: (getState, action) => __DEV__
});

const middleware = applyMiddleware(thunkMiddleware, logger);
const store = createStore(reducers, {}, middleware);

import { loadHistory } from  './statsStorage'
loadHistory(store.dispatch)

export default () => (
  <Provider store={ store }>
    <App />
  </Provider>
);
<|endoftext|>


<commit_before>(function (GulpRequirejsGenerator, yo, chalk, util, path) {
	'use strict';

	chalk = require('chalk'),
	util = require('util'),
	path = require('path');

	GulpRequirejsGenerator.exports = yo.generators.Base.extend({
		init: function () {
			this.pkg = require('../package.json');
			this.on('end', function () {
				if (!this.options['skip-install']) {
					this.installDependencies();
				}
			});
		},

		hasFeature: function (list, feat) {
			return (list || []).indexOf(feat) !== -1;
		},

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

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

			// replace it with a short and sweet description of your generator
			this.log(chalk.magenta('You\'re using the fantastic', chalk.yellow('Gulp\\RequireJS generator') + chalk.magenta('.')));

			var prompts = [
				{
					type: 'checkbox',
					name: 'Features',
					message: 'What more would you like?',
					default: true,
					choices: [
						{
							name: 'Modernizr',
							value: 'includeModernizr',
							checked: true
						},
						{
							name: 'jQuery',
							value: 'includejQuery',
							checked: true
						}
					]
				},
				{
					type: 'confirm',
					name: 'HTML5Shiv',
					value: 'includeHTML5Shiv',
					message: 'Would you like to use a crossbrowser workaround to ' + chalk.red('HTML5') + '?',
					when: function (answers) {
						return !scope.hasFeature(answers.Features, 'includeModernizr');
					}
				},
				{
					type: 'confirm',
					name: 'Sizzle',
					value: 'includeSizzle',
					message: 'Would you like to use a pure-JavaScript CSS selector engine?',
					when: function (answers) {
						return !scope.hasFeature(answers.Features, 'includejQuery');
					}
				}
			];

			this.prompt(prompts, function (props) {
				// HTML features
				this.includeModernizr = this.hasFeature(props.Features, 'includeModernizr');
				this.includeHTML5Shiv = props.HTML5Shiv;
				this.hasHTML5Feat = this.includeModernizr || this.includeHTML5Shiv;

				// JS features
				this.includejQuery = this.hasFeature(props.Features, 'includejQuery');
				this.includeSizzle = props.Sizzle;
				this.hasJSFeat = this.includejQuery || this.includeSizzle;

				// Features
				this.hasFeat = this.hasHTML5Feat || this.hasJSFeat;
				done();
			}.bind(this));
		},

		tree: function () {
			this.log(chalk.magenta('Tree:'));

			// images
			this.mkdir('app/images');

			// scripts
			this.mkdir('app/scripts/application/routers');
			this.mkdir('app/scripts/application/views');
			this.mkdir('app/scripts/helpers');

			// styles
			this.mkdir('app/styles/base');
			this.mkdir('app/styles/layout');
			this.mkdir('app/styles/modules');
			this.mkdir('app/styles/states');
			this.mkdir('app/styles/typography');

			// test
			this.mkdir('test/lib/mocha');
			this.mkdir('test/spec');
		},

		bower: function () {
			this.log(chalk.green(' ✓', chalk.white('Bower')));
			this.copy('_bower.json', 'bower.json');
			this.copy('bower.rc', '.bowerrc');
		},

		gulp: function () {
			this.log(chalk.green('\n ✓', chalk.white('Gulp')));
			this.copy('_gulpfile.js', 'gulpfile.js');
		},

		npm: function () {
			this.log(chalk.green('\n ✓', chalk.white('NPM')));
			this.copy('_package.json', 'package.json');
		},

		editor: function () {
			this.log(chalk.green('\n ✓', chalk.white('Editor')));
			this.copy('editor.config', '.editorconfig');
		},

		git: function () {
			this.log(chalk.green('\n ✓', chalk.white('GIT')));
			this.copy('git.attributes', '.gitattributes');
			this.copy('git.ignore', '.gitignore');
		},

		jshint: function () {
			this.log(chalk.green('\n ✓', chalk.white('JSHint')));
			this.copy('jshint.rc', '.jshintrc');
		},

		jscs: function () {
			this.log(chalk.green('\n ✓', chalk.white('JSCS')));
			this.copy('jscs.json', '.jscs.json');
		},

		requirejs: function () {
			this.log(chalk.green('\n ✓', chalk.white('RequireJS')));
			// app/scripts/helpers/
			this.copy('app/scripts/helpers/polyfills.js', 'app/scripts/helpers/polyfills.js');
			this.copy('app/scripts/helpers/utils.js', 'app/scripts/helpers/utils.js');

			// app/scripts/
			this.copy('app/scripts/application/routers.js', 'app/scripts/application/routers.js');
			this.copy('app/scripts/application/scope.js', 'app/scripts/application/scope.js');
			this.copy('app/scripts/application/views.js', 'app/scripts/application/views.js');
			this.copy('app/scripts/application.js', 'app/scripts/application.js');
			this.copy('app/scripts/config.js', 'app/scripts/config.js');
		},

		bem: function () {
			this.log(chalk.green('\n ✓', chalk.white('BEM')));
			// app/styles/base
			this.copy('app/styles/base/_mixins.scss', 'app/styles/base/_mixins.scss');
			this.copy('app/styles/base/_params.scss', 'app/styles/base/_params.scss');
			this.copy('app/styles/base/_reset.scss', 'app/styles/base/_reset.scss');

			// app/styles/layout
			this.copy('app/styles/layout/_core.scss', 'app/styles/layout/_core.scss');
			this.copy('app/styles/layout/_footer.scss', 'app/styles/layout/_footer.scss');
			this.copy('app/styles/layout/_header.scss', 'app/styles/layout/_header.scss');

			// app/styles/modules
			this.copy('app/styles/modules/_menu.scss', 'app/styles/modules/_menu.scss');

			// app/styles/states
			this.copy('app/styles/states/_breakpoints.scss', 'app/styles/states/_breakpoints.scss');

			// app/styles/
			this.copy('app/styles/base.scss', 'app/styles/base.scss');
			this.copy('app/styles/layout.scss', 'app/styles/layout.scss');
			this.copy('app/styles/modules.scss', 'app/styles/modules.scss');
			this.copy('app/styles/states.scss', 'app/styles/states.scss');

			// app/styles/
			this.copy('app/styles/theme.scss', 'app/styles/theme.scss');
		},

		h5bp: function () {
			this.log(chalk.green('\n ✓', chalk.white('H5BP')));
			// app/
			this.copy('app/README.md', 'README.md');
			this.copy('app/404.html', 'app/404.html');
			this.copy('app/images/cover.png', 'app/images/cover.png');
			this.copy('app/favicon.ico', 'app/favicon.ico');
			this.copy('app/ht.access', 'app/.htaccess');
			this.copy('app/humans.txt', 'app/humans.txt');
			this.copy('app/robots.txt', 'app/robots.txt');
		},

		writeIndex: function () {
			this.copy('app/index.html', 'app/index.html');
		},

		mocha: function () {
			this.log(chalk.green('\n ✓', chalk.white('Mocha')));
			// test/lib/mocha/
			this.copy('test/lib/mocha/mocha.css', 'test/lib/mocha/mocha.css');
			this.copy('test/lib/mocha/mocha.js', 'test/lib/mocha/mocha.js');

			// test/lib/
			this.copy('test/lib/chai.js', 'test/lib/chai.js');
			this.copy('test/lib/expect.js', 'test/lib/expect.js');

			// test/spec/
			this.copy('test/spec/test.js', 'test/spec/test.js');

			// test/
			this.copy('test/index.html', 'test/index.html');
		}
	});

}(module, require('yeoman-generator')));
<commit_msg>Update index.js<commit_after>(function (GulpRequirejsGenerator, yo, chalk, util, path) {
	'use strict';

	chalk = require('chalk'),
	util = require('util'),
	path = require('path');

	GulpRequirejsGenerator.exports = yo.generators.Base.extend({
		init: function () {
			this.pkg = require('../package.json');
			this.on('end', function () {
				if (!this.options['skip-install']) {
					this.installDependencies();
				}
			});
		},

		hasFeature: function (list, feat) {
			return (list || []).indexOf(feat) !== -1;
		},

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

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

			// replace it with a short and sweet description of your generator
			this.log(chalk.magenta('You\'re using the fantastic', chalk.yellow('Gulp\\RequireJS generator') + chalk.magenta('.')));

			var prompts = [
				{
					type: 'checkbox',
					name: 'Features',
					message: 'What more would you like?',
					default: true,
					choices: [
						{
							name: 'Modernizr',
							value: 'includeModernizr',
							checked: true
						},
						{
							name: 'jQuery',
							value: 'includejQuery',
							checked: true
						}
					]
				},
				{
					type: 'confirm',
					name: 'HTML5Shiv',
					value: 'includeHTML5Shiv',
					message: 'Would you like to use a crossbrowser workaround to ' + chalk.red('HTML5') + '?',
					when: function (answers) {
						return !scope.hasFeature(answers.Features, 'includeModernizr');
					}
				},
				{
					type: 'confirm',
					name: 'Sizzle',
					value: 'includeSizzle',
					message: 'Would you like to use a pure-JavaScript CSS selector engine?',
					when: function (answers) {
						return !scope.hasFeature(answers.Features, 'includejQuery');
					}
				}
			];

			this.prompt(prompts, function (props) {
				// HTML features
				this.includeModernizr = this.hasFeature(props.Features, 'includeModernizr');
				this.includeHTML5Shiv = props.HTML5Shiv;
				this.hasHTML5Feat = this.includeModernizr || this.includeHTML5Shiv;

				// JS features
				this.includejQuery = this.hasFeature(props.Features, 'includejQuery');
				this.includeSizzle = props.Sizzle;
				this.hasJSFeat = this.includejQuery || this.includeSizzle;

				// Features
				this.hasFeat = this.hasHTML5Feat || this.hasJSFeat;
				done();
			}.bind(this));
		},

		tree: function () {
			this.log(chalk.magenta('Tree:'));

			// images
			this.mkdir('app/images');

			// scripts
			this.mkdir('app/scripts/application/routers');
			this.mkdir('app/scripts/application/views');
			this.mkdir('app/scripts/helpers');

			// styles
			this.mkdir('app/styles/base');
			this.mkdir('app/styles/layout');
			this.mkdir('app/styles/modules');
			this.mkdir('app/styles/states');
			this.mkdir('app/styles/typography');

			// test
			this.mkdir('test/lib/mocha');
			this.mkdir('test/spec');
		},

		work: function () {
			this.copy('README.md', 'README.md');
		}

		bower: function () {
			this.log(chalk.green(' ✓', chalk.white('Bower')));
			this.copy('_bower.json', 'bower.json');
			this.copy('bower.rc', '.bowerrc');
		},

		gulp: function () {
			this.log(chalk.green('\n ✓', chalk.white('Gulp')));
			this.copy('_gulpfile.js', 'gulpfile.js');
		},

		npm: function () {
			this.log(chalk.green('\n ✓', chalk.white('NPM')));
			this.copy('_package.json', 'package.json');
		},

		editor: function () {
			this.log(chalk.green('\n ✓', chalk.white('Editor')));
			this.copy('editor.config', '.editorconfig');
		},

		git: function () {
			this.log(chalk.green('\n ✓', chalk.white('GIT')));
			this.copy('git.attributes', '.gitattributes');
			this.copy('git.ignore', '.gitignore');
		},

		jshint: function () {
			this.log(chalk.green('\n ✓', chalk.white('JSHint')));
			this.copy('jshint.rc', '.jshintrc');
		},

		jscs: function () {
			this.log(chalk.green('\n ✓', chalk.white('JSCS')));
			this.copy('jscs.json', '.jscs.json');
		},

		requirejs: function () {
			this.log(chalk.green('\n ✓', chalk.white('RequireJS')));
			// app/scripts/helpers/
			this.copy('app/scripts/helpers/polyfills.js', 'app/scripts/helpers/polyfills.js');
			this.copy('app/scripts/helpers/utils.js', 'app/scripts/helpers/utils.js');

			// app/scripts/
			this.copy('app/scripts/application/routers.js', 'app/scripts/application/routers.js');
			this.copy('app/scripts/application/scope.js', 'app/scripts/application/scope.js');
			this.copy('app/scripts/application/views.js', 'app/scripts/application/views.js');
			this.copy('app/scripts/application.js', 'app/scripts/application.js');
			this.copy('app/scripts/config.js', 'app/scripts/config.js');
		},

		bem: function () {
			this.log(chalk.green('\n ✓', chalk.white('BEM')));
			// app/styles/base
			this.copy('app/styles/base/_mixins.scss', 'app/styles/base/_mixins.scss');
			this.copy('app/styles/base/_params.scss', 'app/styles/base/_params.scss');
			this.copy('app/styles/base/_reset.scss', 'app/styles/base/_reset.scss');

			// app/styles/layout
			this.copy('app/styles/layout/_core.scss', 'app/styles/layout/_core.scss');
			this.copy('app/styles/layout/_footer.scss', 'app/styles/layout/_footer.scss');
			this.copy('app/styles/layout/_header.scss', 'app/styles/layout/_header.scss');

			// app/styles/modules
			this.copy('app/styles/modules/_menu.scss', 'app/styles/modules/_menu.scss');

			// app/styles/states
			this.copy('app/styles/states/_breakpoints.scss', 'app/styles/states/_breakpoints.scss');

			// app/styles/
			this.copy('app/styles/base.scss', 'app/styles/base.scss');
			this.copy('app/styles/layout.scss', 'app/styles/layout.scss');
			this.copy('app/styles/modules.scss', 'app/styles/modules.scss');
			this.copy('app/styles/states.scss', 'app/styles/states.scss');

			// app/styles/
			this.copy('app/styles/theme.scss', 'app/styles/theme.scss');
		},

		h5bp: function () {
			this.log(chalk.green('\n ✓', chalk.white('H5BP')));
			// app/
			this.copy('app/404.html', 'app/404.html');
			this.copy('app/images/cover.png', 'app/images/cover.png');
			this.copy('app/favicon.ico', 'app/favicon.ico');
			this.copy('app/ht.access', 'app/.htaccess');
			this.copy('app/humans.txt', 'app/humans.txt');
			this.copy('app/robots.txt', 'app/robots.txt');
		},

		writeIndex: function () {
			this.copy('app/index.html', 'app/index.html');
		},

		mocha: function () {
			this.log(chalk.green('\n ✓', chalk.white('Mocha')));
			// test/lib/mocha/
			this.copy('test/lib/mocha/mocha.css', 'test/lib/mocha/mocha.css');
			this.copy('test/lib/mocha/mocha.js', 'test/lib/mocha/mocha.js');

			// test/lib/
			this.copy('test/lib/chai.js', 'test/lib/chai.js');
			this.copy('test/lib/expect.js', 'test/lib/expect.js');

			// test/spec/
			this.copy('test/spec/test.js', 'test/spec/test.js');

			// test/
			this.copy('test/index.html', 'test/index.html');
		}
	});

}(module, require('yeoman-generator')));
<|endoftext|>


<commit_before>// react-native
import React, { Component } from 'react';
import { Linking } from 'react-native';
import { Actions, Router, Scene } from 'react-native-router-flux';
// redux
import { Provider, connect } from 'react-redux';
// actions
import { getTemporaryAcessToken } from './actions/login';
// temp
import HomeContainer from './routes/home/containers/HomeContainer';
import LoginContainer from './routes/login/containers/LoginContainer';
// store
import configureStore from './store/configureStore';

const store = configureStore();

// TODO: use react navigation or react-router v4 instead.
const Scenes = Actions.create(
  <Scene key="root" hideNavBar={true}>
    <Scene key="login" component={LoginContainer} hideNavBar={true} />
    <Scene key="localhost" component={HomeContainer} />
  </Scene>,
);

const ConnectedRouter = connect()(Router);

function handleOpenURL(url) {
  if (url != null) {
    const myRegexp = /(?:&code=)(\w*)/g;
    const match = myRegexp.exec(url);
    store.dispatch(getTemporaryAcessToken(match[1]));
  }
}

Linking.addEventListener('url', event => handleOpenURL(event.url));

export default class App extends Component {

  componentDidMount() {
    // eslint-disable-statement no-console
    Linking.getInitialURL()
      .then(handleOpenURL)
      .catch(err => console.error('An error occurred', err));
  }

  componentWillUnmount() {
    Linking.removeEventListener('url', handleOpenURL);
  }

  render() {
    return (
      <Provider store={store}>
        <ConnectedRouter scenes={Scenes} />
      </Provider>
    );
  }
}
<commit_msg>remove useless property definition.<commit_after>// react-native
import React, { Component } from 'react';
import { Linking } from 'react-native';
import { Actions, Router, Scene } from 'react-native-router-flux';
// redux
import { Provider, connect } from 'react-redux';
// actions
import { getTemporaryAcessToken } from './actions/login';
// temp
import HomeContainer from './routes/home/containers/HomeContainer';
import LoginContainer from './routes/login/containers/LoginContainer';
// store
import configureStore from './store/configureStore';

const store = configureStore();

// TODO: use react navigation or react-router v4 instead.
const Scenes = Actions.create(
  <Scene key="root" hideNavBar>
    <Scene key="login" component={LoginContainer} hideNavBar />
    <Scene key="localhost" component={HomeContainer} />
  </Scene>,
);

const ConnectedRouter = connect()(Router);

function handleOpenURL(url) {
  if (url != null) {
    const myRegexp = /(?:&code=)(\w*)/g;
    const match = myRegexp.exec(url);
    store.dispatch(getTemporaryAcessToken(match[1]));
  }
}

Linking.addEventListener('url', event => handleOpenURL(event.url));

export default class App extends Component {

  componentDidMount() {
    // eslint-disable no-console
    Linking.getInitialURL()
      .then(handleOpenURL)
      .catch(err => console.error('An error occurred', err));
  }

  componentWillUnmount() {
    Linking.removeEventListener('url', handleOpenURL);
  }

  render() {
    return (
      <Provider store={store}>
        <ConnectedRouter scenes={Scenes} />
      </Provider>
    );
  }
}
<|endoftext|>


<commit_before>/* vim: set tabstop=2 shiftwidth=2 softtabstop=2 expandtab : */
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');

var BeezSubmoduleGenerator = module.exports = function BeezSubmoduleGenerator(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(BeezSubmoduleGenerator, yeoman.generators.Base);

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

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

  var prompts = [{
    type: 'checkbox',
    name: 'mvcr',
    message: 'Check necessary parts',
    // choices: [
    //   'Model', 'Collection', 'View'
    // ],
    choices: [
      {
        name: 'Model',
        checked: false
      },
      {
        name: 'Collection',
        checked: false
      },
      {
        name: 'View',
        checked: true
      }
    ],
    validate: function (c) {
      var done = this.async();

      if (c.length === 0) {
        done('At least check one property');
      }

      done(true);
    }
  }, {
    name: 'name',
    message: 'Submodule Name',
    default: path.basename(process.cwd()),
    validate: function (w) {
      var done = this.async();

      // if no name then show message.
      if (!/[a-z-]/.test(w)) {
        done('You should put lowercase alphabet in module name.');
        return;
      }

      done(true);
    }
  }, {
    name: 'description',
    message: 'Description',
    default: 'The best submodule ever.'
  }, {
    name: 'authorName',
    message: 'Author\'s Name',
    validate: function (w) {
      var done = this.async();

      // if no author name then show message.
      if (w.length === 0) {
        done('You should put your name.');
      }

      done(true);
    },
      // use git username when set
    default: this.user.git.username
  }, {
    name: 'authorEmail',
    message: 'Author\'s Email',
    validate: function (w) {
      var done = this.async();

      // if no email then show message.
      if (w.length === 0) {
        done('You should put your email.');
      }

      done(true);
    },
    // use git email when set
    default: this.user.git.email
  }];

  this.prompt(prompts, function (props) {
    // slugify name
    this.slugname = this._.slugify(props.name);
    this.safeSlugname = this.slugname.replace(
      /-([a-z])/g,
      function (g) { return g[1].toUpperCase(); }
    );

    if (props.mvcr.length >= 0) {
      props.mvcr.forEach(function (i) {
        if (i === 'Model') {
          props.model = true;
        }
        if (i === 'View') {
          props.view = true;
        }
        if (i === 'Collection') {
          props.collection = true;
        }
      });
    }

    this.props = props;

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

BeezSubmoduleGenerator .prototype.app = function app() {
  var submoduleName = this.props.name;

  // bower & npm install settings
  this.installDependencies({
    bower: false,
    npm: true,
    skipInstall: true,
    skipMessage: true
  });

  this.mkdir('img');
  this.template('index.js');

  if (this.props.model) {
    this.template('model/index.js');
  }
  if (this.props.collection) {
    this.template('collection/index.js');
  }
  if (this.props.view) {
    this.template('view/index.js');
  }

  this.template('i18n/ja.js');
  this.template('hbs/submodule.hbs', 'hbs/' + submoduleName + '.hbs');
  this.template('styl/submodule.styl', 'styl/' + submoduleName + '.styl');
  this.template('test/index.js');
  this.template('mock.submodule.html.hbs', 'mock.' + submoduleName + '.html.hbs');
};

BeezSubmoduleGenerator .prototype.projectfiles = function projectfiles() {
  this.template('_package.json', 'package.json');
};
<commit_msg>close #4 show router setting in console.<commit_after>/* vim: set tabstop=2 shiftwidth=2 softtabstop=2 expandtab : */
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');

var BeezSubmoduleGenerator = module.exports = function BeezSubmoduleGenerator(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(BeezSubmoduleGenerator, yeoman.generators.Base);

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

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

  var prompts = [{
    type: 'checkbox',
    name: 'mvcr',
    message: 'Check necessary parts',
    // choices: [
    //   'Model', 'Collection', 'View'
    // ],
    choices: [
      {
        name: 'Model',
        checked: false
      },
      {
        name: 'Collection',
        checked: false
      },
      {
        name: 'View',
        checked: true
      }
    ],
    validate: function (c) {
      var done = this.async();

      if (c.length === 0) {
        done('At least check one property');
      }

      done(true);
    }
  }, {
    name: 'name',
    message: 'Submodule Name',
    default: path.basename(process.cwd()),
    validate: function (w) {
      var done = this.async();

      // if no name then show message.
      if (!/[a-z-]/.test(w)) {
        done('You should put lowercase alphabet in module name.');
        return;
      }

      done(true);
    }
  }, {
    name: 'description',
    message: 'Description',
    default: 'The best submodule ever.'
  }, {
    name: 'authorName',
    message: 'Author\'s Name',
    validate: function (w) {
      var done = this.async();

      // if no author name then show message.
      if (w.length === 0) {
        done('You should put your name.');
      }

      done(true);
    },
      // use git username when set
    default: this.user.git.username
  }, {
    name: 'authorEmail',
    message: 'Author\'s Email',
    validate: function (w) {
      var done = this.async();

      // if no email then show message.
      if (w.length === 0) {
        done('You should put your email.');
      }

      done(true);
    },
    // use git email when set
    default: this.user.git.email
  }];

  this.prompt(prompts, function (props) {
    // slugify name
    this.slugname = this._.slugify(props.name);
    this.safeSlugname = this.slugname.replace(
      /-([a-z])/g,
      function (g) { return g[1].toUpperCase(); }
    );

    if (props.mvcr.length >= 0) {
      props.mvcr.forEach(function (i) {
        if (i === 'Model') {
          props.model = true;
        }
        if (i === 'View') {
          props.view = true;
        }
        if (i === 'Collection') {
          props.collection = true;
        }
      });
    }

    this.props = props;

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

BeezSubmoduleGenerator.prototype.app = function app() {
  var submoduleName = this.props.name,
      yellow = '\u001b[33m',
      message = '\u001b[31m' + 'Put below code in your configure file. (in conf directory)\n';

  message += yellow + '"search": {\n';
  message += yellow + '  "route": "' + this.slugname + '",\n';
  message += yellow + '  "name": "' + this.slugname + '",\n';
  message += yellow + '  "require": "' + this.slugname + '/index' + '",\n';
  message += yellow + '  "xpath": "/@/' + this.slugname + '"\n';
  message += yellow + '}"\n';

  // bower & npm install settings
  this.installDependencies({
    bower: false,
    npm: true,
    skipInstall: true,
    skipMessage: true
  });

  this.mkdir('img');
  this.template('index.js');

  if (this.props.model) {
    this.template('model/index.js');
  }
  if (this.props.collection) {
    this.template('collection/index.js');
  }
  if (this.props.view) {
    this.template('view/index.js');
  }

  this.template('i18n/ja.js');
  this.template('hbs/submodule.hbs', 'hbs/' + submoduleName + '.hbs');
  this.template('styl/submodule.styl', 'styl/' + submoduleName + '.styl');
  this.template('test/index.js');
  this.template('mock.submodule.html.hbs', 'mock.' + submoduleName + '.html.hbs');

  console.log(message);
};

BeezSubmoduleGenerator.prototype.projectfiles = function projectfiles() {
  this.template('_package.json', 'package.json');
};
<|endoftext|>


<commit_before>'use strict';

require('!!file?name=[name].[ext]!./html/index.html');
require('./scss/base.scss');

const angular = require('angular');
const projectApp = angular.module('projectApp', [require('angular-route'), require('angular-jwt')]);

require('./services')(projectApp);
require('./components')(projectApp);
require('./controllers')(projectApp);

projectApp.run(['$rootScope', ($rs) => {
  $rs.baseUrl = `${__API_URL__}`;
  $rs.httpConfig = {
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
  };
}]);

projectApp.config(['$routeProvider', ($rp) => {
  $rp
  .when('/home', {
    template: require('./html/home.html')
  })
  .when('/parks/:id', {
    template: require('./html/singlepark.html')
  })
  .when('/map', {
    template: require('./html/map.html')
  })
  .when('/login', {
    template: require('./html/log-in.html')
  })
  .when('/signout', {
    template: require('./html/sign-out.html')
  })
  .otherwise({
    redirectTo: 'home'
  });
}]);
<commit_msg>css changes<commit_after>'use strict';

require('!!file?name=[name].[ext]!./html/index.html');
require('./scss/base.scss');

const angular = require('angular');
const projectApp = angular.module('projectApp', [require('angular-route'), require('angular-jwt')]);

require('./services')(projectApp);
require('./components')(projectApp);
require('./controllers')(projectApp);

projectApp.run(['$rootScope', ($rs) => {
  $rs.baseUrl = `${__API_URL__}/api`;
  $rs.httpConfig = {
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
  };
}]);

projectApp.config(['$routeProvider', ($rp) => {
  $rp
  .when('/home', {
    template: require('./html/home.html')
  })
  .when('/parks/:id', {
    template: require('./html/singlepark.html')
  })
  .when('/map', {
    template: require('./html/map.html')
  })
  .when('/login', {
    template: require('./html/log-in.html')
  })
  .when('/signout', {
    template: require('./html/sign-out.html')
  })
  .otherwise({
    redirectTo: 'home'
  });
}]);
<|endoftext|>


<commit_before>const _ = require('lodash');
const express = require('express');
const epilogue = require('epilogue');
const bodyParser = require('body-parser');

const models = require('./models');

const app = module.exports = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

epilogue.initialize({
  app,
  sequelize: models.sequelize,
});

_.forEach(models.sequelize.models, (model) => {
  epilogue.resource({ model });
});

// catch 404 and forward to error handler
app.use((req, res, next) => {
  const err = new Error(`Not found: ${req.url}`);

  err.status = 404;

  next(err);
});

// error handlers
app.use((err, req, res, next) => { // eslint-disable-line no-unused-vars
  if (process.env.NODE_ENV !== 'test') {
    console.error(err.message);
  }

  res.status(err.status || 500);
  res.json({
    message: err.message,
    error: app.get('env') === 'development' ? err : {},
  });
});
<commit_msg>Added some comments<commit_after>const _ = require('lodash');
const express = require('express');
const epilogue = require('epilogue');
const bodyParser = require('body-parser');

const models = require('./models');

const app = module.exports = express();

/**
 * Express middleware
 *
 * - bodyParser.json
 * - bodyParser.urlencoded
 */
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

/**
 * Epilogue
 *
 * - initialization
 * - resources
 */
epilogue.initialize({
  app,
  sequelize: models.sequelize,
});

_.forEach(models.sequelize.models, (model) => {
  epilogue.resource({ model });
});

/**
 * Error handlers
 *
 * - 404
 * - 500
 */
app.use((req, res, next) => { // catch 404 and forward to error handler
  const err = new Error(`Not found: ${req.url}`);

  err.status = 404;

  next(err);
});

app.use((err, req, res, next) => { // eslint-disable-line no-unused-vars
  if (process.env.NODE_ENV !== 'test') {
    console.error(err.message); // eslint-disable-line no-console
  }

  res.status(err.status || 500);
  res.json({
    message: err.message,
    error: app.get('env') === 'development' ? err : {},
  });
});
<|endoftext|>


<commit_before>const express = require('express');
const clientApp = require('../clientapp');
const config = require('./lib/config');
const nunjucks = require('nunjucks');
const path = require('path');
const middleware = require('./middleware');

var app = express();

require('express-monkey-patch')(app);

var staticDir = path.join(__dirname, '/static');
var staticRoot = '/static';

app.use(function (req, res, next) {
  res.locals.static = function static (staticPath) {
    return path.join(app.mountPoint, staticRoot, staticPath);
  };
  next();
});

app.use(express.compress());
app.use(express.bodyParser());
app.use(middleware.session());
app.use(middleware.csrf({ whitelist: [] }));

app.use(staticRoot, express.static(staticDir));

var cApp = clientApp(app, {
  developmentMode: config('DEV', false)
});
app.get('*', cApp.html());

if (!module.parent) {
  const port = config('PORT', 3000);

  app.listen(port, function(err) {
    if (err) {
      throw err;
    }

    console.log('Listening on port ' + port + '.');
  });
} else {
  module.exports = http.createServer(app);
}
<commit_msg>Add caching to static files if not in dev mode<commit_after>const express = require('express');
const clientApp = require('../clientapp');
const config = require('./lib/config');
const nunjucks = require('nunjucks');
const path = require('path');
const middleware = require('./middleware');

const DEV_MODE = config('DEV', false);

var app = express();

require('express-monkey-patch')(app);

var staticDir = path.join(__dirname, '/static');
var staticRoot = '/static';

app.use(function (req, res, next) {
  res.locals.static = function static (staticPath) {
    return path.join(app.mountPoint, staticRoot, staticPath);
  };
  next();
});

app.use(express.compress());
app.use(express.bodyParser());
app.use(middleware.session());
app.use(middleware.csrf({ whitelist: [] }));

app.use(staticRoot, express.static(staticDir, {maxAge: DEV_MODE ? 0 : 86400000}));

var cApp = clientApp(app, {
  developmentMode: config('DEV', false)
});
app.get('*', cApp.html());

if (!module.parent) {
  const port = config('PORT', 3000);

  app.listen(port, function(err) {
    if (err) {
      throw err;
    }

    console.log('Listening on port ' + port + '.');
  });
} else {
  module.exports = http.createServer(app);
}
<|endoftext|>


<commit_before>'use strict';

var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var gruntprompts = require('grunt-prompts');

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

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

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};
util.inherits(GruntpluginGenerator, yeoman.generators.NamedBase);

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

  console.log(
    this.yeoman
    + '\nFor more information about Grunt plugin best practices,'
    + '\nplease see the docs at http://gruntjs.com/creating-plugins');

  var prompts = [{
    name: 'name',
    message: 'Plugin Name',
    filter: function (value) {
      var contribRegex = /^grunt-contrib/;

      if (contribRegex.test(value)) {
        console.log((
          'Removing "contrib" from your project\'s name. The grunt-contrib' +
          '\nnamespace would like to be reserved for tasks maintained by the grunt team.'
        ).red);
        value = value.replace(contribRegex, 'grunt');
      }

      return value;
    }
  }, {
    name: 'description',
    message: 'Description',
    default: 'The best Grunt plugin ever.'
  }, {
    name: 'version',
    message: 'Version',
    default: '0.0.1'
  }, {
    name: 'repository',
    message: 'Project git repository'
  }, {
    name: 'homepage',
    message: 'Project homepage'
  }, {
    name: 'license',
    message: 'License',
    default: 'MIT'
  }, {
    name: 'author_name',
    message: 'Author name'
  }, {
    name: 'author_email',
    message: 'Author email'
  }, {
    name: 'author_url',
    message: 'Author url'
  },{
    name: 'node_version',
    message: 'What versions of node does it run on?',
    default: '>= 0.8.0'
  },{
    name: 'grunt_version',
    message: 'What version of grunt does it need?',
    default: '~0.4.0rc2'
  }];

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

  this.prompt(prompts, function (props) {
    this.slugname = this._.slugify(props.name);

    this.shortname = props.name.replace(/^grunt[\-_]?/, '').replace(/[\W_]+/g, '_').replace(/^(\d)/, '_$1');
    this.author_name = props.author_name.replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');

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

    this.props = props;

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

GruntpluginGenerator.prototype.tasks = function tasks() {
  this.mkdir('tasks');
  this.template('tasks/name.js', 'tasks/' + this.shortname + '.js');
};

GruntpluginGenerator.prototype.test = function test() {
  this.directory('test/expected');
  this.directory('test/fixtures');
  this.template('test/name_test.js', 'test/' + this.shortname + '_test.js');
};

GruntpluginGenerator.prototype.projectfiles = function projectfiles() {
  this.copy('jshintrc', '.jshintrc');
  this.copy('gitignore', '.gitignore');

  this.template('README.md');
  this.template('Gruntfile.js');
  this.template('_package.json', 'package.json');
  //this.write('package.json', gruntprompts.packageJSON(this.props));
};
<commit_msg>removing ref to grunt-prompts<commit_after>'use strict';

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

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

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

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};
util.inherits(GruntpluginGenerator, yeoman.generators.NamedBase);

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

  console.log(
    this.yeoman
    + '\nFor more information about Grunt plugin best practices,'
    + '\nplease see the docs at http://gruntjs.com/creating-plugins');

  var prompts = [{
    name: 'name',
    message: 'Plugin Name',
    filter: function (value) {
      var contribRegex = /^grunt-contrib/;

      if (contribRegex.test(value)) {
        console.log((
          'Removing "contrib" from your project\'s name. The grunt-contrib' +
          '\nnamespace would like to be reserved for tasks maintained by the grunt team.'
        ).red);
        value = value.replace(contribRegex, 'grunt');
      }

      return value;
    }
  }, {
    name: 'description',
    message: 'Description',
    default: 'The best Grunt plugin ever.'
  }, {
    name: 'version',
    message: 'Version',
    default: '0.0.1'
  }, {
    name: 'repository',
    message: 'Project git repository'
  }, {
    name: 'homepage',
    message: 'Project homepage'
  }, {
    name: 'license',
    message: 'License',
    default: 'MIT'
  }, {
    name: 'author_name',
    message: 'Author name'
  }, {
    name: 'author_email',
    message: 'Author email'
  }, {
    name: 'author_url',
    message: 'Author url'
  },{
    name: 'node_version',
    message: 'What versions of node does it run on?',
    default: '>= 0.8.0'
  },{
    name: 'grunt_version',
    message: 'What version of grunt does it need?',
    default: '~0.4.0rc2'
  }];

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

  this.prompt(prompts, function (props) {
    this.slugname = this._.slugify(props.name);

    this.shortname = props.name.replace(/^grunt[\-_]?/, '').replace(/[\W_]+/g, '_').replace(/^(\d)/, '_$1');
    this.author_name = props.author_name.replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');

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

    this.props = props;

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

GruntpluginGenerator.prototype.tasks = function tasks() {
  this.mkdir('tasks');
  this.template('tasks/name.js', 'tasks/' + this.shortname + '.js');
};

GruntpluginGenerator.prototype.test = function test() {
  this.directory('test/expected');
  this.directory('test/fixtures');
  this.template('test/name_test.js', 'test/' + this.shortname + '_test.js');
};

GruntpluginGenerator.prototype.projectfiles = function projectfiles() {
  this.copy('jshintrc', '.jshintrc');
  this.copy('gitignore', '.gitignore');

  this.template('README.md');
  this.template('Gruntfile.js');
  this.template('_package.json', 'package.json');
};
<|endoftext|>


<commit_before>var co = require('co');
var koa = require('koa');
var middlewares = require('koa-middlewares');
var config = require('config');

var Model = require('./server/model');
var route = require('./server/route');

var app = koa();
var server;

co(function *() {

  var db = yield Model.initialize;

  // settings
  app.proxy = true;

  // body parser
  app.use(middlewares.bodyParser());

  // routes
  app.use(middlewares.router(app));
  route(app);

  app.listen(config.self.PORT);

  // start server
  (function () {
    var hostname = process.env.HOSTNAME;
    var port = config.self.PORT;
    if (process.env.NODE_ENV !== 'test') {
      server = app.listen(port, hostname, function() {
        console.log('%s server listening on %s with port %s', config.name, hostname, server.address().port);
      });
    }
  })();

}).catch(function (err) {
  console.error(err);
});
<commit_msg>hotfix<commit_after>var co = require('co');
var koa = require('koa');
var middlewares = require('koa-middlewares');
var config = require('config');

var Model = require('./server/model');
var route = require('./server/route');

var app = koa();
var server;

co(function *() {

  var db = yield Model.initialize;

  // settings
  app.proxy = true;

  // body parser
  app.use(middlewares.bodyParser());

  // routes
  app.use(middlewares.router(app));
  route(app);

  // start server
  (function () {
    var hostname = process.env.HOSTNAME;
    var port = config.self.PORT;
    if (process.env.NODE_ENV !== 'test') {
      server = app.listen(port, hostname, function() {
        console.log('%s server listening on %s with port %s', config.name, hostname, server.address().port);
      });
    }
  })();

}).catch(function (err) {
  console.error(err);
});
<|endoftext|>