forked from microsoft/appcenter-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
84 lines (66 loc) · 2.21 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
// Gulpfile to build sonoma CLI
const clean = require("gulp-clean");
const gulp = require("gulp");
const rimraf = require("rimraf");
const sourcemaps = require("gulp-sourcemaps");
const ts = require("gulp-typescript");
const autocompleteTree = require("./scripts/autocomplete-tree");
const tsProject = ts.createProject("tsconfig.json");
//
// General compile
//
gulp.task("clean", function (done) {
rimraf("dist", done);
});
gulp.task("build-ts", function () {
const tsResult = gulp.src(["src/**/*.ts"]).pipe(tsProject());
return tsResult.js.pipe(gulp.dest("dist"));
});
gulp.task("build-ts-sourcemaps", function () {
const tsResult = gulp.src(["src/**/*.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 (done) {
autocompleteTree.generateAndSave();
done();
});
gulp.task("copy-test-templates", function () {
return gulp.src("src/commands/test/lib/templates/**/*").pipe(gulp.dest("dist/commands/test/lib/templates"));
});
gulp.task(
"build:raw",
gulp.series(
gulp.parallel("build-ts", "copy-assets", "copy-generated-client"),
gulp.series("generate-autocomplete-tree", "copy-test-templates")
)
);
gulp.task(
"build-sourcemaps",
gulp.series(
gulp.parallel("build-ts-sourcemaps", "copy-assets", "copy-generated-client"),
gulp.series("generate-autocomplete-tree", "copy-test-templates")
)
);
gulp.task("clean-sourcemaps", function () {
return gulp.src("dist/**/*.js.map").pipe(clean());
});
//
// Stop people from using gulp build to skip linting
//
gulp.task("build", function () {
throw new Error('Do not use gulp build! Run "npm run build" instead!');
});
//
// Prepublish script - set up everything before publishing to npm
//
gulp.task("prepublish", gulp.series("clean", "build:raw"));
//
// Default task - build the code
//
gulp.task("default", gulp.series("build:raw"));