forked from aurelia/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
108 lines (94 loc) · 2.48 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
var gulp = require('gulp');
var runSequence = require('run-sequence');
var del = require('del');
var vinylPaths = require('vinyl-paths');
var to5 = require('gulp-6to5');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var yuidoc = require("gulp-yuidoc");
var changelog = require('conventional-changelog');
var assign = Object.assign || require('object.assign');
var fs = require('fs');
var bump = require('gulp-bump');
var path = {
source:'src/**/*.js',
output:'dist/',
doc:'./doc'
};
var compilerOptions = {
filename: '',
filenameRelative: '',
blacklist: [],
whitelist: [],
modules: '',
sourceMap: true,
sourceMapName: '',
sourceFileName: '',
sourceRoot: '',
moduleRoot: '',
amdModuleIds: false,
runtime: false,
comments: false,
experimental: false
};
var jshintConfig = {esnext:true};
gulp.task('clean', function() {
return gulp.src([path.output])
.pipe(vinylPaths(del));
});
gulp.task('build-es6', function () {
return gulp.src(path.source)
.pipe(gulp.dest(path.output + 'es6'));
});
gulp.task('build-commonjs', function () {
return gulp.src(path.source)
.pipe(to5(assign({}, compilerOptions, {modules:'common'})))
.pipe(gulp.dest(path.output + 'commonjs'));
});
gulp.task('build-amd', function () {
return gulp.src(path.source)
.pipe(to5(assign({}, compilerOptions, {modules:'amd'})))
.pipe(gulp.dest(path.output + 'amd'));
});
gulp.task('lint', function() {
return gulp.src(path.source)
.pipe(jshint(jshintConfig))
.pipe(jshint.reporter(stylish));
});
gulp.task('doc', function(){
return gulp.src(path.source)
.pipe(yuidoc.parser(null, 'api.json'))
.pipe(gulp.dest(path.doc));
});
gulp.task('bump-version', function(){
return gulp.src(['./bower.json', './package.json'])
.pipe(bump({type:'patch'})) //major|minor|patch|prerelease
.pipe(gulp.dest('./'));
});
gulp.task('changelog', function(callback) {
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
return changelog({
repository: pkg.repository.url,
version: pkg.version,
file: path.doc + '/CHANGELOG.md'
}, function(err, log) {
fs.writeFileSync(path.doc + '/CHANGELOG.md', log);
});
});
gulp.task('build', function(callback) {
return runSequence(
'clean',
['build-es6', 'build-commonjs', 'build-amd'],
callback
);
});
gulp.task('prepare-release', function(callback){
return runSequence(
'build',
'lint',
'bump-version',
'doc',
'changelog',
callback
);
});