2014-10-29 18:32:29 -07:00
|
|
|
module.exports = function(grunt) {
|
2014-11-22 19:36:52 -08:00
|
|
|
'use strict';
|
|
|
|
|
2014-10-30 17:57:37 -07:00
|
|
|
var bower = grunt.file.readJSON('bower.json');
|
2014-10-29 18:32:29 -07:00
|
|
|
var components = [];
|
2014-10-31 00:40:00 -07:00
|
|
|
for (var i in bower.concat.app) {
|
2014-10-30 17:57:37 -07:00
|
|
|
components.push('components/' + bower.concat.app[i] + '/**/*.js');
|
2014-10-29 18:32:29 -07:00
|
|
|
}
|
2016-08-15 15:36:29 -07:00
|
|
|
components.push('components/' + 'webaudiorecorder/lib/WebAudioRecorder.js');
|
2014-10-29 18:32:29 -07:00
|
|
|
|
2015-01-14 12:22:26 -10:00
|
|
|
var libtextsecurecomponents = [];
|
|
|
|
for (i in bower.concat.libtextsecure) {
|
|
|
|
libtextsecurecomponents.push('components/' + bower.concat.libtextsecure[i] + '/**/*.js');
|
2015-01-13 15:23:11 -10:00
|
|
|
}
|
|
|
|
|
2014-10-29 18:32:29 -07:00
|
|
|
grunt.initConfig({
|
2014-11-22 19:36:52 -08:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
2014-10-29 18:32:29 -07:00
|
|
|
concat: {
|
|
|
|
components: {
|
|
|
|
src: components,
|
2014-10-30 16:53:08 -07:00
|
|
|
dest: 'js/components.js',
|
2014-10-29 18:32:29 -07:00
|
|
|
},
|
2015-01-14 12:22:26 -10:00
|
|
|
libtextsecurecomponents: {
|
|
|
|
src: libtextsecurecomponents,
|
2015-01-13 15:23:11 -10:00
|
|
|
dest: 'libtextsecure/components.js',
|
|
|
|
},
|
2014-11-09 21:44:56 -08:00
|
|
|
test: {
|
|
|
|
src: [
|
|
|
|
'components/mocha/mocha.js',
|
|
|
|
'components/chai/chai.js',
|
|
|
|
'test/_test.js'
|
|
|
|
],
|
|
|
|
dest: 'test/test.js',
|
2015-01-13 14:09:32 -10:00
|
|
|
},
|
2015-01-15 14:30:55 -10:00
|
|
|
//TODO: Move errors back down?
|
2015-01-13 14:09:32 -10:00
|
|
|
libtextsecure: {
|
2015-04-03 17:18:00 -07:00
|
|
|
options: {
|
|
|
|
banner: ";(function() {\n",
|
|
|
|
footer: "})();\n",
|
|
|
|
},
|
2015-01-13 14:09:32 -10:00
|
|
|
src: [
|
2015-01-15 14:30:55 -10:00
|
|
|
'libtextsecure/errors.js',
|
2016-04-21 18:09:10 -07:00
|
|
|
'libtextsecure/libsignal-protocol.js',
|
2016-04-22 13:43:09 -07:00
|
|
|
'libtextsecure/protocol_wrapper.js',
|
2015-01-13 15:49:38 -10:00
|
|
|
|
2015-01-15 18:11:08 -10:00
|
|
|
'libtextsecure/crypto.js',
|
2015-01-14 12:22:26 -10:00
|
|
|
'libtextsecure/storage.js',
|
2015-03-24 15:48:59 -07:00
|
|
|
'libtextsecure/storage/user.js',
|
2015-01-20 19:48:27 -10:00
|
|
|
'libtextsecure/storage/groups.js',
|
2017-07-17 15:46:00 -07:00
|
|
|
'libtextsecure/storage/unprocessed.js',
|
2015-01-13 14:09:32 -10:00
|
|
|
'libtextsecure/protobufs.js',
|
|
|
|
'libtextsecure/websocket-resources.js',
|
|
|
|
'libtextsecure/helpers.js',
|
|
|
|
'libtextsecure/stringview.js',
|
2016-01-14 14:07:00 -08:00
|
|
|
'libtextsecure/event_target.js',
|
2015-01-13 14:09:32 -10:00
|
|
|
'libtextsecure/api.js',
|
2015-04-29 17:00:30 -07:00
|
|
|
'libtextsecure/account_manager.js',
|
2015-04-29 11:56:40 -07:00
|
|
|
'libtextsecure/message_receiver.js',
|
2015-10-20 16:30:39 -07:00
|
|
|
'libtextsecure/outgoing_message.js',
|
2015-01-13 14:09:32 -10:00
|
|
|
'libtextsecure/sendmessage.js',
|
2016-01-14 13:40:26 -08:00
|
|
|
'libtextsecure/sync_request.js',
|
2015-06-01 14:08:21 -07:00
|
|
|
'libtextsecure/contacts_parser.js',
|
2016-05-01 22:31:44 -07:00
|
|
|
'libtextsecure/ProvisioningCipher.js',
|
2017-07-19 12:05:24 -07:00
|
|
|
'libtextsecure/task_with_timeout.js',
|
2015-01-13 14:09:32 -10:00
|
|
|
],
|
|
|
|
dest: 'js/libtextsecure.js',
|
|
|
|
},
|
2015-01-13 15:04:21 -10:00
|
|
|
libtextsecuretest: {
|
|
|
|
src: [
|
2015-10-19 12:30:23 -07:00
|
|
|
'components/jquery/dist/jquery.js',
|
2015-04-30 15:43:11 -07:00
|
|
|
'components/mock-socket/dist/mock-socket.js',
|
2015-01-13 15:04:21 -10:00
|
|
|
'components/mocha/mocha.js',
|
|
|
|
'components/chai/chai.js',
|
|
|
|
'libtextsecure/test/_test.js'
|
|
|
|
],
|
|
|
|
dest: 'libtextsecure/test/test.js',
|
2014-10-30 17:57:37 -07:00
|
|
|
}
|
2014-11-07 00:32:32 -08:00
|
|
|
},
|
|
|
|
sass: {
|
|
|
|
stylesheets: {
|
|
|
|
files: {
|
2015-03-06 11:43:53 -08:00
|
|
|
'stylesheets/manifest.css': 'stylesheets/manifest.scss',
|
|
|
|
'stylesheets/options.css': 'stylesheets/options.scss'
|
2014-11-07 00:32:32 -08:00
|
|
|
}
|
|
|
|
}
|
2014-11-07 17:55:33 -08:00
|
|
|
},
|
2014-11-22 19:36:52 -08:00
|
|
|
jshint: {
|
2015-02-19 00:20:22 -08:00
|
|
|
files: [
|
|
|
|
'Gruntfile.js',
|
2016-02-17 16:00:50 -08:00
|
|
|
'js/**/*.js',
|
|
|
|
'!js/libtextsecure.js',
|
2016-08-15 15:36:29 -07:00
|
|
|
'!js/WebAudioRecorderMp3.js',
|
|
|
|
'!js/Mp3LameEncoder.min.js',
|
2016-04-21 18:09:10 -07:00
|
|
|
'!js/libsignal-protocol-worker.js',
|
2016-02-17 16:00:50 -08:00
|
|
|
'!js/components.js',
|
2016-04-21 16:45:21 -07:00
|
|
|
'!js/signal_protocol_store.js',
|
2016-02-17 16:00:50 -08:00
|
|
|
'_locales/**/*'
|
2015-02-19 00:20:22 -08:00
|
|
|
],
|
2014-11-22 19:36:52 -08:00
|
|
|
options: { jshintrc: '.jshintrc' },
|
|
|
|
},
|
2015-03-19 16:46:58 -07:00
|
|
|
dist: {
|
|
|
|
src: [
|
|
|
|
'manifest.json',
|
|
|
|
'background.html',
|
|
|
|
'index.html',
|
|
|
|
'options.html',
|
2015-12-14 15:10:49 -08:00
|
|
|
'_locales/**',
|
2015-03-19 16:46:58 -07:00
|
|
|
'protos/*',
|
|
|
|
'js/**',
|
|
|
|
'stylesheets/*.css',
|
2015-05-15 13:13:32 -07:00
|
|
|
'!js/register.js'
|
|
|
|
],
|
|
|
|
res: [
|
2017-02-03 16:53:43 -08:00
|
|
|
'audio/**',
|
2017-05-01 11:08:04 -07:00
|
|
|
'images/**/*',
|
2015-03-19 16:46:58 -07:00
|
|
|
'fonts/*',
|
|
|
|
]
|
|
|
|
},
|
|
|
|
copy: {
|
2015-05-15 13:13:32 -07:00
|
|
|
res: {
|
|
|
|
files: [{ expand: true, dest: 'dist/', src: ['<%= dist.res %>'] }],
|
|
|
|
},
|
|
|
|
src: {
|
2015-05-07 14:45:07 -07:00
|
|
|
files: [{ expand: true, dest: 'dist/', src: ['<%= dist.src %>'] }],
|
|
|
|
options: {
|
|
|
|
process: function(content, srcpath) {
|
2015-10-16 18:18:25 -07:00
|
|
|
if (srcpath.match('background.js')) {
|
2015-05-15 13:13:32 -07:00
|
|
|
return content.replace(
|
2016-09-07 21:53:56 -07:00
|
|
|
/textsecure-service-staging.whispersystems.org/g,
|
2017-03-10 15:19:40 -08:00
|
|
|
'textsecure-service-ca.whispersystems.org');
|
2016-04-03 19:34:34 -07:00
|
|
|
} else if (srcpath.match('expire.js')) {
|
|
|
|
var gitinfo = grunt.config.get('gitinfo');
|
|
|
|
var commited = gitinfo.local.branch.current.lastCommitTime;
|
|
|
|
var time = Date.parse(commited) + 1000 * 60 * 60 * 24 * 90;
|
|
|
|
return content.replace(
|
|
|
|
/var BUILD_EXPIRATION = 0/,
|
|
|
|
"var BUILD_EXPIRATION = " + time
|
|
|
|
);
|
2015-05-15 13:13:32 -07:00
|
|
|
} else {
|
|
|
|
return content;
|
|
|
|
}
|
2015-05-07 14:45:07 -07:00
|
|
|
}
|
|
|
|
}
|
2015-03-19 16:46:58 -07:00
|
|
|
}
|
|
|
|
},
|
2015-01-14 17:33:34 +00:00
|
|
|
jscs: {
|
|
|
|
all: {
|
2016-02-17 16:46:32 -08:00
|
|
|
src: [
|
|
|
|
'Gruntfile',
|
|
|
|
'js/**/*.js',
|
|
|
|
'!js/libtextsecure.js',
|
2016-08-15 15:36:29 -07:00
|
|
|
'!js/WebAudioRecorderMp3.js',
|
|
|
|
'!js/Mp3LameEncoder.min.js',
|
2016-04-21 18:09:10 -07:00
|
|
|
'!js/libsignal-protocol-worker.js',
|
2016-02-17 16:46:32 -08:00
|
|
|
'!js/components.js',
|
|
|
|
'test/**/*.js',
|
|
|
|
'!test/blanket_mocha.js',
|
2016-02-17 17:08:50 -08:00
|
|
|
'!test/test.js',
|
2016-02-17 16:46:32 -08:00
|
|
|
]
|
2015-01-14 17:33:34 +00:00
|
|
|
}
|
|
|
|
},
|
2014-11-22 19:36:52 -08:00
|
|
|
watch: {
|
2015-01-26 10:36:12 -10:00
|
|
|
sass: {
|
2015-01-29 18:53:49 -10:00
|
|
|
files: ['./stylesheets/*.scss'],
|
2015-01-26 10:36:12 -10:00
|
|
|
tasks: ['sass']
|
2015-02-23 11:54:40 -08:00
|
|
|
},
|
|
|
|
libtextsecure: {
|
|
|
|
files: ['./libtextsecure/*.js', './libtextsecure/storage/*.js'],
|
|
|
|
tasks: ['concat:libtextsecure']
|
|
|
|
},
|
2015-03-19 16:46:58 -07:00
|
|
|
dist: {
|
2015-05-15 13:13:32 -07:00
|
|
|
files: ['<%= dist.src %>', '<%= dist.res %>'],
|
2016-04-03 19:34:34 -07:00
|
|
|
tasks: ['copy_dist']
|
2015-03-19 16:46:58 -07:00
|
|
|
},
|
2016-02-22 14:02:03 -08:00
|
|
|
scripts: {
|
|
|
|
files: ['<%= jshint.files %>', './js/**/*.js'],
|
|
|
|
tasks: ['jshint']
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
files: ['<%= jscs.all.src %>', './js/**/*.js'],
|
|
|
|
tasks: ['jscs']
|
|
|
|
},
|
2014-11-22 19:36:52 -08:00
|
|
|
},
|
|
|
|
connect: {
|
|
|
|
server: {
|
|
|
|
options: {
|
|
|
|
base: '.',
|
|
|
|
port: 9999
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'saucelabs-mocha': {
|
|
|
|
all: {
|
|
|
|
options: {
|
2015-03-05 18:28:02 -08:00
|
|
|
urls: [
|
|
|
|
'http://127.0.0.1:9999/test/index.html',
|
|
|
|
'http://127.0.0.1:9999/libtextsecure/test/index.html',
|
|
|
|
],
|
2014-11-22 19:36:52 -08:00
|
|
|
build: process.env.TRAVIS_JOB_ID,
|
2015-03-05 18:28:02 -08:00
|
|
|
browsers: [
|
2015-11-08 00:15:14 -08:00
|
|
|
{ browserName: 'chrome', version: '41' },
|
2015-03-05 18:28:02 -08:00
|
|
|
],
|
2015-07-28 15:41:56 -07:00
|
|
|
testname: 'TextSecure-Browser Tests',
|
2015-07-28 17:36:59 -07:00
|
|
|
'max-duration': 300,
|
|
|
|
statusCheckAttempts: 200
|
2014-11-22 19:36:52 -08:00
|
|
|
}
|
|
|
|
}
|
2015-03-19 16:46:58 -07:00
|
|
|
},
|
2016-01-23 10:28:43 +00:00
|
|
|
exec: {
|
|
|
|
'tx-pull': {
|
|
|
|
cmd: 'tx pull'
|
|
|
|
}
|
2016-04-03 19:34:34 -07:00
|
|
|
},
|
|
|
|
gitinfo: {} // to be populated by grunt gitinfo
|
2014-11-22 19:36:52 -08: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-30 17:57:37 -07:00
|
|
|
}
|
2014-10-29 18:32:29 -07:00
|
|
|
});
|
|
|
|
|
2016-01-22 09:29:49 +00:00
|
|
|
// Transifex does not understand placeholders, so this task patches all non-en
|
|
|
|
// locales with missing placeholders
|
|
|
|
grunt.registerTask('locale-patch', function(){
|
|
|
|
var en = grunt.file.readJSON('_locales/en/messages.json');
|
|
|
|
grunt.file.recurse('_locales', function(abspath, rootdir, subdir, filename){
|
|
|
|
if (subdir === 'en' || filename !== 'messages.json'){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var messages = grunt.file.readJSON(abspath);
|
|
|
|
|
|
|
|
for (var key in messages){
|
2016-03-11 12:00:55 -08:00
|
|
|
if (en[key] !== undefined && messages[key] !== undefined){
|
|
|
|
if (en[key].placeholders !== undefined && messages[key].placeholders === undefined){
|
|
|
|
messages[key].placeholders = en[key].placeholders;
|
|
|
|
}
|
2016-01-22 09:29:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
grunt.file.write(abspath, JSON.stringify(messages, null, 4) + '\n');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-01-23 10:28:43 +00:00
|
|
|
grunt.registerTask('tx', ['exec:tx-pull', 'locale-patch']);
|
2015-08-31 16:45:49 -07:00
|
|
|
grunt.registerTask('dev', ['default', 'connect', 'watch']);
|
2015-01-14 17:33:34 +00:00
|
|
|
grunt.registerTask('test', ['jshint', 'jscs', 'connect', 'saucelabs-mocha']);
|
2016-04-03 19:34:34 -07:00
|
|
|
grunt.registerTask('copy_dist', ['gitinfo', 'copy']);
|
|
|
|
grunt.registerTask('default', ['concat', 'sass', 'copy_dist']);
|
2014-11-22 19:36:52 -08:00
|
|
|
|
2014-10-29 18:32:29 -07:00
|
|
|
};
|