Skip to content

Commit a40e36d

Browse files
committed
fix: Add npm version and fix app setup
1 parent 6f15586 commit a40e36d

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"testEnvironment": "node"
5555
},
5656
"engines": {
57-
"node": "22.x"
57+
"node": "22.x",
58+
"npm": "10.x"
5859
}
5960
}

src/app.js

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,19 @@
99
// Requirements
1010
//-----------------------------------------------------------------------------
1111

12-
const { Probot, run } = require("probot");
12+
const { run } = require("probot");
1313
const plugins = require("./plugins");
1414

1515
//-----------------------------------------------------------------------------
1616
// Type Definitions
1717
//-----------------------------------------------------------------------------
1818

1919
/** @typedef {import("probot").Probot} Probot */
20-
/** @typedef {import("probot").Context<any>} ProbotContext */
21-
/** @typedef {import("probot").ProbotOctokit} ProbotOctokit */
2220

2321
//-----------------------------------------------------------------------------
2422
// Main
2523
//-----------------------------------------------------------------------------
2624

27-
if (!process.env.SECRET) {
28-
throw new Error("Missing 'SECRET' environment variable");
29-
}
30-
31-
if (!process.env.PRIVATE_KEY) {
32-
throw new Error("Missing 'PRIVATE_KEY' environment variable");
33-
}
34-
35-
if (!process.env.APP_ID) {
36-
throw new Error("Missing 'APP_ID' environment variable");
37-
}
38-
39-
const port = process.env.PORT || 8000;
40-
const app = new Probot({
41-
privateKey: process.env.PRIVATE_KEY,
42-
appId: process.env.APP_ID,
43-
secret: process.env.SECRET,
44-
port
45-
});
46-
4725
const enabledPlugins = new Set([
4826
"commitMessage",
4927
"needsInfo",
@@ -52,10 +30,16 @@ const enabledPlugins = new Set([
5230
"wip"
5331
]);
5432

55-
// load all the enabled plugins from inside plugins folder
56-
Object.keys(plugins)
57-
.filter(pluginId => enabledPlugins.has(pluginId))
58-
.forEach(pluginId => app.load(plugins[pluginId]));
33+
/**
34+
* Assign the plugins to the robot.
35+
* @param {Probot} robot The Probot instance.
36+
* @returns {void}
37+
*/
38+
function appFn(robot) {
39+
Object.keys(plugins)
40+
.filter(pluginId => enabledPlugins.has(pluginId))
41+
.forEach(pluginId => plugins[pluginId](robot));
42+
}
5943

6044
// start the server
61-
run(app);
45+
run(appFn);

0 commit comments

Comments
 (0)