@itwin/build-tools 3.0.0-dev.81 → 3.0.0-dev.85

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/README.md CHANGED
@@ -1,59 +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.
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.
package/bin/betools.js CHANGED
@@ -1,148 +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
- }
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/build-tools",
3
- "version": "3.0.0-dev.81",
3
+ "version": "3.0.0-dev.85",
4
4
  "description": "Bentley build tools",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "yargs": "^16.0.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@itwin/eslint-plugin": "3.0.0-dev.81",
42
+ "@itwin/eslint-plugin": "3.0.0-dev.85",
43
43
  "@types/node": "14.14.31",
44
44
  "eslint": "^7.11.0"
45
45
  },
@@ -1,27 +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/cjs/public'),
19
- appLibTests: resolveApp('lib/cjs/test'),
20
- appPublic: resolveApp('public'),
21
- appDocs: resolveApp('lib/cjs/docs'),
22
- appJsonDocs: resolveApp('lib/cjs/docs/json/file.json'),
23
- appJUnitTestResults: resolveApp('lib/test/junit_results.xml'),
24
- libExtract: resolveApp('lib/cjs/extract'),
25
- appLocalesEnglish: resolveApp('public/locales/en'),
26
- appLocalesPseudolocalize: resolveApp('public/locales/en-pseudo'),
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/cjs/public'),
19
+ appLibTests: resolveApp('lib/cjs/test'),
20
+ appPublic: resolveApp('public'),
21
+ appDocs: resolveApp('lib/cjs/docs'),
22
+ appJsonDocs: resolveApp('lib/cjs/docs/json/file.json'),
23
+ appJUnitTestResults: resolveApp('lib/test/junit_results.xml'),
24
+ libExtract: resolveApp('lib/cjs/extract'),
25
+ appLocalesEnglish: resolveApp('public/locales/en'),
26
+ appLocalesPseudolocalize: resolveApp('public/locales/en-pseudo'),
27
+ };