@ui5/webcomponents-tools 1.22.0-rc.2 → 1.22.0-rc.3
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
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.22.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.22.0-rc.2...v1.22.0-rc.3) (2024-02-01)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
6
14
|
# [1.22.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.22.0-rc.1...v1.22.0-rc.2) (2024-01-25)
|
7
15
|
|
8
16
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
@@ -13,12 +13,13 @@ import {
|
|
13
13
|
hasTag,
|
14
14
|
findTag,
|
15
15
|
findAllTags,
|
16
|
-
getJSDocErrors,
|
17
16
|
getTypeRefs,
|
18
17
|
normalizeDescription,
|
19
18
|
formatArrays,
|
20
19
|
isClass,
|
21
|
-
normalizeTagType
|
20
|
+
normalizeTagType,
|
21
|
+
logDocumentationError,
|
22
|
+
displayDocumentationErrors
|
22
23
|
} from "./utils.mjs";
|
23
24
|
|
24
25
|
const packageJSON = JSON.parse(fs.readFileSync("./package.json"));
|
@@ -165,6 +166,7 @@ function processClass(ts, classNode, moduleDoc) {
|
|
165
166
|
|
166
167
|
if (propertyDecorator) {
|
167
168
|
member._ui5validator = propertyDecorator?.expression?.arguments[0]?.properties?.find(property => ["validator", "type"].includes(property.name.text))?.initializer?.text || "String";
|
169
|
+
member._ui5noAttribute = propertyDecorator?.expression?.arguments[0]?.properties?.find(property => property.name.text === "noAttribute")?.initializer?.kind === ts.SyntaxKind.TrueKeyword || undefined;
|
168
170
|
}
|
169
171
|
|
170
172
|
if (hasTag(memberParsedJsDoc, "formProperty")) {
|
@@ -183,24 +185,14 @@ function processClass(ts, classNode, moduleDoc) {
|
|
183
185
|
member.default = tagValue;
|
184
186
|
}
|
185
187
|
|
186
|
-
if (member.privacy === "public") {
|
187
|
-
|
188
|
-
|
189
|
-
if (!member.default) {
|
190
|
-
JSDocErrors.push(
|
191
|
-
`=== ERROR: Problem found with ${member.name}'s JSDoc comment in ${moduleDoc.path}: Default value is missing`
|
192
|
-
);
|
193
|
-
}
|
188
|
+
if (member.privacy === "public" && !member.default) {
|
189
|
+
logDocumentationError(moduleDoc.path, `Missing default value for '${member.name}'.`)
|
194
190
|
}
|
195
191
|
|
196
192
|
// Getters are treated as fields so they should not have return, instead of return they should have default value defined with @default
|
197
193
|
if (member.readonly) {
|
198
194
|
if (member.privacy === "public" && !member.type) {
|
199
|
-
|
200
|
-
|
201
|
-
JSDocErrors.push(
|
202
|
-
`=== ERROR: Problem found with ${member.name}'s JSDoc comment in ${moduleDoc.path}: Missing return type`
|
203
|
-
);
|
195
|
+
logDocumentationError(moduleDoc.path, `Missing return type for read-only field '${member.name}'.`)
|
204
196
|
}
|
205
197
|
|
206
198
|
delete member.return;
|
@@ -249,21 +241,19 @@ function processClass(ts, classNode, moduleDoc) {
|
|
249
241
|
if (member.return) {
|
250
242
|
const returnTag = findTag(memberParsedJsDoc, "returns");
|
251
243
|
member.return.description = returnTag?.description ? `${returnTag.name} ${returnTag.description}` : returnTag?.name;
|
252
|
-
member.return.type.text = classNodeMember?.type?.getFullText?.()?.trim();
|
244
|
+
member.return.type.text = formatArrays(classNodeMember?.type?.getFullText?.()?.trim());
|
253
245
|
const typeRefs = (getTypeRefs(ts, classNodeMember, member.return)
|
254
246
|
?.map(typeRef => getReference(ts, typeRef, classNodeMember, moduleDoc.path)).filter(Boolean)) || [];
|
255
247
|
|
256
248
|
if (typeRefs.length) {
|
257
249
|
member.return.type.references = typeRefs;
|
258
250
|
}
|
259
|
-
}
|
260
251
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
);
|
252
|
+
if (member.privacy === "public" && !member.return.type.text) {
|
253
|
+
logDocumentationError(moduleDoc.path, `Missing return type for function '${member.name}'.`)
|
254
|
+
}
|
255
|
+
} else if (member.privacy === "public") {
|
256
|
+
logDocumentationError(moduleDoc.path, `Missing return type for function '${member.name}'.`)
|
267
257
|
}
|
268
258
|
}
|
269
259
|
}
|
@@ -474,9 +464,7 @@ export default {
|
|
474
464
|
const hasExport = moduleDoc.exports.some(e => e.declaration?.name === reference.name && e.declaration?.module === reference.module)
|
475
465
|
|
476
466
|
if (!hasExport) {
|
477
|
-
|
478
|
-
JSDocErrors.push(
|
479
|
-
`=== ERROR: Problem found with ${reference.name} type reference in ${moduleDoc.path?.replace(/^dist/, "src").replace(/\.js$/, ".ts")}: \n\t- ${reference.name} is used as type of public API, but it's not exported`)
|
467
|
+
logDocumentationError(moduleDoc.path?.replace(/^dist/, "src").replace(/\.js$/, ".ts"), `Type '${reference.name}' is used to describe a public API but is not exported.`,)
|
480
468
|
}
|
481
469
|
}
|
482
470
|
})
|
@@ -486,12 +474,7 @@ export default {
|
|
486
474
|
},
|
487
475
|
packageLinkPhase({ context }) {
|
488
476
|
if (context.dev) {
|
489
|
-
|
490
|
-
if (JSDocErrors.length > 0) {
|
491
|
-
console.log(JSDocErrors.join("\n"));
|
492
|
-
console.log(`Invalid JSDoc. ${JSDocErrors.length} were found.`);
|
493
|
-
throw new Error(`Invalid JSDoc.`);
|
494
|
-
}
|
477
|
+
displayDocumentationErrors();
|
495
478
|
}
|
496
479
|
}
|
497
480
|
},
|
package/lib/cem/event.mjs
CHANGED
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
getReference,
|
13
13
|
normalizeDescription,
|
14
14
|
normalizeTagType,
|
15
|
-
|
15
|
+
logDocumentationError
|
16
16
|
} from "./utils.mjs";
|
17
17
|
|
18
18
|
const jsDocRegExp = /\/\*\*(.|\n)+?\s+\*\//;
|
@@ -83,11 +83,7 @@ function processEvent(ts, event, classNode, moduleDoc) {
|
|
83
83
|
const eventDetails = event?.expression?.arguments?.[1]?.properties?.find(prop => prop?.name?.text === "detail")?.initializer?.properties;
|
84
84
|
|
85
85
|
if (event?.expression?.arguments?.[1] && !event?.expression?.typeArguments) {
|
86
|
-
|
87
|
-
|
88
|
-
JSDocErrors.push(
|
89
|
-
`=== ERROR: Problem found with ${name}'s description in ${moduleDoc.path}: \n\t- Event details have to be described with type via generics type passed to the decorator ( @event<TypeForDetails>("example-name", {details}) ) `
|
90
|
-
);
|
86
|
+
logDocumentationError(moduleDoc.path, `Event details for event '${name}' must be described using generics. Add type via generics to the decorator: @event<TypeForDetails>("${name}", {details}).`)
|
91
87
|
}
|
92
88
|
|
93
89
|
result.description = description;
|
package/lib/cem/utils.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import fs from "fs";
|
2
2
|
import path from "path";
|
3
3
|
|
4
|
-
let
|
4
|
+
let documentationErrors = new Map();
|
5
5
|
|
6
6
|
const getDeprecatedStatus = (jsdocComment) => {
|
7
7
|
const deprecatedTag = findTag(jsdocComment, "deprecated");
|
@@ -24,6 +24,8 @@ const getTypeRefs = (ts, node, member) => {
|
|
24
24
|
return type.typeArguments?.length
|
25
25
|
? type.typeArguments.map((typeRef) => typeRef.typeName?.text)
|
26
26
|
: [type.typeName?.text];
|
27
|
+
} else if (type?.kind === ts.SyntaxKind.ArrayType) {
|
28
|
+
return [type.elementType?.typeName?.text];
|
27
29
|
} else if (type?.kind === ts.SyntaxKind.UnionType) {
|
28
30
|
return type.types
|
29
31
|
.map((type) => extractTypeRefs(type))
|
@@ -316,21 +318,43 @@ const validateJSDocComment = (fieldType, jsdocComment, node, moduleDoc) => {
|
|
316
318
|
}
|
317
319
|
|
318
320
|
if (!isValid) {
|
319
|
-
|
320
|
-
`=== ERROR: Problem found with ${node}'s JSDoc comment in ${moduleDoc.path}: \n\t- @${tag.tag} tag is being used wrong or it's not part of ${fieldType} JSDoc tags`
|
321
|
-
);
|
321
|
+
logDocumentationError(moduleDoc.path, `Incorrect use of @${tag.tag}. Ensure it is part of ${fieldType} JSDoc tags.`)
|
322
322
|
}
|
323
323
|
|
324
324
|
return !!isValid;
|
325
325
|
});
|
326
326
|
};
|
327
327
|
|
328
|
-
const
|
329
|
-
|
330
|
-
|
328
|
+
const logDocumentationError = (modulePath, message) => {
|
329
|
+
let moduleErrors = documentationErrors.get(modulePath);
|
330
|
+
|
331
|
+
if (!moduleErrors) {
|
332
|
+
documentationErrors.set(modulePath, []);
|
333
|
+
moduleErrors = documentationErrors.get(modulePath);
|
334
|
+
}
|
335
|
+
|
336
|
+
moduleErrors.push(message);
|
337
|
+
}
|
338
|
+
|
339
|
+
const displayDocumentationErrors = () => {
|
340
|
+
let errorsCount = 0;
|
341
|
+
[...documentationErrors.keys()].forEach(modulePath => {
|
342
|
+
const moduleErrors = documentationErrors.get(modulePath);
|
343
|
+
|
344
|
+
console.log(`=== ERROR: ${moduleErrors.length > 1 ? `${moduleErrors.length} problems` : "Problem"} found in file: ${modulePath}:`)
|
345
|
+
moduleErrors.forEach(moduleError => {
|
346
|
+
errorsCount++;
|
347
|
+
console.log(`\t- ${moduleError}`)
|
348
|
+
})
|
349
|
+
})
|
350
|
+
|
351
|
+
if(errorsCount) {
|
352
|
+
throw new Error(`Found ${errorsCount} errors in the description of the public API.`);
|
353
|
+
}
|
354
|
+
}
|
331
355
|
|
332
356
|
const formatArrays = (typeText) => {
|
333
|
-
return typeText
|
357
|
+
return typeText?.replaceAll(/(\S+)\[\]/g, "Array<$1>")
|
334
358
|
}
|
335
359
|
|
336
360
|
export {
|
@@ -345,10 +369,11 @@ export {
|
|
345
369
|
hasTag,
|
346
370
|
findTag,
|
347
371
|
findAllTags,
|
348
|
-
getJSDocErrors,
|
349
372
|
getTypeRefs,
|
350
373
|
normalizeDescription,
|
351
374
|
formatArrays,
|
352
375
|
isClass,
|
353
|
-
normalizeTagType
|
376
|
+
normalizeTagType,
|
377
|
+
displayDocumentationErrors,
|
378
|
+
logDocumentationError,
|
354
379
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "1.22.0-rc.
|
3
|
+
"version": "1.22.0-rc.3",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -79,5 +79,5 @@
|
|
79
79
|
"esbuild": "^0.19.9",
|
80
80
|
"yargs": "^17.5.1"
|
81
81
|
},
|
82
|
-
"gitHead": "
|
82
|
+
"gitHead": "7ff123775e38dc646e3a1c70311e33b0c6d7105a"
|
83
83
|
}
|