@next-core/build-config-factory 2.21.0 → 2.23.2
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 +46 -0
- package/package.json +3 -3
- package/src/generateBrickDocs.js +122 -38
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,52 @@
|
|
|
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.2](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.23.1...@next-core/build-config-factory@2.23.2) (2022-07-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **generateBrickDocs:** support wrapping intersection types ([9dca68d](https://github.com/easyops-cn/next-core/commit/9dca68d14396fec7f250c2ad41ba95464dcc3577))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.23.1](https://github.com/easyops-cn/next-core/compare/@next-core/build-config-factory@2.23.0...@next-core/build-config-factory@2.23.1) (2022-07-12)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @next-core/build-config-factory
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [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)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **generateBrickDocs:** filter inherited properties ([38daaff](https://github.com/easyops-cn/next-core/commit/38daaffa0dcb5c4ef66cc3d846e525db2ea3ba95))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **generateBrickDocs:** support typle types ([148ad87](https://github.com/easyops-cn/next-core/commit/148ad87935a8deac87c69fd4d60828a2aef7723f))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# [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)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* **generateBrickDocs:** support function type ([b085bbf](https://github.com/easyops-cn/next-core/commit/b085bbf089b89dc6e7fa7f743a69731b24ea449a))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
6
52
|
# [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)
|
|
7
53
|
|
|
8
54
|
|
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.2",
|
|
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.22",
|
|
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": "9bbe86c9ce96b4bf283c7ec3cddafaa6617e2601"
|
|
41
41
|
}
|
package/src/generateBrickDocs.js
CHANGED
|
@@ -168,7 +168,7 @@ function composeBrickDocMethods(brick) {
|
|
|
168
168
|
parameter.flags?.isOptional ? "?" : ""
|
|
169
169
|
}: ${extractRealInterfaceType(parameter.type)}`
|
|
170
170
|
)
|
|
171
|
-
.join(" "),
|
|
171
|
+
.join(", "),
|
|
172
172
|
...convertTagsToMapByFields(tags, methodComments),
|
|
173
173
|
};
|
|
174
174
|
}
|
|
@@ -314,6 +314,14 @@ function existBrickDocId(element) {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
function wrapBracketByParentType(typeStr, parentType) {
|
|
318
|
+
return parentType === "array" ||
|
|
319
|
+
parentType === "union" ||
|
|
320
|
+
parentType === "intersection"
|
|
321
|
+
? `(${typeStr})`
|
|
322
|
+
: typeStr;
|
|
323
|
+
}
|
|
324
|
+
|
|
317
325
|
function extractRealInterfaceType(typeData, parentType) {
|
|
318
326
|
switch (typeData?.type) {
|
|
319
327
|
case "reference":
|
|
@@ -336,14 +344,12 @@ function extractRealInterfaceType(typeData, parentType) {
|
|
|
336
344
|
typeData.type
|
|
337
345
|
)}[]`;
|
|
338
346
|
case "union":
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
.map((type) => extractRealInterfaceType(type))
|
|
342
|
-
.join(" | ")
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
.map((type) => extractRealInterfaceType(type))
|
|
346
|
-
.join(" | ");
|
|
347
|
+
return wrapBracketByParentType(
|
|
348
|
+
typeData.types
|
|
349
|
+
.map((type) => extractRealInterfaceType(type, typeData.type))
|
|
350
|
+
.join(" | "),
|
|
351
|
+
parentType
|
|
352
|
+
);
|
|
347
353
|
case "stringLiteral":
|
|
348
354
|
return `"${typeData.value}"`;
|
|
349
355
|
case "intrinsic":
|
|
@@ -351,32 +357,57 @@ function extractRealInterfaceType(typeData, parentType) {
|
|
|
351
357
|
case "unknown": // unknown 暂定是`type`中的数字类型,e.g: type t = 0 | 1 | 'string'
|
|
352
358
|
return typeData.name;
|
|
353
359
|
case "intersection":
|
|
354
|
-
return
|
|
355
|
-
.
|
|
356
|
-
|
|
360
|
+
return wrapBracketByParentType(
|
|
361
|
+
typeData.types
|
|
362
|
+
.map((type) => extractRealInterfaceType(type, typeData.type))
|
|
363
|
+
.join(" & "),
|
|
364
|
+
parentType
|
|
365
|
+
);
|
|
357
366
|
case "reflection": {
|
|
358
367
|
if (typeData.declaration) {
|
|
359
|
-
const {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
)
|
|
374
|
-
|
|
375
|
-
|
|
368
|
+
const {
|
|
369
|
+
signatures,
|
|
370
|
+
children = [],
|
|
371
|
+
indexSignature = [],
|
|
372
|
+
} = typeData.declaration;
|
|
373
|
+
|
|
374
|
+
if (signatures) {
|
|
375
|
+
const { parameters, type } = signatures[0];
|
|
376
|
+
const typeStr = `(${parameters
|
|
377
|
+
?.map(
|
|
378
|
+
(parameter) =>
|
|
379
|
+
`${parameter.name}${
|
|
380
|
+
parameter.flags?.isOptional ? "?" : ""
|
|
381
|
+
}: ${extractRealInterfaceType(parameter.type)}`
|
|
382
|
+
)
|
|
383
|
+
.join(", ")}) => ${extractRealInterfaceType(type)}`;
|
|
384
|
+
|
|
385
|
+
return wrapBracketByParentType(typeStr, parentType);
|
|
386
|
+
} else {
|
|
387
|
+
return `{ ${[
|
|
388
|
+
...children.map(
|
|
389
|
+
(child) =>
|
|
390
|
+
`${child.name}${
|
|
391
|
+
child.flags?.isOptional ? "?" : ""
|
|
392
|
+
}: ${extractRealInterfaceType(child.type)}`
|
|
393
|
+
),
|
|
394
|
+
...indexSignature.map((item) => {
|
|
395
|
+
const parameter = item.parameters[0];
|
|
396
|
+
return `[${parameter.name}: ${extractRealInterfaceType(
|
|
397
|
+
parameter.type.type,
|
|
398
|
+
parameter.type
|
|
399
|
+
)}]: ${extractRealInterfaceType(item.type)}`;
|
|
400
|
+
}),
|
|
401
|
+
].join("; ")} }`;
|
|
402
|
+
}
|
|
376
403
|
} else {
|
|
377
404
|
return "object";
|
|
378
405
|
}
|
|
379
406
|
}
|
|
407
|
+
case "tuple":
|
|
408
|
+
return `[${typeData.elements
|
|
409
|
+
?.map((element) => element.name)
|
|
410
|
+
.join(", ")}]`;
|
|
380
411
|
default:
|
|
381
412
|
return "";
|
|
382
413
|
}
|
|
@@ -446,14 +477,20 @@ function extractBrickDocInterface(typeIds, references) {
|
|
|
446
477
|
extendedTypes: finder.extendedTypes,
|
|
447
478
|
description: finder?.comment?.shortText?.trim(),
|
|
448
479
|
children:
|
|
449
|
-
finder.children
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
480
|
+
finder.children
|
|
481
|
+
?.filter((child) => !child.inheritedFrom)
|
|
482
|
+
.map((child) => {
|
|
483
|
+
return {
|
|
484
|
+
name: child.name,
|
|
485
|
+
type: extractRealInterfaceType(child.type),
|
|
486
|
+
required: !get(child, ["flags", "isOptional"], false),
|
|
487
|
+
description: get(
|
|
488
|
+
child,
|
|
489
|
+
["comment", "shortText"],
|
|
490
|
+
""
|
|
491
|
+
).trim(),
|
|
492
|
+
};
|
|
493
|
+
}) || [],
|
|
457
494
|
indexSignature:
|
|
458
495
|
finder.indexSignature?.map((child) => {
|
|
459
496
|
return {
|
|
@@ -464,7 +501,6 @@ function extractBrickDocInterface(typeIds, references) {
|
|
|
464
501
|
})),
|
|
465
502
|
type: extractRealInterfaceType(child.type),
|
|
466
503
|
required: !get(child, ["flags", "isOptional"], false),
|
|
467
|
-
description: get(child, ["comment", "shortText"], "").trim(),
|
|
468
504
|
};
|
|
469
505
|
}) || [],
|
|
470
506
|
};
|
|
@@ -634,6 +670,54 @@ function traverseUsedReferenceIdsByType(
|
|
|
634
670
|
traversedTypeSet
|
|
635
671
|
);
|
|
636
672
|
break;
|
|
673
|
+
case "reflection":
|
|
674
|
+
if (type.declaration) {
|
|
675
|
+
const { signatures, children, indexSignature } = type.declaration;
|
|
676
|
+
|
|
677
|
+
signatures?.forEach((signature) => {
|
|
678
|
+
signature.parameters?.forEach((parameter) =>
|
|
679
|
+
traverseUsedReferenceIdsByType(
|
|
680
|
+
parameter.type,
|
|
681
|
+
usedReferenceIds,
|
|
682
|
+
references,
|
|
683
|
+
traversedTypeSet
|
|
684
|
+
)
|
|
685
|
+
);
|
|
686
|
+
traverseUsedReferenceIdsByType(
|
|
687
|
+
signature.type,
|
|
688
|
+
usedReferenceIds,
|
|
689
|
+
references,
|
|
690
|
+
traversedTypeSet
|
|
691
|
+
);
|
|
692
|
+
});
|
|
693
|
+
children?.forEach((child) => {
|
|
694
|
+
traverseUsedReferenceIdsByType(
|
|
695
|
+
child.type,
|
|
696
|
+
usedReferenceIds,
|
|
697
|
+
references,
|
|
698
|
+
traversedTypeSet
|
|
699
|
+
);
|
|
700
|
+
});
|
|
701
|
+
indexSignature?.forEach((item) => {
|
|
702
|
+
traverseUsedReferenceIdsByType(
|
|
703
|
+
item.type,
|
|
704
|
+
usedReferenceIds,
|
|
705
|
+
references,
|
|
706
|
+
traversedTypeSet
|
|
707
|
+
);
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
break;
|
|
711
|
+
case "tuple":
|
|
712
|
+
type.elements?.forEach((element) =>
|
|
713
|
+
traverseUsedReferenceIdsByType(
|
|
714
|
+
element,
|
|
715
|
+
usedReferenceIds,
|
|
716
|
+
references,
|
|
717
|
+
traversedTypeSet
|
|
718
|
+
)
|
|
719
|
+
);
|
|
720
|
+
break;
|
|
637
721
|
}
|
|
638
722
|
}
|
|
639
723
|
|