-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
114 lines (92 loc) · 3.04 KB
/
gulpfile.babel.js
File metadata and controls
114 lines (92 loc) · 3.04 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
//-------------------------------------------------------------------------------
// Requires
//-------------------------------------------------------------------------------
import { ObjectUtil as _ } from 'bugcore';
import config from 'config';
import gulp from 'gulp';
import babel from 'gulp-babel';
import cloudformation from 'gulp-cloudformation';
import eslint from 'gulp-eslint';
import jest from 'gulp-jest-iojs';
import sourcemaps from 'gulp-sourcemaps';
import util from'gulp-util';
//-------------------------------------------------------------------------------
// Gulp Properties
//-------------------------------------------------------------------------------
const sources = {
babel: [
'src/**',
'!**/tests/**'
],
lint: [
'src/**/*.js',
'!node_modules/**'
],
stacks: [
'aws/stacks/*.json'
]
};
//-------------------------------------------------------------------------------
// Gulp Tasks
//-------------------------------------------------------------------------------
gulp.task('default', ['prod']);
gulp.task('prod', ['babel']);
gulp.task('dev', ['babel', 'lint', 'babel-watch', 'lint-watch']);
gulp.task('test', ['lint']);
gulp.task('deploy', ['cloudformation', 'firebase-deploy-rules']);
gulp.task('babel', function() {
return gulp.src(sources.babel)
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe(babel({
presets: ['es2015', 'stage-2']
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'))
.on('error', function(error) {
util.log(error);
});
});
gulp.task('lint', function() {
return gulp.src(sources.lint)
.pipe(eslint())
.pipe(eslint.formatEach())
.pipe(eslint.failAfterError())
.on('error', function(error) {
util.log('Stream Exiting With Error', error);
throw error;
});
});
gulp.task('cloudformation', function() {
return gulp.src(sources.stacks)
.pipe(cloudformation.init(_.assign({region: 'us-east-1'}, config.get('aws'))))
.pipe(cloudformation.deploy({
Capabilities: [ 'CAPABILITY_IAM' ]
}))
.on('error', function(error) {
util.log('Stream Exiting With Error', error);
throw error;
});
});
gulp.task('firebase-deploy-rules', function() {
});
//-------------------------------------------------------------------------------
// Gulp Watchers
//-------------------------------------------------------------------------------
gulp.task('babel-watch', function() {
gulp.watch(sources.babel, ['babel']);
});
gulp.task('lint-watch', function() {
const lintAndPrint = eslint();
lintAndPrint.pipe(eslint.formatEach());
return gulp.watch('src/**/*.js', function(event) {
if (event.type !== 'deleted') {
gulp.src(event.path)
.pipe(lintAndPrint, {end: false})
.on('error', function(error) {
util.log(error);
});
}
});
});