-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
113 lines (96 loc) · 3.3 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
104
105
106
107
108
109
110
111
112
113
'use strict';
var gulp = require('gulp');
var del = require('del');
var ts = require('gulp-typescript');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var serve = require('gulp-serve');
var mocha = require('gulp-mocha');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var deploy = require('gulp-deploy-git');
var all = require('gulp-all');
var typescriptSource = 'src/main/ts/**/*.ts';
var htmlSource = 'src/demo/html/**/*';
var typeScriptTarget = 'target/js';
var sassSource = 'src/main/scss/**/*.scss';
var sassTarget = 'target/css';
var jsFileName = 'gitline.js';
var tsProject = ts.createProject({
outFile: jsFileName,
noImplicitAny: false
});
gulp.task('clean', function () {
return del([
'.pages',
'dist',
'target/**/*'
]);
});
gulp.task('tsc', ['clean'], function () {
var tsResult = gulp.src(typescriptSource)
.pipe(sourcemaps.init())
.pipe(ts(tsProject, {}, ts.reporter.fullReporter(true)));
return tsResult.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(typeScriptTarget));
});
gulp.task('compress', ['tsc'], function () {
return gulp.src(typeScriptTarget + '/' + jsFileName)
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(typeScriptTarget));
});
gulp.task('sass:compressed', ['clean'], function () {
return gulp.src(sassSource)
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(sassTarget));
});
gulp.task('sass:uncompressed', ['clean'], function () {
return gulp.src(sassSource)
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(sassTarget));
});
gulp.task('sass', ['sass:uncompressed', 'sass:compressed']);
gulp.task('build', ['compress', 'sass']);
gulp.task('run', ['build', 'package'], serve('dist'));
gulp.task('watch', ['build', 'test','package'], function () {
gulp.watch(typescriptSource, ['compress', 'test', 'package']);
gulp.watch(sassSource, ['sass', 'package']);
gulp.watch(htmlSource, ['sass', 'package']);
});
gulp.task('package', ['clean', 'test'], function () {
var p1 = gulp.src([
'target/js/**/*',
'target/css/**/*',
'src/demo/html/**']).pipe(gulp.dest('dist'));
var p2 = gulp.src([ 'src/main/external/**']).pipe(gulp.dest('dist/external'));
var p3 = gulp.src([ 'src/test/data/**']).pipe(gulp.dest('dist/data'));
return all(p1, p2, p3);
});
gulp.task('deploy', ['package'], function() {
return gulp.src('dist/**/*')
.pipe(deploy({
repository: 'git@github.com:blecher-at/gitline.git',
branches: ['feature/GL-36-dist', 'master'],
message: 'auto deploy',
debug: true,
remoteBranch: 'gh-pages-test'
}));
});
gulp.task('test', ['build'], function () {
return gulp.src('src/test/GitlineTests.js', {read: false})
// gulp-mocha needs filepaths so you can't have any plugins before it
.pipe(mocha());
});