-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
177 lines (155 loc) · 4.46 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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
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 browserSync = require('browser-sync');
var changed = require('gulp-changed');
var plumber = require('gulp-plumber');
var tools = require('aurelia-tools');
var protractor = require("gulp-protractor").protractor;
var webdriver_update = require('gulp-protractor').webdriver_update;
var path = {
source:'src/**/*.js',
html:'src/**/*.html',
style:'styles/**/*.css',
output:'dist/',
doc:'./doc',
e2eSpecsSrc: 'test/e2e/src/*.js',
e2eSpecsDist: 'test/e2e/dist/'
};
var compilerOptions = {
filename: '',
filenameRelative: '',
blacklist: [],
whitelist: [],
modules: '',
sourceMap: true,
sourceMapName: '',
sourceFileName: '',
sourceRoot: '',
moduleRoot: '',
moduleIds: false,
experimental: false,
format: {
comments: false,
compact: false,
indent: {
parentheses: true,
adjustMultilineComment: true,
style: " ",
base: 0
}
}
};
var jshintConfig = {esnext:true};
gulp.task('clean', function() {
return gulp.src([path.output])
.pipe(vinylPaths(del));
});
gulp.task('build-system', function () {
return gulp.src(path.source)
.pipe(plumber())
.pipe(changed(path.output, {extension: '.js'}))
.pipe(to5(assign({}, compilerOptions, {modules:'system'})))
.pipe(gulp.dest(path.output));
});
gulp.task('build-html', function () {
return gulp.src(path.html)
.pipe(changed(path.output, {extension: '.html'}))
.pipe(gulp.dest(path.output));
});
gulp.task('lint', function() {
return gulp.src(path.source)
.pipe(jshint(jshintConfig))
.pipe(jshint.reporter(stylish));
});
gulp.task('doc-generate', function(){
return gulp.src(path.source)
.pipe(yuidoc.parser(null, 'api.json'))
.pipe(gulp.dest(path.doc));
});
gulp.task('doc', ['doc-generate'], function(){
tools.transformAPIModel(path.doc);
});
gulp.task('bump-version', function(){
return gulp.src(['./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-system', 'build-html'],
callback
);
});
gulp.task('webdriver_update', webdriver_update);
gulp.task('build-e2e', function () {
return gulp.src(path.e2eSpecsSrc)
.pipe(plumber())
.pipe(to5())
.pipe(gulp.dest(path.e2eSpecsDist));
});
gulp.task('e2e', ['webdriver_update', 'build-e2e'], function(cb) {
return gulp.src(path.e2eSpecsDist + "/*.js")
.pipe(protractor({
configFile: "protractor.conf.js",
args: ['--baseUrl', 'http://127.0.0.1:9000']
}))
.on('error', function(e) { throw e; });
});
gulp.task('update-own-deps', function(){
tools.updateOwnDependenciesFromLocalRepositories();
});
gulp.task('build-dev-env', function () {
tools.buildDevEnv();
});
gulp.task('serve', ['build'], function(done) {
browserSync({
open: false,
port: 9000,
server: {
baseDir: ['.'],
middleware: function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
}
}
}, done);
});
function reportChange(event){
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
}
gulp.task('watch', ['serve'], function() {
gulp.watch(path.source, ['build-system', browserSync.reload]).on('change', reportChange);
gulp.watch(path.html, ['build-html', browserSync.reload]).on('change', reportChange);
gulp.watch(path.style, browserSync.reload).on('change', reportChange);
});
gulp.task('prepare-release', function(callback){
return runSequence(
'build',
'lint',
'bump-version',
'doc',
'changelog',
callback
);
});