-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (35 loc) · 1.33 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
'use strict';
const _ = require('lodash');
const del = require('del');
const gulp = require('gulp');
const zip = require('gulp-zip');
const merge = require('merge-stream');
const install = require('gulp-install');
const runSequence = require('run-sequence');
const awsLambda = require('node-aws-lambda');
const awsConfig = require('./aws-config'); // eslint-disable-line import/no-unresolved
gulp.task('clean', () => del(['dist/']));
gulp.task('bundle', () => gulp
.src('./package.json')
.pipe(gulp.dest('./dist'))
.pipe(install({ production: true })));
gulp.task('compile', () => {
const tasks = ['src'].map(directory => gulp
.src(`${directory}/**/*`)
.pipe(gulp.dest(`./dist/${directory}`)));
return merge(tasks);
});
gulp.task('zip', () => gulp
.src('./dist/**/*', { nodir: true })
.pipe(zip('dist/dist.zip'))
.pipe(gulp.dest('./')));
gulp.task('upload', (callback) => {
awsLambda.deploy('./dist/dist.zip', awsConfig, callback);
});
gulp.task('uploadGoogle', (callback) => {
const awsConfigCloned = _.cloneDeep(awsConfig);
awsConfigCloned.functionName = 'quick-maths-google-action';
awsConfigCloned.handler = 'src/handler.assistantHandler';
awsLambda.deploy('./dist/dist.zip', awsConfigCloned, callback);
});
gulp.task('deploy', callback => runSequence(['clean'], ['bundle'], ['compile'], ['zip'], callback));