@hero-design/snowflake-guard 1.3.4 → 1.3.5

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.
Files changed (2) hide show
  1. package/lib/src/index.js +17 -0
  2. package/package.json +1 -1
package/lib/src/index.js CHANGED
@@ -31,6 +31,7 @@ const SNOWFLAKE_COMMENTS_MOBILE = {
31
31
  'styled-component': 'Please do not use styled-component to customize this component.',
32
32
  };
33
33
  const MOBILE_REPO_NAMES = JSON.parse(process.env.MOBILE_REPO_NAMES || '[]');
34
+ const APPROVED_USER_LIST = JSON.parse(process.env.APPROVED_USER_LIST || '[]');
34
35
  const checkIfDetectedSnowflakesInDiff = (diffLocs, locToComment) => {
35
36
  const locIdx = diffLocs.findIndex(([start, end]) => {
36
37
  return locToComment >= start && locToComment <= end;
@@ -155,4 +156,20 @@ module.exports = (app) => {
155
156
  yield context.octokit.checks.create(Object.assign(Object.assign({}, repoInfo), { name: 'SnowflakeGuard/Check', head_sha: context.payload.pull_request.head.sha, status: 'completed', conclusion: 'failure' }));
156
157
  return context.octokit.pulls.createReview(Object.assign(Object.assign({}, repoInfo), { pull_number: prNumber, commit_id: context.payload.pull_request.head.sha, event: 'COMMENT', body: 'Snowflake Guard Bot has detected some snowflakes in this PR. Please review the following comments.', comments: snowflakeComments }));
157
158
  }));
159
+ app.on('pull_request_review.submitted', (context) => {
160
+ const submittedType = context.payload.review.state;
161
+ const submittedUser = context.payload.review.user.login;
162
+ if (submittedType !== 'approved' ||
163
+ !APPROVED_USER_LIST.includes(submittedUser)) {
164
+ return;
165
+ }
166
+ return context.octokit.checks.create({
167
+ repo: context.payload.repository.name,
168
+ owner: context.payload.repository.owner.login,
169
+ name: 'SnowflakeGuard/Check',
170
+ head_sha: context.payload.pull_request.head.sha,
171
+ status: 'completed',
172
+ conclusion: 'success',
173
+ });
174
+ });
158
175
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/snowflake-guard",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "A hero-design bot detecting snowflake usage",
5
5
  "author": "Hau Dao",
6
6
  "license": "ISC",