UNPKG

5.89 kBMarkdownView Raw
1# @bentley/build-tools
2
3Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.
4
5## Description
6
7The __@bentley/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
11Location: tsconfig-base.json\
12Requires build: no
13
14This 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### tslint
17
18> WARNING: TSLint support will be dropped in the next major release, 3.0. Please switch to ESLint, using `@bentley/eslint-plugin`.
19
20Location: tslint.json\
21Requires build: yes
22
23This file contains common tslint settings across all iTwin.js packages. Packages should extend this file in their own tslint.json file, and then overwrite and set new properties as needed.
24
25### TSLint Rules
26
27> WARNING: TSLint support will be dropped in the next major release, 3.0. Please switch to ESLint, using `@bentley/eslint-plugin`.
28
29Location: tslint-rules\
30Requires build: yes
31
32This directory contains several developer-defined TSLint rules that may be imported into tslint.json files. The rules are written in Typescript and compiled. These rules are imported into the tslint.json file for this package (which other imodeljs packages inherit from), however, the rules may also be imported individually from the generated tslint-rules directory after compilation.
33
34The following are several guidelines to follow when creating new TSLint rules:
35
36- Each new rule must be defined in its own file.
37- The file name must be camel-case and end with the suffix "Rule". When accessing the rule in a tslint.json file, the rule's name will be all lowercase and contain each word in the file name separated with a hyphen (except for the word "Rule").
38 - ie: The file noImportsRule.ts would be accessible in tslint.json as "no-imports".
39
40After compiling each rule, they may be used inside a tslint.json file by setting the "rulesDirectory" property to the path of the directory containing the rule. The rule may be accessed and set just as any other.
41
42### NPM Scripts
43
44Location: scripts/\
45Requires build: no
46
47The 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.
48
49The default behaviors of the scripts (without parameters) assume that the directory structure of your package mirrors the following:
50
51- root
52 - source
53 - test
54 - assets
55 - lib
56 - package.json
57 - tsconfig.json
58 - tslint.json
59
60The following is a list of some of the most commonly used scripts within this package:
61
62#### docs.js
63
64This 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:
65
66- source - specify the TypeScript source directory
67- out - specify the directory of the html output
68- json - specify the directory and filename of the json output
69- baseUrl - specify a baseUrl to resolve modules
70- onlyJson - including this option will skip the html output and only output the json file
71- includes - directory of files to include in documentation (ex: for sample code)
72- excludes - name of directory, files, or file extensions to exclude.
73 - A list can be provided using a `,` as a separator
74 - Each of the provided to exclude is added to a glob pattern which checks all directories within the source.
75 - i.e `--excludes=test,docs/*.md` will translate to `**/{test,docs/*.md}/**/*`
76
77#### extract.js
78
79This 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.
80
81- extractDir - the path at which the sample code files are located
82- outDir - the path at which to output the selected code
83
84#### test.js
85
86This script runs the javascript output of Mocha tests with a few standard parameters. The output (success/failure) of the tests will be written to the console.
87
88- packageRoot - the root directory of the package in which the Mocha executable should be located. Really only needed for multi-package repositories.
89- testDir - the path to the javascript test output
90- watch - adds the "--watch" and "--inline-diffs" parameters to the Mocha command
91- debug - adds the "--inspect=9229" and "--debug-brk" parameters to the Mocha command (for debugging with VS Code)
92
93#### test-tsnode.js
94
95> WARNING: The tsnode script will be dropped. Please switch to using `test.js` or directly using mocha.
96
97This script is similar to the test.js command, but looks for the TypeScript test source in order to run it using ts-node. The arguments for this command are similar to the test command, with the following differences:
98
99- testDir - specifies the test TypeScript source folder (instead of the test JavaScript output folder)
100- tscPaths - adds the --require tsconfig-paths/register arguments to the mocha command, in order to resolve paths in the typescript source files to run them with ts-node (needed for multi-package repositories like imodeljs-core)
101
102#### pseudolocalize.js
103
104This script handles translating an English localization JSON file into a pseudoLocalization file.