From e1b7b0d0b9d04cdd4ce6616f4e2d95a108e4983c Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Fri, 8 Mar 2024 01:11:47 +0800 Subject: [PATCH] chore: add body content log. --- dist/index.js | 38 +++++++++++++++++++------------------- src/index.ts | 9 ++++++--- src/utils.ts | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/dist/index.js b/dist/index.js index 31d8c63..5997fb4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -37881,24 +37881,6 @@ var regeneratorRuntime = __webpack_require__(675); var asyncToGenerator = __webpack_require__(467); // EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js var core = __webpack_require__(3716); -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js -function _objectDestructuringEmpty(obj) { - if (obj == null) throw new TypeError("Cannot destructure " + obj); -} -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js -var objectSpread2 = __webpack_require__(9379); -// EXTERNAL MODULE: ./node_modules/fs-extra/lib/index.js -var lib = __webpack_require__(9184); -var lib_default = /*#__PURE__*/__webpack_require__.n(lib); -// EXTERNAL MODULE: external "path" -var external_path_ = __webpack_require__(6928); -var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_); -// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js -var github = __webpack_require__(8340); -;// CONCATENATED MODULE: ./src/utils.ts -// export type FilePutResult = paths['/repos/{owner}/{repo}/contents/{path}']['get']['responses']['200']['content']['application/vnd.github.v3.object'] -// export type FilePutResultData = components['schemas']['content-file'] -var myToken=(0,core.getInput)('token');var octokit=(0,github.getOctokit)(myToken);var getInputs=function getInputs(){var body=(0,core.getInput)('body')||'';var ref=(0,core.getInput)('ref')||github.context.ref;var branch=(0,core.getInput)('branch');var sha=(0,core.getInput)('sha');var overwrite=(0,core.getInput)('overwrite')||'false';var sync_local_file=(0,core.getInput)('sync_local_file')||'true';var filepath=(0,core.getInput)('path')||'';var message=(0,core.getInput)('message')||'';var committer_name=(0,core.getInput)('committer_name')||'';var committer_email=(0,core.getInput)('committer_email')||'';var openDelimiter=(0,core.getInput)('openDelimiter')||'';var closeDelimiter=(0,core.getInput)('closeDelimiter')||'';return (0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},github.context.repo),{},{body:body,filepath:filepath,ref:ref,branch:branch,sha:sha,message:message,committer_name:committer_name,committer_email:committer_email,openDelimiter:openDelimiter,closeDelimiter:closeDelimiter,overwrite:overwrite,sync_local_file:sync_local_file});};function getBranch(){return _getBranch.apply(this,arguments);}function _getBranch(){_getBranch=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee(){var _getInputs2,branch,_yield$octokit$rest$r,data;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_getInputs2=getInputs(),branch=_getInputs2.branch;if(!(branch!==null)){_context.next=3;break;}return _context.abrupt("return",Promise.resolve(branch));case 3:_context.next=5;return octokit.rest.repos.get(github.context.repo);case 5:_yield$octokit$rest$r=_context.sent;data=_yield$octokit$rest$r.data;return _context.abrupt("return",data.default_branch);case 8:case"end":return _context.stop();}},_callee);}));return _getBranch.apply(this,arguments);}function getFileContents(_x){return _getFileContents.apply(this,arguments);}function _getFileContents(){_getFileContents=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee2(branch){var _getInputs3,owner,repo,filepath,_yield$octokit$rest$r2,data;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_getInputs3=getInputs(),owner=_getInputs3.owner,repo=_getInputs3.repo,filepath=_getInputs3.filepath;_context2.prev=1;_context2.next=4;return octokit.rest.repos.getContent({owner:owner,repo:repo,ref:branch,path:filepath});case 4:_yield$octokit$rest$r2=_context2.sent;data=_yield$octokit$rest$r2.data;return _context2.abrupt("return",data);case 9:_context2.prev=9;_context2.t0=_context2["catch"](1);(0,core.warning)("\uD83D\uDC49 Get File Contents: ".concat(_context2.t0 instanceof Error?_context2.t0.message:_context2.t0));return _context2.abrupt("return");case 13:case"end":return _context2.stop();}},_callee2,null,[[1,9]]);}));return _getFileContents.apply(this,arguments);}function getBodyContent(oldFileContent,content){var _getInputs=getInputs(),openDelimiter=_getInputs.openDelimiter,closeDelimiter=_getInputs.closeDelimiter,overwrite=_getInputs.overwrite;var REG=new RegExp("".concat(openDelimiter,"([\\s\\S]*?)").concat(closeDelimiter),'ig');var match=oldFileContent.match(REG);(0,core.startGroup)("\uD83D\uDC49 Current File content: ".concat(match===null||match===void 0?void 0:match.length));(0,core.info)("\uD83D\uDC49 ".concat(JSON.stringify(match,null,2)));(0,core.endGroup)();if(overwrite.toString()==='true'){}return oldFileContent.replace(REG,"".concat(openDelimiter).concat(content).concat(closeDelimiter));}function modifyPathContents(){return _modifyPathContents.apply(this,arguments);}function _modifyPathContents(){_modifyPathContents=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee3(){var options,content,other,_getInputs4,owner,repo,message,committer_name,committer_email,overwrite,sync_local_file,ref,branch,new_content,body,currentFile,_result$data$content,_result$data$content2,_result$data$content3,fileContent,oldFileContent,reuslt,fullPath,isExists,result,_result$data$content4,_result$data$content5,_result$data$content6,_result,_args3=arguments;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:options=_args3.length>0&&_args3[0]!==undefined?_args3[0]:{};content=_args3.length>1?_args3[1]:undefined;other=Object.assign({},(_objectDestructuringEmpty(options),options));_getInputs4=getInputs(),owner=_getInputs4.owner,repo=_getInputs4.repo,message=_getInputs4.message,committer_name=_getInputs4.committer_name,committer_email=_getInputs4.committer_email,overwrite=_getInputs4.overwrite,sync_local_file=_getInputs4.sync_local_file,ref=_getInputs4.ref;_context3.next=6;return getBranch();case 6:branch=_context3.sent;if(options.path){_context3.next=9;break;}throw new Error("modifyPathContents: file directory parameter does not exist");case 9:(0,core.info)("\uD83D\uDC49 Modify Path (".concat(options.path,")"));(0,core.info)("\uD83D\uDC49 Context.ref: (".concat(github.context.ref,")"));(0,core.info)("\uD83D\uDC49 Context.sha: (".concat(github.context.sha,")"));(0,core.info)("\uD83D\uDC49 branch: (".concat(branch,")"));new_content=Buffer.from(content).toString("base64");body=(0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({owner:owner,repo:repo,path:options.path,branch:branch,message:message||"doc: update ".concat(options.path,"."),committer:{name:committer_name||'github-actions[bot]',email:committer_email||'github-actions[bot]@users.noreply.github.com'}},other),{},{content:new_content});(0,core.startGroup)("\uD83D\uDC49 Init Body: (".concat(branch,")"));(0,core.info)("\uD83D\uDC49 ".concat(JSON.stringify(body,null,2)));(0,core.endGroup)();_context3.next=20;return getFileContents(branch);case 20:currentFile=_context3.sent;if(!(currentFile&&'content'in currentFile)){_context3.next=58;break;}fileContent=currentFile.content||'';oldFileContent=Buffer.from(fileContent,'base64').toString();reuslt=getBodyContent(oldFileContent,content);(0,core.startGroup)("\uD83D\uDC49 Current File content: ".concat(options.path));(0,core.info)("\uD83D\uDC49 ".concat(JSON.stringify(currentFile,null,2)));(0,core.endGroup)();if(overwrite.toString()==='true'){body.content=new_content;reuslt=content;}else{body.content=Buffer.from(reuslt).toString("base64");new_content=reuslt;}(0,core.setOutput)('content',Buffer.from(body.content,'base64').toString());(0,core.startGroup)("\uD83D\uDC49 Text OLD content: ".concat(oldFileContent==reuslt));(0,core.info)("\uD83D\uDC49 ".concat(oldFileContent));(0,core.endGroup)();(0,core.startGroup)("\uD83D\uDC49 Text NEW content: ".concat(oldFileContent==reuslt));(0,core.info)("\uD83D\uDC49 ".concat(reuslt));(0,core.endGroup)();if(!(oldFileContent==reuslt)){_context3.next=39;break;}(0,core.warning)("\uD83D\uDC49 Content has not changed!!!!!");return _context3.abrupt("return");case 39:body=(0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},body),currentFile),{},{content:body.content,sha:currentFile.sha});fullPath=external_path_default().resolve(options.path);isExists=lib_default().existsSync(fullPath);if(!(isExists&&sync_local_file.toString()==='true'&&ref===github.context.ref)){_context3.next=45;break;}_context3.next=45;return lib_default().writeFile(fullPath,new_content);case 45:(0,core.startGroup)("modifyPathContents Body:");(0,core.info)("\uD83D\uDC49 ".concat(JSON.stringify(body,null,2)));(0,core.endGroup)();_context3.next=50;return octokit.request('PUT /repos/{owner}/{repo}/contents/{path}',(0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},body),{},{sha:currentFile.sha}));case 50:result=_context3.sent;(0,core.startGroup)("file result:");(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content=result.data.content)===null||_result$data$content===void 0?void 0:_result$data$content.path));(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content2=result.data.content)===null||_result$data$content2===void 0?void 0:_result$data$content2.size));(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content3=result.data.content)===null||_result$data$content3===void 0?void 0:_result$data$content3.sha));(0,core.endGroup)();_context3.next=67;break;case 58:(0,core.warning)("\uD83D\uDC49 Not Found ::- ".concat(options.path));_context3.next=61;return octokit.request('PUT /repos/{owner}/{repo}/contents/{path}',(0,objectSpread2/* default */.A)({},body));case 61:_result=_context3.sent;(0,core.startGroup)("file result:");(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content4=_result.data.content)===null||_result$data$content4===void 0?void 0:_result$data$content4.path));(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content5=_result.data.content)===null||_result$data$content5===void 0?void 0:_result$data$content5.size));(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content6=_result.data.content)===null||_result$data$content6===void 0?void 0:_result$data$content6.sha));(0,core.endGroup)();case 67:case"end":return _context3.stop();}},_callee3);}));return _modifyPathContents.apply(this,arguments);} ;// CONCATENATED MODULE: ./node_modules/@uiw/formatter/esm/index.js /**! * @uiw/formatter v2.0.2 @@ -37947,8 +37929,26 @@ formatter.utc = function (str, date) { }; //# sourceMappingURL=index.js.map +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure " + obj); +} +// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js +var objectSpread2 = __webpack_require__(9379); +// EXTERNAL MODULE: ./node_modules/fs-extra/lib/index.js +var lib = __webpack_require__(9184); +var lib_default = /*#__PURE__*/__webpack_require__.n(lib); +// EXTERNAL MODULE: external "path" +var external_path_ = __webpack_require__(6928); +var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_); +// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js +var github = __webpack_require__(8340); +;// CONCATENATED MODULE: ./src/utils.ts +// export type FilePutResult = paths['/repos/{owner}/{repo}/contents/{path}']['get']['responses']['200']['content']['application/vnd.github.v3.object'] +// export type FilePutResultData = components['schemas']['content-file'] +var myToken=(0,core.getInput)('token');var octokit=(0,github.getOctokit)(myToken);var getInputs=function getInputs(){var body=(0,core.getInput)('body')||'';var ref=(0,core.getInput)('ref')||github.context.ref;var branch=(0,core.getInput)('branch');var sha=(0,core.getInput)('sha');var overwrite=(0,core.getInput)('overwrite')||'false';var sync_local_file=(0,core.getInput)('sync_local_file')||'true';var filepath=(0,core.getInput)('path')||'';var message=(0,core.getInput)('message')||'';var committer_name=(0,core.getInput)('committer_name')||'';var committer_email=(0,core.getInput)('committer_email')||'';var openDelimiter=(0,core.getInput)('openDelimiter')||'';var closeDelimiter=(0,core.getInput)('closeDelimiter')||'';return (0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},github.context.repo),{},{body:body,filepath:filepath,ref:ref,branch:branch,sha:sha,message:message,committer_name:committer_name,committer_email:committer_email,openDelimiter:openDelimiter,closeDelimiter:closeDelimiter,overwrite:overwrite,sync_local_file:sync_local_file});};function getBranch(){return _getBranch.apply(this,arguments);}function _getBranch(){_getBranch=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee(){var _getInputs2,branch,_yield$octokit$rest$r,data;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_getInputs2=getInputs(),branch=_getInputs2.branch;if(!(branch!==null)){_context.next=3;break;}return _context.abrupt("return",Promise.resolve(branch));case 3:_context.next=5;return octokit.rest.repos.get(github.context.repo);case 5:_yield$octokit$rest$r=_context.sent;data=_yield$octokit$rest$r.data;return _context.abrupt("return",data.default_branch);case 8:case"end":return _context.stop();}},_callee);}));return _getBranch.apply(this,arguments);}function getFileContents(_x){return _getFileContents.apply(this,arguments);}function _getFileContents(){_getFileContents=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee2(branch){var _getInputs3,owner,repo,filepath,_yield$octokit$rest$r2,data;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_getInputs3=getInputs(),owner=_getInputs3.owner,repo=_getInputs3.repo,filepath=_getInputs3.filepath;_context2.prev=1;_context2.next=4;return octokit.rest.repos.getContent({owner:owner,repo:repo,ref:branch,path:filepath});case 4:_yield$octokit$rest$r2=_context2.sent;data=_yield$octokit$rest$r2.data;return _context2.abrupt("return",data);case 9:_context2.prev=9;_context2.t0=_context2["catch"](1);(0,core.warning)("\uD83D\uDC49 Get File Contents: ".concat(_context2.t0 instanceof Error?_context2.t0.message:_context2.t0));return _context2.abrupt("return");case 13:case"end":return _context2.stop();}},_callee2,null,[[1,9]]);}));return _getFileContents.apply(this,arguments);}function getBodyContent(oldFileContent,content){var _getInputs=getInputs(),openDelimiter=_getInputs.openDelimiter,closeDelimiter=_getInputs.closeDelimiter,overwrite=_getInputs.overwrite;var REG=new RegExp("".concat(openDelimiter,"([\\s\\S]*?)").concat(closeDelimiter),'ig');var match=oldFileContent.match(REG);(0,core.startGroup)("\uD83D\uDC49 Current File content: ".concat(match===null||match===void 0?void 0:match.length));(0,core.info)("\uD83D\uDC49 ".concat(JSON.stringify(match,null,2)));(0,core.endGroup)();if(overwrite.toString()==='true'){}return oldFileContent.replace(REG,"".concat(openDelimiter).concat(content).concat(closeDelimiter));}function modifyPathContents(){return _modifyPathContents.apply(this,arguments);}function _modifyPathContents(){_modifyPathContents=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee3(){var options,content,other,_getInputs4,owner,repo,message,committer_name,committer_email,overwrite,sync_local_file,ref,branch,new_content,body,currentFile,_result$data$content,_result$data$content2,_result$data$content3,fileContent,oldFileContent,reuslt,fullPath,isExists,result,_result$data$content4,_result$data$content5,_result$data$content6,_result,_args3=arguments;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:options=_args3.length>0&&_args3[0]!==undefined?_args3[0]:{};content=_args3.length>1?_args3[1]:undefined;other=Object.assign({},(_objectDestructuringEmpty(options),options));_getInputs4=getInputs(),owner=_getInputs4.owner,repo=_getInputs4.repo,message=_getInputs4.message,committer_name=_getInputs4.committer_name,committer_email=_getInputs4.committer_email,overwrite=_getInputs4.overwrite,sync_local_file=_getInputs4.sync_local_file,ref=_getInputs4.ref;_context3.next=6;return getBranch();case 6:branch=_context3.sent;if(options.path){_context3.next=9;break;}throw new Error("modifyPathContents: file directory parameter does not exist");case 9:(0,core.info)("\uD83D\uDC49 Modify Path (".concat(options.path,")"));(0,core.info)("\uD83D\uDC49 Context.ref: (".concat(github.context.ref,")"));(0,core.info)("\uD83D\uDC49 Context.sha: (".concat(github.context.sha,")"));(0,core.info)("\uD83D\uDC49 branch: (".concat(branch,")"));new_content=Buffer.from(content).toString("base64");body=(0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({owner:owner,repo:repo,path:options.path,branch:branch,message:message||"doc: update ".concat(options.path,"."),committer:{name:committer_name||'github-actions[bot]',email:committer_email||'github-actions[bot]@users.noreply.github.com'}},other),{},{content:new_content});(0,core.startGroup)("\uD83D\uDC49 Init Body: (".concat(branch,")"));(0,core.info)("\uD83D\uDC49 ".concat(JSON.stringify(body,null,2)));(0,core.endGroup)();_context3.next=20;return getFileContents(branch);case 20:currentFile=_context3.sent;if(!(currentFile&&'content'in currentFile)){_context3.next=58;break;}fileContent=currentFile.content||'';oldFileContent=Buffer.from(fileContent,'base64').toString();reuslt=getBodyContent(oldFileContent,content);(0,core.startGroup)("\uD83D\uDC49 Current File content: ".concat(options.path));(0,core.info)("\uD83D\uDC49 ".concat(JSON.stringify(currentFile,null,2)));(0,core.endGroup)();if(overwrite.toString()==='true'){body.content=new_content;reuslt=content;}else{body.content=Buffer.from(reuslt).toString("base64");new_content=reuslt;}(0,core.setOutput)('content',Buffer.from(body.content,'base64').toString());(0,core.startGroup)("\uD83D\uDC49 Text OLD content: ".concat(oldFileContent==reuslt));(0,core.info)("\uD83D\uDC49 ".concat(oldFileContent));(0,core.endGroup)();(0,core.startGroup)("\uD83D\uDC49 Text NEW content: ".concat(oldFileContent==reuslt));(0,core.info)("\uD83D\uDC49 ".concat(reuslt));(0,core.endGroup)();if(!(oldFileContent==reuslt)){_context3.next=39;break;}(0,core.warning)("\uD83D\uDC49 Content has not changed!!!!!");return _context3.abrupt("return");case 39:body=(0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},body),currentFile),{},{content:body.content,sha:currentFile.sha});fullPath=external_path_default().resolve(options.path);isExists=lib_default().existsSync(fullPath);if(!(isExists&&sync_local_file.toString()==='true'&&ref===github.context.ref)){_context3.next=45;break;}_context3.next=45;return lib_default().writeFile(fullPath,new_content);case 45:(0,core.startGroup)("modifyPathContents Body:");(0,core.info)("\uD83D\uDC49 ".concat(JSON.stringify(body,null,2)));(0,core.endGroup)();_context3.next=50;return octokit.request('PUT /repos/{owner}/{repo}/contents/{path}',(0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},body),{},{sha:currentFile.sha}));case 50:result=_context3.sent;(0,core.startGroup)("file result:");(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content=result.data.content)===null||_result$data$content===void 0?void 0:_result$data$content.path));(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content2=result.data.content)===null||_result$data$content2===void 0?void 0:_result$data$content2.size));(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content3=result.data.content)===null||_result$data$content3===void 0?void 0:_result$data$content3.sha));(0,core.endGroup)();_context3.next=67;break;case 58:(0,core.warning)("\uD83D\uDC49 Not Found ::- ".concat(options.path));_context3.next=61;return octokit.request('PUT /repos/{owner}/{repo}/contents/{path}',(0,objectSpread2/* default */.A)({},body));case 61:_result=_context3.sent;(0,core.startGroup)("file result:");(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content4=_result.data.content)===null||_result$data$content4===void 0?void 0:_result$data$content4.path));(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content5=_result.data.content)===null||_result$data$content5===void 0?void 0:_result$data$content5.size));(0,core.info)("\uD83D\uDC49 ".concat((_result$data$content6=_result.data.content)===null||_result$data$content6===void 0?void 0:_result$data$content6.sha));(0,core.endGroup)();case 67:case"end":return _context3.stop();}},_callee3);}));return _modifyPathContents.apply(this,arguments);} ;// CONCATENATED MODULE: ./src/index.ts -var REGEXP=/\{\{date:?(.*?)\}\}/ig;(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee(){var filepath,body,result;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:filepath=(0,core.getInput)('path')||'';_context.prev=1;body=(0,core.getInput)('body')||'';if(body){_context.next=6;break;}(0,core.warning)("\uD83D\uDC49 \"body\" input value does not exist.");return _context.abrupt("return");case 6:if(filepath){_context.next=9;break;}(0,core.warning)("\uD83D\uDC49 \"path\" input value does not exist.");return _context.abrupt("return");case 9:if(REGEXP.test(body)){result=body.replace(REGEXP,function(match,str2){var format=match.replace(REGEXP,'$1');var str=formatter(format||'YYYY/MM/DD HH:mm:ss',new Date());return str;});if(result){body=result;}}(0,core.info)("\uD83D\uDC49 Body Content: ".concat(body));_context.next=13;return modifyPathContents({path:filepath},body);case 13:_context.next=18;break;case 15:_context.prev=15;_context.t0=_context["catch"](1);if(_context.t0 instanceof Error){(0,core.setFailed)("".concat(_context.t0.message," - ").concat(filepath));}case 18:case"end":return _context.stop();}},_callee,null,[[1,15]]);}))(); +var REGEXP=/\{\{date:?(.*?)\}\}/ig;(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee(){var filepath,body,result;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:filepath=(0,core.getInput)('path')||'';_context.prev=1;body=(0,core.getInput)('body')||'';if(body){_context.next=6;break;}(0,core.warning)("\uD83D\uDC49 \"body\" input value does not exist.");return _context.abrupt("return");case 6:if(filepath){_context.next=9;break;}(0,core.warning)("\uD83D\uDC49 \"path\" input value does not exist.");return _context.abrupt("return");case 9:if(REGEXP.test(body)){result=body.replace(REGEXP,function(match,str2){var format=match.replace(REGEXP,'$1');var str=formatter(format||'YYYY/MM/DD HH:mm:ss',new Date());return str;});if(result){body=result;}}(0,core.startGroup)("\uD83D\uDC49 Body input content:");(0,core.info)(body);(0,core.endGroup)();_context.next=15;return modifyPathContents({path:filepath},body);case 15:_context.next=20;break;case 17:_context.prev=17;_context.t0=_context["catch"](1);if(_context.t0 instanceof Error){(0,core.setFailed)("".concat(_context.t0.message," - ").concat(filepath));}case 20:case"end":return _context.stop();}},_callee,null,[[1,17]]);}))(); })(); module.exports = __webpack_exports__; diff --git a/src/index.ts b/src/index.ts index d8bc2a2..95d3fd5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ -import { getInput, setFailed, info, warning, startGroup, endGroup } from '@actions/core'; -import { modifyPathContents } from './utils'; +import { getInput, startGroup, endGroup, setFailed, info, warning } from '@actions/core'; import formatter from '@uiw/formatter'; +import { modifyPathContents } from './utils'; const REGEXP = /\{\{date:?(.*?)\}\}/ig @@ -27,7 +27,10 @@ const REGEXP = /\{\{date:?(.*?)\}\}/ig body = result } } - info(`👉 Body Content: ${body}`) + + startGroup(`👉 Body input content:`); + info(body) + endGroup(); await modifyPathContents({ path: filepath }, body); } catch (error) { diff --git a/src/utils.ts b/src/utils.ts index 03d4c68..f0b866e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,7 +2,7 @@ import FS from 'fs-extra'; import path from 'path'; import { context, getOctokit } from '@actions/github'; import { getInput, setOutput, startGroup, info, endGroup, warning } from '@actions/core'; -import { paths, components, } from '@octokit/openapi-types'; +import { paths } from '@octokit/openapi-types'; import { GetResponseTypeFromEndpointMethod } from '@octokit/types'; export type FilePutQuery = paths['/repos/{owner}/{repo}/contents/{path}']['put']['requestBody']['content']['application/json'] & paths['/repos/{owner}/{repo}/contents/{path}']['put']['parameters']['path'];