Skip to content

Commit

Permalink
fix: build js. (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 4, 2023
1 parent 0f55e0b commit a3400d2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11363,7 +11363,7 @@ var slicedToArray = __webpack_require__(885);
;// CONCATENATED MODULE: ./src/utils.ts
var getVersion=function getVersion(){var ver=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';var currentVersion='';ver.replace(/([v|V]\d(\.\d+){0,2})/i,function(str){currentVersion=str;return str;});return currentVersion;};var defaultTypes={type:'🆎',feat:'🌟',style:'🎨',chore:'💄',doc:'📖',docs:'📖',build:'🧯',fix:'🐞',test:'⛑',refactor:'🐝',website:'🌍',revert:'🔙',clean:'💊',perf:'📈',ci:'💢',__unknown__:'📄'};function formatStringCommit(){var commit=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';var repoName=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var _ref=arguments.length>2?arguments[2]:undefined,regExp=_ref.regExp,shortHash=_ref.shortHash,originalMarkdown=_ref.originalMarkdown,filterAuthor=_ref.filterAuthor,hash=_ref.hash,_ref$login=_ref.login,login=_ref$login===void 0?'':_ref$login;if(filterAuthor&&new RegExp(filterAuthor).test(login)){login='';}if(regExp&&new RegExp(regExp).test(commit)){return'';}login=login.replace(/\[bot\]/,'-bot');if(originalMarkdown){return"".concat(commit," ").concat(shortHash," ").concat(login?"@".concat(login):'');}return"".concat(commit," [`").concat(shortHash,"`](http://github.com/").concat(repoName,"/commit/").concat(hash,")").concat(login?" @".concat(login):'');}function getRegExp(){var str=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';var commit=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';return new RegExp("^(".concat(str,"s+[s|(|:])|(").concat(str,"[(|:])")).test(commit.trim().toLocaleLowerCase());}function getCommitLog(log){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var types=options.types,_options$category=options.category,category=_options$category===void 0?{}:_options$category,showEmoji=options.showEmoji,template=options.template,_options$removeType=options.removeType,removeType=_options$removeType===void 0?false:_options$removeType;if(!Array.isArray(category['__unknown__']))category['__unknown__']=[];log=log.map(function(commit){Object.keys(types||{}).forEach(function(name){if(!category[name])category[name]=[];if(getRegExp(name,commit)){commit=showEmoji?"- ".concat(types[name]," ").concat(commit):"- ".concat(commit);category[name].push(commit);}});if(!/^-\s/.test(commit)&&commit){commit=showEmoji?"- ".concat(types['__unknown__']," ").concat(commit):"- ".concat(commit);category['__unknown__'].push(commit);}if(removeType){commit=commit.replace(/(^-\s+?\w+(\s+)?\((.*?)\):\s+)|(^-\s+?\w+(\s+)?:\s+)/,'- ');}return commit;}).filter(Boolean);var changelogContent='';/**
* https://github.com/jaywcjlove/changelog-generator/issues/111#issuecomment-1594085749
*/if(template&&typeof template==='string'){changelogContent=template.replace(/\{\{(.*?)\}\}/g,function(string,replaceValue){var _split=(replaceValue||'').split('||'),_split2=(0,slicedToArray/* default */.Z)(_split,2),_split2$=_split2[0],typeString=_split2$===void 0?'':_split2$,emptyString=_split2[1];var arr=typeString.replace(/\s/g,'').split(',').map(function(name){return category[name]||[];}).flat().filter(Boolean);if(arr.length===0&&emptyString)return emptyString;if(arr.length>0)return arr.join('\n');return string;});changelogContent=changelogContent.replace(/##+\s[\D]+\{\{\w+\}\}/g,'');}else{changelogContent=log.join('\n');}return{changelog:log,category:category,changelogContent:changelogContent};}
*/if(template&&typeof template==='string'){changelogContent=template.replace(/\{\{(.*?)\}\}/g,function(string,replaceValue){var _split=(replaceValue||'').split('||'),_split2=(0,slicedToArray/* default */.Z)(_split,2),_split2$=_split2[0],typeString=_split2$===void 0?'':_split2$,emptyString=_split2[1];var arr=typeString.replace(/\s/g,'').split(',').map(function(name){return category[name]||[];}).flat().filter(Boolean);if(arr.length===0&&emptyString)return emptyString;if(arr.length>0)return arr.join('\n');return string;});changelogContent=changelogContent.replace(/##(.*?)\n+\{\{(.*?)\}\}(\s+)?(\n+)?/g,'');}else{changelogContent=log.join('\n');}return{changelog:log,category:category,changelogContent:changelogContent};}
;// CONCATENATED MODULE: ./src/index.ts
var regexp=/^[.A-Za-z0-9_-]*$/;var getOptions=function getOptions(){var myToken=(0,core.getInput)('token');return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({},github.context.repo),{},{headRef:(0,core.getInput)('head-ref'),baseRef:(0,core.getInput)('base-ref'),myToken:myToken,myPath:(0,core.getInput)('path'),template:(0,core.getInput)('template'),/** @example `type🆎,chore💄,fix🐞` Use commas to separate */customEmoji:(0,core.getInput)('custom-emoji')||'',showEmoji:(0,core.getInput)('show-emoji')==='false'?false:true,removeType:(0,core.getInput)('remove-type')==='false'?false:true,filterAuthor:(0,core.getInput)('filter-author'),regExp:(0,core.getInput)('filter'),ghPagesBranch:(0,core.getInput)('gh-pages')||'gh-pages',originalMarkdown:(0,core.getInput)('original-markdown'),octokit:(0,github.getOctokit)(myToken),types:defaultTypes});};function run(){return _run.apply(this,arguments);}function _run(){_run=(0,asyncToGenerator/* default */.Z)(/*#__PURE__*/(0,regeneratorRuntime/* default */.Z)().mark(function _callee(){var options,_ref,myPath,template,customEmoji,removeType,showEmoji,filterAuthor,regExp,ghPagesBranch,originalMarkdown,owner,repo,octokit,types,customEmojiData,latestRelease,tagRef,branch,branchData,ghPagesData,resultData,commitsData,_commitsData,commitLog,_iterator,_step,data,message,author,listTags,_getCommitLog,changelog,changelogContent;return (0,regeneratorRuntime/* default */.Z)().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;options=getOptions();_ref=options||{},myPath=_ref.myPath,template=_ref.template,customEmoji=_ref.customEmoji,removeType=_ref.removeType,showEmoji=_ref.showEmoji,filterAuthor=_ref.filterAuthor,regExp=_ref.regExp,ghPagesBranch=_ref.ghPagesBranch,originalMarkdown=_ref.originalMarkdown,owner=_ref.owner,repo=_ref.repo,octokit=_ref.octokit,types=_ref.types;customEmojiData=customEmoji.split(',');if(customEmoji&&customEmojiData.length){customEmojiData.forEach(function(item){var emojiIcon=item.match(/(?:[\u2600-\u27BF]|\uD83C[\uDDE0-\uDDFF\uDF00-\uDFFF]|\uD83D[\uDC00-\uDEFF]|\uD83E[\uDD00-\uDDFF])/g);var typeName=item.replace(/(?:[\u2600-\u27BF]|\uD83C[\uDDE0-\uDDFF\uDF00-\uDFFF]|\uD83D[\uDC00-\uDEFF]|\uD83E[\uDD00-\uDDFF])/g,'');if(typeName&&emojiIcon){types[typeName]=emojiIcon[0];}});}if(options.baseRef){_context.next=14;break;}_context.next=8;return octokit.rest.repos.getLatestRelease((0,objectSpread2/* default */.Z)({},github.context.repo));case 8:latestRelease=_context.sent;if(latestRelease.status!==200){(0,core.setFailed)("There are no releases on ".concat(owner,"/").concat(repo,". Tags are not releases. (status=").concat(latestRelease.status,") ").concat(latestRelease.data.message||''));}options.baseRef=latestRelease.data.tag_name;(0,core.startGroup)("Latest Release Result Data: \x1B[32m".concat(latestRelease.status||'-',"\x1B[0m \x1B[32m").concat(latestRelease.data.tag_name,"\x1B[0m"));(0,core.info)("".concat(JSON.stringify(latestRelease,null,2)));(0,core.endGroup)();case 14:if(!options.headRef){options.headRef=github.context.sha;}(0,core.info)("Commit Content: \x1B[34m".concat(owner,"/").concat(repo,"\x1B[0m"));(0,core.startGroup)("Ref: \x1B[34m".concat(github.context.ref,"\x1B[0m"));(0,core.info)("".concat(JSON.stringify(github.context,null,2)));(0,core.endGroup)();tagRef='';if((github.context.ref||'').startsWith('refs/tags/')){tagRef=getVersion(github.context.ref);}if((github.context.ref||'').startsWith('refs/heads/')){branch=github.context.ref.replace(/.*(?=\/)\//,'');(0,core.setOutput)('branch',branch);(0,core.info)("Branch: \x1B[34m".concat(branch,"\x1B[0m"));}(0,core.info)("Ref: baseRef(\x1B[32m".concat(options.baseRef,"\x1B[0m), options.headRef(\x1B[32m").concat(options.headRef,"\x1B[0m), tagRef(\x1B[32m").concat(tagRef,"\x1B[0m)"));_context.prev=23;_context.next=26;return octokit.request('GET /repos/{owner}/{repo}/branches',(0,objectSpread2/* default */.Z)({},github.context.repo));case 26:branchData=_context.sent;ghPagesData=branchData.data.find(function(item){return item.name===ghPagesBranch;});(0,core.startGroup)("\x1B[34mGet Branch \x1B[0m");(0,core.info)("Branch Data: ".concat(JSON.stringify(branchData.data,null,2)));if(ghPagesData){(0,core.info)("ghPages Data: ".concat(ghPagesBranch,", ").concat(ghPagesData.commit.sha,", ").concat(JSON.stringify(ghPagesData,null,2)));}(0,core.endGroup)();if(ghPagesData){(0,core.setOutput)('gh-pages-hash',ghPagesData.commit.sha);(0,core.setOutput)('gh-pages-short-hash',ghPagesData.commit.sha.substring(0,7));}_context.next=38;break;case 35:_context.prev=35;_context.t0=_context["catch"](23);if(_context.t0 instanceof Error){(0,core.info)("Get Branch: \x1B[33m".concat(_context.t0.message,"\x1B[0m"));}case 38:if(!((options.baseRef||'').replace(/^[vV]/,'')===options.headRef)){_context.next=43;break;}(0,core.setOutput)('tag',options.baseRef);(0,core.setOutput)('version',options.baseRef.replace(/^[vV]/,''));(0,core.info)("Done: baseRef(\x1B[33m".concat(options.baseRef,"\x1B[0m) === headRef(\x1B[32m").concat(options.headRef,"\x1B[0m)"));return _context.abrupt("return");case 43:if(!(!!options.headRef&&!!options.baseRef&&regexp.test(options.headRef)&&regexp.test(options.baseRef))){_context.next=89;break;}resultData=[];if(!myPath){_context.next=56;break;}(0,core.info)("path: ".concat(myPath));_context.next=49;return octokit.request('GET /repos/{owner}/{repo}/commits',(0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({},github.context.repo),{},{path:myPath}));case 49:commitsData=_context.sent;if(commitsData&&commitsData.status!==200){(0,core.setFailed)("There are no releases on ".concat(owner,"/").concat(repo,". Tags are not releases. (status=").concat(commitsData.status,") ").concat(commitsData.data.message||''));}else{resultData=commitsData.data;}(0,core.startGroup)("Compare Path Commits Result Data: \x1B[32m".concat(commitsData.status||'-',"\x1B[0m \x1B[32m").concat(options.baseRef,"\x1B[0m...\x1B[32m").concat(options.headRef,"\x1B[0m"));(0,core.info)("".concat(JSON.stringify(commitsData.data,null,2)));(0,core.endGroup)();_context.next=63;break;case 56:_context.next=58;return octokit.rest.repos.compareCommits((0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({},github.context.repo),{},{base:options.baseRef,head:options.headRef}));case 58:_commitsData=_context.sent;if(_commitsData&&_commitsData.status!==200){(0,core.setFailed)("There are no releases on ".concat(owner,"/").concat(repo,". Tags are not releases. (status=").concat(_commitsData.status,") ").concat(_commitsData.data.message||''));}else{resultData=_commitsData.data.commits;}(0,core.startGroup)("Compare Commits Result Data: \x1B[32m".concat(_commitsData.status||'-',"\x1B[0m \x1B[32m").concat(options.baseRef,"\x1B[0m...\x1B[32m").concat(options.headRef,"\x1B[0m"));(0,core.info)("".concat(JSON.stringify(_commitsData,null,2)));(0,core.endGroup)();case 63:commitLog=[];(0,core.info)("ResultData Lenght:".concat(resultData.length));_iterator=(0,createForOfIteratorHelper/* default */.Z)(resultData);try{for(_iterator.s();!(_step=_iterator.n()).done;){data=_step.value;message=data.commit.message.split('\n\n')[0];author=data.author||data.committer||{login:'-'};(0,core.startGroup)("Commit: \x1B[34m".concat(message,"\x1B[0m \x1B[34m").concat((data.commit.author||{}).name,"(").concat(author.login,")\x1B[0m ").concat(data.sha));(0,core.info)("".concat(JSON.stringify(data,null,2)));(0,core.endGroup)();commitLog.push(formatStringCommit(message,"".concat(owner,"/").concat(repo),{originalMarkdown:originalMarkdown,regExp:regExp,shortHash:data.sha.slice(0,7),filterAuthor:filterAuthor,hash:data.sha,// author: '',
// author: data.commit.author ? data.commit.author.name : '',
Expand Down

0 comments on commit a3400d2

Please sign in to comment.