forked from allenhwkim/angularjs-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
153 lines (141 loc) · 4.73 KB
/
gulpfile.js
File metadata and controls
153 lines (141 loc) · 4.73 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
'use strict';
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
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 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 File = require('vinyl');
var through = require('through2');
var path = require('path');
var cheerio = require('cheerio');
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) {
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',
'controllers/*.js',
'directives/*.js',
'filters/*.js',
'services/*.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', 'examples:json', callback);
});
gulp.task('test', function (done) {
karma.start({
configFile: __dirname + '/config/karma.conf.js',
singleRun: true
}, done);
});
gulp.task('test:server', function() {
connect.server({
root: __dirname,
port: 8888
});
});
gulp.task('test:e2e', ['test: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();
});
});
gulp.task('examples:json', function() {
var allExamples = {};
gulp.src([__dirname + "/testapp/*.html"])
.pipe(through.obj(
function(file, encoding, callback) {
var $ = cheerio.load(file.contents);
allExamples[path.basename(file.path)] = {
path: path.relative(path.dirname(path.dirname(file.path)), file.path),
title: $('title').html(),
description: $('meta[name=description]').attr('content'),
keywords: $('meta[name=keywords]').attr('content')
};
callback();
},
function(callback) {
this.push( new File({
cwd: ".",
base: "./",
path: "./all-examples.json",
contents: new Buffer(JSON.stringify(allExamples, null,' '))
}));
callback();
}
))
.pipe(gulp.dest('testapp'));
});