Skip to content

Commit 3461ecf

Browse files
authored
feat: Upgrade to Node 22 (#214)
* fix: Make bot work in Node 22 * feat: Upgrade to Node.js v22 * Update CI script * Remove nock * Fix test failures * Remove octokit/rest * Fix release-monitor tests
1 parent 17c2205 commit 3461ecf

File tree

29 files changed

+7381
-11331
lines changed

29 files changed

+7381
-11331
lines changed

Diff for: .github/workflows/ci.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
name: Lint
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
- name: Setup Node.js
16-
uses: actions/setup-node@v3
16+
uses: actions/setup-node@v4
1717
with:
18-
node-version: '16.x'
18+
node-version: 22.x
1919
- name: Install dependencies
2020
run: npm install
2121
- name: Lint files
@@ -25,14 +25,14 @@ jobs:
2525
strategy:
2626
matrix:
2727
os: [ubuntu-latest]
28-
node: [16.x]
28+
node: [22.x]
2929
runs-on: ${{ matrix.os }}
3030
steps:
31-
- uses: actions/checkout@v3
32-
- uses: actions/setup-node@v3
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-node@v4
3333
with:
3434
node-version: ${{ matrix.node }}
3535
- name: Install dependencies
3636
run: npm install
3737
- name: Run tests
38-
run: npm run test
38+
run: npm test

Diff for: package-lock.json

+6,501-9,106
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+6-7
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@
2222
"*.js": "eslint --fix"
2323
},
2424
"dependencies": {
25-
"moment": "^2.29.4",
26-
"moment-timezone": "^0.5.35",
27-
"probot": "^7.4.0",
28-
"probot-scheduler": "^1.0.3"
25+
"moment": "^2.30.1",
26+
"moment-timezone": "^0.5.46",
27+
"probot": "^13.4.1"
2928
},
3029
"devDependencies": {
3130
"eslint": "^8.55.0",
3231
"eslint-config-eslint": "^9.0.0",
32+
"fetch-mock": "^12.2.0",
3333
"globals": "^13.24.0",
34-
"jest": "^26.1.0",
34+
"jest": "^29.7.0",
3535
"lint-staged": "^13.2.1",
36-
"nock": "^10.0.2",
3736
"yorkie": "^2.0.0"
3837
},
3938
"keywords": [
@@ -55,6 +54,6 @@
5554
"testEnvironment": "node"
5655
},
5756
"engines": {
58-
"node": "16.x"
57+
"node": "22.x"
5958
}
6059
}

Diff for: src/app.js

+24-10
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,25 @@
55

66
"use strict";
77

8-
const probot = require("probot");
8+
//-----------------------------------------------------------------------------
9+
// Requirements
10+
//-----------------------------------------------------------------------------
11+
12+
const { Probot, run } = require("probot");
913
const plugins = require("./plugins");
1014

15+
//-----------------------------------------------------------------------------
16+
// Type Definitions
17+
//-----------------------------------------------------------------------------
18+
19+
/** @typedef {import("probot").Probot} Probot */
20+
/** @typedef {import("probot").Context<any>} ProbotContext */
21+
/** @typedef {import("probot").ProbotOctokit} ProbotOctokit */
22+
23+
//-----------------------------------------------------------------------------
24+
// Main
25+
//-----------------------------------------------------------------------------
26+
1127
if (!process.env.SECRET) {
1228
throw new Error("Missing 'SECRET' environment variable");
1329
}
@@ -21,17 +37,15 @@ if (!process.env.APP_ID) {
2137
}
2238

2339
const port = process.env.PORT || 8000;
24-
const bot = probot.createProbot({
25-
port,
40+
const app = new Probot({
41+
privateKey: process.env.PRIVATE_KEY,
42+
appId: process.env.APP_ID,
2643
secret: process.env.SECRET,
27-
cert: process.env.PRIVATE_KEY,
28-
id: process.env.APP_ID
44+
port
2945
});
46+
3047
const enabledPlugins = new Set([
31-
"addToTriageProject",
32-
"autoCloser",
3348
"commitMessage",
34-
"issueArchiver",
3549
"needsInfo",
3650
"recurringIssues",
3751
"releaseMonitor",
@@ -41,7 +55,7 @@ const enabledPlugins = new Set([
4155
// load all the enabled plugins from inside plugins folder
4256
Object.keys(plugins)
4357
.filter(pluginId => enabledPlugins.has(pluginId))
44-
.forEach(pluginId => bot.load(plugins[pluginId]));
58+
.forEach(pluginId => app.load(plugins[pluginId]));
4559

4660
// start the server
47-
bot.start();
61+
run(app);

Diff for: src/plugins/auto-closer/index.js

-218
This file was deleted.

0 commit comments

Comments
 (0)