2014-11-08 01:55:33 +00:00
|
|
|
var child_process = require('child_process');
|
|
|
|
var util = require('util');
|
2014-10-31 07:40:00 +00:00
|
|
|
|
2014-10-30 01:32:29 +00:00
|
|
|
module.exports = function(grunt) {
|
2014-11-23 03:36:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-10-31 00:57:37 +00:00
|
|
|
var bower = grunt.file.readJSON('bower.json');
|
2014-10-30 01:32:29 +00:00
|
|
|
var components = [];
|
2014-10-31 07:40:00 +00:00
|
|
|
for (var i in bower.concat.app) {
|
2014-10-31 00:57:37 +00:00
|
|
|
components.push('components/' + bower.concat.app[i] + '/**/*.js');
|
2014-10-30 01:32:29 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 22:22:26 +00:00
|
|
|
var libtextsecurecomponents = [];
|
|
|
|
for (i in bower.concat.libtextsecure) {
|
|
|
|
libtextsecurecomponents.push('components/' + bower.concat.libtextsecure[i] + '/**/*.js');
|
2015-01-14 01:23:11 +00:00
|
|
|
}
|
|
|
|
|
2014-10-30 01:32:29 +00:00
|
|
|
grunt.initConfig({
|
2014-11-23 03:36:52 +00:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
2014-10-30 01:32:29 +00:00
|
|
|
concat: {
|
|
|
|
components: {
|
|
|
|
src: components,
|
2014-10-30 23:53:08 +00:00
|
|
|
dest: 'js/components.js',
|
2014-10-30 01:32:29 +00:00
|
|
|
},
|
2015-01-14 22:22:26 +00:00
|
|
|
libtextsecurecomponents: {
|
|
|
|
src: libtextsecurecomponents,
|
2015-01-14 01:23:11 +00:00
|
|
|
dest: 'libtextsecure/components.js',
|
|
|
|
},
|
2014-11-10 05:44:56 +00:00
|
|
|
test: {
|
|
|
|
src: [
|
|
|
|
'components/mocha/mocha.js',
|
|
|
|
'components/chai/chai.js',
|
|
|
|
'test/_test.js'
|
|
|
|
],
|
|
|
|
dest: 'test/test.js',
|
2015-01-14 00:09:32 +00:00
|
|
|
},
|
2015-01-16 00:30:55 +00:00
|
|
|
//TODO: Move errors back down?
|
2015-01-14 00:09:32 +00:00
|
|
|
libtextsecure: {
|
2015-04-04 00:18:00 +00:00
|
|
|
options: {
|
|
|
|
banner: ";(function() {\n",
|
|
|
|
footer: "})();\n",
|
|
|
|
},
|
2015-01-14 00:09:32 +00:00
|
|
|
src: [
|
2015-01-16 00:30:55 +00:00
|
|
|
'libtextsecure/errors.js',
|
2015-03-17 21:31:33 +00:00
|
|
|
'libtextsecure/libaxolotl.js',
|
2015-01-14 23:42:01 +00:00
|
|
|
'libtextsecure/axolotl_wrapper.js',
|
2015-01-14 01:49:38 +00:00
|
|
|
|
2015-01-16 04:11:08 +00:00
|
|
|
'libtextsecure/crypto.js',
|
2015-01-14 22:22:26 +00:00
|
|
|
'libtextsecure/storage.js',
|
2015-03-24 22:48:59 +00:00
|
|
|
'libtextsecure/storage/user.js',
|
2015-01-14 22:22:26 +00:00
|
|
|
'libtextsecure/storage/devices.js',
|
2015-01-21 05:48:27 +00:00
|
|
|
'libtextsecure/storage/groups.js',
|
2015-01-14 00:09:32 +00:00
|
|
|
'libtextsecure/protobufs.js',
|
|
|
|
'libtextsecure/websocket.js',
|
|
|
|
'libtextsecure/websocket-resources.js',
|
|
|
|
'libtextsecure/helpers.js',
|
|
|
|
'libtextsecure/stringview.js',
|
|
|
|
'libtextsecure/api.js',
|
2015-04-30 00:00:30 +00:00
|
|
|
'libtextsecure/account_manager.js',
|
2015-04-29 18:56:40 +00:00
|
|
|
'libtextsecure/message_receiver.js',
|
2015-01-14 00:09:32 +00:00
|
|
|
'libtextsecure/sendmessage.js',
|
2015-06-01 21:08:21 +00:00
|
|
|
'libtextsecure/contacts_parser.js',
|
2015-01-14 00:09:32 +00:00
|
|
|
],
|
|
|
|
dest: 'js/libtextsecure.js',
|
|
|
|
},
|
2015-01-14 01:04:21 +00:00
|
|
|
libtextsecuretest: {
|
|
|
|
src: [
|
2015-04-30 22:43:11 +00:00
|
|
|
'components/mock-socket/dist/mock-socket.js',
|
2015-01-14 01:04:21 +00:00
|
|
|
'components/mocha/mocha.js',
|
|
|
|
'components/chai/chai.js',
|
|
|
|
'libtextsecure/test/_test.js'
|
|
|
|
],
|
|
|
|
dest: 'libtextsecure/test/test.js',
|
2014-10-31 00:57:37 +00:00
|
|
|
}
|
2014-11-07 08:32:32 +00:00
|
|
|
},
|
|
|
|
sass: {
|
|
|
|
stylesheets: {
|
|
|
|
files: {
|
2015-03-06 19:43:53 +00:00
|
|
|
'stylesheets/manifest.css': 'stylesheets/manifest.scss',
|
|
|
|
'stylesheets/options.css': 'stylesheets/options.scss'
|
2014-11-07 08:32:32 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-08 01:55:33 +00:00
|
|
|
},
|
2014-11-23 03:36:52 +00:00
|
|
|
jshint: {
|
2015-02-19 08:20:22 +00:00
|
|
|
files: [
|
|
|
|
'Gruntfile.js',
|
|
|
|
'js/background.js',
|
|
|
|
'js/chromium.js',
|
|
|
|
'js/bimap.js',
|
|
|
|
'js/conversation_panel.js',
|
|
|
|
'js/database.js',
|
|
|
|
'js/inbox_controller.js',
|
|
|
|
'js/index.js',
|
|
|
|
'js/libphonenumber-util.js',
|
|
|
|
'js/options.js',
|
|
|
|
'js/panel_controller.js',
|
|
|
|
'js/models/*.js',
|
|
|
|
'js/views/*.js',
|
|
|
|
],
|
2014-11-23 03:36:52 +00:00
|
|
|
options: { jshintrc: '.jshintrc' },
|
|
|
|
},
|
2015-03-19 23:46:58 +00:00
|
|
|
dist: {
|
|
|
|
src: [
|
|
|
|
'manifest.json',
|
|
|
|
'background.html',
|
|
|
|
'index.html',
|
2015-03-20 17:47:45 +00:00
|
|
|
'conversation.html',
|
2015-03-19 23:46:58 +00:00
|
|
|
'options.html',
|
|
|
|
'protos/*',
|
|
|
|
'js/**',
|
|
|
|
'stylesheets/*.css',
|
2015-05-15 20:13:32 +00:00
|
|
|
'!js/register.js'
|
|
|
|
],
|
|
|
|
res: [
|
2015-03-19 23:46:58 +00:00
|
|
|
'images/**',
|
|
|
|
'fonts/*',
|
|
|
|
]
|
|
|
|
},
|
|
|
|
copy: {
|
2015-05-15 20:13:32 +00:00
|
|
|
res: {
|
|
|
|
files: [{ expand: true, dest: 'dist/', src: ['<%= dist.res %>'] }],
|
|
|
|
},
|
|
|
|
src: {
|
2015-05-07 21:45:07 +00:00
|
|
|
files: [{ expand: true, dest: 'dist/', src: ['<%= dist.src %>'] }],
|
|
|
|
options: {
|
|
|
|
process: function(content, srcpath) {
|
2015-07-23 22:41:17 +00:00
|
|
|
if (srcpath.match('libtextsecure') || srcpath.match('background.js')) {
|
2015-05-15 20:13:32 +00:00
|
|
|
return content.replace(
|
|
|
|
/textsecure-service-staging.whispersystems.org/g,
|
2015-05-15 21:01:03 +00:00
|
|
|
'textsecure-service-ca.whispersystems.org:4433').replace(
|
2015-05-15 20:13:32 +00:00
|
|
|
/whispersystems-textsecure-attachments-staging.s3.amazonaws.com/g,
|
|
|
|
'whispersystems-textsecure-attachments.s3.amazonaws.com');
|
|
|
|
} else {
|
|
|
|
return content;
|
|
|
|
}
|
2015-05-07 21:45:07 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-19 23:46:58 +00:00
|
|
|
}
|
|
|
|
},
|
2015-01-14 17:33:34 +00:00
|
|
|
jscs: {
|
|
|
|
all: {
|
2015-05-04 18:55:47 +00:00
|
|
|
src: ['js/**/*.js', '!js/libtextsecure.js', '!js/libaxolotl-worker.js', '!js/components.js', 'test/**/*.js']
|
2015-01-14 17:33:34 +00:00
|
|
|
}
|
|
|
|
},
|
2014-11-23 03:36:52 +00:00
|
|
|
watch: {
|
2015-01-26 20:36:12 +00:00
|
|
|
scripts: {
|
|
|
|
files: ['<%= jshint.files %>', './js/**/*.js'],
|
|
|
|
tasks: ['jshint']
|
|
|
|
},
|
|
|
|
sass: {
|
2015-01-30 04:53:49 +00:00
|
|
|
files: ['./stylesheets/*.scss'],
|
2015-01-26 20:36:12 +00:00
|
|
|
tasks: ['sass']
|
2015-02-23 19:54:40 +00:00
|
|
|
},
|
|
|
|
libtextsecure: {
|
|
|
|
files: ['./libtextsecure/*.js', './libtextsecure/storage/*.js'],
|
|
|
|
tasks: ['concat:libtextsecure']
|
|
|
|
},
|
2015-03-19 23:46:58 +00:00
|
|
|
dist: {
|
2015-05-15 20:13:32 +00:00
|
|
|
files: ['<%= dist.src %>', '<%= dist.res %>'],
|
2015-03-19 23:46:58 +00:00
|
|
|
tasks: ['copy']
|
|
|
|
},
|
2014-11-23 03:36:52 +00:00
|
|
|
},
|
|
|
|
connect: {
|
|
|
|
server: {
|
|
|
|
options: {
|
|
|
|
base: '.',
|
|
|
|
port: 9999
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'saucelabs-mocha': {
|
|
|
|
all: {
|
|
|
|
options: {
|
2015-03-06 02:28:02 +00:00
|
|
|
urls: [
|
|
|
|
'http://127.0.0.1:9999/test/index.html',
|
|
|
|
'http://127.0.0.1:9999/libtextsecure/test/index.html',
|
|
|
|
],
|
2014-11-23 03:36:52 +00:00
|
|
|
build: process.env.TRAVIS_JOB_ID,
|
2015-03-06 02:28:02 +00:00
|
|
|
browsers: [
|
|
|
|
{ browserName: 'chrome', version: '40' },
|
2015-07-30 00:14:17 +00:00
|
|
|
{ platform: 'linux', browserName: 'firefox', version: '34' }
|
2015-03-06 02:28:02 +00:00
|
|
|
],
|
2015-07-28 22:41:56 +00:00
|
|
|
testname: 'TextSecure-Browser Tests',
|
2015-07-29 00:36:59 +00:00
|
|
|
'max-duration': 300,
|
|
|
|
statusCheckAttempts: 200
|
2014-11-23 03:36:52 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-19 23:46:58 +00:00
|
|
|
},
|
2014-11-23 03:36:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Object.keys(grunt.config.get('pkg').devDependencies).forEach(function(key) {
|
|
|
|
if (/^grunt(?!(-cli)?$)/.test(key)) { // ignore grunt and grunt-cli
|
|
|
|
grunt.loadNpmTasks(key);
|
2014-10-31 00:57:37 +00:00
|
|
|
}
|
2014-10-30 01:32:29 +00:00
|
|
|
});
|
|
|
|
|
2015-08-31 23:45:49 +00:00
|
|
|
grunt.registerTask('dev', ['default', 'connect', 'watch']);
|
2015-01-14 17:33:34 +00:00
|
|
|
grunt.registerTask('test', ['jshint', 'jscs', 'connect', 'saucelabs-mocha']);
|
2015-08-31 23:45:49 +00:00
|
|
|
grunt.registerTask('default', ['concat', 'sass', 'copy']);
|
2014-11-23 03:36:52 +00:00
|
|
|
|
2014-10-30 01:32:29 +00:00
|
|
|
};
|