2018-07-07 02:48:14 +02:00
|
|
|
const importOnce = require('node-sass-import-once');
|
|
|
|
const rimraf = require('rimraf');
|
|
|
|
const mkdirp = require('mkdirp');
|
2018-09-21 00:24:52 +02:00
|
|
|
const sass = require('node-sass');
|
2017-05-13 03:39:58 +02:00
|
|
|
|
2018-07-21 21:00:08 +02:00
|
|
|
/* eslint-disable more/no-then, no-console */
|
2014-11-23 04:36:52 +01:00
|
|
|
|
2021-10-04 01:56:54 +02:00
|
|
|
const toConcatForApp = [
|
|
|
|
'node_modules/jquery/dist/jquery.js',
|
|
|
|
'node_modules/bytebuffer/dist/bytebuffer.min.js',
|
|
|
|
'node_modules/long/dist/long.js',
|
|
|
|
'components/protobuf/**/*.js',
|
|
|
|
'node_modules/mustache/mustache.js',
|
|
|
|
'node_modules/underscore/underscore.js',
|
|
|
|
'node_modules/backbone/backbone.js',
|
|
|
|
];
|
|
|
|
|
|
|
|
const toConcatForComponentTextsecure = [
|
|
|
|
'node_modules/long/dist/long.js',
|
|
|
|
'components/protobuf/**/*.js',
|
|
|
|
];
|
|
|
|
|
2018-07-07 02:48:14 +02:00
|
|
|
module.exports = grunt => {
|
|
|
|
const components = [];
|
|
|
|
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
2021-10-04 01:56:54 +02:00
|
|
|
for (const i in toConcatForApp) {
|
|
|
|
components.push(toConcatForApp[i]);
|
2014-10-30 02:32:29 +01:00
|
|
|
}
|
|
|
|
|
2018-07-07 02:48:14 +02:00
|
|
|
const libtextsecurecomponents = [];
|
|
|
|
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
2021-10-04 01:56:54 +02:00
|
|
|
for (const i in toConcatForComponentTextsecure) {
|
|
|
|
libtextsecurecomponents.push(toConcatForComponentTextsecure[i]);
|
2015-01-14 02:23:11 +01:00
|
|
|
}
|
|
|
|
|
2021-07-09 07:31:10 +02:00
|
|
|
const utilWorkerComponents = [
|
|
|
|
'node_modules/bytebuffer/dist/bytebuffer.js',
|
2021-07-12 07:15:40 +02:00
|
|
|
'js/curve/curve25519_compiled.js',
|
|
|
|
'js/curve/curve25519_wrapper.js',
|
2021-07-13 03:50:11 +02:00
|
|
|
'node_modules/libsodium/dist/modules/libsodium.js',
|
|
|
|
'node_modules/libsodium-wrappers/dist/modules/libsodium-wrappers.js',
|
|
|
|
|
2021-07-13 03:16:59 +02:00
|
|
|
'libtextsecure/libsignal-protocol.js',
|
2021-07-09 07:31:10 +02:00
|
|
|
'js/util_worker_tasks.js',
|
|
|
|
];
|
|
|
|
|
2018-04-27 23:25:04 +02:00
|
|
|
grunt.loadNpmTasks('grunt-sass');
|
2017-05-04 01:43:36 +02: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
|
|
|
},
|
2018-08-16 19:45:09 +02:00
|
|
|
util_worker: {
|
2021-07-09 07:31:10 +02:00
|
|
|
src: utilWorkerComponents,
|
2018-08-16 19:45:09 +02:00
|
|
|
dest: 'js/util_worker.js',
|
|
|
|
},
|
2015-01-14 23:22:26 +01:00
|
|
|
libtextsecurecomponents: {
|
|
|
|
src: libtextsecurecomponents,
|
2015-01-14 02:23:11 +01:00
|
|
|
dest: 'libtextsecure/components.js',
|
|
|
|
},
|
2015-01-14 01:09:32 +01:00
|
|
|
libtextsecure: {
|
2015-04-04 02:18:00 +02:00
|
|
|
options: {
|
2018-04-27 23:25:04 +02:00
|
|
|
banner: ';(function() {\n',
|
|
|
|
footer: '})();\n',
|
2015-04-04 02:18:00 +02:00
|
|
|
},
|
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',
|
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-14 01:09:32 +01:00
|
|
|
'libtextsecure/helpers.js',
|
|
|
|
],
|
|
|
|
dest: 'js/libtextsecure.js',
|
|
|
|
},
|
2015-01-14 02:04:21 +01:00
|
|
|
libtextsecuretest: {
|
|
|
|
src: [
|
2018-05-20 05:53:12 +02:00
|
|
|
'node_modules/jquery/dist/jquery.js',
|
|
|
|
'node_modules/mocha/mocha.js',
|
|
|
|
'node_modules/chai/chai.js',
|
2018-04-27 23:25:04 +02:00
|
|
|
'libtextsecure/test/_test.js',
|
2015-01-14 02:04:21 +01:00
|
|
|
],
|
|
|
|
dest: 'libtextsecure/test/test.js',
|
2018-04-27 23:25:04 +02:00
|
|
|
},
|
2014-11-07 09:32:32 +01:00
|
|
|
},
|
|
|
|
sass: {
|
2017-05-04 01:43:36 +02:00
|
|
|
options: {
|
2018-09-21 00:24:52 +02:00
|
|
|
implementation: sass,
|
2017-05-04 01:43:36 +02:00
|
|
|
sourceMap: true,
|
2018-04-27 23:25:04 +02:00
|
|
|
importer: importOnce,
|
2017-05-04 01:43:36 +02:00
|
|
|
},
|
|
|
|
dev: {
|
|
|
|
files: {
|
2018-04-27 23:25:04 +02:00
|
|
|
'stylesheets/manifest.css': 'stylesheets/manifest.scss',
|
|
|
|
},
|
|
|
|
},
|
2014-11-08 02:55:33 +01:00
|
|
|
},
|
2014-11-23 04:36:52 +01:00
|
|
|
watch: {
|
2015-02-23 20:54:40 +01:00
|
|
|
libtextsecure: {
|
|
|
|
files: ['./libtextsecure/*.js', './libtextsecure/storage/*.js'],
|
2018-04-27 23:25:04 +02:00
|
|
|
tasks: ['concat:libtextsecure'],
|
2015-02-23 20:54:40 +01:00
|
|
|
},
|
2018-12-13 06:33:54 +01:00
|
|
|
utilworker: {
|
2021-07-09 07:31:10 +02:00
|
|
|
files: utilWorkerComponents,
|
2018-12-13 06:33:54 +01:00
|
|
|
tasks: ['concat:util_worker'],
|
|
|
|
},
|
2018-05-07 20:12:38 +02:00
|
|
|
protobuf: {
|
|
|
|
files: ['./protos/SignalService.proto'],
|
|
|
|
tasks: ['exec:build-protobuf'],
|
|
|
|
},
|
2018-05-07 20:10:49 +02:00
|
|
|
sass: {
|
|
|
|
files: ['./stylesheets/*.scss'],
|
|
|
|
tasks: ['sass'],
|
2015-03-20 00:46:58 +01:00
|
|
|
},
|
2018-03-26 20:44:45 +02:00
|
|
|
transpile: {
|
2021-04-22 10:03:58 +02:00
|
|
|
files: ['./ts/**/*.ts', './ts/**/*.tsx', './ts/**/**/*.tsx', './test/ts/**.ts'],
|
2018-04-27 23:25:04 +02:00
|
|
|
tasks: ['exec:transpile'],
|
|
|
|
},
|
2014-11-23 04:36:52 +01:00
|
|
|
},
|
2016-01-23 11:28:43 +01:00
|
|
|
exec: {
|
2018-04-27 23:25:04 +02:00
|
|
|
transpile: {
|
2018-05-07 20:11:12 +02:00
|
|
|
cmd: 'yarn transpile',
|
2018-04-27 23:25:04 +02:00
|
|
|
},
|
2018-05-07 20:12:38 +02:00
|
|
|
'build-protobuf': {
|
|
|
|
cmd: 'yarn build-protobuf',
|
|
|
|
},
|
2016-04-04 04:34:34 +02:00
|
|
|
},
|
2018-04-27 23:25:04 +02:00
|
|
|
gitinfo: {}, // to be populated by grunt gitinfo
|
2014-11-23 04:36:52 +01:00
|
|
|
});
|
|
|
|
|
2018-07-07 02:48:14 +02:00
|
|
|
Object.keys(grunt.config.get('pkg').devDependencies).forEach(key => {
|
2018-04-27 23:25:04 +02:00
|
|
|
if (/^grunt(?!(-cli)?$)/.test(key)) {
|
|
|
|
// ignore grunt and grunt-cli
|
2014-11-23 04:36:52 +01:00
|
|
|
grunt.loadNpmTasks(key);
|
2014-10-31 01:57:37 +01:00
|
|
|
}
|
2014-10-30 02:32:29 +01:00
|
|
|
});
|
|
|
|
|
2019-03-01 07:10:20 +01:00
|
|
|
function updateLocalConfig(update) {
|
|
|
|
const environment = process.env.SIGNAL_ENV || 'development';
|
|
|
|
const configPath = `config/local-${environment}.json`;
|
|
|
|
let localConfig;
|
|
|
|
try {
|
|
|
|
localConfig = grunt.file.readJSON(configPath);
|
|
|
|
} catch (e) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
localConfig = {
|
|
|
|
...localConfig,
|
|
|
|
...update,
|
|
|
|
};
|
|
|
|
grunt.file.write(configPath, `${JSON.stringify(localConfig)}\n`);
|
|
|
|
}
|
|
|
|
|
2018-07-07 02:48:14 +02:00
|
|
|
grunt.registerTask('getExpireTime', () => {
|
2018-04-27 23:25:04 +02:00
|
|
|
grunt.task.requires('gitinfo');
|
2018-07-07 02:48:14 +02:00
|
|
|
const gitinfo = grunt.config.get('gitinfo');
|
2018-12-13 22:41:42 +01:00
|
|
|
const committed = gitinfo.local.branch.current.lastCommitTime;
|
|
|
|
const time = Date.parse(committed) + 1000 * 60 * 60 * 24 * 90;
|
2019-03-01 07:10:20 +01:00
|
|
|
updateLocalConfig({ buildExpiration: time });
|
|
|
|
});
|
|
|
|
|
|
|
|
grunt.registerTask('getCommitHash', () => {
|
|
|
|
grunt.task.requires('gitinfo');
|
|
|
|
const gitinfo = grunt.config.get('gitinfo');
|
|
|
|
const hash = gitinfo.local.branch.current.SHA;
|
|
|
|
updateLocalConfig({ commitHash: hash });
|
2017-04-13 19:52:12 +02:00
|
|
|
});
|
|
|
|
|
2018-07-07 02:48:14 +02:00
|
|
|
grunt.registerTask('clean-release', () => {
|
|
|
|
rimraf.sync('release');
|
|
|
|
mkdirp.sync('release');
|
2017-05-04 23:42:30 +02:00
|
|
|
});
|
|
|
|
|
2017-09-26 00:38:27 +02:00
|
|
|
grunt.registerTask('dev', ['default', 'watch']);
|
2017-04-13 19:52:12 +02:00
|
|
|
grunt.registerTask('date', ['gitinfo', 'getExpireTime']);
|
2018-04-27 23:25:04 +02:00
|
|
|
grunt.registerTask('default', [
|
2018-05-08 01:05:49 +02:00
|
|
|
'exec:build-protobuf',
|
|
|
|
'exec:transpile',
|
2018-04-27 23:25:04 +02:00
|
|
|
'concat',
|
|
|
|
'sass',
|
|
|
|
'date',
|
2019-03-01 07:10:20 +01:00
|
|
|
'getCommitHash',
|
2018-04-27 23:25:04 +02:00
|
|
|
]);
|
2014-10-30 02:32:29 +01:00
|
|
|
};
|