1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.createProbot = void 0;
|
4 | const get_private_key_1 = require("@probot/get-private-key");
|
5 | const get_log_1 = require("./helpers/get-log");
|
6 | const probot_1 = require("./probot");
|
7 | const DEFAULTS = {
|
8 | APP_ID: "",
|
9 | WEBHOOK_SECRET: "",
|
10 | GHE_HOST: "",
|
11 | GHE_PROTOCOL: "",
|
12 | LOG_FORMAT: "",
|
13 | LOG_LEVEL: "warn",
|
14 | LOG_LEVEL_IN_STRING: "",
|
15 | REDIS_URL: "",
|
16 | SENTRY_DSN: "",
|
17 | };
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | function createProbot({ overrides = {}, defaults = {}, env = process.env, } = {}) {
|
28 | const privateKey = get_private_key_1.getPrivateKey({ env });
|
29 | const envWithDefaults = { ...DEFAULTS, ...env };
|
30 | const envOptions = {
|
31 | logLevel: envWithDefaults.LOG_LEVEL,
|
32 | appId: Number(envWithDefaults.APP_ID),
|
33 | privateKey: (privateKey && privateKey.toString()) || undefined,
|
34 | secret: envWithDefaults.WEBHOOK_SECRET,
|
35 | redisConfig: envWithDefaults.REDIS_URL,
|
36 | baseUrl: envWithDefaults.GHE_HOST
|
37 | ? `${envWithDefaults.GHE_PROTOCOL || "https"}://${envWithDefaults.GHE_HOST}/api/v3`
|
38 | : "https://api.github.com",
|
39 | };
|
40 | const probotOptions = {
|
41 | ...defaults,
|
42 | ...envOptions,
|
43 | ...overrides,
|
44 | };
|
45 | const logOptions = {
|
46 | level: probotOptions.logLevel,
|
47 | logFormat: envWithDefaults.LOG_FORMAT,
|
48 | logLevelInString: envWithDefaults.LOG_LEVEL_IN_STRING === "true",
|
49 | sentryDsn: envWithDefaults.SENTRY_DSN,
|
50 | };
|
51 | const log = get_log_1.getLog(logOptions).child({ name: "server" });
|
52 | return new probot_1.Probot({
|
53 | log: log.child({ name: "probot" }),
|
54 | ...probotOptions,
|
55 | });
|
56 | }
|
57 | exports.createProbot = createProbot;
|
58 |
|
\ | No newline at end of file |