@itwin/build-tools 3.6.0-dev.34 → 3.6.0-dev.36
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/LICENSE.md +1 -1
- package/bin/betools.js +8 -4
- package/mocha-reporter/index.js +97 -97
- package/package.json +2 -2
package/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MIT License
|
2
2
|
|
3
|
-
Copyright © 2017-
|
3
|
+
Copyright © 2017-2023 Bentley Systems, Incorporated. All rights reserved.
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
6
|
|
package/bin/betools.js
CHANGED
@@ -100,6 +100,10 @@ function testCommand(options) {
|
|
100
100
|
process.exit(1);
|
101
101
|
}
|
102
102
|
|
103
|
+
function getScriptPath(name) {
|
104
|
+
return `"${path.resolve(__dirname, path.join("..", "scripts", name))}"`;
|
105
|
+
}
|
106
|
+
|
103
107
|
function docsCommand(options) {
|
104
108
|
const sourceOpt = options.source ? ["--source", options.source] : [];
|
105
109
|
const outOpt = options.out ? ["--out", options.out] : [];
|
@@ -110,7 +114,7 @@ function docsCommand(options) {
|
|
110
114
|
const excludesGlobOpt = options.excludeGlob ? ["--excludeGlob", options.excludeGlob] : [];
|
111
115
|
const indexFileOpt = options.tsIndexFile ? ["--tsIndexFile", options.tsIndexFile] : [];
|
112
116
|
const onlyJsonOpt = options.onlyJson ? ["--onlyJson"] : [];
|
113
|
-
exec(["node",
|
117
|
+
exec(["node", getScriptPath("docs.js"),
|
114
118
|
...sourceOpt, ...outOpt, ...jsonOpt, ...baseUrlOpt, ...includesOpt,
|
115
119
|
...excludesOpt, ...excludesGlobOpt, ...indexFileOpt, ...onlyJsonOpt]);
|
116
120
|
}
|
@@ -120,19 +124,19 @@ function extractCommand(options) {
|
|
120
124
|
const outOpt = options.out ? ["--out", options.out] : [];
|
121
125
|
const fileExt = options.fileExt ? ["--fileExt", options.fileExt] : [];
|
122
126
|
const recursive = options.recursive ? ["--recursive"] : [];
|
123
|
-
exec(["node",
|
127
|
+
exec(["node", getScriptPath("extract.js"), ...extractOpt, ...outOpt, ...fileExt, ...recursive]);
|
124
128
|
}
|
125
129
|
|
126
130
|
function extractApiCommand(options) {
|
127
131
|
const entryOpt = options.entry ? ["--entry", options.entry] : [];
|
128
132
|
const ignoreTagsOpt = options.ignoreMissingTags ? ["--ignoreMissingTags"] : [];
|
129
|
-
exec(["node",
|
133
|
+
exec(["node", getScriptPath("extract-api.js"), ...entryOpt, ...ignoreTagsOpt]);
|
130
134
|
}
|
131
135
|
|
132
136
|
function pseudolocalizeCommand(options) {
|
133
137
|
const englishDir = options.englishDir ? ["--englishDir", options.englishDir] : [];
|
134
138
|
const outOpt = options.out ? ["--out", options.out] : [];
|
135
|
-
exec(["node",
|
139
|
+
exec(["node", getScriptPath("pseudolocalize"), ...englishDir, ...outOpt]);
|
136
140
|
}
|
137
141
|
|
138
142
|
function exec(cmd) {
|
package/mocha-reporter/index.js
CHANGED
@@ -1,97 +1,97 @@
|
|
1
|
-
"use strict";
|
2
|
-
var _a, _b;
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
/*---------------------------------------------------------------------------------------------
|
5
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
6
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
7
|
-
*--------------------------------------------------------------------------------------------*/
|
8
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
9
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
10
|
-
/* eslint-disable no-console */
|
11
|
-
const debugLeaks = process.env.DEBUG_LEAKS;
|
12
|
-
if (debugLeaks)
|
13
|
-
require("wtfnode");
|
14
|
-
const path = require("path");
|
15
|
-
const fs = require("fs-extra");
|
16
|
-
const { logBuildWarning, logBuildError, failBuild } = require("../scripts/utils/utils");
|
17
|
-
const Base = require("mocha/lib/reporters/base");
|
18
|
-
const Spec = require("mocha/lib/reporters/spec");
|
19
|
-
const MochaJUnitReporter = require("mocha-junit-reporter");
|
20
|
-
function withStdErr(callback) {
|
21
|
-
const originalConsoleLog = Base.consoleLog;
|
22
|
-
Base.consoleLog = console.error;
|
23
|
-
callback();
|
24
|
-
Base.consoleLog = originalConsoleLog;
|
25
|
-
}
|
26
|
-
const isCI = process.env.CI || process.env.TF_BUILD;
|
27
|
-
// Force rush test to fail CI builds if describe.only or it.only is used.
|
28
|
-
// These should only be used for debugging and must not be committed, otherwise we may be accidentally skipping lots of tests.
|
29
|
-
if (isCI) {
|
30
|
-
if (typeof (mocha) !== "undefined")
|
31
|
-
mocha.forbidOnly();
|
32
|
-
else
|
33
|
-
require.cache[require.resolve("mocha/lib/mocharc.json", { paths: (_b = (_a = require.main) === null || _a === void 0 ? void 0 : _a.paths) !== null && _b !== void 0 ? _b : module.paths })].exports.forbidOnly = true;
|
34
|
-
}
|
35
|
-
// This is necessary to enable colored output when running in rush test:
|
36
|
-
Object.defineProperty(Base, "color", {
|
37
|
-
get: () => process.env.FORCE_COLOR !== "false" && process.env.FORCE_COLOR !== "0",
|
38
|
-
set: () => { },
|
39
|
-
});
|
40
|
-
class BentleyMochaReporter extends Spec {
|
41
|
-
constructor(_runner, _options) {
|
42
|
-
super(...arguments);
|
43
|
-
this._junitReporter = new MochaJUnitReporter(...arguments);
|
44
|
-
}
|
45
|
-
epilogue(...args) {
|
46
|
-
// Force test errors to be printed to stderr instead of stdout.
|
47
|
-
// This will allow rush to correctly summarize test failure when running rush test.
|
48
|
-
if (this.stats.failures) {
|
49
|
-
withStdErr(() => super.epilogue(...args));
|
50
|
-
}
|
51
|
-
else {
|
52
|
-
super.epilogue(...args);
|
53
|
-
if (0 === this.stats.passes) {
|
54
|
-
logBuildError("There were 0 passing tests. That doesn't seem right."
|
55
|
-
+ "\nIf there are really no passing tests and no failures, then what was even the point?"
|
56
|
-
+ "\nIt seems likely that tests were skipped by it.only, it.skip, or grep filters, so I'm going to fail now.");
|
57
|
-
failBuild();
|
58
|
-
}
|
59
|
-
}
|
60
|
-
// Detect hangs caused by tests that leave timers/other handles open - not possible in electron frontends.
|
61
|
-
if (!("electron" in process.versions)) {
|
62
|
-
// NB: By calling unref() on this timer, we stop it from keeping the process alive, so it will only fire if _something else_ is still keeping
|
63
|
-
// the process alive after 5 seconds. This also has the benefit of preventing the timer from showing up in wtfnode's dump of open handles.
|
64
|
-
setTimeout(() => {
|
65
|
-
logBuildError(`Handle leak detected. Node was still running 5 seconds after tests completed.`);
|
66
|
-
if (debugLeaks) {
|
67
|
-
const wtf = require("wtfnode");
|
68
|
-
wtf.setLogger("info", console.error);
|
69
|
-
wtf.dump();
|
70
|
-
}
|
71
|
-
else {
|
72
|
-
console.error("Try running with the DEBUG_LEAKS env var set to see open handles.");
|
73
|
-
}
|
74
|
-
// Not sure why, but process.exit(1) wasn't working here...
|
75
|
-
process.kill(process.pid);
|
76
|
-
}, 5000).unref();
|
77
|
-
}
|
78
|
-
if (!this.stats.pending)
|
79
|
-
return;
|
80
|
-
// Also log warnings in CI builds when tests have been skipped.
|
81
|
-
const currentPkgJson = path.join(process.cwd(), "package.json");
|
82
|
-
if (fs.existsSync(currentPkgJson)) {
|
83
|
-
const currentPackage = require(currentPkgJson).name;
|
84
|
-
if (this.stats.pending === 1)
|
85
|
-
logBuildWarning(`1 test skipped in ${currentPackage}`);
|
86
|
-
else
|
87
|
-
logBuildWarning(`${this.stats.pending} tests skipped in ${currentPackage}`);
|
88
|
-
}
|
89
|
-
else {
|
90
|
-
if (this.stats.pending === 1)
|
91
|
-
logBuildWarning(`1 test skipped`);
|
92
|
-
else
|
93
|
-
logBuildWarning(`${this.stats.pending} tests skipped`);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}
|
97
|
-
module.exports = BentleyMochaReporter;
|
1
|
+
"use strict";
|
2
|
+
var _a, _b;
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
8
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
9
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
10
|
+
/* eslint-disable no-console */
|
11
|
+
const debugLeaks = process.env.DEBUG_LEAKS;
|
12
|
+
if (debugLeaks)
|
13
|
+
require("wtfnode");
|
14
|
+
const path = require("path");
|
15
|
+
const fs = require("fs-extra");
|
16
|
+
const { logBuildWarning, logBuildError, failBuild } = require("../scripts/utils/utils");
|
17
|
+
const Base = require("mocha/lib/reporters/base");
|
18
|
+
const Spec = require("mocha/lib/reporters/spec");
|
19
|
+
const MochaJUnitReporter = require("mocha-junit-reporter");
|
20
|
+
function withStdErr(callback) {
|
21
|
+
const originalConsoleLog = Base.consoleLog;
|
22
|
+
Base.consoleLog = console.error;
|
23
|
+
callback();
|
24
|
+
Base.consoleLog = originalConsoleLog;
|
25
|
+
}
|
26
|
+
const isCI = process.env.CI || process.env.TF_BUILD;
|
27
|
+
// Force rush test to fail CI builds if describe.only or it.only is used.
|
28
|
+
// These should only be used for debugging and must not be committed, otherwise we may be accidentally skipping lots of tests.
|
29
|
+
if (isCI) {
|
30
|
+
if (typeof (mocha) !== "undefined")
|
31
|
+
mocha.forbidOnly();
|
32
|
+
else
|
33
|
+
require.cache[require.resolve("mocha/lib/mocharc.json", { paths: (_b = (_a = require.main) === null || _a === void 0 ? void 0 : _a.paths) !== null && _b !== void 0 ? _b : module.paths })].exports.forbidOnly = true;
|
34
|
+
}
|
35
|
+
// This is necessary to enable colored output when running in rush test:
|
36
|
+
Object.defineProperty(Base, "color", {
|
37
|
+
get: () => process.env.FORCE_COLOR !== "false" && process.env.FORCE_COLOR !== "0",
|
38
|
+
set: () => { },
|
39
|
+
});
|
40
|
+
class BentleyMochaReporter extends Spec {
|
41
|
+
constructor(_runner, _options) {
|
42
|
+
super(...arguments);
|
43
|
+
this._junitReporter = new MochaJUnitReporter(...arguments);
|
44
|
+
}
|
45
|
+
epilogue(...args) {
|
46
|
+
// Force test errors to be printed to stderr instead of stdout.
|
47
|
+
// This will allow rush to correctly summarize test failure when running rush test.
|
48
|
+
if (this.stats.failures) {
|
49
|
+
withStdErr(() => super.epilogue(...args));
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
super.epilogue(...args);
|
53
|
+
if (0 === this.stats.passes) {
|
54
|
+
logBuildError("There were 0 passing tests. That doesn't seem right."
|
55
|
+
+ "\nIf there are really no passing tests and no failures, then what was even the point?"
|
56
|
+
+ "\nIt seems likely that tests were skipped by it.only, it.skip, or grep filters, so I'm going to fail now.");
|
57
|
+
failBuild();
|
58
|
+
}
|
59
|
+
}
|
60
|
+
// Detect hangs caused by tests that leave timers/other handles open - not possible in electron frontends.
|
61
|
+
if (!("electron" in process.versions)) {
|
62
|
+
// NB: By calling unref() on this timer, we stop it from keeping the process alive, so it will only fire if _something else_ is still keeping
|
63
|
+
// the process alive after 5 seconds. This also has the benefit of preventing the timer from showing up in wtfnode's dump of open handles.
|
64
|
+
setTimeout(() => {
|
65
|
+
logBuildError(`Handle leak detected. Node was still running 5 seconds after tests completed.`);
|
66
|
+
if (debugLeaks) {
|
67
|
+
const wtf = require("wtfnode");
|
68
|
+
wtf.setLogger("info", console.error);
|
69
|
+
wtf.dump();
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
console.error("Try running with the DEBUG_LEAKS env var set to see open handles.");
|
73
|
+
}
|
74
|
+
// Not sure why, but process.exit(1) wasn't working here...
|
75
|
+
process.kill(process.pid);
|
76
|
+
}, 5000).unref();
|
77
|
+
}
|
78
|
+
if (!this.stats.pending)
|
79
|
+
return;
|
80
|
+
// Also log warnings in CI builds when tests have been skipped.
|
81
|
+
const currentPkgJson = path.join(process.cwd(), "package.json");
|
82
|
+
if (fs.existsSync(currentPkgJson)) {
|
83
|
+
const currentPackage = require(currentPkgJson).name;
|
84
|
+
if (this.stats.pending === 1)
|
85
|
+
logBuildWarning(`1 test skipped in ${currentPackage}`);
|
86
|
+
else
|
87
|
+
logBuildWarning(`${this.stats.pending} tests skipped in ${currentPackage}`);
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
if (this.stats.pending === 1)
|
91
|
+
logBuildWarning(`1 test skipped`);
|
92
|
+
else
|
93
|
+
logBuildWarning(`${this.stats.pending} tests skipped`);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
module.exports = BentleyMochaReporter;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@itwin/build-tools",
|
3
|
-
"version": "3.6.0-dev.
|
3
|
+
"version": "3.6.0-dev.36",
|
4
4
|
"description": "Bentley build tools",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"yargs": "^17.4.0"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
40
|
-
"@itwin/eslint-plugin": "3.6.0-dev.
|
40
|
+
"@itwin/eslint-plugin": "3.6.0-dev.36",
|
41
41
|
"@types/node": "18.11.5",
|
42
42
|
"eslint": "^7.11.0"
|
43
43
|
},
|