@next-core/build-config-factory 2.19.0 → 2.22.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 +36 -0
- package/package.json +3 -3
- package/src/generateBrickDocs.js +152 -33
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,42 @@
|
|
|
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.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)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **generateBrickDocs:** support function type ([b085bbf](https://github.com/easyops-cn/next-core/commit/b085bbf089b89dc6e7fa7f743a69731b24ea449a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **generateBrickDocs:** support description of enum and interface ([3b81fe1](https://github.com/easyops-cn/next-core/commit/3b81fe1a5ee3d1666083fad50c7da8d62379c98a))
|
|
23
|
+
* **generateBrickDocs:** support get detail of reflection type from declaration ([b62557f](https://github.com/easyops-cn/next-core/commit/b62557f09a362a85ac25151d8940cec4e691700b))
|
|
24
|
+
* **generateBrickDocs:** support get parameters type of method from declaration ([e88bef6](https://github.com/easyops-cn/next-core/commit/e88bef6006140001bd44271911566df497e03ca4))
|
|
25
|
+
* **generateBrickDocs:** support get property type from setter ([5825363](https://github.com/easyops-cn/next-core/commit/5825363195c4359a21b9b80360a58a261e886825))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# [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)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **generateBrickDocs:** support infer required and default of property and detail of event from declaration ([6a60f26](https://github.com/easyops-cn/next-core/commit/6a60f26563683d89d5b36bb766f973cb23522e70))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
6
42
|
# [2.19.0](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.18.52...@next-core/build-config-factory@2.19.0) (2022-07-05)
|
|
7
43
|
|
|
8
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/build-config-factory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.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": "42bab4e94fbac369b5e9953272d568ba5cfb15e8"
|
|
41
41
|
}
|
package/src/generateBrickDocs.js
CHANGED
|
@@ -100,12 +100,26 @@ 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 } = brick;
|
|
105
|
-
const type = brick
|
|
115
|
+
const { name, comment, flags, defaultValue } = brick;
|
|
116
|
+
const type = getClassChildType(brick);
|
|
117
|
+
|
|
106
118
|
return {
|
|
107
119
|
name,
|
|
108
|
-
type: extractRealInterfaceType(type
|
|
120
|
+
type: extractRealInterfaceType(type),
|
|
121
|
+
required: flags?.isOptional !== true,
|
|
122
|
+
default: defaultValue,
|
|
109
123
|
...convertTagsToMapByFields(get(comment, "tags", []), propertyDocComments),
|
|
110
124
|
};
|
|
111
125
|
}
|
|
@@ -122,11 +136,19 @@ function getEventTypeByDecorators(decorators) {
|
|
|
122
136
|
return null;
|
|
123
137
|
}
|
|
124
138
|
|
|
139
|
+
function getDetailTypeByEventType(type) {
|
|
140
|
+
if (type.name === "EventEmitter" && type.typeArguments?.length > 0) {
|
|
141
|
+
const argument = type.typeArguments[0];
|
|
142
|
+
return extractRealInterfaceType(argument);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
125
146
|
function composeBrickDocEvents(brick) {
|
|
126
|
-
const { comment, decorators } = brick;
|
|
147
|
+
const { comment, decorators, type } = brick;
|
|
127
148
|
|
|
128
149
|
return {
|
|
129
150
|
type: getEventTypeByDecorators(decorators),
|
|
151
|
+
detail: getDetailTypeByEventType(type),
|
|
130
152
|
...convertTagsToMapByFields(get(comment, "tags", []), eventDocComments),
|
|
131
153
|
};
|
|
132
154
|
}
|
|
@@ -139,6 +161,14 @@ function composeBrickDocMethods(brick) {
|
|
|
139
161
|
[];
|
|
140
162
|
return {
|
|
141
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(", "),
|
|
142
172
|
...convertTagsToMapByFields(tags, methodComments),
|
|
143
173
|
};
|
|
144
174
|
}
|
|
@@ -284,8 +314,8 @@ function existBrickDocId(element) {
|
|
|
284
314
|
}
|
|
285
315
|
}
|
|
286
316
|
|
|
287
|
-
function extractRealInterfaceType(
|
|
288
|
-
switch (type) {
|
|
317
|
+
function extractRealInterfaceType(typeData, parentType) {
|
|
318
|
+
switch (typeData?.type) {
|
|
289
319
|
case "reference":
|
|
290
320
|
// eslint-disable-next-line no-case-declarations
|
|
291
321
|
let result = "";
|
|
@@ -295,26 +325,25 @@ function extractRealInterfaceType(type, typeData, parentType) {
|
|
|
295
325
|
|
|
296
326
|
if (typeData.typeArguments && typeData.typeArguments.length > 0) {
|
|
297
327
|
result += `<${typeData.typeArguments
|
|
298
|
-
.map((type) => extractRealInterfaceType(type
|
|
328
|
+
.map((type) => extractRealInterfaceType(type))
|
|
299
329
|
.join(", ")}>`;
|
|
300
330
|
}
|
|
301
331
|
|
|
302
332
|
return result;
|
|
303
333
|
case "array":
|
|
304
334
|
return `${extractRealInterfaceType(
|
|
305
|
-
typeData.elementType.type,
|
|
306
335
|
typeData.elementType,
|
|
307
|
-
type
|
|
336
|
+
typeData.type
|
|
308
337
|
)}[]`;
|
|
309
|
-
case "union":
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
.map((type) => extractRealInterfaceType(type.type, type))
|
|
313
|
-
.join(" | ")})`;
|
|
314
|
-
}
|
|
315
|
-
return typeData.types
|
|
316
|
-
.map((type) => extractRealInterfaceType(type.type, type))
|
|
338
|
+
case "union": {
|
|
339
|
+
const typeStr = typeData.types
|
|
340
|
+
.map((type) => extractRealInterfaceType(type, typeData.type))
|
|
317
341
|
.join(" | ");
|
|
342
|
+
|
|
343
|
+
return parentType === "array" || parentType === "union"
|
|
344
|
+
? `(${typeStr})`
|
|
345
|
+
: typeStr;
|
|
346
|
+
}
|
|
318
347
|
case "stringLiteral":
|
|
319
348
|
return `"${typeData.value}"`;
|
|
320
349
|
case "intrinsic":
|
|
@@ -323,10 +352,51 @@ function extractRealInterfaceType(type, typeData, parentType) {
|
|
|
323
352
|
return typeData.name;
|
|
324
353
|
case "intersection":
|
|
325
354
|
return typeData.types
|
|
326
|
-
.map((type) => extractRealInterfaceType(type
|
|
355
|
+
.map((type) => extractRealInterfaceType(type))
|
|
327
356
|
.join(" & ");
|
|
328
|
-
case "reflection":
|
|
329
|
-
|
|
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
|
+
}
|
|
330
400
|
default:
|
|
331
401
|
return "";
|
|
332
402
|
}
|
|
@@ -338,7 +408,7 @@ function extractBrickDocTypes(type) {
|
|
|
338
408
|
typeParameter: getTypeParameter(type),
|
|
339
409
|
kind: "type",
|
|
340
410
|
description: get(type, ["comment", "shortText"], "").trim(),
|
|
341
|
-
type: extractRealInterfaceType(type.type
|
|
411
|
+
type: extractRealInterfaceType(type.type),
|
|
342
412
|
};
|
|
343
413
|
}
|
|
344
414
|
|
|
@@ -347,6 +417,7 @@ function extractBrickDocEnumerations(enumerations) {
|
|
|
347
417
|
name: enumerations.name,
|
|
348
418
|
typeParameter: null,
|
|
349
419
|
kind: "enum",
|
|
420
|
+
description: enumerations?.comment?.shortText?.trim(),
|
|
350
421
|
children: [
|
|
351
422
|
...enumerations.children.map((child) => {
|
|
352
423
|
return {
|
|
@@ -393,11 +464,12 @@ function extractBrickDocInterface(typeIds, references) {
|
|
|
393
464
|
typeParameter: getTypeParameter(finder),
|
|
394
465
|
kind: "interface",
|
|
395
466
|
extendedTypes: finder.extendedTypes,
|
|
467
|
+
description: finder?.comment?.shortText?.trim(),
|
|
396
468
|
children:
|
|
397
469
|
finder.children?.map((child) => {
|
|
398
470
|
return {
|
|
399
471
|
name: child.name,
|
|
400
|
-
type: extractRealInterfaceType(child.type
|
|
472
|
+
type: extractRealInterfaceType(child.type),
|
|
401
473
|
required: !get(child, ["flags", "isOptional"], false),
|
|
402
474
|
description: get(child, ["comment", "shortText"], "").trim(),
|
|
403
475
|
};
|
|
@@ -408,12 +480,9 @@ function extractBrickDocInterface(typeIds, references) {
|
|
|
408
480
|
name: child.name,
|
|
409
481
|
parameters: child.parameters.map((parameter) => ({
|
|
410
482
|
...parameter,
|
|
411
|
-
type: extractRealInterfaceType(
|
|
412
|
-
parameter.type.type,
|
|
413
|
-
parameter.type
|
|
414
|
-
),
|
|
483
|
+
type: extractRealInterfaceType(parameter.type),
|
|
415
484
|
})),
|
|
416
|
-
type: extractRealInterfaceType(child.type
|
|
485
|
+
type: extractRealInterfaceType(child.type),
|
|
417
486
|
required: !get(child, ["flags", "isOptional"], false),
|
|
418
487
|
description: get(child, ["comment", "shortText"], "").trim(),
|
|
419
488
|
};
|
|
@@ -458,12 +527,25 @@ function traverseElementUsedInterfaceIds(
|
|
|
458
527
|
traversedTypeSet
|
|
459
528
|
) {
|
|
460
529
|
element.children.forEach((child) => {
|
|
461
|
-
|
|
462
|
-
child.
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
530
|
+
if (child.kindString === "Method") {
|
|
531
|
+
child.signatures[0].parameters?.map((parameter) =>
|
|
532
|
+
traverseUsedReferenceIdsByType(
|
|
533
|
+
parameter.type,
|
|
534
|
+
usedReferenceIds,
|
|
535
|
+
references,
|
|
536
|
+
traversedTypeSet
|
|
537
|
+
)
|
|
538
|
+
);
|
|
539
|
+
} else {
|
|
540
|
+
const type = getClassChildType(child);
|
|
541
|
+
|
|
542
|
+
traverseUsedReferenceIdsByType(
|
|
543
|
+
type,
|
|
544
|
+
usedReferenceIds,
|
|
545
|
+
references,
|
|
546
|
+
traversedTypeSet
|
|
547
|
+
);
|
|
548
|
+
}
|
|
467
549
|
});
|
|
468
550
|
}
|
|
469
551
|
|
|
@@ -572,6 +654,43 @@ function traverseUsedReferenceIdsByType(
|
|
|
572
654
|
traversedTypeSet
|
|
573
655
|
);
|
|
574
656
|
break;
|
|
657
|
+
case "reflection":
|
|
658
|
+
if (type.declaration) {
|
|
659
|
+
const { signatures, children, indexSignature } = type.declaration;
|
|
660
|
+
|
|
661
|
+
signatures?.forEach((signature) => {
|
|
662
|
+
signature.parameters?.forEach((parameter) =>
|
|
663
|
+
traverseUsedReferenceIdsByType(
|
|
664
|
+
parameter.type,
|
|
665
|
+
usedReferenceIds,
|
|
666
|
+
references,
|
|
667
|
+
traversedTypeSet
|
|
668
|
+
)
|
|
669
|
+
);
|
|
670
|
+
traverseUsedReferenceIdsByType(
|
|
671
|
+
signature.type,
|
|
672
|
+
usedReferenceIds,
|
|
673
|
+
references,
|
|
674
|
+
traversedTypeSet
|
|
675
|
+
);
|
|
676
|
+
});
|
|
677
|
+
children?.forEach((child) => {
|
|
678
|
+
traverseUsedReferenceIdsByType(
|
|
679
|
+
child.type,
|
|
680
|
+
usedReferenceIds,
|
|
681
|
+
references,
|
|
682
|
+
traversedTypeSet
|
|
683
|
+
);
|
|
684
|
+
});
|
|
685
|
+
indexSignature?.forEach((item) => {
|
|
686
|
+
traverseUsedReferenceIdsByType(
|
|
687
|
+
item.type,
|
|
688
|
+
usedReferenceIds,
|
|
689
|
+
references,
|
|
690
|
+
traversedTypeSet
|
|
691
|
+
);
|
|
692
|
+
});
|
|
693
|
+
}
|
|
575
694
|
}
|
|
576
695
|
}
|
|
577
696
|
|