@next-core/build-config-factory 2.20.0 → 2.23.0
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 +41 -0
- package/package.json +3 -3
- package/src/generateBrickDocs.js +170 -40
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
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
|
+
# [2.23.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.22.0...@next-core/build-config-factory@2.23.0) (2022-07-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **generateBrickDocs:** filter inherited properties ([38daaff](https://github.com/easyops-cn/next-core/commit/38daaffa0dcb5c4ef66cc3d846e525db2ea3ba95))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **generateBrickDocs:** support typle types ([148ad87](https://github.com/easyops-cn/next-core/commit/148ad87935a8deac87c69fd4d60828a2aef7723f))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [2.22.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.21.0...@next-core/build-config-factory@2.22.0) (2022-07-11)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **generateBrickDocs:** support function type ([b085bbf](https://github.com/easyops-cn/next-core/commit/b085bbf089b89dc6e7fa7f743a69731b24ea449a))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [2.21.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.20.0...@next-core/build-config-factory@2.21.0) (2022-07-07)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* **generateBrickDocs:** support description of enum and interface ([3b81fe1](https://github.com/easyops-cn/next-core/commit/3b81fe1a5ee3d1666083fad50c7da8d62379c98a))
|
|
39
|
+
* **generateBrickDocs:** support get detail of reflection type from declaration ([b62557f](https://github.com/easyops-cn/next-core/commit/b62557f09a362a85ac25151d8940cec4e691700b))
|
|
40
|
+
* **generateBrickDocs:** support get parameters type of method from declaration ([e88bef6](https://github.com/easyops-cn/next-core/commit/e88bef6006140001bd44271911566df497e03ca4))
|
|
41
|
+
* **generateBrickDocs:** support get property type from setter ([5825363](https://github.com/easyops-cn/next-core/commit/5825363195c4359a21b9b80360a58a261e886825))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
6
47
|
# [2.20.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.19.0...@next-core/build-config-factory@2.20.0) (2022-07-05)
|
|
7
48
|
|
|
8
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/build-config-factory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "build config factory",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-core/tree/master/packages/build-config-factory",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@next-core/brick-utils": "^2.37.
|
|
21
|
+
"@next-core/brick-utils": "^2.37.21",
|
|
22
22
|
"@next-core/repo-config": "^0.2.1",
|
|
23
23
|
"@next-core/typedoc-plugin-filter-inherit": "^1.2.2",
|
|
24
24
|
"@next-core/webpack-config-factory": "^2.16.6",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"typedoc": "^0.19.2",
|
|
38
38
|
"typedoc-plugin-no-inherit": "^1.2.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "c8dfe32cac64f85af7aa55e420d6b5182d1c1505"
|
|
41
41
|
}
|
package/src/generateBrickDocs.js
CHANGED
|
@@ -100,11 +100,24 @@ function convertTagsToMapByFields(tags, fields) {
|
|
|
100
100
|
}, {});
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
function getClassChildType(child) {
|
|
104
|
+
let type = child.type;
|
|
105
|
+
|
|
106
|
+
// setter
|
|
107
|
+
if (!type && child.kindString === "Accessor" && child.setSignature) {
|
|
108
|
+
type = child.setSignature[0].parameters[0].type;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return type;
|
|
112
|
+
}
|
|
113
|
+
|
|
103
114
|
function composeBrickDocProperties(brick) {
|
|
104
|
-
const { name, comment,
|
|
115
|
+
const { name, comment, flags, defaultValue } = brick;
|
|
116
|
+
const type = getClassChildType(brick);
|
|
117
|
+
|
|
105
118
|
return {
|
|
106
119
|
name,
|
|
107
|
-
type: extractRealInterfaceType(type
|
|
120
|
+
type: extractRealInterfaceType(type),
|
|
108
121
|
required: flags?.isOptional !== true,
|
|
109
122
|
default: defaultValue,
|
|
110
123
|
...convertTagsToMapByFields(get(comment, "tags", []), propertyDocComments),
|
|
@@ -126,7 +139,7 @@ function getEventTypeByDecorators(decorators) {
|
|
|
126
139
|
function getDetailTypeByEventType(type) {
|
|
127
140
|
if (type.name === "EventEmitter" && type.typeArguments?.length > 0) {
|
|
128
141
|
const argument = type.typeArguments[0];
|
|
129
|
-
return extractRealInterfaceType(argument
|
|
142
|
+
return extractRealInterfaceType(argument);
|
|
130
143
|
}
|
|
131
144
|
}
|
|
132
145
|
|
|
@@ -148,6 +161,14 @@ function composeBrickDocMethods(brick) {
|
|
|
148
161
|
[];
|
|
149
162
|
return {
|
|
150
163
|
name,
|
|
164
|
+
params: signatures[0].parameters
|
|
165
|
+
?.map(
|
|
166
|
+
(parameter) =>
|
|
167
|
+
`${parameter.name}${
|
|
168
|
+
parameter.flags?.isOptional ? "?" : ""
|
|
169
|
+
}: ${extractRealInterfaceType(parameter.type)}`
|
|
170
|
+
)
|
|
171
|
+
.join(", "),
|
|
151
172
|
...convertTagsToMapByFields(tags, methodComments),
|
|
152
173
|
};
|
|
153
174
|
}
|
|
@@ -293,8 +314,8 @@ function existBrickDocId(element) {
|
|
|
293
314
|
}
|
|
294
315
|
}
|
|
295
316
|
|
|
296
|
-
function extractRealInterfaceType(
|
|
297
|
-
switch (type) {
|
|
317
|
+
function extractRealInterfaceType(typeData, parentType) {
|
|
318
|
+
switch (typeData?.type) {
|
|
298
319
|
case "reference":
|
|
299
320
|
// eslint-disable-next-line no-case-declarations
|
|
300
321
|
let result = "";
|
|
@@ -304,26 +325,25 @@ function extractRealInterfaceType(type, typeData, parentType) {
|
|
|
304
325
|
|
|
305
326
|
if (typeData.typeArguments && typeData.typeArguments.length > 0) {
|
|
306
327
|
result += `<${typeData.typeArguments
|
|
307
|
-
.map((type) => extractRealInterfaceType(type
|
|
328
|
+
.map((type) => extractRealInterfaceType(type))
|
|
308
329
|
.join(", ")}>`;
|
|
309
330
|
}
|
|
310
331
|
|
|
311
332
|
return result;
|
|
312
333
|
case "array":
|
|
313
334
|
return `${extractRealInterfaceType(
|
|
314
|
-
typeData.elementType.type,
|
|
315
335
|
typeData.elementType,
|
|
316
|
-
type
|
|
336
|
+
typeData.type
|
|
317
337
|
)}[]`;
|
|
318
|
-
case "union":
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
.map((type) => extractRealInterfaceType(type.type, type))
|
|
322
|
-
.join(" | ")})`;
|
|
323
|
-
}
|
|
324
|
-
return typeData.types
|
|
325
|
-
.map((type) => extractRealInterfaceType(type.type, type))
|
|
338
|
+
case "union": {
|
|
339
|
+
const typeStr = typeData.types
|
|
340
|
+
.map((type) => extractRealInterfaceType(type, typeData.type))
|
|
326
341
|
.join(" | ");
|
|
342
|
+
|
|
343
|
+
return parentType === "array" || parentType === "union"
|
|
344
|
+
? `(${typeStr})`
|
|
345
|
+
: typeStr;
|
|
346
|
+
}
|
|
327
347
|
case "stringLiteral":
|
|
328
348
|
return `"${typeData.value}"`;
|
|
329
349
|
case "intrinsic":
|
|
@@ -332,10 +352,55 @@ function extractRealInterfaceType(type, typeData, parentType) {
|
|
|
332
352
|
return typeData.name;
|
|
333
353
|
case "intersection":
|
|
334
354
|
return typeData.types
|
|
335
|
-
.map((type) => extractRealInterfaceType(type
|
|
355
|
+
.map((type) => extractRealInterfaceType(type))
|
|
336
356
|
.join(" & ");
|
|
337
|
-
case "reflection":
|
|
338
|
-
|
|
357
|
+
case "reflection": {
|
|
358
|
+
if (typeData.declaration) {
|
|
359
|
+
const {
|
|
360
|
+
signatures,
|
|
361
|
+
children = [],
|
|
362
|
+
indexSignature = [],
|
|
363
|
+
} = typeData.declaration;
|
|
364
|
+
|
|
365
|
+
if (signatures) {
|
|
366
|
+
const { parameters, type } = signatures[0];
|
|
367
|
+
const typeStr = `(${parameters
|
|
368
|
+
?.map(
|
|
369
|
+
(parameter) =>
|
|
370
|
+
`${parameter.name}${
|
|
371
|
+
parameter.flags?.isOptional ? "?" : ""
|
|
372
|
+
}: ${extractRealInterfaceType(parameter.type)}`
|
|
373
|
+
)
|
|
374
|
+
.join(", ")}) => ${extractRealInterfaceType(type)}`;
|
|
375
|
+
|
|
376
|
+
return parentType === "array" || parentType === "union"
|
|
377
|
+
? `(${typeStr})`
|
|
378
|
+
: typeStr;
|
|
379
|
+
} else {
|
|
380
|
+
return `{ ${[
|
|
381
|
+
...children.map(
|
|
382
|
+
(child) =>
|
|
383
|
+
`${child.name}${
|
|
384
|
+
child.flags?.isOptional ? "?" : ""
|
|
385
|
+
}: ${extractRealInterfaceType(child.type)};`
|
|
386
|
+
),
|
|
387
|
+
...indexSignature.map((item) => {
|
|
388
|
+
const parameter = item.parameters[0];
|
|
389
|
+
return `[${parameter.name}: ${extractRealInterfaceType(
|
|
390
|
+
parameter.type.type,
|
|
391
|
+
parameter.type
|
|
392
|
+
)}]: ${extractRealInterfaceType(item.type)};`;
|
|
393
|
+
}),
|
|
394
|
+
].join(" ")} }`;
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
return "object";
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
case "tuple":
|
|
401
|
+
return `[${typeData.elements
|
|
402
|
+
?.map((element) => element.name)
|
|
403
|
+
.join(", ")}]`;
|
|
339
404
|
default:
|
|
340
405
|
return "";
|
|
341
406
|
}
|
|
@@ -347,7 +412,7 @@ function extractBrickDocTypes(type) {
|
|
|
347
412
|
typeParameter: getTypeParameter(type),
|
|
348
413
|
kind: "type",
|
|
349
414
|
description: get(type, ["comment", "shortText"], "").trim(),
|
|
350
|
-
type: extractRealInterfaceType(type.type
|
|
415
|
+
type: extractRealInterfaceType(type.type),
|
|
351
416
|
};
|
|
352
417
|
}
|
|
353
418
|
|
|
@@ -356,6 +421,7 @@ function extractBrickDocEnumerations(enumerations) {
|
|
|
356
421
|
name: enumerations.name,
|
|
357
422
|
typeParameter: null,
|
|
358
423
|
kind: "enum",
|
|
424
|
+
description: enumerations?.comment?.shortText?.trim(),
|
|
359
425
|
children: [
|
|
360
426
|
...enumerations.children.map((child) => {
|
|
361
427
|
return {
|
|
@@ -402,29 +468,32 @@ function extractBrickDocInterface(typeIds, references) {
|
|
|
402
468
|
typeParameter: getTypeParameter(finder),
|
|
403
469
|
kind: "interface",
|
|
404
470
|
extendedTypes: finder.extendedTypes,
|
|
471
|
+
description: finder?.comment?.shortText?.trim(),
|
|
405
472
|
children:
|
|
406
|
-
finder.children
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
473
|
+
finder.children
|
|
474
|
+
?.filter((child) => !child.inheritedFrom)
|
|
475
|
+
.map((child) => {
|
|
476
|
+
return {
|
|
477
|
+
name: child.name,
|
|
478
|
+
type: extractRealInterfaceType(child.type),
|
|
479
|
+
required: !get(child, ["flags", "isOptional"], false),
|
|
480
|
+
description: get(
|
|
481
|
+
child,
|
|
482
|
+
["comment", "shortText"],
|
|
483
|
+
""
|
|
484
|
+
).trim(),
|
|
485
|
+
};
|
|
486
|
+
}) || [],
|
|
414
487
|
indexSignature:
|
|
415
488
|
finder.indexSignature?.map((child) => {
|
|
416
489
|
return {
|
|
417
490
|
name: child.name,
|
|
418
491
|
parameters: child.parameters.map((parameter) => ({
|
|
419
492
|
...parameter,
|
|
420
|
-
type: extractRealInterfaceType(
|
|
421
|
-
parameter.type.type,
|
|
422
|
-
parameter.type
|
|
423
|
-
),
|
|
493
|
+
type: extractRealInterfaceType(parameter.type),
|
|
424
494
|
})),
|
|
425
|
-
type: extractRealInterfaceType(child.type
|
|
495
|
+
type: extractRealInterfaceType(child.type),
|
|
426
496
|
required: !get(child, ["flags", "isOptional"], false),
|
|
427
|
-
description: get(child, ["comment", "shortText"], "").trim(),
|
|
428
497
|
};
|
|
429
498
|
}) || [],
|
|
430
499
|
};
|
|
@@ -467,12 +536,25 @@ function traverseElementUsedInterfaceIds(
|
|
|
467
536
|
traversedTypeSet
|
|
468
537
|
) {
|
|
469
538
|
element.children.forEach((child) => {
|
|
470
|
-
|
|
471
|
-
child.
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
539
|
+
if (child.kindString === "Method") {
|
|
540
|
+
child.signatures[0].parameters?.map((parameter) =>
|
|
541
|
+
traverseUsedReferenceIdsByType(
|
|
542
|
+
parameter.type,
|
|
543
|
+
usedReferenceIds,
|
|
544
|
+
references,
|
|
545
|
+
traversedTypeSet
|
|
546
|
+
)
|
|
547
|
+
);
|
|
548
|
+
} else {
|
|
549
|
+
const type = getClassChildType(child);
|
|
550
|
+
|
|
551
|
+
traverseUsedReferenceIdsByType(
|
|
552
|
+
type,
|
|
553
|
+
usedReferenceIds,
|
|
554
|
+
references,
|
|
555
|
+
traversedTypeSet
|
|
556
|
+
);
|
|
557
|
+
}
|
|
476
558
|
});
|
|
477
559
|
}
|
|
478
560
|
|
|
@@ -581,6 +663,54 @@ function traverseUsedReferenceIdsByType(
|
|
|
581
663
|
traversedTypeSet
|
|
582
664
|
);
|
|
583
665
|
break;
|
|
666
|
+
case "reflection":
|
|
667
|
+
if (type.declaration) {
|
|
668
|
+
const { signatures, children, indexSignature } = type.declaration;
|
|
669
|
+
|
|
670
|
+
signatures?.forEach((signature) => {
|
|
671
|
+
signature.parameters?.forEach((parameter) =>
|
|
672
|
+
traverseUsedReferenceIdsByType(
|
|
673
|
+
parameter.type,
|
|
674
|
+
usedReferenceIds,
|
|
675
|
+
references,
|
|
676
|
+
traversedTypeSet
|
|
677
|
+
)
|
|
678
|
+
);
|
|
679
|
+
traverseUsedReferenceIdsByType(
|
|
680
|
+
signature.type,
|
|
681
|
+
usedReferenceIds,
|
|
682
|
+
references,
|
|
683
|
+
traversedTypeSet
|
|
684
|
+
);
|
|
685
|
+
});
|
|
686
|
+
children?.forEach((child) => {
|
|
687
|
+
traverseUsedReferenceIdsByType(
|
|
688
|
+
child.type,
|
|
689
|
+
usedReferenceIds,
|
|
690
|
+
references,
|
|
691
|
+
traversedTypeSet
|
|
692
|
+
);
|
|
693
|
+
});
|
|
694
|
+
indexSignature?.forEach((item) => {
|
|
695
|
+
traverseUsedReferenceIdsByType(
|
|
696
|
+
item.type,
|
|
697
|
+
usedReferenceIds,
|
|
698
|
+
references,
|
|
699
|
+
traversedTypeSet
|
|
700
|
+
);
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
break;
|
|
704
|
+
case "tuple":
|
|
705
|
+
type.elements?.forEach((element) =>
|
|
706
|
+
traverseUsedReferenceIdsByType(
|
|
707
|
+
element,
|
|
708
|
+
usedReferenceIds,
|
|
709
|
+
references,
|
|
710
|
+
traversedTypeSet
|
|
711
|
+
)
|
|
712
|
+
);
|
|
713
|
+
break;
|
|
584
714
|
}
|
|
585
715
|
}
|
|
586
716
|
|