2017-10-30 04:22:43 +00:00
|
|
|
|
2017-04-11 07:10:36 +00:00
|
|
|
|
|
|
|
var bowerArray = ['public/lib/angular/angular.min.js',
|
|
|
|
'public/lib/angular-scroll/angular-scroll.min.js',
|
|
|
|
'public/lib/angular-ui-select/dist/select.min.js',
|
|
|
|
'public/lib/v-button/dist/v-button.min.js',
|
|
|
|
'public/lib/angular-resource/angular-resource.min.js',
|
|
|
|
'public/lib/angular-ui-router/release/angular-ui-router.min.js',
|
|
|
|
'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
|
|
|
|
'public/lib/angular-translate/angular-translate.min.js',
|
|
|
|
'public/lib/ng-file-upload/ng-file-upload-all.min.js',
|
|
|
|
'public/lib/angular-ui-date/src/date.js',
|
|
|
|
'public/lib/angular-input-stars/angular-input-stars.js',
|
|
|
|
'public/lib/jsep/build/jsep.min.js',
|
|
|
|
'public/lib/raven-js/dist/raven.min.js',
|
|
|
|
'public/lib/lodash/lodash.min.js',
|
|
|
|
'public/lib/mobile-detect/mobile-detect.js',
|
2017-04-11 11:04:48 +00:00
|
|
|
'public/lib/js-yaml/dist/js-yaml.js',
|
2017-04-11 07:10:36 +00:00
|
|
|
'public/lib/angular-sanitize/angular-sanitize.min.js'];
|
2016-05-10 06:30:09 +00:00
|
|
|
|
2015-06-29 22:51:29 +00:00
|
|
|
module.exports = function(grunt) {
|
2015-12-12 20:08:48 +00:00
|
|
|
require('jit-grunt')(grunt);
|
2016-04-23 15:07:34 +00:00
|
|
|
|
2015-06-29 22:51:29 +00:00
|
|
|
// Unified Watch Object
|
|
|
|
var watchFiles = {
|
2017-10-28 00:19:45 +00:00
|
|
|
serverViews: ['app/views/**/*.pug'],
|
2015-06-29 22:51:29 +00:00
|
|
|
serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js', '!app/tests/'],
|
2016-05-05 19:12:40 +00:00
|
|
|
|
2017-09-20 22:18:19 +00:00
|
|
|
clientViews: ['public/modules/**/*.html', 'public/form_modules/forms/base/**/*.html', '!public/modules/forms/base/**/*.html',],
|
2017-10-29 15:43:20 +00:00
|
|
|
clientJS: ['public/form_modules/**/*.js', 'public/modules/**/*.js'],
|
2017-10-11 05:07:13 +00:00
|
|
|
clientCSS: ['public/modules/**/*.css'],
|
2016-05-05 19:12:40 +00:00
|
|
|
|
2015-11-23 19:19:02 +00:00
|
|
|
serverTests: ['app/tests/**/*.js'],
|
2017-10-11 05:07:13 +00:00
|
|
|
clientTests: ['public/modules/**/tests/*.js']
|
2015-06-29 22:51:29 +00:00
|
|
|
};
|
|
|
|
|
2016-05-05 19:12:40 +00:00
|
|
|
watchFiles.allTests = watchFiles.serverTests.concat(watchFiles.clientTests);
|
|
|
|
|
2015-06-29 22:51:29 +00:00
|
|
|
// Project Configuration
|
|
|
|
grunt.initConfig({
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
watch: {
|
|
|
|
serverViews: {
|
|
|
|
files: watchFiles.serverViews,
|
|
|
|
options: {
|
2015-07-03 19:25:02 +00:00
|
|
|
livereload: true,
|
|
|
|
spawn: false
|
2015-06-29 22:51:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
serverJS: {
|
|
|
|
files: watchFiles.serverJS,
|
2015-07-03 19:25:02 +00:00
|
|
|
tasks: ['newer:jshint'],
|
2015-06-29 22:51:29 +00:00
|
|
|
options: {
|
2015-07-03 19:25:02 +00:00
|
|
|
livereload: true,
|
|
|
|
spawn: false
|
2015-06-29 22:51:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
clientViews: {
|
|
|
|
files: watchFiles.clientViews,
|
2015-11-23 19:19:02 +00:00
|
|
|
tasks: ['html2js:main'],
|
2015-06-29 22:51:29 +00:00
|
|
|
options: {
|
2015-07-03 19:25:02 +00:00
|
|
|
livereload: true,
|
|
|
|
spawn: false
|
2015-06-29 22:51:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
clientJS: {
|
|
|
|
files: watchFiles.clientJS,
|
2015-07-03 19:25:02 +00:00
|
|
|
tasks: ['newer:jshint'],
|
2015-06-29 22:51:29 +00:00
|
|
|
options: {
|
2015-07-03 19:25:02 +00:00
|
|
|
livereload: true,
|
|
|
|
spawn: false
|
2015-06-29 22:51:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
clientCSS: {
|
|
|
|
files: watchFiles.clientCSS,
|
2015-07-03 19:25:02 +00:00
|
|
|
tasks: ['newer:csslint'],
|
2015-06-29 22:51:29 +00:00
|
|
|
options: {
|
2015-07-03 19:25:02 +00:00
|
|
|
livereload: true,
|
|
|
|
spawn: false
|
2015-06-29 22:51:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mochaTests: {
|
2015-11-23 19:19:02 +00:00
|
|
|
files: watchFiles.serverTests,
|
2017-03-27 22:00:22 +00:00
|
|
|
tasks: ['test:server']
|
2015-06-29 22:51:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
jshint: {
|
|
|
|
all: {
|
|
|
|
src: watchFiles.clientJS.concat(watchFiles.serverJS),
|
|
|
|
options: {
|
|
|
|
jshintrc: true
|
|
|
|
}
|
2016-05-10 06:30:09 +00:00
|
|
|
},
|
|
|
|
allTests: {
|
2015-11-23 21:06:02 +00:00
|
|
|
src: watchFiles.allTests,
|
|
|
|
options: {
|
2016-05-10 06:30:09 +00:00
|
|
|
jshintrc: true
|
2015-06-29 22:51:29 +00:00
|
|
|
}
|
2016-05-10 06:30:09 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
csslint: {
|
|
|
|
options: {
|
2016-04-29 03:07:51 +00:00
|
|
|
csslintrc: '.csslintrc'
|
2016-05-10 06:30:09 +00:00
|
|
|
},
|
|
|
|
all: {
|
2016-04-29 03:07:51 +00:00
|
|
|
src: watchFiles.clientCSS
|
2016-05-10 06:30:09 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
uglify: {
|
2017-04-11 07:10:36 +00:00
|
|
|
productionAdmin: {
|
2016-05-10 06:30:09 +00:00
|
|
|
options: {
|
2017-04-11 07:10:36 +00:00
|
|
|
compress: true,
|
|
|
|
mangled: true
|
2016-05-10 06:30:09 +00:00
|
|
|
},
|
|
|
|
files: {
|
2016-06-20 22:35:41 +00:00
|
|
|
'public/dist/application.min.js': 'public/dist/application.js',
|
|
|
|
'public/dist/form-application.min.js': 'public/dist/form-application.js'
|
2016-05-10 06:30:09 +00:00
|
|
|
}
|
2017-04-11 07:10:36 +00:00
|
|
|
},
|
|
|
|
productionForms: {
|
|
|
|
options: {
|
|
|
|
mangled: true,
|
2017-10-05 08:19:13 +00:00
|
|
|
compress: true
|
2017-04-11 07:10:36 +00:00
|
|
|
},
|
|
|
|
files: {
|
2017-10-05 08:19:13 +00:00
|
|
|
'public/dist/vendor.min.js': bowerArray
|
2017-04-11 07:10:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-05-10 06:30:09 +00:00
|
|
|
cssmin: {
|
|
|
|
combine: {
|
|
|
|
files: {
|
|
|
|
'public/dist/application.min.css': '<%= applicationCSSFiles %>'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
nodemon: {
|
|
|
|
dev: {
|
|
|
|
script: 'server.js',
|
|
|
|
options: {
|
|
|
|
nodeArgs: ['--debug'],
|
|
|
|
ext: 'js,html',
|
|
|
|
watch: watchFiles.serverViews.concat(watchFiles.serverJS)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ngAnnotate: {
|
2017-10-29 15:43:20 +00:00
|
|
|
options:{
|
|
|
|
add: true,
|
|
|
|
remove: true
|
|
|
|
},
|
2016-05-10 06:30:09 +00:00
|
|
|
production: {
|
|
|
|
files: {
|
2017-10-29 15:43:20 +00:00
|
|
|
'public/dist/application.js': ['public/application.js', 'public/config.js', 'public/form_modules/**/*.js'],
|
|
|
|
'public/dist/form_application.js': ['public/form-application.js', 'public/form-config.js', 'public/form_modules/**/*.js']
|
2016-05-05 19:12:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-05-01 09:03:55 +00:00
|
|
|
concurrent: {
|
|
|
|
default: ['nodemon', 'watch'],
|
2017-10-11 05:07:13 +00:00
|
|
|
debug: ['nodemon', 'watch'],
|
2016-05-05 19:12:40 +00:00
|
|
|
options: {
|
2016-05-01 09:03:55 +00:00
|
|
|
logConcurrentOutput: true,
|
|
|
|
limit: 10
|
|
|
|
}
|
2016-04-29 03:07:51 +00:00
|
|
|
},
|
2016-05-10 06:30:09 +00:00
|
|
|
env: {
|
2017-10-11 05:25:39 +00:00
|
|
|
src: '.env',
|
|
|
|
|
2016-05-10 06:30:09 +00:00
|
|
|
test: {
|
|
|
|
NODE_ENV: 'test',
|
2015-06-29 22:51:29 +00:00
|
|
|
},
|
|
|
|
secure: {
|
2016-04-12 04:35:28 +00:00
|
|
|
NODE_ENV: 'secure',
|
2015-07-27 20:33:43 +00:00
|
|
|
},
|
2016-04-12 05:55:10 +00:00
|
|
|
production: {
|
2016-04-29 02:48:02 +00:00
|
|
|
NODE_ENV: 'production',
|
|
|
|
},
|
|
|
|
dev: {
|
|
|
|
NODE_ENV: 'development',
|
2016-05-10 06:30:09 +00:00
|
|
|
}
|
2015-06-29 22:51:29 +00:00
|
|
|
},
|
|
|
|
mochaTest: {
|
2015-11-23 20:12:10 +00:00
|
|
|
src: watchFiles.serverTests,
|
2015-06-29 22:51:29 +00:00
|
|
|
options: {
|
|
|
|
reporter: 'spec',
|
2016-04-23 15:07:34 +00:00
|
|
|
quiet: false,
|
2015-10-06 20:14:38 +00:00
|
|
|
require: 'server.js',
|
2017-07-29 00:04:16 +00:00
|
|
|
ui: 'bdd',
|
2017-10-11 05:07:13 +00:00
|
|
|
debug: false
|
2015-06-29 22:51:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
karma: {
|
|
|
|
unit: {
|
2016-04-21 18:59:42 +00:00
|
|
|
configFile: 'karma.conf.js',
|
|
|
|
singleRun: true
|
2017-07-28 21:47:09 +00:00
|
|
|
},
|
|
|
|
debug: {
|
|
|
|
configFile: 'karma.conf.js',
|
|
|
|
browserConsoleLogOptions: {
|
|
|
|
level: 'log',
|
|
|
|
terminal: true
|
|
|
|
},
|
|
|
|
singleRun: true
|
|
|
|
}
|
2015-08-18 21:44:36 +00:00
|
|
|
},
|
2015-11-23 19:19:02 +00:00
|
|
|
mocha_istanbul: {
|
|
|
|
coverageServer: {
|
|
|
|
src: watchFiles.serverTests,
|
|
|
|
options: {
|
|
|
|
coverageFolder: 'coverageServer',
|
|
|
|
mask: '*.test.js',
|
2017-10-30 04:22:43 +00:00
|
|
|
require: ['server.js'],
|
2015-11-23 19:19:02 +00:00
|
|
|
reportFormats: ['cobertura','lcovonly']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2017-10-30 04:22:43 +00:00
|
|
|
lcovMerge: {
|
|
|
|
options: {
|
|
|
|
emitters: ['event'],
|
|
|
|
},
|
|
|
|
src: ['./coverageServer/*.info', './clientCoverage/lcov-report/*.info']
|
|
|
|
},
|
2016-05-10 06:30:09 +00:00
|
|
|
html2js: {
|
|
|
|
options: {
|
2016-05-05 19:12:40 +00:00
|
|
|
base: 'public',
|
2016-05-10 06:30:09 +00:00
|
|
|
watch: true,
|
|
|
|
singleModule: true,
|
|
|
|
useStrict: true,
|
|
|
|
htmlmin: {
|
|
|
|
collapseBooleanAttributes: true,
|
|
|
|
collapseWhitespace: true,
|
|
|
|
removeAttributeQuotes: true,
|
|
|
|
removeComments: true,
|
|
|
|
removeEmptyAttributes: true,
|
|
|
|
removeRedundantAttributes: true
|
|
|
|
}
|
|
|
|
},
|
2017-03-27 20:32:06 +00:00
|
|
|
forms: {
|
|
|
|
options: {
|
2017-03-27 22:00:22 +00:00
|
|
|
module: 'TellForm-Form.form_templates'
|
2017-03-27 20:32:06 +00:00
|
|
|
},
|
|
|
|
src: ['public/form_modules/**/views/**.html', 'public/form_modules/**/views/**/*.html'],
|
|
|
|
dest: 'public/dist/form_populate_template_cache.js'
|
|
|
|
},
|
2016-05-10 06:30:09 +00:00
|
|
|
main: {
|
2017-03-27 20:32:06 +00:00
|
|
|
options: {
|
|
|
|
module: 'TellForm.templates'
|
|
|
|
},
|
2017-09-20 22:18:19 +00:00
|
|
|
src: ['public/modules/**/views/**.html', 'public/modules/**/views/**/*.html', 'public/form_modules/forms/base/**/*.html', '!public/modules/forms/base/**/*.html'],
|
2016-05-10 06:30:09 +00:00
|
|
|
dest: 'public/dist/populate_template_cache.js'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
execute: {
|
|
|
|
target: {
|
|
|
|
src: ['./scripts/setup.js']
|
|
|
|
}
|
2017-10-27 19:52:39 +00:00
|
|
|
},
|
2015-11-23 19:19:02 +00:00
|
|
|
});
|
2017-03-27 22:00:22 +00:00
|
|
|
|
2015-11-23 19:19:02 +00:00
|
|
|
grunt.event.on('coverage', function(lcov, done){
|
2015-11-23 22:00:21 +00:00
|
|
|
var coveralls = require('coveralls');
|
2017-03-27 20:32:06 +00:00
|
|
|
coveralls.handleInput(lcov, function(err){
|
2015-11-23 19:19:02 +00:00
|
|
|
if (err) {
|
2016-04-17 02:45:17 +00:00
|
|
|
grunt.log.error('Failed to submit lcov file to coveralls: ' + err);
|
2015-11-23 19:19:02 +00:00
|
|
|
return done(err);
|
|
|
|
}
|
2016-04-17 02:45:17 +00:00
|
|
|
grunt.verbose.ok('Successfully submitted lcov file to coveralls');
|
2015-11-23 19:19:02 +00:00
|
|
|
done();
|
|
|
|
});
|
2015-06-29 22:51:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Making grunt default to force in order not to break the project.
|
|
|
|
grunt.option('force', true);
|
|
|
|
|
|
|
|
// A Task for loading the configuration object
|
2017-04-23 20:11:30 +00:00
|
|
|
grunt.task.registerTask('loadConfig', 'Task that loads the config into a grunt option.', function() {
|
2017-04-23 02:46:35 +00:00
|
|
|
require('./config/init')();
|
2015-06-29 22:51:29 +00:00
|
|
|
var config = require('./config/config');
|
|
|
|
grunt.config.set('applicationJavaScriptFiles', config.assets.js);
|
2016-06-20 22:35:41 +00:00
|
|
|
grunt.config.set('formApplicationJavaScriptFiles', config.assets.form_js);
|
2015-06-29 22:51:29 +00:00
|
|
|
grunt.config.set('applicationCSSFiles', config.assets.css);
|
2017-04-23 20:11:30 +00:00
|
|
|
});
|
2015-11-23 19:19:02 +00:00
|
|
|
|
|
|
|
// Code coverage tasks.
|
2017-10-30 04:22:43 +00:00
|
|
|
grunt.registerTask('coveralls', ['env:test','lcovMerge']);
|
2017-07-28 21:47:09 +00:00
|
|
|
grunt.registerTask('coverage:server', ['env:test', 'mocha_istanbul:coverageServer']);
|
2015-06-29 22:51:29 +00:00
|
|
|
|
|
|
|
// Default task(s).
|
2017-03-27 22:00:22 +00:00
|
|
|
grunt.registerTask('default', ['lint', 'html2js:main', 'html2js:forms', 'env', 'concurrent:default']);
|
|
|
|
grunt.registerTask('dev', ['lint', 'html2js:main', 'html2js:forms', 'env:dev', 'concurrent:default']);
|
2016-05-10 06:30:09 +00:00
|
|
|
|
2015-06-29 22:51:29 +00:00
|
|
|
// Debug task.
|
2017-03-27 22:00:22 +00:00
|
|
|
grunt.registerTask('debug', ['lint', 'html2js:main', 'html2js:forms', 'concurrent:debug']);
|
2015-06-29 22:51:29 +00:00
|
|
|
|
|
|
|
// Secure task(s).
|
2017-03-27 22:00:22 +00:00
|
|
|
grunt.registerTask('secure', ['env:secure', 'lint', 'html2js:main', 'html2js:forms', 'concurrent:default']);
|
2015-06-29 22:51:29 +00:00
|
|
|
|
|
|
|
// Lint task(s).
|
2017-10-28 00:19:45 +00:00
|
|
|
grunt.registerTask('lint', ['jshint', 'csslint', 'i18nlint:client', 'i18nlint:server']);
|
2017-09-20 18:29:17 +00:00
|
|
|
grunt.registerTask('lint:tests', ['jshint:allTests']);
|
2015-06-29 22:51:29 +00:00
|
|
|
|
|
|
|
// Build task(s).
|
2017-10-05 08:19:13 +00:00
|
|
|
grunt.registerTask('build', ['lint', 'loadConfig', 'cssmin', 'ngAnnotate', 'uglify', 'html2js:main', 'html2js:forms']);
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2016-05-10 06:30:09 +00:00
|
|
|
//Setup task(s).
|
|
|
|
grunt.registerTask('setup', ['execute']);
|
|
|
|
|
2016-04-24 17:19:31 +00:00
|
|
|
// Test task(s).
|
2017-10-29 19:59:12 +00:00
|
|
|
grunt.registerTask('test', ['test:server', 'test:client']);
|
2015-12-12 20:08:48 +00:00
|
|
|
grunt.registerTask('test:server', ['lint:tests', 'env:test', 'mochaTest']);
|
2017-03-27 22:00:22 +00:00
|
|
|
grunt.registerTask('test:client', ['lint:tests', 'html2js:main', 'html2js:forms', 'env:test', 'karma:unit']);
|
2017-10-29 19:59:12 +00:00
|
|
|
grunt.registerTask('test:travis', ['env:test', 'html2js:main', 'html2js:forms', 'env:test', 'karma:unit', 'mochaTest', 'coveralls']);
|
|
|
|
|
2017-07-28 21:47:09 +00:00
|
|
|
|
|
|
|
grunt.registerTask('testdebug', ['env:test', 'karma:debug']);
|
2015-06-29 22:51:29 +00:00
|
|
|
};
|