@@ -6,101 +6,101 @@ const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
6
6
const { rest, paginate } = new Octokit ( { auth : token } ) ;
7
7
8
8
const now = DateTime . now ( ) ;
9
- const age = ( timestamp ) => now . diff ( DateTime . fromISO ( timestamp ) ) ;
10
9
11
10
( async ( ) => {
12
11
for await ( const { data : issues } of paginate . iterator (
13
12
rest . issues . listForRepo ,
14
13
{ owner, repo }
15
14
) ) {
16
- issues
17
- . filter (
18
- ( { created_at } ) => age ( created_at ) < Duration . fromObject ( { years : 1 } )
19
- )
20
- . forEach ( ( issue ) => {
21
- const { number, created_at, title, pull_request, html_url } = issue ;
22
- const assignee = issue . assignee ?. login ;
15
+ issues . forEach ( ( issue ) => {
16
+ const { number, created_at, title, pull_request, html_url } = issue ;
17
+ const assignee = issue . assignee ?. login ;
23
18
24
- const labels = issue . labels . map ( ( { name } ) => name ) ;
25
- const version = labels . find ( ( name ) => / \d + \. [ \d x ] + \. [ \d x ] + / . test ( name ) ) ;
19
+ const age = now
20
+ . diff ( DateTime . fromISO ( created_at ) )
21
+ . shiftTo ( "years" , "months" , "days" )
22
+ . toHuman ( { maximumFractionDigits : 0 } ) ;
26
23
27
- const triaged = labels . includes ( "triage" ) ;
28
- const help = labels . includes ( "help wanted" ) ;
24
+ const labels = issue . labels . map ( ( { name } ) => name ) ;
25
+ const version = labels . find ( ( name ) => / \d + \. [ \d x ] + \. [ \d x ] + / . test ( name ) ) ;
29
26
30
- const question = labels . includes ( "question " ) ;
31
- const unanswered = labels . includes ( "unanswered " ) ;
27
+ const triage = labels . includes ( "triage " ) ;
28
+ const help = labels . includes ( "help wanted " ) ;
32
29
33
- const directions = labels . filter ( ( i ) =>
34
- [ "bug" , "enhancement" , "question" ] . includes ( i )
35
- ) ;
30
+ const question = labels . includes ( "question" ) ;
31
+ const unanswered = labels . includes ( "unanswered" ) ;
36
32
37
- const problems = [ ] ;
33
+ const directions = labels . filter ( ( i ) =>
34
+ [ "bug" , "enhancement" , "question" ] . includes ( i )
35
+ ) ;
38
36
39
- if ( directions . length === 0 ) {
40
- problems . push ( 'Missing a "bug", "enhancement" or "question" label' ) ;
37
+ const problems = [ ] ;
38
+
39
+ if ( version ) {
40
+ if ( assignee && help ) {
41
+ problems . push (
42
+ 'Should not have both an assignee and a "help wanted" label'
43
+ ) ;
41
44
}
42
45
43
- if ( directions . length > 1 ) {
44
- problems . push ( 'Too many "bug", "enhancement" and "question" labels' ) ;
46
+ if ( ! assignee && ! help ) {
47
+ problems . push ( 'Missing an assignee or a "help wanted" label' ) ;
48
+ }
49
+ } else {
50
+ if ( assignee || help ) {
51
+ problems . push ( "Missing a version label" ) ;
45
52
}
53
+ }
46
54
47
- if ( version ) {
48
- if ( assignee && help ) {
49
- problems . push (
50
- 'Should not have both an assignee and a "help wanted" label'
51
- ) ;
52
- }
53
-
54
- if ( ! assignee && ! help ) {
55
- problems . push ( 'Missing an assignee or a "help wanted" label' ) ;
56
- }
57
- } else {
58
- if ( assignee || help ) {
59
- problems . push ( "Missing a version label" ) ;
60
- }
55
+ if ( pull_request ) {
56
+ if ( triage && version ) {
57
+ problems . push ( 'Should not have both a "triage" and version label' ) ;
61
58
}
62
59
63
- if ( pull_request ) {
64
- if ( triaged && version ) {
65
- problems . push ( 'Should not have both a "triage" and version label' ) ;
66
- }
67
-
68
- if ( ! triaged && ! version ) {
69
- problems . push ( 'Missing a "triage" or version label' ) ;
70
- }
71
- } else {
72
- if ( [ triaged , question , version ] . filter ( ( i ) => i ) . length > 1 ) {
73
- problems . push ( 'Too many "triage", "question" and version labels' ) ;
74
- }
75
-
76
- if ( [ triaged , question , version ] . every ( ( i ) => ! i ) ) {
77
- problems . push ( 'Missing a "triage", "question" or version label' ) ;
78
- }
60
+ if ( ! triage && ! version ) {
61
+ problems . push ( 'Missing a "triage" or version label' ) ;
62
+ }
63
+ } else {
64
+ if ( [ triage , question , version ] . filter ( ( i ) => i ) . length > 1 ) {
65
+ problems . push ( 'Too many "triage", "question" and version labels' ) ;
79
66
}
80
67
81
- if ( problems . length > 0 ) {
82
- console . log ( {
83
- age : age ( created_at )
84
- . shiftTo ( "years" , "months" , "days" )
85
- . toHuman ( { maximumFractionDigits : 0 } ) ,
86
- source : {
87
- id : number ,
88
- title,
89
- url : html_url ,
90
- } ,
91
- problems,
92
- context : {
93
- labels,
94
- assignee,
95
- version,
96
- help_wanted : help ,
97
- triaged,
98
- question,
99
- unanswered,
100
- directions,
101
- } ,
102
- } ) ;
68
+ if ( [ triage , question , version ] . every ( ( i ) => ! i ) ) {
69
+ problems . push ( 'Missing a "triage", "question" or version label' ) ;
70
+ }
71
+ }
72
+
73
+ if ( ! triage ) {
74
+ if ( directions . length === 0 ) {
75
+ problems . push ( 'Missing a "bug", "enhancement" or "question" label' ) ;
76
+ }
77
+
78
+ if ( directions . length > 1 ) {
79
+ problems . push ( 'Too many "bug", "enhancement" and "question" labels' ) ;
103
80
}
104
- } ) ;
81
+ }
82
+
83
+ if ( problems . length > 0 ) {
84
+ console . log ( {
85
+ age,
86
+ source : {
87
+ id : number ,
88
+ title,
89
+ url : html_url ,
90
+ } ,
91
+ problems,
92
+ context : {
93
+ labels,
94
+ assignee,
95
+ version,
96
+ help_wanted : help ,
97
+ triage,
98
+ question,
99
+ unanswered,
100
+ directions,
101
+ } ,
102
+ } ) ;
103
+ }
104
+ } ) ;
105
105
}
106
106
} ) ( ) ;
0 commit comments