forked from allenhwkim/angularjs-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (110 loc) · 3.86 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
'use strict';
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 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 karma = require('karma').server;
var connect = require('gulp-connect');
var gulpProtractor = require("gulp-protractor").protractor;
var angularJsdoc = require('angular-jsdoc');
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('build')
.pipe(clean({force: true}));
});
gulp.task('build-js', function() {
return gulp.src([
'app.js',
'services/*.js',
'directives/*.js'
])
.pipe(concat('ng-map.debug.js'))
.pipe(gulp.dest('build/scripts'))
.pipe(stripDebug())
.pipe(concat('ng-map.js'))
.pipe(gulp.dest('build/scripts'))
.pipe(uglify())
.pipe(rename('ng-map.min.js'))
.pipe(gulp.dest('build/scripts'))
.on('error', gutil.log);
});
gulp.task('docs', function() {
gulp.task('docs', shell.task([
'node_modules/jsdoc/jsdoc.js '+
'-c node_modules/angular-jsdoc/common/conf.json '+ // config file
'-t node_modules/angular-jsdoc/angular-template '+ // template file
'-d build/docs '+ // output directory
'./README.md ' + // to include README.md as index contents
'-r directives services' // source code directory
]));
});
gulp.task('bump', function() { bumpVersion('patch'); });
gulp.task('bump:patch', function() { bumpVersion('patch'); });
gulp.task('bump:minor', function() { bumpVersion('minor'); });
gulp.task('bump:major', function() { bumpVersion('major'); });
gulp.task('build', function(callback) {
runSequence('clean', 'build-js', 'test', 'docs', callback);
});
gulp.task('test', function (done) {
karma.start({
configFile: __dirname + '/config/karma.conf.js',
singleRun: true
}, done);
});
gulp.task('testapp-server', function() {
connect.server({
root: __dirname + '/testapp',
port: 8888
});
});
gulp.task('test-e2e', ['testapp-server'], function() {
gulp.src([__dirname + "/spec/e2e/*_spec.js"])
.pipe(gulpProtractor({
configFile: __dirname + "/config/protractor.conf.js",
args: [
'--baseUrl', 'http://localhost:8888'
]
}))
.on('error', function(e) {
console.log([
'------------------------------------------------------------------------------------',
'For first-time user, we need to update webdrivers',
'$ node_modules/gulp-protractor/node_modules/protractor/bin/webdriver-manager update',
'------------------------------------------------------------------------------------'
].join('\n'));
throw e;
})
.on('end', function() { // when process exits:
connect.serverClose();
});
});