@itwin/build-tools 4.0.0-dev.7 → 4.0.0-dev.72
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/CHANGELOG.md +45 -1
- package/mocha-reporter/index.js +96 -97
- package/package.json +8 -8
- package/scripts/docs.js +4 -3
- package/scripts/utils/addPackageMetadata.js +50 -0
- package/tsconfig-base.json +2 -2
- package/scripts/utils/addSourceDir.js +0 -39
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,50 @@
|
|
1
1
|
# Change Log - @itwin/build-tools
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Wed, 12 Apr 2023 13:12:42 GMT and should not be manually modified.
|
4
|
+
|
5
|
+
## 3.7.2
|
6
|
+
Wed, 12 Apr 2023 13:12:42 GMT
|
7
|
+
|
8
|
+
_Version update only_
|
9
|
+
|
10
|
+
## 3.7.1
|
11
|
+
Mon, 03 Apr 2023 15:15:36 GMT
|
12
|
+
|
13
|
+
_Version update only_
|
14
|
+
|
15
|
+
## 3.7.0
|
16
|
+
Wed, 29 Mar 2023 15:02:27 GMT
|
17
|
+
|
18
|
+
_Version update only_
|
19
|
+
|
20
|
+
## 3.6.3
|
21
|
+
Mon, 27 Mar 2023 16:26:47 GMT
|
22
|
+
|
23
|
+
_Version update only_
|
24
|
+
|
25
|
+
## 3.6.2
|
26
|
+
Fri, 17 Mar 2023 17:52:32 GMT
|
27
|
+
|
28
|
+
_Version update only_
|
29
|
+
|
30
|
+
## 3.6.1
|
31
|
+
Fri, 24 Feb 2023 22:00:48 GMT
|
32
|
+
|
33
|
+
_Version update only_
|
34
|
+
|
35
|
+
## 3.6.0
|
36
|
+
Wed, 08 Feb 2023 14:58:39 GMT
|
37
|
+
|
38
|
+
### Updates
|
39
|
+
|
40
|
+
- Fix script paths for situation when repository path has spaces
|
41
|
+
- add copy-assets script to betools command
|
42
|
+
- Added ability to override default exclude pattern for tests when generating docs
|
43
|
+
|
44
|
+
## 3.5.6
|
45
|
+
Fri, 24 Feb 2023 16:02:47 GMT
|
46
|
+
|
47
|
+
_Version update only_
|
4
48
|
|
5
49
|
## 3.5.5
|
6
50
|
Thu, 26 Jan 2023 22:53:27 GMT
|
package/mocha-reporter/index.js
CHANGED
@@ -1,97 +1,96 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
*
|
6
|
-
|
7
|
-
|
8
|
-
/* eslint-disable @typescript-eslint/
|
9
|
-
/* eslint-disable
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
const
|
15
|
-
const
|
16
|
-
const
|
17
|
-
const
|
18
|
-
const
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
//
|
28
|
-
|
29
|
-
if (
|
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
|
-
wtf.
|
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
|
-
module.exports = BentleyMochaReporter;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
4
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
5
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
7
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
8
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
9
|
+
/* eslint-disable no-console */
|
10
|
+
const debugLeaks = process.env.DEBUG_LEAKS;
|
11
|
+
if (debugLeaks)
|
12
|
+
require("wtfnode");
|
13
|
+
const path = require("path");
|
14
|
+
const fs = require("fs-extra");
|
15
|
+
const { logBuildWarning, logBuildError, failBuild } = require("../scripts/utils/utils");
|
16
|
+
const Base = require("mocha/lib/reporters/base");
|
17
|
+
const Spec = require("mocha/lib/reporters/spec");
|
18
|
+
const MochaJUnitReporter = require("mocha-junit-reporter");
|
19
|
+
function withStdErr(callback) {
|
20
|
+
const originalConsoleLog = Base.consoleLog;
|
21
|
+
Base.consoleLog = console.error;
|
22
|
+
callback();
|
23
|
+
Base.consoleLog = originalConsoleLog;
|
24
|
+
}
|
25
|
+
const isCI = process.env.CI || process.env.TF_BUILD;
|
26
|
+
// Force rush test to fail CI builds if describe.only or it.only is used.
|
27
|
+
// These should only be used for debugging and must not be committed, otherwise we may be accidentally skipping lots of tests.
|
28
|
+
if (isCI) {
|
29
|
+
if (typeof (mocha) !== "undefined")
|
30
|
+
mocha.forbidOnly();
|
31
|
+
else
|
32
|
+
require.cache[require.resolve("mocha/lib/mocharc.json", { paths: require.main?.paths ?? module.paths })].exports.forbidOnly = true;
|
33
|
+
}
|
34
|
+
// This is necessary to enable colored output when running in rush test:
|
35
|
+
Object.defineProperty(Base, "color", {
|
36
|
+
get: () => process.env.FORCE_COLOR !== "false" && process.env.FORCE_COLOR !== "0",
|
37
|
+
set: () => { },
|
38
|
+
});
|
39
|
+
class BentleyMochaReporter extends Spec {
|
40
|
+
constructor(_runner, _options) {
|
41
|
+
super(...arguments);
|
42
|
+
this._junitReporter = new MochaJUnitReporter(...arguments);
|
43
|
+
}
|
44
|
+
epilogue(...args) {
|
45
|
+
// Force test errors to be printed to stderr instead of stdout.
|
46
|
+
// This will allow rush to correctly summarize test failure when running rush test.
|
47
|
+
if (this.stats.failures) {
|
48
|
+
withStdErr(() => super.epilogue(...args));
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
super.epilogue(...args);
|
52
|
+
if (0 === this.stats.passes) {
|
53
|
+
logBuildError("There were 0 passing tests. That doesn't seem right."
|
54
|
+
+ "\nIf there are really no passing tests and no failures, then what was even the point?"
|
55
|
+
+ "\nIt seems likely that tests were skipped by it.only, it.skip, or grep filters, so I'm going to fail now.");
|
56
|
+
failBuild();
|
57
|
+
}
|
58
|
+
}
|
59
|
+
// Detect hangs caused by tests that leave timers/other handles open - not possible in electron frontends.
|
60
|
+
if (!("electron" in process.versions)) {
|
61
|
+
// 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
|
62
|
+
// 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.
|
63
|
+
setTimeout(() => {
|
64
|
+
logBuildError(`Handle leak detected. Node was still running 5 seconds after tests completed.`);
|
65
|
+
if (debugLeaks) {
|
66
|
+
const wtf = require("wtfnode");
|
67
|
+
wtf.setLogger("info", console.error);
|
68
|
+
wtf.dump();
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
console.error("Try running with the DEBUG_LEAKS env var set to see open handles.");
|
72
|
+
}
|
73
|
+
// Not sure why, but process.exit(1) wasn't working here...
|
74
|
+
process.kill(process.pid);
|
75
|
+
}, 5000).unref();
|
76
|
+
}
|
77
|
+
if (!this.stats.pending)
|
78
|
+
return;
|
79
|
+
// Also log warnings in CI builds when tests have been skipped.
|
80
|
+
const currentPkgJson = path.join(process.cwd(), "package.json");
|
81
|
+
if (fs.existsSync(currentPkgJson)) {
|
82
|
+
const currentPackage = require(currentPkgJson).name;
|
83
|
+
if (this.stats.pending === 1)
|
84
|
+
logBuildWarning(`1 test skipped in ${currentPackage}`);
|
85
|
+
else
|
86
|
+
logBuildWarning(`${this.stats.pending} tests skipped in ${currentPackage}`);
|
87
|
+
}
|
88
|
+
else {
|
89
|
+
if (this.stats.pending === 1)
|
90
|
+
logBuildWarning(`1 test skipped`);
|
91
|
+
else
|
92
|
+
logBuildWarning(`${this.stats.pending} tests skipped`);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
module.exports = BentleyMochaReporter;
|
package/package.json
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@itwin/build-tools",
|
3
|
-
"version": "4.0.0-dev.
|
3
|
+
"version": "4.0.0-dev.72",
|
4
4
|
"description": "Bentley build tools",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
7
7
|
"type": "git",
|
8
|
-
"url": "https://github.com/iTwin/itwinjs-core
|
8
|
+
"url": "https://github.com/iTwin/itwinjs-core.git",
|
9
|
+
"directory": "tools/build"
|
9
10
|
},
|
10
11
|
"bin": {
|
11
12
|
"betools": "bin/betools.js"
|
@@ -20,7 +21,7 @@
|
|
20
21
|
"url": "http://www.bentley.com"
|
21
22
|
},
|
22
23
|
"dependencies": {
|
23
|
-
"@microsoft/api-extractor": "7.
|
24
|
+
"@microsoft/api-extractor": "7.34.4",
|
24
25
|
"chalk": "^3.0.0",
|
25
26
|
"cpx2": "^3.0.0",
|
26
27
|
"cross-spawn": "^7.0.1",
|
@@ -32,14 +33,14 @@
|
|
32
33
|
"tree-kill": "^1.2.0",
|
33
34
|
"typedoc": "^0.22.11",
|
34
35
|
"typedoc-plugin-merge-modules": "^3.0.2",
|
35
|
-
"typescript": "~
|
36
|
+
"typescript": "~5.0.2",
|
36
37
|
"wtfnode": "^0.9.1",
|
37
38
|
"yargs": "^17.4.0"
|
38
39
|
},
|
39
40
|
"devDependencies": {
|
40
|
-
"@itwin/eslint-plugin": "4.0.0-dev.
|
41
|
-
"@types/node": "18.11.5",
|
42
|
-
"eslint": "^
|
41
|
+
"@itwin/eslint-plugin": "^4.0.0-dev.33",
|
42
|
+
"@types/node": "^18.11.5",
|
43
|
+
"eslint": "^8.36.0"
|
43
44
|
},
|
44
45
|
"eslintConfig": {
|
45
46
|
"plugins": [
|
@@ -52,7 +53,6 @@
|
|
52
53
|
},
|
53
54
|
"scripts": {
|
54
55
|
"build": "tsc 1>&2",
|
55
|
-
"build:ci": "npm run -s build",
|
56
56
|
"clean": "rimraf ../../modules .rush/temp/package-deps*.json",
|
57
57
|
"docs": "",
|
58
58
|
"lint": "eslint -f visualstudio --config package.json --no-eslintrc \"./src/**/*.ts\" 1>&2",
|
package/scripts/docs.js
CHANGED
@@ -12,7 +12,7 @@ const cpx = require("cpx2");
|
|
12
12
|
const fs = require("fs");
|
13
13
|
const { spawn, handleInterrupts } = require("./utils/simpleSpawn");
|
14
14
|
const { validateTags } = require("./utils/validateTags");
|
15
|
-
const {
|
15
|
+
const { addPackageMetadata } = require("./utils/addPackageMetadata");
|
16
16
|
const argv = require("yargs").argv;
|
17
17
|
|
18
18
|
// Makes the script crash on unhandled rejections instead of silently
|
@@ -85,13 +85,14 @@ spawn(require.resolve(".bin/typedoc"), args).then((code) => {
|
|
85
85
|
cpx.copySync(path.join(source, argv.tsIndexFile), outputDir);
|
86
86
|
fs.renameSync(path.join(outputDir, argv.tsIndexFile), path.join(outputDir, 'index.ts'));
|
87
87
|
}
|
88
|
+
|
88
89
|
// Copy CHANGELOG.json to json output folder
|
89
90
|
if (fs.existsSync(path.join(process.cwd(), 'CHANGELOG.json'))) {
|
90
91
|
cpx.copySync(path.join(process.cwd(), 'CHANGELOG.json'), outputDir);
|
91
92
|
}
|
92
93
|
|
93
|
-
// Append the directory of the package to the output
|
94
|
-
|
94
|
+
// Append the directory of the package, version and repository URL to the output
|
95
|
+
addPackageMetadata(json, process.cwd());
|
95
96
|
|
96
97
|
if (code === 0) {
|
97
98
|
let tagErrors = validateTags(json);
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
5
|
+
|
6
|
+
const FS = require("fs-extra");
|
7
|
+
const path = require("path");
|
8
|
+
|
9
|
+
// We cannot guarantee the folder structure of a project
|
10
|
+
// so find the project root using rush env variable if available.
|
11
|
+
const rootPackageJson = process.env.RUSHSTACK_FILE_ERROR_BASE_FOLDER
|
12
|
+
? path.join(process.env.RUSHSTACK_FILE_ERROR_BASE_FOLDER, "package.json")
|
13
|
+
: "../../../../package.json";
|
14
|
+
|
15
|
+
// Check if path to root package.json is valid.
|
16
|
+
const rootPackageJsonPath = require.resolve(rootPackageJson);
|
17
|
+
|
18
|
+
//Find the package.json of the project and retrieve the version and repository URL
|
19
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
20
|
+
const packageJson = JSON.parse(FS.readFileSync(packageJsonPath));
|
21
|
+
const version = packageJson.version;
|
22
|
+
const repositoryUrl = packageJson.repository?.url;
|
23
|
+
const repositoryDirectory = packageJson.repository?.directory;
|
24
|
+
|
25
|
+
if (!version || !repositoryUrl || !repositoryDirectory) {
|
26
|
+
throw new Error("version or repository info not found in package.json");
|
27
|
+
}
|
28
|
+
|
29
|
+
// Appends the directory of the package root to the Typedoc JSON output
|
30
|
+
function addPackageMetadata(file, directory) {
|
31
|
+
if (FS.existsSync(file) && FS.statSync(file).isFile()) {
|
32
|
+
const contents = FS.readFileSync(file, "utf-8");
|
33
|
+
const pathToRootFolder = path.dirname(rootPackageJsonPath);
|
34
|
+
const packageRoot = directory.substring(pathToRootFolder.length + 1);
|
35
|
+
const jsonContents = JSON.parse(contents);
|
36
|
+
|
37
|
+
jsonContents["packageRoot"] = packageRoot.endsWith("src")
|
38
|
+
? packageRoot
|
39
|
+
: `${packageRoot}\\${"src"}`;
|
40
|
+
jsonContents["version"] = version;
|
41
|
+
jsonContents["repositoryUrl"] = repositoryUrl;
|
42
|
+
jsonContents["repositoryDirectory"] = repositoryDirectory;
|
43
|
+
|
44
|
+
FS.writeFileSync(file, Buffer.from(JSON.stringify(jsonContents, null, 2)));
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
module.exports = {
|
49
|
+
addPackageMetadata,
|
50
|
+
};
|
package/tsconfig-base.json
CHANGED
@@ -1,39 +0,0 @@
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
5
|
-
|
6
|
-
const FS = require("fs-extra");
|
7
|
-
const path = require("path");
|
8
|
-
|
9
|
-
// We cannot guarantee the folder structure of a project
|
10
|
-
// so find the project root using rush env variable if available.
|
11
|
-
if (process.env.RUSHSTACK_FILE_ERROR_BASE_FOLDER) {
|
12
|
-
rootPackageJsonPath = path.resolve(
|
13
|
-
process.env.RUSHSTACK_FILE_ERROR_BASE_FOLDER,
|
14
|
-
"package.json"
|
15
|
-
);
|
16
|
-
} else {
|
17
|
-
rootPackageJsonPath = path.resolve("../../../../package.json");
|
18
|
-
}
|
19
|
-
|
20
|
-
const rootPackageJson = require(rootPackageJsonPath);
|
21
|
-
|
22
|
-
// Appends the directory of the package root to the Typedoc JSON output
|
23
|
-
function addSourceDir(file, directory) {
|
24
|
-
if (FS.existsSync(file) && FS.statSync(file).isFile()) {
|
25
|
-
const contents = FS.readFileSync(file, "utf-8");
|
26
|
-
const packageRoot = directory.substring(
|
27
|
-
directory.indexOf(rootPackageJson.name) + rootPackageJson.name.length + 1
|
28
|
-
);
|
29
|
-
const jsonContents = JSON.parse(contents);
|
30
|
-
jsonContents["packageRoot"] = packageRoot.endsWith("src")
|
31
|
-
? packageRoot
|
32
|
-
: `${packageRoot}\\${"src"}`;
|
33
|
-
FS.writeFileSync(file, Buffer.from(JSON.stringify(jsonContents, null, 2)));
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
module.exports = {
|
38
|
-
addSourceDir,
|
39
|
-
};
|