First upload version 0.0.1
This commit is contained in:
105
node_modules/@octokit/app/dist-src/index.js
generated
vendored
Normal file
105
node_modules/@octokit/app/dist-src/index.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
import { Octokit as OctokitCore } from "@octokit/core";
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
import { OAuthApp } from "@octokit/oauth-app";
|
||||
import { VERSION } from "./version.js";
|
||||
import { webhooks } from "./webhooks.js";
|
||||
import { eachInstallationFactory } from "./each-installation.js";
|
||||
import { eachRepositoryFactory } from "./each-repository.js";
|
||||
import { getInstallationOctokit } from "./get-installation-octokit.js";
|
||||
import { getInstallationUrlFactory } from "./get-installation-url.js";
|
||||
class App {
|
||||
static VERSION = VERSION;
|
||||
static defaults(defaults) {
|
||||
const AppWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
super({
|
||||
...defaults,
|
||||
...args[0]
|
||||
});
|
||||
}
|
||||
};
|
||||
return AppWithDefaults;
|
||||
}
|
||||
octokit;
|
||||
// @ts-ignore calling app.webhooks will throw a helpful error when options.webhooks is not set
|
||||
webhooks;
|
||||
// @ts-ignore calling app.oauth will throw a helpful error when options.oauth is not set
|
||||
oauth;
|
||||
getInstallationOctokit;
|
||||
eachInstallation;
|
||||
eachRepository;
|
||||
getInstallationUrl;
|
||||
log;
|
||||
constructor(options) {
|
||||
const Octokit = options.Octokit || OctokitCore;
|
||||
const authOptions = Object.assign(
|
||||
{
|
||||
appId: options.appId,
|
||||
privateKey: options.privateKey
|
||||
},
|
||||
options.oauth ? {
|
||||
clientId: options.oauth.clientId,
|
||||
clientSecret: options.oauth.clientSecret
|
||||
} : {}
|
||||
);
|
||||
const octokitOptions = {
|
||||
authStrategy: createAppAuth,
|
||||
auth: authOptions
|
||||
};
|
||||
if ("log" in options && typeof options.log !== "undefined") {
|
||||
octokitOptions.log = options.log;
|
||||
}
|
||||
this.octokit = new Octokit(octokitOptions);
|
||||
this.log = Object.assign(
|
||||
{
|
||||
debug: () => {
|
||||
},
|
||||
info: () => {
|
||||
},
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console)
|
||||
},
|
||||
options.log
|
||||
);
|
||||
if (options.webhooks) {
|
||||
this.webhooks = webhooks(this.octokit, options.webhooks);
|
||||
} else {
|
||||
Object.defineProperty(this, "webhooks", {
|
||||
get() {
|
||||
throw new Error("[@octokit/app] webhooks option not set");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (options.oauth) {
|
||||
this.oauth = new OAuthApp({
|
||||
...options.oauth,
|
||||
clientType: "github-app",
|
||||
Octokit
|
||||
});
|
||||
} else {
|
||||
Object.defineProperty(this, "oauth", {
|
||||
get() {
|
||||
throw new Error(
|
||||
"[@octokit/app] oauth.clientId / oauth.clientSecret options are not set"
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.getInstallationOctokit = getInstallationOctokit.bind(
|
||||
null,
|
||||
this
|
||||
);
|
||||
this.eachInstallation = eachInstallationFactory(
|
||||
this
|
||||
);
|
||||
this.eachRepository = eachRepositoryFactory(
|
||||
this
|
||||
);
|
||||
this.getInstallationUrl = getInstallationUrlFactory(this);
|
||||
}
|
||||
}
|
||||
import { createNodeMiddleware } from "./middleware/node/index.js";
|
||||
export {
|
||||
App,
|
||||
createNodeMiddleware
|
||||
};
|
||||
Reference in New Issue
Block a user