2014-08-07 17:27:32 +00:00
|
|
|
module.exports = function(grunt) {
|
|
|
|
|
2014-12-09 08:04:28 +00:00
|
|
|
// Tell our Express server that Grunt launched it
|
|
|
|
process.env.GRUNTED = true;
|
|
|
|
|
2014-08-07 17:27:32 +00:00
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
2014-12-30 07:11:47 +00:00
|
|
|
settings: grunt.file.readJSON('./server_config/settings.json'),
|
2014-08-07 17:27:32 +00:00
|
|
|
|
2014-09-04 14:15:24 +00:00
|
|
|
font: {
|
|
|
|
icons: {
|
2014-12-18 17:02:04 +00:00
|
|
|
src: ['front/src/fonts/svg-icons/*.svg'],
|
|
|
|
destCss: 'front/src/less/icons.less',
|
|
|
|
destFonts: 'front/src/fonts/icons.woff',
|
2014-09-04 14:15:24 +00:00
|
|
|
|
|
|
|
// Optional: Custom routing of font filepaths for CSS
|
|
|
|
cssRouter: function (fontpath) {
|
|
|
|
var pathArray = fontpath.split('/');
|
|
|
|
var fileName = pathArray[pathArray.length - 1];
|
2014-12-18 17:02:04 +00:00
|
|
|
return '/front/fonts/' + fileName;
|
2014-09-04 14:15:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
less: {
|
2014-09-26 21:22:43 +00:00
|
|
|
all: {
|
2014-12-18 17:02:04 +00:00
|
|
|
files: [
|
|
|
|
{
|
|
|
|
expand: true,
|
|
|
|
cwd: 'front/src/less/',
|
|
|
|
src: ['**/*.less'],
|
|
|
|
dest: 'front/src/css/',
|
|
|
|
ext: '.css'
|
|
|
|
}
|
|
|
|
]
|
2014-09-04 14:15:24 +00:00
|
|
|
}
|
|
|
|
},
|
2014-12-30 07:11:47 +00:00
|
|
|
replace: {
|
|
|
|
dist: {
|
|
|
|
options: {
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
match: 'googleAnalyticsId',
|
|
|
|
replacement: '<%= settings.googleAnalyticsId %>'
|
2014-12-30 08:20:05 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
match: 'version',
|
|
|
|
replacement: 'v<%= pkg.version %>'
|
2014-12-30 07:11:47 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
files: [
|
|
|
|
{expand: true, flatten: true, src: ['front/src/main.html'], dest: 'front/build/'}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2014-08-07 17:27:32 +00:00
|
|
|
jshint: {
|
|
|
|
all: [
|
|
|
|
'*.js',
|
2014-11-28 09:45:30 +00:00
|
|
|
'app/lib/*.js',
|
|
|
|
'bin/*.js',
|
|
|
|
'lib/**/*.js',
|
2014-08-07 17:27:32 +00:00
|
|
|
'app/nodeControllers/*.js',
|
|
|
|
'app/public/scripts/*.js',
|
2014-12-01 23:08:07 +00:00
|
|
|
'phantomas_custom/**/*.js',
|
2014-12-15 17:58:38 +00:00
|
|
|
'test/**/*.js',
|
|
|
|
'front/src/js/**/*.js'
|
2014-08-07 17:27:32 +00:00
|
|
|
]
|
2014-09-03 07:06:35 +00:00
|
|
|
},
|
|
|
|
clean: {
|
2015-01-05 22:18:15 +00:00
|
|
|
tmp: {
|
2014-09-04 14:15:24 +00:00
|
|
|
src: ['tmp']
|
|
|
|
},
|
2014-12-18 17:02:04 +00:00
|
|
|
dev: {
|
|
|
|
src: ['front/src/css']
|
|
|
|
},
|
2014-09-03 07:06:35 +00:00
|
|
|
coverage: {
|
2015-01-05 22:18:15 +00:00
|
|
|
src: ['tmp', 'coverage/']
|
2014-09-03 07:06:35 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
copy: {
|
2015-01-05 22:18:15 +00:00
|
|
|
beforeCoverage: {
|
|
|
|
files: [
|
|
|
|
{src: ['bin/server.js'], dest: 'tmp/'}
|
|
|
|
]
|
|
|
|
},
|
2014-09-03 07:06:35 +00:00
|
|
|
coverage: {
|
2014-11-28 16:22:32 +00:00
|
|
|
files: [
|
|
|
|
{src: ['test/**'], dest: 'coverage/'},
|
2015-01-05 22:18:15 +00:00
|
|
|
{src: ['lib/metadata/**'], dest: 'coverage/'}
|
2014-11-28 16:22:32 +00:00
|
|
|
]
|
2014-09-03 07:06:35 +00:00
|
|
|
}
|
|
|
|
},
|
2015-01-05 22:18:15 +00:00
|
|
|
lineremover: {
|
|
|
|
beforeCoverage: {
|
|
|
|
files: {
|
|
|
|
'tmp/bin/cli.js': 'bin/cli.js'
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
exclusionPattern: /#!\/usr\/bin\/env node/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-09-03 07:06:35 +00:00
|
|
|
blanket: {
|
2014-11-28 09:45:30 +00:00
|
|
|
coverageApp: {
|
2014-09-03 07:06:35 +00:00
|
|
|
src: ['app/'],
|
|
|
|
dest: 'coverage/app/'
|
2014-11-28 09:45:30 +00:00
|
|
|
},
|
|
|
|
coverageLib: {
|
|
|
|
src: ['lib/'],
|
|
|
|
dest: 'coverage/lib/'
|
2014-12-13 11:11:33 +00:00
|
|
|
},
|
|
|
|
coverageBin: {
|
2015-01-05 22:18:15 +00:00
|
|
|
src: ['tmp/bin/'],
|
2014-12-13 11:11:33 +00:00
|
|
|
dest: 'coverage/bin/'
|
2014-09-03 07:06:35 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mochaTest: {
|
|
|
|
test: {
|
|
|
|
options: {
|
|
|
|
reporter: 'spec',
|
|
|
|
},
|
2014-12-05 15:14:08 +00:00
|
|
|
src: ['coverage/test/core/*.js', 'coverage/test/api/*.js']
|
2014-11-28 09:45:30 +00:00
|
|
|
},
|
|
|
|
'test-current-work': {
|
|
|
|
options: {
|
|
|
|
reporter: 'spec',
|
|
|
|
},
|
2014-12-09 08:04:28 +00:00
|
|
|
src: ['coverage/test/api/apiTest.js']
|
2014-09-03 07:06:35 +00:00
|
|
|
},
|
|
|
|
coverage: {
|
|
|
|
options: {
|
|
|
|
reporter: 'html-cov',
|
|
|
|
quiet: true,
|
|
|
|
captureFile: 'coverage/coverage.html'
|
|
|
|
},
|
2014-12-09 08:04:28 +00:00
|
|
|
src: ['coverage/test/core/*.js', 'coverage/test/api/*.js']
|
2014-11-28 09:45:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
express: {
|
2014-12-09 08:04:28 +00:00
|
|
|
dev: {
|
|
|
|
options: {
|
|
|
|
port: 8383,
|
|
|
|
server: './bin/server.js',
|
|
|
|
serverreload: true,
|
|
|
|
showStack: true
|
|
|
|
}
|
|
|
|
},
|
2014-12-22 21:08:24 +00:00
|
|
|
test: {
|
|
|
|
options: {
|
|
|
|
port: 8387,
|
|
|
|
server: './coverage/bin/server.js',
|
|
|
|
showStack: true
|
|
|
|
}
|
|
|
|
},
|
2014-12-09 08:04:28 +00:00
|
|
|
testSuite: {
|
2014-11-28 09:45:30 +00:00
|
|
|
options: {
|
|
|
|
port: 8388,
|
|
|
|
bases: 'test/www'
|
|
|
|
}
|
2014-09-03 07:06:35 +00:00
|
|
|
}
|
2014-08-07 17:27:32 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-12-13 11:11:33 +00:00
|
|
|
|
|
|
|
// 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));
|
2014-12-13 12:56:21 +00:00
|
|
|
grunt.log.ok('File ' + outputFile + ' created');
|
2014-12-13 11:11:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-07 17:27:32 +00:00
|
|
|
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
|
|
|
|
|
2014-09-26 15:06:49 +00:00
|
|
|
grunt.registerTask('icons', [
|
2014-09-04 14:15:24 +00:00
|
|
|
'font:icons',
|
2014-09-26 15:06:49 +00:00
|
|
|
'less',
|
2015-01-05 22:18:15 +00:00
|
|
|
'clean:tmp'
|
2014-09-04 14:15:24 +00:00
|
|
|
]);
|
2014-08-07 17:27:32 +00:00
|
|
|
|
2014-09-26 15:06:49 +00:00
|
|
|
grunt.registerTask('build', [
|
2014-12-30 07:11:47 +00:00
|
|
|
'less',
|
|
|
|
'replace'
|
2014-09-26 15:06:49 +00:00
|
|
|
]);
|
|
|
|
|
2014-09-03 07:06:35 +00:00
|
|
|
grunt.registerTask('hint', [
|
|
|
|
'jshint'
|
|
|
|
]);
|
|
|
|
|
2014-12-09 08:04:28 +00:00
|
|
|
grunt.registerTask('dev', [
|
2014-12-22 21:13:17 +00:00
|
|
|
'express:dev'
|
2014-12-09 08:04:28 +00:00
|
|
|
]);
|
|
|
|
|
2014-09-03 07:06:35 +00:00
|
|
|
grunt.registerTask('test', [
|
2014-11-28 09:45:30 +00:00
|
|
|
'build',
|
|
|
|
'jshint',
|
2014-12-09 08:04:28 +00:00
|
|
|
'express:testSuite',
|
2014-11-28 09:45:30 +00:00
|
|
|
'clean:coverage',
|
2014-12-13 12:56:21 +00:00
|
|
|
'copy-test-server-settings',
|
2015-01-05 22:18:15 +00:00
|
|
|
'lineremover:beforeCoverage',
|
|
|
|
'copy:beforeCoverage',
|
2014-11-28 09:45:30 +00:00
|
|
|
'blanket',
|
|
|
|
'copy:coverage',
|
2014-12-22 21:08:24 +00:00
|
|
|
'express:test',
|
2014-11-28 09:45:30 +00:00
|
|
|
'mochaTest:test',
|
2015-01-05 22:18:15 +00:00
|
|
|
'mochaTest:coverage',
|
|
|
|
'clean:tmp'
|
2014-11-28 09:45:30 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask('test-current-work', [
|
|
|
|
'build',
|
|
|
|
'jshint',
|
2014-12-09 08:04:28 +00:00
|
|
|
'express:testSuite',
|
2014-09-03 07:06:35 +00:00
|
|
|
'clean:coverage',
|
2014-12-13 12:56:21 +00:00
|
|
|
'copy-test-server-settings',
|
2015-01-05 22:18:15 +00:00
|
|
|
'lineremover:beforeCoverage',
|
|
|
|
'copy:beforeCoverage',
|
2014-09-03 07:06:35 +00:00
|
|
|
'blanket',
|
|
|
|
'copy:coverage',
|
2015-01-05 22:18:15 +00:00
|
|
|
'express:test',
|
|
|
|
'mochaTest:test-current-work',
|
|
|
|
'clean:tmp'
|
2014-09-03 07:06:35 +00:00
|
|
|
]);
|
2014-08-07 17:27:32 +00:00
|
|
|
|
|
|
|
};
|