@ycmd/commands
Version:
LSK.js CLI Creds is the easiest way to manage GitHub / Gitlab secrets and credentials
9 lines (7 loc) • 1.64 kB
JavaScript
import { map } from 'fishbird';
import { gitlogPromise } from 'gitlog';
import { createCommand } from 'ycmd';
var w=Object.defineProperty;var l=(t,r)=>w(t,"name",{value:r,configurable:!0});var j=l((t,r)=>t.reduce((o,a)=>(o[a[r]]||(o[a[r]]=[]),o[a[r]].push(a),o),{}),"groupBy"),x=l(t=>t.reduce((r,o)=>r+o,0),"sum"),A=l(t=>Math.min(...t),"min"),C=l(t=>Math.max(...t),"max"),H=createCommand({command:"show-contributors [-f]",describe:"show contributors in git projects",builder:t=>t.options({format:{alias:"f",describe:"format of output",choices:["table","json"],default:"table"},path:{alias:"p",describe:"paths of directories comma separated"}}),async main({argv:t,log:r,cwd:o}){let{format:a="table",path:u=o}=t,p=String(u).split(",").map(e=>e.trim().replace("~",process.env.HOME)).filter(Boolean),c=(await map(p,async e=>{try{let s=await gitlogPromise({repo:e,number:1e5,execOptions:{maxBuffer:1e11},fields:["authorName","authorEmail","authorDate"]}),m=j(s,"authorEmail");return Object.values(m).map(n=>{let f=x(n.map(i=>i.files.length)),d=A(n.map(i=>new Date(i.authorDate))),h=C(n.map(i=>new Date(i.authorDate))),{authorName:b,authorEmail:g}=n[0];return {path:e,authorName:b,authorEmail:g,commits:n.length,files:f,firstCommitedAt:new Date(d).toISOString(),lastComiitedAt:new Date(h).toISOString()}})}catch(s){return r.warn(e,"err",s),[]}})).flat().flat().map(({path:e,...s})=>{e=e.replace(process.env.HOME,"~");let m=e.split("/")[2];return {path:e,project:m,...s}});a==="json"?console.log(JSON.stringify(c,null,4)):console.table(c);}});
export { H as default };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=show-contributors.js.map