zarro 1.99.5 → 1.100.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gulp-tasks/build.js +18 -30
- package/gulp-tasks/clean.js +55 -37
- package/gulp-tasks/modules/register-environment-variables.js +2 -2
- package/gulp-tasks/modules/try-do.js +51 -0
- package/gulp-tasks/modules/try-do.ts +56 -0
- package/package.json +1 -1
- package/types.d.ts +761 -757
package/gulp-tasks/build.js
CHANGED
|
@@ -14,9 +14,10 @@ const
|
|
|
14
14
|
log = requireModule("log"),
|
|
15
15
|
resolveMasks = requireModule("resolve-masks"),
|
|
16
16
|
logConfig = requireModule("log-config"),
|
|
17
|
+
tryDo = requireModule("try-do"),
|
|
17
18
|
msbuild = require("gulp-msbuild");
|
|
18
19
|
|
|
19
|
-
gulp.task("prebuild", ["nuget-restore"]);
|
|
20
|
+
gulp.task("prebuild", ["nuget-restore", "clean"]);
|
|
20
21
|
|
|
21
22
|
const myTasks = ["build"],
|
|
22
23
|
myVars = [
|
|
@@ -48,28 +49,12 @@ gulp.task(
|
|
|
48
49
|
gulp.task("quick-build", "Quick build without pre-cursors", tryBuild);
|
|
49
50
|
|
|
50
51
|
async function tryBuild() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
while (totalAttempts-- > 0) {
|
|
59
|
-
try {
|
|
60
|
-
await build();
|
|
61
|
-
} catch (e) {
|
|
62
|
-
if (totalAttempts > 0) {
|
|
63
|
-
console.error(chalk.red(`Build fails: ${e}`));
|
|
64
|
-
console.log(chalk.green(`Retrying (${++retryCount} / ${totalRetries })`));
|
|
65
|
-
} else {
|
|
66
|
-
if (totalRetries < 1) {
|
|
67
|
-
console.log(chalk.magentaBright(`Build fails! If the error looks transient, I suggest setting the environment variable 'BUILD_RETRIES' to some number > 0 🔨.`));
|
|
68
|
-
}
|
|
69
|
-
throw e;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
52
|
+
return tryDo(
|
|
53
|
+
build,
|
|
54
|
+
env.resolveNumber("BUILD_RETRIES"),
|
|
55
|
+
e => console.error(chalk.red(`Build fails: ${e}`)),
|
|
56
|
+
() => console.log(chalk.magentaBright(`Build fails! If the error looks transient, I suggest setting the environment variable 'BUILD_RETRIES' to some number > 0 🔨.`))
|
|
57
|
+
);
|
|
73
58
|
}
|
|
74
59
|
|
|
75
60
|
async function build() {
|
|
@@ -100,11 +85,6 @@ function buildForNetCore(solutions) {
|
|
|
100
85
|
}
|
|
101
86
|
return promisifyStream(
|
|
102
87
|
solutions
|
|
103
|
-
.pipe(
|
|
104
|
-
dotnetClean({
|
|
105
|
-
configuration
|
|
106
|
-
})
|
|
107
|
-
)
|
|
108
88
|
.pipe(
|
|
109
89
|
dotnetBuild({
|
|
110
90
|
verbosity: env.resolve("BUILD_VERBOSITY"),
|
|
@@ -139,11 +119,18 @@ function buildAsStream(solutions) {
|
|
|
139
119
|
nologo: false,
|
|
140
120
|
logCommand: true,
|
|
141
121
|
nodeReuse: env.resolveFlag("BUILD_MSBUILD_NODE_REUSE"),
|
|
142
|
-
maxcpucount: env.resolveNumber("BUILD_MAX_CPU_COUNT")
|
|
122
|
+
maxcpucount: env.resolveNumber("BUILD_MAX_CPU_COUNT"),
|
|
143
123
|
};
|
|
144
124
|
|
|
145
125
|
if (env.resolveFlag("BUILD_SHOW_INFO")) {
|
|
146
|
-
|
|
126
|
+
const
|
|
127
|
+
buildRetries = env.resolveNumber("BUILD_RETRIES"),
|
|
128
|
+
retryMessage = buildRetries > 0 ? `yes (${buildRetries})` : `no`;
|
|
129
|
+
|
|
130
|
+
logConfig({
|
|
131
|
+
...config,
|
|
132
|
+
buildRetries: retryMessage
|
|
133
|
+
}, {
|
|
147
134
|
toolsVersion: "Tools version",
|
|
148
135
|
targets: "Build targets",
|
|
149
136
|
configuration: "Build configuration",
|
|
@@ -154,6 +141,7 @@ function buildAsStream(solutions) {
|
|
|
154
141
|
architecture: "Build architecture",
|
|
155
142
|
nodeReuse: "Re-use MSBUILD nodes",
|
|
156
143
|
maxcpucount: "Max CPUs to use for build",
|
|
144
|
+
buildRetries: "Retry builds"
|
|
157
145
|
});
|
|
158
146
|
}
|
|
159
147
|
return solutions
|
package/gulp-tasks/clean.js
CHANGED
|
@@ -1,37 +1,55 @@
|
|
|
1
|
-
const
|
|
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
|
-
|
|
1
|
+
const
|
|
2
|
+
gulp = requireModule("gulp"),
|
|
3
|
+
promisifyStream = requireModule("promisify-stream"),
|
|
4
|
+
tryDo = requireModule("try-do"),
|
|
5
|
+
msbuild = require("gulp-msbuild"),
|
|
6
|
+
env = requireModule("env");
|
|
7
|
+
const chalk = require("ansi-colors");
|
|
8
|
+
|
|
9
|
+
const myVars = [
|
|
10
|
+
"BUILD_TOOLSVERSION",
|
|
11
|
+
"BUILD_CONFIGURATION",
|
|
12
|
+
"BUILD_VERBOSITY",
|
|
13
|
+
"BUILD_MAX_CPU_COUNT",
|
|
14
|
+
"BUILD_FAIL_ON_ERROR",
|
|
15
|
+
"BUILD_PLATFORM",
|
|
16
|
+
"BUILD_ARCHITECTURE",
|
|
17
|
+
"BUILD_MSBUILD_NODE_REUSE",
|
|
18
|
+
"BUILD_RETRIES"
|
|
19
|
+
];
|
|
20
|
+
env.associate(myVars, "clean");
|
|
21
|
+
|
|
22
|
+
gulp.task(
|
|
23
|
+
"clean",
|
|
24
|
+
"Invokes the 'Clean' target on all solutions in the tree",
|
|
25
|
+
tryClean
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
function tryClean() {
|
|
29
|
+
tryDo(
|
|
30
|
+
clean,
|
|
31
|
+
env.resolveNumber("BUILD_RETRIES"),
|
|
32
|
+
e => console.error(chalk.red(`Clean fails: ${e}`))
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function clean() {
|
|
37
|
+
return promisifyStream(
|
|
38
|
+
gulp.src("**/*.sln")
|
|
39
|
+
.pipe(
|
|
40
|
+
msbuild({
|
|
41
|
+
toolsVersion: env.resolve("BUILD_TOOLSVERSION"),
|
|
42
|
+
targets: [ "Clean" ],
|
|
43
|
+
configuration: env.resolve("BUILD_CONFIGURATION"),
|
|
44
|
+
stdout: true,
|
|
45
|
+
logCommand: true,
|
|
46
|
+
errorOnFail: env.resolveFlag("BUILD_FAIL_ON_ERROR"),
|
|
47
|
+
solutionPlatform: env.resolve("BUILD_PLATFORM"),
|
|
48
|
+
architecture: env.resolve("BUILD_ARCHITECTURE"),
|
|
49
|
+
verbosity: env.resolve("BUILD_VERBOSITY"),
|
|
50
|
+
nodeReuse: env.resolveFlag("BUILD_MSBUILD_NODE_REUSE"),
|
|
51
|
+
maxcpucount: env.resolveNumber("BUILD_MAX_CPU_COUNT")
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -187,7 +187,7 @@ module.exports = function _env(env) {
|
|
|
187
187
|
env.register({
|
|
188
188
|
name: "BUILD_TARGETS",
|
|
189
189
|
help: "Targets to invoke msbuild with",
|
|
190
|
-
default: "
|
|
190
|
+
default: "Build"
|
|
191
191
|
});
|
|
192
192
|
|
|
193
193
|
env.register({
|
|
@@ -525,7 +525,7 @@ module.exports = function _env(env) {
|
|
|
525
525
|
env.register({
|
|
526
526
|
name: "BUILD_RETRIES",
|
|
527
527
|
help: "Retry the build again up to this many times on failure (work around transient errors on build host)",
|
|
528
|
-
default: "
|
|
528
|
+
default: "0"
|
|
529
529
|
});
|
|
530
530
|
|
|
531
531
|
debug("-- env registration complete --");
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(function () {
|
|
3
|
+
const env = requireModule("env"), chalk = require("ansi-colors");
|
|
4
|
+
async function tryDo(logic, retries, onTransientError, onFinalFailure) {
|
|
5
|
+
// always attempt at least once
|
|
6
|
+
const requestedRetries = typeof retries === "string"
|
|
7
|
+
? env.resolveNumber(retries)
|
|
8
|
+
: retries;
|
|
9
|
+
let totalAttempts = requestedRetries + 1;
|
|
10
|
+
if (totalAttempts < 0) {
|
|
11
|
+
totalAttempts = 1;
|
|
12
|
+
}
|
|
13
|
+
let retryCount = 0;
|
|
14
|
+
while (totalAttempts-- > 0) {
|
|
15
|
+
try {
|
|
16
|
+
await logic();
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
if (totalAttempts > 0) {
|
|
20
|
+
if (onTransientError) {
|
|
21
|
+
onTransientError(e);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
console.log(chalk.red(`Error: ${e.message || e.toString()}`));
|
|
25
|
+
}
|
|
26
|
+
console.log(chalk.green(`Retrying (${++retryCount} / ${retries})`));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (retries < 1) {
|
|
30
|
+
if (onFinalFailure) {
|
|
31
|
+
await onFinalFailure();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log(chalk.magentaBright(`Failed after ${totalAttempts} attempts`));
|
|
35
|
+
if (typeof retries === "string") {
|
|
36
|
+
if (process.env[retries] === undefined) {
|
|
37
|
+
console.info(chalk.yellow(`If the error looks transient, try setting the '${retries}' environment variable.`));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.info(chalk.yellow(`If the error looks transient, try setting the '${retries}' environment variable to a larger value (currently: ${process.env[retries]})`));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
module.exports = tryDo;
|
|
51
|
+
})();
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const
|
|
3
|
+
env = requireModule<Env>("env"),
|
|
4
|
+
chalk = require("ansi-colors");
|
|
5
|
+
|
|
6
|
+
async function tryDo(
|
|
7
|
+
logic: AsyncVoidVoid,
|
|
8
|
+
retries: number | string,
|
|
9
|
+
onTransientError: ErrorReporter,
|
|
10
|
+
onFinalFailure: VoidVoid
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
// always attempt at least once
|
|
13
|
+
const requestedRetries = typeof retries === "string"
|
|
14
|
+
? env.resolveNumber(retries)
|
|
15
|
+
: retries;
|
|
16
|
+
let totalAttempts = requestedRetries + 1;
|
|
17
|
+
if (totalAttempts < 0) {
|
|
18
|
+
totalAttempts = 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let retryCount = 0;
|
|
22
|
+
|
|
23
|
+
while (totalAttempts-- > 0) {
|
|
24
|
+
try {
|
|
25
|
+
await logic();
|
|
26
|
+
} catch (e) {
|
|
27
|
+
if (totalAttempts > 0) {
|
|
28
|
+
if (onTransientError) {
|
|
29
|
+
onTransientError(e)
|
|
30
|
+
} else {
|
|
31
|
+
console.log(chalk.red(`Error: ${ e.message || e.toString() }`));
|
|
32
|
+
}
|
|
33
|
+
console.log(chalk.green(`Retrying (${ ++retryCount } / ${ retries })`));
|
|
34
|
+
} else {
|
|
35
|
+
if (retries < 1) {
|
|
36
|
+
if (onFinalFailure) {
|
|
37
|
+
await onFinalFailure()
|
|
38
|
+
} else {
|
|
39
|
+
console.log(chalk.magentaBright(`Failed after ${ totalAttempts } attempts`));
|
|
40
|
+
if (typeof retries === "string") {
|
|
41
|
+
if (process.env[retries] === undefined) {
|
|
42
|
+
console.info(chalk.yellow(`If the error looks transient, try setting the '${retries}' environment variable.`));
|
|
43
|
+
} else {
|
|
44
|
+
console.info(chalk.yellow(`If the error looks transient, try setting the '${retries}' environment variable to a larger value (currently: ${process.env[retries]})`));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
throw e;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = tryDo;
|
|
56
|
+
})();
|