@@ -17,7 +17,8 @@ type StoriesMetadata = Array<{
17
17
| undefined ;
18
18
} > ;
19
19
20
- type AggregatedList = { [ group_name : string ] : Array < { children : string [ ] ; project : string } > } ;
20
+ type GroupedList = { [ group_name : string ] : Array < { children : string [ ] ; project : string } > } ;
21
+ type AggregatedGroupedList = { [ group_name : string ] : { [ project_name : string ] : string [ ] } } ;
21
22
22
23
export async function storiesMapGenerator ( tree : Tree , _options : StoriesMapGeneratorSchema ) {
23
24
const stories = getStoriesMetadata ( tree ) ;
@@ -28,19 +29,20 @@ export async function storiesMapGenerator(tree: Tree, _options: StoriesMapGenera
28
29
writeJson ( tree , '/stories-list.json' , list ) ;
29
30
30
31
const githubIssueOptions = createOptions ( list ) ;
32
+ const yamlList = githubIssueOptions . map ( item => `- ${ item } ` ) . join ( `\n` ) ;
31
33
32
- console . log ( githubIssueOptions ) ;
34
+ console . log ( yamlList ) ;
33
35
34
36
await formatFiles ( tree ) ;
35
37
}
36
38
37
39
export default storiesMapGenerator ;
38
40
39
- function createOptions ( groups : AggregatedList ) {
41
+ function createOptions ( groups : AggregatedGroupedList ) {
40
42
const list : string [ ] = [ ] ;
41
43
const components = { stable : [ ] as string [ ] , preview : [ ] as string [ ] , compat : [ ] as string [ ] } ;
42
44
43
- for ( const [ group , content ] of Object . entries ( groups ) ) {
45
+ for ( const [ group , entry ] of Object . entries ( groups ) ) {
44
46
if ( group === 'Utilities' ) {
45
47
list . push ( group ) ;
46
48
continue ;
@@ -57,42 +59,38 @@ function createOptions(groups: AggregatedList) {
57
59
list . push ( `${ group } /Tokens` ) ;
58
60
continue ;
59
61
}
62
+
63
+ const entriesForList = Object . values ( entry ) . flat ( ) ;
60
64
if ( group === 'Migration Shims' ) {
61
- const item = unique ( content . map ( val => val . children [ 0 ] ) ) . map ( val => ` ${ group } ${ val } ` ) ;
62
- list . push ( ...item ) ;
65
+ const item = entriesForList . filter ( val => / ^ V \d / . exec ( val ) ) ;
66
+ list . push ( ...item . map ( val => ` ${ group } ${ val } ` ) ) ;
63
67
continue ;
64
68
}
65
69
if ( group === 'Components' ) {
66
- const item = unique ( content . map ( val => val . children [ 0 ] ) )
67
- . sort ( )
68
- . map ( val => `${ val } ` ) ;
70
+ const item = entriesForList . filter ( val => val [ 0 ] === val [ 0 ] . toUpperCase ( ) ) . sort ( ) ;
69
71
components . stable . push ( ...item ) ;
70
72
continue ;
71
73
}
72
74
if ( group === 'Compat Components' ) {
73
- const item = unique ( content . map ( val => val . children [ 0 ] ) )
74
- . sort ( )
75
- . map ( val => `${ val } (Compat)` ) ;
75
+ const item = entriesForList . sort ( ) . map ( val => `${ val } (Compat)` ) ;
76
76
components . compat . push ( ...item ) ;
77
77
continue ;
78
78
}
79
79
if ( group === 'Preview Components' ) {
80
- const item = unique ( content . map ( val => val . children [ 0 ] ) )
81
- . sort ( )
82
- . map ( val => `${ val } (Preview)` ) ;
80
+ const item = entriesForList . sort ( ) . map ( val => `${ val } (Preview)` ) ;
83
81
components . preview . push ( ...item ) ;
84
82
continue ;
85
83
}
86
84
}
87
85
88
- list . unshift ( ...components . stable , ...components . preview , ...components . compat ) ;
86
+ list . sort ( ) . unshift ( ...components . stable , ...components . preview , ...components . compat ) ;
89
87
list . push ( 'Other...' ) ;
90
88
91
89
return list ;
92
90
}
93
91
94
92
function generateIssuesOptionList ( tree : Tree , metadata : StoriesMetadata ) {
95
- const groups : AggregatedList = { } ;
93
+ const groups : GroupedList = { } ;
96
94
97
95
for ( const entry of metadata ) {
98
96
if ( ! entry . group ) {
@@ -104,7 +102,29 @@ function generateIssuesOptionList(tree: Tree, metadata: StoriesMetadata) {
104
102
groups [ entry . group . name ] . push ( { project : entry . project . name ! , children : unique ( entry . group . children ) } ) ;
105
103
}
106
104
107
- return groups ;
105
+ const aggregatedGroups = aggregateData ( groups ) ;
106
+
107
+ return aggregatedGroups ;
108
+
109
+ function aggregateData ( input : typeof groups ) : AggregatedGroupedList {
110
+ const output = Object . entries ( input ) . reduce ( ( acc , [ group , entry ] ) => {
111
+ if ( ! acc [ group ] ) {
112
+ acc [ group ] = { } ;
113
+ }
114
+ entry . forEach ( val => {
115
+ if ( ! acc [ group ] [ val . project ] ) {
116
+ acc [ group ] [ val . project ] = [ ] ;
117
+ }
118
+
119
+ acc [ group ] [ val . project ] . push ( ...val . children ) ;
120
+ acc [ group ] [ val . project ] = unique ( acc [ group ] [ val . project ] ) ;
121
+ } ) ;
122
+
123
+ return acc ;
124
+ } , { } as { [ group_name : string ] : { [ project_name : string ] : string [ ] } } ) ;
125
+
126
+ return output ;
127
+ }
108
128
}
109
129
110
130
function getStoriesMetadata ( tree : Tree ) {
0 commit comments