forked from microsoft/appcenter-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
117 lines (92 loc) · 3.04 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
// Gulpfile to build sonoma CLI
const clean = require('gulp-clean');
const gulp = require('gulp');
const minimist = require('minimist');
const runSeq = require('run-sequence');
const rimraf = require('rimraf');
const sourcemaps = require('gulp-sourcemaps');
const ts = require('gulp-typescript');
const util = require('util');
const autorest = require('./scripts/autorest');
const autocompleteTree = require('./scripts/autocomplete-tree');
let tsProject = ts.createProject('tsconfig.json');
//
// General compile
//
gulp.task('clean', function (done) {
rimraf('dist', done);
});
gulp.task('build-ts', function () {
let tsResult = gulp.src(['src/**/*.ts', 'typings/**/*.d.ts'])
.pipe(tsProject());
return tsResult.js
.pipe(gulp.dest('dist'));
});
gulp.task('build-ts-sourcemaps', function () {
let tsResult = gulp.src(['src/**/*.ts', 'typings/**/*.d.ts'])
.pipe(sourcemaps.init())
.pipe(tsProject());
return tsResult.js
.pipe(sourcemaps.write('.', { includeContent:false, sourceRoot: '.' }))
.pipe(gulp.dest('dist'));
});
gulp.task('copy-assets', function () {
return gulp.src('src/**/*.txt')
.pipe(gulp.dest('dist'));
});
gulp.task('copy-generated-client', function () {
return gulp.src('src/util/apis/generated/**/*.[tj]s')
.pipe(gulp.dest('dist/util/apis/generated'));
});
gulp.task('generate-autocomplete-tree', function () {
autocompleteTree.generateAndSave();
});
gulp.task('build', function(done) {
runSeq([ 'build-ts', 'copy-assets', 'copy-generated-client' ], 'generate-autocomplete-tree', done);
});
gulp.task('build-sourcemaps', function(done) {
runSeq([ 'build-ts-sourcemaps', 'copy-assets', 'copy-generated-client' ], 'generate-autocomplete-tree', done);
});
gulp.task('clean-sourcemaps', function (cb) {
return gulp.src('dist/**/*.js.map')
.pipe(clean())
});
//
// Client code generation. Requires mono to be installed on the machine
// on a mac or linux machine
//
const generatedSource = './src/util/apis/generated';
gulp.task('clean-autorest', function (done) {
rimraf(generatedSource, done);
});
gulp.task('fixup-swagger', function () {
autorest.fixupRawSwagger('./swagger/bifrost.swagger.before.json', './swagger/bifrost.swagger.json');
});
const parseOpts = {
string: 'env',
alias: { env: 'e' },
default: { env: 'prod' }
};
gulp.task('download-autorest-tools', function () {
return autorest.downloadTools();
});
gulp.task('download-swagger', function() {
const args = minimist(process.argv.slice(2), parseOpts);
return autorest.downloadSwagger(args.env);
});
gulp.task('generate-client', function () {
return autorest.generateCode('./swagger/bifrost.swagger.json', generatedSource, 'AppCenterClient');
});
gulp.task('autorest', ['clean-autorest'], function (done) {
runSeq(['download-autorest-tools', 'download-swagger'], 'fixup-swagger', 'generate-client', done);
});
//
// Prepublish script - set up everything before publishing to npm
//
gulp.task('prepublish', function(done) {
runSeq('clean', 'build', done);
});
//
// Default task - build the code
//
gulp.task('default', [ 'build' ]);