Skip to content

Commit

Permalink
v2.0: ng 1.2, bs 3, fa 4, new ngUI, underscore instead of lodash, jqu…
Browse files Browse the repository at this point in the history
…ery 2
  • Loading branch information
Chris Gross committed Dec 30, 2013
1 parent 752893d commit 75bdbfc
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 92 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Features

* Provides a directory structure geared towards large Angular projects.
* Each controller, service, filter, and directive are placed in their own file.
* Provides a directory structure geared towards large Angular projects.
* Each controller, service, filter, and directive are placed in their own file.
* All files related to a conceptual unit are placed together. For example, the controller and HTML file for a partial are placed together in the same directory.
* Provides a ready-made Grunt build that produces an extremely optimized distribution.
* Build uses [grunt-ngmin](https://github.com/btford/grunt-ngmin) so you don't have to use the Angular injection syntax for safe minification (i.e. you dont need `$inject` or `(['$scope','$http',...`.
Expand Down Expand Up @@ -101,7 +101,7 @@ The project will include a ready-made Grunt build that will:

* Build all the LESS files into one minified CSS file.
* Uses [grunt-angular-templates](https://github.com/ericclemmons/grunt-angular-templates) to turn all your partials into Javascript.
* Uses [grunt-ngmin](https://github.com/btford/grunt-ngmin) to preprocess all Angular injectable methods and add the necessary Angular annotations to ensure minification will not break your app (and you don't have to use the array syntax to
* Uses [grunt-ngmin](https://github.com/btford/grunt-ngmin) to preprocess all Angular injectable methods and add the necessary Angular annotations to ensure minification will not break your app (and you don't have to use the array syntax to
manually add the annotations nor $inject). Read more about [ngmin](https://github.com/btford/ngmin).
* Concatenates and minifies all Javascript into one file.
* Replaces all appropriate script references in `index.html` with the minified CSS and JS files.
Expand All @@ -115,6 +115,7 @@ The build process uses [grunt-dom-munger](https://github.com/cgross/grunt-dom-mu

Release History
-------------
* 12/30/2013 - v2.0.0 - Big Update. Angular 1.2 and Bootstrap 3. Newer versions of Angular UI, Font Awesome, and JQuery. Lodash was replaced with Underscore. Lots of other small changes.
* 9/06/2013 - V1.0.4 - Fixed templating issue with generated specs for `yo cg-angular:service` subgenerator.
* 8/29/2013 - V1.0.3 - Renamed `/lib` back to `/bower_components` as clarity trumps brevity. Renamed `/bin` to `/dist`. Fixed spelling error in generated directive's js template location. Moved up to later version of `yeoman-generator` dependency to solve "Cannot read bold of undefined" error coming from Yeoman. JSHint options now read from `.jshintrc`. And more small stuff.
* 7/08/2013 - V1.0.2 - Added utf8 charset to index.html. Fix for "EMFile, too many open files" on `grunt watch` by no longer watching the `lib` folder.
Expand Down
29 changes: 22 additions & 7 deletions app/templates/skeleton/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ var folderMount = function folderMount(connect, point) {
};

module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);

// load all grunt tasks
require('load-grunt-tasks')(grunt);

Expand Down Expand Up @@ -58,7 +57,17 @@ module.exports = function (grunt) {
ngtemplates: {
main: {
options: {
module:'<%= _.slugify(appname) %>'
module:'<%= _.slugify(appname) %>',
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}
},
src: [ 'partial/**/*.html','directive/**/*.html' ],
dest: 'temp/templates.js'
Expand All @@ -69,10 +78,10 @@ module.exports = function (grunt) {
files: [
{src: ['index.html'], dest: 'dist/'},
{src: ['img/**'], dest: 'dist/'},
{src: ['bower_components/angular-ui/build/angular-ui-ieshiv.js'], dest: 'dist/'},
{src: ['bower_components/font-awesome/build/assets/font-awesome/font/**'], dest: 'dist/',filter:'isFile',expand:true},
{src: ['bower_components/angular-ui-utils/ui-utils-ieshiv.min.js'], dest: 'dist/'},
{src: ['bower_components/font-awesome/fonts/**'], dest: 'dist/',filter:'isFile',expand:true}
// {src: ['bower_components/select2/*.png','bower_components/select2/*.gif'], dest:'dist/css/',flatten:true,expand:true},
{src: ['bower_components/angular-mocks/angular-mocks.js'], dest: 'dist/'}
// {src: ['bower_components/angular-mocks/angular-mocks.js'], dest: 'dist/'}
]
}
},
Expand Down Expand Up @@ -143,8 +152,14 @@ module.exports = function (grunt) {
htmlmin: {
main: {
options: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
collapseWhitespace: true
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
},
files: {
'dist/index.html': 'dist/index.html'
Expand Down
27 changes: 14 additions & 13 deletions app/templates/skeleton/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
"bower_components"
],
"dependencies": {
"jquery": "1.x",
"lodash": "~1.2.1",
"bootstrap": "~2.3.2",
"angular": "~1.0.7",
"angular-resource": "~1.0.7",
"angular-cookies": "~1.0.7",
"angular-mocks": "~1.0.7",
"angular-ui": "~0.4.0",
"angular-ui-utils": "~0.0.2",
"angular-bootstrap": "~0.3.0",
"moment": "~2.0.0",
"less.js": "~1.4.0",
"font-awesome": "~3.1.1"
"jquery": "~2.0",
"underscore": "~1.5",
"bootstrap": "~3.0",
"angular": "~1.2",
"angular-route": "~1.2",
"angular-animate": "~1.2",
"angular-resource": "~1.2",
"angular-cookies": "~1.2",
"angular-mocks": "~1.2",
"angular-ui-utils": "~0.1",
"angular-bootstrap": "~0.9",
"moment": "~2.5",
"less.js": "~1.5",
"font-awesome": "~4.0"
}
}
22 changes: 19 additions & 3 deletions app/templates/skeleton/css/app.less
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
@import "../bower_components/bootstrap/less/bootstrap.less";
@import "../bower_components/font-awesome/build/assets/font-awesome/less/font-awesome.less";
@FontAwesomePath: "../bower_components/font-awesome/build/assets/font-awesome/font";
//@import "../bower_components/bootstrap/less/theme.less";
@import "../bower_components/font-awesome/less/font-awesome.less";
@fa-font-path: "../bower_components/font-awesome/fonts";

/* Directive LESS */
/* Add Directive LESS Above */

/* Partial LESS */
/* Add Partial LESS Above */
/* Add Partial LESS Above */

/* Required for Angular UI Bootstrap */
.nav, .pagination, .carousel a { cursor: pointer; }

/* Personal preference for BS modal. The LESS below makes the backdrop white and
causes the modal to fade in rather than slide in. */
//@modal-backdrop-bg: white;
//.modal {
// &.fade {
// .transition(opacity .3s);
// }
// &.fade .modal-dialog {
// .translate(0,0);
// }
//}
35 changes: 10 additions & 25 deletions app/templates/skeleton/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
<html ng-app="<%= _.slugify(appname) %>">
<head>
<title></title>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">

<!-- CSS from Bower components -->
<link href="bower_components/angular-ui/build/angular-ui.css" rel="stylesheet">

<!-- App LESS -->
<link href="css/app.less" type="text/css" rel="stylesheet/less">

Expand All @@ -19,35 +15,24 @@
<script src="http://localhost:35729/livereload.js" data-build="exclude"></script>

<!-- JS from Bower components -->
<script src="bower_components/less.js/dist/less-1.4.0.js" data-build="exclude"></script>
<script src="bower_components/less.js/dist/less-1.5.0.js" data-build="exclude"></script>
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/lodash/dist/lodash.compat.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-affix.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-alert.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-button.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-carousel.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-collapse.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-dropdown.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-modal.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-tooltip.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-popover.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-scrollspy.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-tab.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-transition.js"></script>
<script src="bower_components/bootstrap/js/bootstrap-typeahead.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/underscore/underscore.js"></script>
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-ui/build/angular-ui.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/moment/min/moment.min.js"></script>
<script src="bower_components/angular-ui-utils/ui-utils.js"></script>


<!-- Main App JS -->
<script src="js/setup.js"></script>

<!-- Service JS -->
<!-- Add New Service JS Above -->
<!-- Add New Service JS Above -->

<!-- Directive JS -->
<!-- Add New Directive JS Above -->
Expand Down
2 changes: 1 addition & 1 deletion app/templates/skeleton/js/setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('<%= _.slugify(appname) %>', ['ui.bootstrap','ui']);
angular.module('<%= _.slugify(appname) %>', ['ui.bootstrap','ui.utils','ngRoute','ngAnimate']);

angular.module('<%= _.slugify(appname) %>').config(function($routeProvider) {

Expand Down
39 changes: 18 additions & 21 deletions app/templates/skeleton/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
{
"name": "<%= _.slugify(appname) %>",
"version": "0.1.0",
"version": "0.0.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-livereload": "~0.1.2",
"grunt-contrib-connect": "~0.2.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-cssmin": "~0.5.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-jasmine-task": "0.2.x",
"grunt-angular-templates": "~0.3.1",
"grunt-contrib-jshint": "~0.3.0",
"grunt-dom-munger": "~2.0.0",
"grunt-contrib-htmlmin": "~0.1.1",
"grunt-contrib-imagemin": "~0.1.2",
"grunt-ngmin": "0.0.2",
"grunt-contrib-less": "~0.6.0",
"grunt-contrib-watch": "~0.4.4",
"grunt-contrib-jasmine": "~0.5.1",
"time-grunt": "~0.1.1",
"load-grunt-tasks": "~0.2.0"
"grunt": "~0.4",
"grunt-dom-munger": "~3.1",
"grunt-angular-templates": "~0.5",
"grunt-ngmin": "0.0.3",
"grunt-contrib-connect": "~0.6",
"grunt-contrib-copy": "~0.5",
"grunt-contrib-clean": "~0.5",
"grunt-contrib-concat": "~0.3",
"grunt-contrib-cssmin": "~0.7",
"grunt-contrib-uglify": "~0.2",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-htmlmin": "~0.1",
"grunt-contrib-imagemin": "~0.4",
"grunt-contrib-less": "~0.8",
"grunt-contrib-watch": "~0.5",
"grunt-contrib-jasmine": "~0.5",
"load-grunt-tasks": "~0.2"
}
}
2 changes: 1 addition & 1 deletion directive/templates/directive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('<%= appname %>').directive('<%= _.classify(name) %>', function() {
angular.module('<%= appname %>').directive('<%= _.camelize(name) %>', function() {
return {
restrict: 'E',
replace: true,
Expand Down
2 changes: 1 addition & 1 deletion directive/templates/directive_simple.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('<%= appname %>').directive('<%= _.classify(name) %>', function() {
angular.module('<%= appname %>').directive('<%= _.camelize(name) %>', function() {
return {
restrict: 'A',
link: function(scope, element, attrs, fn) {
Expand Down
2 changes: 1 addition & 1 deletion directive/templates/spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('<%= _.classify(name) %>', function() {
describe('<%= _.camelize(name) %>', function() {

beforeEach(module('<%= appname %>'));

Expand Down
2 changes: 1 addition & 1 deletion filter/templates/filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('<%= appname %>').filter('<%= name %>', function() {
angular.module('<%= appname %>').filter('<%= _.camelize(name) %>', function() {
return function(input,arg) {
return '';
};
Expand Down
4 changes: 2 additions & 2 deletions filter/templates/spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
describe('<%= name %>', function() {
describe('<%= _.camelize(name) %>', function() {

beforeEach(module('<%= appname %>'));

it('should ...', inject(function($filter) {

var filter = $filter('<%= name %>');
var filter = $filter('<%= _.camelize(name) %>');

expect(filter('input')).toEqual('filter result');

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-cg-angular",
"version": "1.0.4",
"version": "2.0.0",
"description": "Yeoman Generator for Enterprise Angular projects.",
"keywords": [
"yeoman-generator"
Expand All @@ -21,9 +21,9 @@
"test": "mocha"
},
"dependencies": {
"yeoman-generator": "~0.13.0",
"underscore": "~1.4.4",
"underscore.string": "~2.3.1"
"yeoman-generator": "~0.15",
"underscore": "~1.5",
"underscore.string": "~2.3"
},
"devDependencies": {
"mocha": "~1.10.0"
Expand Down
2 changes: 1 addition & 1 deletion partial/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ PartialGenerator.prototype.askFor = function askFor() {

PartialGenerator.prototype.files = function files() {

this.ctrlname = _.classify(this.name) + 'Ctrl';
this.ctrlname = _.camelize(_.classify(this.name)) + 'Ctrl';

this.template('partial.js', 'partial/'+this.name+'/'+this.name+'.js');
this.template('partial.html', 'partial/'+this.name+'/'+this.name+'.html');
Expand Down
2 changes: 1 addition & 1 deletion partial/templates/partial.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="span12" ng-controller="<%= ctrlname %>">
<div class="col-md-12" ng-controller="<%= ctrlname %>">


</div>
6 changes: 3 additions & 3 deletions service/templates/service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module('<%= appname %>').factory('<%= name %>',function() {
angular.module('<%= appname %>').factory('<%= _.camelize(name) %>',function() {

var <%= name %> = {};
var <%= _.camelize(name) %> = {};

return <%= name %>;
return <%= _.camelize(name) %>;
});
6 changes: 3 additions & 3 deletions service/templates/spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
describe('<%= name %>', function() {
describe('<%= _.camelize(name) %>', function() {

beforeEach(module('<%= appname %>'));

it('should ...', inject(function(<%= name %>) {
it('should ...', inject(function(<%= _.camelize(name) %>) {

//expect(<%= name %>.doSomething()).toEqual('something');
//expect(<%= _.camelize(name) %>.doSomething()).toEqual('something');

}));

Expand Down
1 change: 0 additions & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var path = require('path');
var fs = require('fs');

exports.addToFile = function(filename,lineToAdd,beforeMarker,spacing){

try {
var fullPath = path.join(process.cwd(),filename);
var fileSrc = fs.readFileSync(fullPath,'utf8');
Expand Down

0 comments on commit 75bdbfc

Please sign in to comment.