From 7cc66e5f6ce07ec4923ca05b9565f12247fc07f4 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 7 Dec 2023 07:55:19 +0800 Subject: [PATCH] fix: fix `jsonPath` input param issue. (fix #31 #29) --- dist/action.js | 208 ++++++++++++++++++++++++++++--------------------- src/action.ts | 3 +- 2 files changed, 122 insertions(+), 89 deletions(-) diff --git a/dist/action.js b/dist/action.js index 095c5b3..1a15151 100644 --- a/dist/action.js +++ b/dist/action.js @@ -5392,7 +5392,6 @@ function specialHexEncode(match) { // compresses better } } - function svgToTinyDataUri(svgString) { if (typeof svgString !== 'string') { throw new TypeError('Expected a string, but received ' + typeof svgString); @@ -5685,7 +5684,6 @@ function toOptions(host, port, localAddress) { } return host; // for v0.11 or later } - function mergeOptions(target) { for (var i = 1, len = arguments.length; i < len; ++i) { var overrides = arguments[i]; @@ -6794,6 +6792,7 @@ function request(opts, callback) { } } module.exports = request; +module.exports.RequestHandler = RequestHandler; /***/ }), @@ -7472,7 +7471,7 @@ module.exports = /*#__PURE__*/function (_Readable) { }) : noop; _this2.on('close', function () { signalListenerCleanup(); - if (signal !== null && signal !== void 0 && signal.aborted) { + if (signal && signal.aborted) { reject(signal.reason || Object.assign(new Error('The operation was aborted'), { name: 'AbortError' })); @@ -8488,7 +8487,6 @@ var Cache = /*#__PURE__*/function () { // 7.3.3 response: response // 7.3.4 }; - operations.push(operation); // 7.3.5 index++; // 7.3.6 @@ -9457,13 +9455,13 @@ module.exports = { /***/ }), /***/ 9581: -/***/ ((module) => { +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; module.exports = { - kConstruct: Symbol('constructable') + kConstruct: (__webpack_require__(3329).kConstruct) }; /***/ }), @@ -9821,7 +9819,6 @@ var Client = /*#__PURE__*/function (_DispatcherBase) { // Keep track of them to decide wether or not unref the session maxConcurrentStreams: maxConcurrentStreams != null ? maxConcurrentStreams : 100 // Max peerConcurrentStreams for a Node h2 server }; - _this[kHost] = "".concat(_this[kUrl].hostname).concat(_this[kUrl].port ? ":".concat(_this[kUrl].port) : ''); // kQueue is built up of 3 sections separated by @@ -10427,11 +10424,8 @@ var Parser = /*#__PURE__*/function () { // Stop more requests from being dispatched. socket[kReset] = true; } - var pause; - try { - pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false; - } catch (err) { - util.destroy(socket, err); + var pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false; + if (request.aborted) { return -1; } if (request.method === 'HEAD') { @@ -10471,13 +10465,8 @@ var Parser = /*#__PURE__*/function () { return -1; } this.bytesRead += buf.length; - try { - if (request.onData(buf) === false) { - return constants.ERROR.PAUSED; - } - } catch (err) { - util.destroy(socket, err); - return -1; + if (request.onData(buf) === false) { + return constants.ERROR.PAUSED; } } }, { @@ -10518,11 +10507,7 @@ var Parser = /*#__PURE__*/function () { util.destroy(socket, new ResponseContentLengthMismatchError()); return -1; } - try { - request.onComplete(headers); - } catch (err) { - errorRequest(client, request, err); - } + request.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { assert.strictEqual(client[kRunning], 0); @@ -11270,12 +11255,16 @@ function writeH2(client, session, request) { request.onComplete([]); }); stream.on('data', function (chunk) { - if (request.onData(chunk) === false) stream.pause(); + if (request.onData(chunk) === false) { + stream.pause(); + } }); stream.once('close', function () { h2State.openStreams -= 1; // TODO(HTTP/2): unref only if current streams count is 0 - if (h2State.openStreams === 0) session.unref(); + if (h2State.openStreams === 0) { + session.unref(); + } }); stream.once('error', function (err) { if (client[kHTTP2Session] && !client[kHTTP2Session].destroyed && !this.closed && !this.destroyed) { @@ -13514,7 +13503,11 @@ var Request = /*#__PURE__*/function () { key: "onBodySent", value: function onBodySent(chunk) { if (this[kHandler].onBodySent) { - return this[kHandler].onBodySent(chunk); + try { + return this[kHandler].onBodySent(chunk); + } catch (err) { + this.abort(err); + } } } }, { @@ -13526,7 +13519,11 @@ var Request = /*#__PURE__*/function () { }); } if (this[kHandler].onRequestSent) { - return this[kHandler].onRequestSent(); + try { + return this[kHandler].onRequestSent(); + } catch (err) { + this.abort(err); + } } } }, { @@ -13556,14 +13553,23 @@ var Request = /*#__PURE__*/function () { } }); } - return this[kHandler].onHeaders(statusCode, headers, resume, statusText); + try { + return this[kHandler].onHeaders(statusCode, headers, resume, statusText); + } catch (err) { + this.abort(err); + } } }, { key: "onData", value: function onData(chunk) { assert(!this.aborted); assert(!this.completed); - return this[kHandler].onData(chunk); + try { + return this[kHandler].onData(chunk); + } catch (err) { + this.abort(err); + return false; + } } }, { key: "onUpgrade", @@ -13584,7 +13590,12 @@ var Request = /*#__PURE__*/function () { trailers: trailers }); } - return this[kHandler].onComplete(trailers); + try { + return this[kHandler].onComplete(trailers); + } catch (err) { + // TODO (fix): This might be a bad idea? + this.onError(err); + } } }, { key: "onError", @@ -13812,7 +13823,8 @@ module.exports = { kHTTP1BuildRequest: Symbol('http1 build request'), kHTTP2CopyHeaders: Symbol('http2 copy headers'), kHTTPConnVersion: Symbol('http connection version'), - kRetryHandlerDefaultRetry: Symbol('retry agent default retry') + kRetryHandlerDefaultRetry: Symbol('retry agent default retry'), + kConstruct: Symbol('constructable') }; /***/ }), @@ -15699,15 +15711,12 @@ function dataURLProcessor(dataURL) { */ function URLSerializer(url) { var excludeFragment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var href = url.href; if (!excludeFragment) { - return href; + return url.href; } - var hash = href.lastIndexOf('#'); - if (hash === -1) { - return href; - } - return href.slice(0, hash); + var href = url.href; + var hashLength = url.hash.length; + return hashLength === 0 ? href : href.substring(0, href.length - hashLength); } // https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points @@ -16916,7 +16925,8 @@ var _createClass = (__webpack_require__(9728)["default"]); var _defineProperty = (__webpack_require__(8416)["default"]); var _Symbol$iterator; var _require = __webpack_require__(3329), - kHeadersList = _require.kHeadersList; + kHeadersList = _require.kHeadersList, + kConstruct = _require.kConstruct; var _require2 = __webpack_require__(102), kGuard = _require2.kGuard; var _require3 = __webpack_require__(3902), @@ -17209,6 +17219,9 @@ var Headers = /*#__PURE__*/function (_Symbol$for) { function Headers() { var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; _classCallCheck(this, Headers); + if (init === kConstruct) { + return; + } this[kHeadersList] = new HeadersList(); // The new Headers(init) constructor steps are: @@ -17906,7 +17919,7 @@ function finalizeAndReportTiming(response) { } // 8. If response’s timing allow passed flag is not set, then: - if (!timingInfo.timingAllowPassed) { + if (!response.timingAllowPassed) { // 1. Set timingInfo to a the result of creating an opaque timing info for timingInfo. timingInfo = createOpaqueTimingInfo({ startTime: timingInfo.startTime @@ -19963,7 +19976,8 @@ var _require4 = __webpack_require__(6030), isValidHTTPToken = _require4.isValidHTTPToken, sameOrigin = _require4.sameOrigin, normalizeMethod = _require4.normalizeMethod, - makePolicyContainer = _require4.makePolicyContainer; + makePolicyContainer = _require4.makePolicyContainer, + normalizeMethodRecord = _require4.normalizeMethodRecord; var _require5 = __webpack_require__(2654), forbiddenMethodsSet = _require5.forbiddenMethodsSet, corsSafeListedMethodsSet = _require5.corsSafeListedMethodsSet, @@ -19987,7 +20001,8 @@ var _require8 = __webpack_require__(2369), var _require9 = __webpack_require__(645), URLSerializer = _require9.URLSerializer; var _require10 = __webpack_require__(3329), - kHeadersList = _require10.kHeadersList; + kHeadersList = _require10.kHeadersList, + kConstruct = _require10.kConstruct; var assert = __webpack_require__(9491); var _require11 = __webpack_require__(2361), getMaxListeners = _require11.getMaxListeners, @@ -19995,7 +20010,6 @@ var _require11 = __webpack_require__(2361), getEventListeners = _require11.getEventListeners, defaultMaxListeners = _require11.defaultMaxListeners; var TransformStream = globalThis.TransformStream; -var kInit = Symbol('init'); var kAbortController = Symbol('abortController'); var requestFinalizer = new FinalizationRegistry(function (_ref) { var signal = _ref.signal, @@ -20010,7 +20024,7 @@ var Request = /*#__PURE__*/function () { var _request$window, _initBody; var init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _classCallCheck(this, Request); - if (input === kInit) { + if (input === kConstruct) { return; } webidl.argumentLengthCheck(arguments, 1, { @@ -20147,9 +20161,10 @@ var Request = /*#__PURE__*/function () { // URL list A clone of request’s URL list. urlList: _toConsumableArray(request.urlList) }); + var initHasKey = Object.keys(init).length !== 0; // 13. If init is not empty, then: - if (Object.keys(init).length > 0) { + if (initHasKey) { // 1. If request’s mode is "navigate", then set it to "same-origin". if (request.mode === 'navigate') { request.mode = 'same-origin'; @@ -20261,7 +20276,7 @@ var Request = /*#__PURE__*/function () { } // 23. If init["integrity"] exists, then set request’s integrity metadata to it. - if (init.integrity !== undefined && init.integrity != null) { + if (init.integrity != null) { request.integrity = String(init.integrity); } @@ -20272,20 +20287,21 @@ var Request = /*#__PURE__*/function () { // 25. If init["method"] exists, then: if (init.method !== undefined) { + var _normalizeMethodRecor; // 1. Let method be init["method"]. var method = init.method; // 2. If method is not a method or method is a forbidden method, then // throw a TypeError. - if (!isValidHTTPToken(init.method)) { - throw new TypeError("'".concat(init.method, "' is not a valid HTTP method.")); + if (!isValidHTTPToken(method)) { + throw new TypeError("'".concat(method, "' is not a valid HTTP method.")); } if (forbiddenMethodsSet.has(method.toUpperCase())) { - throw new TypeError("'".concat(init.method, "' HTTP method is unsupported.")); + throw new TypeError("'".concat(method, "' HTTP method is unsupported.")); } // 3. Normalize method. - method = normalizeMethod(init.method); + method = (_normalizeMethodRecor = normalizeMethodRecord[method]) !== null && _normalizeMethodRecor !== void 0 ? _normalizeMethodRecor : normalizeMethod(method); // 4. Set request’s method to method. request.method = method; @@ -20350,7 +20366,7 @@ var Request = /*#__PURE__*/function () { // 30. Set this’s headers to a new Headers object with this’s relevant // Realm, whose header list is request’s header list and guard is // "request". - this[kHeaders] = new Headers(); + this[kHeaders] = new Headers(kConstruct); this[kHeaders][kHeadersList] = request.headersList; this[kHeaders][kGuard] = 'request'; this[kHeaders][kRealm] = this[kRealm]; @@ -20368,22 +20384,20 @@ var Request = /*#__PURE__*/function () { } // 32. If init is not empty, then: - if (Object.keys(init).length !== 0) { + if (initHasKey) { + /** @type {HeadersList} */ + var headersList = this[kHeaders][kHeadersList]; // 1. Let headers be a copy of this’s headers and its associated header // list. - var headers = new Headers(this[kHeaders]); - // 2. If init["headers"] exists, then set headers to init["headers"]. - if (init.headers !== undefined) { - headers = init.headers; - } + var headers = init.headers !== undefined ? init.headers : new HeadersList(headersList); // 3. Empty this’s headers’s header list. - this[kHeaders][kHeadersList].clear(); + headersList.clear(); // 4. If headers is a Headers object, then for each header in its header // list, append header’s name/header’s value to this’s headers. - if (headers.constructor.name === 'Headers') { + if (headers instanceof HeadersList) { var _iterator = _createForOfIteratorHelper(headers), _step; try { @@ -20391,13 +20405,15 @@ var Request = /*#__PURE__*/function () { var _step$value = _slicedToArray(_step.value, 2), key = _step$value[0], val = _step$value[1]; - this[kHeaders].append(key, val); + headersList.append(key, val); } + // Note: Copy the `set-cookie` meta-data. } catch (err) { _iterator.e(err); } finally { _iterator.f(); } + headersList.cookies = headers.cookies; } else { // 5. Otherwise, fill this’s headers with headers. fillHeaders(this[kHeaders], headers); @@ -20713,10 +20729,10 @@ var Request = /*#__PURE__*/function () { // 3. Let clonedRequestObject be the result of creating a Request object, // given clonedRequest, this’s headers’s guard, and this’s relevant Realm. - var clonedRequestObject = new Request(kInit); + var clonedRequestObject = new Request(kConstruct); clonedRequestObject[kState] = clonedRequest; clonedRequestObject[kRealm] = this[kRealm]; - clonedRequestObject[kHeaders] = new Headers(); + clonedRequestObject[kHeaders] = new Headers(kConstruct); clonedRequestObject[kHeaders][kHeadersList] = clonedRequest.headersList; clonedRequestObject[kHeaders][kGuard] = this[kHeaders][kGuard]; clonedRequestObject[kHeaders][kRealm] = this[kHeaders][kRealm]; @@ -20955,7 +20971,8 @@ var _require8 = __webpack_require__(2369), var _require9 = __webpack_require__(645), URLSerializer = _require9.URLSerializer; var _require10 = __webpack_require__(3329), - kHeadersList = _require10.kHeadersList; + kHeadersList = _require10.kHeadersList, + kConstruct = _require10.kConstruct; var assert = __webpack_require__(9491); var _require11 = __webpack_require__(3837), types = _require11.types; @@ -20985,7 +21002,7 @@ var Response = /*#__PURE__*/function () { // 2. Set this’s headers to a new Headers object with this’s relevant // Realm, whose header list is this’s response’s header list and guard // is "response". - this[kHeaders] = new Headers(); + this[kHeaders] = new Headers(kConstruct); this[kHeaders][kGuard] = 'response'; this[kHeaders][kHeadersList] = this[kState].headersList; this[kHeaders][kRealm] = this[kRealm]; @@ -21467,7 +21484,7 @@ webidl.converters.XMLHttpRequestBodyInit = function (V) { strict: false }); } - if (types.isAnyArrayBuffer(V) || types.isTypedArray(V) || types.isDataView(V)) { + if (types.isArrayBuffer(V) || types.isTypedArray(V) || types.isDataView(V)) { return webidl.converters.BufferSource(V); } if (util.isFormDataLike(V)) { @@ -21837,7 +21854,6 @@ function appendRequestOriginHeader(request) { default: // Do nothing. } - if (serializedOrigin) { // 2. Append (`Origin`, serializedOrigin) to request’s header list. request.headersList.append('origin', serializedOrigin); @@ -22244,10 +22260,31 @@ function isAborted(fetchParams) { function isCancelled(fetchParams) { return fetchParams.controller.state === 'aborted' || fetchParams.controller.state === 'terminated'; } +var normalizeMethodRecord = { + "delete": 'DELETE', + DELETE: 'DELETE', + get: 'GET', + GET: 'GET', + head: 'HEAD', + HEAD: 'HEAD', + options: 'OPTIONS', + OPTIONS: 'OPTIONS', + post: 'POST', + POST: 'POST', + put: 'PUT', + PUT: 'PUT' +}; + +// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. +Object.setPrototypeOf(normalizeMethodRecord, null); -// https://fetch.spec.whatwg.org/#concept-method-normalize +/** + * @see https://fetch.spec.whatwg.org/#concept-method-normalize + * @param {string} method + */ function normalizeMethod(method) { - return /^(DELETE|GET|HEAD|OPTIONS|POST|PUT)$/i.test(method) ? method.toUpperCase() : method; + var _normalizeMethodRecor; + return (_normalizeMethodRecor = normalizeMethodRecord[method.toLowerCase()]) !== null && _normalizeMethodRecor !== void 0 ? _normalizeMethodRecor : method; } // https://infra.spec.whatwg.org/#serialize-a-javascript-value-to-a-json-string @@ -22625,7 +22662,8 @@ module.exports = { urlIsLocal: urlIsLocal, urlHasHttpsScheme: urlHasHttpsScheme, urlIsHttpHttpsScheme: urlIsHttpHttpsScheme, - readAllBytes: readAllBytes + readAllBytes: readAllBytes, + normalizeMethodRecord: normalizeMethodRecord }; /***/ }), @@ -24833,7 +24871,7 @@ var _objectWithoutProperties = (__webpack_require__(215)["default"]); var _classCallCheck = (__webpack_require__(6690)["default"]); var _createClass = (__webpack_require__(9728)["default"]); var _excluded = ["retryOptions"]; -var assert = __webpack_require__(8061); +var assert = __webpack_require__(9491); var _require = __webpack_require__(3329), kRetryHandlerDefaultRetry = _require.kRetryHandlerDefaultRetry; var _require2 = __webpack_require__(7105), @@ -24928,7 +24966,7 @@ var RetryHandler = /*#__PURE__*/function () { }, { key: "onBodySent", value: function onBodySent(chunk) { - return this.handler.onBodySent(chunk); + if (this.handler.onBodySent) return this.handler.onBodySent(chunk); } }, { key: "onHeaders", @@ -25107,7 +25145,6 @@ var RetryHandler = /*#__PURE__*/function () { retryAfterHeader = Number(retryAfterHeader); retryAfterHeader = isNaN(retryAfterHeader) ? calculateRetryAfterHeader(retryAfterHeader) : retryAfterHeader * 1e3; // Retry-After is in seconds } - var retryTimeout = retryAfterHeader > 0 ? Math.min(retryAfterHeader, maxTimeout) : Math.min(currentTimeout * Math.pow(timeoutFactor, counter), maxTimeout); state.currentTimeout = retryTimeout; setTimeout(function () { @@ -27411,6 +27448,12 @@ var ProxyAgent = /*#__PURE__*/function (_DispatcherBase) { _this[kRequestTls] = opts.requestTls; _this[kProxyTls] = opts.proxyTls; _this[kProxyHeaders] = opts.headers || {}; + var resolvedUrl = new URL(opts.uri); + var origin = resolvedUrl.origin, + port = resolvedUrl.port, + host = resolvedUrl.host, + username = resolvedUrl.username, + password = resolvedUrl.password; if (opts.auth && opts.token) { throw new InvalidArgumentError('opts.auth cannot be used in combination with opts.token'); } else if (opts.auth) { @@ -27418,11 +27461,9 @@ var ProxyAgent = /*#__PURE__*/function (_DispatcherBase) { _this[kProxyHeaders]['proxy-authorization'] = "Basic ".concat(opts.auth); } else if (opts.token) { _this[kProxyHeaders]['proxy-authorization'] = opts.token; + } else if (username && password) { + _this[kProxyHeaders]['proxy-authorization'] = "Basic ".concat(Buffer.from("".concat(decodeURIComponent(username), ":").concat(decodeURIComponent(password))).toString('base64')); } - var resolvedUrl = new URL(opts.uri); - var origin = resolvedUrl.origin, - port = resolvedUrl.port, - host = resolvedUrl.host; var connect = buildConnector(_objectSpread({}, opts.proxyTls)); _this[kConnectEndpoint] = buildConnector(_objectSpread({}, opts.requestTls)); _this[kClient] = clientFactory(resolvedUrl, { @@ -27456,7 +27497,7 @@ var ProxyAgent = /*#__PURE__*/function (_DispatcherBase) { statusCode = _yield$_this$kClient$.statusCode; if (statusCode !== 200) { socket.on('error', function () {}).destroy(); - callback(new RequestAbortedError('Proxy response !== 200 when HTTP Tunneling')); + callback(new RequestAbortedError("Proxy response (".concat(statusCode, ") !== 200 when HTTP Tunneling"))); } if (!(opts.protocol !== 'https:')) { _context.next = 12; @@ -28989,7 +29030,6 @@ function isValidStatusCode(code) { code !== 1006 // "MUST NOT be set as a status code" ; } - return code >= 3000 && code <= 4999; } @@ -30147,14 +30187,6 @@ module.exports = require("net"); /***/ }), -/***/ 8061: -/***/ ((module) => { - -"use strict"; -module.exports = require("node:assert"); - -/***/ }), - /***/ 5673: /***/ ((module) => { @@ -34033,7 +34065,7 @@ var mini_svg_data_uri_default = /*#__PURE__*/__webpack_require__.n(mini_svg_data // Copied from `badgen` because it's not exported var getIconString=function getIconString(path){return (0,external_fs_.readFileSync)(path,'utf8');};function badge(option,summary){var _ref=option||{},_ref$label=_ref.label,label=_ref$label===void 0?'coverage':_ref$label,_ref$style=_ref.style,style=_ref$style===void 0?'classic':_ref$style,_ref$jsonPath=_ref.jsonPath,jsonPath=_ref$jsonPath===void 0?'total.statements.pct':_ref$jsonPath;var pct=summary;jsonPath.split(".").forEach(function(key){return pct=pct[key];});if(typeof pct!=='number'){throw new Error("".concat(jsonPath," evaluates to ").concat(JSON.stringify(pct)," and is not a suitable path in the JSON coverage data"));}var colorData={'#49c31a':[100],'#97c40f':[99.99,90],'#a0a127':[89.99,80],'#cba317':[79.99,60],'#ce0000':[59.99,0]};var color=Object.keys(colorData).find(function(value,idx){if(colorData[value].length===1&&pct>=colorData[value][0]){return true;}if(colorData[value].length===2&&pct<=colorData[value][0]&&pct>=colorData[value][1]){return true;}return false;});var badgenArgs={style:style,label:label,status:"".concat(pct<0?'Unknown':"".concat(pct,"%")),color:(color||'e5e5e5').replace(/^#/,'')};if(option.icon){var svgString=getIconString(option.icon);var svgDataUri=mini_svg_data_uri_default()(svgString);badgenArgs.icon=svgDataUri;}return (0,dist.badgen)(badgenArgs);} ;// CONCATENATED MODULE: ./src/action.ts -;_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var _require,version,output,source,label,style,sourceData,svgStr;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_require=__webpack_require__(4147),version=_require.version;(0,core.info)("coverage-badges-cli v\x1B[32;1m".concat(version,"\x1B[0m"));output=external_path_default().resolve(process.cwd(),(0,core.getInput)('output')||'coverage/badges.svg');source=external_path_default().resolve(process.cwd(),(0,core.getInput)('source')||'coverage/coverage-summary.json');label=(0,core.getInput)('label')||'coverage';style=(0,core.getInput)('style')||'classic';lib_default().ensureDirSync(external_path_default().dirname(output));if(lib_default().existsSync(source)){_context.next=11;break;}(0,core.setFailed)("File \x1B[31m".concat(source,"\x1B[0m does not exist.\n please specify the file directory\n\x1B[35mnpm\x1B[0m coverage-badges-cli \x1B[33m--source\x1B[0m coverage/coverage-summary.json"));return _context.abrupt("return");case 11:(0,core.info)("Source Path: \x1B[32;1m".concat(source,"\x1B[0m"));(0,core.info)("Output Path: \x1B[32;1m".concat(output,"\x1B[0m"));sourceData=lib_default().readJSONSync(source);(0,core.startGroup)("Source Path: \x1B[32;1m".concat(source,"\x1B[0m"));(0,core.info)("".concat(JSON.stringify(sourceData,null,2)));(0,core.endGroup)();svgStr=badge({label:label,style:style},sourceData);(0,core.setOutput)('svg',svgStr);(0,core.startGroup)("SVG String: \x1B[32;1m".concat(output,"\x1B[0m"));(0,core.info)("".concat(svgStr));(0,core.endGroup)();lib_default().writeFileSync(output,svgStr);(0,core.info)("\nCreate Coverage Badges: \x1B[32;1m".concat(external_path_default().relative(process.cwd(),output),"\x1B[0m\n"));_context.next=29;break;case 26:_context.prev=26;_context.t0=_context["catch"](0);(0,core.setFailed)(_context.t0.message);case 29:case"end":return _context.stop();}},_callee,null,[[0,26]]);}))(); +;_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var _require,version,output,source,label,jsonPath,style,sourceData,svgStr;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_require=__webpack_require__(4147),version=_require.version;(0,core.info)("coverage-badges-cli v\x1B[32;1m".concat(version,"\x1B[0m"));output=external_path_default().resolve(process.cwd(),(0,core.getInput)('output')||'coverage/badges.svg');source=external_path_default().resolve(process.cwd(),(0,core.getInput)('source')||'coverage/coverage-summary.json');label=(0,core.getInput)('label')||'coverage';jsonPath=(0,core.getInput)('jsonPath')||'total.statements.pct';style=(0,core.getInput)('style')||'classic';lib_default().ensureDirSync(external_path_default().dirname(output));if(lib_default().existsSync(source)){_context.next=12;break;}(0,core.setFailed)("File \x1B[31m".concat(source,"\x1B[0m does not exist.\n please specify the file directory\n\x1B[35mnpm\x1B[0m coverage-badges-cli \x1B[33m--source\x1B[0m coverage/coverage-summary.json"));return _context.abrupt("return");case 12:(0,core.info)("Source Path: \x1B[32;1m".concat(source,"\x1B[0m"));(0,core.info)("Output Path: \x1B[32;1m".concat(output,"\x1B[0m"));sourceData=lib_default().readJSONSync(source);(0,core.startGroup)("Source Path: \x1B[32;1m".concat(source,"\x1B[0m"));(0,core.info)("".concat(JSON.stringify(sourceData,null,2)));(0,core.endGroup)();svgStr=badge({label:label,style:style,jsonPath:jsonPath},sourceData);(0,core.setOutput)('svg',svgStr);(0,core.startGroup)("SVG String: \x1B[32;1m".concat(output,"\x1B[0m"));(0,core.info)("".concat(svgStr));(0,core.endGroup)();lib_default().writeFileSync(output,svgStr);(0,core.info)("\nCreate Coverage Badges: \x1B[32;1m".concat(external_path_default().relative(process.cwd(),output),"\x1B[0m\n"));_context.next=30;break;case 27:_context.prev=27;_context.t0=_context["catch"](0);(0,core.setFailed)(_context.t0.message);case 30:case"end":return _context.stop();}},_callee,null,[[0,27]]);}))(); })(); module.exports = __webpack_exports__; diff --git a/src/action.ts b/src/action.ts index 1bb535d..0a53b34 100644 --- a/src/action.ts +++ b/src/action.ts @@ -10,6 +10,7 @@ import { badge, BadgeOption } from './badges'; const output = path.resolve(process.cwd(), getInput('output') || 'coverage/badges.svg'); const source = path.resolve(process.cwd(), getInput('source') || 'coverage/coverage-summary.json'); const label = getInput('label') || 'coverage'; + const jsonPath = getInput('jsonPath') || 'total.statements.pct'; const style = (getInput('style') || 'classic') as BadgeOption['style']; fs.ensureDirSync(path.dirname(output)); if (!fs.existsSync(source)) { @@ -24,7 +25,7 @@ import { badge, BadgeOption } from './badges'; info(`${JSON.stringify(sourceData, null, 2)}`); endGroup(); - const svgStr = badge({ label, style } as BadgeOption, sourceData); + const svgStr = badge({ label, style, jsonPath } as BadgeOption, sourceData); setOutput('svg', svgStr);