Skip to content

Commit

Permalink
fix(app): Add option for angular-material
Browse files Browse the repository at this point in the history
Fixes #77
  • Loading branch information
jskrzypek committed Mar 11, 2015
1 parent a03a92a commit 043d50f
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 7 deletions.
9 changes: 9 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ var AppGenerator = Class.extend({
type: 'confirm',
message: 'Would you like to include ngCordova?',
default: true
}, {
name: 'material',
type: 'confirm',
message: 'Would you like to include angular-material?',
default: true
}, {
name: 'fontawesome',
type: 'confirm',
Expand All @@ -101,6 +106,7 @@ var AppGenerator = Class.extend({
this.famous = answers.famous;
this.ngCordova = answers.ngCordova;
this.fontawesome = answers.fontawesome;
this.material = answers.material;
this.bootstrap = answers.bootstrap;
this.mobile = this.options.mobile;

Expand All @@ -111,6 +117,7 @@ var AppGenerator = Class.extend({
famous: answers.famous,
fontawesome: answers.fontawesome,
bootstrap: answers.bootstrap,
material: answers.material,
lint: true,
serve: true,
browserify: true,
Expand All @@ -119,6 +126,7 @@ var AppGenerator = Class.extend({
test: true,
style: true,
dist: true
// pass answers.material
}
});
done();
Expand Down Expand Up @@ -170,6 +178,7 @@ var AppGenerator = Class.extend({
this.config.set('ngCordova', this.ngCordova);
this.config.set('fontawesome', this.fontawesome);
this.config.set('bootstrap', this.bootstrap);
this.config.set('material', this.material);
this.config.forceSave();
},

Expand Down
1 change: 1 addition & 0 deletions module/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var ModuleGenerator = Class.extend({
this.ionic = this.config.get('ionic');
this.famous = this.config.get('famous');
this.ngCordova = this.config.get('ngCordova');
this.material = this.config.get('material');
this.ngModules = utils.getNgModules(this);
},

Expand Down
3 changes: 2 additions & 1 deletion target/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ var TargetGenerator = Class.extend({
this.ionic = this.config.get('ionic');
this.famous = this.config.get('famous');
this.fontawesome = this.config.get('fontawesome');
this.bootstrap = this.config.get('boostrap');
this.bootstrap = this.config.get('bootstrap');
this.material = this.config.get('material');
},

initializing: function() {
Expand Down
5 changes: 3 additions & 2 deletions templates/app/_bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
"famous-angular": "0.5.0"<% } %><% if (ngCordova) { %>,
"ngCordova": "0.1.9-alpha"<% } %><% if (fontawesome) { %>,
"font-awesome": "4.2.0"<% } %><% if (bootstrap) { %>,
"angular-bootstrap": "0.12.0",
"bootstrap": "3.3.1"<% } %>
"angular-bootstrap": "0.12.0",
"bootstrap": "3.3.1"<% } %><% if (material) { %>,
"angular-material": "0.8.3"<% } %>
},
"resolutions": {
"angular": "1.3.6"
Expand Down
14 changes: 12 additions & 2 deletions templates/app/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"famous-angular": "./bower_components/famous-angular/dist/famous-angular.js"<% } %><% if(ngCordova) { %>,
"ngCordova": "./bower_components/ngCordova/dist/ng-cordova.js",
"ngCordovaMocks": "./bower_components/ngCordova/dist/ng-cordova-mocks.js"<% } %><% if(bootstrap) { %>,
"angular-bootstrap": "./bower_components/angular-bootstrap/ui-bootstrap-tpls.js"<% } %>
"angular-bootstrap": "./bower_components/angular-bootstrap/ui-bootstrap-tpls.js"<% } %><% if(material) { %>,
"angular-material": "./bower_components/angular-material/angular-material.js",
"angular-aria": "./bower_components/angular-aria/angular-aria.js"<% } %>
},
"browserify": {
"transform": [
Expand Down Expand Up @@ -93,6 +95,14 @@
"angular"
],
"exports": "angular.module('ui.bootstrap').name"
}<% } %>
}<% } %><% if(material) { %>,
"angular-material": {
"depends": [
"angular",
"angular-aria",
"angular-animate"
]
}<% } %>

}
}
1 change: 1 addition & 0 deletions templates/module/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
require('angular-ui-router');
<% if (ionic) { %>require('angular-ionic');<% } %>
<% if (material) { %>require('angular-material');<% } %>
<% if (famous) { %>require('famous-angular');<% } %>
<% if (ngCordova) { %>require('ngCordova');<% } %>

Expand Down
3 changes: 2 additions & 1 deletion templates/target/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var namespace = 'main';

var angular = require('angular');
<% if (ionic) { %>require('angular-ionic');<% } %>
var app = angular.module(namespace, [<% if (ionic) { %>'ionic',<% } %>
<% if (material) { %>require('angular-material');<% } %>
var app = angular.module(namespace, [<% if (ionic) { %>'ionic',<% } %><% if (material) { %>'ngMaterial',<% } %>
// inject:modules start
// inject:modules end
]);
Expand Down
1 change: 1 addition & 0 deletions test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('angular-famous-ionic:app', function() {
assert(config['generator-angular-famous-ionic'].ionic !== undefined, 'ionic does not exist in .yo-rc.json');
assert(config['generator-angular-famous-ionic'].famous !== undefined, 'famous does not exist in .yo-rc.json');
assert(config['generator-angular-famous-ionic'].ngCordova !== undefined, 'ngCordova does not exist in .yo-rc.json');
assert(config['generator-angular-famous-ionic'].material !== undefined, 'angular-material does not exist in .yo-rc.json');
assert(config['generator-angular-famous-ionic'].clientFolder !== undefined, 'clientFolder does not exist in .yo-rc.json');

done();
Expand Down
37 changes: 36 additions & 1 deletion test/module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,37 @@ describe('angular-famous-ionic:module', function() {

});

it('should include angular-material with material', function(done) {
testHelper.runGenerator('module')
.withOptions({
'skip-install': true,
'check-travis': false,
'check-git': true
})
.withPrompt({
modulename: modulename
})
.on('ready', function(generator) {
generator.clientFolder = clientFolder;
generator.log = sinon.spy();

generator.afterInitializing = function() {
generator.material = true;
generator.ngModules = utils.getNgModules(generator);
};
generator.mkdir(clientFolder + '/scripts/toto');
generator.mkdir(clientFolder + '/scripts/tata');
})
.on('end', function() {
var file = clientFolder + '/scripts/' + modulename + '/index.js';
var body = testHelper.readTextFile(file);
assert(_.contains(body, 'require(\'angular-material\');'));
assert(_.contains(body, '\'ngMaterial\''));
done();
});

});

it('should include ngCordova', function(done) {
testHelper.runGenerator('module')
.withOptions({
Expand Down Expand Up @@ -274,7 +305,7 @@ describe('angular-famous-ionic:module', function() {

});

it('should include famous-angular and angular-ionic with famous, ionic and ngCordova', function(done) {
it('should include famous-angular and angular-ionic with famous, ionic, ngCordova, and material', function(done) {
testHelper.runGenerator('module')
.withOptions({
'skip-install': true,
Expand All @@ -292,6 +323,7 @@ describe('angular-famous-ionic:module', function() {
generator.famous = true;
generator.ionic = true;
generator.ngCordova = true;
generator.material = true;
generator.ngModules = utils.getNgModules(generator);

};
Expand All @@ -305,6 +337,7 @@ describe('angular-famous-ionic:module', function() {
assert(_.contains(body, 'require(\'famous-angular\');'));
assert(_.contains(body, 'require(\'angular-ionic\');'));
assert(_.contains(body, 'require(\'ngCordova\');'));
assert(_.contains(body, 'require(\'angular-material\');'));
assert(_.contains(body, '\'ionic\''));
assert(_.contains(body, '\'famous.angular\''));
done();
Expand All @@ -331,6 +364,7 @@ describe('angular-famous-ionic:module', function() {
generator.famous = true;
generator.ionic = true;
generator.ngCordova = true;
generator.material = true;
generator.ngModules = utils.getNgModules(generator);

};
Expand Down Expand Up @@ -370,6 +404,7 @@ describe('angular-famous-ionic:module', function() {
generator.famous = true;
generator.ionic = true;
generator.ngCordova = true;
generator.material = true;
generator.ngModules = utils.getNgModules(generator);

};
Expand Down
1 change: 1 addition & 0 deletions test/testHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ var testHelper = {
generator.ionic = true;
generator.famous = true;
generator.ngCordova = true;
generator.material = true;
generator.ngModules = [];
generator.skipRoute = false;
}
Expand Down
3 changes: 3 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,8 @@ exports.getNgModules = function(generator) {
if(generator.ngCordova) {
retVal.push('\'ngCordova\'');
}
if(generator.material) {
retVal.push('\'ngMaterial\'');
}
return retVal.join(', ');
};

0 comments on commit 043d50f

Please sign in to comment.