UNPKG

2.23 kBJavaScriptView Raw
1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 if (k2 === undefined) k2 = k;
4 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5}) : (function(o, m, k, k2) {
6 if (k2 === undefined) k2 = k;
7 o[k2] = m[k];
8}));
9var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10 Object.defineProperty(o, "default", { enumerable: true, value: v });
11}) : function(o, v) {
12 o["default"] = v;
13});
14var __importStar = (this && this.__importStar) || function (mod) {
15 if (mod && mod.__esModule) return mod;
16 var result = {};
17 if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18 __setModuleDefault(result, mod);
19 return result;
20};
21Object.defineProperty(exports, "__esModule", { value: true });
22exports.getOctokitOptions = exports.GitHub = exports.context = void 0;
23const Context = __importStar(require("./context"));
24const Utils = __importStar(require("./internal/utils"));
25// octokit + plugins
26const core_1 = require("@octokit/core");
27const plugin_rest_endpoint_methods_1 = require("@octokit/plugin-rest-endpoint-methods");
28const plugin_paginate_rest_1 = require("@octokit/plugin-paginate-rest");
29exports.context = new Context.Context();
30const baseUrl = Utils.getApiBaseUrl();
31const defaults = {
32 baseUrl,
33 request: {
34 agent: Utils.getProxyAgent(baseUrl)
35 }
36};
37exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults);
38/**
39 * Convience function to correctly format Octokit Options to pass into the constructor.
40 *
41 * @param token the repo PAT or GITHUB_TOKEN
42 * @param options other options to set
43 */
44function getOctokitOptions(token, options) {
45 const opts = Object.assign({}, options || {}); // Shallow clone - don't mutate the object provided by the caller
46 // Auth
47 const auth = Utils.getAuthString(token, opts);
48 if (auth) {
49 opts.auth = auth;
50 }
51 return opts;
52}
53exports.getOctokitOptions = getOctokitOptions;
54//# sourceMappingURL=utils.js.map
\No newline at end of file