UNPKG

@bring-it/sentry

Version:
1 lines 4.1 kB
export const __webpack_esm_id__=992;export const __webpack_esm_ids__=[992];export const __webpack_esm_modules__={119:(e,t,n)=>{n.a(e,async(e,o)=>{try{n.d(t,{Vy:()=>E,Xe:()=>m,Xg:()=>N});var s=n(455),a=n(538),i=n(460),r=e([i]),c=r.then?(await r)():r;i=c[0];const{red:_,cyan:l,green:d,yellow:f,magenta:u}=a.Ay,g=d("[okay]"),h=_("[fail]"),p=f("[warn]");class E{constructor(e){this.name=`[${l("bring-it")}:${u(e)}]`}okay(...e){this.log(g,...e)}fail(...e){this.log(h,...e)}warn(...e){this.log(p,...e)}task(...e){this.log("[task]",...e)}file(...e){this.log("[file]",...e)}info(...e){this.log("[info]",...e)}json(e){this.log("[json]",JSON.stringify(e,"",2))}log(...e){console.log(this.name,...e)}}const m=["**/.{cache,git,svn,ssh,yarn}/**","**/.{npm,yarn}rc","**/.env.*","**/.env","**/.git{keep,ignore}","**/{node,web}_modules/**","**/*.{pem,ppk}","**/id_{d,r}sa","**/.obsidian/**","**/.docusaurus/**","**/miniprogram_npm/**","**/ssh*config","**/sshd*config"];function y(e,t){return(0,s.readFile)(e,"utf8").then(e=>JSON.parse(e)).then(e=>{if(i.P9){const{branches:t,...n}=e;return{...n,...t?.[i.P9]}}return e}).catch(e=>(t.warn(e.message),t.info("Fallback to default configuration"),{}))}function N(e,t){return y(`.bring-it/${e}.config.json`,t)}o()}catch(R){o(R)}})},460:(e,t,n)=>{n.a(e,async(e,o)=>{try{n.d(t,{P9:()=>y});const{CNB_BUILD_ID:s,CNB_BRANCH:a,CNB_COMMIT:i,CNB_COMMIT_SHORT:r,CNB_BEFORE_SHA:c,CNB_REPO_URL_HTTPS:_,CNB_DOCKER_REGISTRY:l,CNB_PIPELINE_NAME:d,CNB_REPO_SLUG_LOWERCASE:f,CNB_BUILD_WEB_URL:u,CNB_TOKEN:g}=process.env;async function h(){const e=`https://api.cnb.cool/${f}/-/build/logs?sourceRef=${a}&pagesize=1&status=success&event=push`;try{const t=await fetch(e,{headers:{Authorization:`Bearer ${g}`}});if(!t.ok)throw new Error(`Response status: ${t.status}`);const n=await t.json(),{sha:o}=n.data[0]||{};return o||c}catch(e){console.error(e.message)}return c}const{CNB:p,npm_package_version:E="\u672a\u77e5",CUSTOM_ARTIFACT_URL:m,BRANCH_NAME:y=(p?a:void 0),CCI_JOB_NAME:N=(p?d:void 0),CI_BUILD_NUMBER:R,DEPOT_NAME:T=(p?f:void 0),GIT_COMMIT_SHORT:C=(p?r:void 0),GIT_COMMIT:w=(p?i:void 0),GIT_PREVIOUS_COMMIT:O=(p?await h():void 0),GIT_HTTP_URL:B=(p?_:void 0),JOB_ID:k=(p?s:void 0),PROJECT_WEB_URL:v=(p?`https://cnb.cool/${f}`:void 0),DOCKER_REG_HOST:I=(p?l:void 0)}=process.env;function S(e=""){return e.slice(0,7)}S(O),o()}catch(A){o(A)}},1)},992:(e,t,n)=>{n.a(e,async(e,o)=>{try{n.d(t,{action:()=>g});var s=n(421),a=n(455),i=n(119),r=n(293),c=n(373),_=e([i]),l=_.then?(await _)():_;const d=new(i=l[0]).Vy("sentry");function f({include:e}){return(0,c.globby)(e,{ignore:i.Xe,onlyFiles:!0,dot:!0}).then(e=>e.filter(e=>/\.map$/.test(e))).then(e=>e.toSorted())}function u({url:e,org:t,project:n}){return function(...o){return(0,r.Ho)("sentry-cli",["releases",...o],{stdio:"inherit",env:{SENTRY_AUTH_TOKEN:process.env.SENTRY_AUTH_TOKEN,SENTRY_URL:e,SENTRY_ORG:t,SENTRY_PROJECT:n,SENTRY_LOG_LEVEL:"info"}}).then(e=>{if(e.stderr)throw new Error("Command failed")})}}async function g({name:e}){try{const{[e]:t,...n}=await(0,i.Xg)("sentry",d),{url:o,org:r,project:c,include:_="dist/**"}={...n,...t};d.json({url:o,org:r,project:c,name:e,include:_}),d.task("scanning...");const l=await f({include:_});d.info("found",l.length,"files");for(const e of l)d.file(e);if(l.length>0){const t=(0,s.execFileSync)("git",["rev-parse","HEAD"],{encoding:"utf8"}).trim();d.info("git commit hash",t);const n=u({url:o,org:r,project:c});d.task("create release..."),await n("new",t),d.okay("release created"),d.task("uploading...");const i=process.env.BRANCH_NAME;await n("files",t,"upload-sourcemaps",_,"--dist",e,"--note",JSON.stringify({name:e,mode:i}),"--no-sourcemap-reference","--no-rewrite"),d.okay("uploaded"),d.task("deploys",i),await n("deploys",t,"new","-e",i,"-n",e),await n("set-commits","--local",t,"--ignore-missing"),d.task("finalize..."),await n("finalize",t),d.okay("finalized"),d.task("delete files...");for(const e of l)await(0,a.rm)(e,{force:!0}).then(()=>{d.okay("[delete]",e)}).catch(t=>{d.fail("[delete]",e,t.message)});d.okay("done")}}catch(e){d.fail(e.message)}}o()}catch(h){o(h)}})}};