staklink 0.2.22 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/proxy-server.cjs +1 -1
- package/dist/staklink-cli.cjs +1 -1
- package/package.json +1 -1
package/dist/proxy-server.cjs
CHANGED
|
@@ -77,7 +77,7 @@ globstar while`,t,h,n,f,m),this.matchOne(t.slice(h),n.slice(f),i))return this.de
|
|
|
77
77
|
`)[0];if(!n)throw new Error("empty result");let i=n.split(/\s+/)[1];if(!i)throw new Error("no hash found");return i}catch(t){throw t instanceof Error?t:new Error("Unknown error while getting commit hash")}}async getLatestCommitLink(){return(await this.execCommand(`echo "$(git config --get remote.origin.url | sed -e 's/\\.git$//g')/commit/$(git rev-parse HEAD)"`)).trim()}async newPr(){let t=await this.printMainBranch(),n=await this.printCurrentBranch();if(t===n)throw new Error("You are already on the main branch.");return this.execCommand(`gh pr create --base ${t} --head ${n} --fill`)}async getRemoteUrl(){return(await this.execCommand("git config --get remote.origin.url")).trim()}async setRemoteUrl(t){await this.execCommand(`git remote set-url origin "${t}"`)}async setUserConfig(t){await this.execCommand(`git config user.name "${t.auth_data.username}"`),await this.execCommand(`git config user.email "${t.auth_data.username}@users.noreply.github.com"`)}async unsetUserConfig(){await this.execCommand("git config --unset user.name").catch(t=>{console.warn("Error running git config --unset user.name",t)}),await this.execCommand("git config --unset user.email").catch(t=>{console.warn("Error running git config --unset user.email",t)})}async setUserCredentials(t){this.originalRemoteUrl=await this.getRemoteUrl();let n;switch(t.provider){case"github":n=this.originalRemoteUrl.replace("https://github.com/",`https://${t.auth_data.token}@github.com/`).replace(/https:\/\/.*@github\.com\//,`https://${t.auth_data.token}@github.com/`);break;case"gitlab":n=this.originalRemoteUrl.replace("https://gitlab.com/",`https://oauth2:${t.auth_data.token}@gitlab.com/`).replace(/https:\/\/.*@gitlab\.com\//,`https://oauth2:${t.auth_data.token}@gitlab.com/`);break;case"bitbucket":n=this.originalRemoteUrl.replace("https://bitbucket.org/",`https://${t.auth_data.username}:${t.auth_data.token}@bitbucket.org/`).replace(/https:\/\/.*@bitbucket\.org\//,`https://${t.auth_data.username}:${t.auth_data.token}@bitbucket.org/`);break;default:throw new Error(`Unsupported provider: ${t.provider}`)}await this.setRemoteUrl(n),await this.setUserConfig(t)}async restoreOriginalCredentials(){this.originalRemoteUrl&&(await this.setRemoteUrl(this.originalRemoteUrl),this.originalRemoteUrl=null),await this.unsetUserConfig()}async pushCurrentBranchWithCredentials(t){let n=(await this.printCurrentBranch()).trim();try{return t&&await this.setUserCredentials(t),await this.push(n)}catch(i){throw i}finally{t&&await this.restoreOriginalCredentials()}}async commitWithCredentials(t,n){try{return n&&await this.setUserConfig(n),await this.commit(t)}catch(i){throw i}finally{n&&await this.unsetUserConfig()}}};async function kn(e){let t=xn(e),n=await td(t);if(!n)throw new Error(`Repository not found for ${e}`);return new Ry(n)}var Dy=class{clients=new Set;addClient(t){return this.clients.add(t),this.sendToClient(t,"connected",{status:"connected"}),()=>this.removeClient(t)}removeClient(t){this.clients.delete(t)}sendLog(t){this.clients.size!==0&&this.broadcastEvent("log",t)}broadcastEvent(t,n){this.clients.forEach(i=>{this.sendToClient(i,t,n)})}sendToClient(t,n,i){try{t.writableEnded?this.removeClient(t):(t.write(`event: ${n}
|
|
78
78
|
`),t.write(`data: ${JSON.stringify(i)}
|
|
79
79
|
|
|
80
|
-
`))}catch(r){console.error("Error sending SSE:",r),this.removeClient(t)}}get clientCount(){return this.clients.size}},Uy=new Dy;var wz="0.
|
|
80
|
+
`))}catch(r){console.error("Error sending SSE:",r),this.removeClient(t)}}get clientCount(){return this.clients.size}},Uy=new Dy;var wz="0.3.0";var ft=[];for(let e=0;e<256;++e)ft.push((e+256).toString(16).slice(1));function kz(e,t=0){return(ft[e[t+0]]+ft[e[t+1]]+ft[e[t+2]]+ft[e[t+3]]+"-"+ft[e[t+4]]+ft[e[t+5]]+"-"+ft[e[t+6]]+ft[e[t+7]]+"-"+ft[e[t+8]]+ft[e[t+9]]+"-"+ft[e[t+10]]+ft[e[t+11]]+ft[e[t+12]]+ft[e[t+13]]+ft[e[t+14]]+ft[e[t+15]]).toLowerCase()}var $z=require("crypto"),Id=new Uint8Array(256),Sd=Id.length;function My(){return Sd>Id.length-16&&((0,$z.randomFillSync)(Id),Sd=0),Id.slice(Sd,Sd+=16)}var Sz=require("crypto"),Ly={randomUUID:Sz.randomUUID};function AK(e,t,n){if(Ly.randomUUID&&!t&&!e)return Ly.randomUUID();e=e||{};let i=e.random??e.rng?.()??My();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(n=n||0,n<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let r=0;r<16;++r)t[n+r]=i[r];return t}return kz(i)}var qy=AK;var $n={},Zy=[],NK=100;function Sn(){let e=qy();if(Zy.length>=NK){let t=Zy.shift();t&&delete $n[t]}return $n[e]={status:"pending",result:void 0},Zy.push(e),e}function In(e,t){$n[e]&&($n[e].status="completed",$n[e].result=t)}function En(e,t){$n[e]&&($n[e].status="failed",$n[e].error=t)}function Iz(e){return $n[e]}var Ez=ke(require("child_process"),1);async function Tz(e,t,n,i){return new Promise((r,o)=>{let a=Ez.spawn("sh",["-c",e],{cwd:t,stdio:["pipe","pipe","pipe"],env:n?{...process.env,...n}:process.env}),s="",c="";a.stdout?.on("data",u=>{let p=u.toString();s+=p,p.split(`
|
|
81
81
|
`).forEach(d=>{d.trim()&&i&&i(d)})}),a.stderr?.on("data",u=>{let p=u.toString();c+=p,p.split(`
|
|
82
82
|
`).forEach(d=>{d.trim()&&i&&i(`[ERR] ${d}`)})}),a.on("close",u=>{if(u===0)r({stdout:s,stderr:c});else{let p=new Error(`Command failed with exit code ${u}`);i&&i(`\u274C Error: ${p.message}`),o(`${p.message}
|
|
83
83
|
${c}`)}}),a.on("error",u=>{let p=u.message||String(u);i&&i(`\u274C Error: ${p}`),o(`${p}
|
package/dist/staklink-cli.cjs
CHANGED
|
@@ -10896,7 +10896,7 @@ var glob = Object.assign(glob_, {
|
|
|
10896
10896
|
glob.glob = glob;
|
|
10897
10897
|
|
|
10898
10898
|
// src/proxy/version.ts
|
|
10899
|
-
var VERSION = "0.
|
|
10899
|
+
var VERSION = "0.3.0";
|
|
10900
10900
|
|
|
10901
10901
|
// src/cli.ts
|
|
10902
10902
|
var STAKLINK_PROXY = "staklink-proxy";
|