forked from touchstonejs/touchstonejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
139 lines (113 loc) · 2.45 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
var babel = require('gulp-babel');
var bump = require('gulp-bump');
var connect = require('gulp-connect');
var del = require('del');
var deploy = require('gulp-gh-pages');
var git = require('gulp-git');
var gulp = require('gulp');
var less = require('gulp-less');
var src = [
'src/**/*.js',
'!**/__tests__/**/*'
];
/**
* Clean the build
*/
gulp.task('clean:lib', function (done) {
del(['lib'], done);
});
/**
* Build lib
*/
gulp.task('build:lib', function () {
return gulp.src(src)
.pipe(babel({
plugins: [require('babel-plugin-object-assign')]
}))
.pipe(gulp.dest('lib'));
});
gulp.task('watch:lib', ['build:lib'], function () {
gulp.watch(src, ['build:lib']);
});
/**
* Clean site build
*/
gulp.task('clean:site', function (done) {
del(['site/public/build'], done);
});
/**
* Build site css from less
*/
function buildSiteCSS () {
return gulp.src('site/src/less/site.less')
.pipe(less())
.pipe(gulp.dest('site/public/build/css'))
.pipe(connect.reload());
}
gulp.task('build:site:css', buildSiteCSS);
/**
* Build site
*/
gulp.task('build:site', [
'build:site:css'
]);
gulp.task('watch:site', [
'build:site:css'
], function () {
gulp.watch(['site/src/less/**/*'], ['build:site:css']);
});
/**
* Serve task for local development
*/
gulp.task('site', ['watch:site'], function () {
connect.server({
root: 'site/public',
port: 8000,
livereload: true
});
});
/**
* Version bump tasks
*/
function _bump (type) {
return function () {
return gulp.src(['./package.json', './bower.json'])
.pipe(bump({ type: type }))
.pipe(gulp.dest('./'));
};
}
gulp.task('bump', _bump('patch'));
gulp.task('bump:minor', _bump('minor'));
gulp.task('bump:major', _bump('major'));
/**
* Git tag task
* (version *must* be bumped first)
*/
gulp.task('publish:tag', function (done) {
var pkg = require('./package.json');
var v = 'v' + pkg.version;
var message = 'Release ' + v;
git.tag(v, message, function (err) {
if (err) throw err;
git.push('origin', v, function (err) {
if (err) throw err;
done();
});
});
});
/**
* npm publish task
* * (version *must* be bumped first)
*/
gulp.task('publish:npm', function (done) {
require('child_process')
.spawn('npm', ['publish'], { stdio: 'inherit' })
.on('close', done);
});
/**
* Deploy tasks
*/
gulp.task('publish:site', ['build:site'], function () {
return gulp.src('site/public/**/*').pipe(deploy());
});
gulp.task('release', ['publish:tag', 'publish:npm', 'publish:site']);