Skip to content

Commit

Permalink
Post link on Azure
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushgaud committed Sep 4, 2024
1 parent 0a6cdf0 commit ee650fb
Show file tree
Hide file tree
Showing 9 changed files with 1,527 additions and 2,606 deletions.
1 change: 1 addition & 0 deletions .github/workflows/develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: wrike-ist
env:
WRIKE_TOKEN: ${{ secrets.WRIKE_TOKEN }}
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
uses: ./
with:
opened: "In review"
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
- name: wrike-ist
env:
WRIKE_TOKEN: ${{ secrets.WRIKE_TOKEN }}
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
uses: ./
with:
opened: "In review"
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- name: wrike-ist
env:
WRIKE_TOKEN: ${{ secrets.WRIKE_TOKEN }}
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
uses: ./
with:
opened: "In review"
15 changes: 12 additions & 3 deletions resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12364,11 +12364,20 @@ wrike_ist.wrike.update_task_status=function(a,b){a=cljs.core.__destructure_map(a
e=cljs.core.clj__GT_js(new cljs.core.PersistentArrayMap(null,1,[cljs$cst$216$customStatus,e],null));return httpurr.client.node.put(d,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$183$headers,wrike_ist.wrike.headers(),cljs$cst$184$body,JSON.stringify(e)],null))})};
wrike_ist.wrike.progress_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);if(cljs.core.truth_(cljs.core.not_empty(b)))return wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$214$wanted_status,b,cljs$cst$215$wanted_group,"In Progress"],null))});console.log('Skipping `open` transition because it\'s set to "-"');return Promise.resolve()};
wrike_ist.wrike.complete_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?(console.log('Skipping `merged` transition because it\'s set to "-"'),Promise.resolve()):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$214$wanted_status,b,cljs$cst$215$wanted_group,"Completed"],null))})};
wrike_ist.wrike.cancel_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?(console.log('Skipping `closed` transition because it\'s set to "-"'),Promise.resolve()):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$214$wanted_status,b,cljs$cst$215$wanted_group,"Cancelled"],null))})};wrike_ist.core={};wrike_ist.core.find_links=function(a){return cljs.core.not_empty(cljs.core.re_seq(/\bhttps:\/\/www\.wrike\.com\/open\.htm\?id=\d+\b/,a))};
wrike_ist.wrike.cancel_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$210$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?(console.log('Skipping `closed` transition because it\'s set to "-"'),Promise.resolve()):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$214$wanted_status,b,cljs$cst$215$wanted_group,"Cancelled"],null))})};wrike_ist.azure={};wrike_ist.azure.organization="rapyuta-robotics";wrike_ist.azure.project="sootballs";wrike_ist.azure.azure_token=function(){var a=process;a=null==a?null:a.env;a=null==a?null:a.AZURE_TOKEN;return null==a?null:a.trim()};
wrike_ist.azure.headers=function(){return new cljs.core.PersistentArrayMap(null,2,[cljs$cst$203$Authorization,["Basic ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(btoa([":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(wrike_ist.azure.azure_token())].join("")))].join(""),cljs$cst$204$Content_Type,"application/json"],null)};wrike_ist.azure.parse_body=function(a){return cljs.core.js__GT_clj.cljs$core$IFn$_invoke$arity$1(JSON.parse(cljs$cst$184$body.cljs$core$IFn$_invoke$arity$1(a)))};
wrike_ist.azure.link_badge='\x3cspan style\x3d"background-color: rgb(255,204,128); color: rgb(25,25,25);" contenteditable\x3d"false"\x3ePull request for \x3c/span\x3e ';
wrike_ist.azure.link_html=function(a){var b=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$205$id);var c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$206$pr_url),d=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$207$target_branch),e=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$208$repository_name);b=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$209$title);return cljs.core.empty_QMARK_(b)?[wrike_ist.azure.link_badge,cljs.core.str.cljs$core$IFn$_invoke$arity$1(d),
': \x3ca href\x3d"',cljs.core.str.cljs$core$IFn$_invoke$arity$1(c),'"\x3e (#',cljs.core.str.cljs$core$IFn$_invoke$arity$1(a),")\x3c/a\x3e"].join(""):[wrike_ist.azure.link_badge,cljs.core.str.cljs$core$IFn$_invoke$arity$1(e)," on branch ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(d),': \x3ca href\x3d"',cljs.core.str.cljs$core$IFn$_invoke$arity$1(c),'"\x3e',cljs.core.str.cljs$core$IFn$_invoke$arity$1(b)," (#",cljs.core.str.cljs$core$IFn$_invoke$arity$1(a),")\x3c/a\x3e"].join("")};
wrike_ist.azure.find_task=function(a){var b=cljs.core.re_seq(/https:\/\/dev\.azure\.com\/[^\/]+\/[^\/]+\/_workitems\/edit\/(\d+)/,a);return new Promise(function(c,d){if(cljs.core.seq(b))return d=parseInt(cljs.core.second(cljs.core.first(b))),c.cljs$core$IFn$_invoke$arity$1?c.cljs$core$IFn$_invoke$arity$1(d):c.call(null,d);c=Error("No task ID found");return d.cljs$core$IFn$_invoke$arity$1?d.cljs$core$IFn$_invoke$arity$1(c):d.call(null,c)})};
wrike_ist.azure.link_pr=function(a){var b=cljs.core.__destructure_map(a),c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$206$pr_url);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$210$permalink);return wrike_ist.azure.find_task(a).then(function(d){d=cljs.core.__destructure_map(d);d=cljs.core.get.cljs$core$IFn$_invoke$arity$2(d,"id");var e=["https://dev.azure.com/",wrike_ist.azure.organization,"/",wrike_ist.azure.project,"/_apis/wit/workitems/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(d),
"/comments?api-version\x3d6.0"].join("");return httpurr.client.node.get(e,new cljs.core.PersistentArrayMap(null,1,[cljs$cst$183$headers,wrike_ist.azure.headers()],null)).then(function(f){return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(function(g,h){return cljs.core.truth_(cljs.core.get.cljs$core$IFn$_invoke$arity$2(h,"text").includes(c))?cljs.core.reduced(Promise.reject(cljs$cst$211$present)):g},Promise.resolve(),cljs.core.get.cljs$core$IFn$_invoke$arity$2(wrike_ist.azure.parse_body(f),"data"))}).then(function(){var f=
function(h){h=wrike_ist.azure.link_html(b);h=cljs.core.clj__GT_js(new cljs.core.PersistentArrayMap(null,2,[cljs$cst$212$text,h,cljs$cst$213$plainText,!1],null));return httpurr.client.node.post(e,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$183$headers,wrike_ist.azure.headers(),cljs$cst$184$body,JSON.stringify(h)],null))},g=function(h){var k=null;if(0<arguments.length){k=0;for(var l=Array(arguments.length-0);k<l.length;)l[k]=arguments[k+0],++k;k=new cljs.core.IndexedSeq(l,0,null)}return f.call(this,
k)};g.cljs$lang$maxFixedArity=0;g.cljs$lang$applyTo=function(h){h=cljs.core.seq(h);return f(h)};g.cljs$core$IFn$_invoke$arity$variadic=f;return g}()).then(function(){return console.log("PR link sent to task")}).catch(function(f){return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(f,cljs$cst$211$present)?console.log("PR link already in comments"):Promise.reject(f)})})};wrike_ist.core={};wrike_ist.core.find_links=function(a){return cljs.core.not_empty(cljs.core.re_seq(/\bhttps:\/\/dev\.azure\.com\/[^\/]+\/[^\/]+\/_workitems\/edit\/\d+\b/,a))};
wrike_ist.core.extract_details=function(a){var b=a.body;if(cljs.core.truth_(b)&&(b=wrike_ist.core.find_links(b),cljs.core.truth_(b))){var c=a.merged?cljs$cst$217$merged:cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(a.state,"closed")?cljs$cst$218$closed:a.draft?cljs$cst$219$draft:cljs$cst$220$open,d=a.html_url,e=a.title,f=a.number,g=a.base.ref,h=a.head.repo.name;return cljs.core.map.cljs$core$IFn$_invoke$arity$2(function(k){return new cljs.core.PersistentArrayMap(null,7,[cljs$cst$221$state,c,cljs$cst$210$permalink,
k,cljs$cst$206$pr_url,d,cljs$cst$205$id,f,cljs$cst$209$title,e,cljs$cst$207$target_branch,g,cljs$cst$208$repository_name,h],null)},b)}return null};
wrike_ist.core.main=function(){var a=shadow.js.shim.module$$actions$github.context.payload,b=a.pull_request;if(cljs.core.truth_(b))for(var c=wrike_ist.core.extract_details(b);;){var d=cljs.core.first(c);if(cljs.core.truth_(d)){var e=d,f=cljs.core.__destructure_map(e),g=f,h=cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,cljs$cst$221$state);(function(){var k=h;switch(k instanceof cljs.core.Keyword?k.fqn:null){case "draft":return wrike_ist.wrike.link_pr(g);case "open":return wrike_ist.wrike.link_pr(g);
case "merged":return wrike_ist.wrike.complete_task(g,shadow.js.shim.module$$actions$core.getInput("merged"));case "closed":return wrike_ist.wrike.cancel_task(g,shadow.js.shim.module$$actions$core.getInput("closed"));default:return Promise.resolve()}})().catch(function(k,l,m,n,p,q,r,t,v){return function(x){return shadow.js.shim.module$$actions$core.setFailed(x.message)}}(c,e,f,g,h,d,b,b,a));c=cljs.core.rest(c)}else return null}else return console.log("No pull_request in payload")};cljs.core.apply.cljs$core$IFn$_invoke$arity$2(wrike_ist.core.main,process.argv.slice(2));
wrike_ist.core.main=function(){var a=shadow.js.shim.module$$actions$github.context.payload,b=a.pull_request;if(cljs.core.truth_(b))for(var c=wrike_ist.core.extract_details(b);;){var d=cljs.core.first(c);if(cljs.core.truth_(d)){var e=d,f=cljs.core.__destructure_map(e),g=f,h=cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,cljs$cst$221$state);(function(){var k=h;switch(k instanceof cljs.core.Keyword?k.fqn:null){case "draft":return wrike_ist.azure.link_pr(g);case "open":return wrike_ist.azure.link_pr(g);
default:return Promise.resolve()}})().catch(function(k,l,m,n,p,q,r,t,v){return function(x){return shadow.js.shim.module$$actions$core.setFailed(x.message)}}(c,e,f,g,h,d,b,b,a));c=cljs.core.rest(c)}else return null}else return console.log("No pull_request in payload")};cljs.core.apply.cljs$core$IFn$_invoke$arity$2(wrike_ist.core.main,process.argv.slice(2));
})();

})();
Expand Down
Loading

0 comments on commit ee650fb

Please sign in to comment.