forked from allenhwkim/angularjs-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
98 lines (89 loc) · 3.04 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var debug = require('gulp-debug');
var rename = require('gulp-rename');
var stripDebug = require('gulp-strip-debug');
var filesize = require('gulp-filesize');
var gutil = require('gulp-util');
var clean = require('gulp-clean');
var runSequence = require('run-sequence');
var gutil = require('gulp-util');
var through = require('through2');
var replace = require('gulp-replace');
var tap = require('gulp-tap');
var bump = require('gulp-bump');
var shell = require('gulp-shell');
var bumpVersion = function(type) {
type = type || 'patch';
var version = '';
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type: type}))
.pipe(gulp.dest('./'))
.pipe(tap(function(file, t) {
version = JSON.parse(file.contents.toString()).version;
})).on('end', function() {
var color = gutil.colors;
gulp.src('')
.pipe(shell([
'git commit --all --message "Version ' + version + '"',
(type != 'patch' ? 'git tag --annotate "v' + version + '" --message "Version ' + version + '"' : 'true')
], {ignoreErrors: false}))
.pipe(tap(function() {
gutil.log(color.green("Version bumped to ") + color.yellow(version) + color.green(", don't forget to push!"));
}));
});
};
gulp.task('clean', function() {
return gulp.src('bulid')
.pipe(clean({force: true}));
});
gulp.task('build-js', function() {
return gulp.src(['app/scripts/namespace.js',
'app/scripts/services/*.js',
'app/scripts/directives/*.js',
'app/scripts/app.js'])
.pipe(concat('ng-map.js'))
.pipe(gulp.dest('build/scripts'))
.pipe(filesize())
.pipe(stripDebug())
.pipe(uglify())
.pipe(rename('ng-map.min.js'))
.pipe(gulp.dest('build/scripts'))
.pipe(filesize())
.on('error', gutil.log);
});
gulp.task('copy', function() {
return gulp.src('./testapp/scripts/*')
.pipe(gulp.dest('./build/scripts'))
.pipe(gulp.src('./testapp/css/*'))
.pipe(gulp.dest('./build/css'))
});
gulp.task('build-html', function() {
return gulp.src('./testapp/*.html')
.pipe(replace(
/<!-- build:js ([^ ]+) -->[^\!]+<!-- endbuild -->/gm,
function(natch, $1) {
{return '<script src="' + $1+'"></script>';}
}
))
.pipe(gulp.dest('./build'));
});
gulp.task('docs', shell.task([
'node_modules/jsdoc/jsdoc.js '+
'-c node_modules/angular-jsdoc/conf.json '+
'-t node_modules/angular-jsdoc/template '+
'-d build/docs '+
'./README.md ' +
'-r app/scripts'
]));
gulp.task('bump', ['build'], function() { bumpVersion('patch'); });
gulp.task('bump:patch', ['build'], function() { bumpVersion('patch'); });
gulp.task('bump:minor', ['build'], function() { bumpVersion('minor'); });
gulp.task('bump:major', ['build'], function() { bumpVersion('major'); });
gulp.task('build', function(callback) {
runSequence('clean', 'build-js', 'copy', 'build-html', 'test', 'docs', callback);
});
gulp.task('test', shell.task([
'./node_modules/karma/bin/karma start'
]));