diff --git a/dist/main.js b/dist/main.js index a9b66b3..3353634 100644 --- a/dist/main.js +++ b/dist/main.js @@ -24,16 +24,12 @@ var __copyProps = (to, from, except, desc) => { return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __async = (__this, __arguments, generator) => { - return new Promise((resolve, reject) => { + return new Promise((resolve2, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); @@ -48,7 +44,7 @@ var __async = (__this, __arguments, generator) => { reject(e); } }; - var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + var step = (x) => x.done ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; @@ -898,11 +894,11 @@ var require_lib = __commonJS({ }; var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); + return value instanceof P ? value : new P(function(resolve2) { + resolve2(value); }); } - return new (P || (P = Promise))(function(resolve, reject) { + return new (P || (P = Promise))(function(resolve2, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -918,7 +914,7 @@ var require_lib = __commonJS({ } } function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -1003,13 +999,13 @@ var require_lib = __commonJS({ } readBody() { return __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve2) => __awaiter(this, void 0, void 0, function* () { let output = Buffer.alloc(0); this.message.on("data", (chunk) => { output = Buffer.concat([output, chunk]); }); this.message.on("end", () => { - resolve(output.toString()); + resolve2(output.toString()); }); })); }); @@ -1099,10 +1095,6 @@ var require_lib = __commonJS({ return this.request(verb, requestUrl, stream, additionalHeaders); }); } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ getJson(requestUrl, additionalHeaders = {}) { return __awaiter(this, void 0, void 0, function* () { additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); @@ -1137,11 +1129,6 @@ var require_lib = __commonJS({ return this._processResponse(res, this.requestOptions); }); } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ request(verb, requestUrl, data, headers) { return __awaiter(this, void 0, void 0, function* () { if (this._disposed) { @@ -1202,42 +1189,28 @@ var require_lib = __commonJS({ return response; }); } - /** - * Needs to be called if keepAlive is set to true in request options. - */ dispose() { if (this._agent) { this._agent.destroy(); } this._disposed = true; } - /** - * Raw request. - * @param info - * @param data - */ requestRaw(info2, data) { return __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { + return new Promise((resolve2, reject) => { function callbackForResult(err, res) { if (err) { reject(err); } else if (!res) { reject(new Error("Unknown error")); } else { - resolve(res); + resolve2(res); } } this.requestRawWithCallback(info2, data, callbackForResult); }); }); } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ requestRawWithCallback(info2, data, onResult) { if (typeof data === "string") { if (!info2.options.headers) { @@ -1281,11 +1254,6 @@ var require_lib = __commonJS({ req.end(); } } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ getAgent(serverUrl) { const parsedUrl = new URL(serverUrl); return this._getAgent(parsedUrl); @@ -1381,12 +1349,12 @@ var require_lib = __commonJS({ return __awaiter(this, void 0, void 0, function* () { retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise((resolve) => setTimeout(() => resolve(), ms)); + return new Promise((resolve2) => setTimeout(() => resolve2(), ms)); }); } _processResponse(res, options) { return __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve2, reject) => __awaiter(this, void 0, void 0, function* () { const statusCode = res.message.statusCode || 0; const response = { statusCode, @@ -1394,7 +1362,7 @@ var require_lib = __commonJS({ headers: {} }; if (statusCode === HttpCodes.NotFound) { - resolve(response); + resolve2(response); } function dateTimeDeserializer(key, value) { if (typeof value === "string") { @@ -1433,7 +1401,7 @@ var require_lib = __commonJS({ err.result = response.result; reject(err); } else { - resolve(response); + resolve2(response); } })); }); @@ -1450,11 +1418,11 @@ var require_auth = __commonJS({ "use strict"; var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); + return value instanceof P ? value : new P(function(resolve2) { + resolve2(value); }); } - return new (P || (P = Promise))(function(resolve, reject) { + return new (P || (P = Promise))(function(resolve2, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -1470,7 +1438,7 @@ var require_auth = __commonJS({ } } function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -1488,7 +1456,6 @@ var require_auth = __commonJS({ } options.headers["Authorization"] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString("base64")}`; } - // This handler cannot handle 401 canHandleAuthentication() { return false; } @@ -1503,15 +1470,12 @@ var require_auth = __commonJS({ constructor(token) { this.token = token; } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 prepareRequest(options) { if (!options.headers) { throw Error("The request has no headers"); } options.headers["Authorization"] = `Bearer ${this.token}`; } - // This handler cannot handle 401 canHandleAuthentication() { return false; } @@ -1526,15 +1490,12 @@ var require_auth = __commonJS({ constructor(token) { this.token = token; } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 prepareRequest(options) { if (!options.headers) { throw Error("The request has no headers"); } options.headers["Authorization"] = `Basic ${Buffer.from(`PAT:${this.token}`).toString("base64")}`; } - // This handler cannot handle 401 canHandleAuthentication() { return false; } @@ -1554,11 +1515,11 @@ var require_oidc_utils = __commonJS({ "use strict"; var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); + return value instanceof P ? value : new P(function(resolve2) { + resolve2(value); }); } - return new (P || (P = Promise))(function(resolve, reject) { + return new (P || (P = Promise))(function(resolve2, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -1574,7 +1535,7 @@ var require_oidc_utils = __commonJS({ } } function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -1652,11 +1613,11 @@ var require_summary = __commonJS({ "use strict"; var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); + return value instanceof P ? value : new P(function(resolve2) { + resolve2(value); }); } - return new (P || (P = Promise))(function(resolve, reject) { + return new (P || (P = Promise))(function(resolve2, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -1672,7 +1633,7 @@ var require_summary = __commonJS({ } } function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -1688,12 +1649,6 @@ var require_summary = __commonJS({ constructor() { this._buffer = ""; } - /** - * Finds the summary file path from the environment, rejects if env var is not found or file does not exist - * Also checks r/w permissions. - * - * @returns step summary file path - */ filePath() { return __awaiter(this, void 0, void 0, function* () { if (this._filePath) { @@ -1712,15 +1667,6 @@ var require_summary = __commonJS({ return this._filePath; }); } - /** - * Wraps content in an HTML tag, adding any HTML attributes - * - * @param {string} tag HTML tag to wrap - * @param {string | null} content content within the tag - * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add - * - * @returns {string} content wrapped in HTML element - */ wrap(tag, content, attrs = {}) { const htmlAttrs = Object.entries(attrs).map(([key, value]) => ` ${key}="${value}"`).join(""); if (!content) { @@ -1728,13 +1674,6 @@ var require_summary = __commonJS({ } return `<${tag}${htmlAttrs}>${content}`; } - /** - * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. - * - * @param {SummaryWriteOptions} [options] (optional) options for write operation - * - * @returns {Promise} summary instance - */ write(options) { return __awaiter(this, void 0, void 0, function* () { const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); @@ -1744,95 +1683,39 @@ var require_summary = __commonJS({ return this.emptyBuffer(); }); } - /** - * Clears the summary buffer and wipes the summary file - * - * @returns {Summary} summary instance - */ clear() { return __awaiter(this, void 0, void 0, function* () { return this.emptyBuffer().write({ overwrite: true }); }); } - /** - * Returns the current summary buffer as a string - * - * @returns {string} string of summary buffer - */ stringify() { return this._buffer; } - /** - * If the summary buffer is empty - * - * @returns {boolen} true if the buffer is empty - */ isEmptyBuffer() { return this._buffer.length === 0; } - /** - * Resets the summary buffer without writing to summary file - * - * @returns {Summary} summary instance - */ emptyBuffer() { this._buffer = ""; return this; } - /** - * Adds raw text to the summary buffer - * - * @param {string} text content to add - * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) - * - * @returns {Summary} summary instance - */ addRaw(text, addEOL = false) { this._buffer += text; return addEOL ? this.addEOL() : this; } - /** - * Adds the operating system-specific end-of-line marker to the buffer - * - * @returns {Summary} summary instance - */ addEOL() { return this.addRaw(os_1.EOL); } - /** - * Adds an HTML codeblock to the summary buffer - * - * @param {string} code content to render within fenced code block - * @param {string} lang (optional) language to syntax highlight code - * - * @returns {Summary} summary instance - */ addCodeBlock(code, lang) { const attrs = Object.assign({}, lang && { lang }); const element = this.wrap("pre", this.wrap("code", code), attrs); return this.addRaw(element).addEOL(); } - /** - * Adds an HTML list to the summary buffer - * - * @param {string[]} items list of items to render - * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) - * - * @returns {Summary} summary instance - */ addList(items, ordered = false) { const tag = ordered ? "ol" : "ul"; const listItems = items.map((item) => this.wrap("li", item)).join(""); const element = this.wrap(tag, listItems); return this.addRaw(element).addEOL(); } - /** - * Adds an HTML table to the summary buffer - * - * @param {SummaryTableCell[]} rows table rows - * - * @returns {Summary} summary instance - */ addTable(rows) { const tableBody = rows.map((row) => { const cells = row.map((cell) => { @@ -1849,86 +1732,35 @@ var require_summary = __commonJS({ const element = this.wrap("table", tableBody); return this.addRaw(element).addEOL(); } - /** - * Adds a collapsable HTML details element to the summary buffer - * - * @param {string} label text for the closed state - * @param {string} content collapsable content - * - * @returns {Summary} summary instance - */ addDetails(label, content) { const element = this.wrap("details", this.wrap("summary", label) + content); return this.addRaw(element).addEOL(); } - /** - * Adds an HTML image tag to the summary buffer - * - * @param {string} src path to the image you to embed - * @param {string} alt text description of the image - * @param {SummaryImageOptions} options (optional) addition image attributes - * - * @returns {Summary} summary instance - */ addImage(src, alt, options) { const { width, height } = options || {}; const attrs = Object.assign(Object.assign({}, width && { width }), height && { height }); const element = this.wrap("img", null, Object.assign({ src, alt }, attrs)); return this.addRaw(element).addEOL(); } - /** - * Adds an HTML section heading element - * - * @param {string} text heading text - * @param {number | string} [level=1] (optional) the heading level, default: 1 - * - * @returns {Summary} summary instance - */ addHeading(text, level) { const tag = `h${level}`; const allowedTag = ["h1", "h2", "h3", "h4", "h5", "h6"].includes(tag) ? tag : "h1"; const element = this.wrap(allowedTag, text); return this.addRaw(element).addEOL(); } - /** - * Adds an HTML thematic break (
) to the summary buffer - * - * @returns {Summary} summary instance - */ addSeparator() { const element = this.wrap("hr", null); return this.addRaw(element).addEOL(); } - /** - * Adds an HTML line break (
) to the summary buffer - * - * @returns {Summary} summary instance - */ addBreak() { const element = this.wrap("br", null); return this.addRaw(element).addEOL(); } - /** - * Adds an HTML blockquote to the summary buffer - * - * @param {string} text quote text - * @param {string} cite (optional) citation url - * - * @returns {Summary} summary instance - */ addQuote(text, cite) { const attrs = Object.assign({}, cite && { cite }); const element = this.wrap("blockquote", text, attrs); return this.addRaw(element).addEOL(); } - /** - * Adds an HTML anchor tag to the summary buffer - * - * @param {string} text link text/content - * @param {string} href hyperlink - * - * @returns {Summary} summary instance - */ addLink(text, href) { const element = this.wrap("a", text, { href }); return this.addRaw(element).addEOL(); @@ -1974,7 +1806,7 @@ var require_path_utils = __commonJS({ }; Object.defineProperty(exports, "__esModule", { value: true }); exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; - var path = __importStar(require("path")); + var path2 = __importStar(require("path")); function toPosixPath(pth) { return pth.replace(/[\\]/g, "/"); } @@ -1984,7 +1816,7 @@ var require_path_utils = __commonJS({ } exports.toWin32Path = toWin32Path; function toPlatformPath(pth) { - return pth.replace(/[/\\]/g, path.sep); + return pth.replace(/[/\\]/g, path2.sep); } exports.toPlatformPath = toPlatformPath; } @@ -2024,11 +1856,11 @@ var require_core = __commonJS({ }; var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); + return value instanceof P ? value : new P(function(resolve2) { + resolve2(value); }); } - return new (P || (P = Promise))(function(resolve, reject) { + return new (P || (P = Promise))(function(resolve2, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -2044,7 +1876,7 @@ var require_core = __commonJS({ } } function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -2055,7 +1887,7 @@ var require_core = __commonJS({ var file_command_1 = require_file_command(); var utils_1 = require_utils(); var os = __importStar(require("os")); - var path = __importStar(require("path")); + var path2 = __importStar(require("path")); var oidc_utils_1 = require_oidc_utils(); var ExitCode; (function(ExitCode2) { @@ -2083,7 +1915,7 @@ var require_core = __commonJS({ } else { command_1.issueCommand("add-path", {}, inputPath); } - process.env["PATH"] = `${inputPath}${path.delimiter}${process.env["PATH"]}`; + process.env["PATH"] = `${inputPath}${path2.delimiter}${process.env["PATH"]}`; } exports.addPath = addPath; function getInput2(name, options) { @@ -2222,6 +2054,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); // src/main.ts var core = __toESM(require_core()); var fs = __toESM(require("fs")); +var path = __toESM(require("path")); function run() { return __async(this, null, function* () { try { @@ -2229,7 +2062,8 @@ function run() { const fileName = core.getInput("fileName"); core.info(`Found filename: ${fileName}`); core.info(`Found json: ${json}`); - fs.writeFileSync(fileName, json); + const filePath = path.resolve(fileName); + fs.writeFileSync(filePath, json); core.info(`File written successfully`); } catch (error) { if (error instanceof Error)