session-desktop/Gruntfile.js

200 lines
5.4 KiB
JavaScript
Raw Normal View History

var child_process = require('child_process');
var util = require('util');
2014-10-31 08:40:00 +01:00
module.exports = function(grunt) {
2014-11-23 04:36:52 +01:00
'use strict';
var bower = grunt.file.readJSON('bower.json');
var components = [];
2014-10-31 08:40:00 +01:00
for (var i in bower.concat.app) {
components.push('components/' + bower.concat.app[i] + '/**/*.js');
}
2015-01-14 23:22:26 +01:00
var libtextsecurecomponents = [];
for (i in bower.concat.libtextsecure) {
libtextsecurecomponents.push('components/' + bower.concat.libtextsecure[i] + '/**/*.js');
}
grunt.initConfig({
2014-11-23 04:36:52 +01:00
pkg: grunt.file.readJSON('package.json'),
concat: {
components: {
src: components,
dest: 'js/components.js',
},
2015-01-14 23:22:26 +01:00
libtextsecurecomponents: {
src: libtextsecurecomponents,
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',
},
//TODO: Move errors back down?
libtextsecure: {
options: {
banner: ";(function() {\n",
footer: "})();\n",
},
src: [
'libtextsecure/errors.js',
2015-03-17 22:31:33 +01:00
'libtextsecure/libaxolotl.js',
2015-01-15 00:42:01 +01:00
'libtextsecure/axolotl_wrapper.js',
'libtextsecure/crypto.js',
2015-01-14 23:22:26 +01:00
'libtextsecure/storage.js',
'libtextsecure/storage/user.js',
2015-01-14 23:22:26 +01:00
'libtextsecure/storage/devices.js',
'libtextsecure/storage/groups.js',
'libtextsecure/protobufs.js',
'libtextsecure/websocket-resources.js',
'libtextsecure/helpers.js',
'libtextsecure/stringview.js',
'libtextsecure/api.js',
'libtextsecure/account_manager.js',
'libtextsecure/message_receiver.js',
'libtextsecure/sendmessage.js',
'libtextsecure/contacts_parser.js',
],
dest: 'js/libtextsecure.js',
},
libtextsecuretest: {
src: [
'components/jquery/dist/jquery.js',
'components/mock-socket/dist/mock-socket.js',
'components/mocha/mocha.js',
'components/chai/chai.js',
'libtextsecure/test/_test.js'
],
dest: 'libtextsecure/test/test.js',
}
},
sass: {
stylesheets: {
files: {
'stylesheets/manifest.css': 'stylesheets/manifest.scss',
'stylesheets/options.css': 'stylesheets/options.scss'
}
}
},
2014-11-23 04:36:52 +01:00
jshint: {
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 04:36:52 +01:00
options: { jshintrc: '.jshintrc' },
},
dist: {
src: [
'manifest.json',
'background.html',
'index.html',
2015-03-20 18:47:45 +01:00
'conversation.html',
'options.html',
'protos/*',
'js/**',
'stylesheets/*.css',
2015-05-15 22:13:32 +02:00
'!js/register.js'
],
res: [
'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) {
if (srcpath.match('background.js')) {
2015-05-15 22:13:32 +02:00
return content.replace(
/textsecure-service-staging.whispersystems.org/g,
'textsecure-service-ca.whispersystems.org:4433');
2015-05-15 22:13:32 +02:00
} else {
return content;
}
2015-05-07 23:45:07 +02:00
}
}
}
},
jscs: {
all: {
src: ['js/**/*.js', '!js/libtextsecure.js', '!js/libaxolotl-worker.js', '!js/components.js', 'test/**/*.js']
}
},
2014-11-23 04:36:52 +01:00
watch: {
2015-01-26 21:36:12 +01:00
scripts: {
files: ['<%= jshint.files %>', './js/**/*.js'],
tasks: ['jshint']
},
sass: {
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']
},
dist: {
2015-05-15 22:13:32 +02:00
files: ['<%= dist.src %>', '<%= dist.res %>'],
tasks: ['copy']
},
2014-11-23 04:36:52 +01:00
},
connect: {
server: {
options: {
base: '.',
port: 9999
}
}
},
'saucelabs-mocha': {
all: {
options: {
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,
browsers: [
{ browserName: 'chrome', version: '40' },
{ platform: 'linux', browserName: 'firefox', version: '34' }
],
testname: 'TextSecure-Browser Tests',
'max-duration': 300,
statusCheckAttempts: 200
2014-11-23 04:36:52 +01:00
}
}
},
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);
}
});
grunt.registerTask('dev', ['default', 'connect', 'watch']);
grunt.registerTask('test', ['jshint', 'jscs', 'connect', 'saucelabs-mocha']);
grunt.registerTask('default', ['concat', 'sass', 'copy']);
2014-11-23 04:36:52 +01:00
};