2013-05-21 09:38:18 -04:00
|
|
|
module.exports = function(grunt) {
|
2013-08-09 11:23:38 -04:00
|
|
|
'use strict';
|
2013-05-21 09:38:18 -04:00
|
|
|
|
2013-08-09 11:23:38 -04:00
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
|
|
|
connect: {
|
|
|
|
dev: {
|
|
|
|
options: {
|
|
|
|
port: 8580,
|
|
|
|
base: '.',
|
|
|
|
keepalive: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
test: {
|
|
|
|
options: {
|
|
|
|
port: 8581,
|
|
|
|
base: '.'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
prod: {
|
|
|
|
options: {
|
|
|
|
port: process.env.PORT || 8585,
|
2013-09-27 10:17:38 -04:00
|
|
|
base: './dist/',
|
2013-08-09 11:23:38 -04:00
|
|
|
keepalive: true,
|
|
|
|
middleware: function(connect, options) {
|
|
|
|
// Return array of whatever middlewares you want
|
2013-09-27 10:17:38 -04:00
|
|
|
return [
|
|
|
|
function(req, res, next) {
|
|
|
|
res.setHeader('Content-Security-Policy', "default-src 'self'; connect-src *; object-src 'none'; style-src 'self' 'unsafe-inline'");
|
2013-05-22 04:16:26 -04:00
|
|
|
|
2013-08-09 11:23:38 -04:00
|
|
|
return next();
|
|
|
|
},
|
2013-05-22 04:16:26 -04:00
|
|
|
|
2013-08-09 11:23:38 -04:00
|
|
|
// Serve static files.
|
2013-09-27 10:17:38 -04:00
|
|
|
connect.static(options.base)
|
|
|
|
];
|
2013-08-09 11:23:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-05-22 04:16:26 -04:00
|
|
|
|
2013-08-09 11:23:38 -04:00
|
|
|
jshint: {
|
2013-08-19 15:13:32 -04:00
|
|
|
all: ['Gruntfile.js', 'src/*.js', 'src/js/**/*.js', 'test/new-unit/*.js', 'test/unit/*.js', 'test/integration/*.js'],
|
2013-08-09 11:23:38 -04:00
|
|
|
options: {
|
|
|
|
jshintrc: '.jshintrc'
|
|
|
|
}
|
|
|
|
},
|
2013-05-22 04:16:26 -04:00
|
|
|
|
2013-08-09 11:23:38 -04:00
|
|
|
qunit: {
|
|
|
|
all: {
|
|
|
|
options: {
|
|
|
|
timeout: 20000,
|
|
|
|
urls: ['http://localhost:<%= connect.test.options.port %>/test/unit/index.html'
|
|
|
|
/*,
|
|
|
|
'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'*/
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2013-08-19 15:13:32 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
mocha: {
|
|
|
|
all: {
|
|
|
|
options: {
|
|
|
|
urls: ['http://localhost:<%= connect.test.options.port %>/test/new-unit/index.html'],
|
2013-09-11 18:11:44 -04:00
|
|
|
run: false
|
2013-08-19 15:13:32 -04:00
|
|
|
}
|
|
|
|
}
|
2013-09-16 13:46:04 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
clean: {
|
2013-10-02 09:47:41 -04:00
|
|
|
dist: ['dist', 'src/lib/*.js', 'test/lib', 'test/integration/src']
|
2013-09-16 13:46:04 -04:00
|
|
|
},
|
|
|
|
sass: {
|
|
|
|
dist: {
|
|
|
|
files: {
|
2013-10-22 12:26:30 -04:00
|
|
|
'src/css/all.css': 'src/sass/all.scss'
|
2013-09-16 13:46:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
autoprefixer: {
|
|
|
|
options: {
|
|
|
|
browsers: ['last 2 versions']
|
|
|
|
},
|
|
|
|
dist: {
|
|
|
|
files: {
|
2013-10-22 12:26:30 -04:00
|
|
|
'src/css/all.css': 'src/css/all.css'
|
2013-09-16 13:46:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
csso: {
|
|
|
|
options: {
|
2013-10-22 12:57:21 -04:00
|
|
|
banner: '/*! Copyright © 2013, Whiteout Networks GmbH. All rights reserved.*/\n'
|
2013-09-16 13:46:04 -04:00
|
|
|
},
|
|
|
|
dist: {
|
|
|
|
files: {
|
2013-10-22 12:26:30 -04:00
|
|
|
'dist/css/all.min.css': 'src/css/all.css'
|
2013-09-16 13:46:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
css: {
|
|
|
|
files: ['src/sass/**/*.scss'],
|
|
|
|
tasks: ['dist-css']
|
2013-09-17 07:04:41 -04:00
|
|
|
},
|
2013-09-17 08:40:35 -04:00
|
|
|
js: {
|
|
|
|
files: ['src/js/**/*.js'],
|
|
|
|
tasks: ['copy:js']
|
|
|
|
},
|
|
|
|
lib: {
|
|
|
|
files: ['src/lib/**/*.js'],
|
|
|
|
tasks: ['copy:lib']
|
|
|
|
},
|
|
|
|
app: {
|
|
|
|
files: ['src/*.js', 'src/**/*.html', 'src/**/*.json', 'src/img/**/*', 'src/font/**/*'],
|
|
|
|
tasks: ['copy:app', 'copy:tpl', 'copy:img', 'copy:font']
|
2013-09-16 13:46:04 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
copy: {
|
2013-09-17 08:40:35 -04:00
|
|
|
npm: {
|
2013-09-16 13:46:04 -04:00
|
|
|
expand: true,
|
|
|
|
flatten: true,
|
2013-09-17 11:34:40 -04:00
|
|
|
cwd: 'node_modules/',
|
2013-09-19 12:35:12 -04:00
|
|
|
src: [
|
2013-09-19 13:55:21 -04:00
|
|
|
'requirejs/require.js',
|
2013-09-19 12:35:12 -04:00
|
|
|
'crypto-lib/node_modules/node-forge/js/*.js',
|
|
|
|
'imap-client/src/*.js',
|
|
|
|
'imap-client/node_modules/inbox/src/*.js',
|
|
|
|
'imap-client/node_modules/setimmediate/setImmediate.js',
|
|
|
|
'imap-client/node_modules/inbox/node_modules/node-shims/src/*.js',
|
|
|
|
'imap-client/node_modules/inbox/node_modules/utf7/src/utf7.js',
|
|
|
|
'imap-client/node_modules/inbox/node_modules/xoauth2/src/xoauth2.js',
|
|
|
|
'imap-client/node_modules/mimelib/src/mimelib.js',
|
|
|
|
'imap-client/node_modules/mimelib/node_modules/addressparser/src/addressparser.js',
|
|
|
|
'imap-client/node_modules/mimelib/node_modules/encoding/src/encoding.js',
|
|
|
|
'imap-client/node_modules/mimelib/node_modules/encoding/node_modules/iconv-lite/src/*.js',
|
|
|
|
'imap-client/node_modules/mimelib/node_modules/encoding/node_modules/mime/src/*.js',
|
|
|
|
'imap-client/node_modules/mailparser/src/*.js',
|
2013-09-26 07:26:57 -04:00
|
|
|
'imap-client/node_modules/mailparser/node_modules/mime/src/mime.js',
|
2013-09-27 07:55:08 -04:00
|
|
|
'smtp-client/src/*.js',
|
|
|
|
'smtp-client/node_modules/mailcomposer/src/*',
|
|
|
|
'smtp-client/node_modules/nodemailer/src/*',
|
|
|
|
'smtp-client/node_modules/nodemailer/node_modules/simplesmtp/src/*',
|
2013-09-19 12:35:12 -04:00
|
|
|
],
|
2013-09-17 08:40:35 -04:00
|
|
|
dest: 'src/lib/'
|
2013-09-16 13:46:04 -04:00
|
|
|
},
|
2013-09-17 08:40:35 -04:00
|
|
|
npmDev: {
|
2013-09-16 13:46:04 -04:00
|
|
|
expand: true,
|
|
|
|
flatten: true,
|
2013-09-17 11:34:40 -04:00
|
|
|
cwd: 'node_modules/',
|
2013-10-02 09:47:41 -04:00
|
|
|
src: ['requirejs/require.js', 'mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js'],
|
|
|
|
dest: 'test/lib/'
|
2013-09-17 08:40:35 -04:00
|
|
|
},
|
|
|
|
cryptoLib: {
|
|
|
|
expand: true,
|
2013-09-17 11:34:40 -04:00
|
|
|
cwd: 'node_modules/crypto-lib/src/',
|
|
|
|
src: ['*.js'],
|
2013-09-17 08:40:35 -04:00
|
|
|
dest: 'src/js/crypto/'
|
|
|
|
},
|
|
|
|
lib: {
|
|
|
|
expand: true,
|
2013-09-17 11:34:40 -04:00
|
|
|
cwd: 'src/lib/',
|
|
|
|
src: ['**'],
|
2013-09-17 08:40:35 -04:00
|
|
|
dest: 'dist/lib/'
|
2013-09-16 13:46:04 -04:00
|
|
|
},
|
|
|
|
js: {
|
|
|
|
expand: true,
|
2013-09-17 11:34:40 -04:00
|
|
|
cwd: 'src/js/',
|
|
|
|
src: ['**'],
|
2013-09-16 13:46:04 -04:00
|
|
|
dest: 'dist/js/'
|
|
|
|
},
|
2013-09-17 08:40:35 -04:00
|
|
|
font: {
|
2013-09-16 13:46:04 -04:00
|
|
|
expand: true,
|
2013-09-17 11:34:40 -04:00
|
|
|
cwd: 'src/font/',
|
|
|
|
src: ['*'],
|
2013-09-17 08:40:35 -04:00
|
|
|
dest: 'dist/font/'
|
2013-09-16 13:46:04 -04:00
|
|
|
},
|
2013-09-17 08:40:35 -04:00
|
|
|
img: {
|
2013-09-16 13:46:04 -04:00
|
|
|
expand: true,
|
2013-09-17 11:34:40 -04:00
|
|
|
cwd: 'src/img/',
|
|
|
|
src: ['*'],
|
2013-09-17 08:40:35 -04:00
|
|
|
dest: 'dist/img/'
|
|
|
|
},
|
|
|
|
tpl: {
|
|
|
|
expand: true,
|
2013-09-17 11:34:40 -04:00
|
|
|
cwd: 'src/tpl/',
|
|
|
|
src: ['*'],
|
2013-09-17 08:40:35 -04:00
|
|
|
dest: 'dist/tpl/'
|
2013-09-16 13:46:04 -04:00
|
|
|
},
|
|
|
|
app: {
|
|
|
|
expand: true,
|
2013-09-17 11:34:40 -04:00
|
|
|
cwd: 'src/',
|
|
|
|
src: ['*.html', '*.js', '*.json'],
|
2013-09-16 13:46:04 -04:00
|
|
|
dest: 'dist/'
|
2013-10-02 09:47:41 -04:00
|
|
|
},
|
|
|
|
integration: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'src/',
|
|
|
|
src: ['**'],
|
|
|
|
dest: 'test/integration/src/'
|
2013-09-16 13:46:04 -04:00
|
|
|
}
|
2013-08-09 11:23:38 -04:00
|
|
|
}
|
|
|
|
});
|
2013-05-21 09:38:18 -04:00
|
|
|
|
2013-08-09 11:23:38 -04:00
|
|
|
// Load the plugin(s)
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-qunit');
|
2013-08-19 15:13:32 -04:00
|
|
|
grunt.loadNpmTasks('grunt-mocha');
|
2013-09-16 13:46:04 -04:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
|
|
|
grunt.loadNpmTasks('grunt-csso');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-sass');
|
|
|
|
grunt.loadNpmTasks('grunt-autoprefixer');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
2013-05-21 09:38:18 -04:00
|
|
|
|
2013-09-17 07:04:41 -04:00
|
|
|
// Build tasks
|
2013-09-17 08:40:35 -04:00
|
|
|
grunt.registerTask('dist-npm', ['copy:npm', 'copy:npmDev', 'copy:cryptoLib']);
|
2013-09-16 13:46:04 -04:00
|
|
|
grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']);
|
2013-09-17 07:04:41 -04:00
|
|
|
grunt.registerTask('dist-copy', ['copy']);
|
2013-09-17 08:40:35 -04:00
|
|
|
grunt.registerTask('dist', ['clean', 'dist-npm', 'dist-css', 'dist-copy']);
|
2013-09-16 13:46:04 -04:00
|
|
|
grunt.registerTask('default', ['dist']);
|
|
|
|
|
2013-09-17 07:04:41 -04:00
|
|
|
// Test/Dev tasks
|
|
|
|
grunt.registerTask('dev', ['connect:dev']);
|
2013-09-17 08:40:35 -04:00
|
|
|
grunt.registerTask('test', ['jshint', 'connect:test', 'mocha', 'qunit']);
|
2013-09-17 07:04:41 -04:00
|
|
|
grunt.registerTask('prod', ['connect:prod']);
|
|
|
|
|
2013-05-21 09:38:18 -04:00
|
|
|
};
|