@itwin/build-tools 3.6.0-dev.7 → 4.0.0-dev.1
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 +26 -1
- package/LICENSE.md +1 -1
- package/bin/betools.js +35 -5
- package/package.json +2 -2
- package/scripts/copy-assets.js +61 -0
- package/scripts/docs.js +2 -1
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,31 @@
|
|
1
1
|
# Change Log - @itwin/build-tools
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Thu, 26 Jan 2023 22:53:27 GMT and should not be manually modified.
|
4
|
+
|
5
|
+
## 3.5.5
|
6
|
+
Thu, 26 Jan 2023 22:53:27 GMT
|
7
|
+
|
8
|
+
_Version update only_
|
9
|
+
|
10
|
+
## 3.5.4
|
11
|
+
Wed, 18 Jan 2023 15:27:15 GMT
|
12
|
+
|
13
|
+
_Version update only_
|
14
|
+
|
15
|
+
## 3.5.3
|
16
|
+
Fri, 13 Jan 2023 17:23:07 GMT
|
17
|
+
|
18
|
+
_Version update only_
|
19
|
+
|
20
|
+
## 3.5.2
|
21
|
+
Wed, 11 Jan 2023 16:46:30 GMT
|
22
|
+
|
23
|
+
_Version update only_
|
24
|
+
|
25
|
+
## 3.5.1
|
26
|
+
Thu, 15 Dec 2022 16:38:28 GMT
|
27
|
+
|
28
|
+
_Version update only_
|
4
29
|
|
5
30
|
## 3.5.0
|
6
31
|
Wed, 07 Dec 2022 19:12:36 GMT
|
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
@@ -40,6 +40,9 @@ yargs.strict(true)
|
|
40
40
|
"excludeGlob": {
|
41
41
|
describe: "Specify a directory, filename, or pattern to be excluded"
|
42
42
|
},
|
43
|
+
"testExcludeGlob": {
|
44
|
+
describe: "Specify a directory, filename, or pattern to exclude tests. Default value: '**/*test*/**/*'"
|
45
|
+
},
|
43
46
|
"tsIndexFile": {
|
44
47
|
describe: "The barrel file containing the module documentation. This file is copied to the output folder for parsing."
|
45
48
|
},
|
@@ -92,6 +95,21 @@ yargs.strict(true)
|
|
92
95
|
})
|
93
96
|
},
|
94
97
|
(argv) => { pseudolocalizeCommand(argv) })
|
98
|
+
.command("copy-assets", "copy assets from @itwin or @bentley dependencies into a destination directory",
|
99
|
+
function (yargs) {
|
100
|
+
return yargs.options({
|
101
|
+
"packageJsonDir": {
|
102
|
+
describe: "The path at which the package.json listing deps that need their assets copied can be found. defaults to '.'"
|
103
|
+
},
|
104
|
+
"nodeModulesDir": {
|
105
|
+
describe: "The path to the node_modules directory where the deps that need their assets copied can be found. defaults to '.'"
|
106
|
+
},
|
107
|
+
"destinationDir": {
|
108
|
+
describe: "the location to copy the assets to. defaults to './lib/assets'"
|
109
|
+
},
|
110
|
+
})
|
111
|
+
},
|
112
|
+
(argv) => { copyAssetsCommand(argv) })
|
95
113
|
.help()
|
96
114
|
.argv;
|
97
115
|
|
@@ -100,6 +118,10 @@ function testCommand(options) {
|
|
100
118
|
process.exit(1);
|
101
119
|
}
|
102
120
|
|
121
|
+
function getScriptPath(name) {
|
122
|
+
return `"${path.resolve(__dirname, path.join("..", "scripts", name))}"`;
|
123
|
+
}
|
124
|
+
|
103
125
|
function docsCommand(options) {
|
104
126
|
const sourceOpt = options.source ? ["--source", options.source] : [];
|
105
127
|
const outOpt = options.out ? ["--out", options.out] : [];
|
@@ -108,11 +130,12 @@ function docsCommand(options) {
|
|
108
130
|
const includesOpt = options.includes ? ["--includes", options.includes] : [];
|
109
131
|
const excludesOpt = options.excludes ? ["--excludes", options.excludes] : [];
|
110
132
|
const excludesGlobOpt = options.excludeGlob ? ["--excludeGlob", options.excludeGlob] : [];
|
133
|
+
const testExcludeGlobOpt = options.testExcludeGlob ? ["--testExcludeGlob", options.testExcludeGlob] : [];
|
111
134
|
const indexFileOpt = options.tsIndexFile ? ["--tsIndexFile", options.tsIndexFile] : [];
|
112
135
|
const onlyJsonOpt = options.onlyJson ? ["--onlyJson"] : [];
|
113
|
-
exec(["node",
|
136
|
+
exec(["node", getScriptPath("docs.js"),
|
114
137
|
...sourceOpt, ...outOpt, ...jsonOpt, ...baseUrlOpt, ...includesOpt,
|
115
|
-
...excludesOpt, ...excludesGlobOpt, ...indexFileOpt, ...onlyJsonOpt]);
|
138
|
+
...excludesOpt, ...excludesGlobOpt, ...testExcludeGlobOpt, ...indexFileOpt, ...onlyJsonOpt]);
|
116
139
|
}
|
117
140
|
|
118
141
|
function extractCommand(options) {
|
@@ -120,19 +143,26 @@ function extractCommand(options) {
|
|
120
143
|
const outOpt = options.out ? ["--out", options.out] : [];
|
121
144
|
const fileExt = options.fileExt ? ["--fileExt", options.fileExt] : [];
|
122
145
|
const recursive = options.recursive ? ["--recursive"] : [];
|
123
|
-
exec(["node",
|
146
|
+
exec(["node", getScriptPath("extract.js"), ...extractOpt, ...outOpt, ...fileExt, ...recursive]);
|
124
147
|
}
|
125
148
|
|
126
149
|
function extractApiCommand(options) {
|
127
150
|
const entryOpt = options.entry ? ["--entry", options.entry] : [];
|
128
151
|
const ignoreTagsOpt = options.ignoreMissingTags ? ["--ignoreMissingTags"] : [];
|
129
|
-
exec(["node",
|
152
|
+
exec(["node", getScriptPath("extract-api.js"), ...entryOpt, ...ignoreTagsOpt]);
|
130
153
|
}
|
131
154
|
|
132
155
|
function pseudolocalizeCommand(options) {
|
133
156
|
const englishDir = options.englishDir ? ["--englishDir", options.englishDir] : [];
|
134
157
|
const outOpt = options.out ? ["--out", options.out] : [];
|
135
|
-
exec(["node",
|
158
|
+
exec(["node", getScriptPath("pseudolocalize"), ...englishDir, ...outOpt]);
|
159
|
+
}
|
160
|
+
|
161
|
+
function copyAssetsCommand(options) {
|
162
|
+
const packageJsonDir = options.packageJsonDir ? ["--packageJsonDir", options.packageJsonDir] : [];
|
163
|
+
const nodeModulesDir = options.nodeModulesDir ? ["--nodeModulesDir", options.nodeModulesDir] : [];
|
164
|
+
const destinationDir = options.destinationDir ? ["--destinationDir", options.destinationDir] : [];
|
165
|
+
exec(["node", path.resolve(__dirname, "../scripts/copy-assets.js"), ...packageJsonDir, ...nodeModulesDir, ...destinationDir]);
|
136
166
|
}
|
137
167
|
|
138
168
|
function exec(cmd) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@itwin/build-tools",
|
3
|
-
"version": "
|
3
|
+
"version": "4.0.0-dev.1",
|
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": "
|
40
|
+
"@itwin/eslint-plugin": "4.0.0-dev.1",
|
41
41
|
"@types/node": "18.11.5",
|
42
42
|
"eslint": "^7.11.0"
|
43
43
|
},
|
@@ -0,0 +1,61 @@
|
|
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
|
+
"use strict"
|
7
|
+
|
8
|
+
const argv = require("yargs").argv;
|
9
|
+
const fs = require("fs-extra");
|
10
|
+
const path = require("path");
|
11
|
+
|
12
|
+
// example usage
|
13
|
+
// betools copy-assets --nodeModulesDir=../../../../
|
14
|
+
|
15
|
+
const packageJsonDir = argv.packageJsonDir ?? ".";
|
16
|
+
const nodeModulesDir = argv.nodeModulesDir ?? ".";
|
17
|
+
const destinationDir = argv.destinationDir ?? "./lib/assets";
|
18
|
+
|
19
|
+
// find all dependencies that should have their assets copied from
|
20
|
+
// currently this logic will find only packages with the @itwin or @bentley scope
|
21
|
+
const getBentleyPackageDeps = () => {
|
22
|
+
const packageJsonPath = `${packageJsonDir}/package.json`;
|
23
|
+
const packageJsonRaw = fs.readFileSync(packageJsonPath);
|
24
|
+
const packageJson = JSON.parse(packageJsonRaw);
|
25
|
+
const deps = new Set();
|
26
|
+
|
27
|
+
for (const packageName in packageJson.dependencies) {
|
28
|
+
if (packageName.includes("@itwin") || packageName.includes("@bentley")) {
|
29
|
+
deps.add(packageName);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
return Array.from(deps);
|
34
|
+
}
|
35
|
+
|
36
|
+
const copySync = (fromPath, toPath) => {
|
37
|
+
if (fs.existsSync(fromPath)) {
|
38
|
+
try {
|
39
|
+
fs.copySync(fromPath, toPath);
|
40
|
+
console.log(`successfully copied from ${fromPath} to ${toPath}`)
|
41
|
+
} catch (ex) {
|
42
|
+
console.error(`failed to copy from ${fromPath} to ${toPath}`, ex);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
// finds all applicable dependences with assets and copies them into the destination folder
|
48
|
+
const copyBentleyPackageDepAssets = () => {
|
49
|
+
if (!fs.existsSync(destinationDir)) {
|
50
|
+
fs.mkdirSync(destinationDir, { recursive: true });
|
51
|
+
}
|
52
|
+
|
53
|
+
// check for assets found in lib as well as lib/cjs
|
54
|
+
for (const target of getBentleyPackageDeps()) {
|
55
|
+
copySync(path.join(nodeModulesDir, "node_modules", target, "lib/assets"), destinationDir);
|
56
|
+
copySync(path.join(nodeModulesDir, "node_modules", target, "lib/cjs/assets"), destinationDir);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
copyBentleyPackageDepAssets();
|
61
|
+
console.log("finished copying assets");
|
package/scripts/docs.js
CHANGED
@@ -29,7 +29,8 @@ const json = (argv.json === undefined) ? paths.appJsonDocs : argv.json;
|
|
29
29
|
const baseUrlOptions = (argv.baseUrl === undefined) ? [] : ["--baseUrl", argv.baseUrl];
|
30
30
|
const includeOptions = (argv.includes === undefined) ? [] : ["--includes", argv.includes];
|
31
31
|
|
32
|
-
|
32
|
+
const testExclude = argv.testExcludeGlob ?? "**/*test*/**/*";
|
33
|
+
let excludeList = `**/node_modules/**/*,${testExclude}`;
|
33
34
|
if (argv.excludes !== undefined)
|
34
35
|
excludeList += ",**/" + argv.excludes + "/**/*";
|
35
36
|
if (argv.excludeGlob !== undefined)
|