-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathgulpfile.js
112 lines (98 loc) · 3.28 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
var gulp = require('gulp'),
runSequence = require('run-sequence'),
newVer;
gulp.task('karma', function(done) {
var karma = require('karma').server;
karma.start({
frameworks: ['jasmine'],
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/localforage/dist/localforage.js',
'src/angular-localForage.js',
'tests/*.js'
],
singleRun: true,
browsers: ['Firefox', 'Chrome']
}, done);
});
gulp.task('build-files', function() {
var rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
header = require('gulp-header'),
pkg = require('./package.json'),
banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' * @author <%= pkg.author %>',
' */',
''].join('\n');
return gulp.src('src/angular-localForage.js')
.pipe(header(banner, { pkg: pkg, version: newVer || pkg.version }))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(header(banner, { pkg: pkg, version: newVer || pkg.version }))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('build', ['karma'], function(done) {
runSequence('karma', 'build-files', done);
});
gulp.task('promptBump', function() {
var prompt = require('gulp-prompt'),
semver = require('semver'),
pkg = require('./package.json');
return gulp.src('')
.pipe(prompt.prompt({
type: 'list',
name: 'bump',
message: 'What type of version bump would you like to do ? (current version is ' + pkg.version + ')',
choices: [
'patch (' + pkg.version + ' --> ' + semver.inc(pkg.version, 'patch') + ')',
'minor (' + pkg.version + ' --> ' + semver.inc(pkg.version, 'minor') + ')',
'major (' + pkg.version + ' --> ' + semver.inc(pkg.version, 'major') + ')',
'none (exit)'
]
}, function(res) {
if(res.bump.match(/^patch/)) {
newVer = semver.inc(pkg.version, 'patch');
} else if(res.bump.match(/^minor/)) {
newVer = semver.inc(pkg.version, 'minor');
} else if(res.bump.match(/^major/)) {
newVer = semver.inc(pkg.version, 'major');
}
}));
});
gulp.task('changelog', function() {
var streamqueue = require('streamqueue'),
stream = streamqueue({objectMode: true}),
exec = require('gulp-exec'),
concat = require('gulp-concat'),
clean = require('gulp-clean');
stream.queue(gulp.src('').pipe(exec('node ./changelog.js ' + newVer, {pipeStdout: true})));
stream.queue(gulp.src('CHANGELOG.md').pipe(clean()));
return stream.done()
.pipe(concat('CHANGELOG.md'))
.pipe(gulp.dest('./'));
});
gulp.task('updatePackage', function() {
var jeditor = require("gulp-json-editor");
return gulp.src('package.json')
.pipe(jeditor({
'version': newVer
}))
.pipe(gulp.dest("./"))
});
gulp.task('updateBower', function() {
var jeditor = require("gulp-json-editor");
return gulp.src('bower.json')
.pipe(jeditor({
'version': newVer
}))
.pipe(gulp.dest("./"));
});
gulp.task('release', ['karma'], function(done) {
runSequence('promptBump', 'updatePackage', 'updateBower', 'changelog', 'build-files', done);
});