Skip to content

Commit

Permalink
Fix problem with extensions without client
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte committed May 6, 2015
1 parent 4d1eeba commit 6480b10
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
47 changes: 30 additions & 17 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion generators/app/templates/app.js
Original file line number Diff line number Diff line change
@@ -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();
2 changes: 1 addition & 1 deletion generators/app/templates/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<Mozaik />, document.getElementById('mozaik'));

Expand Down

0 comments on commit 6480b10

Please sign in to comment.