diff --git a/generators/app/index.js b/generators/app/index.js index 8005de6..072bc8f 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -3,6 +3,24 @@ var chalk = require('chalk'); var npmName = require('npm-name'); var _ = require('lodash'); +// Available extensions +var extensions = [ + { id: 'none' }, + { id: 'aws', name: 'AWS', client: true }, + { id: 'github', name: 'github', client: true }, + { id: 'analytics', name: 'google analytics', client: true }, + { id: 'calendar', name: 'google calendar', client: true }, + { id: 'sheets', name: 'google sheets', client: true }, + { id: 'heroku', name: 'heroku', client: true }, + { id: 'image', name: 'image', client: true }, + { id: 'jenkins', name: 'jenkins', client: true }, + { id: 'sensu', name: 'sensu', client: true }, + { id: 'time', name: 'time', client: false }, + { id: 'travis', name: 'travis', client: true }, + { id: 'twitter', name: 'twitter', client: true }, + { id: 'weather', name: 'weather', client: true } +]; + module.exports = generators.Base.extend({ init: function () { this.extensions = []; @@ -92,29 +110,24 @@ module.exports = generators.Base.extend({ askForExtension: function () { var done = this.async(); + var choices = _.map(extensions, function (extension) { + return { + name: extension.name, + value: extension.id + }; + }); + this.prompt({ type: 'list', name: 'extension', message: 'Select an extension to install or select `none` to continue', - choices: [ - 'none', - 'aws', - 'github', - { name: 'google analytics', value: 'analytics' }, - { name: 'google calendar', value: 'calendar' }, - { name: 'google sheets', value: 'sheets' }, - 'heroku', - 'image', - 'jenkins', - 'sensu', - 'time', - 'travis', - 'twitter', - 'weather' - ] + choices: choices }, function (answers) { if (answers.extension !== 'none') { - this.extensions.push(answers.extension); + var extension = _.find(extensions, { id: answers.extension }); + if (typeof extension !== 'undefined') { + this.extensions.push(extension); + } return this.prompting.askForExtension.call(this); } diff --git a/generators/app/templates/_package.json b/generators/app/templates/_package.json index 65ec009..65cb0e4 100644 --- a/generators/app/templates/_package.json +++ b/generators/app/templates/_package.json @@ -12,7 +12,7 @@ "gulp-uglify": "^1.1.0", "lodash": "^3.2.0", "mozaik": "*", -<% extensions.forEach(function (extension) { %> "mozaik-ext-<%= extension %>": "*", +<% extensions.forEach(function (extension) { %> "mozaik-ext-<%= extension.id %>": "*", <% }) %> "react": "^0.12.2", "reactify": "^1.0.0", "reflux": "^0.2.5", diff --git a/generators/app/templates/app.js b/generators/app/templates/app.js index bcb5c93..896a12d 100644 --- a/generators/app/templates/app.js +++ b/generators/app/templates/app.js @@ -1,5 +1,7 @@ var mozaik = new (require('mozaik'))(require('./config')); -<% extensions.forEach(function (extension) { %>mozaik.bus.registerApi('<%= extension %>', require('mozaik-ext-<%= extension %>/client')); +<% extensions.filter(function (extension) { + return extension.client === true; +}).forEach(function (extension) { %>mozaik.bus.registerApi('<%= extension.id %>', require('mozaik-ext-<%= extension.id %>/client')); <% }) %> mozaik.startServer(); \ No newline at end of file diff --git a/generators/app/templates/src/App.jsx b/generators/app/templates/src/App.jsx index 580fad9..ae5b522 100644 --- a/generators/app/templates/src/App.jsx +++ b/generators/app/templates/src/App.jsx @@ -3,7 +3,7 @@ var mozaik = require('mozaik/browser'); var Mozaik = mozaik.Component.Mozaik; var ConfigActions = mozaik.Actions.Config; -<% extensions.forEach(function (extension) { %>mozaik.addBatch('<%= extension %>', require('mozaik-ext-<%= extension %>')); +<% extensions.forEach(function (extension) { %>mozaik.addBatch('<%= extension.id %>', require('mozaik-ext-<%= extension.id %>')); <% }) %> React.render(, document.getElementById('mozaik'));