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