forked from areijngoudt/angular-swagger-form-field-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (52 loc) · 2.18 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
/*global __dirname */
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({ lazy: true });
var args = require('yargs').argv;
var swaggerTSGenerator = require('./node_modules/swagger-ts-generator');
var request = require('request');
var source = require('vinyl-source-stream');
var config = require('./gulp.config');
//--------------- gulp tasks ---------------
gulp.task('default', ['show-help']); // Set default gulp tasks
gulp.task('show-help', $.taskListing);
gulp.task('gen', ['gen-webapi']);
gulp.task('gen-webapi', ['gen-webapi-download-swagger'], genWebapi);
gulp.task('gen-webapi-download-swagger', genWebapiDownloadSwagger);
//--------------- generator tasks ---------------
function genWebapi(done) {
swaggerTSGenerator.generateTSFiles(config.swagger.swaggerFile, config.swagger.swaggerTSGeneratorOptions);
done();
}
function genWebapiDownloadSwagger(done) {
// for this project we use a static swagger.json which is included in the project (in the swagger folder)
// in a real project the swagger.json is downloaded from the webapi using logic like the commented section below.
// remove the done() statement and uncomment the section below.
done();
// process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'; // Ignore 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' authorization error
// return request
// .get({
// url: config.swagger.url,
// headers: {
// 'User-Agent': 'request',
// 'content-type': 'application/json'
// }
// })
// .pipe(customPlumber('Error gen-webapi-download-swagger'))
// .pipe(source(config.swagger.swaggerFile))
// .pipe($.streamify($.jsbeautifier(/*{ mode: 'VERIFY_AND_WRITE' }*/)))
// .pipe(gulp.dest(config.root));
}
function customPlumber(errTitle) {
return $.plumber({
errorHandler: $.notify.onError({
// Customizing error title
title: errTitle || "Error running Gulp",
message: "Error: <%= error.message %>",
sound: "Glass"
})
});
}
function log(msg) {
$.util.log($.util.colors.yellow(msg));
}