diff --git a/dist/index.js b/dist/index.js index 0528815..363a926 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2,7 +2,7 @@ module.exports = /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 748: +/***/ 7351: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -29,7 +29,7 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.issue = exports.issueCommand = void 0; const os = __importStar(__nccwpck_require__(2087)); -const utils_1 = __nccwpck_require__(2195); +const utils_1 = __nccwpck_require__(5278); /** * Commands * @@ -101,7 +101,7 @@ function escapeProperty(s) { /***/ }), -/***/ 3419: +/***/ 2186: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -136,12 +136,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; -const command_1 = __nccwpck_require__(748); -const file_command_1 = __nccwpck_require__(5844); -const utils_1 = __nccwpck_require__(2195); +const command_1 = __nccwpck_require__(7351); +const file_command_1 = __nccwpck_require__(717); +const utils_1 = __nccwpck_require__(5278); const os = __importStar(__nccwpck_require__(2087)); const path = __importStar(__nccwpck_require__(5622)); -const oidc_utils_1 = __nccwpck_require__(7796); +const oidc_utils_1 = __nccwpck_require__(8041); /** * The code to exit an action */ @@ -420,7 +420,7 @@ exports.getIDToken = getIDToken; /***/ }), -/***/ 5844: +/***/ 717: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -451,7 +451,7 @@ exports.issueCommand = void 0; /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(5747)); const os = __importStar(__nccwpck_require__(2087)); -const utils_1 = __nccwpck_require__(2195); +const utils_1 = __nccwpck_require__(5278); function issueCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { @@ -469,7 +469,7 @@ exports.issueCommand = issueCommand; /***/ }), -/***/ 7796: +/***/ 8041: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -485,9 +485,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(2259); -const auth_1 = __nccwpck_require__(3400); -const core_1 = __nccwpck_require__(3419); +const http_client_1 = __nccwpck_require__(9925); +const auth_1 = __nccwpck_require__(3702); +const core_1 = __nccwpck_require__(2186); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { const requestOptions = { @@ -553,7 +553,7 @@ exports.OidcClient = OidcClient; /***/ }), -/***/ 2195: +/***/ 5278: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -600,7 +600,7 @@ exports.toCommandProperties = toCommandProperties; /***/ }), -/***/ 4947: +/***/ 4087: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -657,7 +657,7 @@ exports.Context = Context; /***/ }), -/***/ 1840: +/***/ 5438: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -683,8 +683,8 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getOctokit = exports.context = void 0; -const Context = __importStar(__nccwpck_require__(4947)); -const utils_1 = __nccwpck_require__(2049); +const Context = __importStar(__nccwpck_require__(4087)); +const utils_1 = __nccwpck_require__(3030); exports.context = new Context.Context(); /** * Returns a hydrated octokit ready to use for GitHub Actions @@ -700,7 +700,7 @@ exports.getOctokit = getOctokit; /***/ }), -/***/ 8383: +/***/ 7914: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -726,7 +726,7 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getApiBaseUrl = exports.getProxyAgent = exports.getAuthString = void 0; -const httpClient = __importStar(__nccwpck_require__(2259)); +const httpClient = __importStar(__nccwpck_require__(9925)); function getAuthString(token, options) { if (!token && !options.auth) { throw new Error('Parameter token or opts.auth is required'); @@ -750,7 +750,7 @@ exports.getApiBaseUrl = getApiBaseUrl; /***/ }), -/***/ 2049: +/***/ 3030: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -776,12 +776,12 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getOctokitOptions = exports.GitHub = exports.context = void 0; -const Context = __importStar(__nccwpck_require__(4947)); -const Utils = __importStar(__nccwpck_require__(8383)); +const Context = __importStar(__nccwpck_require__(4087)); +const Utils = __importStar(__nccwpck_require__(7914)); // octokit + plugins -const core_1 = __nccwpck_require__(9770); -const plugin_rest_endpoint_methods_1 = __nccwpck_require__(8733); -const plugin_paginate_rest_1 = __nccwpck_require__(4914); +const core_1 = __nccwpck_require__(6762); +const plugin_rest_endpoint_methods_1 = __nccwpck_require__(3044); +const plugin_paginate_rest_1 = __nccwpck_require__(4193); exports.context = new Context.Context(); const baseUrl = Utils.getApiBaseUrl(); const defaults = { @@ -811,7 +811,7 @@ exports.getOctokitOptions = getOctokitOptions; /***/ }), -/***/ 3400: +/***/ 3702: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -877,7 +877,7 @@ exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHand /***/ }), -/***/ 2259: +/***/ 9925: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -885,7 +885,7 @@ exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHand Object.defineProperty(exports, "__esModule", ({ value: true })); const http = __nccwpck_require__(8605); const https = __nccwpck_require__(7211); -const pm = __nccwpck_require__(7006); +const pm = __nccwpck_require__(6443); let tunnel; var HttpCodes; (function (HttpCodes) { @@ -1304,7 +1304,7 @@ class HttpClient { if (useProxy) { // If using proxy, need tunnel if (!tunnel) { - tunnel = __nccwpck_require__(3356); + tunnel = __nccwpck_require__(4294); } const agentOptions = { maxSockets: maxSockets, @@ -1422,7 +1422,7 @@ exports.HttpClient = HttpClient; /***/ }), -/***/ 7006: +/***/ 6443: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -1487,7 +1487,7 @@ exports.checkBypass = checkBypass; /***/ }), -/***/ 2622: +/***/ 334: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -1550,7 +1550,7 @@ exports.createTokenAuth = createTokenAuth; /***/ }), -/***/ 9770: +/***/ 6762: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -1558,11 +1558,11 @@ exports.createTokenAuth = createTokenAuth; Object.defineProperty(exports, "__esModule", ({ value: true })); -var universalUserAgent = __nccwpck_require__(6393); -var beforeAfterHook = __nccwpck_require__(6996); -var request = __nccwpck_require__(9212); -var graphql = __nccwpck_require__(7570); -var authToken = __nccwpck_require__(2622); +var universalUserAgent = __nccwpck_require__(5030); +var beforeAfterHook = __nccwpck_require__(3682); +var request = __nccwpck_require__(6234); +var graphql = __nccwpck_require__(8467); +var authToken = __nccwpck_require__(334); function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; @@ -1734,7 +1734,7 @@ exports.Octokit = Octokit; /***/ }), -/***/ 2061: +/***/ 9440: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -1742,8 +1742,8 @@ exports.Octokit = Octokit; Object.defineProperty(exports, "__esModule", ({ value: true })); -var isPlainObject = __nccwpck_require__(7080); -var universalUserAgent = __nccwpck_require__(6393); +var isPlainObject = __nccwpck_require__(3287); +var universalUserAgent = __nccwpck_require__(5030); function lowercaseKeys(object) { if (!object) { @@ -2132,7 +2132,7 @@ exports.endpoint = endpoint; /***/ }), -/***/ 7570: +/***/ 8467: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -2140,8 +2140,8 @@ exports.endpoint = endpoint; Object.defineProperty(exports, "__esModule", ({ value: true })); -var request = __nccwpck_require__(9212); -var universalUserAgent = __nccwpck_require__(6393); +var request = __nccwpck_require__(6234); +var universalUserAgent = __nccwpck_require__(5030); const VERSION = "4.8.0"; @@ -2258,7 +2258,7 @@ exports.withCustomRequest = withCustomRequest; /***/ }), -/***/ 4914: +/***/ 4193: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -2483,7 +2483,7 @@ exports.paginatingEndpoints = paginatingEndpoints; /***/ }), -/***/ 5184: +/***/ 8883: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -2521,7 +2521,7 @@ exports.requestLog = requestLog; /***/ }), -/***/ 8733: +/***/ 3044: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -3758,7 +3758,299 @@ exports.restEndpointMethods = restEndpointMethods; /***/ }), -/***/ 7674: +/***/ 537: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var deprecation = __nccwpck_require__(8932); +var once = _interopDefault(__nccwpck_require__(1223)); + +const logOnceCode = once(deprecation => console.warn(deprecation)); +const logOnceHeaders = once(deprecation => console.warn(deprecation)); +/** + * Error with extra properties to help with debugging + */ + +class RequestError extends Error { + constructor(message, statusCode, options) { + super(message); // Maintains proper stack trace (only available on V8) + + /* istanbul ignore next */ + + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); + } + + this.name = "HttpError"; + this.status = statusCode; + let headers; + + if ("headers" in options && typeof options.headers !== "undefined") { + headers = options.headers; + } + + if ("response" in options) { + this.response = options.response; + headers = options.response.headers; + } // redact request credentials without mutating original request options + + + const requestCopy = Object.assign({}, options.request); + + if (options.request.headers.authorization) { + requestCopy.headers = Object.assign({}, options.request.headers, { + authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]") + }); + } + + requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit + // see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications + .replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]") // OAuth tokens can be passed as URL query parameters, although it is not recommended + // see https://developer.github.com/v3/#oauth2-token-sent-in-a-header + .replace(/\baccess_token=\w+/g, "access_token=[REDACTED]"); + this.request = requestCopy; // deprecations + + Object.defineProperty(this, "code", { + get() { + logOnceCode(new deprecation.Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`.")); + return statusCode; + } + + }); + Object.defineProperty(this, "headers", { + get() { + logOnceHeaders(new deprecation.Deprecation("[@octokit/request-error] `error.headers` is deprecated, use `error.response.headers`.")); + return headers || {}; + } + + }); + } + +} + +exports.RequestError = RequestError; +//# sourceMappingURL=index.js.map + + +/***/ }), + +/***/ 6234: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var endpoint = __nccwpck_require__(9440); +var universalUserAgent = __nccwpck_require__(5030); +var isPlainObject = __nccwpck_require__(3287); +var nodeFetch = _interopDefault(__nccwpck_require__(467)); +var requestError = __nccwpck_require__(537); + +const VERSION = "5.6.2"; + +function getBufferResponse(response) { + return response.arrayBuffer(); +} + +function fetchWrapper(requestOptions) { + const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console; + + if (isPlainObject.isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) { + requestOptions.body = JSON.stringify(requestOptions.body); + } + + let headers = {}; + let status; + let url; + const fetch = requestOptions.request && requestOptions.request.fetch || nodeFetch; + return fetch(requestOptions.url, Object.assign({ + method: requestOptions.method, + body: requestOptions.body, + headers: requestOptions.headers, + redirect: requestOptions.redirect + }, // `requestOptions.request.agent` type is incompatible + // see https://github.com/octokit/types.ts/pull/264 + requestOptions.request)).then(async response => { + url = response.url; + status = response.status; + + for (const keyAndValue of response.headers) { + headers[keyAndValue[0]] = keyAndValue[1]; + } + + if ("deprecation" in headers) { + const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/); + const deprecationLink = matches && matches.pop(); + log.warn(`[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${headers.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`); + } + + if (status === 204 || status === 205) { + return; + } // GitHub API returns 200 for HEAD requests + + + if (requestOptions.method === "HEAD") { + if (status < 400) { + return; + } + + throw new requestError.RequestError(response.statusText, status, { + response: { + url, + status, + headers, + data: undefined + }, + request: requestOptions + }); + } + + if (status === 304) { + throw new requestError.RequestError("Not modified", status, { + response: { + url, + status, + headers, + data: await getResponseData(response) + }, + request: requestOptions + }); + } + + if (status >= 400) { + const data = await getResponseData(response); + const error = new requestError.RequestError(toErrorMessage(data), status, { + response: { + url, + status, + headers, + data + }, + request: requestOptions + }); + throw error; + } + + return getResponseData(response); + }).then(data => { + return { + status, + url, + headers, + data + }; + }).catch(error => { + if (error instanceof requestError.RequestError) throw error; + throw new requestError.RequestError(error.message, 500, { + request: requestOptions + }); + }); +} + +async function getResponseData(response) { + const contentType = response.headers.get("content-type"); + + if (/application\/json/.test(contentType)) { + return response.json(); + } + + if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) { + return response.text(); + } + + return getBufferResponse(response); +} + +function toErrorMessage(data) { + if (typeof data === "string") return data; // istanbul ignore else - just in case + + if ("message" in data) { + if (Array.isArray(data.errors)) { + return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}`; + } + + return data.message; + } // istanbul ignore next - just in case + + + return `Unknown error: ${JSON.stringify(data)}`; +} + +function withDefaults(oldEndpoint, newDefaults) { + const endpoint = oldEndpoint.defaults(newDefaults); + + const newApi = function (route, parameters) { + const endpointOptions = endpoint.merge(route, parameters); + + if (!endpointOptions.request || !endpointOptions.request.hook) { + return fetchWrapper(endpoint.parse(endpointOptions)); + } + + const request = (route, parameters) => { + return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters))); + }; + + Object.assign(request, { + endpoint, + defaults: withDefaults.bind(null, endpoint) + }); + return endpointOptions.request.hook(request, endpointOptions); + }; + + return Object.assign(newApi, { + endpoint, + defaults: withDefaults.bind(null, endpoint) + }); +} + +const request = withDefaults(endpoint.endpoint, { + headers: { + "user-agent": `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}` + } +}); + +exports.request = request; +//# sourceMappingURL=index.js.map + + +/***/ }), + +/***/ 5375: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ value: true })); + +var core = __nccwpck_require__(6762); +var pluginRequestLog = __nccwpck_require__(8883); +var pluginPaginateRest = __nccwpck_require__(4193); +var pluginRestEndpointMethods = __nccwpck_require__(4923); + +const VERSION = "18.12.0"; + +const Octokit = core.Octokit.plugin(pluginRequestLog.requestLog, pluginRestEndpointMethods.legacyRestEndpointMethods, pluginPaginateRest.paginateRest).defaults({ + userAgent: `octokit-rest.js/${VERSION}` +}); + +exports.Octokit = Octokit; +//# sourceMappingURL=index.js.map + + +/***/ }), + +/***/ 4923: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -4668,422 +4960,130 @@ const Endpoints = { listGpgKeysForAuthenticatedUser: ["GET /user/gpg_keys"], listGpgKeysForUser: ["GET /users/{username}/gpg_keys"], listPublicEmailsForAuthenticated: ["GET /user/public_emails", {}, { - renamed: ["users", "listPublicEmailsForAuthenticatedUser"] - }], - listPublicEmailsForAuthenticatedUser: ["GET /user/public_emails"], - listPublicKeysForUser: ["GET /users/{username}/keys"], - listPublicSshKeysForAuthenticated: ["GET /user/keys", {}, { - renamed: ["users", "listPublicSshKeysForAuthenticatedUser"] - }], - listPublicSshKeysForAuthenticatedUser: ["GET /user/keys"], - setPrimaryEmailVisibilityForAuthenticated: ["PATCH /user/email/visibility", {}, { - renamed: ["users", "setPrimaryEmailVisibilityForAuthenticatedUser"] - }], - setPrimaryEmailVisibilityForAuthenticatedUser: ["PATCH /user/email/visibility"], - unblock: ["DELETE /user/blocks/{username}"], - unfollow: ["DELETE /user/following/{username}"], - updateAuthenticated: ["PATCH /user"] - } -}; - -const VERSION = "5.13.0"; - -function endpointsToMethods(octokit, endpointsMap) { - const newMethods = {}; - - for (const [scope, endpoints] of Object.entries(endpointsMap)) { - for (const [methodName, endpoint] of Object.entries(endpoints)) { - const [route, defaults, decorations] = endpoint; - const [method, url] = route.split(/ /); - const endpointDefaults = Object.assign({ - method, - url - }, defaults); - - if (!newMethods[scope]) { - newMethods[scope] = {}; - } - - const scopeMethods = newMethods[scope]; - - if (decorations) { - scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations); - continue; - } - - scopeMethods[methodName] = octokit.request.defaults(endpointDefaults); - } - } - - return newMethods; -} - -function decorate(octokit, scope, methodName, defaults, decorations) { - const requestWithDefaults = octokit.request.defaults(defaults); - /* istanbul ignore next */ - - function withDecorations(...args) { - // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488 - let options = requestWithDefaults.endpoint.merge(...args); // There are currently no other decorations than `.mapToData` - - if (decorations.mapToData) { - options = Object.assign({}, options, { - data: options[decorations.mapToData], - [decorations.mapToData]: undefined - }); - return requestWithDefaults(options); - } - - if (decorations.renamed) { - const [newScope, newMethodName] = decorations.renamed; - octokit.log.warn(`octokit.${scope}.${methodName}() has been renamed to octokit.${newScope}.${newMethodName}()`); - } - - if (decorations.deprecated) { - octokit.log.warn(decorations.deprecated); - } - - if (decorations.renamedParameters) { - // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488 - const options = requestWithDefaults.endpoint.merge(...args); - - for (const [name, alias] of Object.entries(decorations.renamedParameters)) { - if (name in options) { - octokit.log.warn(`"${name}" parameter is deprecated for "octokit.${scope}.${methodName}()". Use "${alias}" instead`); - - if (!(alias in options)) { - options[alias] = options[name]; - } - - delete options[name]; - } - } - - return requestWithDefaults(options); - } // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488 - - - return requestWithDefaults(...args); - } - - return Object.assign(withDecorations, requestWithDefaults); -} - -function restEndpointMethods(octokit) { - const api = endpointsToMethods(octokit, Endpoints); - return { - rest: api - }; -} -restEndpointMethods.VERSION = VERSION; -function legacyRestEndpointMethods(octokit) { - const api = endpointsToMethods(octokit, Endpoints); - return _objectSpread2(_objectSpread2({}, api), {}, { - rest: api - }); -} -legacyRestEndpointMethods.VERSION = VERSION; - -exports.legacyRestEndpointMethods = legacyRestEndpointMethods; -exports.restEndpointMethods = restEndpointMethods; -//# sourceMappingURL=index.js.map - - -/***/ }), - -/***/ 9220: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); - -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } - -var deprecation = __nccwpck_require__(4177); -var once = _interopDefault(__nccwpck_require__(7731)); - -const logOnceCode = once(deprecation => console.warn(deprecation)); -const logOnceHeaders = once(deprecation => console.warn(deprecation)); -/** - * Error with extra properties to help with debugging - */ - -class RequestError extends Error { - constructor(message, statusCode, options) { - super(message); // Maintains proper stack trace (only available on V8) - - /* istanbul ignore next */ - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } - - this.name = "HttpError"; - this.status = statusCode; - let headers; - - if ("headers" in options && typeof options.headers !== "undefined") { - headers = options.headers; - } - - if ("response" in options) { - this.response = options.response; - headers = options.response.headers; - } // redact request credentials without mutating original request options - - - const requestCopy = Object.assign({}, options.request); - - if (options.request.headers.authorization) { - requestCopy.headers = Object.assign({}, options.request.headers, { - authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]") - }); - } - - requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit - // see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications - .replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]") // OAuth tokens can be passed as URL query parameters, although it is not recommended - // see https://developer.github.com/v3/#oauth2-token-sent-in-a-header - .replace(/\baccess_token=\w+/g, "access_token=[REDACTED]"); - this.request = requestCopy; // deprecations - - Object.defineProperty(this, "code", { - get() { - logOnceCode(new deprecation.Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`.")); - return statusCode; - } - - }); - Object.defineProperty(this, "headers", { - get() { - logOnceHeaders(new deprecation.Deprecation("[@octokit/request-error] `error.headers` is deprecated, use `error.response.headers`.")); - return headers || {}; - } - - }); + renamed: ["users", "listPublicEmailsForAuthenticatedUser"] + }], + listPublicEmailsForAuthenticatedUser: ["GET /user/public_emails"], + listPublicKeysForUser: ["GET /users/{username}/keys"], + listPublicSshKeysForAuthenticated: ["GET /user/keys", {}, { + renamed: ["users", "listPublicSshKeysForAuthenticatedUser"] + }], + listPublicSshKeysForAuthenticatedUser: ["GET /user/keys"], + setPrimaryEmailVisibilityForAuthenticated: ["PATCH /user/email/visibility", {}, { + renamed: ["users", "setPrimaryEmailVisibilityForAuthenticatedUser"] + }], + setPrimaryEmailVisibilityForAuthenticatedUser: ["PATCH /user/email/visibility"], + unblock: ["DELETE /user/blocks/{username}"], + unfollow: ["DELETE /user/following/{username}"], + updateAuthenticated: ["PATCH /user"] } +}; -} - -exports.RequestError = RequestError; -//# sourceMappingURL=index.js.map - - -/***/ }), - -/***/ 9212: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); - -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } - -var endpoint = __nccwpck_require__(2061); -var universalUserAgent = __nccwpck_require__(6393); -var isPlainObject = __nccwpck_require__(7080); -var nodeFetch = _interopDefault(__nccwpck_require__(9917)); -var requestError = __nccwpck_require__(9220); - -const VERSION = "5.6.2"; +const VERSION = "5.13.0"; -function getBufferResponse(response) { - return response.arrayBuffer(); -} +function endpointsToMethods(octokit, endpointsMap) { + const newMethods = {}; -function fetchWrapper(requestOptions) { - const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console; + for (const [scope, endpoints] of Object.entries(endpointsMap)) { + for (const [methodName, endpoint] of Object.entries(endpoints)) { + const [route, defaults, decorations] = endpoint; + const [method, url] = route.split(/ /); + const endpointDefaults = Object.assign({ + method, + url + }, defaults); - if (isPlainObject.isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) { - requestOptions.body = JSON.stringify(requestOptions.body); - } + if (!newMethods[scope]) { + newMethods[scope] = {}; + } - let headers = {}; - let status; - let url; - const fetch = requestOptions.request && requestOptions.request.fetch || nodeFetch; - return fetch(requestOptions.url, Object.assign({ - method: requestOptions.method, - body: requestOptions.body, - headers: requestOptions.headers, - redirect: requestOptions.redirect - }, // `requestOptions.request.agent` type is incompatible - // see https://github.com/octokit/types.ts/pull/264 - requestOptions.request)).then(async response => { - url = response.url; - status = response.status; + const scopeMethods = newMethods[scope]; - for (const keyAndValue of response.headers) { - headers[keyAndValue[0]] = keyAndValue[1]; - } + if (decorations) { + scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations); + continue; + } - if ("deprecation" in headers) { - const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/); - const deprecationLink = matches && matches.pop(); - log.warn(`[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${headers.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`); + scopeMethods[methodName] = octokit.request.defaults(endpointDefaults); } + } - if (status === 204 || status === 205) { - return; - } // GitHub API returns 200 for HEAD requests + return newMethods; +} +function decorate(octokit, scope, methodName, defaults, decorations) { + const requestWithDefaults = octokit.request.defaults(defaults); + /* istanbul ignore next */ - if (requestOptions.method === "HEAD") { - if (status < 400) { - return; - } + function withDecorations(...args) { + // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488 + let options = requestWithDefaults.endpoint.merge(...args); // There are currently no other decorations than `.mapToData` - throw new requestError.RequestError(response.statusText, status, { - response: { - url, - status, - headers, - data: undefined - }, - request: requestOptions + if (decorations.mapToData) { + options = Object.assign({}, options, { + data: options[decorations.mapToData], + [decorations.mapToData]: undefined }); + return requestWithDefaults(options); } - if (status === 304) { - throw new requestError.RequestError("Not modified", status, { - response: { - url, - status, - headers, - data: await getResponseData(response) - }, - request: requestOptions - }); + if (decorations.renamed) { + const [newScope, newMethodName] = decorations.renamed; + octokit.log.warn(`octokit.${scope}.${methodName}() has been renamed to octokit.${newScope}.${newMethodName}()`); } - if (status >= 400) { - const data = await getResponseData(response); - const error = new requestError.RequestError(toErrorMessage(data), status, { - response: { - url, - status, - headers, - data - }, - request: requestOptions - }); - throw error; + if (decorations.deprecated) { + octokit.log.warn(decorations.deprecated); } - return getResponseData(response); - }).then(data => { - return { - status, - url, - headers, - data - }; - }).catch(error => { - if (error instanceof requestError.RequestError) throw error; - throw new requestError.RequestError(error.message, 500, { - request: requestOptions - }); - }); -} - -async function getResponseData(response) { - const contentType = response.headers.get("content-type"); - - if (/application\/json/.test(contentType)) { - return response.json(); - } + if (decorations.renamedParameters) { + // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488 + const options = requestWithDefaults.endpoint.merge(...args); - if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) { - return response.text(); - } + for (const [name, alias] of Object.entries(decorations.renamedParameters)) { + if (name in options) { + octokit.log.warn(`"${name}" parameter is deprecated for "octokit.${scope}.${methodName}()". Use "${alias}" instead`); - return getBufferResponse(response); -} + if (!(alias in options)) { + options[alias] = options[name]; + } -function toErrorMessage(data) { - if (typeof data === "string") return data; // istanbul ignore else - just in case + delete options[name]; + } + } - if ("message" in data) { - if (Array.isArray(data.errors)) { - return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}`; - } + return requestWithDefaults(options); + } // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488 - return data.message; - } // istanbul ignore next - just in case + return requestWithDefaults(...args); + } - return `Unknown error: ${JSON.stringify(data)}`; + return Object.assign(withDecorations, requestWithDefaults); } -function withDefaults(oldEndpoint, newDefaults) { - const endpoint = oldEndpoint.defaults(newDefaults); - - const newApi = function (route, parameters) { - const endpointOptions = endpoint.merge(route, parameters); - - if (!endpointOptions.request || !endpointOptions.request.hook) { - return fetchWrapper(endpoint.parse(endpointOptions)); - } - - const request = (route, parameters) => { - return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters))); - }; - - Object.assign(request, { - endpoint, - defaults: withDefaults.bind(null, endpoint) - }); - return endpointOptions.request.hook(request, endpointOptions); +function restEndpointMethods(octokit) { + const api = endpointsToMethods(octokit, Endpoints); + return { + rest: api }; - - return Object.assign(newApi, { - endpoint, - defaults: withDefaults.bind(null, endpoint) +} +restEndpointMethods.VERSION = VERSION; +function legacyRestEndpointMethods(octokit) { + const api = endpointsToMethods(octokit, Endpoints); + return _objectSpread2(_objectSpread2({}, api), {}, { + rest: api }); } +legacyRestEndpointMethods.VERSION = VERSION; -const request = withDefaults(endpoint.endpoint, { - headers: { - "user-agent": `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}` - } -}); - -exports.request = request; -//# sourceMappingURL=index.js.map - - -/***/ }), - -/***/ 5744: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); - -var core = __nccwpck_require__(9770); -var pluginRequestLog = __nccwpck_require__(5184); -var pluginPaginateRest = __nccwpck_require__(4914); -var pluginRestEndpointMethods = __nccwpck_require__(7674); - -const VERSION = "18.12.0"; - -const Octokit = core.Octokit.plugin(pluginRequestLog.requestLog, pluginRestEndpointMethods.legacyRestEndpointMethods, pluginPaginateRest.paginateRest).defaults({ - userAgent: `octokit-rest.js/${VERSION}` -}); - -exports.Octokit = Octokit; +exports.legacyRestEndpointMethods = legacyRestEndpointMethods; +exports.restEndpointMethods = restEndpointMethods; //# sourceMappingURL=index.js.map /***/ }), -/***/ 7891: +/***/ 55: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -5133,12 +5133,12 @@ exports.dealStringToArr = dealStringToArr; /***/ }), -/***/ 6996: +/***/ 3682: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var register = __nccwpck_require__(7598) -var addHook = __nccwpck_require__(3889) -var removeHook = __nccwpck_require__(557) +var register = __nccwpck_require__(4670) +var addHook = __nccwpck_require__(5549) +var removeHook = __nccwpck_require__(6819) // bind with array of arguments: https://stackoverflow.com/a/21792913 var bind = Function.bind @@ -5197,7 +5197,7 @@ module.exports.Collection = Hook.Collection /***/ }), -/***/ 3889: +/***/ 5549: /***/ ((module) => { module.exports = addHook; @@ -5250,7 +5250,7 @@ function addHook(state, kind, name, hook) { /***/ }), -/***/ 7598: +/***/ 4670: /***/ ((module) => { module.exports = register; @@ -5284,7 +5284,7 @@ function register(state, name, method, options) { /***/ }), -/***/ 557: +/***/ 6819: /***/ ((module) => { module.exports = removeHook; @@ -5310,7 +5310,7 @@ function removeHook(state, name, method) { /***/ }), -/***/ 4177: +/***/ 8932: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -5338,7 +5338,7 @@ exports.Deprecation = Deprecation; /***/ }), -/***/ 7080: +/***/ 3287: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -5384,7 +5384,7 @@ exports.isPlainObject = isPlainObject; /***/ }), -/***/ 9917: +/***/ 467: /***/ ((module, exports, __nccwpck_require__) => { "use strict"; @@ -5397,7 +5397,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau var Stream = _interopDefault(__nccwpck_require__(2413)); var http = _interopDefault(__nccwpck_require__(8605)); var Url = _interopDefault(__nccwpck_require__(8835)); -var whatwgUrl = _interopDefault(__nccwpck_require__(1252)); +var whatwgUrl = _interopDefault(__nccwpck_require__(8665)); var https = _interopDefault(__nccwpck_require__(7211)); var zlib = _interopDefault(__nccwpck_require__(8761)); @@ -5550,7 +5550,7 @@ FetchError.prototype.name = 'FetchError'; let convert; try { - convert = __nccwpck_require__(7198).convert; + convert = __nccwpck_require__(2877).convert; } catch (e) {} const INTERNALS = Symbol('Body internals'); @@ -7063,10 +7063,10 @@ exports.FetchError = FetchError; /***/ }), -/***/ 7731: +/***/ 1223: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var wrappy = __nccwpck_require__(6301) +var wrappy = __nccwpck_require__(2940) module.exports = wrappy(once) module.exports.strict = wrappy(onceStrict) @@ -7112,14 +7112,14 @@ function onceStrict (fn) { /***/ }), -/***/ 9578: +/***/ 4256: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; var punycode = __nccwpck_require__(4213); -var mappingTable = __nccwpck_require__(6154); +var mappingTable = __nccwpck_require__(68); var PROCESSING_OPTIONS = { TRANSITIONAL: 0, @@ -7313,15 +7313,15 @@ module.exports.PROCESSING_OPTIONS = PROCESSING_OPTIONS; /***/ }), -/***/ 3356: +/***/ 4294: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports = __nccwpck_require__(5073); +module.exports = __nccwpck_require__(4219); /***/ }), -/***/ 5073: +/***/ 4219: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -7593,7 +7593,7 @@ exports.debug = debug; // for test /***/ }), -/***/ 6393: +/***/ 5030: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -7619,7 +7619,7 @@ exports.getUserAgent = getUserAgent; /***/ }), -/***/ 9086: +/***/ 4886: /***/ ((module) => { "use strict"; @@ -7816,12 +7816,12 @@ conversions["RegExp"] = function (V, opts) { /***/ }), -/***/ 2672: +/***/ 7537: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -const usm = __nccwpck_require__(6506); +const usm = __nccwpck_require__(2158); exports.implementation = class URLImpl { constructor(constructorArgs) { @@ -8024,15 +8024,15 @@ exports.implementation = class URLImpl { /***/ }), -/***/ 2566: +/***/ 3394: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; -const conversions = __nccwpck_require__(9086); -const utils = __nccwpck_require__(3259); -const Impl = __nccwpck_require__(2672); +const conversions = __nccwpck_require__(4886); +const utils = __nccwpck_require__(3185); +const Impl = __nccwpck_require__(7537); const impl = utils.implSymbol; @@ -8228,32 +8228,32 @@ module.exports = { /***/ }), -/***/ 1252: +/***/ 8665: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -exports.URL = __nccwpck_require__(2566).interface; -exports.serializeURL = __nccwpck_require__(6506).serializeURL; -exports.serializeURLOrigin = __nccwpck_require__(6506).serializeURLOrigin; -exports.basicURLParse = __nccwpck_require__(6506).basicURLParse; -exports.setTheUsername = __nccwpck_require__(6506).setTheUsername; -exports.setThePassword = __nccwpck_require__(6506).setThePassword; -exports.serializeHost = __nccwpck_require__(6506).serializeHost; -exports.serializeInteger = __nccwpck_require__(6506).serializeInteger; -exports.parseURL = __nccwpck_require__(6506).parseURL; +exports.URL = __nccwpck_require__(3394).interface; +exports.serializeURL = __nccwpck_require__(2158).serializeURL; +exports.serializeURLOrigin = __nccwpck_require__(2158).serializeURLOrigin; +exports.basicURLParse = __nccwpck_require__(2158).basicURLParse; +exports.setTheUsername = __nccwpck_require__(2158).setTheUsername; +exports.setThePassword = __nccwpck_require__(2158).setThePassword; +exports.serializeHost = __nccwpck_require__(2158).serializeHost; +exports.serializeInteger = __nccwpck_require__(2158).serializeInteger; +exports.parseURL = __nccwpck_require__(2158).parseURL; /***/ }), -/***/ 6506: +/***/ 2158: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; const punycode = __nccwpck_require__(4213); -const tr46 = __nccwpck_require__(9578); +const tr46 = __nccwpck_require__(4256); const specialSchemes = { ftp: 21, @@ -9552,7 +9552,7 @@ module.exports.parseURL = function (input, options) { /***/ }), -/***/ 3259: +/***/ 3185: /***/ ((module) => { "use strict"; @@ -9580,7 +9580,7 @@ module.exports.implForWrapper = function (wrapper) { /***/ }), -/***/ 6301: +/***/ 2940: /***/ ((module) => { // Returns a wrapper function that returns a wrapped callback @@ -9620,19 +9620,19 @@ function wrappy (fn, cb) { /***/ }), -/***/ 5434: +/***/ 1713: /***/ ((__unused_webpack_module, __unused_webpack_exports, __nccwpck_require__) => { -const core = __nccwpck_require__(3419); -const github = __nccwpck_require__(1840); -const { Octokit } = __nccwpck_require__(5744); +const core = __nccwpck_require__(2186); +const github = __nccwpck_require__(5438); +const { Octokit } = __nccwpck_require__(5375); // ************************************************ const token = core.getInput('token'); const octokit = new Octokit({ auth: `token ${token}` }); const context = github.context; -const { dealStringToArr, THANKS } = __nccwpck_require__(7891); +const { dealStringToArr, THANKS } = __nccwpck_require__(55); // ************************************************ async function run() { @@ -9783,7 +9783,7 @@ run(); /***/ }), -/***/ 7198: +/***/ 2877: /***/ ((module) => { module.exports = eval("require")("encoding"); @@ -9791,7 +9791,7 @@ module.exports = eval("require")("encoding"); /***/ }), -/***/ 6154: +/***/ 68: /***/ ((module) => { "use strict"; @@ -9949,6 +9949,6 @@ module.exports = require("zlib");; /******/ // module exports must be returned from runtime so entry inlining is disabled /******/ // startup /******/ // Load entry module and return exports -/******/ return __nccwpck_require__(5434); +/******/ return __nccwpck_require__(1713); /******/ })() ; \ No newline at end of file diff --git a/package.json b/package.json index 9c8c1cd..a541b7d 100644 --- a/package.json +++ b/package.json @@ -11,16 +11,19 @@ "author": "xrkffgg", "main": "src/main.js", "scripts": { + "check-commit": "node ./scripts/check-commit.js", "package": "ncc build", "format": "prettier --write src/*.js", "format-check": "prettier --check src/*.js", "tag": "node ./scripts/tag.js", - "release": "node ./scripts/release" + "release": "node ./scripts/release", + "pub": "sh -e ./scripts/pub.sh" }, "dependencies": { "@actions/core": "^1.2.6", "@actions/github": "^4.0.0", - "@octokit/rest": "^18.0.14" + "@octokit/rest": "^18.0.14", + "actions-util": "^1.0.0" }, "devDependencies": { "@umijs/fabric": "^2.5.6", diff --git a/scripts/check-commit.js b/scripts/check-commit.js new file mode 100755 index 0000000..2f0d426 --- /dev/null +++ b/scripts/check-commit.js @@ -0,0 +1,23 @@ +const chalk = require('chalk'); +const simpleGit = require('simple-git/promise'); + +const cwd = process.cwd(); +const git = simpleGit(cwd); + +async function checkCommit({ files }) { + if (files.length) { + console.log(chalk.yellow('πŸ™„ You forgot something to commit.')); + files.forEach(({ path: filePath }) => { + console.log(' -', chalk.red(filePath)); + }); + console.log(''); + process.exit(1); + } +} + +async function run() { + const status = await git.status(); + await checkCommit(status); +} + +run(); diff --git a/scripts/pub.sh b/scripts/pub.sh new file mode 100644 index 0000000..6e7a129 --- /dev/null +++ b/scripts/pub.sh @@ -0,0 +1,14 @@ +echo "[TEST] check format" +npm run format-check + +echo "[TEST] test package" +npm run package + +echo "[TEST] test commit" +npm run check-commit + +echo "[Action] do tag" +npm run tag + +echo "[Action] do release" +npm run release diff --git a/scripts/release.js b/scripts/release.js index a0526c0..ed06f22 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -12,21 +12,20 @@ const repo = 'maintain-one-comment'; function getChangelog(content) { const lines = content.split('\n'); const changeLog = []; - const startPattern = new RegExp(`^## `); - const stopPattern = /^## /; // 前一δΈͺη‰ˆζœ¬ + const pin = /^## /; let begin = false; for (let i = 0; i < lines.length; i += 1) { const line = lines[i]; - if (begin && stopPattern.test(line)) { + if (begin && pin.test(line)) { break; } if (begin && line) { changeLog.push(line); } if (!begin) { - begin = startPattern.test(line); + begin = pin.test(line); if (begin) { - tag = line.substring(3, line.length); + tag = line.substring(3, line.length).trim(); } } } diff --git a/scripts/tag.js b/scripts/tag.js index c04a98a..909eb3f 100644 --- a/scripts/tag.js +++ b/scripts/tag.js @@ -1,16 +1,33 @@ const chalk = require('chalk'); const simpleGit = require('simple-git/promise'); const { execSync } = require('child_process'); +const { readFileSync } = require('fs'); +const path = require('path'); + +const CHANGELOG_NAME = 'CHANGELOG.md'; +const CHANGELOG_PATH = path.join(__dirname, '..', CHANGELOG_NAME); +const CHANGELOG = readFileSync(CHANGELOG_PATH, 'utf-8'); const cwd = process.cwd(); const git = simpleGit(cwd); async function run() { + execSync(`git pull`); + const data = await git.tags(); const tags = data.all; - const tag = tags.reverse()[0]; + let tag = tags.reverse()[0]; console.log(chalk.green(`[Git Query] tag: ${tag}`)); + const tagChangelog = getChangelogTag(CHANGELOG); + if (tagChangelog && tag != tagChangelog) { + console.log(chalk.yellow(`[Git Action] Push new ${tagChangelog} tag!`)); + execSync(`git tag ${tagChangelog}`); + execSync(`git push origin ${tagChangelog}:${tagChangelog}`); + execSync(`git pull`); + tag = tagChangelog; + } + const tagSimple = tag.startsWith('v') ? tag.substring(0, 2) : tag.substring(0, 1); console.log(chalk.green(`[Git Query] tagSimple: ${tagSimple}`)); @@ -19,9 +36,31 @@ async function run() { execSync(`git push origin :refs/tags/${tagSimple}`); } - console.log(chalk.yellow(`[Git Action] Add new ${tagSimple} tag`)); + console.log(chalk.yellow(`[Git Action] Add new simple ${tagSimple} tag`)); execSync(`git push origin ${tag}:${tagSimple}`); console.log(chalk.green('πŸŽ‰ Done!')); } +function getChangelogTag(content) { + const lines = content.split('\n'); + const pin = /^## /; + let begin = false; + let tag = ''; + + for (let i = 0; i < lines.length; i += 1) { + const line = lines[i]; + if (begin && pin.test(line)) { + break; + } + if (!begin) { + begin = pin.test(line); + if (begin) { + tag = line.substring(3, line.length); + } + } + } + + return tag.trim(); +} + run();