-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (61 loc) · 1.85 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
/* eslint "import/no-extraneous-dependencies": ["error", {"devDependencies": true}] */
const fs = require('fs');
const gulp = require('gulp');
const replace = require('gulp-replace-task');
const tar = require('gulp-tar');
const gzip = require('gulp-gzip');
const rename = require('gulp-rename');
const gitRev = require('git-rev-sync');
const exec = require('child_process').exec;
const rimraf = require('rimraf');
const packageInfo = JSON.parse(fs.readFileSync('./package.json'));
const destName = packageInfo.name;
gulp.task('clean', () => {
rimraf.sync(destName);
});
gulp.task('yarn build', (cb) => {
exec('yarn run build', cb);
});
const configSrc = [
'default/**/*.*',
'metadata/**/*.*',
'README/**/*.*',
'static/**/*.*',
'lookups/**/*.*',
'README.md',
];
gulp.task('process config', ['clean'], () => {
gulp.src(configSrc, { base: '.' })
.pipe(replace({
patterns: [
{ json: packageInfo },
{ json: { buildNumber: parseInt(gitRev.short(), 16) } },
],
}))
.pipe(gulp.dest(destName));
});
const vizFiles = [
'visualization.js',
'visualization.css',
'formatter.html',
'preview.png',
];
const staticSrc = [
`appserver/static/visualizations/timewrap/{${vizFiles.join(',')}}`,
];
gulp.task('process static', ['clean', 'yarn build'], () => {
gulp.src(staticSrc, { base: '.' })
.pipe(gulp.dest(destName));
});
gulp.task('default', ['process config', 'process static'], (cb) => {
// Work-around for a bug where the files from the `process static` task
// are not in place immediately.
setTimeout(() => {
gulp.src(`${destName}/**/*.*`, { base: '.' })
.pipe(tar(`${destName}.tar`))
.pipe(gzip())
.pipe(rename(`${destName}.spl`))
.pipe(gulp.dest('.'));
cb();
}, 100);
});