From 07786009eef6076d62fb7f4f6586fb2011b95802 Mon Sep 17 00:00:00 2001 From: gkr-bot Date: Sat, 10 Oct 2020 16:34:37 +0000 Subject: [PATCH] [skip-ci] Published 1.3.0 --- dist/blog-post-workflow.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/blog-post-workflow.js b/dist/blog-post-workflow.js index 4a5f617..09886aa 100644 --- a/dist/blog-post-workflow.js +++ b/dist/blog-post-workflow.js @@ -119,5 +119,5 @@ function i(i,n,r,t){return JSON.stringify(i,e(n,t),r)}function e(i,e){var n=[],r },{}],"KFkI":[function(require,module,exports) { "use strict";var n=require("json-stringify-safe"),r=function(){var n=4022871197;return function(r){if(r){r=r.toString();for(var t=0;t>>0,n=(e*=n)>>>0,n+=4294967296*(e-=n)}return 2.3283064365386963e-10*(n>>>0)}n=4022871197}},t=function(t){return function(){var e,o,i=48,u=1,a=i,f=new Array(i),c=0,l=new r;for(e=0;e=i&&(a=0);var n=1768863*f[a]+2.3283064365386963e-10*u;return f[a]=n-(u=0|n)},h=function(n){return Math.floor(n*(g()+1.1102230246251565e-16*(2097152*g()|0)))};h.string=function(n){var r,t="";for(r=0;r{const r=a.getInput("comment_tag_name"),i=r?`\x3c!-- ${r}:`:"\x3c!-- BLOG-POST-LIST:",o=a.getInput("tag_post_pre_newline"),c=e.indexOf(`${i}START`),s=e.indexOf("--\x3e",c),l=e.indexOf(`${i}END`,s);return-1!==c&&-1!==s&&-1!==l||(a.error(`Cannot find the comment tag on the readme:\n\x3c!-- ${i}:START --\x3e\n\x3c!-- ${i}:END --\x3e`),n.exit(1)),[e.slice(0,s+"--\x3e".length),o?"\n":"",t,o?"\n":"",e.slice(l)].join("")},p=async()=>{const e=a.getInput("committer_username"),t=a.getInput("committer_email"),r=a.getInput("commit_message");await s("git",["config","--global","user.email",t]),h&&await s("git",["remote","set-url","origin",`https://${h}@github.com/${n.env.GITHUB_REPOSITORY}.git`]),await s("git",["config","--global","user.name",e]),await s("git",["add",d]),await s("git",["commit","-m",r]),await s("git",["push"]),a.info("Readme updated successfully in the upstream repository"),n.exit(k?1:0)},m=a.getInput("user_agent"),g=a.getInput("accept_header"),f=Number.parseInt(a.getInput("max_post_count")),d=a.getInput("readme_path"),h=a.getInput("gh_token"),O={stackoverflow:"Comment by $author",stackexchange:"Comment by $author"},b={},x=(e,t)=>{const r=e.split("/");return 3===r.length?(Object.assign(t,{[r[0]]:r[1]}),r[0]):e},w=(e,t)=>e.indexOf("$"+t)>-1&&e.match(new RegExp("\\$"+t+"\\((.)*\\)","g"))?e.match(new RegExp("\\$"+t+"\\((.)*\\)","g"))[0].replace("$"+t+"(","").replace(")","").split(",").map(e=>e.trim()):null;a.setSecret(h);const y=a.getInput("filter_comments").trim().split(",").map(e=>(e=e.trim()).startsWith("stackoverflow")||e.startsWith("stackexchange")?x(e,O):e);a.getInput("custom_tags").trim().split(",").forEach(e=>{e=e.trim(),x(e,b)});const _=[],I=[];let $=[],k=!1;const j=a.getInput("feed_list").trim();let E=j.split(",").map(e=>e.trim());0===E.length&&(a.error("Please double check the value of feed_list"),n.exit(1));const v=e=>!(-1!==y.indexOf("medium")&&e.link.includes("medium.com")&&void 0===e.categories),P=e=>!(-1!==y.indexOf("stackoverflow")&&e.link.includes("stackoverflow.com")&&e.title.startsWith(O.stackoverflow.replace(/\$author/g,e.author))),T=e=>!(-1!==y.indexOf("stackexchange")&&e.link.includes("stackexchange.com")&&e.title.startsWith(O.stackexchange.replace(/\$author/g,e.author))),S=Object.keys(b).map(e=>[b[e],e]);let R=new i({headers:{"User-Agent":m,Accept:g},customFields:{item:[...S]}});E.forEach(e=>{I.push(e),_.push(new Promise((r,n)=>{R.parseURL(e).then(e=>{if(e.items){const i=e.items.filter(v).filter(P).filter(T).map(e=>{e.pubDate||n("Cannot read response->item->pubDate"),e.title||n("Cannot read response->item->title"),e.link||n("Cannot read response->item->link");let r={};return Object.keys(b).forEach(t=>{e[t]&&Object.assign(r,{[t]:e[t]})}),t({title:e.title.trim(),url:e.link.trim(),date:new Date(e.pubDate.trim())},r)});r(i)}else n("Cannot read response->item")}).catch(n)}))}),Promise.allSettled(_).then(e=>{e.forEach((e,t)=>{"fulfilled"===e.status?(a.info(I[t]+" runner succeeded. Post count: "+e.value.length),$.push(...e.value)):(k=!0,a.error(I[t]+" runner failed, please verify the configuration. Error:"),a.error(e.reason))})}).finally(()=>{if("false"===a.getInput("disable_sort")&&$.sort(function(e,t){return t.date-e.date}),($=$.slice(0,f)).length>0)try{const t=o.readFileSync(d,"utf8"),r=a.getInput("template"),i=w(r,"randomEmoji"),s=w(r,"emojiKey"),m=$.reduce((e,t,o)=>{if("default"===r)return e+`\n- [${t.title}](${t.url})`+(o+1===$.length?"\n":"");{const u=c(t.date,a.getInput("date_format"));let p=r.replace(/\$title\b/g,t.title).replace(/\$url\b/g,t.url).replace(/\$date\b/g,u).replace(/\$newline/g,"\n");if(Object.keys(b).forEach(e=>{const r=t[e]?t[e]:"";p=p.replace(new RegExp("\\$"+e+"\\b","g"),r)}),i){const e=(n.env.GITHUB_REPOSITORY&&!n.env.TEST_MODE?n.env.GITHUB_REPOSITORY:"example")+o,t=i[l.create(e).range(i.length)];p=p.replace(/\$randomEmoji\((.)*\)/g,t)}return s&&(p=p.replace(/\$emojiKey\((.)*\)/g,s[o%s.length])),e+p}},""),g=u(t,m);g!==t?(a.info("Writing to "+d),o.writeFileSync(d,g),n.env.TEST_MODE||p()):(a.info("No change detected, skipping"),n.exit(0))}catch(e){a.error(e),n.exit(1)}else a.info("0 blog posts fetched"),n.exit(k?1:0)}); +function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function t(t){for(var n=1;n{const r=a.getInput("comment_tag_name"),i=r?`\x3c!-- ${r}:`:"\x3c!-- BLOG-POST-LIST:",o=a.getInput("tag_post_pre_newline"),c=e.indexOf(`${i}START`),s=e.indexOf("--\x3e",c),l=e.indexOf(`${i}END`,s);return-1!==c&&-1!==s&&-1!==l||(a.error(`Cannot find the comment tag on the readme:\n\x3c!-- ${i}:START --\x3e\n\x3c!-- ${i}:END --\x3e`),n.exit(1)),[e.slice(0,s+"--\x3e".length),o?"\n":"",t,o?"\n":"",e.slice(l)].join("")},m=async()=>{const e=a.getInput("committer_username"),t=a.getInput("committer_email"),r=a.getInput("commit_message");await s("git",["config","--global","user.email",t]),b&&await s("git",["remote","set-url","origin",`https://${b}@github.com/${n.env.GITHUB_REPOSITORY}.git`]),await s("git",["config","--global","user.name",e]),await s("git",["add",d]),await s("git",["commit","-m",r]),await s("git",["push"]),a.info("Readme updated successfully in the upstream repository"),n.exit(j?1:0)},p=a.getInput("user_agent"),g=a.getInput("accept_header"),f=Number.parseInt(a.getInput("max_post_count")),h=a.getInput("title_max_length")?Number.parseInt(a.getInput("title_max_length")):null,d=a.getInput("readme_path"),b=a.getInput("gh_token"),O={stackoverflow:"Comment by $author",stackexchange:"Comment by $author"},x={},_=(e,t)=>{const r=e.split("/");return 3===r.length?(Object.assign(t,{[r[0]]:r[1]}),r[0]):e},w=(e,t)=>e.indexOf("$"+t)>-1&&e.match(new RegExp("\\$"+t+"\\((.)*\\)","g"))?e.match(new RegExp("\\$"+t+"\\((.)*\\)","g"))[0].replace("$"+t+"(","").replace(")","").split(",").map(e=>e.trim()):null;a.setSecret(b);const y=a.getInput("filter_comments").trim().split(",").map(e=>(e=e.trim()).startsWith("stackoverflow")||e.startsWith("stackexchange")?_(e,O):e);a.getInput("custom_tags").trim().split(",").forEach(e=>{e=e.trim(),_(e,x)});const I=[],$=[];let k=[],j=!1;const E=a.getInput("feed_list").trim();let v=E.split(",").map(e=>e.trim());0===v.length&&(a.error("Please double check the value of feed_list"),n.exit(1));const P=e=>!(-1!==y.indexOf("medium")&&e.link.includes("medium.com")&&void 0===e.categories),T=e=>!(-1!==y.indexOf("stackoverflow")&&e.link.includes("stackoverflow.com")&&e.title.startsWith(O.stackoverflow.replace(/\$author/g,e.author))),S=e=>!(-1!==y.indexOf("stackexchange")&&e.link.includes("stackexchange.com")&&e.title.startsWith(O.stackexchange.replace(/\$author/g,e.author))),R=Object.keys(x).map(e=>[x[e],e]);let D=new i({headers:{"User-Agent":p,Accept:g},customFields:{item:[...R]}});v.forEach(e=>{$.push(e),I.push(new Promise((r,n)=>{D.parseURL(e).then(e=>{if(e.items){const i=e.items.filter(P).filter(T).filter(S).map(e=>{e.pubDate||n("Cannot read response->item->pubDate"),e.title||n("Cannot read response->item->title"),e.link||n("Cannot read response->item->link");let r={};return Object.keys(x).forEach(t=>{e[t]&&Object.assign(r,{[t]:e[t]})}),h&&(e.title=e.title.trim().slice(0,h)===e.title.trim()?e.title.trim():e.title.trim().slice(0,h)+"..."),t({title:e.title.trim(),url:e.link.trim(),date:new Date(e.pubDate.trim())},r)});r(i)}else n("Cannot read response->item")}).catch(n)}))}),Promise.allSettled(I).then(e=>{e.forEach((e,t)=>{"fulfilled"===e.status?(a.info($[t]+" runner succeeded. Post count: "+e.value.length),k.push(...e.value)):(j=!0,a.error($[t]+" runner failed, please verify the configuration. Error:"),a.error(e.reason))})}).finally(()=>{if("false"===a.getInput("disable_sort")&&k.sort(function(e,t){return t.date-e.date}),(k=k.slice(0,f)).length>0)try{const t=o.readFileSync(d,"utf8"),r=a.getInput("template"),i=w(r,"randomEmoji"),s=w(r,"emojiKey"),p=k.reduce((e,t,o)=>{if("default"===r)return e+`\n- [${t.title}](${t.url})`+(o+1===k.length?"\n":"");{const u=c(t.date,a.getInput("date_format"));let m=r.replace(/\$title\b/g,t.title).replace(/\$url\b/g,t.url).replace(/\$date\b/g,u).replace(/\$newline/g,"\n");if(Object.keys(x).forEach(e=>{const r=t[e]?t[e]:"";m=m.replace(new RegExp("\\$"+e+"\\b","g"),r)}),i){const e=(n.env.GITHUB_REPOSITORY&&!n.env.TEST_MODE?n.env.GITHUB_REPOSITORY:"example")+o,t=i[l.create(e).range(i.length)];m=m.replace(/\$randomEmoji\((.)*\)/g,t)}return s&&(m=m.replace(/\$emojiKey\((.)*\)/g,s[o%s.length])),e+m}},""),g=u(t,p);g!==t?(a.info("Writing to "+d),o.writeFileSync(d,g),n.env.TEST_MODE||m()):(a.info("No change detected, skipping"),n.exit(0))}catch(e){a.error(e),n.exit(1)}else a.info("0 blog posts fetched"),n.exit(j?1:0)}); },{"rss-parser":"BF6Y","@actions/core":"FTVr","dateformat":"FWyg","./exec":"z3en","random-seed":"KFkI"}]},{},["MHPq"], null) \ No newline at end of file diff --git a/package.json b/package.json index cb97fe9..417a2c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blog-post-workflow", - "version": "1.2.9", + "version": "1.3.0", "description": "Allows you to show your latest blog posts on your github profile or project readme", "main": "blog-post-workflow.js", "scripts": {