wuffle 0.71.0 → 0.72.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019-present Nico Rehwaldt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -63,13 +63,15 @@ export function filterUser(user) {
63
63
  const {
64
64
  login,
65
65
  avatar_url,
66
- html_url
66
+ html_url,
67
+ type
67
68
  } = user;
68
69
 
69
70
  return {
70
71
  login,
71
72
  avatar_url,
72
- html_url
73
+ html_url,
74
+ type
73
75
  };
74
76
  }
75
77
 
@@ -138,13 +140,15 @@ export function filterReview(review) {
138
140
  const {
139
141
  state,
140
142
  user,
141
- html_url
143
+ html_url,
144
+ author_association
142
145
  } = review;
143
146
 
144
147
  return {
145
148
  state,
146
149
  html_url,
147
- user: filterUser(user)
150
+ user: filterUser(user),
151
+ author_association
148
152
  };
149
153
  }
150
154
 
@@ -173,7 +177,8 @@ export function filterPull(pullRequest) {
173
177
  order,
174
178
  column,
175
179
  check_runs = [],
176
- statuses = []
180
+ statuses = [],
181
+ author_association
177
182
  } = pullRequest;
178
183
 
179
184
  return {
@@ -198,7 +203,8 @@ export function filterPull(pullRequest) {
198
203
  order,
199
204
  column,
200
205
  statuses: statuses.map(filterStatus),
201
- check_runs: check_runs.map(filterCheckRun)
206
+ check_runs: check_runs.map(filterCheckRun),
207
+ author_association
202
208
  };
203
209
  }
204
210
 
@@ -222,7 +228,8 @@ export function filterIssue(issue) {
222
228
  comments = [],
223
229
  links = [],
224
230
  order,
225
- column
231
+ column,
232
+ author_association
226
233
  } = issue;
227
234
 
228
235
  return {
@@ -242,7 +249,8 @@ export function filterIssue(issue) {
242
249
  html_url,
243
250
  links: links.map(filterLink),
244
251
  order,
245
- column
252
+ column,
253
+ author_association
246
254
  };
247
255
 
248
256
  }
@@ -117,7 +117,8 @@ function filterReview(review) {
117
117
  submitted_at,
118
118
  state,
119
119
  user,
120
- html_url
120
+ html_url,
121
+ author_association
121
122
  } = review;
122
123
 
123
124
  return {
@@ -128,6 +129,7 @@ function filterReview(review) {
128
129
  submitted_at,
129
130
  state: state.toLowerCase(),
130
131
  user: filterUser(user),
131
- html_url
132
+ html_url,
133
+ author_association
132
134
  };
133
135
  }
@@ -8,7 +8,7 @@ const CHILD_LINK_TYPES = {
8
8
  };
9
9
 
10
10
  /**
11
- * @typedef { { defaultFilter?: string } } SearchConfig
11
+ * @typedef { { defaultFilter?: string, treatBotsAsReviewers?: boolean } } SearchConfig
12
12
  * @typedef { import('../../util/search.js').SearchTerm } SearchTerm
13
13
  *
14
14
  * @typedef { import('../../types.js').GitHubUser } GitHubUser
@@ -31,6 +31,10 @@ export default function Search(config, logger, store) {
31
31
  name: 'wuffle:search'
32
32
  });
33
33
 
34
+ const {
35
+ treatBotsAsReviewers = false
36
+ } = config;
37
+
34
38
  function filterNoop(issue) {
35
39
  return true;
36
40
  }
@@ -67,12 +71,46 @@ export default function Search(config, logger, store) {
67
71
  return issue.pull_request;
68
72
  }
69
73
 
74
+ function isValidReview(review) {
75
+
76
+ const {
77
+ user,
78
+ author_association
79
+ } = review;
80
+
81
+ if (!user) {
82
+ return false;
83
+ }
84
+
85
+ if (user.type === 'Bot') {
86
+ return treatBotsAsReviewers;
87
+ }
88
+
89
+ // backwards compatibility - we did not have that
90
+ // data stored previously
91
+ return author_association ? [ 'COLLABORATOR', 'MEMBER', 'OWNER' ].includes(author_association) : true;
92
+ }
93
+
94
+ function getEffectiveReviews(reviews) {
95
+ const byReviewer = new Map();
96
+
97
+ for (const review of reviews) {
98
+ if (review.state === 'commented' || !isValidReview(review)) continue;
99
+
100
+ byReviewer.set(review.user?.login, review);
101
+ }
102
+
103
+ return [ ...byReviewer.values() ];
104
+ }
105
+
70
106
  function isApproved(issue) {
71
- return (issue.reviews || []).some(r => r.state === 'approved');
107
+ return getEffectiveReviews(issue.reviews || []).some(
108
+ r => r.state === 'approved'
109
+ );
72
110
  }
73
111
 
74
112
  function isReviewed(issue) {
75
- return (issue.reviews || []).length > 0;
113
+ return getEffectiveReviews(issue.reviews || []).length > 0;
76
114
  }
77
115
 
78
116
  const filters = {
@@ -158,6 +196,10 @@ export default function Search(config, logger, store) {
158
196
 
159
197
  return !links || !links.some(link => CHILD_LINK_TYPES[link.type]);
160
198
  };
199
+ case 'referenced':
200
+ return function filterReferenced(issue) {
201
+ return (issue.links || []).length > 0;
202
+ };
161
203
  default:
162
204
  return filterNoop;
163
205
  }
@@ -286,7 +328,29 @@ export default function Search(config, logger, store) {
286
328
  return function filterCreated(issue) {
287
329
  return matchTemporal(issue.updated_at);
288
330
  };
289
- })
331
+ }),
332
+
333
+ 'or': function orFilter(value, _exact, user) {
334
+
335
+ const childTerms = /** @type {SearchTerm[]} */ (value);
336
+
337
+ const filterFns = childTerms.map(childTerm => buildTermFn(childTerm, user));
338
+
339
+ return (issue) => filterFns.some(
340
+ filterFn => filterFn(issue)
341
+ );
342
+ },
343
+
344
+ 'and': function andFilter(value, _exact, user) {
345
+
346
+ const childTerms = /** @type {SearchTerm[]} */ (value);
347
+
348
+ const filterFns = childTerms.map(childTerm => buildTermFn(childTerm, user));
349
+
350
+ return (issue) => filterFns.every(
351
+ filterFn => filterFn(issue)
352
+ );
353
+ }
290
354
  };
291
355
 
292
356
  function temporalFilter(fn) {
@@ -339,19 +403,6 @@ export default function Search(config, logger, store) {
339
403
 
340
404
  const wrap = (fn) => negated ? ((issue) => !fn(issue)) : fn;
341
405
 
342
- if ([ 'or', 'and' ].includes(qualifier)) {
343
-
344
- const childTerms = /** @type {SearchTerm[]} */ (value);
345
-
346
- const filterFns = childTerms.map(childTerm => buildTermFn(childTerm, user));
347
-
348
- return wrap(
349
- (issue) => filterFns[qualifier === 'or' ? 'some' : 'every'](
350
- filterFn => filterFn(issue)
351
- )
352
- );
353
- }
354
-
355
406
  if (!value) {
356
407
  return noopFilter();
357
408
  }
@@ -371,7 +422,7 @@ export default function Search(config, logger, store) {
371
422
  return noopFilter();
372
423
  }
373
424
 
374
- return wrap(factoryFn(value, exact));
425
+ return wrap(factoryFn(value, exact, user));
375
426
  }
376
427
 
377
428
  function buildFilterFn(search, user) {
package/lib/filters.js CHANGED
@@ -47,7 +47,8 @@ export function filterUser(githubUser) {
47
47
  node_id,
48
48
  login,
49
49
  avatar_url,
50
- html_url
50
+ html_url,
51
+ type
51
52
  } = githubUser;
52
53
 
53
54
  return {
@@ -55,7 +56,8 @@ export function filterUser(githubUser) {
55
56
  node_id,
56
57
  login,
57
58
  avatar_url,
58
- html_url
59
+ html_url,
60
+ type
59
61
  };
60
62
  }
61
63
 
@@ -147,7 +149,8 @@ export function filterPull(githubPull, githubRepository) {
147
149
  additions,
148
150
  deletions,
149
151
  changed_files,
150
- html_url
152
+ html_url,
153
+ author_association
151
154
  } = githubPull;
152
155
 
153
156
  // stable ID that is independent from GitHubs internal issue/pr distinction
@@ -187,7 +190,8 @@ export function filterPull(githubPull, githubRepository) {
187
190
  changed_files,
188
191
  pull_request: true,
189
192
  repository: filterRepository(githubRepository),
190
- html_url
193
+ html_url,
194
+ author_association
191
195
  };
192
196
  }
193
197
 
@@ -209,7 +213,8 @@ export function filterIssue(githubIssue, githubRepository) {
209
213
  labels,
210
214
  milestone,
211
215
  pull_request,
212
- html_url
216
+ html_url,
217
+ author_association
213
218
  } = githubIssue;
214
219
 
215
220
  // stable ID that is independent from GitHubs internal issue/pr distinction
@@ -239,7 +244,8 @@ export function filterIssue(githubIssue, githubRepository) {
239
244
  milestone: milestone ? filterMilestone(milestone) : null,
240
245
  repository: filterRepository(githubRepository),
241
246
  pull_request: !!pull_request,
242
- html_url
247
+ html_url,
248
+ author_association
243
249
  };
244
250
 
245
251
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "wuffle",
3
- "version": "0.71.0",
3
+ "version": "0.72.0",
4
4
  "description": "A multi-repository task board for GitHub issues",
5
5
  "author": {
6
6
  "name": "Nico Rehwaldt",
7
7
  "url": "https://github.com/nikku"
8
8
  },
9
9
  "bin": {
10
- "wuffle": "./bin/wuffle"
10
+ "wuffle": "bin/wuffle"
11
11
  },
12
12
  "exports": {
13
13
  ".": "./index.js",
@@ -19,7 +19,7 @@
19
19
  "homepage": "https://github.com/nikku/wuffle",
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "https://github.com/nikku/wuffle.git",
22
+ "url": "git+https://github.com/nikku/wuffle.git",
23
23
  "directory": "packages/app"
24
24
  },
25
25
  "keywords": [
@@ -48,7 +48,7 @@
48
48
  "compression": "^1.8.1",
49
49
  "express-session": "^1.19.0",
50
50
  "fake-tag": "^5.0.0",
51
- "memorystore": "^1.6.7",
51
+ "memorystore": "^1.6.8",
52
52
  "min-dash": "^5.0.0",
53
53
  "p-defer": "^4.0.1",
54
54
  "prexit": "^2.3.0",
@@ -81,5 +81,6 @@
81
81
  "app.yml",
82
82
  "index.js",
83
83
  "wuffle.config.example.js"
84
- ]
84
+ ],
85
+ "gitHead": "f42a56e87fb1f6d3f06ef5e9215c5e0b91544c0b"
85
86
  }