aboutsummaryrefslogtreecommitdiffstats
path: root/gulpfile.babel.js
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-07-08 09:21:39 +0200
committerLibravatar GitHub <noreply@github.com>2021-07-08 12:51:39 +0530
commit4817b83394bc901c02d619f16d74cfbc3a5d294c (patch)
tree019e83ebaacfb0d15627c3405478be8d683af180 /gulpfile.babel.js
parentIncluding the '@meetfranz' node modules in the packed artefact (since its cau... (diff)
downloadferdium-app-4817b83394bc901c02d619f16d74cfbc3a5d294c.tar.gz
ferdium-app-4817b83394bc901c02d619f16d74cfbc3a5d294c.tar.zst
ferdium-app-4817b83394bc901c02d619f16d74cfbc3a5d294c.zip
chore: run security audit on node modules (#1621)
- changed electron target for @babel/preset-env from 4 to 13 - added .prettierrc.js with conforming settings to current code style - upgraded gulp-sass to v5 to fix CVE and adapted code to breaking changes - refreshed package-lock.json of packages/forms and packages/ui - upgraded normalize-url to fix CVE - removed unnecessary @types/color-convert - fixed ToggleComponent breaking tsc compilation
Diffstat (limited to 'gulpfile.babel.js')
-rw-r--r--gulpfile.babel.js59
1 files changed, 39 insertions, 20 deletions
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index 9a04732b7..ed5245ee1 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -1,8 +1,8 @@
1/* eslint max-len: 0 */
2import gulp from 'gulp'; 1import gulp from 'gulp';
3import gulpIf from 'gulp-if'; 2import gulpIf from 'gulp-if';
4import babel from 'gulp-babel'; 3import babel from 'gulp-babel';
5import sass from 'gulp-sass'; 4import dartSass from 'sass';
5import gulpSass from 'gulp-sass';
6import csso from 'gulp-csso'; 6import csso from 'gulp-csso';
7import terser from 'terser'; 7import terser from 'terser';
8import composer from 'gulp-uglify/composer'; 8import composer from 'gulp-uglify/composer';
@@ -22,19 +22,18 @@ import * as rawStyleConfig from './src/theme/default/legacy.js';
22 22
23dotenv.config(); 23dotenv.config();
24 24
25const sass = gulpSass(dartSass);
25const uglify = composer(terser, console); 26const uglify = composer(terser, console);
26 27
27const isDevBuild = process.env.NODE_ENV === 'development'; 28const isDevBuild = process.env.NODE_ENV === 'development';
28 29
29const getTargetEnv = isDevBuild ? 'development' : 'production'; 30const getTargetEnv = isDevBuild ? 'development' : 'production';
30 31
31const styleConfig = Object.keys(rawStyleConfig).map((key) => { 32const styleConfig = Object.keys(rawStyleConfig).map(key => {
32 const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]); 33 const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]);
33 return { 34 return {
34 [`$raw_${kebabCase(key)}`]: isHex 35 [`$raw_${kebabCase(key)}`]: isHex
35 ? hexRgb(rawStyleConfig[key], { format: 'array' }) 36 ? hexRgb(rawStyleConfig[key], { format: 'array' }).splice(0, 3).join(',')
36 .splice(0, 3)
37 .join(',')
38 : rawStyleConfig[key], 37 : rawStyleConfig[key],
39 }; 38 };
40}); 39});
@@ -107,7 +106,7 @@ function _shell(cmd, cb) {
107 ); 106 );
108} 107}
109 108
110const clean = (done) => { 109const clean = done => {
111 removeSync(paths.tmp); 110 removeSync(paths.tmp);
112 removeSync(paths.dest); 111 removeSync(paths.dest);
113 removeSync(paths.dist); 112 removeSync(paths.dist);
@@ -140,7 +139,7 @@ export function mvLernaPackages() {
140} 139}
141 140
142export function exportBuildInfo() { 141export function exportBuildInfo() {
143 var buildInfoData = { 142 const buildInfoData = {
144 timestamp: buildInfo.timestamp, 143 timestamp: buildInfo.timestamp,
145 gitHashShort: buildInfo.gitHashShort, 144 gitHashShort: buildInfo.gitHashShort,
146 gitBranch: buildInfo.gitBranch, 145 gitBranch: buildInfo.gitBranch,
@@ -151,10 +150,16 @@ export function exportBuildInfo() {
151export function html() { 150export function html() {
152 return gulp 151 return gulp
153 .src(paths.html.src, { since: gulp.lastRun(html) }) 152 .src(paths.html.src, { since: gulp.lastRun(html) })
154 .pipe(gulpIf(!isDevBuild, htmlMin({ // Only minify in production to speed up dev builds 153 .pipe(
155 collapseWhitespace: true, 154 gulpIf(
156 removeComments: true, 155 !isDevBuild,
157 }))) 156 htmlMin({
157 // Only minify in production to speed up dev builds
158 collapseWhitespace: true,
159 removeComments: true,
160 }),
161 ),
162 )
158 .pipe(gulp.dest(paths.html.dest)) 163 .pipe(gulp.dest(paths.html.dest))
159 .pipe(connect.reload()); 164 .pipe(connect.reload());
160} 165}
@@ -177,9 +182,15 @@ export function styles() {
177 includePaths: ['./node_modules', '../node_modules'], 182 includePaths: ['./node_modules', '../node_modules'],
178 }).on('error', sass.logError), 183 }).on('error', sass.logError),
179 ) 184 )
180 .pipe((gulpIf(!isDevBuild, csso({ // Only minify in production to speed up dev builds 185 .pipe(
181 restructure: false, // Don't restructure CSS, otherwise it will break the styles 186 gulpIf(
182 })))) 187 !isDevBuild,
188 csso({
189 // Only minify in production to speed up dev builds
190 restructure: false, // Don't restructure CSS, otherwise it will break the styles
191 }),
192 ),
193 )
183 .pipe(gulp.dest(paths.styles.dest)) 194 .pipe(gulp.dest(paths.styles.dest))
184 .pipe(connect.reload()); 195 .pipe(connect.reload());
185} 196}
@@ -202,9 +213,15 @@ export function verticalStyle() {
202 includePaths: ['./node_modules', '../node_modules'], 213 includePaths: ['./node_modules', '../node_modules'],
203 }).on('error', sass.logError), 214 }).on('error', sass.logError),
204 ) 215 )
205 .pipe((gulpIf(!isDevBuild, csso({ // Only minify in production to speed up dev builds 216 .pipe(
206 restructure: false, // Don't restructure CSS, otherwise it will break the styles 217 gulpIf(
207 })))) 218 !isDevBuild,
219 csso({
220 // Only minify in production to speed up dev builds
221 restructure: false, // Don't restructure CSS, otherwise it will break the styles
222 }),
223 ),
224 )
208 .pipe(gulp.dest(paths.verticalStyle.dest)) 225 .pipe(gulp.dest(paths.verticalStyle.dest))
209 .pipe(connect.reload()); 226 .pipe(connect.reload());
210} 227}
@@ -240,11 +257,13 @@ export function webserver() {
240} 257}
241 258
242export function recipes() { 259export function recipes() {
243 return gulp.src(paths.recipes.src, { since: gulp.lastRun(recipes) }) 260 return gulp
261 .src(paths.recipes.src, { since: gulp.lastRun(recipes) })
244 .pipe(gulp.dest(paths.recipes.dest)); 262 .pipe(gulp.dest(paths.recipes.dest));
245} 263}
246export function recipeInfo() { 264export function recipeInfo() {
247 return gulp.src(paths.recipeInfo.src, { since: gulp.lastRun(recipeInfo) }) 265 return gulp
266 .src(paths.recipeInfo.src, { since: gulp.lastRun(recipeInfo) })
248 .pipe(gulp.dest(paths.recipeInfo.dest)); 267 .pipe(gulp.dest(paths.recipeInfo.dest));
249} 268}
250 269