Skip to content

Commit f086186

Browse files
authored
chore: Upgrade dependencies (#57)
* upgrade easy dependencies * ⬆️ probot 7.5 * ⬆️ probot 9.0 * ⬆️ probot 9.2.20 * 👕 lint
1 parent 4009e9c commit f086186

File tree

7 files changed

+760
-583
lines changed

7 files changed

+760
-583
lines changed

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"start": "probot run ./src/index.js",
88
"lint": "standard --fix",
9-
"test": "jest && standard",
9+
"test": "jest",
10+
"posttest": "standard",
1011
"test:fix": "jest --updateSnapshot && standard --fix"
1112
},
1213
"repository": {
@@ -27,13 +28,13 @@
2728
"collectCoverage": true
2829
},
2930
"dependencies": {
30-
"commonmark": "^0.28.1",
31-
"probot": "^6.1.0"
31+
"commonmark": "^0.29.0",
32+
"probot": "^9.2.20"
3233
},
3334
"devDependencies": {
3435
"jest": "^24.8.0",
3536
"nock": "^10.0.6",
36-
"smee-client": "^1.0.1",
37-
"standard": "^11.0.1"
37+
"smee-client": "^1.1.0",
38+
"standard": "^13.1.0"
3839
}
3940
}

src/commands.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ module.exports = [
128128
ruleMatcher: async function (logger, context, ruleArgs) {
129129
// See https://developer.github.com/v3/activity/events/types/#pullrequestreviewevent
130130
// Check if there are any Pending or Rejected reviews and ensure there is at least one Accepted one
131-
const {data: reviews} = await context.github.pullRequests.getReviews(context.issue())
131+
const issue = context.issue()
132+
const { data: reviews } = await context.github.pullRequests.listReviews({ owner: issue.owner, repo: issue.repo, pull_number: issue.number })
132133
// Check that there is at least one Accepted
133134
const hasAccepted = reviews.filter((review) => review.state === 'APPROVED').length >= 1
134135
const hasRejections = reviews.filter((review) => review.state === 'REQUEST_CHANGES').length >= 1

src/extract-rules.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function parseMarkdown (card) {
2020
const parsedRules = []
2121
let walkEvent
2222
while ((walkEvent = walker.next())) {
23-
const {node} = walkEvent
23+
const { node } = walkEvent
2424
// Each item should be simple text that contains the rule, followed by a space,
2525
// followed by any arguments (sometimes wrapped in spaces)
2626
if (walkEvent.entering && node.type === 'code') {
@@ -38,7 +38,7 @@ function parseMarkdown (card) {
3838
if (args.length === 0 && node.next && node.next.literal) {
3939
args = node.next.literal.trim().split(' ').map((arg) => arg.trim())
4040
}
41-
parsedRules.push({ruleName: node.literal, ruleArgs: args})
41+
parsedRules.push({ ruleName: node.literal, ruleArgs: args })
4242
}
4343
}
4444
}
@@ -54,15 +54,15 @@ module.exports = function extractAutomationRules (projects) {
5454
projects.forEach((project) => {
5555
project.columns.nodes.forEach((column) => {
5656
column.firstCards.nodes.forEach((card) => {
57-
allCards.set(card.id, {card, column})
57+
allCards.set(card.id, { card, column })
5858
})
5959
column.lastCards.nodes.forEach((card) => {
60-
allCards.set(card.id, {card, column})
60+
allCards.set(card.id, { card, column })
6161
})
6262
})
6363
})
6464

65-
allCards.forEach(({card, column}) => {
65+
allCards.forEach(({ card, column }) => {
6666
const rules = parseMarkdown(card)
6767
rules.forEach((r) => {
6868
automationRules.push({

src/index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ async function sleep (ms) {
1212
// Often, there is a delay between the webhook firing and GaphQL updating
1313
async function retryQuery (context, query, args) {
1414
try {
15-
return await context.github.query(query, args)
15+
return await context.github.graphql(query, args)
1616
} catch (err) {
1717
await sleep(1000)
18-
return context.github.query(query, args)
18+
return context.github.graphql(query, args)
1919
}
2020
}
2121

@@ -49,14 +49,14 @@ const PROJECT_FRAGMENT = `
4949
`
5050

5151
module.exports = (robot) => {
52-
const logger = robot.log.child({name: 'project-bot'})
52+
const logger = robot.log.child({ name: 'project-bot' })
5353
// Increase the maxListenerCount by the number of automationCommands
5454
// because we register a bunch of listeners
5555
robot.events.setMaxListeners(robot.events.getMaxListeners() + automationCommands.length)
5656
logger.info(`Starting up`)
5757

5858
// Register all of the automation commands
59-
automationCommands.forEach(({createsACard, webhookName, ruleName, ruleMatcher}) => {
59+
automationCommands.forEach(({ createsACard, webhookName, ruleName, ruleMatcher }) => {
6060
logger.trace(`Attaching listener for ${webhookName}`)
6161
robot.on(webhookName, async function (context) {
6262
const issueUrl = context.payload.issue ? context.payload.issue.html_url : context.payload.pull_request.html_url.replace('/pull/', '/issues/')
@@ -92,8 +92,8 @@ module.exports = (robot) => {
9292
}
9393
}
9494
}
95-
`, {issueUrl: issueUrl})
96-
const {resource} = graphResult
95+
`, { issueUrl: issueUrl })
96+
const { resource } = graphResult
9797

9898
let allProjects = []
9999
if (resource.repository.owner.projects) {
@@ -105,25 +105,25 @@ module.exports = (robot) => {
105105
}
106106

107107
// Loop through all of the Automation Cards and see if any match
108-
const automationRules = extractAutomationRules(allProjects).filter(({ruleName: rn}) => rn === ruleName)
108+
const automationRules = extractAutomationRules(allProjects).filter(({ ruleName: rn }) => rn === ruleName)
109109

110-
for (const {column, ruleArgs} of automationRules) {
110+
for (const { column, ruleArgs } of automationRules) {
111111
if (await ruleMatcher(logger, context, ruleArgs)) {
112112
logger.info(`Creating Card for "${issueUrl}" to column ${column.id} because of "${ruleName}" and value: "${ruleArgs}"`)
113-
await context.github.query(`
113+
await context.github.graphql(`
114114
mutation createCard($contentId: ID!, $columnId: ID!) {
115115
addProjectCard(input: {contentId: $contentId, projectColumnId: $columnId}) {
116116
clientMutationId
117117
}
118118
}
119-
`, {contentId: resource.id, columnId: column.id})
119+
`, { contentId: resource.id, columnId: column.id })
120120
}
121121
}
122122
} else {
123123
// Check if we need to move the Issue (or Pull request)
124124
const graphResult = await retryQuery(context, `
125-
query getCardAndColumnAutomationCards($url: URI!) {
126-
resource(url: $url) {
125+
query getCardAndColumnAutomationCards($issueUrl: URI!) {
126+
resource(url: $issueUrl) {
127127
... on Issue {
128128
projectCards(first: 10) {
129129
nodes {
@@ -141,28 +141,28 @@ module.exports = (robot) => {
141141
}
142142
}
143143
}
144-
`, {url: issueUrl})
144+
`, { issueUrl: issueUrl })
145145
logger.debug(graphResult, 'Retrieved results')
146-
const {resource} = graphResult
146+
const { resource } = graphResult
147147
// sometimes there are no projectCards
148148
if (!resource.projectCards) {
149149
logger.error(issueUrl, resource, 'Not even an array for project cards. Odd')
150150
}
151151
const cardsForIssue = resource.projectCards ? resource.projectCards.nodes : []
152152

153153
for (const issueCard of cardsForIssue) {
154-
const automationRules = extractAutomationRules([issueCard.project]).filter(({ruleName: rn}) => rn === ruleName)
154+
const automationRules = extractAutomationRules([issueCard.project]).filter(({ ruleName: rn }) => rn === ruleName)
155155

156-
for (const {column, ruleArgs} of automationRules) {
156+
for (const { column, ruleArgs } of automationRules) {
157157
if (await ruleMatcher(logger, context, ruleArgs)) {
158158
logger.info(`Moving Card ${issueCard.id} for "${issueUrl}" to column ${column.id} because of "${ruleName}" and value: "${ruleArgs}"`)
159-
await context.github.query(`
159+
await context.github.graphql(`
160160
mutation moveCard($cardId: ID!, $columnId: ID!) {
161161
moveProjectCard(input: {cardId: $cardId, columnId: $columnId}) {
162162
clientMutationId
163163
}
164164
}
165-
`, {cardId: issueCard.id, columnId: column.id})
165+
`, { cardId: issueCard.id, columnId: column.id })
166166
}
167167
}
168168
}

0 commit comments

Comments
 (0)