diff --git a/.gitignore b/.gitignore index c7fe5be2..ecec0aea 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ dist /target *.iml atlassian-ide-plugin.xml +jshint-log.xml \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 8e5633fd..3a093982 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,320 +1,184 @@ -// Generated on 2013-10-20 using generator-angular 0.3.0 + 'use strict'; -var LIVERELOAD_PORT = 35729; -var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT }); -var mountFolder = function (connect, dir) { - return connect.static(require('path').resolve(dir)); -}; -// # Globbing -// for performance reasons we're only matching one level down: -// 'test/spec/{,*/}*.js' -// use this if you want to recursively match all subfolders: -// 'test/spec/**/*.js' - -module.exports = function (grunt) { - // load all grunt tasks - require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); - - // configurable paths - var yeomanConfig = { - app: 'app', - dist: 'dist' - }; - - try { - yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app; - } catch (e) {} +module.exports = function(grunt) { + // Project configuration. grunt.initConfig({ - yeoman: yeomanConfig, - watch: { - coffee: { - files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'], - tasks: ['coffee:dist'] - }, - coffeeTest: { - files: ['test/spec/{,*/}*.coffee'], - tasks: ['coffee:test'] - }, - livereload: { - options: { - livereload: LIVERELOAD_PORT - }, - files: [ - '<%= yeoman.app %>/{,*/}*.html', - '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css', - '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js', - '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' - ] - } + pkg: grunt.file.readJSON('package.json'), + // Project settings + mifosx: { + // configurable paths + app: require('./bower.json').appPath || 'app', + dist: 'dist' }, - connect: { + + // Make sure code styles are up to par and there are no obvious mistakes + jshint: { options: { - port: 9000, - // Change this to '0.0.0.0' to access the server from outside. - hostname: 'localhost' + node: true, + jshintrc: true, + reporter:'checkstyle', + reporterOutput:'jshint-log.xml' }, - livereload: { - options: { - middleware: function (connect) { - return [ - lrSnippet, - mountFolder(connect, '.tmp'), - mountFolder(connect, yeomanConfig.app) - ]; - } - } + all: ['Gruntfile.js', '<%= mifosx.app %>/scripts/**/*.js'] + }, + + //uglify the js files + uglify: { + options: { + banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' }, - test: { - options: { - middleware: function (connect) { - return [ - mountFolder(connect, '.tmp'), - mountFolder(connect, 'test') - ]; - } - } - }, - dist: { - options: { - middleware: function (connect) { - return [ - mountFolder(connect, yeomanConfig.dist) - ]; - } - } - } - }, - open: { - server: { - url: 'http://localhost:<%= connect.options.port %>' + prod: { + files: [{'<%= mifosx.dist %>/bower_components/angular-mocks/angular-mocks.min.js' + :['<%= mifosx.app %>/bower_components/angular-mocks/angular-mocks.js'], + '<%= mifosx.dist %>/bower_components/angular-webstorage/angular-webstorage.min.js' + :['<%= mifosx.app %>/bower_components/angular-webstorage/angular-webstorage.js'], + '<%= mifosx.dist %>/bower_components/ckeditor/ckeditor.min.js' + :['<%= mifosx.app %>/bower_components/ckeditor/ckeditor.js'], + '<%= mifosx.dist %>/bower_components/datatables/media/js/jquery.dataTables.min.js' + :['<%= mifosx.app %>/bower_components/datatables/media/js/jquery.dataTables.js'], + //'<%= mifosx.dist %>/bower_components/require-css/css.min.js' + //:['<%= mifosx.app %>/bower_components/require-css/css.js'], + //'<%= mifosx.dist %>/bower_components/require-less/less.min.js' + //:['<%= mifosx.app %>/bower_components/require-less/less.js'], + //'<%= mifosx.dist %>/bower_components/requirejs/requirejs.min.js' + //:['<%= mifosx.app %>/bower_components/requirejs/require.js'], + '<%= mifosx.dist %>/bower_components/underscore/underscore.min.js' + :['<%= mifosx.app %>/bower_components/underscore/underscore.js'] + }] } }, + + // Empties folders to start fresh clean: { dist: { files: [{ dot: true, src: [ '.tmp', - '<%= yeoman.dist %>/*', - '!<%= yeoman.dist %>/.git*' + '<%= mifosx.dist %>/*', + '!<%= mifosx.dist %>/.git*' ] }] - }, - server: '.tmp' - }, - jshint: { - options: { - jshintrc: '.jshintrc' - }, - all: [ - 'Gruntfile.js', - '<%= yeoman.app %>/scripts/{,*/}*.js' - ] - }, - coffee: { - dist: { - files: [{ - expand: true, - cwd: '<%= yeoman.app %>/scripts', - src: '{,*/}*.coffee', - dest: '.tmp/scripts', - ext: '.js' - }] - }, - test: { - files: [{ - expand: true, - cwd: 'test/spec', - src: '{,*/}*.coffee', - dest: '.tmp/spec', - ext: '.js' - }] } }, - // not used since Uglify task does concat, - // but still available if needed - /*concat: { - dist: {} - },*/ - rev: { - dist: { - files: { - src: [ - '<%= yeoman.dist %>/scripts/{,*/}*.js', - '<%= yeoman.dist %>/styles/{,*/}*.css', - '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', - '<%= yeoman.dist %>/styles/fonts/*' - ] - } - } - }, - useminPrepare: { - html: '<%= yeoman.app %>/index.html', - options: { - dest: '<%= yeoman.dist %>' - } - }, - usemin: { - html: ['<%= yeoman.dist %>/{,*/}*.html'], - css: ['<%= yeoman.dist %>/styles/{,*/}*.css'], - options: { - dirs: ['<%= yeoman.dist %>'] - } - }, - imagemin: { - dist: { - files: [{ - expand: true, - cwd: '<%= yeoman.app %>/images', - src: '{,*/}*.{png,jpg,jpeg}', - dest: '<%= yeoman.dist %>/images' - }] - } - }, - cssmin: { - // By default, your `index.html` will take care of - // minification. This option is pre-configured if you do not wish to use - // Usemin blocks. - // dist: { - // files: { - // '<%= yeoman.dist %>/styles/main.css': [ - // '.tmp/styles/{,*/}*.css', - // '<%= yeoman.app %>/styles/{,*/}*.css' - // ] - // } - // } - }, - htmlmin: { - dist: { - options: { - /*removeCommentsFromCDATA: true, - // https://github.com/yeoman/grunt-usemin/issues/44 - //collapseWhitespace: true, - collapseBooleanAttributes: true, - removeAttributeQuotes: true, - removeRedundantAttributes: true, - useShortDoctype: true, - removeEmptyAttributes: true, - removeOptionalTags: true*/ - }, - files: [{ - expand: true, - cwd: '<%= yeoman.app %>', - src: ['*.html', 'views/*.html'], - dest: '<%= yeoman.dist %>' - }] - } - }, - // Put files not handled in other tasks here + + // Copies remaining files to places other tasks can use copy: { - dist: { + prod: { files: [{ expand: true, dot: true, - cwd: '<%= yeoman.app %>', - dest: '<%= yeoman.dist %>', + cwd: '<%= mifosx.app %>', + dest: '<%= mifosx.dist %>', src: [ '*.{ico,png,txt}', '.htaccess', - 'bower_components/**/*', - 'images/{,*/}*.{gif,webp,svg}', - 'styles/fonts/*' + 'images/{,*/}*.{webp}', + 'fonts/*', + 'scripts/*.js', + 'scripts/services/*.js', + 'scripts/modules/*.js', + '!scripts/routes.js', + '!scripts/initialTasks.js', + '!scripts/webstorage-configuration.js', + '!scripts/mifosXComponents.js', + '!scripts/mifosXComponents-build.js', + '!scripts/loader.js', + '!scripts/loader-build.js', + 'global-translations/**', + 'styles/**', + '*.html', + 'views/**', + 'images/**', ] - }, { + }, + { + '<%= mifosx.dist %>/scripts/mifosXComponents.js':['<%= mifosx.app %>/scripts/mifosXComponents-build.js'], + '<%= mifosx.dist %>/scripts/loader.js':['<%= mifosx.app %>/scripts/loader-build.js'] + }, + { expand: true, - cwd: '.tmp/images', - dest: '<%= yeoman.dist %>/images', + dot: true, + cwd: '<%= mifosx.app %>/bower_components', + dest: '<%= mifosx.dist %>/bower_components', src: [ - 'generated/*' + '**/*min.js', 'require-css/*.js', 'require-less/*.js', + '!jasmine/**', '!requirejs/**/**', 'requirejs/require.js', '!underscore/**' ] - }] - } - }, - concurrent: { - server: [ - 'coffee:dist' - ], - test: [ - 'coffee' - ], - dist: [ - 'coffee', - 'imagemin', - 'htmlmin' - ] - }, - karma: { - unit: { - configFile: 'karma.conf.js', - singleRun: true - } - }, - cdnify: { - dist: { - html: ['<%= yeoman.dist %>/*.html'] - } - }, - ngmin: { - dist: { + } + ] + }, + dev: { files: [{ expand: true, - cwd: '<%= yeoman.dist %>/scripts', - src: '*.js', - dest: '<%= yeoman.dist %>/scripts' + dot: true, + cwd: '<%= mifosx.app %>', + dest: '<%= mifosx.dist %>', + src: [ + '*.{ico,png,txt}', + '.htaccess', + 'images/{,*/}*.{webp}', + 'fonts/*', + 'scripts/**/*.js', + 'global-translations/**', + 'styles/**', + '*.html', + 'views/**', + 'images/**', + 'bower_components/**' + ] }] } }, - uglify: { + + // concatinate JS files + /** FIXME: Address issues with this task**/ + concat: { + options: { + separator: ';', + }, + // dist: { files: { - '<%= yeoman.dist %>/scripts/scripts.js': [ - '<%= yeoman.dist %>/scripts/scripts.js' - ] + '<%= mifosx.dist %>/scripts/controllers/controllers.js': ['<%= mifosx.app %>/scripts/controllers/**/*.js'], + '<%= mifosx.dist %>/scripts/directives/directives.js': ['<%= mifosx.app %>/scripts/directives/**/*.js'], + '<%= mifosx.dist %>/scripts/models/models.js': ['<%= mifosx.app %>/scripts/models/**/*.js'], + //'<%= mifosx.dist %>/scripts/services/services.js': ['<%= mifosx.app %>/scripts/services/**/*.js'], + '<%= mifosx.dist %>/scripts/filters/filters.js': ['<%= mifosx.app %>/scripts/filters/**/*.js'], + '<%= mifosx.dist %>/scripts/routes-initialTasks-webstorage-configuration.js': + ['<%= mifosx.app %>/scripts/routes.js', + '<%= mifosx.app %>/scripts/initialTasks.js', + '<%= mifosx.app %>/scripts/webstorage-configuration.js'] + } + } + }, + //FIXME: Address issues with requirejs task + requirejs: { + compile: { + options: { + baseUrl: '<%= mifosx.app %>', + mainConfigFile: '<%= mifosx.app %>/scripts/loader.js', + out: '<%= mifosx.dist %>/loader.js' } } } }); - grunt.registerTask('server', function (target) { - if (target === 'dist') { - return grunt.task.run(['build', 'open', 'connect:dist:keepalive']); - } + // Load the plugin that provides the "uglify" task. + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-requirejs'); + grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.task.run([ - 'clean:server', - 'concurrent:server', - 'connect:livereload', - 'open', - 'watch' - ]); - }); + // Default task(s). + + grunt.registerTask('default', ['clean', 'jshint', 'copy:dev']); + grunt.registerTask('prod', ['clean', 'copy:prod', 'concat', 'uglify:prod']); + grunt.registerTask('dev', ['clean', 'copy:dev']); + grunt.registerTask('compile', ['jshint']); - grunt.registerTask('test', [ - 'clean:server', - 'concurrent:test', - 'connect:test', - 'karma' - ]); - - grunt.registerTask('build', [ - 'clean:dist', - 'useminPrepare', - 'concurrent:dist', - 'concat', - 'copy', - 'cdnify', - 'ngmin', - 'cssmin', - 'uglify', - 'rev', - 'usemin' - ]); - - grunt.registerTask('default', [ - 'jshint', - 'test', - 'build' - ]); -}; +}; \ No newline at end of file diff --git a/app/scripts/loader-build.js b/app/scripts/loader-build.js new file mode 100644 index 00000000..5125d4cc --- /dev/null +++ b/app/scripts/loader-build.js @@ -0,0 +1,93 @@ +(function() { + require.config({ + paths: { + 'jquery': '../bower_components/jquery/jquery.min', + 'data-tables': '../bower_components/datatables/media/js/jquery.dataTables.min', + 'angular': '../bower_components/angular/angular.min', + 'angular-resource': '../bower_components/angular-resource/angular-resource.min', + 'angular-translate':'../bower_components/angular-translate/angular-translate.min', + 'angular-translate-loader-static-files':'../bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.min', + 'angular-mocks': '../bower_components/angular-mocks/angular-mocks.min', + 'angularui': '../bower_components/angular-bootstrap/ui-bootstrap.min', + 'angularuitpls': '../bower_components/angular-bootstrap/ui-bootstrap-tpls.min', + 'underscore': '../bower_components/underscore/underscore.min', + 'webstorage': '../bower_components/angular-webstorage/angular-webstorage.min', + 'require-css': '../bower_components/require-css/css', + 'require-less': '../bower_components/require-less/less', + 'd3': '../bower_components/d3/d3.min', + 'nvd3': '../bower_components/nvd3/nv.d3.min', + 'nvd3ChartDirectives':'../scripts/modules/angularjs-nvd3-directives', + 'styles': '../styles', + 'test': '../../test/functional', + 'notificationWidget':'../scripts/modules/notificationWidget', + 'modified.datepicker':'../scripts/modules/datepicker', + 'configurations':'../scripts/modules/configurations', + 'angularFileUpload':'../bower_components/angularjs-file-upload/angular-file-upload.min', + 'ngSanitize': '../bower_components/angular-sanitize/angular-sanitize.min', + 'ckEditor': '../bower_components/ckeditor/ckeditor.min', + 'LocalStorageModule':'../scripts/modules/localstorage' + }, + shim: { + 'angular': { exports: 'angular' }, + 'angular-resource': { deps: ['angular'] }, + 'angular-translate': { deps: ['angular'] }, + 'angular-translate-loader-static-files': {deps: ['angular' , 'angular-translate'] }, + 'angularui': { deps: ['angular'] }, + 'angularuitpls': { deps: ['angular' ,'angularui' ] }, + 'angular-mocks': { deps: ['angular'] }, + 'webstorage': { deps: ['angular'] }, + 'd3': {exports: 'd3'}, + 'nvd3': { deps: ['d3']}, + 'nvd3ChartDirectives': {deps: ['angular','nvd3']}, + 'configurations':{deps: ['angular']}, + 'notificationWidget':{deps: ['angular','jquery'],exports:'notificationWidget'}, + 'angularFileUpload':{deps: ['angular','jquery'],exports:'angularFileUpload'}, + 'modified.datepicker':{deps: ['angular']}, + 'ngSanitize':{deps:['angular'],exports:'ngSanitize'}, + 'ckEditor':{deps:['jquery']}, + 'LocalStorageModule':{deps:['angular']}, + 'mifosX': { + deps: [ + 'angular', + 'jquery', + 'angular-resource', + 'angular-translate', + 'angular-translate-loader-static-files', + 'angularui', + 'angularuitpls', + 'webstorage', + 'data-tables', + 'nvd3ChartDirectives', + 'notificationWidget', + 'angularFileUpload', + 'modified.datepicker', + 'ngSanitize', + 'ckEditor', + 'configurations', + 'LocalStorageModule' + ], + exports: 'mifosX' + } + }, + packages: [ + { + name: 'css', + location: '../bower_components/require-css', + main: 'css' + }, + { + name: 'less', + location: '../bower_components/require-less', + main: 'less' + } + ] + }); + + require(['mifosXComponents', 'mifosXStyles'], function() { + require(['test/testInitializer'], function(testMode) { + if (!testMode) { + angular.bootstrap(document, ['MifosX_Application']); + } + }); + }); +}()); diff --git a/app/scripts/mifosXComponents-build.js b/app/scripts/mifosXComponents-build.js new file mode 100644 index 00000000..0c698bdf --- /dev/null +++ b/app/scripts/mifosXComponents-build.js @@ -0,0 +1,29 @@ +define(['underscore', 'mifosX'], function() { + var components = { + models: [ + 'models' + ], + services: [ + 'ResourceFactoryProvider', + 'HttpServiceProvider', + 'AuthenticationService', + 'SessionManager', + 'Paginator' + ], + controllers: [ + 'controllers' + ], + filters: [ + 'filters' + ], + directives: [ + 'directives' + ] + }; + + require(_.reduce(_.keys(components), function(list, group) { + return list.concat(_.map(components[group], function(name) { return group + "/" + name; })); + }, [ + 'routes-initialTasks-webstorage-configuration' + ])); +}); diff --git a/bower.json b/bower.json index 5aa8439c..cfc1d4f0 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,7 @@ "angular-translate-loader-static-files": "0.1.4", "d3": "3.3.9", "nvd3": "1.1.14-beta", - "angularjs-file-upload": "0.1.4", + "angularjs-file-upload": "", "angular-sanitize": "v1.0.8", "ckeditor": "" }, diff --git a/package.json b/package.json index b95985c3..31d683b8 100644 --- a/package.json +++ b/package.json @@ -1,30 +1,16 @@ { - "name": "yeomanagain", + "name": "mifosx-community-app", "version": "0.0.0", "dependencies": {}, "devDependencies": { - "grunt": "~0.4.1", + "grunt": "~0.4.2", + "grunt-contrib-jshint": "~0.7.2", + "grunt-contrib-nodeunit": "~0.2.0", + "grunt-contrib-uglify": "~0.2.2", + "grunt-contrib-clean": "~0.5.0", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-concat": "~0.3.0", - "grunt-contrib-coffee": "~0.7.0", - "grunt-contrib-uglify": "~0.2.0", - "grunt-contrib-compass": "~0.3.0", - "grunt-contrib-jshint": "~0.6.0", - "grunt-contrib-cssmin": "~0.6.0", - "grunt-contrib-connect": "~0.3.0", - "grunt-contrib-clean": "~0.4.1", - "grunt-contrib-htmlmin": "~0.1.3", - "grunt-contrib-imagemin": "~0.1.4", - "grunt-contrib-watch": "~0.4.0", - "grunt-usemin": "~0.1.11", - "grunt-rev": "~0.1.0", - "grunt-karma": "~0.4.3", - "grunt-open": "~0.2.0", - "grunt-concurrent": "~0.3.0", - "matchdep": "~0.1.2", - "connect-livereload": "~0.2.0", - "grunt-google-cdn": "~0.2.0", - "grunt-ngmin": "~0.0.2" + "grunt-contrib-requirejs": "~0.3.1" }, "engines": { "node": ">=0.8.0"