From 2862ab6357e5a890990e22474261bea9942cdb09 Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Tue, 27 Apr 2021 19:25:09 +0200 Subject: [PATCH] update comment by default, add ability to switch to old behaviour (#13) --- README.md | 9 ++++---- action.js | 61 ++++++++++++++++++++++++++++++++++++++++++++------- action.yml | 6 ++++- dist/index.js | 2 +- package.json | 4 ++-- yarn.lock | 4 ++-- 6 files changed, 68 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9399160..5e3a6f7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ Creates a comment inside Pull Request with the human-readable summary of the cha ## Inputs -| Input | Required | Description | -| --- | --- | --- | -| `path` | No | Path to the `yarn.lock` file in the repository. Default `yarn.lock` (project root). | -| `token` | **Yes** | GitHub token for the bot, so it can publish a comment in the pull request. | +| Input | Required | Default | Description | +| --- | :---: | :---: | --- | +| `path` | No | `'yarn.lock'` | Path to the `yarn.lock` file in the repository. Default value points to the file at project root. | +| `token` | **Yes** | - | GitHub token for the bot, so it can publish a comment in the pull request. | +| `updateComment` | No | `'true'` | Should the bot update the summary comment. If value is other than default, bot will post new comment on each new commit. | diff --git a/action.js b/action.js index 97575b3..cce4314 100644 --- a/action.js +++ b/action.js @@ -9,6 +9,7 @@ const path = require('path'); const GH_RAW_URL = 'https://raw.githubusercontent.com'; const ASSETS_URL = `${GH_RAW_URL}/Simek/yarn-lock-changes/main/assets`; +const COMMENT_HEADER = '## `yarn.lock` changes'; const getStatusLabel = (status) => `[${status.toUpperCase()}](#)`; @@ -74,17 +75,18 @@ const run = async () => { try { const octokit = github.getOctokit(core.getInput('token')); const inputPath = core.getInput('path'); + const updateComment = core.getInput('updateComment'); const { owner, repo, number } = github.context.issue; if (!number) { - throw new Error('Cannot find the PR!'); + throw new Error('💥 Cannot find the PR, aborting!'); } const lockPath = path.resolve(process.cwd(), inputPath); if (!fs.existsSync(lockPath)) { - throw new Error(`${lockPath} does not exist!`); + throw new Error('💥 It looks like lock does not exist in this PR, aborting!'); } const content = await fs.readFileSync(lockPath, { encoding: 'utf8' }); @@ -96,17 +98,60 @@ const run = async () => { path: inputPath }); + if (!masterLockResponse || !masterLockResponse.data || !masterLockResponse.data.content) { + throw new Error('💥 Cannot fetch base lock, aborting!'); + } + const masterLock = lockfile.parse(Base64.decode(masterLockResponse.data.content)); const lockChanges = diffLocks(masterLock, updatedLock); if (Object.keys(lockChanges).length) { const diffsTable = createTable(lockChanges); - await octokit.issues.createComment({ - owner, - repo, - issue_number: number, - body: '## `yarn.lock` changes' + '\n' + diffsTable - }); + const commentBody = COMMENT_HEADER + '\n' + diffsTable; + + if (updateComment === 'true') { + const currentComments = await octokit.issues.listComments({ + owner, + repo, + issue_number: number, + per_page: 100 + }); + + if (!currentComments || !currentComments.data) { + throw new Error('💥 Cannot fetch PR comments, aborting!'); + } + + const commentId = currentComments.data + .filter( + (comment) => + comment.user.login === 'github-actions[bot]' && + comment.body.startsWith(COMMENT_HEADER) + ) + .map((comment) => comment.id)[0]; + + if (commentId) { + await octokit.issues.updateComment({ + owner, + repo, + comment_id: commentId, + body: commentBody + }); + } else { + await octokit.issues.createComment({ + owner, + repo, + issue_number: number, + body: commentBody + }); + } + } else { + await octokit.issues.createComment({ + owner, + repo, + issue_number: number, + body: commentBody + }); + } } } catch (error) { core.setFailed(error.message); diff --git a/action.yml b/action.yml index f2e27b3..50fbd45 100644 --- a/action.yml +++ b/action.yml @@ -5,12 +5,16 @@ branding: color: 'purple' inputs: path: - description: 'Path to the `yarn.lock` file in the repository.' + description: 'Path to the `yarn.lock` file in the repository. Default value points to the file at project root.' required: false default: 'yarn.lock' token: description: 'GitHub token for the bot, so it can publish a comment in the pull request.' required: true + updateComment: + description: 'Should the bot update the summary comment. If value is other than default, bot will post new comment on each new commit.' + required: false + default: 'true' runs: using: 'node12' main: 'dist/index.js' \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 6d72e1c..2fcc310 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10,4 +10,4 @@ * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. - */var t="";var r;e.exports=repeat;function repeat(e,n){if(typeof e!=="string"){throw new TypeError("expected a string")}if(n===1)return e;if(n===2)return e+e;var o=e.length*n;if(r!==e||typeof r==="undefined"){r=e;t=""}else if(t.length>=o){return t.substr(0,o)}while(o>t.length&&n>1){if(n&1){t+=e}n>>=1;e+=e}t+=e;t=t.substr(0,o);return t}},2083:(e,t,r)=>{e.exports=r(8203)},8203:(e,t,r)=>{"use strict";var n=r(1631);var o=r(4016);var s=r(8605);var i=r(7211);var a=r(8614);var c=r(2357);var u=r(1669);t.httpOverHttp=httpOverHttp;t.httpsOverHttp=httpsOverHttp;t.httpOverHttps=httpOverHttps;t.httpsOverHttps=httpsOverHttps;function httpOverHttp(e){var t=new TunnelingAgent(e);t.request=s.request;return t}function httpsOverHttp(e){var t=new TunnelingAgent(e);t.request=s.request;t.createSocket=createSecureSocket;t.defaultPort=443;return t}function httpOverHttps(e){var t=new TunnelingAgent(e);t.request=i.request;return t}function httpsOverHttps(e){var t=new TunnelingAgent(e);t.request=i.request;t.createSocket=createSecureSocket;t.defaultPort=443;return t}function TunnelingAgent(e){var t=this;t.options=e||{};t.proxyOptions=t.options.proxy||{};t.maxSockets=t.options.maxSockets||s.Agent.defaultMaxSockets;t.requests=[];t.sockets=[];t.on("free",(function onFree(e,r,n,o){var s=toOptions(r,n,o);for(var i=0,a=t.requests.length;i=this.maxSockets){o.requests.push(s);return}o.createSocket(s,(function(t){t.on("free",onFree);t.on("close",onCloseOrRemove);t.on("agentRemove",onCloseOrRemove);e.onSocket(t);function onFree(){o.emit("free",t,s)}function onCloseOrRemove(e){o.removeSocket(t);t.removeListener("free",onFree);t.removeListener("close",onCloseOrRemove);t.removeListener("agentRemove",onCloseOrRemove)}}))};TunnelingAgent.prototype.createSocket=function createSocket(e,t){var r=this;var n={};r.sockets.push(n);var o=mergeOptions({},r.proxyOptions,{method:"CONNECT",path:e.host+":"+e.port,agent:false,headers:{host:e.host+":"+e.port}});if(e.localAddress){o.localAddress=e.localAddress}if(o.proxyAuth){o.headers=o.headers||{};o.headers["Proxy-Authorization"]="Basic "+new Buffer(o.proxyAuth).toString("base64")}l("making CONNECT request");var s=r.request(o);s.useChunkedEncodingByDefault=false;s.once("response",onResponse);s.once("upgrade",onUpgrade);s.once("connect",onConnect);s.once("error",onError);s.end();function onResponse(e){e.upgrade=true}function onUpgrade(e,t,r){process.nextTick((function(){onConnect(e,t,r)}))}function onConnect(o,i,a){s.removeAllListeners();i.removeAllListeners();if(o.statusCode!==200){l("tunneling socket could not be established, statusCode=%d",o.statusCode);i.destroy();var c=new Error("tunneling socket could not be established, "+"statusCode="+o.statusCode);c.code="ECONNRESET";e.request.emit("error",c);r.removeSocket(n);return}if(a.length>0){l("got illegal response body from proxy");i.destroy();var c=new Error("got illegal response body from proxy");c.code="ECONNRESET";e.request.emit("error",c);r.removeSocket(n);return}l("tunneling connection has established");r.sockets[r.sockets.indexOf(n)]=i;return t(i)}function onError(t){s.removeAllListeners();l("tunneling socket could not be established, cause=%s\n",t.message,t.stack);var o=new Error("tunneling socket could not be established, "+"cause="+t.message);o.code="ECONNRESET";e.request.emit("error",o);r.removeSocket(n)}};TunnelingAgent.prototype.removeSocket=function removeSocket(e){var t=this.sockets.indexOf(e);if(t===-1){return}this.sockets.splice(t,1);var r=this.requests.shift();if(r){this.createSocket(r,(function(e){r.request.onSocket(e)}))}};function createSecureSocket(e,t){var r=this;TunnelingAgent.prototype.createSocket.call(r,e,(function(n){var s=e.request.getHeader("host");var i=mergeOptions({},r.options,{socket:n,servername:s?s.replace(/:.*$/,""):e.host});var a=o.connect(0,i);r.sockets[r.sockets.indexOf(n)]=a;t(a)}))}function toOptions(e,t,r){if(typeof e==="string"){return{host:e,port:t,localAddress:r}}return e}function mergeOptions(e){for(var t=1,r=arguments.length;t{"use strict";Object.defineProperty(t,"__esModule",{value:true});function getUserAgent(){if(typeof navigator==="object"&&"userAgent"in navigator){return navigator.userAgent}if(typeof process==="object"&&"version"in process){return`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`}return""}t.getUserAgent=getUserAgent},5488:e=>{e.exports=wrappy;function wrappy(e,t){if(e&&t)return wrappy(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach((function(t){wrapper[t]=e[t]}));return wrapper;function wrapper(){var t=new Array(arguments.length);for(var r=0;r{module.exports=eval("require")("encoding")},2357:e=>{"use strict";e.exports=require("assert")},4293:e=>{"use strict";e.exports=require("buffer")},6417:e=>{"use strict";e.exports=require("crypto")},8614:e=>{"use strict";e.exports=require("events")},5747:e=>{"use strict";e.exports=require("fs")},8605:e=>{"use strict";e.exports=require("http")},7211:e=>{"use strict";e.exports=require("https")},1631:e=>{"use strict";e.exports=require("net")},2087:e=>{"use strict";e.exports=require("os")},5622:e=>{"use strict";e.exports=require("path")},2413:e=>{"use strict";e.exports=require("stream")},4016:e=>{"use strict";e.exports=require("tls")},3867:e=>{"use strict";e.exports=require("tty")},8835:e=>{"use strict";e.exports=require("url")},1669:e=>{"use strict";e.exports=require("util")},8761:e=>{"use strict";e.exports=require("zlib")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var r=__webpack_module_cache__[e]={exports:{}};var n=true;try{__webpack_modules__[e].call(r.exports,r,r.exports,__nccwpck_require__);n=false}finally{if(n)delete __webpack_module_cache__[e]}return r.exports}(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__={};(()=>{const e=__nccwpck_require__(7090);const t=__nccwpck_require__(6993);const r=__nccwpck_require__(4705);const n=__nccwpck_require__(9035);const o=__nccwpck_require__(5747);const{Base64:s}=__nccwpck_require__(9990);const{markdownTable:i}=__nccwpck_require__(3852);const a=__nccwpck_require__(5622);const c="https://raw.githubusercontent.com";const u=`${c}/Simek/yarn-lock-changes/main/assets`;const getStatusLabel=e=>`[${e.toUpperCase()}](#)`;const formatNameAndVersion=e=>Object.fromEntries(Object.keys(e.object).map((t=>{const r=t.split("@");const n=r[0]===""?"@"+r[1]:r[0];return[n,{name:n,version:e.object[t].version}]})));const diffLocks=(e,t)=>{const r={};const o=formatNameAndVersion(e);const s=formatNameAndVersion(t);Object.keys(o).forEach((e=>{r[e]={previous:o[e].version,current:"-",status:getStatusLabel("removed")}}));Object.keys(s).forEach((e=>{if(!r[e]){r[e]={previous:"-",current:s[e].version,status:getStatusLabel("added")}}else{if(r[e].previous===s[e].version){delete r[e]}else{r[e].current=s[e].version;if(n(r[e].previous,r[e].current)===1){r[e].status=getStatusLabel("downgraded")}else{r[e].status=getStatusLabel("updated")}}}}));return r};const createTable=e=>i([["Name","Status","Previous","Current"],...Object.entries(e).map((([e,{status:t,previous:r,current:n}])=>["`"+e+"`",t,r,n])).sort(((e,t)=>e[0].localeCompare(t[0])))],{align:["l","c","c","c"],alignDelimiters:false});const run=async()=>{try{const n=t.getOctokit(e.getInput("token"));const i=e.getInput("path");const{owner:c,repo:u,number:l}=t.context.issue;if(!l){throw new Error("Cannot find the PR!")}const p=a.resolve(process.cwd(),i);if(!o.existsSync(p)){throw new Error(`${p} does not exist!`)}const d=await o.readFileSync(p,{encoding:"utf8"});const h=r.parse(d);const m=await n.request("GET /repos/{owner}/{repo}/contents/{path}",{owner:c,repo:u,path:i});const g=r.parse(s.decode(m.data.content));const v=diffLocks(g,h);if(Object.keys(v).length){const e=createTable(v);await n.issues.createComment({owner:c,repo:u,issue_number:l,body:"## `yarn.lock` changes"+"\n"+e})}}catch(t){e.setFailed(t.message)}};run()})();module.exports=__webpack_exports__})(); \ No newline at end of file + */var t="";var r;e.exports=repeat;function repeat(e,n){if(typeof e!=="string"){throw new TypeError("expected a string")}if(n===1)return e;if(n===2)return e+e;var o=e.length*n;if(r!==e||typeof r==="undefined"){r=e;t=""}else if(t.length>=o){return t.substr(0,o)}while(o>t.length&&n>1){if(n&1){t+=e}n>>=1;e+=e}t+=e;t=t.substr(0,o);return t}},2083:(e,t,r)=>{e.exports=r(8203)},8203:(e,t,r)=>{"use strict";var n=r(1631);var o=r(4016);var s=r(8605);var i=r(7211);var a=r(8614);var c=r(2357);var u=r(1669);t.httpOverHttp=httpOverHttp;t.httpsOverHttp=httpsOverHttp;t.httpOverHttps=httpOverHttps;t.httpsOverHttps=httpsOverHttps;function httpOverHttp(e){var t=new TunnelingAgent(e);t.request=s.request;return t}function httpsOverHttp(e){var t=new TunnelingAgent(e);t.request=s.request;t.createSocket=createSecureSocket;t.defaultPort=443;return t}function httpOverHttps(e){var t=new TunnelingAgent(e);t.request=i.request;return t}function httpsOverHttps(e){var t=new TunnelingAgent(e);t.request=i.request;t.createSocket=createSecureSocket;t.defaultPort=443;return t}function TunnelingAgent(e){var t=this;t.options=e||{};t.proxyOptions=t.options.proxy||{};t.maxSockets=t.options.maxSockets||s.Agent.defaultMaxSockets;t.requests=[];t.sockets=[];t.on("free",(function onFree(e,r,n,o){var s=toOptions(r,n,o);for(var i=0,a=t.requests.length;i=this.maxSockets){o.requests.push(s);return}o.createSocket(s,(function(t){t.on("free",onFree);t.on("close",onCloseOrRemove);t.on("agentRemove",onCloseOrRemove);e.onSocket(t);function onFree(){o.emit("free",t,s)}function onCloseOrRemove(e){o.removeSocket(t);t.removeListener("free",onFree);t.removeListener("close",onCloseOrRemove);t.removeListener("agentRemove",onCloseOrRemove)}}))};TunnelingAgent.prototype.createSocket=function createSocket(e,t){var r=this;var n={};r.sockets.push(n);var o=mergeOptions({},r.proxyOptions,{method:"CONNECT",path:e.host+":"+e.port,agent:false,headers:{host:e.host+":"+e.port}});if(e.localAddress){o.localAddress=e.localAddress}if(o.proxyAuth){o.headers=o.headers||{};o.headers["Proxy-Authorization"]="Basic "+new Buffer(o.proxyAuth).toString("base64")}l("making CONNECT request");var s=r.request(o);s.useChunkedEncodingByDefault=false;s.once("response",onResponse);s.once("upgrade",onUpgrade);s.once("connect",onConnect);s.once("error",onError);s.end();function onResponse(e){e.upgrade=true}function onUpgrade(e,t,r){process.nextTick((function(){onConnect(e,t,r)}))}function onConnect(o,i,a){s.removeAllListeners();i.removeAllListeners();if(o.statusCode!==200){l("tunneling socket could not be established, statusCode=%d",o.statusCode);i.destroy();var c=new Error("tunneling socket could not be established, "+"statusCode="+o.statusCode);c.code="ECONNRESET";e.request.emit("error",c);r.removeSocket(n);return}if(a.length>0){l("got illegal response body from proxy");i.destroy();var c=new Error("got illegal response body from proxy");c.code="ECONNRESET";e.request.emit("error",c);r.removeSocket(n);return}l("tunneling connection has established");r.sockets[r.sockets.indexOf(n)]=i;return t(i)}function onError(t){s.removeAllListeners();l("tunneling socket could not be established, cause=%s\n",t.message,t.stack);var o=new Error("tunneling socket could not be established, "+"cause="+t.message);o.code="ECONNRESET";e.request.emit("error",o);r.removeSocket(n)}};TunnelingAgent.prototype.removeSocket=function removeSocket(e){var t=this.sockets.indexOf(e);if(t===-1){return}this.sockets.splice(t,1);var r=this.requests.shift();if(r){this.createSocket(r,(function(e){r.request.onSocket(e)}))}};function createSecureSocket(e,t){var r=this;TunnelingAgent.prototype.createSocket.call(r,e,(function(n){var s=e.request.getHeader("host");var i=mergeOptions({},r.options,{socket:n,servername:s?s.replace(/:.*$/,""):e.host});var a=o.connect(0,i);r.sockets[r.sockets.indexOf(n)]=a;t(a)}))}function toOptions(e,t,r){if(typeof e==="string"){return{host:e,port:t,localAddress:r}}return e}function mergeOptions(e){for(var t=1,r=arguments.length;t{"use strict";Object.defineProperty(t,"__esModule",{value:true});function getUserAgent(){if(typeof navigator==="object"&&"userAgent"in navigator){return navigator.userAgent}if(typeof process==="object"&&"version"in process){return`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`}return""}t.getUserAgent=getUserAgent},5488:e=>{e.exports=wrappy;function wrappy(e,t){if(e&&t)return wrappy(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach((function(t){wrapper[t]=e[t]}));return wrapper;function wrapper(){var t=new Array(arguments.length);for(var r=0;r{module.exports=eval("require")("encoding")},2357:e=>{"use strict";e.exports=require("assert")},4293:e=>{"use strict";e.exports=require("buffer")},6417:e=>{"use strict";e.exports=require("crypto")},8614:e=>{"use strict";e.exports=require("events")},5747:e=>{"use strict";e.exports=require("fs")},8605:e=>{"use strict";e.exports=require("http")},7211:e=>{"use strict";e.exports=require("https")},1631:e=>{"use strict";e.exports=require("net")},2087:e=>{"use strict";e.exports=require("os")},5622:e=>{"use strict";e.exports=require("path")},2413:e=>{"use strict";e.exports=require("stream")},4016:e=>{"use strict";e.exports=require("tls")},3867:e=>{"use strict";e.exports=require("tty")},8835:e=>{"use strict";e.exports=require("url")},1669:e=>{"use strict";e.exports=require("util")},8761:e=>{"use strict";e.exports=require("zlib")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var r=__webpack_module_cache__[e]={exports:{}};var n=true;try{__webpack_modules__[e].call(r.exports,r,r.exports,__nccwpck_require__);n=false}finally{if(n)delete __webpack_module_cache__[e]}return r.exports}(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__={};(()=>{const e=__nccwpck_require__(7090);const t=__nccwpck_require__(6993);const r=__nccwpck_require__(4705);const n=__nccwpck_require__(9035);const o=__nccwpck_require__(5747);const{Base64:s}=__nccwpck_require__(9990);const{markdownTable:i}=__nccwpck_require__(3852);const a=__nccwpck_require__(5622);const c="https://raw.githubusercontent.com";const u=`${c}/Simek/yarn-lock-changes/main/assets`;const l="## `yarn.lock` changes";const getStatusLabel=e=>`[${e.toUpperCase()}](#)`;const formatNameAndVersion=e=>Object.fromEntries(Object.keys(e.object).map((t=>{const r=t.split("@");const n=r[0]===""?"@"+r[1]:r[0];return[n,{name:n,version:e.object[t].version}]})));const diffLocks=(e,t)=>{const r={};const o=formatNameAndVersion(e);const s=formatNameAndVersion(t);Object.keys(o).forEach((e=>{r[e]={previous:o[e].version,current:"-",status:getStatusLabel("removed")}}));Object.keys(s).forEach((e=>{if(!r[e]){r[e]={previous:"-",current:s[e].version,status:getStatusLabel("added")}}else{if(r[e].previous===s[e].version){delete r[e]}else{r[e].current=s[e].version;if(n(r[e].previous,r[e].current)===1){r[e].status=getStatusLabel("downgraded")}else{r[e].status=getStatusLabel("updated")}}}}));return r};const createTable=e=>i([["Name","Status","Previous","Current"],...Object.entries(e).map((([e,{status:t,previous:r,current:n}])=>["`"+e+"`",t,r,n])).sort(((e,t)=>e[0].localeCompare(t[0])))],{align:["l","c","c","c"],alignDelimiters:false});const run=async()=>{try{const n=t.getOctokit(e.getInput("token"));const i=e.getInput("path");const c=e.getInput("updateComment");const{owner:u,repo:p,number:d}=t.context.issue;if(!d){throw new Error("💥 Cannot find the PR, aborting!")}const h=a.resolve(process.cwd(),i);if(!o.existsSync(h)){throw new Error("💥 It looks like lock does not exist in this PR, aborting!")}const m=await o.readFileSync(h,{encoding:"utf8"});const g=r.parse(m);const v=await n.request("GET /repos/{owner}/{repo}/contents/{path}",{owner:u,repo:p,path:i});if(!v||!v.data||!v.data.content){throw new Error("💥 Cannot fetch base lock, aborting!")}const y=r.parse(s.decode(v.data.content));const b=diffLocks(y,g);if(Object.keys(b).length){const e=createTable(b);const t=l+"\n"+e;if(c==="true"){const e=await n.issues.listComments({owner:u,repo:p,issue_number:d,per_page:100});if(!e||!e.data){throw new Error("💥 Cannot fetch PR comments, aborting!")}const r=e.data.filter((e=>e.user.login==="github-actions[bot]"&&e.body.startsWith(l))).map((e=>e.id))[0];if(r){await n.issues.updateComment({owner:u,repo:p,comment_id:r,body:t})}else{await n.issues.createComment({owner:u,repo:p,issue_number:d,body:t})}}else{await n.issues.createComment({owner:u,repo:p,issue_number:d,body:t})}}}catch(t){e.setFailed(t.message)}};run()})();module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/package.json b/package.json index 0a7e339..4c8ade2 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,8 @@ }, "devDependencies": { "eslint": "^7.25.0", - "eslint-config-prettier": "^8.1.0", - "eslint-plugin-prettier": "^3.3.1", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-prettier": "^3.4.0", "prettier": "^2.2.1", "svgo": "^2.3.0" } diff --git a/yarn.lock b/yarn.lock index adc75e5..1cd3a15 100644 --- a/yarn.lock +++ b/yarn.lock @@ -427,12 +427,12 @@ escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= -eslint-config-prettier@^8.1.0: +eslint-config-prettier@^8.3.0: version "8.3.0" resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a" integrity sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew== -eslint-plugin-prettier@^3.3.1: +eslint-plugin-prettier@^3.4.0: version "3.4.0" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.4.0.tgz#cdbad3bf1dbd2b177e9825737fe63b476a08f0c7" integrity sha512-UDK6rJT6INSfcOo545jiaOwB701uAIt2/dR7WnFQoGCVl1/EMqdANBmwUaqqQ45aXprsTGzSa39LI1PyuRBxxw==