This repository has been archived by the owner on Dec 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
gulpfile.js
145 lines (124 loc) · 3.53 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
143
144
145
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const gulp = require("gulp");
const ts = require("gulp-typescript");
const sourcemaps = require("gulp-sourcemaps");
const typescript = require("typescript");
const del = require("del");
const es = require("event-stream");
const vsce = require("vsce");
const nls = require("vscode-nls-dev");
const tsProject = ts.createProject("./tsconfig.json", { typescript });
const inlineMap = true;
const inlineSource = false;
const outDest = "out";
// A list of all locales supported by VSCode can be found here: https://code.visualstudio.com/docs/getstarted/locales
const languages = [{ folderName: "en", id: "en" }];
gulp.task("clean", () => {
return del(
[
"out/*",
"package.nls.*.json",
"../../dist/*0.0.0-UNTRACKEDVERSION.vsix",
],
{ force: true }
);
});
const pythonToMove = [
"./src/adafruit_circuitplayground/*.*",
"./src/clue/*.*",
"./src/clue/!(test)/**/*",
"./src/base_circuitpython/**/*",
"./src/micropython/*.*",
"./src/micropython/microbit/*.*",
"./src/micropython/microbit/!(test)/**/*",
"./src/*.py",
"./src/common/*.py",
"./src/dev-requirements.txt",
"./src/requirements.txt",
"./src/templates/*.*"
];
gulp.task("python-compile", () => {
// the base option sets the relative root for the set of files,
// preserving the folder structure
return gulp.src(pythonToMove, { base: "./src/" }).pipe(gulp.dest("out"));
});
gulp.task("internal-compile", () => {
return compile(false);
});
gulp.task("internal-nls-compile", () => {
return compile(true);
});
gulp.task("add-locales", () => {
return gulp
.src(["package.nls.json"])
.pipe(nls.createAdditionalLanguageFiles(languages, "locales"))
.pipe(gulp.dest("."));
});
gulp.task("vsce:publish", () => {
return vsce.publish();
});
gulp.task("vsce:package", () => {
return vsce.createVSIX({
packagePath:
"../../dist/deviceSimulatorExpress-0.0.0-UNTRACKEDVERSION.vsix",
});
});
gulp.task(
"compile",
gulp.series("clean", "internal-compile", "python-compile", callback => {
callback();
})
);
gulp.task(
"build",
gulp.series(
"clean",
"internal-nls-compile",
"python-compile",
"add-locales",
callback => {
callback();
}
)
);
gulp.task(
"publish",
gulp.series("compile", "vsce:publish", callback => {
callback();
})
);
gulp.task(
"package",
gulp.series("compile", "vsce:package", callback => {
callback();
})
);
//---- internal
function compile(buildNls) {
var r = tsProject
.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
.pipe(
buildNls
? nls.createAdditionalLanguageFiles(languages, "locales", "out")
: es.through()
);
if (inlineMap && inlineSource) {
r = r.pipe(sourcemaps.write());
} else {
r = r.pipe(
sourcemaps.write("../out", {
// no inlined source
includeContent: inlineSource,
// Return relative source map root directories per file.
sourceRoot: "../src",
})
);
}
return r.pipe(gulp.dest(outDest));
}