-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
182 lines (161 loc) · 4.37 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
178
179
180
181
182
var gulp = require('gulp');
var runSequence = require('run-sequence');
var del = require('del');
var vinylPaths = require('vinyl-paths');
var babel = require('gulp-babel');
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 nodemon = require('gulp-nodemon');
var util = require("util");
var path = {
source: ["public/polymer/**/*.js", "!public/polymer/bower_components/**/*.js"],
html: ["public/polymer/**/*.html", "!public/polymer/bower_components/**/*.html"],
style: ["public/polymer/**/*.css", "!public/polymer/bower_components/**/*.css"],
//output:'public/app/dist/',
//doc:'public/app/doc'
};
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 false;
//return gulp.src([path.output])
// .pipe(vinylPaths(del));
});
gulp.task('build-system', function () {
return false;
//return gulp.src(path.source)
// .pipe(plumber())
// .pipe(changed(path.output, {extension: '.js'}))
// .pipe(babel(assign({}, compilerOptions, {modules:'system'})))
// .pipe(gulp.dest(path.output));
});
gulp.task('build-html', function () {
return false;
//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('update-own-deps', function(){
tools.updateOwnDependenciesFromLocalRepositories();
});
gulp.task('browser-sync', ['build', 'nodemon'], function() {
browserSync.init({
proxy: 'http://localhost:9000',
port: 7000,
//browser: ['firefox']
open: false
});
});
function reportChange(event){
util.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
}
gulp.task('nodemon', function (cb) {
var called = false;
return nodemon({
script: 'app.js',
"execMap": {
"js": "node --harmony"
},
"ignore": [
".git",
"public",
"node_modules"
]
})
.on('start', function onStart() {
if (!called) {
cb();
}
called = true;
})
.on('restart', function onRestart() {
setTimeout(function reload() {
browserSync.reload({
stream: false
});
}, 500);
});
});
gulp.task('watch', ['nodemon', 'browser-sync'], function() {
util.log("Watching files");
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
);
});