Skip to content

Commit

Permalink
released v2.1.0 #35
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 4, 2024
1 parent ad3b10d commit 798bfe8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ inputs:

color:
description: "<Color RGB> or <Color Name> (default: '555')"
default: "555"
required: false

labelColor:
Expand Down
6 changes: 3 additions & 3 deletions dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -37246,10 +37246,10 @@ var mini_svg_data_uri_default = /*#__PURE__*/__webpack_require__.n(mini_svg_data
var lodash_get = __webpack_require__(7935);
var lodash_get_default = /*#__PURE__*/__webpack_require__.n(lodash_get);
;// ./src/badges.ts
var _excluded=["label","style","jsonPath"];// Copied from `badgen` because it's not exported
var getIconString=function getIconString(path){return (0,external_fs_.readFileSync)(path,'utf8');};var defaultColorData={'#49c31a':[100],'#97c40f':[99.99,90],'#a0a127':[89.99,80],'#cba317':[79.99,60],'#ce0000':[59.99,0]};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,otherOption=_objectWithoutProperties(_ref,_excluded);var pct=summary;pct=lodash_get_default()(summary,jsonPath,0);if(!isNaN(Number(pct))){pct=Number(pct);}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=defaultColorData;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=_objectSpread2(_objectSpread2({},otherOption),{},{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;}console.log("badgenArgs",badgenArgs);return (0,dist.badgen)(badgenArgs);}
var _excluded=["label","style","jsonPath","color"];// Copied from `badgen` because it's not exported
var getIconString=function getIconString(path){return (0,external_fs_.readFileSync)(path,'utf8');};var defaultColorData={'#49c31a':[100],'#97c40f':[99.99,90],'#a0a127':[89.99,80],'#cba317':[79.99,60],'#ce0000':[59.99,0]};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,optionColor=_ref.color,otherOption=_objectWithoutProperties(_ref,_excluded);var pct=summary;pct=lodash_get_default()(summary,jsonPath,0);if(!isNaN(Number(pct))){pct=Number(pct);}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=defaultColorData;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=_objectSpread2(_objectSpread2({},otherOption),{},{style:style,label:label,status:"".concat(pct<0?'Unknown':"".concat(pct,"%")),color:(color||'e5e5e5').replace(/^#/,'')});if(optionColor){badgenArgs.color=optionColor.replace(/^#/,'');}if(option.icon){var svgString=getIconString(option.icon);var svgDataUri=mini_svg_data_uri_default()(svgString);badgenArgs.icon=svgDataUri;}console.log("badgenArgs",badgenArgs);return (0,dist.badgen)(badgenArgs);}
;// ./src/action.ts
;_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var _require,version,output,source,label,labelColor,scale,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__(8330),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';labelColor=(0,core.getInput)('labelColor')||'555';scale=Number((0,core.getInput)('scale')||1)||1;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=14;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 14:(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,labelColor:labelColor,style:style,jsonPath:jsonPath,scale:scale},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=32;break;case 29:_context.prev=29;_context.t0=_context["catch"](0);(0,core.setFailed)(_context.t0.message);case 32:case"end":return _context.stop();}},_callee,null,[[0,29]]);}))();
;_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var _require,version,output,source,label,labelColor,color,scale,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__(8330),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';labelColor=(0,core.getInput)('labelColor')||'555';color=(0,core.getInput)('color');scale=Number((0,core.getInput)('scale')||1)||1;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=15;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 15:(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,labelColor:labelColor,color:color,style:style,jsonPath:jsonPath,scale:scale},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=33;break;case 30:_context.prev=30;_context.t0=_context["catch"](0);(0,core.setFailed)(_context.t0.message);case 33:case"end":return _context.stop();}},_callee,null,[[0,30]]);}))();
})();

module.exports = __webpack_exports__;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coverage-badges-cli",
"version": "2.0.0",
"version": "2.1.0",
"description": "Create coverage badges from coverage reports. Using GitHub Actions and GitHub Workflow CPU time (no 3rd parties servers).",
"homepage": "https://jaywcjlove.github.io/coverage-badges-cli/",
"funding": "https://jaywcjlove.github.io/#/sponsor",
Expand Down

0 comments on commit 798bfe8

Please sign in to comment.