2018-07-07 02:48:14 +02:00
|
|
|
const importOnce = require('node-sass-import-once');
|
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',
|
2022-02-14 06:42:53 +01:00
|
|
|
'node_modules/underscore/underscore-min.js',
|
2021-10-04 01:56:54 +02:00
|
|
|
'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',
|
2022-03-08 06:30:50 +01:00
|
|
|
'node_modules/libsodium-sumo/dist/modules-sumo/libsodium-sumo.js',
|
|
|
|
'node_modules/libsodium-wrappers-sumo/dist/modules-sumo/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 01:09:32 +01:00
|
|
|
],
|
|
|
|
dest: 'js/libtextsecure.js',
|
|
|
|
},
|
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) {
|
2022-03-22 00:42:15 +01:00
|
|
|
const environment = process.env.SIGNAL_ENV || 'production';
|
2019-03-01 07:10:20 +01:00
|
|
|
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`);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
|
2017-09-26 00:38:27 +02:00
|
|
|
grunt.registerTask('dev', ['default', 'watch']);
|
2021-12-14 05:15:12 +01:00
|
|
|
grunt.registerTask('date', ['gitinfo']);
|
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
|
|
|
};
|