forked from wireapp/wire-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
111 lines (98 loc) · 3.14 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Wire
* Copyright (C) 2018 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/
const path = require('path');
const {format} = require('date-fns');
const {SRC_PATH, DIST_PATH} = require('./locations');
module.exports = grunt => {
require('load-grunt-tasks')(grunt);
/* eslint-disable sort-keys-fix/sort-keys-fix */
const dir = {
src_: SRC_PATH,
src: {
demo: `${SRC_PATH}/demo`,
ext: `${SRC_PATH}/ext`,
page: `${SRC_PATH}/page`,
style: `${SRC_PATH}/style`,
},
server: 'server',
dist: {
s3: `${DIST_PATH}/s3`,
static: `${DIST_PATH}/static`,
templates: `${DIST_PATH}/templates`,
},
dist_: DIST_PATH,
docs: {
api: 'docs/api',
coverage: 'docs/coverage',
},
resource: 'resource',
test_: 'test',
test: {
api: 'test/api',
coverage: 'test/coverage',
lib: 'test/lib',
unitTests: 'test/unit_tests',
},
};
grunt.initConfig({
dir,
aws_s3: require('./grunt/config/aws_s3'),
clean: require('./grunt/config/clean'),
compress: require('./grunt/config/compress'),
copy: require('./grunt/config/copy'),
includereplace: require('./grunt/config/includereplace'),
open: require('./grunt/config/open'),
postcss: require('./grunt/config/postcss'),
shell: require('./grunt/config/shell'),
watch: require('./grunt/config/watch'),
});
/* eslint-enable sort-keys-fix/sort-keys-fix */
grunt.registerTask('build', [
'clean:dist',
'clean:dist_src',
'clean:dist_s3',
'set_version',
'build_style',
'copy:dist_serviceworker',
'copy:dist_resource',
'copy:dist_certificate',
'build_markup',
]);
grunt.registerTask('build_style', ['shell:less', 'postcss']);
grunt.registerTask('build_markup', ['includereplace:prod_index', 'includereplace:prod_auth']);
grunt.registerTask('build_prod', ['build', 'shell:dist_bundle', 'compress']);
grunt.registerTask('set_version', () => {
grunt.task.run('gitinfo');
const target = grunt.config('gitinfo.local.branch.current.name');
grunt.log.ok(`Version target set to ${target}`);
let user = grunt.config('gitinfo.local.branch.current.currentUser');
if (user) {
user = user.substr(0, user.indexOf(' ')).toLowerCase();
}
let version = format(new Date(), 'yyyy.MM.dd.HH.mm');
if (user) {
version = `${version}-${user}`;
}
if (target) {
version = `${version}-${target}`;
}
grunt.log.ok(`Version set to ${version}`);
grunt.file.write(path.join('server/dist/version'), version);
});
};