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-11-13 05:50:41 -05:00
|
|
|
var version = grunt.option('release'),
|
|
|
|
zipName = (version) ? version : 'DEV';
|
2013-11-12 14:02:46 -05: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: '.'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-05-22 04:16:26 -04:00
|
|
|
|
2013-08-09 11:23:38 -04:00
|
|
|
jshint: {
|
2014-06-05 09:36:53 -04:00
|
|
|
all: ['Gruntfile.js', 'src/*.js', 'src/js/**/*.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-19 15:13:32 -04:00
|
|
|
mocha: {
|
|
|
|
all: {
|
|
|
|
options: {
|
2014-06-11 03:42:34 -04:00
|
|
|
urls: [
|
2014-06-05 09:36:53 -04:00
|
|
|
'http://localhost:<%= connect.test.options.port %>/test/unit/index.html',
|
2014-06-11 03:42:34 -04:00
|
|
|
'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'
|
|
|
|
],
|
2013-10-29 07:19:27 -04:00
|
|
|
run: false,
|
2014-06-11 03:42:34 -04:00
|
|
|
reporter: 'Spec',
|
|
|
|
log: false,
|
|
|
|
|
|
|
|
// phanotmjs is soooo slow
|
|
|
|
timeout: 100000
|
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: {
|
2014-07-10 14:07:03 -04:00
|
|
|
'src/css/read-sandbox.css': 'src/sass/read-sandbox.scss',
|
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: {
|
2014-07-10 14:07:03 -04:00
|
|
|
'src/css/read-sandbox.css': 'src/css/read-sandbox.css',
|
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: {
|
2014-07-10 14:07:03 -04:00
|
|
|
'dist/css/read-sandbox.min.css': 'src/css/read-sandbox.css',
|
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'],
|
2014-09-17 08:43:53 -04:00
|
|
|
tasks: ['dist-css', 'manifest']
|
2013-09-17 07:04:41 -04:00
|
|
|
},
|
2013-09-17 08:40:35 -04:00
|
|
|
js: {
|
|
|
|
files: ['src/js/**/*.js'],
|
2014-09-17 08:43:53 -04:00
|
|
|
tasks: ['copy:js', 'copy:integration', 'manifest']
|
2013-09-17 08:40:35 -04:00
|
|
|
},
|
|
|
|
lib: {
|
|
|
|
files: ['src/lib/**/*.js'],
|
2014-09-17 08:43:53 -04:00
|
|
|
tasks: ['copy:lib', 'manifest']
|
2013-09-17 08:40:35 -04:00
|
|
|
},
|
|
|
|
app: {
|
|
|
|
files: ['src/*.js', 'src/**/*.html', 'src/**/*.json', 'src/img/**/*', 'src/font/**/*'],
|
2014-09-17 08:43:53 -04:00
|
|
|
tasks: ['copy:app', 'copy:ca', 'copy:tpl', 'copy:img', 'copy:font', 'manifest-dev', 'manifest']
|
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
|
|
|
'imap-client/src/*.js',
|
2014-04-17 09:13:18 -04:00
|
|
|
'imap-client/node_modules/browserbox/src/*.js',
|
2014-07-28 13:01:47 -04:00
|
|
|
'imap-client/node_modules/browserbox/node_modules/wo-imap-handler/src/*.js',
|
2014-04-17 09:13:18 -04:00
|
|
|
'imap-client/node_modules/browserbox/node_modules/mimefuncs/src/*.js',
|
|
|
|
'imap-client/node_modules/browserbox/node_modules/tcp-socket/src/*.js',
|
2014-07-28 13:01:47 -04:00
|
|
|
'imap-client/node_modules/browserbox/node_modules/wo-utf7/src/*.js',
|
2014-02-25 13:18:37 -05:00
|
|
|
'mailreader/src/*.js',
|
2014-04-17 09:13:18 -04:00
|
|
|
'mailreader/node_modules/mimeparser/src/*.js',
|
2014-07-28 13:01:47 -04:00
|
|
|
'mailreader/node_modules/mimeparser/node_modules/wo-addressparser/src/*.js',
|
2014-04-22 12:19:28 -04:00
|
|
|
'pgpbuilder/src/*.js',
|
|
|
|
'pgpbuilder/node_modules/mailbuild/src/*.js',
|
|
|
|
'pgpbuilder/node_modules/mailbuild/node_modules/mimetypes/src/*.js',
|
|
|
|
'pgpbuilder/node_modules/mailbuild/node_modules/punycode/punycode.min.js',
|
|
|
|
'pgpmailer/src/*.js',
|
2014-07-28 13:01:47 -04:00
|
|
|
'pgpmailer/node_modules/wo-smtpclient/src/*.js',
|
|
|
|
'pgpmailer/node_modules/wo-smtpclient/node_modules/wo-stringencoding/dist/stringencoding.js',
|
|
|
|
'axe-logger/axe.js',
|
2014-07-16 06:47:25 -04:00
|
|
|
'dompurify/purify.js',
|
|
|
|
'jquery/dist/jquery.min.js',
|
|
|
|
'ng-infinite-scroll/build/ng-infinite-scroll.min.js'
|
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/',
|
2014-06-11 03:42:34 -04:00
|
|
|
src: ['requirejs/require.js', 'mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js', 'angularjs/src/ngMock/angular-mocks.js', 'browsercrow/src/*.js', 'browsersmtp/src/*.js'],
|
2013-10-02 09:47:41 -04:00
|
|
|
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
|
|
|
},
|
2013-11-14 11:41:31 -05:00
|
|
|
ca: {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'src/ca/',
|
|
|
|
src: ['*'],
|
|
|
|
dest: 'dist/ca/'
|
|
|
|
},
|
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-11-12 14:02:46 -05:00
|
|
|
},
|
2014-03-02 17:50:16 -05:00
|
|
|
|
2013-11-12 14:02:46 -05:00
|
|
|
compress: {
|
2014-03-03 07:00:26 -05:00
|
|
|
main: {
|
2013-11-12 14:02:46 -05:00
|
|
|
options: {
|
|
|
|
mode: 'zip',
|
2014-03-03 07:00:26 -05:00
|
|
|
archive: 'release/whiteout-mail_' + zipName + '.zip'
|
2013-11-12 14:02:46 -05:00
|
|
|
},
|
|
|
|
expand: true,
|
|
|
|
cwd: 'dist/',
|
|
|
|
src: ['**/*'],
|
|
|
|
dest: 'release/'
|
2014-03-05 14:14:23 -05:00
|
|
|
},
|
|
|
|
nodeWebkit: {
|
|
|
|
options: {
|
|
|
|
mode: 'zip',
|
|
|
|
archive: 'release/whiteout-mail_' + zipName + '.nw'
|
|
|
|
},
|
|
|
|
expand: true,
|
|
|
|
cwd: 'dist/',
|
|
|
|
src: ['**/*'],
|
|
|
|
dest: '/'
|
2013-11-12 14:02:46 -05:00
|
|
|
}
|
2014-03-02 17:50:16 -05:00
|
|
|
},
|
|
|
|
|
2014-08-13 10:16:28 -04:00
|
|
|
manifest: {
|
|
|
|
generate: {
|
|
|
|
options: {
|
|
|
|
basePath: 'dist/',
|
|
|
|
timestamp: true,
|
|
|
|
hash: true,
|
|
|
|
cache: ['socket.io/socket.io.js'],
|
|
|
|
master: ['index.html']
|
|
|
|
},
|
|
|
|
src: ['**/*.*'],
|
|
|
|
dest: 'dist/appcache.manifest'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-03-02 17:50:16 -05:00
|
|
|
nodewebkit: {
|
|
|
|
options: {
|
|
|
|
version: '0.9.2', // node-webkit version
|
2014-03-03 07:00:26 -05:00
|
|
|
build_dir: './release/node-webkit/', // Where the build version of my node-webkit app is saved
|
2014-03-02 17:50:16 -05:00
|
|
|
mac: true, // We want to build it for mac
|
|
|
|
win: false, // We want to build it for win
|
|
|
|
linux32: false, // We don't need linux32
|
|
|
|
linux64: false, // We don't need linux64
|
|
|
|
},
|
|
|
|
src: ['./dist/**/*'] // Your node-webkit app
|
|
|
|
},
|
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');
|
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-11-12 14:02:46 -05:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-compress');
|
2014-03-02 17:50:16 -05:00
|
|
|
grunt.loadNpmTasks('grunt-node-webkit-builder');
|
2014-08-13 10:16:28 -04:00
|
|
|
grunt.loadNpmTasks('grunt-manifest');
|
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']);
|
2014-08-13 10:16:28 -04:00
|
|
|
grunt.registerTask('dist', ['clean', 'dist-npm', 'dist-css', 'dist-copy', 'manifest']);
|
2013-09-16 13:46:04 -04:00
|
|
|
|
2013-09-17 07:04:41 -04:00
|
|
|
// Test/Dev tasks
|
|
|
|
grunt.registerTask('dev', ['connect:dev']);
|
2013-12-09 13:21:52 -05:00
|
|
|
grunt.registerTask('test', ['jshint', 'connect:test', 'mocha']);
|
2013-09-17 07:04:41 -04:00
|
|
|
grunt.registerTask('prod', ['connect:prod']);
|
|
|
|
|
2013-11-12 14:02:46 -05:00
|
|
|
//
|
|
|
|
// Release tasks for Chrome App Release Channels
|
|
|
|
//
|
|
|
|
|
|
|
|
grunt.registerTask('manifest-dev', function() {
|
|
|
|
patchManifest({
|
|
|
|
suffix: ' (DEV)',
|
2013-11-13 05:50:41 -05:00
|
|
|
version: '9999.9999.9999.9999'
|
2013-11-12 14:02:46 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
grunt.registerTask('manifest-test', function() {
|
2013-11-13 05:50:41 -05:00
|
|
|
if (!version) {
|
|
|
|
throw new Error('You must specify the version: "--release=1.0"');
|
|
|
|
}
|
|
|
|
|
2013-11-12 14:02:46 -05:00
|
|
|
patchManifest({
|
2013-11-13 05:50:41 -05:00
|
|
|
suffix: ' (TEST)',
|
|
|
|
client_id: '440907777130-bfpgo5fbo4f7hetrg3hn57qolrtubs0u.apps.googleusercontent.com',
|
2013-11-13 07:15:44 -05:00
|
|
|
version: version,
|
|
|
|
deleteKey: true
|
2013-11-12 14:02:46 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
grunt.registerTask('manifest-stable', function() {
|
2013-11-13 05:50:41 -05:00
|
|
|
if (!version) {
|
|
|
|
throw new Error('You must specify the version: "--release=1.0"');
|
|
|
|
}
|
|
|
|
|
|
|
|
patchManifest({
|
2013-11-13 07:15:44 -05:00
|
|
|
version: version,
|
2013-12-02 04:33:45 -05:00
|
|
|
deleteKey: true,
|
2014-06-26 11:21:28 -04:00
|
|
|
keyServer: 'https://keys.whiteout.io/',
|
|
|
|
keychainServer: 'https://keychain.whiteout.io/'
|
2013-11-13 05:50:41 -05:00
|
|
|
});
|
2013-11-12 14:02:46 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
function patchManifest(options) {
|
|
|
|
var fs = require('fs'),
|
|
|
|
path = './dist/manifest.json',
|
|
|
|
manifest = require(path);
|
|
|
|
|
2013-11-13 05:50:41 -05:00
|
|
|
if (options.version) {
|
|
|
|
manifest.version = options.version;
|
2013-11-12 14:02:46 -05:00
|
|
|
}
|
|
|
|
if (options.suffix) {
|
|
|
|
manifest.name += options.suffix;
|
|
|
|
}
|
|
|
|
if (options.client_id) {
|
|
|
|
manifest.oauth2.client_id = options.client_id;
|
|
|
|
}
|
2013-12-02 04:33:45 -05:00
|
|
|
if (options.keyServer) {
|
2014-01-23 08:52:46 -05:00
|
|
|
var ksIndex = manifest.permissions.indexOf('https://keys-test.whiteout.io/');
|
2013-12-02 04:33:45 -05:00
|
|
|
manifest.permissions[ksIndex] = options.keyServer;
|
|
|
|
}
|
2014-06-26 11:21:28 -04:00
|
|
|
if (options.keychainServer) {
|
|
|
|
var kcsIndex = manifest.permissions.indexOf('https://keychain-test.whiteout.io/');
|
|
|
|
manifest.permissions[kcsIndex] = options.keychainServer;
|
|
|
|
}
|
2013-11-13 07:15:44 -05:00
|
|
|
if (options.deleteKey) {
|
|
|
|
delete manifest.key;
|
|
|
|
}
|
2013-11-12 14:02:46 -05:00
|
|
|
|
|
|
|
fs.writeFileSync(path, JSON.stringify(manifest, null, 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
grunt.registerTask('release-dev', ['dist', 'manifest-dev', 'compress']);
|
|
|
|
grunt.registerTask('release-test', ['dist', 'manifest-test', 'compress']);
|
|
|
|
grunt.registerTask('release-stable', ['dist', 'manifest-stable', 'compress']);
|
2013-11-13 05:50:41 -05:00
|
|
|
grunt.registerTask('default', ['release-dev']);
|
2013-11-12 14:02:46 -05:00
|
|
|
|
2013-05-21 09:38:18 -04:00
|
|
|
};
|