@itwin/build-tools 3.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/.nycrc +30 -0
- package/CHANGELOG.md +1026 -0
- package/LICENSE.md +9 -0
- package/README.md +59 -0
- package/ThirdPartyNotices.md +15 -0
- package/bin/betools.js +148 -0
- package/mocha-reporter/index.js +76 -0
- package/package.json +64 -0
- package/scripts/config/paths.js +27 -0
- package/scripts/docs.js +100 -0
- package/scripts/extract-api-summary.js +91 -0
- package/scripts/extract-api.js +134 -0
- package/scripts/extract.js +72 -0
- package/scripts/pseudolocalize.js +107 -0
- package/scripts/rush/audit.js +99 -0
- package/scripts/rush/utils.js +39 -0
- package/scripts/utils/simpleSpawn.js +86 -0
- package/scripts/utils/validateTags.js +120 -0
- package/tsconfig-base.json +35 -0
- package/tsconfig.json +19 -0
package/LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright © 2017-2021 Bentley Systems, Incorporated. All rights reserved.
|
4
|
+
|
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
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# @itwin/build-tools
|
2
|
+
|
3
|
+
Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
The **@itwin/build-tools** is a package for developers to consolidate the steps for building TypeScript-based packages. The tools contained in this package are written in either Typescript or Javascript within the src/ directory, and compiled for use into the lib/ directory. As a developer package, this package has only dependencies, no devDependencies.
|
8
|
+
|
9
|
+
### tsconfig-base
|
10
|
+
|
11
|
+
Location: tsconfig-base.json\
|
12
|
+
Requires build: no
|
13
|
+
|
14
|
+
This file contains common tsconfig settings across all iTwin.js packages. Packages should extend this file in their own tsconfig.json file, and then overwrite and set new properties as needed. Note that this file is different from the tsconfig.json file for this package, as that contains different settings for bentleyjs-tools only.
|
15
|
+
|
16
|
+
### NPM Scripts
|
17
|
+
|
18
|
+
Location: scripts/\
|
19
|
+
Requires build: no
|
20
|
+
|
21
|
+
The following node scripts are delivered in this package's scripts folder in order to ease development of iTwin.js packages with npm scripts. These scripts may require that additional packages be installed as dependencies of your package.
|
22
|
+
|
23
|
+
The default behaviors of the scripts (without parameters) assume that the directory structure of your package mirrors the following:
|
24
|
+
|
25
|
+
- root
|
26
|
+
- source
|
27
|
+
- test
|
28
|
+
- assets
|
29
|
+
- lib
|
30
|
+
- package.json
|
31
|
+
- tsconfig.json
|
32
|
+
|
33
|
+
The following is a list of some of the most commonly used scripts within this package:
|
34
|
+
|
35
|
+
#### docs.js
|
36
|
+
|
37
|
+
This script runs a TypeDoc command, with specific parameters, to generate html TypeScript documentation as well as a json representation of the documentation to be consumed for other purposes. It includes the following parameters:
|
38
|
+
|
39
|
+
- source - specify the TypeScript source directory
|
40
|
+
- out - specify the directory of the html output
|
41
|
+
- json - specify the directory and filename of the json output
|
42
|
+
- baseUrl - specify a baseUrl to resolve modules
|
43
|
+
- onlyJson - including this option will skip the html output and only output the json file
|
44
|
+
- includes - directory of files to include in documentation (ex: for sample code)
|
45
|
+
- excludes - name of directory, files, or file extensions to exclude.
|
46
|
+
- A list can be provided using a `,` as a separator
|
47
|
+
- Each of the provided to exclude is added to a glob pattern which checks all directories within the source.
|
48
|
+
- i.e `--excludes=test,docs/*.md` will translate to `**/{test,docs/*.md}/**/*`
|
49
|
+
|
50
|
+
#### extract.js
|
51
|
+
|
52
|
+
This is a script designed to extract sample code from test.ts files in a specific directory. The sample code should be surrounded by comments containing "\_\_PUBLISH_EXTRACT_START\_\_" and "\_\_PUBLISH_EXTRACT_END\_\_" directives.
|
53
|
+
|
54
|
+
- extractDir - the path at which the sample code files are located
|
55
|
+
- outDir - the path at which to output the selected code
|
56
|
+
|
57
|
+
#### pseudolocalize.js
|
58
|
+
|
59
|
+
This script handles translating an English localization JSON file into a pseudoLocalization file.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
# Third-Party Code
|
3
|
+
|
4
|
+
The iTwin.js library potentially incorporates work from the following third-party code:
|
5
|
+
|
6
|
+
## [tslint-react-set-state-usage](https://github.com/sutrkiller/tslint-react-set-state-usage)
|
7
|
+
|
8
|
+
The MIT License (MIT)
|
9
|
+
Copyright (c) 2017 Tobias Kamenicky
|
10
|
+
|
11
|
+
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:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/bin/betools.js
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
#! /usr/bin/env node
|
2
|
+
|
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
|
+
|
8
|
+
"use strict"
|
9
|
+
const yargs = require("yargs");
|
10
|
+
var path = require("path");
|
11
|
+
var child_process = require("child_process");
|
12
|
+
|
13
|
+
yargs.strict(true)
|
14
|
+
.wrap(Math.min(150, yargs.terminalWidth()))
|
15
|
+
.version("2.0.0")
|
16
|
+
.usage("Bentley Scripts Utility\n\n These scripts consist of several standard npm tasks an app may want to make use of.")
|
17
|
+
.command("test", false, {}, () => { testCommand() })
|
18
|
+
.command("test-tsnode", false, {}, () => { testCommand() })
|
19
|
+
.command("docs", "Generate TypeDoc documentation by using the provided parameters to pass to TypeDoc. Supports generating html TypeScript documentation as well as a json representation of the documentation.",
|
20
|
+
function (yargs) {
|
21
|
+
return yargs.options({
|
22
|
+
"source": {
|
23
|
+
describe: "Specify the TypeScript source directory"
|
24
|
+
},
|
25
|
+
"out": {
|
26
|
+
describe: "Specify the directory of the html output"
|
27
|
+
},
|
28
|
+
"json": {
|
29
|
+
describe: "Specify the directory and filename of the json output"
|
30
|
+
},
|
31
|
+
"baseUrl": {
|
32
|
+
describe: "Specify a baseUrl to resolve modules"
|
33
|
+
},
|
34
|
+
"includes": {
|
35
|
+
describe: "Specify a baseUrl to resolve modules"
|
36
|
+
},
|
37
|
+
"excludes": {
|
38
|
+
describe: "Specify a directory, filename, or pattern to be excluded"
|
39
|
+
},
|
40
|
+
"excludeGlob": {
|
41
|
+
describe: "Specify a directory, filename, or pattern to be excluded"
|
42
|
+
},
|
43
|
+
"tsIndexFile": {
|
44
|
+
describe: "The barrel file containing the module documentation. This file is copied to the output folder for parsing."
|
45
|
+
},
|
46
|
+
"onlyJson": {
|
47
|
+
describe: "Specify a baseUrl to resolve modules"
|
48
|
+
}
|
49
|
+
})
|
50
|
+
},
|
51
|
+
(argv) => { docsCommand(argv) })
|
52
|
+
.command("extract", "Extract sample code from test files in a specific directory",
|
53
|
+
function (yargs) {
|
54
|
+
return yargs.options({
|
55
|
+
"extractFrom": {
|
56
|
+
describe: "The path at which the sample code files are located"
|
57
|
+
},
|
58
|
+
"out": {
|
59
|
+
describe: "The path at which to output the selected code"
|
60
|
+
},
|
61
|
+
"fileExt": {
|
62
|
+
describe: "The extension of the files to include"
|
63
|
+
},
|
64
|
+
"recursive": {
|
65
|
+
alias: "r",
|
66
|
+
describe: "Recursively search subdirectories from"
|
67
|
+
}
|
68
|
+
})
|
69
|
+
},
|
70
|
+
(argv) => { extractCommand(argv) })
|
71
|
+
.command("extract-api", "Extracts the API of the Typescript library starting from an entry file with a default presets. Powered by @microsoft/api-extractor (https://api-extractor.com)",
|
72
|
+
function (yargs) {
|
73
|
+
return yargs.options({
|
74
|
+
"entry": {
|
75
|
+
describe: "The main Typescript entry point for the library which is compiled to the 'main' field in the package.json"
|
76
|
+
},
|
77
|
+
"ignoreMissingTags": {
|
78
|
+
describe: "Turns off the 'ae-missing-release-tag' option which returns an error when a missing release tag is detected"
|
79
|
+
}
|
80
|
+
})
|
81
|
+
},
|
82
|
+
(argv) => { extractApiCommand(argv) })
|
83
|
+
.command("pseudolocalize", "Pseudo-localizes an english localization JSON file.",
|
84
|
+
function (yargs) {
|
85
|
+
return yargs.options({
|
86
|
+
"englishDir": {
|
87
|
+
describe: "The path to the English localization folder. Default is `./public/locales/en`"
|
88
|
+
},
|
89
|
+
"out": {
|
90
|
+
describe: "The output path to put the pseudo-localized files. Default is `./public/locales/en-pseudo`"
|
91
|
+
}
|
92
|
+
})
|
93
|
+
},
|
94
|
+
(argv) => { pseudolocalizeCommand(argv) })
|
95
|
+
.help()
|
96
|
+
.argv;
|
97
|
+
|
98
|
+
function testCommand(options) {
|
99
|
+
console.error("ERROR: The test and test-tsnode commands have been removed from betools. Please use mocha directly instead.");
|
100
|
+
process.exit(1);
|
101
|
+
}
|
102
|
+
|
103
|
+
function docsCommand(options) {
|
104
|
+
const sourceOpt = options.source ? ["--source", options.source] : [];
|
105
|
+
const outOpt = options.out ? ["--out", options.out] : [];
|
106
|
+
const jsonOpt = options.json ? ["--json", options.json] : [];
|
107
|
+
const baseUrlOpt = options.baseUrl ? ["--baseUrl", options.baseUrl] : [];
|
108
|
+
const includesOpt = options.includes ? ["--includes", options.includes] : [];
|
109
|
+
const excludesOpt = options.excludes ? ["--excludes", options.excludes] : [];
|
110
|
+
const excludesGlobOpt = options.excludes ? ["--excludeGlob", options.excludeGlob] : [];
|
111
|
+
const indexFileOpt = options.tsIndexFile ? ["--tsIndexFile", options.tsIndexFile] : [];
|
112
|
+
const onlyJsonOpt = options.onlyJson ? ["--onlyJson"] : [];
|
113
|
+
exec(["node", path.resolve(__dirname, "../scripts/docs.js"),
|
114
|
+
...sourceOpt, ...outOpt, ...jsonOpt, ...baseUrlOpt, ...includesOpt,
|
115
|
+
...excludesOpt, ...excludesGlobOpt, ...indexFileOpt, ...onlyJsonOpt]);
|
116
|
+
}
|
117
|
+
|
118
|
+
function extractCommand(options) {
|
119
|
+
const extractOpt = options.extractFrom ? ["--extractFrom", options.extractFrom] : [];
|
120
|
+
const outOpt = options.out ? ["--out", options.out] : [];
|
121
|
+
const fileExt = options.fileExt ? ["--fileExt", options.fileExt] : [];
|
122
|
+
const recursive = options.recursive ? ["--recursive"] : [];
|
123
|
+
exec(["node", path.resolve(__dirname, "../scripts/extract.js"), ...extractOpt, ...outOpt, ...fileExt, ...recursive]);
|
124
|
+
}
|
125
|
+
|
126
|
+
function extractApiCommand(options) {
|
127
|
+
const entryOpt = options.entry ? ["--entry", options.entry] : [];
|
128
|
+
const ignoreTagsOpt = options.ignoreMissingTags ? ["--ignoreMissingTags"] : [];
|
129
|
+
exec(["node", path.resolve(__dirname, "../scripts/extract-api.js"), ...entryOpt, ...ignoreTagsOpt]);
|
130
|
+
}
|
131
|
+
|
132
|
+
function pseudolocalizeCommand(options) {
|
133
|
+
const englishDir = options.englishDir ? ["--englishDir", options.englishDir] : [];
|
134
|
+
const outOpt = options.out ? ["--out", options.out] : [];
|
135
|
+
exec(["node", path.resolve(__dirname, "../scripts/pseudolocalize"), ...englishDir, ...outOpt]);
|
136
|
+
}
|
137
|
+
|
138
|
+
function exec(cmd) {
|
139
|
+
console.log("Running command:");
|
140
|
+
console.log(cmd.join(" "));
|
141
|
+
try {
|
142
|
+
return child_process.execSync(cmd.join(" "), { encoding: "utf8", stdio: 'inherit' });
|
143
|
+
} catch (error) {
|
144
|
+
if (error.status)
|
145
|
+
process.exit(error.status);
|
146
|
+
throw error;
|
147
|
+
}
|
148
|
+
}
|
@@ -0,0 +1,76 @@
|
|
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 path = require("path");
|
12
|
+
const fs = require("fs-extra");
|
13
|
+
const { logBuildWarning, logBuildError, failBuild } = require("../scripts/rush/utils");
|
14
|
+
const Base = require("mocha/lib/reporters/base");
|
15
|
+
const Spec = require("mocha/lib/reporters/spec");
|
16
|
+
const MochaJUnitReporter = require("mocha-junit-reporter");
|
17
|
+
function withStdErr(callback) {
|
18
|
+
const originalConsoleLog = Base.consoleLog;
|
19
|
+
Base.consoleLog = console.error;
|
20
|
+
callback();
|
21
|
+
Base.consoleLog = originalConsoleLog;
|
22
|
+
}
|
23
|
+
const isCI = process.env.CI || process.env.TF_BUILD;
|
24
|
+
// Force rush test to fail CI builds if describe.only or it.only is used.
|
25
|
+
// These should only be used for debugging and must not be committed, otherwise we may be accidentally skipping lots of tests.
|
26
|
+
if (isCI) {
|
27
|
+
if (typeof (mocha) !== "undefined")
|
28
|
+
mocha.forbidOnly();
|
29
|
+
else
|
30
|
+
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;
|
31
|
+
}
|
32
|
+
// This is necessary to enable colored output when running in rush test:
|
33
|
+
Object.defineProperty(Base, "color", {
|
34
|
+
get: () => process.env.FORCE_COLOR !== "false" && process.env.FORCE_COLOR !== "0",
|
35
|
+
set: () => { },
|
36
|
+
});
|
37
|
+
class BentleyMochaReporter extends Spec {
|
38
|
+
constructor(_runner, _options) {
|
39
|
+
super(...arguments);
|
40
|
+
this._junitReporter = new MochaJUnitReporter(...arguments);
|
41
|
+
}
|
42
|
+
epilogue(...args) {
|
43
|
+
// Force test errors to be printed to stderr instead of stdout.
|
44
|
+
// This will allow rush to correctly summarize test failure when running rush test.
|
45
|
+
if (this.stats.failures) {
|
46
|
+
withStdErr(() => super.epilogue(...args));
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
super.epilogue(...args);
|
50
|
+
if (0 === this.stats.passes) {
|
51
|
+
logBuildError("There were 0 passing tests. That doesn't seem right."
|
52
|
+
+ "\nIf there are really no passing tests and no failures, then what was even the point?"
|
53
|
+
+ "\nIt seems likely that tests were skipped by it.only, it.skip, or grep filters, so I'm going to fail now.");
|
54
|
+
failBuild();
|
55
|
+
}
|
56
|
+
}
|
57
|
+
if (!this.stats.pending)
|
58
|
+
return;
|
59
|
+
// Also log warnings in CI builds when tests have been skipped.
|
60
|
+
const currentPkgJson = path.join(process.cwd(), "package.json");
|
61
|
+
if (fs.existsSync(currentPkgJson)) {
|
62
|
+
const currentPackage = require(currentPkgJson).name;
|
63
|
+
if (this.stats.pending === 1)
|
64
|
+
logBuildWarning(`1 test skipped in ${currentPackage}`);
|
65
|
+
else
|
66
|
+
logBuildWarning(`${this.stats.pending} tests skipped in ${currentPackage}`);
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
if (this.stats.pending === 1)
|
70
|
+
logBuildWarning(`1 test skipped`);
|
71
|
+
else
|
72
|
+
logBuildWarning(`${this.stats.pending} tests skipped`);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
module.exports = BentleyMochaReporter;
|
package/package.json
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
{
|
2
|
+
"name": "@itwin/build-tools",
|
3
|
+
"version": "3.0.0-dev.72",
|
4
|
+
"description": "Bentley build tools",
|
5
|
+
"license": "MIT",
|
6
|
+
"repository": {
|
7
|
+
"type": "git",
|
8
|
+
"url": "https://github.com/imodeljs/imodeljs/tree/master/tools/build"
|
9
|
+
},
|
10
|
+
"bin": {
|
11
|
+
"betools": "bin/betools.js"
|
12
|
+
},
|
13
|
+
"keywords": [
|
14
|
+
"Bentley",
|
15
|
+
"BIM",
|
16
|
+
"iModel"
|
17
|
+
],
|
18
|
+
"author": {
|
19
|
+
"name": "Bentley Systems, Inc.",
|
20
|
+
"url": "http://www.bentley.com"
|
21
|
+
},
|
22
|
+
"dependencies": {
|
23
|
+
"@microsoft/api-extractor": "7.7.3",
|
24
|
+
"chalk": "^3.0.0",
|
25
|
+
"cpx": "^1.5.0",
|
26
|
+
"cross-spawn": "^7.0.1",
|
27
|
+
"fs-extra": "^8.1.0",
|
28
|
+
"glob": "^7.1.2",
|
29
|
+
"mocha": "^8.3.2",
|
30
|
+
"mocha-junit-reporter": "^1.16.0",
|
31
|
+
"recursive-readdir": "^2.2.2",
|
32
|
+
"rimraf": "^3.0.2",
|
33
|
+
"tree-kill": "^1.2.0",
|
34
|
+
"tsconfig-paths": "^3.3.2",
|
35
|
+
"typedoc": "^0.16.8",
|
36
|
+
"typedoc-plugin-external-module-name": "3.0.0",
|
37
|
+
"typedoc-plugin-internal-external": "2.1.1",
|
38
|
+
"typescript": "~4.4.0",
|
39
|
+
"yargs": "^16.0.0"
|
40
|
+
},
|
41
|
+
"devDependencies": {
|
42
|
+
"@itwin/eslint-plugin": "3.0.0-dev.72",
|
43
|
+
"@types/node": "14.14.31",
|
44
|
+
"eslint": "^7.11.0"
|
45
|
+
},
|
46
|
+
"eslintConfig": {
|
47
|
+
"plugins": [
|
48
|
+
"@itwin"
|
49
|
+
],
|
50
|
+
"extends": "plugin:@itwin/itwinjs-recommended",
|
51
|
+
"rules": {
|
52
|
+
"deprecation/deprecation": "off"
|
53
|
+
}
|
54
|
+
},
|
55
|
+
"scripts": {
|
56
|
+
"compile": "npm run build",
|
57
|
+
"build": "tsc 1>&2",
|
58
|
+
"clean": "rimraf ../../modules .rush/temp/package-deps*.json",
|
59
|
+
"docs": "",
|
60
|
+
"lint": "eslint -f visualstudio --config package.json --no-eslintrc \"./src/**/*.ts\" 1>&2",
|
61
|
+
"test": "",
|
62
|
+
"cover": ""
|
63
|
+
}
|
64
|
+
}
|
@@ -0,0 +1,27 @@
|
|
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
|
+
'use strict';
|
6
|
+
|
7
|
+
const path = require('path');
|
8
|
+
const fs = require('fs-extra');
|
9
|
+
|
10
|
+
// Make sure any symlinks in the project folder are resolved:
|
11
|
+
const appDirectory = fs.realpathSync(process.cwd());
|
12
|
+
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
|
13
|
+
|
14
|
+
module.exports = {
|
15
|
+
appSrc: resolveApp('src'),
|
16
|
+
appTest: resolveApp('src/test'),
|
17
|
+
appLib: resolveApp('lib'),
|
18
|
+
appLibPublic: resolveApp('lib/public'),
|
19
|
+
appLibTests: resolveApp('lib/test'),
|
20
|
+
appPublic: resolveApp('public'),
|
21
|
+
appDocs: resolveApp('lib/docs'),
|
22
|
+
appJsonDocs: resolveApp('lib/docs/json/file.json'),
|
23
|
+
appJUnitTestResults: resolveApp('lib/test/junit_results.xml'),
|
24
|
+
libExtract: resolveApp('lib/extract'),
|
25
|
+
appLocalesEnglish: resolveApp('public/locales/en'),
|
26
|
+
appLocalesPseudolocalize: resolveApp('public/locales/en-pseudo'),
|
27
|
+
};
|
package/scripts/docs.js
ADDED
@@ -0,0 +1,100 @@
|
|
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
|
+
"use strict";
|
6
|
+
|
7
|
+
process.env.NODE_ENV = "prod";
|
8
|
+
|
9
|
+
const paths = require("./config/paths");
|
10
|
+
const path = require("path");
|
11
|
+
const cpx = require("cpx");
|
12
|
+
const fs = require("fs");
|
13
|
+
const { spawn, handleInterrupts } = require("./utils/simpleSpawn");
|
14
|
+
const { validateTags } = require("./utils/validateTags");
|
15
|
+
const argv = require("yargs").argv;
|
16
|
+
|
17
|
+
// Makes the script crash on unhandled rejections instead of silently
|
18
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
19
|
+
// terminate the Node.js process with a non-zero exit code.
|
20
|
+
process.on("unhandledRejection", err => {
|
21
|
+
throw err;
|
22
|
+
});
|
23
|
+
|
24
|
+
const source = (argv.source === undefined) ? paths.appSrc : argv.source;
|
25
|
+
const out = (argv.out === undefined) ? paths.appDocs : argv.out;
|
26
|
+
const json = (argv.json === undefined) ? paths.appJsonDocs : argv.json;
|
27
|
+
|
28
|
+
const baseUrlOptions = (argv.baseUrl === undefined) ? [] : ["--baseUrl", argv.baseUrl];
|
29
|
+
console.log("Input: " + argv)
|
30
|
+
const includeOptions = (argv.includes === undefined) ? [] : ["--includes", argv.includes];
|
31
|
+
|
32
|
+
let excludeList = "**/node_modules/**/*,**/*test*/**/*";
|
33
|
+
if (argv.excludes !== undefined)
|
34
|
+
excludeList += ",**/" + argv.excludes + "/**/*";
|
35
|
+
if (argv.excludeGlob !== undefined)
|
36
|
+
excludeList += "," + argv.excludeGlob;
|
37
|
+
|
38
|
+
let outputOptions = [
|
39
|
+
"--json", json
|
40
|
+
];
|
41
|
+
|
42
|
+
if (argv.onlyJson === undefined)
|
43
|
+
outputOptions = outputOptions.concat(["--out", out]);
|
44
|
+
|
45
|
+
const readmeOption = (argv.readme === undefined) ? "none" : argv.readme;
|
46
|
+
|
47
|
+
const options = [
|
48
|
+
"--excludePrivate",
|
49
|
+
"--experimentalDecorators",
|
50
|
+
"--excludeExternals",
|
51
|
+
"--excludeNotExported",
|
52
|
+
"--ignoreCompilerErrors",
|
53
|
+
"--hideGenerator",
|
54
|
+
];
|
55
|
+
|
56
|
+
if (argv.name) options.push("--name", argv.name);
|
57
|
+
|
58
|
+
if (argv.theme) options.push("--theme", argv.theme);
|
59
|
+
|
60
|
+
const args = [
|
61
|
+
path.resolve(process.cwd(), source),
|
62
|
+
...options,
|
63
|
+
"--exclude", [excludeList],
|
64
|
+
...outputOptions,
|
65
|
+
"--mode", "modules",
|
66
|
+
"--readme", readmeOption,
|
67
|
+
"--module", "commonjs",
|
68
|
+
"--plugin", "typedoc-plugin-external-module-name,typedoc-plugin-internal-external",
|
69
|
+
"--external-aliases", "alpha,internal",
|
70
|
+
"--internal-aliases", "UNUSED",
|
71
|
+
...baseUrlOptions,
|
72
|
+
...includeOptions
|
73
|
+
];
|
74
|
+
|
75
|
+
console.log("Arguments to TypeDoc: " + JSON.stringify(args, null, 2));
|
76
|
+
|
77
|
+
spawn(require.resolve(".bin/typedoc"), args).then((code) => {
|
78
|
+
// Copy index.ts file to json output folder and rename to index.ts if a file is specified. Needed to add descriptions within the barrel file.
|
79
|
+
const outputDir = path.parse(json).dir;
|
80
|
+
if (argv.tsIndexFile) {
|
81
|
+
cpx.copySync(path.join(source, argv.tsIndexFile), outputDir);
|
82
|
+
fs.renameSync(path.join(outputDir, argv.tsIndexFile), path.join(outputDir, 'index.ts'));
|
83
|
+
}
|
84
|
+
// Copy CHANGELOG.json to json output folder
|
85
|
+
if (fs.existsSync(path.join(process.cwd(), 'CHANGELOG.json'))) {
|
86
|
+
cpx.copySync(path.join(process.cwd(), 'CHANGELOG.json'), outputDir);
|
87
|
+
}
|
88
|
+
|
89
|
+
if (code === 0) {
|
90
|
+
let tagErrors = validateTags(json);
|
91
|
+
if (tagErrors.toString()) {
|
92
|
+
console.error(`JSON contains invalid tags: ${JSON.stringify(tagErrors)}`);
|
93
|
+
fs.unlink(json);
|
94
|
+
console.log(`JSON removed from ${json}`)
|
95
|
+
code = 5;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
process.exit(code)
|
99
|
+
});
|
100
|
+
handleInterrupts();
|
@@ -0,0 +1,91 @@
|
|
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
|
+
"use strict";
|
6
|
+
|
7
|
+
// The script parses api.md files, generated by the extract-api.js script (and subsequently the api-extractor.com tool), and extracts the high level API items
|
8
|
+
// into a csv format for easier review.
|
9
|
+
|
10
|
+
const path = require('path');
|
11
|
+
const argv = require("yargs").argv;
|
12
|
+
const fs = require("fs-extra");
|
13
|
+
|
14
|
+
if (undefined === argv.apiSignature) {
|
15
|
+
console.log("Missing apiSignature argument.");
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
|
19
|
+
if (!fs.existsSync(argv.apiSignature)) {
|
20
|
+
console.log("The api signature file does not exist.")
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
|
24
|
+
if (undefined === argv.outDir) {
|
25
|
+
console.log("Missing outDir argument.");
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
|
29
|
+
fs.ensureDir(path.normalize(argv.outDir));
|
30
|
+
|
31
|
+
let shouldGenerateFullReport = false;
|
32
|
+
if (undefined !== argv.gatherFullReport)
|
33
|
+
shouldGenerateFullReport = true;
|
34
|
+
|
35
|
+
// create output file
|
36
|
+
const trimmedApiSignature = (argv.apiSignature.split('.'))[0];
|
37
|
+
const sigFileName = path.basename(path.normalize(trimmedApiSignature));
|
38
|
+
const sigFilePath = path.join(argv.outDir, `${shouldGenerateFullReport ? "summary" : sigFileName}.exports.csv`);
|
39
|
+
|
40
|
+
const outputLines = [];
|
41
|
+
if (shouldGenerateFullReport) {
|
42
|
+
if (fs.existsSync(sigFilePath))
|
43
|
+
outputLines.push("");
|
44
|
+
else {
|
45
|
+
outputLines.push("sep=;");
|
46
|
+
outputLines.push("Package Name;Release Tag;API Item");
|
47
|
+
}
|
48
|
+
} else {
|
49
|
+
fs.createFileSync(sigFilePath);
|
50
|
+
outputLines.push("sep=;");
|
51
|
+
outputLines.push("Release Tag;API Item");
|
52
|
+
}
|
53
|
+
|
54
|
+
// Open up the signature file
|
55
|
+
fs.readFile(argv.apiSignature, function (error, data) {
|
56
|
+
if (error) { throw error; }
|
57
|
+
|
58
|
+
let previousLines = [];
|
59
|
+
data.toString().split("\n").forEach(function (line, index, arr) {
|
60
|
+
if (index === arr.length - 1 && line === "") { return; }
|
61
|
+
|
62
|
+
if (previousLines.length !== 0) {
|
63
|
+
const matches = line.match(/export \S*\s(.*)(\s{|;)/);
|
64
|
+
if (null !== matches) {
|
65
|
+
const split = matches[1].split(/(<|extends|implements)/);
|
66
|
+
for (const previousLine of previousLines)
|
67
|
+
outputLines.push(shouldGenerateFullReport ? `${sigFileName};${previousLine};${split[0]}` : `${previousLine};${split[0]}`);
|
68
|
+
}
|
69
|
+
|
70
|
+
previousLines = [];
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
|
74
|
+
let match = line.match(/\s@(beta|alpha|public|internal)/);
|
75
|
+
if (null === match) {
|
76
|
+
previousLines = [];
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
|
80
|
+
previousLines.push(match[1]);
|
81
|
+
|
82
|
+
// handle deprecated separate since it can be used together with the other release tags
|
83
|
+
match = line.match(/\s@(deprecated)/);
|
84
|
+
if (null !== match) {
|
85
|
+
previousLines.push(match[1]);
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
shouldGenerateFullReport ? fs.appendFileSync(sigFilePath, outputLines.join("\n")) : fs.writeFileSync(sigFilePath, outputLines.join("\n"));
|
91
|
+
});
|