forked from AnalyticsEarth/variance-waterfall
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
90 lines (78 loc) · 2.22 KB
/
gulpfile.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
var gulp = require('gulp');
var gutil = require('gulp-util');
var zip = require('gulp-zip');
var del = require('del');
var webpackConfig = require('./webpack.config');
var webpack = require('webpack');
var pkg = require('./package.json');
var DIST = './dist';
var VERSION = process.env.VERSION || 'local-dev';
gulp.task('qext', function () {
var qext = {
name: 'Variance Waterfall',
type: 'visualization',
description: pkg.description + '\nVersion: ' + VERSION,
version: VERSION,
icon: 'waterfallchart',
preview: 'qlik-variance-waterfall.png',
keywords: 'qlik-sense, visualization',
author: pkg.author,
homepage: pkg.homepage,
license: pkg.license,
repository: pkg.repository,
dependencies: {
'qlik-sense': '>=5.5.x'
}
};
if (pkg.contributors) {
qext.contributors = pkg.contributors;
}
var src = require('stream').Readable({
objectMode: true
});
src._read = function () {
this.push(
new gutil.File({
cwd: "",
base: "",
path: "qlik-variance-waterfall.qext",
contents: Buffer.from(JSON.stringify(qext, null, 4)),
})
);
this.push(null);
};
return src.pipe(gulp.dest(DIST));
});
gulp.task('clean', function(){
return del([DIST], { force: true });
});
gulp.task('zip-build', function(){
return gulp
.src(DIST + "/**/*")
.pipe(zip(`qlik-variance-waterfall_${VERSION}.zip`))
.pipe(gulp.dest(DIST));
});
gulp.task('add-assets', function(){
return gulp.src('./assets/**/*').pipe(gulp.dest(DIST));
});
gulp.task('webpack-build', done => {
webpack(webpackConfig, (error, statistics) => {
const compilationErrors = statistics && statistics.compilation.errors;
const hasCompilationErrors = !statistics || (compilationErrors && compilationErrors.length > 0);
console.log(statistics && statistics.toString({ chunks: false, colors: true })); // eslint-disable-line no-console
if (error || hasCompilationErrors) {
console.log('Build has errors or eslint errors, fail it'); // eslint-disable-line no-console
process.exit(1);
}
done();
});
});
gulp.task('build',
gulp.series('clean', 'webpack-build', 'qext', 'add-assets')
);
gulp.task('zip',
gulp.series('build', 'zip-build')
);
gulp.task('default',
gulp.series('build')
);