forked from neuroanatomy/BrainBox
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
104 lines (90 loc) · 3.75 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
91
92
93
94
95
96
97
98
99
100
101
102
103
const exec = require('child_process').execSync;
const del = require('del');
const gulp = require('gulp');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify-es').default;
const sourcemaps = require('gulp-sourcemaps');
const download = require('gulp-download');
const gulpif = require('gulp-if');
const print = require('gulp-print');
const brainboxFiles = ['view/dist/atlasMaker.*js', 'view/brainbox/*.js'];
const atlasmakerFiles = ['view/downloads/*.js', 'view/atlasMaker/*.js', 'view/dist/atlasMaker-*.js'];
const jsdest = 'view/dist/';
const tmpFiles = ['atlasMaker-resources.js'];
gulp.task('default', ['brainbox-dev']);
gulp.task('brainbox-dev', ['pack-brainbox-dev']);
gulp.task('brainbox', ['pack-brainbox']);
gulp.task('atlasMaker-dev', ['pack-atlasMaker-dev']);
gulp.task('atlasMaker', ['pack-atlasMaker']);
gulp.task('pack-brainbox-dev', ['pack-atlasMaker-dev'], function () {
return gulp.src(brainboxFiles)
.pipe(print())
.pipe(sourcemaps.init())
//.pipe(gulpif(file => !(file.path.includes('.min.js')), uglify()))
.pipe(concat('brainbox.js'))
//.pipe(gulp.dest(jsdest))
//.pipe(rename('brainbox.min.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(jsdest));
});
gulp.task('pack-atlasMaker-dev', ['download', 'pack-resources'], function () {
return gulp.src(atlasmakerFiles)
//.pipe(sourcemaps.init())
//.pipe(gulpif(file => !(file.path.includes('.min.js')), uglify()))
.pipe(concat('atlasMaker.js'))
//.pipe(gulp.dest(jsdest))
//.pipe(rename('atlasMaker.min.js'))
//.pipe(sourcemaps.write())
.pipe(gulp.dest(jsdest));
});
gulp.task('pack-brainbox', ['pack-atlasMaker'], function () {
return gulp.src(brainboxFiles)
.pipe(gulpif(file => !(file.path.includes('.min.js')), uglify()))
.pipe(concat('brainbox.js'))
.pipe(gulp.dest(jsdest))
.pipe(rename('brainbox.min.js'))
.pipe(gulp.dest(jsdest));
});
gulp.task('pack-atlasMaker', ['download', 'pack-resources'], function () {
return gulp.src(atlasmakerFiles)
.pipe(gulpif(file => !(file.path.includes('.min.js')), uglify()))
.pipe(concat('atlasMaker.js'))
.pipe(gulp.dest(jsdest))
.pipe(rename('atlasMaker.min.js'))
.pipe(gulp.dest(jsdest));
});
gulp.task('clean-brainbox-dev', ['pack-brainbox-dev'], function () {
return del(tmpFiles);
});
gulp.task('clean-brainbox', ['pack-brainbox'], function () {
return del(tmpFiles);
});
gulp.task('clean-atlasMaker-dev', ['pack-atlasMaker-dev'], function () {
return del(tmpFiles);
});
gulp.task('clean-atlasMaker', ['pack-atlasMaker'], function () {
return del(tmpFiles);
});
gulp.task('download', function () {
download([
'https://code.jquery.com/jquery-3.2.1.min.js',
'https://code.jquery.com/ui/1.12.1/jquery-ui.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.6/pako.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/dompurify/1.0.2/purify.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/fast-json-patch/2.0.6/fast-json-patch.min.js',
'https://cdn.rawgit.com/r03ert0/structjs/v0.0.1/struct.js'
])
.pipe(gulp.dest('view/downloads'));
});
gulp.task('pack-resources', function () {
exec('node scripts/alltogethernow.js "view/atlasMaker/" "AtlasMakerResources.js"');
exec('mv "AtlasMakerResources.js" "view/dist/atlasMaker-resources.js"');
});
gulp.task('copy', function () {
exec('cp view/dist/brainbox.js public/lib/brainbox.js');
exec('cp view/dist/brainbox.js /Library/WebServer/Documents/braincatalogue/public/lib/brainbox.js');
});
gulp.task('copy-min', function () {
exec('cp view/dist/brainbox.min.js public/lib/brainbox.min.js');
});