1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-11 03:35:01 -05:00
mail/Gruntfile.js

492 lines
18 KiB
JavaScript
Raw Normal View History

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
2014-10-07 14:32:23 -04:00
require('time-grunt')(grunt);
var version = grunt.option('release'),
zipName = (version) ? version : 'DEV';
2013-11-12 14:02:46 -05:00
var browserifyOpt = {
exclude: ['openpgp', 'node-forge', 'net', 'tls', 'crypto'], // node apis not required at build time
ignore: ['buffer'], // node apis to be stubbed for runtime
browserifyOptions: {
debug: true
}
};
2013-08-09 11:23:38 -04:00
// Project configuration.
grunt.initConfig({
2014-10-02 16:05:44 -04:00
2013-08-09 11:23:38 -04:00
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-10-09 10:51:39 -04:00
all: ['Gruntfile.js', 'src/*.js', 'src/js/**/*.js', 'test/unit/*-test.js', 'test/integration/*-test.js'],
2013-08-09 11:23:38 -04:00
options: {
jshintrc: '.jshintrc'
}
},
2013-05-22 04:16:26 -04:00
2014-10-09 11:31:01 -04:00
mocha_phantomjs: {
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'
2014-10-09 11:31:01 -04:00
]
}
}
2013-09-16 13:46:04 -04:00
},
clean: {
2014-10-02 16:05:44 -04:00
dist: ['dist', 'test/lib', 'test/integration/src']
2013-09-16 13:46:04 -04:00
},
2014-10-02 16:05:44 -04:00
2013-09-16 13:46:04 -04:00
sass: {
dist: {
files: {
'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
}
}
},
2014-10-02 16:05:44 -04:00
2013-09-16 13:46:04 -04:00
autoprefixer: {
options: {
browsers: ['last 2 versions']
},
dist: {
files: {
'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
}
}
},
2014-10-02 16:05:44 -04:00
2013-09-16 13:46:04 -04:00
csso: {
options: {
2014-10-02 16:05:44 -04:00
banner: '/*! Copyright © <%= grunt.template.today("yyyy") %>, Whiteout Networks GmbH.*/\n'
2013-09-16 13:46:04 -04:00
},
dist: {
files: {
'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
}
}
},
2014-10-02 16:05:44 -04:00
2013-09-16 13:46:04 -04:00
watch: {
css: {
files: ['src/sass/**/*.scss'],
tasks: ['dist-css', 'manifest']
2013-09-17 07:04:41 -04:00
},
js: {
files: ['src/js/**/*.js'],
2014-10-02 16:05:44 -04:00
tasks: ['dist-js', 'copy:integration', 'manifest']
},
lib: {
files: ['src/lib/**/*.js'],
tasks: ['copy:lib', 'manifest']
},
app: {
files: ['src/*.js', 'src/**/*.html', 'src/**/*.json', 'src/manifest.*', 'src/img/**/*', 'src/font/**/*'],
tasks: ['copy:app', 'copy:ca', 'copy:tpl', 'copy:img', 'copy:font', 'manifest-dev', 'manifest']
2013-09-16 13:46:04 -04:00
}
},
2014-10-02 16:05:44 -04:00
browserify: {
2014-10-08 12:36:00 -04:00
app: {
2014-10-02 16:05:44 -04:00
files: {
'dist/js/app.browserified.js': ['src/js/app.js']
2014-10-02 16:05:44 -04:00
},
options: browserifyOpt
2014-10-08 12:36:00 -04:00
},
pbkdf2Worker: {
files: {
'dist/js/pbkdf2-worker.browserified.js': ['src/js/crypto/pbkdf2-worker.js']
},
options: browserifyOpt
2014-10-07 14:32:23 -04:00
},
2014-10-13 12:00:01 -04:00
mailreaderWorker: {
files: {
'dist/js/mailreader-parser-worker.browserified.js': ['node_modules/mailreader/src/mailreader-parser-worker-browserify.js']
},
options: browserifyOpt
2014-10-13 12:00:01 -04:00
},
2014-10-07 14:32:23 -04:00
unitTest: {
files: {
2014-10-09 09:23:41 -04:00
'test/unit/index.browserified.js': [
2014-10-09 08:28:47 -04:00
'test/unit/oauth-test.js',
'test/unit/auth-test.js',
'test/unit/email-dao-test.js',
'test/unit/app-controller-test.js',
'test/unit/pgp-test.js',
'test/unit/crypto-test.js',
'test/unit/backbutton-handler-test.js',
'test/unit/rest-dao-test.js',
'test/unit/admin-dao-test.js',
'test/unit/publickey-dao-test.js',
'test/unit/privatekey-dao-test.js',
'test/unit/lawnchair-dao-test.js',
'test/unit/keychain-dao-test.js',
'test/unit/devicestorage-dao-test.js',
'test/unit/dialog-ctrl-test.js',
'test/unit/add-account-ctrl-test.js',
'test/unit/account-ctrl-test.js',
'test/unit/set-passphrase-ctrl-test.js',
'test/unit/contacts-ctrl-test.js',
'test/unit/login-existing-ctrl-test.js',
'test/unit/login-initial-ctrl-test.js',
'test/unit/login-new-device-ctrl-test.js',
'test/unit/login-privatekey-download-ctrl-test.js',
'test/unit/login-set-credentials-ctrl-test.js',
'test/unit/privatekey-upload-ctrl-test.js',
'test/unit/login-ctrl-test.js',
'test/unit/read-ctrl-test.js',
'test/unit/navigation-ctrl-test.js',
'test/unit/mail-list-ctrl-test.js',
'test/unit/write-ctrl-test.js',
'test/unit/outbox-bo-test.js',
'test/unit/invitation-dao-test.js',
'test/unit/update-handler-test.js',
2014-10-09 09:23:41 -04:00
'test/unit/connection-doctor-test.js',
2014-10-09 10:51:39 -04:00
'test/main.js'
2014-10-09 08:28:47 -04:00
]
2014-10-07 14:32:23 -04:00
},
options: browserifyOpt
2014-10-02 16:05:44 -04:00
},
2014-10-09 10:51:39 -04:00
integrationTest: {
files: {
'test/integration/index.browserified.js': [
'test/integration/email-dao-test.js',
'test/main.js'
]
},
options: browserifyOpt
2014-10-09 10:51:39 -04:00
}
2014-10-02 16:05:44 -04:00
},
2014-10-09 12:39:08 -04:00
exorcise: {
app: {
2014-10-09 12:39:08 -04:00
files: {
'dist/js/app.browserified.js.map': ['dist/js/app.browserified.js'],
}
},
unitTest: {
files: {
'test/unit/index.browserified.js.map': ['test/unit/index.browserified.js'],
}
},
integrationTest: {
files: {
'test/integration/index.browserified.js.map': ['test/integration/index.browserified.js'],
}
2014-10-09 12:39:08 -04:00
}
},
2014-10-02 16:05:44 -04:00
uglify: {
2014-10-08 12:36:00 -04:00
app: {
2014-10-02 16:05:44 -04:00
files: {
'dist/js/app.min.js': [
'src/lib/underscore/underscore-min.js',
'node_modules/jquery/dist/jquery.min.js',
'src/lib/angular/angular.min.js',
'src/lib/angular/angular-route.min.js',
'src/lib/angular/angular-animate.min.js',
'src/lib/ngtagsinput/ng-tags-input.min.js',
'node_modules/ng-infinite-scroll/build/ng-infinite-scroll.min.js',
2014-10-08 12:36:00 -04:00
'src/lib/fastclick/fastclick.js',
2014-10-02 16:05:44 -04:00
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
'dist/js/app.browserified.js'
2014-10-02 16:05:44 -04:00
]
},
options: {
mangle: false,
sourceMap: true,
2014-10-09 12:39:08 -04:00
sourceMapIn: 'dist/js/app.browserified.js.map',
sourceMapIncludeSources: true,
sourceMapName: 'dist/js/app.min.js.map'
2014-10-02 16:05:44 -04:00
}
2013-09-16 13:46:04 -04:00
},
readSandbox: {
files: {
'dist/js/read-sandbox.min.js': [
'node_modules/dompurify/purify.js',
'src/js/controller/read-sandbox.js'
]
},
options: {
sourceMap: true,
sourceMapName: 'dist/js/read-sandbox.min.js.map'
}
},
2014-10-08 12:36:00 -04:00
pbkdf2Worker: {
files: {
'dist/js/pbkdf2-worker.min.js': ['dist/js/pbkdf2-worker.browserified.js']
2014-10-08 12:36:00 -04:00
}
},
2014-10-13 12:00:01 -04:00
mailreaderWorker: {
files: {
'dist/js/mailreader-parser-worker.min.js': ['dist/js/mailreader-parser-worker.browserified.js']
},
options: {
sourceMap: true,
sourceMapName: 'dist/js/mailreader-parser-worker.min.js.map'
}
},
2014-10-07 14:32:23 -04:00
unitTest: {
files: {
'test/unit/index.js': [
'src/lib/underscore/underscore-min.js',
'node_modules/jquery/dist/jquery.min.js',
'src/lib/angular/angular.min.js',
'src/lib/angular/angular-route.min.js',
'src/lib/angular/angular-animate.min.js',
2014-10-09 09:56:35 -04:00
'node_modules/angularjs/src/ngMock/angular-mocks.js',
2014-10-07 14:32:23 -04:00
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
2014-10-09 09:23:41 -04:00
'test/unit/index.browserified.js'
2014-10-07 14:32:23 -04:00
]
2014-10-08 12:36:00 -04:00
},
options: {
2014-10-09 09:23:41 -04:00
mangle: false,
sourceMap: true,
sourceMapIn: 'test/unit/index.browserified.js.map',
sourceMapIncludeSources: true,
2014-10-09 09:23:41 -04:00
sourceMapName: 'test/unit/index.js.map'
2014-10-07 14:32:23 -04:00
}
},
2014-10-09 10:51:39 -04:00
integrationTest: {
files: {
'test/integration/index.js': [
'src/lib/underscore/underscore-min.js',
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
'test/integration/index.browserified.js'
]
},
options: {
mangle: false,
sourceMap: true,
sourceMapIn: 'test/integration/index.browserified.js.map',
sourceMapIncludeSources: true,
2014-10-09 10:51:39 -04:00
sourceMapName: 'test/integration/index.js.map'
}
},
2014-10-02 16:05:44 -04:00
options: {
banner: '/*! Copyright © <%= grunt.template.today("yyyy") %>, Whiteout Networks GmbH.*/\n'
}
},
copy: {
npmDev: {
2013-09-16 13:46:04 -04:00
expand: true,
flatten: true,
2014-10-09 09:23:41 -04:00
cwd: './',
src: [
'node_modules/mocha/mocha.css',
'node_modules/mocha/mocha.js',
'node_modules/chai/chai.js',
'node_modules/sinon/pkg/sinon.js',
'node_modules/browsercrow/src/*.js',
'node_modules/browsersmtp/src/*.js',
'src/lib/openpgp/openpgp.js',
'src/lib/openpgp/openpgp.worker.js',
'src/lib/forge/forge.min.js',
'dist/js/pbkdf2-worker.min.js'
],
dest: 'test/lib/'
},
2014-10-08 12:36:00 -04:00
lib: {
expand: true,
flatten: true,
cwd: 'src/lib/',
src: ['openpgp/openpgp.js', 'openpgp/openpgp.worker.js', 'forge/forge.min.js'],
dest: 'dist/js/'
},
2014-10-13 13:11:04 -04:00
tls: {
expand: true,
flatten: true,
cwd: 'node_modules/tcp-socket/src/',
src: ['tcp-socket-tls-worker.js', 'tcp-socket-tls.js'],
dest: 'dist/js/'
},
font: {
2013-09-16 13:46:04 -04:00
expand: true,
2013-09-17 11:34:40 -04:00
cwd: 'src/font/',
src: ['*'],
dest: 'dist/font/'
2013-09-16 13:46:04 -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: ['*'],
dest: 'dist/img/'
},
tpl: {
expand: true,
2013-09-17 11:34:40 -04:00
cwd: 'src/tpl/',
src: ['*'],
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', 'manifest.*'],
2013-09-16 13:46:04 -04:00
dest: 'dist/'
}
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-02 17:50:16 -05:00
},
manifest: {
generate: {
options: {
basePath: 'dist/',
timestamp: true,
hash: true,
cache: ['socket.io/socket.io.js'],
exclude: [
'appcache.manifest',
'manifest.webapp',
'js/app.min.js.map',
'js/app.browserified.js',
2014-10-09 12:39:08 -04:00
'js/app.browserified.js.map',
'js/crypto/pbkdf2-worker.browserified.js',
'js/pbkdf2-worker.browserified.js',
'js/read-sandbox.min.js.map'
],
master: ['index.html']
},
src: ['**/*.*'],
dest: 'dist/appcache.manifest'
}
2014-10-02 16:05:44 -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)
2014-10-02 16:05:44 -04:00
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
2013-08-09 11:23:38 -04:00
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
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');
grunt.loadNpmTasks('grunt-manifest');
2014-10-09 11:31:01 -04:00
grunt.loadNpmTasks('grunt-mocha-phantomjs');
2014-10-09 12:39:08 -04:00
grunt.loadNpmTasks('grunt-exorcise');
2013-05-21 09:38:18 -04:00
2013-09-17 07:04:41 -04:00
// Build tasks
2013-09-16 13:46:04 -04:00
grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']);
2014-10-09 12:39:08 -04:00
grunt.registerTask('dist-js', ['browserify', 'exorcise', 'uglify']);
2013-09-17 07:04:41 -04:00
grunt.registerTask('dist-copy', ['copy']);
2014-10-09 09:23:41 -04:00
grunt.registerTask('dist', ['clean', 'dist-css', 'dist-js', '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']);
2014-10-09 11:31:01 -04:00
grunt.registerTask('test', ['jshint', 'connect:test', 'mocha_phantomjs']);
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)',
version: '9999.9999.9999.9999'
2013-11-12 14:02:46 -05:00
});
});
grunt.registerTask('manifest-test', function() {
if (!version) {
throw new Error('You must specify the version: "--release=1.0"');
}
2013-11-12 14:02:46 -05:00
patchManifest({
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() {
if (!version) {
throw new Error('You must specify the version: "--release=1.0"');
}
patchManifest({
2013-11-13 07:15:44 -05:00
version: version,
deleteKey: true,
keyServer: 'https://keys.whiteout.io/',
keychainServer: 'https://keychain.whiteout.io/'
});
2013-11-12 14:02:46 -05:00
});
function patchManifest(options) {
var fs = require('fs'),
path = './dist/manifest.json',
manifest = require(path);
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;
}
if (options.keyServer) {
var ksIndex = manifest.permissions.indexOf('https://keys-test.whiteout.io/');
manifest.permissions[ksIndex] = options.keyServer;
}
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']);
grunt.registerTask('default', ['release-dev']);
2013-11-12 14:02:46 -05:00
};