From 179bb680de30b0a2d2926477ad291ca9a81bede1 Mon Sep 17 00:00:00 2001 From: mechiru <46036584+mechiru@users.noreply.github.com> Date: Sat, 20 Feb 2021 21:04:08 +0900 Subject: [PATCH] Bump to v1.0.1 --- dist/index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index d2fa000..8054c78 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -module.exports=(()=>{"use strict";var e={109:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.prototype.hasOwnProperty.call(e,n))r(t,e,n);o(t,e);return t};var i=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.shouldTrigger=t.toChatworkMessage=t.postMessage=t.extractUsers=void 0;const u=s(n(186));const a=s(n(211));const c=s(n(191));function parseInput(){const e=+u.getInput("roomid");const t=u.getInput("token");const n=JSON.parse(u.getInput("mapping"));const r=JSON.parse(u.getInput("context"));const o=u.getInput("ignoreUpdate")==="true";const s=u.getInput("ignoreBody")==="true";return{roomId:e,token:t,mapping:n,context:r,ignoreUpdate:o,ignoreBody:s}}function extractUsers(e){const t=[];const n=[...e];let r=0;while(rt[e]).filter(e=>e!=null)}function postMessage(e,t){return new Promise((n,r)=>{const o={hostname:"api.chatwork.com",port:443,path:`/v2/rooms/${e.roomId}/messages`,method:"POST",headers:{"X-ChatWorkToken":e.token,"Content-Type":"application/x-www-form-urlencoded"}};const s=a.request(o,e=>{if(e.statusCode!==200){r(new Error(`status code error. status code: ${e.statusCode}`))}e.setEncoding("utf8");let t="";e.on("data",e=>t+=e);e.on("end",()=>{try{const e=JSON.parse(t);n(e)}catch(e){r(e)}})});s.on("error",r);s.write(`body=${c.escape(t)}`,e=>{if(e!=null)r(e)});s.end()})}t.postMessage=postMessage;function toChatworkMessage(e,t,n){const r=e.event.issue.title;const o=e.event_name==="issue_comment";const s=o?e.event.comment.html_url:e.event.issue.html_url;const i=o?e.event.comment.body:e.event.issue.body;let u=extractUsers(i);if(!o){const t=e.event.issue.assignees.map(e=>e.login);u=u.concat(t).filter((e,t,n)=>n.indexOf(e)===t)}const a=mapToChatworkUser(u,t);let c=a.length>0?`${a.join("\n")}\n`:"";c+=`title: ${r}\nurl: ${s}\n`;if(!n)c+=`\n${i}`;return c}t.toChatworkMessage=toChatworkMessage;function shouldTrigger(e,t){return["issues","issue_comment"].includes(e.event_name)&&(["opened","created"].includes(e.event.action)||e.event.action==="edited"&&!t)}t.shouldTrigger=shouldTrigger;function run(){return i(this,void 0,void 0,function*(){try{const e=parseInput();u.debug(`event_name: ${e.context.event_name}`);u.debug(`event.action: ${JSON.stringify(e.context.event.action)}`);const t=shouldTrigger(e.context,e.ignoreUpdate);u.debug(`trigger: ${t}`);if(!t)return;const n=toChatworkMessage(e.context,e.mapping,e.ignoreBody);u.debug(`message body: ${n}`);const r=yield postMessage(e,n);u.debug(`response: ${r}`);u.setOutput("messageId",r.message_id)}catch(e){u.setFailed(e.message)}})}run()},351:function(e,t,n){var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=r(n(87));const s=n(278);function issueCommand(e,t,n){const r=new Command(e,t,n);process.stdout.write(r.toString()+o.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const i="::";class Command{constructor(e,t,n){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=n}toString(){let e=i+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const n in this.properties){if(this.properties.hasOwnProperty(n)){const r=this.properties[n];if(r){if(t){t=false}else{e+=","}e+=`${n}=${escapeProperty(r)}`}}}}e+=`${i}${escapeData(this.message)}`;return e}}function escapeData(e){return s.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return s.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},186:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const s=n(351);const i=n(717);const u=n(278);const a=o(n(87));const c=o(n(622));var p;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(p=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const n=u.toCommandValue(t);process.env[e]=n;const r=process.env["GITHUB_ENV"]||"";if(r){const t="_GitHubActionsFileCommandDelimeter_";const r=`${e}<<${t}${a.EOL}${n}${a.EOL}${t}`;i.issueCommand("ENV",r)}else{s.issueCommand("set-env",{name:e},n)}}t.exportVariable=exportVariable;function setSecret(e){s.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){i.issueCommand("PATH",e)}else{s.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${c.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const n=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!n){throw new Error(`Input required and not supplied: ${e}`)}return n.trim()}t.getInput=getInput;function setOutput(e,t){s.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){s.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=p.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){s.issueCommand("debug",{},e)}t.debug=debug;function error(e){s.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){s.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+a.EOL)}t.info=info;function startGroup(e){s.issue("group",e)}t.startGroup=startGroup;function endGroup(){s.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return r(this,void 0,void 0,function*(){startGroup(e);let n;try{n=yield t()}finally{endGroup()}return n})}t.group=group;function saveState(e,t){s.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},717:function(e,t,n){var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=r(n(747));const s=r(n(87));const i=n(278);function issueCommand(e,t){const n=process.env[`GITHUB_${e}`];if(!n){throw new Error(`Unable to find environment variable for file command ${e}`)}if(!o.existsSync(n)){throw new Error(`Missing file at path: ${n}`)}o.appendFileSync(n,`${i.toCommandValue(t)}${s.EOL}`,{encoding:"utf8"})}t.issueCommand=issueCommand},278:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue},747:e=>{e.exports=require("fs")},211:e=>{e.exports=require("https")},87:e=>{e.exports=require("os")},622:e=>{e.exports=require("path")},191:e=>{e.exports=require("querystring")}};var t={};function __webpack_require__(n){if(t[n]){return t[n].exports}var r=t[n]={exports:{}};var o=true;try{e[n].call(r.exports,r,r.exports,__webpack_require__);o=false}finally{if(o)delete t[n]}return r.exports}__webpack_require__.ab=__dirname+"/";return __webpack_require__(109)})(); \ No newline at end of file +module.exports=(()=>{"use strict";var e={109:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.prototype.hasOwnProperty.call(e,n))r(t,e,n);o(t,e);return t};var i=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.shouldTrigger=t.toChatworkMessage=t.postMessage=t.extractUsers=void 0;const u=s(n(186));const a=s(n(211));const c=s(n(191));function parseInput(){const e=+u.getInput("roomid");const t=u.getInput("token");const n=JSON.parse(u.getInput("mapping"));const r=JSON.parse(u.getInput("context"));const o=u.getInput("ignoreUpdate")==="true";const s=u.getInput("ignoreBody")==="true";return{roomId:e,token:t,mapping:n,context:r,ignoreUpdate:o,ignoreBody:s}}function extractUsers(e){const t=[];const n=[...e];let r=0;while(rt[e]).filter(e=>e!=null)}function postMessage(e,t){return new Promise((n,r)=>{const o={hostname:"api.chatwork.com",port:443,path:`/v2/rooms/${e.roomId}/messages`,method:"POST",headers:{"X-ChatWorkToken":e.token,"Content-Type":"application/x-www-form-urlencoded"}};const s=a.request(o,e=>{if(e.statusCode!==200){r(new Error(`status code error. status code: ${e.statusCode}`))}e.setEncoding("utf8");let t="";e.on("data",e=>t+=e);e.on("end",()=>{try{const e=JSON.parse(t);n(e)}catch(e){r(e)}})});s.on("error",r);s.write(`body=${c.escape(t)}`,e=>{if(e!=null)r(e)});s.end()})}t.postMessage=postMessage;function toChatworkMessage(e,t,n){const r=e.event.issue.title;const o=e.event_name==="issue_comment";const s=o?e.event.comment.html_url:e.event.issue.html_url;const i=o?e.event.comment.body:e.event.issue.body;let u=extractUsers(i);if(!o){const t=e.event.issue.assignees.map(e=>e.login);u=u.concat(t).filter((e,t,n)=>n.indexOf(e)===t)}const a=mapToChatworkUser(u,t);let c=a.length>0?`${a.join("\n")}\n`:"";c+=`title: ${r}\nurl: ${s}\n`;if(!n)c+=`\n${i}`;return c}t.toChatworkMessage=toChatworkMessage;function shouldTrigger(e,t){return["issues","issue_comment"].includes(e.event_name)&&(["opened","created"].includes(e.event.action)||e.event.action==="edited"&&!t)}t.shouldTrigger=shouldTrigger;function run(){return i(this,void 0,void 0,function*(){try{const e=parseInput();u.debug(`event_name: ${e.context.event_name}`);u.debug(`event.action: ${JSON.stringify(e.context.event.action)}`);const t=shouldTrigger(e.context,e.ignoreUpdate);u.debug(`trigger: ${t}`);if(!t)return;const n=toChatworkMessage(e.context,e.mapping,e.ignoreBody);u.debug(`message body: ${n}`);const r=yield postMessage(e,n);u.debug(`response: ${r}`);u.setOutput("messageId",r.message_id)}catch(e){u.setFailed(e.message)}})}run()},351:function(e,t,n){var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=r(n(87));const s=n(278);function issueCommand(e,t,n){const r=new Command(e,t,n);process.stdout.write(r.toString()+o.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const i="::";class Command{constructor(e,t,n){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=n}toString(){let e=i+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const n in this.properties){if(this.properties.hasOwnProperty(n)){const r=this.properties[n];if(r){if(t){t=false}else{e+=","}e+=`${n}=${escapeProperty(r)}`}}}}e+=`${i}${escapeData(this.message)}`;return e}}function escapeData(e){return s.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return s.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},186:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const s=n(351);const i=n(717);const u=n(278);const a=o(n(87));const c=o(n(622));var p;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(p=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const n=u.toCommandValue(t);process.env[e]=n;const r=process.env["GITHUB_ENV"]||"";if(r){const t="_GitHubActionsFileCommandDelimeter_";const r=`${e}<<${t}${a.EOL}${n}${a.EOL}${t}`;i.issueCommand("ENV",r)}else{s.issueCommand("set-env",{name:e},n)}}t.exportVariable=exportVariable;function setSecret(e){s.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){i.issueCommand("PATH",e)}else{s.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${c.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const n=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!n){throw new Error(`Input required and not supplied: ${e}`)}return n.trim()}t.getInput=getInput;function setOutput(e,t){s.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){s.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=p.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){s.issueCommand("debug",{},e)}t.debug=debug;function error(e){s.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){s.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+a.EOL)}t.info=info;function startGroup(e){s.issue("group",e)}t.startGroup=startGroup;function endGroup(){s.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return r(this,void 0,void 0,function*(){startGroup(e);let n;try{n=yield t()}finally{endGroup()}return n})}t.group=group;function saveState(e,t){s.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},717:function(e,t,n){var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=r(n(747));const s=r(n(87));const i=n(278);function issueCommand(e,t){const n=process.env[`GITHUB_${e}`];if(!n){throw new Error(`Unable to find environment variable for file command ${e}`)}if(!o.existsSync(n)){throw new Error(`Missing file at path: ${n}`)}o.appendFileSync(n,`${i.toCommandValue(t)}${s.EOL}`,{encoding:"utf8"})}t.issueCommand=issueCommand},278:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue},747:e=>{e.exports=require("fs")},211:e=>{e.exports=require("https")},87:e=>{e.exports=require("os")},622:e=>{e.exports=require("path")},191:e=>{e.exports=require("querystring")}};var t={};function __nccwpck_require__(n){if(t[n]){return t[n].exports}var r=t[n]={exports:{}};var o=true;try{e[n].call(r.exports,r,r.exports,__nccwpck_require__);o=false}finally{if(o)delete t[n]}return r.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(109)})(); \ No newline at end of file diff --git a/package.json b/package.json index 296d835..86f0d6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chatwork", - "version": "1.0.0", + "version": "1.0.1", "private": true, "description": "Send event to the chatwork", "main": "lib/main.js",