diff --git a/.gitignore b/.gitignore
index 7a1537ba..aa461ff9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.idea
node_modules
+bower_components
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 47430c17..79bda212 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,12 +5,13 @@
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- - npm install -g grunt-cli@0.1.x karma@0.8.x
+ - npm install -g gulp karma bower
- cd server
- npm install --quiet
- node server.js &
- sleep 3 # give server some time to start
- cd ../client
- npm install --quiet
+ - bower install --quiet
- script: grunt release
+ script: gulp
diff --git a/README.md b/README.md
index 27a8e0cf..d25f1f61 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
## Purpose
-The idea is to **demonstrate how to write a typical, non-trivial CRUD application using AngularJS**. To showcase AngularJS in its most advantageous environment we've set out to write a simplified project management tool supporting teams using the SCRUM methodology. The sample application tries to show best practices when it comes to: folders structure, using modules, testing, communicating with a REST back-end, organizing navigation, addressing security concerns (authentication / authorization).
+The idea is to **demonstrate how to write a typical, non-trivial [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) application using AngularJS**. To showcase AngularJS in its most advantageous environment we've set out to write a simplified project management tool supporting teams using the [SCRUM](http://en.wikipedia.org/wiki/Scrum_(software_development)) methodology. The sample application tries to show best practices when it comes to: folders structure, using modules, testing, communicating with a REST back-end, organizing navigation, addressing security concerns (authentication / authorization).
This sample application is featured in our [book](http://goo.gl/gKEsIo) where you can find detailed description of the patterns and techniques used to write this code:
@@ -19,16 +19,15 @@ We've learned a lot while using and supporting AngularJS on the [mailing list](h
* Persistence store: [MongoDB](http://www.mongodb.org/) hosted on [MongoLab](https://mongolab.com/)
* Backend: [Node.js](http://nodejs.org/)
* Awesome [AngularJS](http://www.angularjs.org/) on the client
-* CSS based on [Twitter's bootstrap](http://getbootstrap.com/)
+* CSS based on [Bootstrap](http://getbootstrap.com/)
### Build
It is a complete project with a build system focused on AngularJS apps and tightly integrated with other tools commonly used in the AngularJS community:
-* powered by [Grunt.js](http://gruntjs.com/)
+* powered by [gulp.js](http://gulpjs.com/)
* test written using [Jasmine](http://jasmine.github.io/) syntax
-* test are executed by [Karma Test Runner](http://karma-runner.github.io/0.8/index.html) (integrated with the Grunt.js build)
+* test are executed by [Karma Test Runner](http://karma-runner.github.io/) (integrated with the gulp.js build)
* build supporting JS, CSS and AngularJS templates minification
-* [Twitter's bootstrap](http://getbootstrap.com/) with LESS templates processing integrated into the build
* [Travis-CI](https://travis-ci.org/) integration
## Installation
@@ -37,14 +36,12 @@ It is a complete project with a build system focused on AngularJS apps and tight
You need to install Node.js and then the development tools. Node.js comes with a package manager called [npm](http://npmjs.org) for installing NodeJS applications and libraries.
* [Install node.js](http://nodejs.org/download/) (requires node.js version >= 0.8.4)
-* Install Grunt-CLI and Karma as global npm modules:
+* Install gulp and Karma runner as global npm modules:
```
- npm install -g grunt-cli karma
+ npm install -g gulp karma
```
-(Note that you may need to uninstall grunt 0.3 globally before installing grunt-cli)
-
### Get the Code
Either clone this repository or fork it on GitHub and clone your fork:
@@ -71,7 +68,7 @@ Our backend application server is a NodeJS application that relies upon some 3rd
### Client App
Our client application is a straight HTML/Javascript application but our development process uses a Node.js build tool
-[Grunt.js](gruntjs.com). Grunt relies upon some 3rd party libraries that we need to install as local dependencies using npm.
+[gulp.js](gulpjs.com). gulp relies upon some 3rd party libraries that we need to install as local dependencies using npm.
* Install local dependencies (from the project root folder):
@@ -129,12 +126,12 @@ angular.module('app').constant('MONGOLAB_CONFIG', {
```
### Build the client app
-The app made up of a number of javascript, css and html files that need to be merged into a final distribution for running. We use the Grunt build tool to do this.
+The app made up of a number of javascript, css and html files that need to be merged into a final distribution for running. We use the gulp build tool to do this.
* Build client application:
```
cd client
- grunt build
+ gulp
cd ..
```
@@ -163,37 +160,26 @@ testing against browsers that you need to support.
### Folders structure
At the top level, the repository is split into a client folder and a server folder. The client folder contains all the client-side AngularJS application. The server folder contains a very basic Express based webserver that delivers and supports the application.
Within the client folder you have the following structure:
-* `node_modules` contains build tasks for Grunt along with other, user-installed, Node packages
+* `node_modules` contains build tasks for gulp along with other, user-installed, Node packages
* `dist` contains build results
* `src` contains application's sources
* `test` contains test sources, configuration and dependencies
* `vendor` contains external dependencies for the application
### Default Build
-The default grunt task will build (checks the javascript (lint), runs the unit tests (test:unit) and builds distributable files) and run all unit tests: `grunt` (or `grunt.cmd` on Windows). The tests are run by karma and need one or more browsers open to actually run the tests.
+The default gulp task will build (checks the javascript (`lint`), runs the unit tests (`test``) and builds distributable files:
* `cd client`
-* `grunt`
-* Open one or more browsers and point them to [http://localhost:8080/__test/]. Once the browsers connect the tests will run and the build will complete.
-* If you leave the browsers open at this url then future runs of `grunt` will automatically run the tests against these browsers.
+* `gulp`
### Continuous Building
-The watch grunt task will monitor the source files and run the default build task every time a file changes: `grunt watch`.
+The watch gulp task will monitor the source files and run the default build task every time a file changes: `gulp watch`.
### Build without tests
-If for some reason you don't want to run the test but just generate the files - not a good idea(!!) - you can simply run the build task: `grunt build`.
-
-### Building release code
-You can build a release version of the app, with minified files. This task will also run the "end to end" (e2e) tests.
-The e2e tests require the server to be started and also one or more browsers open to run the tests. (You can use the same browsers as for the unit tests.)
-* `cd client`
-* Run `grunt release`
-* Open one or more browsers and point them to [http://localhost:8080/__test/]. Once the browsers connect the tests will run and the build will complete.
-* If you leave the browsers open at this url then future runs of `grunt` will automatically run the tests against these browsers.
+If for some reason you don't want to run the test but just generate the files - not a good idea(!!) - you can simply run the build task: `gulp build`.
### Continuous testing
-You can have grunt (karma) continuously watch for file changes and automatically run all the tests on every change, without rebuilding the distribution files. This can make the test run faster when you are doing test driven development and don't need to actually run the application itself.
+You can have gulp (karma) continuously watch for file changes and automatically run all the tests on every change, without rebuilding the distribution files. This can make the test run faster when you are doing test driven development and don't need to actually run the application itself.
* `cd client`
-* Run `grunt test-watch`.
-* Open one or more browsers and point them to [http://localhost:8080/__test/].
-* Each time a file changes the tests will be run against each browser.
+* Run `gulp tdd`. In the default configuration it will start a new instance of Chrome.
+* The task will wait for code changes, re-executing tests on each change.
\ No newline at end of file
diff --git a/client/bower.json b/client/bower.json
new file mode 100644
index 00000000..bfa5d5bb
--- /dev/null
+++ b/client/bower.json
@@ -0,0 +1,27 @@
+{
+ "name": "angular-app",
+ "version": "0.0.0",
+ "homepage": "https://github.com/angular-app/angular-app",
+ "authors": [
+ "Pawel Kozlowski & Peter Bacon Darwin"
+ ],
+ "description": "a simplified project management tool supporting teams using the SCRUM methodology - demonstrating AngularJS",
+ "license": "MIT",
+ "private": true,
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ],
+ "dependencies": {
+ "angularjs": "~1.3.0",
+ "angular-route": "~1.3.0",
+ "angular-mocks": "~1.3.0",
+ "jquery": "~2.1.1",
+ "angularjs-mongolab": "*",
+ "angular-bootstrap": "~0.11.0",
+ "bootstrap-css": "~3.2.0"
+ }
+}
diff --git a/client/gruntFile.js b/client/gruntFile.js
deleted file mode 100644
index 3eb736d3..00000000
--- a/client/gruntFile.js
+++ /dev/null
@@ -1,182 +0,0 @@
-module.exports = function (grunt) {
-
- grunt.loadNpmTasks('grunt-contrib-concat');
- grunt.loadNpmTasks('grunt-contrib-jshint');
- grunt.loadNpmTasks('grunt-contrib-uglify');
- grunt.loadNpmTasks('grunt-contrib-clean');
- grunt.loadNpmTasks('grunt-contrib-copy');
- grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-recess');
- grunt.loadNpmTasks('grunt-karma');
- grunt.loadNpmTasks('grunt-html2js');
-
- // Default task.
- grunt.registerTask('default', ['jshint','build','karma:unit']);
- grunt.registerTask('build', ['clean','html2js','concat','recess:build','copy:assets']);
- grunt.registerTask('release', ['clean','html2js','uglify','jshint','karma:unit','concat:index', 'recess:min','copy:assets']);
- grunt.registerTask('test-watch', ['karma:watch']);
-
- // Print a timestamp (useful for when watching)
- grunt.registerTask('timestamp', function() {
- grunt.log.subhead(Date());
- });
-
- var karmaConfig = function(configFile, customOptions) {
- var options = { configFile: configFile, keepalive: true };
- var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' };
- return grunt.util._.extend(options, customOptions, travisOptions);
- };
-
- // Project configuration.
- grunt.initConfig({
- distdir: 'dist',
- pkg: grunt.file.readJSON('package.json'),
- banner:
- '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
- '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
- ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' +
- ' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */\n',
- src: {
- js: ['src/**/*.js'],
- jsTpl: ['<%= distdir %>/templates/**/*.js'],
- specs: ['test/**/*.spec.js'],
- scenarios: ['test/**/*.scenario.js'],
- html: ['src/index.html'],
- tpl: {
- app: ['src/app/**/*.tpl.html'],
- common: ['src/common/**/*.tpl.html']
- },
- less: ['src/less/stylesheet.less'], // recess:build doesn't accept ** in its file patterns
- lessWatch: ['src/less/**/*.less']
- },
- clean: ['<%= distdir %>/*'],
- copy: {
- assets: {
- files: [{ dest: '<%= distdir %>', src : '**', expand: true, cwd: 'src/assets/' }]
- }
- },
- karma: {
- unit: { options: karmaConfig('test/config/unit.js') },
- watch: { options: karmaConfig('test/config/unit.js', { singleRun:false, autoWatch: true}) }
- },
- html2js: {
- app: {
- options: {
- base: 'src/app'
- },
- src: ['<%= src.tpl.app %>'],
- dest: '<%= distdir %>/templates/app.js',
- module: 'templates.app'
- },
- common: {
- options: {
- base: 'src/common'
- },
- src: ['<%= src.tpl.common %>'],
- dest: '<%= distdir %>/templates/common.js',
- module: 'templates.common'
- }
- },
- concat:{
- dist:{
- options: {
- banner: "<%= banner %>"
- },
- src:['<%= src.js %>', '<%= src.jsTpl %>'],
- dest:'<%= distdir %>/<%= pkg.name %>.js'
- },
- index: {
- src: ['src/index.html'],
- dest: '<%= distdir %>/index.html',
- options: {
- process: true
- }
- },
- angular: {
- src:['vendor/angular/angular.js', 'vendor/angular/angular-route.js'],
- dest: '<%= distdir %>/angular.js'
- },
- mongo: {
- src:['vendor/mongolab/*.js'],
- dest: '<%= distdir %>/mongolab.js'
- },
- bootstrap: {
- src:['vendor/angular-ui/bootstrap/*.js'],
- dest: '<%= distdir %>/bootstrap.js'
- },
- jquery: {
- src:['vendor/jquery/*.js'],
- dest: '<%= distdir %>/jquery.js'
- }
- },
- uglify: {
- dist:{
- options: {
- banner: "<%= banner %>"
- },
- src:['<%= src.js %>' ,'<%= src.jsTpl %>'],
- dest:'<%= distdir %>/<%= pkg.name %>.js'
- },
- angular: {
- src:['<%= concat.angular.src %>'],
- dest: '<%= distdir %>/angular.js'
- },
- mongo: {
- src:['vendor/mongolab/*.js'],
- dest: '<%= distdir %>/mongolab.js'
- },
- bootstrap: {
- src:['vendor/angular-ui/bootstrap/*.js'],
- dest: '<%= distdir %>/bootstrap.js'
- },
- jquery: {
- src:['vendor/jquery/*.js'],
- dest: '<%= distdir %>/jquery.js'
- }
- },
- recess: {
- build: {
- files: {
- '<%= distdir %>/<%= pkg.name %>.css':
- ['<%= src.less %>'] },
- options: {
- compile: true
- }
- },
- min: {
- files: {
- '<%= distdir %>/<%= pkg.name %>.css': ['<%= src.less %>']
- },
- options: {
- compress: true
- }
- }
- },
- watch:{
- all: {
- files:['<%= src.js %>', '<%= src.specs %>', '<%= src.lessWatch %>', '<%= src.tpl.app %>', '<%= src.tpl.common %>', '<%= src.html %>'],
- tasks:['default','timestamp']
- },
- build: {
- files:['<%= src.js %>', '<%= src.specs %>', '<%= src.lessWatch %>', '<%= src.tpl.app %>', '<%= src.tpl.common %>', '<%= src.html %>'],
- tasks:['build','timestamp']
- }
- },
- jshint:{
- files:['gruntFile.js', '<%= src.js %>', '<%= src.jsTpl %>', '<%= src.specs %>', '<%= src.scenarios %>'],
- options:{
- curly:true,
- eqeqeq:true,
- immed:true,
- latedef:true,
- newcap:true,
- noarg:true,
- sub:true,
- boss:true,
- eqnull:true,
- globals:{}
- }
- }
- });
-
-};
diff --git a/client/gulpfile.js b/client/gulpfile.js
new file mode 100644
index 00000000..2ba63696
--- /dev/null
+++ b/client/gulpfile.js
@@ -0,0 +1,171 @@
+var gulp = require('gulp');
+var templateCache = require('gulp-angular-templatecache');
+var jshint = require('gulp-jshint');
+var concat = require('gulp-concat');
+var uglify = require('gulp-uglify');
+var template = require('gulp-template');
+var header = require('gulp-header');
+var htmlmin = require('gulp-htmlmin');
+var protractor = require("gulp-protractor").protractor;
+
+var merge = require('merge-stream');
+var rimraf = require('rimraf');
+var _ = require('lodash');
+
+var karma = require('karma').server;
+
+var package = require('./package.json');
+
+var karmaCommonConf = {
+ browsers: process.env.TRAVIS ? ['SL_Chrome', 'SL_Firefox', 'SL_Safari', 'SL_IE_11'] : ['Chrome'],
+ customLaunchers: {
+ 'SL_Chrome': {
+ base: 'SauceLabs',
+ browserName: 'chrome',
+ platform: 'Linux',
+ version: '36'
+ },
+ 'SL_Firefox': {
+ base: 'SauceLabs',
+ browserName: 'firefox',
+ platform: 'Linux',
+ version: '31'
+ },
+ 'SL_Safari': {
+ base: 'SauceLabs',
+ browserName: 'safari',
+ platform: 'OS X 10.9',
+ version: '7'
+ },
+ 'SL_IE_11': {
+ base: 'SauceLabs',
+ browserName: 'internet explorer',
+ platform: 'Windows 8.1',
+ version: '11'
+ }
+ },
+ frameworks: ['jasmine'],
+ preprocessors: {
+ 'src/**/*.tpl.html': ['ng-html2js']
+ },
+ files: [
+ 'bower_components/jquery/dist/jquery.js',
+ 'bower_components/angular/angular.js',
+ 'bower_components/angular-route/angular-route.js',
+ 'bower_components/angularjs-mongolab/src/angular-mongolab.js',
+ 'bower_components/angular-mocks/angular-mocks.js',
+ 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
+ 'src/**/*.tpl.html',
+ 'src/**/*.js',
+ 'test/unit/**/*.spec.js'
+ ],
+ reporters: process.env.TRAVIS ? ['dots', 'saucelabs'] : ['progress'],
+ ngHtml2JsPreprocessor: {
+ cacheIdFromPath: function(filepath) {
+ //cut off src/common/ and src/app/ prefixes, if present
+ //we do this so in directives we can refer to templates in a way
+ //that those templates can be served by a web server during dev time
+ //without any need to bundle them
+ return filepath.replace('src/common/', '').replace('src/app/', '');
+ }
+ },
+ sauceLabs: {
+ username: 'pkozlowski',
+ accessKey: '173aa66e-43e6-4e34-b873-9cb037b8ae5c',
+ testName: 'angular-app tests'
+ }
+};
+
+
+gulp.task('build-index', function () {
+ return gulp.src('src/index.html')
+ .pipe(template({
+ pkg: package,
+ year: new Date()
+ }))
+ .pipe(gulp.dest('dist'));
+});
+
+gulp.task('build-js', function () {
+
+ var now = new Date();
+
+ var htmlMinOpts = {
+ collapseWhitespace: true,
+ conservativeCollapse: true
+ };
+
+ return merge(
+ gulp.src('src/**/*.js'),
+ gulp.src('src/app/**/*.tpl.html').pipe(htmlmin(htmlMinOpts)).pipe(templateCache({standalone: true, module: 'templates.app'})),
+ gulp.src('src/common/**/*.tpl.html').pipe(htmlmin(htmlMinOpts)).pipe(templateCache({standalone: true, module: 'templates.common'}))
+ ).pipe(concat(package.name + '.js'))
+ .pipe(uglify())
+ .pipe(header(
+ '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= buildDate %>\n' +
+ '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
+ ' * Copyright (c) <%= copyrightYear %> <%= pkg.author %>;\n' +
+ ' * Licensed <%= pkg.licenses[0].type %>\n */\n',
+ {
+ pkg: package,
+ buildDate: now,
+ copyrightYear: now.getFullYear()
+ }))
+ .pipe(gulp.dest('dist'));
+});
+
+gulp.task('copy-static', function () {
+ return merge(
+ gulp.src('bower_components/bootstrap-css/css/*.css').pipe(gulp.dest('dist/css')),
+ gulp.src('bower_components/bootstrap-css/fonts/*').pipe(gulp.dest('dist/fonts')),
+ merge(
+ gulp.src('src/assets/**/*.*'),
+ gulp.src(['bower_components/angular/angular.js', 'bower_components/angular-route/angular-route.js']).pipe(concat('angular.js')),
+ gulp.src('bower_components/angular-bootstrap/ui-bootstrap-tpls.js'),
+ gulp.src('bower_components/jquery/dist/jquery.js'),
+ gulp.src('bower_components/angularjs-mongolab/src/*.js')
+ ).pipe(gulp.dest('dist'))
+ );
+});
+
+gulp.task('clean', function (done) {
+ return rimraf('dist', done);
+});
+
+gulp.task('lint', function () {
+ return gulp.src(['src/**/*.js', 'test/unit/**/*.js']).pipe(jshint())
+ .pipe(jshint.reporter('default'))
+ .pipe(jshint.reporter('fail'));
+});
+
+gulp.task('test', function (done) {
+ karma.start(_.assign({}, karmaCommonConf, {singleRun: true}), done);
+});
+
+gulp.task('tdd', function (done) {
+ karma.start(karmaCommonConf, done);
+});
+
+gulp.task('e2e', function() {
+ return gulp.src(['./test/e2e/**/*.js'], false)
+ .pipe(protractor({ configFile: 'test/protractor.conf.js' }));
+});
+
+gulp.task('watch', ['lint', 'build'], function () {
+
+ gulp.watch('src/**/*.js', ['lint', 'build-js']);
+ gulp.watch('src/**/*.tpl.html', ['build-js']);
+ gulp.watch('src/index.html', ['build-index']);
+ gulp.watch('src/assets/**/*.*', ['copy-static']);
+
+});
+
+gulp.task('build', ['copy-static', 'build-index', 'build-js']);
+gulp.task('default', ['lint', 'test', 'build']);
+
+/*
+TODO:
+- watch shouldn't break on errors
+- don't uglify / HTML minifiy during watch
+- live-reload
+ */
\ No newline at end of file
diff --git a/client/package.json b/client/package.json
index 703954e9..cdb8c6e4 100644
--- a/client/package.json
+++ b/client/package.json
@@ -19,17 +19,25 @@
"engines": {
"node": ">= 0.8.4"
},
- "dependencies": {},
"devDependencies": {
- "grunt": "~0.4.0",
- "grunt-recess": "~0.3",
- "grunt-contrib-clean": "~0.4.0",
- "grunt-contrib-copy": "~0.4.0",
- "grunt-contrib-jshint": "~0.2.0",
- "grunt-contrib-concat": "~0.1.3",
- "grunt-contrib-uglify": "~0.1.1",
- "grunt-karma": "~0.4.4",
- "grunt-html2js": "~0.1.0",
- "grunt-contrib-watch": "~0.3.1"
+ "lodash": "~2.4.1",
+ "merge-stream": "~0.1.5",
+ "rimraf": "~2.2.8",
+ "karma": "~0.12.17",
+ "karma-jasmine": "~0.1.5",
+ "karma-ng-html2js-preprocessor": "~0.1.0",
+ "karma-chrome-launcher": "~0.1.4",
+ "karma-firefox-launcher": "~0.1.3",
+ "karma-sauce-launcher": "~0.2.10",
+ "gulp": "~3.8.6",
+ "gulp-angular-templatecache": "~1.2.1",
+ "gulp-concat": "~2.3.3",
+ "gulp-uglify": "~0.3.1",
+ "gulp-jshint": "~1.7.1",
+ "gulp-template": "~0.1.1",
+ "gulp-header": "~1.0.5",
+ "gulp-htmlmin": "~0.1.3",
+ "gulp-protractor": "0.0.12",
+ "protractor": "^1.5.0"
}
}
diff --git a/client/src/app/admin/projects/admin-projects.js b/client/src/app/admin/projects/admin-projects.js
index 3cf50271..7cd21307 100644
--- a/client/src/app/admin/projects/admin-projects.js
+++ b/client/src/app/admin/projects/admin-projects.js
@@ -45,7 +45,7 @@ angular.module('admin-projects', [
};
$scope.onError = function() {
- i18nNotifications.pushForCurrentRoute('crud.project.save.error', 'error');
+ i18nNotifications.pushForCurrentRoute('crud.project.save.error', 'danger');
};
}])
diff --git a/client/src/app/admin/projects/projects-edit.tpl.html b/client/src/app/admin/projects/projects-edit.tpl.html
index 6c998338..9bcfd0a2 100644
--- a/client/src/app/admin/projects/projects-edit.tpl.html
+++ b/client/src/app/admin/projects/projects-edit.tpl.html
@@ -1,25 +1,32 @@