forked from Jiiks/BetterDiscordApp
-
Notifications
You must be signed in to change notification settings - Fork 116
/
gulpfile.babel.js
155 lines (130 loc) · 4.03 KB
/
gulpfile.babel.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import gulp from 'gulp';
import pump from 'pump';
import del from 'del';
import copy from 'gulp-copy';
import rename from 'gulp-rename';
import inject from 'gulp-inject-string';
import replace from 'gulp-replace';
import copydeps from './scripts/copydeps';
import file from 'gulp-file';
import editjson from 'gulp-json-editor';
import corepkg from './core/package';
import clientpkg from './client/package';
import editorpkg from './editor/package';
// core-release >
gulp.task('core-main', function() {
return pump([
gulp.src('core/dist/main.js'),
replace('/*PRODUCTION*/', 'const PRODUCTION = true;'),
rename(`core.${corepkg.version}.js`),
gulp.dest('release/core')
]);
});
gulp.task('core-pkg', function() {
return pump([
gulp.src('core/package.json'),
editjson(function(pkg) {
pkg.main = `core.${corepkg.version}.js`;
delete pkg.devDependencies;
delete pkg.scripts;
return pkg;
}),
gulp.dest('release/core')
]);
});
gulp.task('core-modules', function() {
return pump([
gulp.src('core/dist/modules/**/*'),
copy('release/core', { prefix: 2 })
]);
});
gulp.task('core-sparkplug', function() {
return pump([
gulp.src('core/dist/sparkplug.js'),
gulp.dest('release/core')
]);
});
gulp.task('core-extras', function() {
return pump([
gulp.src(['core/src/csp.json']),
gulp.dest('release/core')
]);
});
gulp.task('core-release', gulp.parallel('core-main', 'core-pkg', 'core-sparkplug', 'core-modules', 'core-extras'));
// < core-release
// client
gulp.task('client-main', function() {
return pump([
gulp.src('client/dist/*.client-release.js'),
rename(`client.${clientpkg.version}.js`),
gulp.dest('release/client')
]);
});
gulp.task('client-pkg', function() {
return pump([
gulp.src('client/package.json'),
editjson(function (pkg) {
pkg.main = `client.${clientpkg.version}.js`;
delete pkg.scripts;
return pkg;
}),
gulp.dest('release/client')
]);
});
gulp.task('client-sparkplug', function() {
return pump([
gulp.src('core/dist/sparkplug.js'),
gulp.dest('release/client')
]);
});
gulp.task('client-release', gulp.parallel('client-main', 'client-pkg', 'client-sparkplug'));
// Editor
gulp.task('editor-main', function() {
return pump([
gulp.src('editor/dist/editor.release.js'),
rename(`editor.${editorpkg.version}.js`),
gulp.dest('release/editor')
]);
});
gulp.task('editor-pkg', function() {
return pump([
gulp.src('editor/package.json'),
editjson(function(pkg) {
pkg.main = `editor.${editorpkg.version}.js`;
delete pkg.scripts;
return pkg;
}),
gulp.dest('release/editor')
]);
});
gulp.task('editor-release', gulp.parallel('editor-main', 'editor-pkg'));
// Deps
gulp.task('node-modules', function() {
return pump([
gulp.src(copydeps({ignore: ['fsevents']}), { base: '.' }),
gulp.dest('./release/core')
]);
});
gulp.task('node-sass-bindings', gulp.series(function() {
return del(['release/node_modules/node-sass/vendor']);
}, function() {
return pump([
gulp.src('other/node_sass_bindings/**/*'),
copy('release/core/node_modules/node-sass/vendor', { prefix: 2 })
]);
}));
gulp.task('keytar-bindings', gulp.series(function() {
return del(['release/node_modules/keytar/build']);
}, function() {
return pump([
gulp.src('other/keytar/**/*'),
copy('release/core/node_modules/keytar/build/Release', { prefix: 2 })
]);
}));
// Other
gulp.task('del-release', function() {
return del(['release/**/*']);
});
gulp.task('dependencies', gulp.series('node-modules', gulp.parallel('node-sass-bindings', 'keytar-bindings')));
gulp.task('build-release', gulp.parallel('core-release', 'client-release', 'editor-release', 'dependencies'));
gulp.task('release', gulp.series('del-release', 'build-release'));