all files / app/ index.js

100% Statements 48/48
75% Branches 3/4
100% Functions 12/12
100% Lines 47/47
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113                                                                                                                                   
'use strict';
 
var _yeomanGenerator = require('yeoman-generator');
 
var _underscore = require('underscore.string');
 
var _path = require('path');
 
var _path2 = _interopRequireDefault(_path);
 
var _mkdirp = require('mkdirp');
 
var _mkdirp2 = _interopRequireDefault(_mkdirp);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
module.exports = _yeomanGenerator.Base.extend({
  constructor: constructor,
  appNameParam: appNameParam,
  appSecretParam: appSecretParam,
  common: common,
  gulp: gulp,
  express: express,
  test: test,
  docs: docs,
  install: install
});
 
function constructor() {
  _yeomanGenerator.Base.apply(this, arguments);
  this.slugify = _underscore.slugify;
 
  this.argument('appName', {
    desc: 'create an app with name [appName]',
    type: Boolean,
    required: false,
    defaults: _path2.default.basename(process.cwd())
  });
}
 
function appNameParam() {
  var _this = this;
 
  var done = this.async();
  var prompt = {
    type: 'input',
    name: 'appName',
    message: 'application name',
    default: this.appName
  };
 
  this.prompt(prompt, function (data) {
    _this.appName = data.appName;
    done();
  });
}
 
function appSecretParam() {
  var _this2 = this;
 
  var done = this.async();
  var defaultSecret = Math.random().toString(36).slice(-16);
 
  var prompt = {
    type: 'input',
    name: 'appSecret',
    message: 'type secret to use in json web token',
    default: defaultSecret
  };
 
  this.prompt(prompt, function (data) {
    _this2.appSecret = data.appSecret;
    done();
  });
}
 
function common() {
  this.sourceRoot(__dirname + '/templates/common', this);
  this.directory('.', '.');
}
 
function gulp() {
  this.sourceRoot(__dirname + '/templates/gulp', this);
  this.directory('.', '.');
 
  this.sourceRoot(__dirname + '/templates/tasks', this);
  this.directory('.', './tasks');
}
 
function express() {
  (0, _mkdirp2.default)('app');
  this.sourceRoot(__dirname + '/templates/express', this);
  this.directory('.', './app');
}
 
function test() {
  (0, _mkdirp2.default)('test');
  this.sourceRoot(__dirname + '/templates/test', this);
  this.directory('.', './test');
}
 
function docs() {
  (0, _mkdirp2.default)('docs');
}
 
function install() {
  this.installDependencies({
    npm: true,
    bower: false,
    skipInstall: true
  });
}