Skip to content

Commit 0fe8383

Browse files
feat: Migrate to Node.js 20
This commit updates the project to use Node.js version 20. Changes include: - Updated `engines.node` in `functions/package.json` to "20". - Updated the Node.js version in the GitHub Actions CI workflow (`.github/workflows/test.yml`) to `20.x`. - Added a placeholder `functions/config/config.json` to allow tests to pass, as the original configuration file is managed externally and not present in the repository. The project builds successfully and all tests pass with Node.js 20.
1 parent f51982e commit 0fe8383

File tree

5 files changed

+39
-43
lines changed

5 files changed

+39
-43
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
node-version:
16-
- 16.x
16+
- 20.x
1717
steps:
1818
- uses: actions/checkout@v1
1919
- uses: actions/setup-node@v1

functions/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "oss-bot",
33
"description": "GitHub monitoring robot.",
44
"engines": {
5-
"node": "16"
5+
"node": "20"
66
},
77
"main": "dist/index.js",
88
"dependencies": {

functions/src/github.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ export class GitHubClient {
166166
* Blocks the given user on behalf of the specified organization.
167167
*/
168168
blockFromOrg(org: string, username: string) {
169-
return this.api.request('PUT /orgs/' + org + '/blocks/' + username, {
169+
return this.api.request("PUT /orgs/" + org + "/blocks/" + username, {
170170
org: org,
171-
username: username,
171+
username: username
172172
});
173173
}
174174

functions/src/issues.ts

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -243,51 +243,47 @@ export class IssueHandler {
243243

244244
// Filter spam from b/378634578. This can be removed in the future.
245245
const spamWords = [
246-
'pemain',
247-
'wallet wallet', // seems to be in most crypto issues
248-
'minecraft',
249-
'paybis',
250-
'blockchain',
251-
'official contact number',
252-
'phantom wallet',
253-
'defi wallet',
254-
'dogecoin',
255-
'crypto.com',
256-
'moonpay',
257-
'coinmama',
258-
'daftar',
259-
['wallet', 'support'],
246+
"pemain",
247+
"wallet wallet", // seems to be in most crypto issues
248+
"minecraft",
249+
"paybis",
250+
"blockchain",
251+
"official contact number",
252+
"phantom wallet",
253+
"defi wallet",
254+
"dogecoin",
255+
"crypto.com",
256+
"moonpay",
257+
"coinmama",
258+
"daftar",
259+
["wallet", "support"]
260260
];
261-
const issueContent = ` ${issue.title} ${issue.body || ''} `.toLowerCase();
261+
const issueContent = ` ${issue.title} ${issue.body || ""} `.toLowerCase();
262262
// Scope spam filtering to affected repos only.
263-
const isAffectedRepo = org == "firebase" && (
264-
name == "flutterfire" ||
265-
name == "quickstart-android" ||
266-
name == "quickstart-ios"
267-
);
268-
const isSpam = isAffectedRepo && spamWords.find((wordOrArray) => {
269-
if (Array.isArray(wordOrArray)) {
270-
return wordOrArray.every((word) => issueContent.includes(word));
271-
} else {
272-
const wordWithSpace = ` ${wordOrArray} `;
273-
return issueContent.includes(wordWithSpace);
274-
}
275-
});
263+
const isAffectedRepo =
264+
org == "firebase" &&
265+
(name == "flutterfire" ||
266+
name == "quickstart-android" ||
267+
name == "quickstart-ios");
268+
const isSpam =
269+
isAffectedRepo &&
270+
spamWords.find(wordOrArray => {
271+
if (Array.isArray(wordOrArray)) {
272+
return wordOrArray.every(word => issueContent.includes(word));
273+
} else {
274+
const wordWithSpace = ` ${wordOrArray} `;
275+
return issueContent.includes(wordWithSpace);
276+
}
277+
});
276278

277279
if (isSpam) {
278280
// Discard other actions, wipe and lock the issue, and block
279281
// the offending user.
280-
const reason = `Issue is believed to be spam: ${issue.title}`
282+
const reason = `Issue is believed to be spam: ${issue.title}`;
281283
return [
282-
new types.GitHubSpamAction(
283-
org, name, issue.number, reason
284-
),
285-
new types.GitHubBlockAction(
286-
org, issue.user.login
287-
),
288-
new types.GitHubLockAction(
289-
org, name, issue.number
290-
)
284+
new types.GitHubSpamAction(org, name, issue.number, reason),
285+
new types.GitHubBlockAction(org, issue.user.login),
286+
new types.GitHubLockAction(org, name, issue.number)
291287
];
292288
}
293289

0 commit comments

Comments
 (0)