mirror of
https://github.com/qlik-oss/PLSmartPivot.git
synced 2025-12-19 10:17:24 -05:00
92 lines
2.3 KiB
JavaScript
92 lines
2.3 KiB
JavaScript
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: "P&L pivot",
|
|
type: "visualization",
|
|
description: pkg.description + "\nVersion: " + VERSION,
|
|
version: VERSION,
|
|
icon: "pivot-table",
|
|
preview: "qlik-smart-pivot.png",
|
|
keywords: "qlik-sense, visualization",
|
|
author: pkg.author,
|
|
homepage: pkg.homepage,
|
|
license: pkg.license,
|
|
repository: pkg.repository,
|
|
dependencies: {
|
|
"qlik-sense": ">=5.5.x",
|
|
},
|
|
__next: true,
|
|
};
|
|
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-smart-pivot.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-smart-pivot_${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')
|
|
);
|