forked from Azure/azure-openapi-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
142 lines (121 loc) · 4.34 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var gulp = require('gulp');
var clean = require('gulp-clean');
var run = require('gulp-shell')
var mocha = require('gulp-mocha');
// All the typescript tasks
gulp.task('clean/typescript', function () {
console.log('Cleaning build directories...');
return gulp.src(['src/typescript/azure-openapi-validator/*.{js,d.ts}', 'src/typescript/jsonrpc/*.{js,d.ts}'], { read: false })
.pipe(clean({ force: true }));
});
gulp.task("build/typescript", gulp.series(["clean/typescript"], function () {
console.log("Running the typescript transpiler...")
return gulp.src("./src/typescript/").pipe(run("tsc --project tsconfig.json"))
}))
gulp.task('test/typescript', gulp.series(['build/typescript'], function (done) {
console.log('Running the unit tests...');
gulp.src(['src/typescript/azure-openapi-validator/tests/*.js'])
.pipe(mocha({
timeout: 120000
}))
.once('error', () => {
process.exit(1);
});
done()
}));
gulp.task(
"generate/doc",
gulp.series(["build/typescript"], function(done) {
console.log("Generating the doc...")
gulp
.src("src/typescript/azure-openapi-validator/generateDoc.js")
.once("error", () => {
process.exit(1)
})
done()
})
)
// All the dotnet tasks
gulp.task('clean/dotnet', function () {
console.log('Cleaning build directories...');
return gulp.src("./").pipe(run ("dotnet clean src/dotnet/OpenAPI.Validator.sln"));
});
gulp.task('restore/dotnet', gulp.series(['clean/dotnet'], function () {
console.log('Running dotnet restore...');
return gulp.src("./").pipe(run ("dotnet restore src/dotnet/OpenAPI.Validator.sln"));
}))
gulp.task('build/dotnet', gulp.series(['restore/dotnet'], function () {
console.log('Running dotnet build...');
return gulp.src("./").pipe(run ("dotnet build src/dotnet/OpenAPI.Validator.sln"));
}))
gulp.task('build/regressionTest', gulp.series([], function () {
console.log('Running regression test build...');
return gulp.src("./").pipe(run("tsc --project tsconfig.json"))
}))
gulp.task('test/dotnet', gulp.series(['clean/dotnet'], function () {
console.log('Running the dotnet unit tests...');
return gulp.src("./").pipe(run("dotnet test src/dotnet/OpenAPI.Validator.sln"));
}))
// Now the defaults/commons
gulp.task(
"build",
gulp.parallel(["build/dotnet", "build/typescript", "build/regressionTest"], async function (done) {
console.log("Building code...")
done()
})
)
gulp.task(
"clean",
gulp.parallel(["clean/typescript", "clean/dotnet"], function (done) {
console.log("Cleaning artifacts...")
done()
})
)
gulp.task(
"test",
gulp.parallel(["test/dotnet", "test/typescript"], function (done) {
console.log("Successfully ran the tests...")
done()
})
)
gulp.task('dotnet', gulp.series(['test/dotnet'], function (done) {
done()
}))
gulp.task('typescript', gulp.series(['test/typescript'], function (done) {
done()
}))
gulp.task(
"default",
gulp.parallel(["dotnet", "typescript"], function (done) {
console.log("Successfully built and tested the repo...")
done()
})
)
gulp.task(
"dotnet/pack", function () {
console.log("Kicking off the dotnet publish task...")
return gulp.src("./").pipe(run("dotnet publish src/dotnet/AutoRest/AutoRest.csproj --configuration release --output bin/netcoreapp2.0"));
})
gulp.task('pack/typescript', function () {
return gulp.src("./").pipe(run('cd src/typescript && npm pack'));
})
gulp.task('pack/dotnet',gulp.series(["clean/dotnet","dotnet/pack"], function () {
return gulp.src("./").pipe(run('cd src/dotnet/AutoRest && npm pack'));
}))
// this task can be excuted only when `gulp test` has been excuted successfully
gulp.task(
"pack",
gulp.series(["pack/dotnet", "pack/typescript"], function (done) {
gulp.src(["src/dotnet/AutoRest/*.tgz", "src/typescript/*.tgz"]).pipe(gulp.dest("dist/"))
console.log("Successfully Packed the repo...")
done()
})
)
gulp.task('coverage/ts', function() {
return gulp.src("./").pipe(run('nyc mocha ./src/typescript/azure-openapi-validator/tests/**/*.js'))
}
);