-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
133 lines (111 loc) · 3.59 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*jslint node: true */ // allow 'require' global
'use strict';
var gulpCore = require('gulp'),
gulpLoadPlugins = require('gulp-load-plugins'),
plugins = gulpLoadPlugins({
pattern: [
'gulp-*',
'gulp.*',
'event-stream',
'del',
'globby',
'inquirer',
'main-bower-files',
'minimatch',
'run-sequence',
'json5',
'merge2'
],
rename: {}
}),
gulp = plugins.help(gulpCore),
_ = require('lodash'),
path = require('path')
;
var tsDefinitions = './typings/globals/**/*.d.ts';
var sources = {
app: {
ts: [tsDefinitions, './typings/modules/**/*.d.ts', './src/**/*.ts', '!**/*.spec.ts', '!src/test.ts']
}
};
var destinations = {
app: './dist',
coverage: 'reports/**/lcov.info'
};
gulp.task('typescript', function () {
var tsProject = plugins.typescript.createProject('tsconfig.build.json', {
declarationFiles: true,
noExternalResolve: true
});
var tsStream = gulp.src(sources.app.ts)
.pipe(plugins.sourcemaps.init())
.pipe(plugins.typescript(tsProject, undefined, plugins.typescript.reporter.longReporter()));
return plugins.merge2([
tsStream.dts
.pipe(gulp.dest(destinations.app)),
tsStream.js
.pipe(plugins.sourcemaps.write('./', {includeContent: false, sourceRoot: '../src/'}))
.pipe(gulp.dest(destinations.app))
]);
});
// deletes the dist folder for a clean build
gulp.task('clean', function () {
return plugins.del([destinations.app], function (err, deletedFiles) {
if (deletedFiles.length) {
plugins.util.log('Deleted', plugins.util.colors.red(deletedFiles.join(' ,')));
} else {
plugins.util.log(plugins.util.colors.yellow('/dist directory empty - nothing to delete'));
}
});
});
gulp.task('build', [
'clean',
'typescript'
]);
gulp.task('bump', function (cb) {
var questions = [
{
type: 'list',
message: 'What type of release is this?',
name: 'bumpType',
choices: [
{
name: 'Patch (minor fix, no breaking changes)',
value: 'patch'
},
{
name: 'Minor (minor improvement, extended functionality, no breaking changes)',
value: 'minor'
},
{
name: 'Major (Breaking Changes)',
value: 'major'
}
]
},
{
type: 'confirm',
name: 'confirm',
message: function (answers) {
return 'Are you sure you want to bump the ' + answers.bumpType + ' version?'
}
}
];
plugins.inquirer.prompt(questions, function (answers) {
if (answers.confirm === true) {
return gulp.src(['./package.json', './bower.json'])
.pipe(plugins.bump({type: answers.bumpType}))
.pipe(gulp.dest('./'))
.pipe(plugins.git.commit('chore(semver): bump ' + answers.bumpType + ' version'))
.pipe(plugins.filter('package.json')) // read package.json for the new version
.pipe(plugins.tagVersion()) // create tag
;
}
});
});
// default
gulp.task('default', ['build']);
gulp.task('coveralls', 'submits code coverage to coveralls', [], function () {
gulp.src(destinations.coverage)
.pipe(plugins.coveralls());
});