-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
105 lines (92 loc) · 2.56 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
/* jshint node: true */
'use strict'
const gulp = require('gulp')
const jsdoc = require('gulp-jsdoc3')
const zip = require('gulp-zip')
const path = require('path')
const fs = require('fs')
const chalk = require('chalk')
const jshint = require('gulp-jshint')
const stylish = require('jshint-stylish')
const ftp = require('vinyl-ftp');
// handle the zip filename consistently with functions
const zip_filename = () => {
return `${process.env.NODE_ENV}.zip`
}
const zip_path = () => {
return 'deploy/aws-lambda/'
}
const zip_filepath = () => {
return path.join(zip_path(), zip_filename())
}
gulp.task('watch', () => {
gulp.watch('./code/*.js', ['gendoc', ])
});
gulp.task('lint', function() {
return gulp.src(['./src/**/*.js', './__test__/**/*.js',])
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
/* copied & adapted from the jsdoc master config
* https://github.com/mlucool/gulp-jsdoc3/blob/master/src/jsdocConfig.json
*/
var jsdoc_config = {
"tags": {
"allowUnknownTags": true,
},
"opts": {
"destination": "./code-docs/",
},
"plugins": [
"plugins/markdown",
],
"templates": {
"cleverLinks": false,
"monospaceLinks": true, //modified
"default": {
"outputSourceFiles": false, //modified
},
"path": "ink-docstrap",
"theme": "cerulean",
"navType": "vertical",
"linenums": true,
"dateFormat": "MMMM Do YYYY, h:mm:ss a",
},
}
gulp.task('gendoc', (cb) =>
gulp.src(['README.md', './code/*.js', './extensions/*.js', ], {
read: false,
})
.pipe(jsdoc(jsdoc_config, cb))
)
//pull deployment credentials from the shared credentials file ~/.aws/credentials
//runtime credentials are in the config
gulp.task("zip", function (cb) {
//config management load order described here: https://github.com/lorenwest/node-config/wiki/Configuration-Files
var config = require('config')
if (undefined == process.env.NODE_ENV){
console.log(chalk`{red ${'ERROR:'}} {blueBright process.env.NODE_ENV} is not defined`)
done()
return
}
try {
fs.unlinkSync(zip_filepath())
console.log(`old $${zip_filepath()} deleted`);
} catch (e) {
console.log(`old $${zip_filepath()} cannot be deleted`);
}
console.log(`zip paths:`)
console.dir(deploy_files)
console.log(`zipping to ${zip_filepath()} ...`)
//var params = config.lambda.params
//var options = config.lambda.options
return gulp.src(deploy_files, {
base: '.',
})
.pipe(zip(zip_filename(), {
FileComment: "Auto generated from gulp script",
}))
.pipe(gulp.dest(zip_path()))
})
gulp.task('mmupload', async () =>{
})