123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- module.exports = function(grunt) {
- var DEV_SERVER_PORT = 8383;
- var TEST_SERVER_PORT = 8387;
- // Tell our Express server that Grunt launched it
- process.env.GRUNTED = true;
- // Project configuration.
- grunt.initConfig({
- pkg: grunt.file.readJSON('package.json'),
-
- font: {
- icons: {
- src: ['front/src/fonts/svg-icons/*.svg'],
- destCss: 'front/src/less/icons.less',
- destFonts: 'front/src/fonts/icons.woff',
- // Optional: Custom routing of font filepaths for CSS
- cssRouter: function (fontpath) {
- var pathArray = fontpath.split('/');
- var fileName = pathArray[pathArray.length - 1];
- return '/front/fonts/' + fileName;
- }
- }
- },
- less: {
- all: {
- files: [
- {
- expand: true,
- cwd: 'front/src/less/',
- src: ['**/*.less'],
- dest: 'front/src/css/',
- ext: '.css'
- }
- ]
- }
- },
- jshint: {
- all: [
- '*.js',
- 'app/lib/*.js',
- 'bin/*.js',
- 'lib/**/*.js',
- 'app/nodeControllers/*.js',
- 'app/public/scripts/*.js',
- 'phantomas_custom/**/*.js',
- 'test/**/*.js',
- 'front/src/js/**/*.js'
- ]
- },
- clean: {
- icons: {
- src: ['tmp']
- },
- dev: {
- src: ['front/src/css']
- },
- coverage: {
- src: ['coverage/']
- }
- },
- copy: {
- coverage: {
- files: [
- {src: ['test/**'], dest: 'coverage/'},
- {src: ['lib/metadata/**'], dest: 'coverage/'},
- {src: ['bin/**'], dest: 'coverage/'}
- ]
- }
- },
- blanket: {
- coverageApp: {
- src: ['app/'],
- dest: 'coverage/app/'
- },
- coverageLib: {
- src: ['lib/'],
- dest: 'coverage/lib/'
- },
- coverageBin: {
- src: ['bin/'],
- dest: 'coverage/bin/'
- }
- },
- mochaTest: {
- test: {
- options: {
- reporter: 'spec',
- },
- src: ['coverage/test/core/*.js', 'coverage/test/api/*.js']
- },
- 'test-current-work': {
- options: {
- reporter: 'spec',
- },
- src: ['coverage/test/api/apiTest.js']
- },
- coverage: {
- options: {
- reporter: 'html-cov',
- quiet: true,
- captureFile: 'coverage/coverage.html'
- },
- src: ['coverage/test/core/*.js', 'coverage/test/api/*.js']
- }
- },
- express: {
- dev: {
- options: {
- port: 8383,
- server: './bin/server.js',
- serverreload: true,
- showStack: true
- }
- },
- test: {
- options: {
- port: 8387,
- server: './coverage/bin/server.js',
- showStack: true
- }
- },
- testSuite: {
- options: {
- port: 8388,
- bases: 'test/www'
- }
- }
- }
- });
- // Custom task: copies the test settings.json file to the coverage folder, and checks if there's no missing fields
- grunt.registerTask('copy-test-server-settings', function() {
- var mainSettingsFile = './server_config/settings.json';
- var testSettingsFile = './test/fixtures/settings.json';
- var mainSettings = grunt.file.readJSON(mainSettingsFile);
- var testSettings = grunt.file.readJSON(testSettingsFile);
- // Recursively compare keys of two objects (not the values)
- function compareKeys(original, copy, context) {
- for (var key in original) {
- if (!copy[key] && copy[key] !== '' && copy[key] !== 0) {
- grunt.fail.warn('Settings file ' + testSettingsFile + ' doesn\'t contain key ' + context + '.' + key);
- }
- if (original[key] !== null && typeof original[key] === 'object') {
- compareKeys(original[key], copy[key], context + '.' + key);
- }
- }
- }
- compareKeys(mainSettings, testSettings, 'settings');
- var outputFile = './coverage/server_config/settings.json';
- grunt.file.write(outputFile, JSON.stringify(testSettings, null, 4));
- grunt.log.ok('File ' + outputFile + ' created');
- });
- require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
- grunt.registerTask('icons', [
- 'font:icons',
- 'less',
- 'clean:icons'
- ]);
- grunt.registerTask('build', [
- 'less'
- ]);
- grunt.registerTask('hint', [
- 'jshint'
- ]);
- grunt.registerTask('dev', [
- 'clean:dev',
- 'less'
- ]);
- grunt.registerTask('test', [
- 'build',
- 'jshint',
- 'express:testSuite',
- 'clean:coverage',
- 'copy-test-server-settings',
- 'blanket',
- 'copy:coverage',
- 'express:test',
- 'mochaTest:test',
- 'mochaTest:coverage'
- ]);
- grunt.registerTask('test-current-work', [
- 'build',
- 'jshint',
- 'express:testSuite',
- 'clean:coverage',
- 'copy-test-server-settings',
- 'blanket',
- 'copy:coverage',
- 'mochaTest:test-current-work'
- ]);
- };
|