Skip to content

Commit

Permalink
fix: revert node v20 & upgrade deps
Browse files Browse the repository at this point in the history
it reverts the following commits:
* 76601d6
* 9c480a2
* 4a5cccd

it reopen the issue: #205

fixes #212
  • Loading branch information
aladdin-add committed May 17, 2024
1 parent b818e1b commit 063937c
Show file tree
Hide file tree
Showing 21 changed files with 6,087 additions and 15,403 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'
- name: Install dependencies
run: npm install
- name: Lint files
Expand All @@ -25,11 +25,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [16.x]
node: [20.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
Expand Down
21,316 changes: 5,996 additions & 15,320 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"moment": "^2.29.4",
"moment-timezone": "^0.5.35",
"probot": "^7.4.0",
"probot": "^9.15.1",
"probot-scheduler": "^1.0.3"
},
"devDependencies": {
Expand All @@ -33,7 +33,7 @@
"globals": "^13.24.0",
"jest": "^26.1.0",
"lint-staged": "^13.2.1",
"nock": "^10.0.2",
"nock": "^13.5.4",
"yorkie": "^2.0.0"
},
"keywords": [
Expand All @@ -55,6 +55,7 @@
"testEnvironment": "node"
},
"engines": {
"node": "16.x"
"node": "20.x",
"npm": "10.x"
}
}
13 changes: 6 additions & 7 deletions src/plugins/auto-closer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const AUTO_CLOSE_LABEL = "auto closed";
*/
async function hasAutoCloseLabel(context) {
const allLabels = await context.github.paginate(
context.github.issues.listLabelsForRepo(context.repo()),
res => res.data
context.github.issues.listLabelsForRepo.endpoint.merge(context.repo())
);

return allLabels.some(label => label.name === AUTO_CLOSE_LABEL);
Expand Down Expand Up @@ -160,9 +159,9 @@ a message to our [mailing list](https://groups.google.com/group/eslint) or
*/
async function closeIssue(context, issueNum, commentText) {
await Promise.all([
context.github.issues.update(context.repo({ number: issueNum, state: "closed" })),
context.github.issues.addLabels(context.repo({ number: issueNum, labels: [AUTO_CLOSE_LABEL] })),
context.github.issues.createComment(context.repo({ number: issueNum, body: commentText }))
context.github.issues.update(context.repo({ issue_number: issueNum, state: "closed" })),
context.github.issues.addLabels(context.repo({ issue_number: issueNum, labels: [AUTO_CLOSE_LABEL] })),
context.github.issues.createComment(context.repo({ issue_number: issueNum, body: commentText }))
]);
}

Expand All @@ -174,8 +173,8 @@ async function closeIssue(context, issueNum, commentText) {
*/
function queryIssues(context, searchQuery) {
return context.github.paginate(
context.github.search.issues({ q: searchQuery, per_page: 100 }),
result => result.data.items
context.github.search.issuesAndPullRequests.endpoint.merge({ q: searchQuery, per_page: 100 }),
result => result.data
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/check-unit-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function action(context) {
const { payload, github } = context;

if (!isChoreTypePullRequest(payload.pull_request.title)) {
const { data: allFiles } = await github.pullRequests.listFiles(context.issue());
const { data: allFiles } = await github.pulls.listFiles(context.issue());

if (!areUnitTestFilesPresent(allFiles, payload.repository.html_url)) {
await github.issues.createComment(context.issue({
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/commit-message/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async function processCommitMessage(context) {
return;
}

const allCommits = await github.pullRequests.listCommits(context.issue());
const allCommits = await github.pulls.listCommits(context.issue());
const messageToCheck = payload.pull_request.title;
const errors = getCommitMessageErrors(messageToCheck);
let description;
Expand All @@ -126,7 +126,7 @@ async function processCommitMessage(context) {
// create status on the last commit
await github.repos.createStatus(
context.repo({
sha: allCommits.data[allCommits.data.length - 1].sha,
sha: allCommits.data.at(-1).sha,
state,
target_url: "https://github.com/eslint/eslint-github-bot/blob/main/docs/commit-message-check.md",
description,
Expand Down
11 changes: 5 additions & 6 deletions src/plugins/issue-archiver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const ARCHIVED_LABEL = "archived due to age";
*/
async function hasArchivedLabel(context) {
const allLabels = await context.github.paginate(
context.github.issues.listLabelsForRepo(context.repo()),
res => res.data
context.github.issues.listLabelsForRepo.endpoint.merge(context.repo())
);

return allLabels.some(label => label.name === ARCHIVED_LABEL);
Expand Down Expand Up @@ -49,8 +48,8 @@ function createSearchQuery({ owner, repo }) {
*/
async function archiveIssue(context, issueNum) {
await Promise.all([
context.github.issues.lock(context.repo({ number: issueNum })),
context.github.issues.addLabels(context.repo({ number: issueNum, labels: [ARCHIVED_LABEL] }))
context.github.issues.lock(context.repo({ issue_number: issueNum })),
context.github.issues.addLabels(context.repo({ issue_number: issueNum, labels: [ARCHIVED_LABEL] }))
]);
}

Expand All @@ -63,8 +62,8 @@ async function getAllSearchResults(context) {
const searchQuery = createSearchQuery(context.repo());

return context.github.paginate(
context.github.search.issues({ q: searchQuery, per_page: 100 }),
result => result.data.items
context.github.search.issues.endpoint.merge({ q: searchQuery, per_page: 100 }),
result => result.data

/*
* Do not label issues which are already locked.
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/pr-ready-to-merge/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function addPrApprovedLabel(context) {
* @returns {Promise<Object | null>} Promise that fulfills when the action is complete
*/
async function getPullrequestBySha(context, sha) {
const { data: { items } } = await context.github.search.issues({
const { data: { items } } = await context.github.search.issuesAndPullRequests({
q: sha
});

Expand All @@ -59,8 +59,8 @@ async function getPullrequestBySha(context, sha) {
* @returns {Promise<Array>} Resolves with commit collection
*/
async function getAllCommitsByPR(context, prId) {
const { data: commits } = await context.github.pullRequests.getCommits(context.repo({
number: prId
const { data: commits } = await context.github.pulls.getCommits(context.repo({
pull_number: prId
}));

return commits;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/pr-ready-to-merge/reviewCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const { getPullrequestBySha, labels } = require("./common");
* @returns {Promise<Array>} Resolves with all reviews collection
*/
async function getAllReviewsByPR(context, prId) {
const { data: allReviews } = await context.github.pullRequests.getReviews(context.repo({
number: prId
const { data: allReviews } = await context.github.pulls.getReviews(context.repo({
pull_number: prId
}));

return allReviews;
Expand Down
14 changes: 12 additions & 2 deletions src/plugins/recurring-issues/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ Resources:
*/
async function getTeamMembers({ github, organizationName, teamName }) {

/**
* TODO: use getByUsername (`github.users.getById()` has been removed since @octokit/rest v16+)
* Gets the name of a user by their userid
* @param {number} id user id to get the name of
* @returns {Promise<string>} the user's name
*/
function getById(id) {
return github.request(`GET /user/${id}`).then(res => res.data.name);
}

/*
* NOTE: This will fail if the organization contains more than 100 teams. This isn't
* close to being a problem right now, so it hasn't been worth figuring out a good
Expand All @@ -93,7 +103,7 @@ async function getTeamMembers({ github, organizationName, teamName }) {

return Promise.all(teamMembers.map(async member => ({
login: member.login,
name: await github.users.getById({ id: member.id }).then(res => res.data.name)
name: await getById(member.id)
})));
}

Expand Down Expand Up @@ -166,7 +176,7 @@ async function issueWasClosedMultipleTimes(github, { owner, repo, number }) {
const issueEvents = await github.issues.listEvents({
owner,
repo,
number,
issue_number: number,
per_page: 100
}).then(res => res.data);

Expand Down
11 changes: 5 additions & 6 deletions src/plugins/release-monitor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function isMessageValidForPatchRelease(message) {
* @private
*/
function pluckLatestCommitSha(allCommits) {
return allCommits[allCommits.length - 1].sha;
return allCommits.at(-1).sha;
}

/**
Expand All @@ -37,12 +37,11 @@ function pluckLatestCommitSha(allCommits) {
*/
function getAllOpenPRs(context) {
return context.github.paginate(
context.github.pullRequests.list(
context.github.pulls.list.endpoint.merge(
context.repo({
state: "open"
})
),
res => res.data
)
);
}

Expand Down Expand Up @@ -78,8 +77,8 @@ function createStatusOnPR({ context, state, sha, description, targetUrl }) {
* @private
*/
async function getAllCommitsForPR({ context, pr }) {
const { data: commitList } = await context.github.pullRequests.listCommits(
context.repo({ number: pr.number })
const { data: commitList } = await context.github.pulls.listCommits(
context.repo({ pull_number: pr.number })
);

return commitList;
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/wip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function maybeResolveWipStatusOnPR(context, sha) {
let statusCheckExists = false;

await context.github.paginate(
context.github.repos.getCombinedStatusForRef(repoAndRef),
context.github.repos.getCombinedStatusForRef.endpoint.merge(repoAndRef),
(res, done) => {
for (const status of res.data.statuses) {
if (status.context === "wip") {
Expand All @@ -105,8 +105,8 @@ async function maybeResolveWipStatusOnPR(context, sha) {
* @private
*/
async function getAllCommitsForPR({ context, pr }) {
const { data: commitList } = await context.github.pullRequests.listCommits(
context.repo({ number: pr.number })
const { data: commitList } = await context.github.pulls.listCommits(
context.repo({ pull_number: pr.number })
);

return commitList;
Expand All @@ -129,7 +129,7 @@ function hasDoNotMergeLabel(labels) {
* @private
*/
function pluckLatestCommitSha(allCommits) {
return allCommits[allCommits.length - 1].sha;
return allCommits.at(-1).sha;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/plugins/auto-closer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// Requirements
//-----------------------------------------------------------------------------

const { autoCloser } = require("../../../src/plugins/index");
const autoCloser = require("../../../src/plugins/auto-closer/index.js");

const nock = require("nock");
const probot = require("probot");
const GitHubApi = require("@octokit/rest");
const GitHubApi = require("@octokit/rest").Octokit;

//-----------------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -101,8 +101,8 @@ describe("auto-closer", () => {
beforeEach(async () => {
githubNock = nock("https://api.github.com");
bot = new probot.Application({
id: "test",
cert: "test",
id: 110,
githubToken: "test",
cache: {
wrap: () => Promise.resolve({ data: { token: "test" } })
},
Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/check-unit-test/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";

const { checkUnitTest } = require("../../../src/plugins/index");
const checkUnitTest = require("../../../src/plugins/check-unit-test/index.js");
const nock = require("nock");
const probot = require("probot");
const GitHubApi = require("@octokit/rest");
const GitHubApi = require("@octokit/rest").Octokit;

/**
* Mocks a given PR on issue existing with specified files
Expand Down
8 changes: 4 additions & 4 deletions tests/plugins/commit-message/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";

const { commitMessage } = require("../../../src/plugins/index");
const commitMessage = require("../../../src/plugins/commit-message/index.js");
const { TAG_LABELS } = require("../../../src/plugins/commit-message/util");
const nock = require("nock");
const probot = require("probot");
const GitHubApi = require("@octokit/rest");
const GitHubApi = require("@octokit/rest").Octokit;

/**
* Mocks a given commit on a PR with the specified message
Expand Down Expand Up @@ -98,8 +98,8 @@ describe("commit-message", () => {

beforeAll(() => {
bot = new probot.Application({
id: "test",
cert: "test",
id: 110,
githubToken: "test",
cache: {
wrap: () => Promise.resolve({ data: { token: "test" } })
}
Expand Down
8 changes: 4 additions & 4 deletions tests/plugins/duplicate-comments/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";

const { duplicateComments } = require("../../../src/plugins/index");
const duplicateComments = require("../../../src/plugins/duplicate-comments/index.js");
const nock = require("nock");
const probot = require("probot");
const GitHubApi = require("@octokit/rest");
const GitHubApi = require("@octokit/rest").Octokit;

/**
* Creates a mock PR with the given comments
Expand Down Expand Up @@ -85,8 +85,8 @@ describe("duplicate-comments", () => {

beforeAll(() => {
bot = new probot.Application({
id: "test",
cert: "test",
id: 110,
githubToken: "test",
cache: {
wrap: () => Promise.resolve({ data: { token: "test" } })
}
Expand Down
8 changes: 4 additions & 4 deletions tests/plugins/issue-archiver/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"use strict";

const { issueArchiver } = require("../../../src/plugins/index");
const issueArchiver = require("../../../src/plugins/issue-archiver/index.js");

const nock = require("nock");
const probot = require("probot");
const GitHubApi = require("@octokit/rest");
const GitHubApi = require("@octokit/rest").Octokit;

describe("issue-archiver", () => {
let bot;

beforeEach(async () => {
bot = new probot.Application({
id: "test",
cert: "test",
id: 110,
githubToken: "test",
cache: {
wrap: () => Promise.resolve({ data: { token: "test" } })
},
Expand Down
Loading

0 comments on commit 063937c

Please sign in to comment.