@gadgetinc/ggt 1.2.0 → 1.3.1
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/README.md +3 -0
- package/dist/add-CVO2CSA3.js +78 -0
- package/dist/add-CVO2CSA3.js.map +7 -0
- package/dist/chunk-3V7YWBUK.js +2 -0
- package/dist/{chunk-BSCZOMV4.js.map → chunk-3V7YWBUK.js.map} +1 -1
- package/dist/chunk-6BXHYE2C.js +187 -0
- package/dist/chunk-6BXHYE2C.js.map +7 -0
- package/dist/{chunk-BYMG3KOL.js → chunk-ACR6CVXY.js} +4 -4
- package/dist/{chunk-BYMG3KOL.js.map → chunk-ACR6CVXY.js.map} +2 -2
- package/dist/{chunk-KMCOZJPU.js → chunk-AGRDDZFS.js} +2 -2
- package/dist/{chunk-KMCOZJPU.js.map → chunk-AGRDDZFS.js.map} +4 -4
- package/dist/chunk-B6XQEEUK.js +2 -0
- package/dist/chunk-B6XQEEUK.js.map +7 -0
- package/dist/chunk-FQ2LR3BI.js +6 -0
- package/dist/chunk-FQ2LR3BI.js.map +7 -0
- package/dist/chunk-GIAIN3IJ.js +65 -0
- package/dist/chunk-GIAIN3IJ.js.map +7 -0
- package/dist/{chunk-THZRTDWW.js → chunk-HCQR6OPH.js} +2 -2
- package/dist/chunk-MIN6ZMLJ.js +117 -0
- package/dist/chunk-MIN6ZMLJ.js.map +7 -0
- package/dist/chunk-O2K4B6AL.js +50 -0
- package/dist/chunk-O2K4B6AL.js.map +7 -0
- package/dist/chunk-P5OUQ5XQ.js +2 -0
- package/dist/chunk-SGMPMYEU.js +2 -0
- package/dist/chunk-SGMPMYEU.js.map +7 -0
- package/dist/{chunk-BZSAGSV3.js → chunk-W5JAWOQQ.js} +2 -2
- package/dist/chunk-XB3JTJT6.js +18 -0
- package/dist/{chunk-6FBP46EB.js.map → chunk-XB3JTJT6.js.map} +3 -3
- package/dist/chunk-YESACFSR.js +2 -0
- package/dist/chunk-YESACFSR.js.map +7 -0
- package/dist/deploy-6JPQ4SNV.js +25 -0
- package/dist/deploy-6JPQ4SNV.js.map +7 -0
- package/dist/dev-ZPSCK7JQ.js +58 -0
- package/dist/{dev-OT7PEKUN.js.map → dev-ZPSCK7JQ.js.map} +4 -4
- package/dist/esm-46TFUFSK.js +36 -0
- package/dist/esm-46TFUFSK.js.map +7 -0
- package/dist/list-A7LFGUXG.js +11 -0
- package/dist/list-A7LFGUXG.js.map +7 -0
- package/dist/login-BP4XIHLA.js +2 -0
- package/dist/logout-PPA6JCDY.js +7 -0
- package/dist/{logout-B3YAZN6R.js.map → logout-PPA6JCDY.js.map} +1 -1
- package/dist/main.js +10 -10
- package/dist/main.js.map +3 -3
- package/dist/open-MWPVVE7V.js +74 -0
- package/dist/open-MWPVVE7V.js.map +7 -0
- package/dist/{pull-SLPBOP6Z.js → pull-WEYQPN7H.js} +4 -4
- package/dist/{pull-SLPBOP6Z.js.map → pull-WEYQPN7H.js.map} +2 -2
- package/dist/push-S4CWMHMS.js +2 -0
- package/dist/status-GI5XJQTQ.js +14 -0
- package/dist/status-GI5XJQTQ.js.map +7 -0
- package/dist/{version-AUI4NRDS.js → version-CXGPMLMK.js} +2 -2
- package/dist/{version-AUI4NRDS.js.map → version-CXGPMLMK.js.map} +1 -1
- package/dist/whoami-PPXXBHUR.js +7 -0
- package/dist/{whoami-TXO7VJXC.js.map → whoami-PPXXBHUR.js.map} +1 -1
- package/package.json +20 -19
- package/dist/add-DCE6CV2D.js +0 -78
- package/dist/add-DCE6CV2D.js.map +0 -7
- package/dist/build-4BGA4IZE.js +0 -3
- package/dist/build-4BGA4IZE.js.map +0 -7
- package/dist/chunk-3Q3GPB6Z.js +0 -2
- package/dist/chunk-3Q3GPB6Z.js.map +0 -7
- package/dist/chunk-57XALM2W.js +0 -2
- package/dist/chunk-57XALM2W.js.map +0 -7
- package/dist/chunk-5WC5D4WL.js +0 -2
- package/dist/chunk-5WC5D4WL.js.map +0 -7
- package/dist/chunk-6FBP46EB.js +0 -18
- package/dist/chunk-AB4I3BMD.js +0 -33
- package/dist/chunk-AB4I3BMD.js.map +0 -7
- package/dist/chunk-BSCZOMV4.js +0 -2
- package/dist/chunk-CXYA3RFX.js +0 -117
- package/dist/chunk-CXYA3RFX.js.map +0 -7
- package/dist/chunk-D2K5XPNJ.js +0 -2
- package/dist/chunk-D2K5XPNJ.js.map +0 -7
- package/dist/chunk-DVKNBG4P.js +0 -180
- package/dist/chunk-DVKNBG4P.js.map +0 -7
- package/dist/chunk-EFU2JNKY.js +0 -9
- package/dist/chunk-EFU2JNKY.js.map +0 -7
- package/dist/chunk-F3EZ4KS3.js +0 -2
- package/dist/chunk-F3EZ4KS3.js.map +0 -7
- package/dist/chunk-GOBNB5VT.js +0 -2
- package/dist/chunk-GOBNB5VT.js.map +0 -7
- package/dist/chunk-HKBXEZNF.js +0 -2
- package/dist/chunk-KGOVR5SK.js +0 -67
- package/dist/chunk-KGOVR5SK.js.map +0 -7
- package/dist/chunk-M4PNFOA5.js +0 -6
- package/dist/chunk-M4PNFOA5.js.map +0 -7
- package/dist/chunk-OLKWG2EP.js +0 -12
- package/dist/chunk-OLKWG2EP.js.map +0 -7
- package/dist/context-L5YSPF3X.js +0 -2
- package/dist/deploy-PBJEUYGH.js +0 -25
- package/dist/deploy-PBJEUYGH.js.map +0 -7
- package/dist/dev-OT7PEKUN.js +0 -55
- package/dist/esm-GJ7RK6IC.js +0 -34
- package/dist/esm-GJ7RK6IC.js.map +0 -7
- package/dist/list-CC5PICEF.js +0 -11
- package/dist/list-CC5PICEF.js.map +0 -7
- package/dist/login-SE7XIHRW.js +0 -2
- package/dist/logout-B3YAZN6R.js +0 -7
- package/dist/open-OVK3YL4O.js +0 -74
- package/dist/open-OVK3YL4O.js.map +0 -7
- package/dist/push-3HGVWCKW.js +0 -2
- package/dist/push-3HGVWCKW.js.map +0 -7
- package/dist/status-7GLNL7D5.js +0 -14
- package/dist/status-7GLNL7D5.js.map +0 -7
- package/dist/user-C34J52UL.js +0 -2
- package/dist/user-C34J52UL.js.map +0 -7
- package/dist/whoami-TXO7VJXC.js +0 -7
- /package/dist/{chunk-THZRTDWW.js.map → chunk-HCQR6OPH.js.map} +0 -0
- /package/dist/{chunk-HKBXEZNF.js.map → chunk-P5OUQ5XQ.js.map} +0 -0
- /package/dist/{chunk-BZSAGSV3.js.map → chunk-W5JAWOQQ.js.map} +0 -0
- /package/dist/{context-L5YSPF3X.js.map → login-BP4XIHLA.js.map} +0 -0
- /package/dist/{login-SE7XIHRW.js.map → push-S4CWMHMS.js.map} +0 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import{b as gt,e as ft,h as ht,j as xe,k as te,l as It}from"./chunk-MIN6ZMLJ.js";import{a as St,b as mt}from"./chunk-HCQR6OPH.js";import{b as $}from"./chunk-W5JAWOQQ.js";import{c as dt}from"./chunk-YESACFSR.js";import{c as Me}from"./chunk-XB3JTJT6.js";import{B as Mt,i as Ee,j as w,k as _r,l as yt,q as bt}from"./chunk-O2K4B6AL.js";import{b as Et,c as xt}from"./chunk-AGRDDZFS.js";import{$ as R,E as ut,H as pt,I as N,L as be,M as Z,P as ee,S as ct,Z as m,_ as k,b,d as rt,g as at,n as ot,p as he,q as st,r as it,s as lt,z as Ar}from"./chunk-GIAIN3IJ.js";import{a as Ir}from"./chunk-B6XQEEUK.js";import{a as v,c as x,e as F,g as u}from"./chunk-SGMPMYEU.js";var Dt=x((hs,Vt)=>{u();Vt.exports=Gt;Gt.sync=Pr;var kt=v("fs");function wr(e,t){var n=t.pathExt!==void 0?t.pathExt:process.env.PATHEXT;if(!n||(n=n.split(";"),n.indexOf("")!==-1))return!0;for(var r=0;r<n.length;r++){var a=n[r].toLowerCase();if(a&&e.substr(-a.length).toLowerCase()===a)return!0}return!1}function Lt(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:wr(t,n)}function Gt(e,t,n){kt.stat(e,function(r,a){n(r,r?!1:Lt(a,e,t))})}function Pr(e,t){return Lt(kt.statSync(e),e,t)}});var jt=x((Es,Qt)=>{u();Qt.exports=Ut;Ut.sync=Or;var Ht=v("fs");function Ut(e,t,n){Ht.stat(e,function(r,a){n(r,r?!1:$t(a,t))})}function Or(e,t){return $t(Ht.statSync(e),t)}function $t(e,t){return e.isFile()&&Br(e,t)}function Br(e,t){var n=e.mode,r=e.uid,a=e.gid,o=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),s=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),i=parseInt("100",8),l=parseInt("010",8),p=parseInt("001",8),c=i|l,d=n&p||n&l&&a===s||n&i&&r===o||n&c&&o===0;return d}});var Wt=x((Is,Jt)=>{u();var Ms=v("fs"),ae;process.platform==="win32"||global.TESTING_WINDOWS?ae=Dt():ae=jt();Jt.exports=_e;_e.sync=Nr;function _e(e,t,n){if(typeof t=="function"&&(n=t,t={}),!n){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(r,a){_e(e,t||{},function(o,s){o?a(o):r(s)})})}ae(e,t||{},function(r,a){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,a=!1),n(r,a)})}function Nr(e,t){try{return ae.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}});var en=x((_s,Zt)=>{u();var V=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",qt=v("path"),kr=V?";":":",Yt=Wt(),zt=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Kt=(e,t)=>{let n=t.colon||kr,r=e.match(/\//)||V&&e.match(/\\/)?[""]:[...V?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],a=V?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=V?a.split(n):[""];return V&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:r,pathExt:o,pathExtExe:a}},Xt=(e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});let{pathEnv:r,pathExt:a,pathExtExe:o}=Kt(e,t),s=[],i=p=>new Promise((c,d)=>{if(p===r.length)return t.all&&s.length?c(s):d(zt(e));let y=r[p],S=/^".*"$/.test(y)?y.slice(1,-1):y,f=qt.join(S,e),h=!S&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;c(l(h,p,0))}),l=(p,c,d)=>new Promise((y,S)=>{if(d===a.length)return y(i(c+1));let f=a[d];Yt(p+f,{pathExt:o},(h,g)=>{if(!h&&g)if(t.all)s.push(p+f);else return y(p+f);return y(l(p,c,d+1))})});return n?i(0).then(p=>n(null,p),n):i(0)},Lr=(e,t)=>{t=t||{};let{pathEnv:n,pathExt:r,pathExtExe:a}=Kt(e,t),o=[];for(let s=0;s<n.length;s++){let i=n[s],l=/^".*"$/.test(i)?i.slice(1,-1):i,p=qt.join(l,e),c=!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+p:p;for(let d=0;d<r.length;d++){let y=c+r[d];try{if(Yt.sync(y,{pathExt:a}))if(t.all)o.push(y);else return y}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw zt(e)};Zt.exports=Xt;Xt.sync=Lr});var nn=x((Ts,Ce)=>{"use strict";u();var tn=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"};Ce.exports=tn;Ce.exports.default=tn});var sn=x((Fs,on)=>{"use strict";u();var rn=v("path"),Gr=en(),Vr=nn();function an(e,t){let n=e.options.env||process.env,r=process.cwd(),a=e.options.cwd!=null,o=a&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch{}let s;try{s=Gr.sync(e.command,{path:n[Vr({env:n})],pathExt:t?rn.delimiter:void 0})}catch{}finally{o&&process.chdir(r)}return s&&(s=rn.resolve(a?e.options.cwd:"",s)),s}function Dr(e){return an(e)||an(e,!0)}on.exports=Dr});var ln=x((ws,ve)=>{"use strict";u();var Te=/([()\][%!^"`<>&|;, *?])/g;function Hr(e){return e=e.replace(Te,"^$1"),e}function Ur(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(Te,"^$1"),t&&(e=e.replace(Te,"^$1")),e}ve.exports.command=Hr;ve.exports.argument=Ur});var pn=x((Os,un)=>{"use strict";u();un.exports=/^#!(.*)/});var dn=x((Ns,cn)=>{"use strict";u();var $r=pn();cn.exports=(e="")=>{let t=e.match($r);if(!t)return null;let[n,r]=t[0].replace(/#! ?/,"").split(" "),a=n.split("/").pop();return a==="env"?r:r?`${a} ${r}`:a}});var Sn=x((Ls,yn)=>{"use strict";u();var Fe=v("fs"),Qr=dn();function jr(e){let n=Buffer.alloc(150),r;try{r=Fe.openSync(e,"r"),Fe.readSync(r,n,0,150,0),Fe.closeSync(r)}catch{}return Qr(n.toString())}yn.exports=jr});var hn=x((Vs,fn)=>{"use strict";u();var Jr=v("path"),mn=sn(),gn=ln(),Wr=Sn(),qr=process.platform==="win32",Yr=/\.(?:com|exe)$/i,zr=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Kr(e){e.file=mn(e);let t=e.file&&Wr(e.file);return t?(e.args.unshift(e.file),e.command=t,mn(e)):e.file}function Xr(e){if(!qr)return e;let t=Kr(e),n=!Yr.test(t);if(e.options.forceShell||n){let r=zr.test(t);e.command=Jr.normalize(e.command),e.command=gn.command(e.command),e.args=e.args.map(o=>gn.argument(o,r));let a=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${a}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Zr(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:Xr(r)}fn.exports=Zr});var xn=x((Hs,En)=>{"use strict";u();var Re=process.platform==="win32";function we(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function ea(e,t){if(!Re)return;let n=e.emit;e.emit=function(r,a){if(r==="exit"){let o=bn(a,t,"spawn");if(o)return n.call(e,"error",o)}return n.apply(e,arguments)}}function bn(e,t){return Re&&e===1&&!t.file?we(t.original,"spawn"):null}function ta(e,t){return Re&&e===1&&!t.file?we(t.original,"spawnSync"):null}En.exports={hookChildProcess:ea,verifyENOENT:bn,verifyENOENTSync:ta,notFoundError:we}});var An=x(($s,D)=>{"use strict";u();var Mn=v("child_process"),Pe=hn(),Oe=xn();function In(e,t,n){let r=Pe(e,t,n),a=Mn.spawn(r.command,r.args,r.options);return Oe.hookChildProcess(a,r),a}function na(e,t,n){let r=Pe(e,t,n),a=Mn.spawnSync(r.command,r.args,r.options);return a.error=a.error||Oe.verifyENOENTSync(a.status,r),a}D.exports=In;D.exports.spawn=In;D.exports.sync=na;D.exports._parse=Pe;D.exports._enoent=Oe});var Kn=x((pl,zn)=>{"use strict";u();var{PassThrough:Xa}=v("stream");zn.exports=function(){var e=[],t=new Xa({objectMode:!0});return t.setMaxListeners(0),t.add=n,t.isEmpty=r,t.on("unpipe",a),Array.prototype.slice.call(arguments).forEach(n),t;function n(o){return Array.isArray(o)?(o.forEach(n),this):(e.push(o),o.once("end",a.bind(null,o)),o.once("error",t.emit.bind(t,"error")),o.pipe(t,{end:!1}),this)}function r(){return e.length==0}function a(o){e=e.filter(function(s){return s!==o}),!e.length&&t.readable&&t.end()}}});var mr=x((zl,Sr)=>{u();function I(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}Sr.exports=I;I.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};I.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};I.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0};I.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};I.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};I.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};I.prototype.start=I.prototype.try;I.prototype.errors=function(){return this._errors};I.prototype.attempts=function(){return this._attempts};I.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var a=this._errors[r],o=a.message,s=(e[o]||0)+1;e[o]=s,s>=n&&(t=a,n=s)}return t}});var gr=x(B=>{u();var Io=mr();B.operation=function(e){var t=B.timeouts(e);return new Io(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};B.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],a=0;a<t.retries;a++)r.push(this.createTimeout(a,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(a,t)),r.sort(function(o,s){return o-s}),r};B.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return r=Math.min(r,t.maxTimeout),r};B.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var r in e)typeof e[r]=="function"&&n.push(r)}for(var a=0;a<n.length;a++){var o=n[a],s=e[o];e[o]=function(l){var p=B.operation(t),c=Array.prototype.slice.call(arguments,1),d=c.pop();c.push(function(y){p.retry(y)||(y&&(arguments[0]=p.mainError()),d.apply(this,arguments))}),p.attempt(function(){l.apply(e,c)})}.bind(e,s),e[o].options=t}}});var hr=x((eu,fr)=>{u();fr.exports=gr()});u();var Q=F(yt(),1);var ne=class extends Map{created=N(()=>Array.from(this.entries()).filter(([,t])=>t.type==="create").map(([t])=>t));updated=N(()=>Array.from(this.entries()).filter(([,t])=>t.type==="update").map(([t])=>t));deleted=N(()=>Array.from(this.entries()).filter(([,t])=>t.type==="delete").map(([t])=>t))},Cr=b.greenBright("+"),Tr=b.blueBright("\xB1"),vr=b.redBright("-"),At=b.yellowBright("\u2192"),j=(e,{changes:t,tense:n,limit:r=1/0,...a})=>{ee.logLevel<=Z.TRACE&&(r=1/0);let o=Array.from(t.entries()).filter(([y])=>!y.startsWith(".gadget/"));if(o.length===0)return"";let s=b.yellowBright(n==="past"?"renamed":"rename"),i=b.greenBright(n==="past"?"created":"create"),l=b.blueBright(n==="past"?"updated":"update"),p=b.redBright(n==="past"?"deleted":"delete"),c=o.sort((y,S)=>y[0].localeCompare(S[0])).slice(0,r).map(([y,S])=>{switch(!0){case(S.type==="create"&&at(S.oldPath)):return[At,b.yellowBright(S.oldPath),s,At,b.yellowBright(y)];case S.type==="create":return[Cr,b.greenBright(y),i];case S.type==="update":return[Tr,b.blueBright(y),l];case S.type==="delete":return[vr,b.redBright(y),p];default:return ot(S)}});o.length>r&&c.push([b.gray(w.ellipsis),m`{gray ${o.length-r} more}`,""]);let d;if(o.length>=5){let y=[],S=o.filter(([,g])=>g.type==="create").length;if(S>0){let g=n==="past"?`${S} created`:(0,Q.default)("create",S,!0);y.push(m`{greenBright ${g}}`)}let f=o.filter(([,g])=>g.type==="update").length;if(f>0){let g=n==="past"?`${f} updated`:(0,Q.default)("update",f,!0);y.push(m`{blueBright ${g}}`)}let h=o.filter(([,g])=>g.type==="delete").length;if(h>0){let g=n==="past"?`${h} deleted`:(0,Q.default)("delete",h,!0);y.push(m`{redBright ${g}}`)}d=k`
|
|
2
|
+
${(0,Q.default)("change",o.length,!0)} in total. ${y.join(", ")}.
|
|
3
|
+
`}return St({rows:c,footer:d,ensureEmptyLineAbove:!0,ensureEmptyLineAboveBody:!1,ensureEmptyLineAboveFooter:!0,indent:0,...a})},re=(e,t)=>{let n=j(e,t);n&&R(n)};u();var _t=m(`
|
|
4
|
+
subscription EnvironmentLogs($query: String!, $start: DateTime, $limit: Int) {
|
|
5
|
+
logsSearchV2(query: $query, start: $start, limit: $limit) {
|
|
6
|
+
status
|
|
7
|
+
data
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`),Ct=m(`
|
|
11
|
+
subscription RemoteFileSyncEvents($localFilesVersion: String!) {
|
|
12
|
+
remoteFileSyncEvents(localFilesVersion: $localFilesVersion, encoding: base64) {
|
|
13
|
+
remoteFilesVersion
|
|
14
|
+
changed {
|
|
15
|
+
path
|
|
16
|
+
mode
|
|
17
|
+
content
|
|
18
|
+
encoding
|
|
19
|
+
}
|
|
20
|
+
deleted {
|
|
21
|
+
path
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`),Ho=m(`
|
|
26
|
+
query RemoteFilesVersion {
|
|
27
|
+
remoteFilesVersion
|
|
28
|
+
}
|
|
29
|
+
`),Tt=m(`
|
|
30
|
+
mutation PublishFileSyncEvents($input: PublishFileSyncEventsInput!) {
|
|
31
|
+
publishFileSyncEvents(input: $input) {
|
|
32
|
+
remoteFilesVersion
|
|
33
|
+
problems {
|
|
34
|
+
level
|
|
35
|
+
message
|
|
36
|
+
path
|
|
37
|
+
type
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`),vt=m(`
|
|
42
|
+
query FileSyncFiles($paths: [String!]!, $filesVersion: String, $encoding: FileSyncEncoding) {
|
|
43
|
+
fileSyncFiles(paths: $paths, filesVersion: $filesVersion, encoding: $encoding) {
|
|
44
|
+
filesVersion
|
|
45
|
+
files {
|
|
46
|
+
path
|
|
47
|
+
mode
|
|
48
|
+
content
|
|
49
|
+
encoding
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`),Ft=m(`
|
|
54
|
+
query FileSyncHashes($filesVersion: String) {
|
|
55
|
+
fileSyncHashes(filesVersion: $filesVersion) {
|
|
56
|
+
filesVersion
|
|
57
|
+
hashes
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`),Rt=m(`
|
|
61
|
+
query FileSyncComparisonHashes($filesVersion: String!) {
|
|
62
|
+
fileSyncComparisonHashes(filesVersion: $filesVersion) {
|
|
63
|
+
filesVersionHashes {
|
|
64
|
+
filesVersion
|
|
65
|
+
hashes
|
|
66
|
+
}
|
|
67
|
+
latestFilesVersionHashes {
|
|
68
|
+
filesVersion
|
|
69
|
+
hashes
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`),Uo=m(`
|
|
74
|
+
subscription PublishStatus($localFilesVersion: String!, $force: Boolean, $allowCharges: Boolean, $allowDeletedData: Boolean) {
|
|
75
|
+
publishStatus(localFilesVersion: $localFilesVersion, force: $force, allowCharges: $allowCharges, allowDeletedData: $allowDeletedData) {
|
|
76
|
+
publishStarted
|
|
77
|
+
remoteFilesVersion
|
|
78
|
+
progress
|
|
79
|
+
issues {
|
|
80
|
+
severity
|
|
81
|
+
message
|
|
82
|
+
node {
|
|
83
|
+
type
|
|
84
|
+
key
|
|
85
|
+
apiIdentifier
|
|
86
|
+
name
|
|
87
|
+
fieldType
|
|
88
|
+
parentKey
|
|
89
|
+
parentApiIdentifier
|
|
90
|
+
}
|
|
91
|
+
nodeLabels {
|
|
92
|
+
type
|
|
93
|
+
identifier
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
deletedModelsAndFields {
|
|
97
|
+
deletedModels
|
|
98
|
+
deletedModelFields {
|
|
99
|
+
modelIdentifier
|
|
100
|
+
fields
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
status {
|
|
104
|
+
code
|
|
105
|
+
message
|
|
106
|
+
output
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`),$o=m(`
|
|
111
|
+
mutation createModel($path: String!, $fields: [CreateModelFieldsInput!]) {
|
|
112
|
+
createModel(path: $path, fields: $fields) {
|
|
113
|
+
remoteFilesVersion
|
|
114
|
+
changed {
|
|
115
|
+
path
|
|
116
|
+
mode
|
|
117
|
+
content
|
|
118
|
+
encoding
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
`),Qo=m(`
|
|
123
|
+
mutation createAction($path: String!) {
|
|
124
|
+
createAction(path: $path) {
|
|
125
|
+
remoteFilesVersion
|
|
126
|
+
changed {
|
|
127
|
+
path
|
|
128
|
+
mode
|
|
129
|
+
content
|
|
130
|
+
encoding
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
`),jo=m(`
|
|
135
|
+
mutation createRoute($method: String!, $path: String!) {
|
|
136
|
+
createRoute(method: $method, path: $path) {
|
|
137
|
+
remoteFilesVersion
|
|
138
|
+
changed {
|
|
139
|
+
path
|
|
140
|
+
mode
|
|
141
|
+
content
|
|
142
|
+
encoding
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`),Jo=m(`
|
|
147
|
+
mutation createModelFields($path: String!, $fields: [CreateModelFieldsInput!]!) {
|
|
148
|
+
createModelFields(path: $path, fields: $fields) {
|
|
149
|
+
remoteFilesVersion
|
|
150
|
+
changed {
|
|
151
|
+
path
|
|
152
|
+
mode
|
|
153
|
+
content
|
|
154
|
+
encoding
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
`);u();var Pt=F(_r(),1);u();var wt=N(pt,e=>(e??="",["true","1"].includes(e.trim().toLowerCase())));var P=()=>!rt.testLike&&wt(process.env.CI)?new Date().toISOString():b.gray((0,Pt.default)().format("hh:mm:ss A"));u();u();import Fr from"node:assert";var L=class extends Map{created(){return Array.from(this.entries()).filter(([,t])=>t.type==="create").map(([t])=>t)}updated(){return Array.from(this.entries()).filter(([,t])=>t.type==="update").map(([t])=>t)}deleted(){return Array.from(this.entries()).filter(([,t])=>t.type==="delete").map(([t])=>t)}},G=(e,{from:t,to:n,existing:r,ignore:a})=>{let o=new L,s=Object.keys(n);for(let[i,l]of Object.entries(t)){if(a?.some(c=>i.startsWith(c)))continue;let p=n[i];p?J(i,l,p)||(o.set(i,{type:"update",sourceHash:l,targetHash:p}),e.log.trace("file updated",{path:i,sourceHash:l,targetHash:p})):(!i.endsWith("/")||!s.some(c=>c.startsWith(i)))&&(o.set(i,{type:"delete",sourceHash:l}),e.log.trace("file deleted",{path:i,sourceHash:l}))}for(let i of s)if(!a?.some(l=>i.startsWith(l))&&!t[i]){let l=n[i];Fr(l,"targetHash should exist"),o.set(i,{type:"create",targetHash:l}),e.log.trace("file created",{path:i,targetHash:l})}return r?Rr(e,{changes:o,existing:r}):o},Rr=(e,{changes:t,existing:n})=>{let r=new L;for(let[a,o]of t){let s=n[a];if(o.type==="delete"&&!s){e.log.trace("already deleted",{path:a});continue}if(o.type!=="delete"&&s&&J(a,o.targetHash,s)){e.log.trace("already created or updated",{path:a,existingHash:s,targetHash:o.targetHash});continue}r.set(a,o)}return r},J=(e,t,n)=>t.sha1===n.sha1,Ot=(e,t,n)=>{for(let[r,a]of Object.entries(t)){let o=n[r];if(!o||!J(r,a,o))return e.log.debug("hashes are not equal",{path:r,aHash:a,bHash:o}),!1}for(let r of Object.keys(n))if(!t[r])return e.log.debug("hashes are not equal",{path:r,aHash:void 0,bHash:n[r]}),!1;return!0};var Ie=class extends Map{},Bt=({localChanges:e,environmentChanges:t})=>{let n=new Ie;for(let[r,a]of e){let o=t.get(r);o&&(a.type==="delete"&&o.type==="delete"||"targetHash"in a&&"targetHash"in o&&J(r,a.targetHash,o.targetHash)||n.set(r,{localChange:a,gadgetChange:o}))}for(let r of n.keys())r.startsWith(".gadget/")&&n.delete(r);return n},Ae=({conflicts:e,changes:t})=>{let n=new L(t);for(let[r]of n)e.has(r)&&n.delete(r);return n},Nt=({conflicts:e})=>{let t=b.greenBright("+ created"),n=b.blueBright("\xB1 updated"),r=b.redBright("- deleted");mt({title:"These files have conflicting changes.",ensureEmptyLineAbove:!0,ensureEmptyLineAboveBody:!0,colAligns:["left","center","center"],headers:["","You","Environment"],rows:Array.from(e.entries()).sort((a,o)=>a[0].localeCompare(o[0])).map(([a,{localChange:o,gadgetChange:s}])=>{switch(!0){case(o.type==="create"&&s.type==="create"):return[a,t,t];case(o.type==="create"&&s.type==="update"):return[a,t,n];case(o.type==="create"&&s.type==="delete"):return[a,t,r];case(o.type==="update"&&s.type==="create"):return[a,n,t];case(o.type==="update"&&s.type==="update"):return[a,n,n];case(o.type==="update"&&s.type==="delete"):return[a,n,r];case(o.type==="delete"&&s.type==="create"):return[a,r,t];case(o.type==="delete"&&s.type==="update"):return[a,r,n];default:throw new Error(`Unexpected conflict: ${o.type} vs ${s.type}`)}})})};u();var Ss=Object.freeze({CANCEL:"cancel",MERGE:"merge",PUSH:"push",PULL:"pull"}),O=Object.freeze({CANCEL:m`Cancel (Ctrl+C)`,LOCAL:m`Keep {underline local} conflicting changes`,ENVIRONMENT:m`Keep {underline environment}'s conflicting changes`}),ms=(e,t)=>{if(["local","environment"].includes(e))return O[e.toUpperCase()];if(e==="gadget")return O.ENVIRONMENT;throw new dt(m`
|
|
159
|
+
${t} must be {bold local} or {bold environment}
|
|
160
|
+
|
|
161
|
+
{bold EXAMPLES:}
|
|
162
|
+
${t}=local
|
|
163
|
+
${t}=environment
|
|
164
|
+
`)};u();u();var pr=F(An(),1);import{Buffer as fo}from"node:buffer";import ho from"node:path";import Ke from"node:child_process";import ge from"node:process";u();function Be(e){let t=typeof e=="string"?`
|
|
165
|
+
`:10,n=typeof e=="string"?"\r":13;return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}u();import se from"node:process";import W from"node:path";import{fileURLToPath as _n}from"node:url";u();function oe(e={}){let{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"}var ra=({cwd:e=se.cwd(),path:t=se.env[oe()],preferLocal:n=!0,execPath:r=se.execPath,addExecPath:a=!0}={})=>{let o=e instanceof URL?_n(e):e,s=W.resolve(o),i=[];return n&&aa(i,s),a&&oa(i,r,s),[...i,t].join(W.delimiter)},aa=(e,t)=>{let n;for(;n!==t;)e.push(W.join(t,"node_modules/.bin")),n=t,t=W.resolve(t,"..")},oa=(e,t,n)=>{let r=t instanceof URL?_n(t):t;e.push(W.resolve(n,r,".."))},Cn=({env:e=se.env,...t}={})=>{e={...e};let n=oe({env:e});return t.path=e[n],e[n]=ra(t),e};u();u();var sa=(e,t,n,r)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;let a=Object.getOwnPropertyDescriptor(e,n),o=Object.getOwnPropertyDescriptor(t,n);!ia(a,o)&&r||Object.defineProperty(e,n,o)},ia=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},la=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},ua=(e,t)=>`/* Wrapped ${e}*/
|
|
166
|
+
${t}`,pa=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ca=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),da=(e,t,n)=>{let r=n===""?"":`with ${n.trim()}() `,a=ua.bind(null,r,t.toString());Object.defineProperty(a,"name",ca),Object.defineProperty(e,"toString",{...pa,value:a})};function Ne(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let a of Reflect.ownKeys(t))sa(e,t,a,n);return la(e,t),da(e,t,r),e}var ie=new WeakMap,Tn=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,r=0,a=e.displayName||e.name||"<anonymous>",o=function(...s){if(ie.set(o,++r),r===1)n=e.apply(this,s),e=null;else if(t.throw===!0)throw new Error(`Function \`${a}\` can only be called once`);return n};return Ne(o,e),ie.set(o,r),o};Tn.callCount=e=>{if(!ie.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return ie.get(e)};var vn=Tn;u();import Ma from"node:process";u();import{constants as ga}from"node:os";u();var Fn=()=>{let e=wn-Rn+1;return Array.from({length:e},ya)},ya=(e,t)=>({name:`SIGRT${t+1}`,number:Rn+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Rn=34,wn=64;u();import{constants as Sa}from"node:os";u();var Pn=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var ke=()=>{let e=Fn();return[...Pn,...e].map(ma)},ma=({name:e,number:t,description:n,action:r,forced:a=!1,standard:o})=>{let{signals:{[e]:s}}=Sa,i=s!==void 0;return{name:e,number:i?s:t,description:n,supported:i,action:r,forced:a,standard:o}};var fa=()=>{let e=ke();return Object.fromEntries(e.map(ha))},ha=({name:e,number:t,description:n,supported:r,action:a,forced:o,standard:s})=>[e,{name:e,number:t,description:n,supported:r,action:a,forced:o,standard:s}],On=fa(),ba=()=>{let e=ke(),t=65,n=Array.from({length:t},(r,a)=>Ea(a,e));return Object.assign({},...n)},Ea=(e,t)=>{let n=xa(e,t);if(n===void 0)return{};let{name:r,description:a,supported:o,action:s,forced:i,standard:l}=n;return{[e]:{name:r,number:e,description:a,supported:o,action:s,forced:i,standard:l}}},xa=(e,t)=>{let n=t.find(({name:r})=>ga.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)},fi=ba();var Ia=({timedOut:e,timeout:t,errorCode:n,signal:r,signalDescription:a,exitCode:o,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":n!==void 0?`failed with ${n}`:r!==void 0?`was killed with ${r} (${a})`:o!==void 0?`failed with exit code ${o}`:"failed",q=({stdout:e,stderr:t,all:n,error:r,signal:a,exitCode:o,command:s,escapedCommand:i,timedOut:l,isCanceled:p,killed:c,parsed:{options:{timeout:d,cwd:y=Ma.cwd()}}})=>{o=o===null?void 0:o,a=a===null?void 0:a;let S=a===void 0?void 0:On[a].description,f=r&&r.code,g=`Command ${Ia({timedOut:l,timeout:d,errorCode:f,signal:a,signalDescription:S,exitCode:o,isCanceled:p})}: ${s}`,M=Object.prototype.toString.call(r)==="[object Error]",E=M?`${g}
|
|
167
|
+
${r.message}`:g,_=[E,t,e].filter(Boolean).join(`
|
|
168
|
+
`);return M?(r.originalMessage=r.message,r.message=_):r=new Error(_),r.shortMessage=E,r.command=s,r.escapedCommand=i,r.exitCode=o,r.signal=a,r.signalDescription=S,r.stdout=e,r.stderr=t,r.cwd=y,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!l,r.isCanceled=p,r.killed=c&&!l,r};u();var le=["stdin","stdout","stderr"],Aa=e=>le.some(t=>e[t]!==void 0),Bn=e=>{if(!e)return;let{stdio:t}=e;if(t===void 0)return le.map(r=>e[r]);if(Aa(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${le.map(r=>`\`${r}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);let n=Math.max(t.length,le.length);return Array.from({length:n},(r,a)=>t[a])};u();import _a from"node:os";var Ca=1e3*5,Nn=(e,t="SIGTERM",n={})=>{let r=e(t);return Ta(e,t,n,r),r},Ta=(e,t,n,r)=>{if(!va(t,n,r))return;let a=Ra(n),o=setTimeout(()=>{e("SIGKILL")},a);o.unref&&o.unref()},va=(e,{forceKillAfterTimeout:t},n)=>Fa(e)&&t!==!1&&n,Fa=e=>e===_a.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Ra=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Ca;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},kn=(e,t)=>{e.kill()&&(t.isCanceled=!0)},wa=(e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Ln=(e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let a,o=new Promise((i,l)=>{a=setTimeout(()=>{wa(e,n,l)},t)}),s=r.finally(()=>{clearTimeout(a)});return Promise.race([o,s])},Gn=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},Vn=async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;let a=ct(()=>{e.kill()});return r.finally(()=>{a()})};u();import{createWriteStream as Pa}from"node:fs";import{ChildProcess as Oa}from"node:child_process";u();function ue(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Le(e){return ue(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}var Ba=e=>e instanceof Oa&&typeof e.then=="function",Ge=(e,t,n)=>{if(typeof n=="string")return e[t].pipe(Pa(n)),e;if(Le(n))return e[t].pipe(n),e;if(!Ba(n))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Le(n.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(n.stdin),n},Dn=e=>{e.stdout!==null&&(e.pipeStdout=Ge.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=Ge.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=Ge.bind(void 0,e,"all"))};u();import{createReadStream as Za,readFileSync as eo}from"node:fs";import{setTimeout as to}from"node:timers/promises";u();u();u();var Y=async(e,{init:t,convertChunk:n,getSize:r,truncateChunk:a,addChunk:o,getFinalChunk:s,finalize:i},{maxBuffer:l=Number.POSITIVE_INFINITY}={})=>{if(!ka(e))throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");let p=t();p.length=0;try{for await(let c of e){let d=La(c),y=n[d](c,p);$n({convertedChunk:y,state:p,getSize:r,truncateChunk:a,addChunk:o,maxBuffer:l})}return Na({state:p,convertChunk:n,getSize:r,truncateChunk:a,addChunk:o,getFinalChunk:s,maxBuffer:l}),i(p)}catch(c){throw c.bufferedData=i(p),c}},Na=({state:e,getSize:t,truncateChunk:n,addChunk:r,getFinalChunk:a,maxBuffer:o})=>{let s=a(e);s!==void 0&&$n({convertedChunk:s,state:e,getSize:t,truncateChunk:n,addChunk:r,maxBuffer:o})},$n=({convertedChunk:e,state:t,getSize:n,truncateChunk:r,addChunk:a,maxBuffer:o})=>{let s=n(e),i=t.length+s;if(i<=o){Hn(e,t,a,i);return}let l=r(e,o-t.length);throw l!==void 0&&Hn(l,t,a,o),new pe},Hn=(e,t,n,r)=>{t.contents=n(e,t,r),t.length=r},ka=e=>typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function",La=e=>{let t=typeof e;if(t==="string")return"string";if(t!=="object"||e===null)return"others";if(globalThis.Buffer?.isBuffer(e))return"buffer";let n=Un.call(e);return n==="[object ArrayBuffer]"?"arrayBuffer":n==="[object DataView]"?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&Un.call(e.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:Un}=Object.prototype,pe=class extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}};u();var Ve=e=>e,De=()=>{},He=({contents:e})=>e,ce=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},de=e=>e.length;u();async function Ue(e,t){return Y(e,Ja,t)}var Ga=()=>({contents:new ArrayBuffer(0)}),Va=e=>Da.encode(e),Da=new TextEncoder,Qn=e=>new Uint8Array(e),jn=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Ha=(e,t)=>e.slice(0,t),Ua=(e,{contents:t,length:n},r)=>{let a=qn()?Qa(t,r):$a(t,r);return new Uint8Array(a).set(e,n),a},$a=(e,t)=>{if(t<=e.byteLength)return e;let n=new ArrayBuffer(Wn(t));return new Uint8Array(n).set(new Uint8Array(e),0),n},Qa=(e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let n=new ArrayBuffer(t,{maxByteLength:Wn(t)});return new Uint8Array(n).set(new Uint8Array(e),0),n},Wn=e=>Jn**Math.ceil(Math.log(e)/Math.log(Jn)),Jn=2,ja=({contents:e,length:t})=>qn()?e:e.slice(0,t),qn=()=>"resize"in ArrayBuffer.prototype,Ja={init:Ga,convertChunk:{string:Va,buffer:Qn,arrayBuffer:Qn,dataView:jn,typedArray:jn,others:ce},getSize:de,truncateChunk:Ha,addChunk:Ua,getFinalChunk:De,finalize:ja};u();async function ye(e,t){if(!("Buffer"in globalThis))throw new Error("getStreamAsBuffer() is only supported in Node.js");try{return Yn(await Ue(e,t))}catch(n){throw n.bufferedData!==void 0&&(n.bufferedData=Yn(n.bufferedData)),n}}var Yn=e=>globalThis.Buffer.from(e);u();async function $e(e,t){return Y(e,Ka,t)}var Wa=()=>({contents:"",textDecoder:new TextDecoder}),Se=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),qa=(e,{contents:t})=>t+e,Ya=(e,t)=>e.slice(0,t),za=({textDecoder:e})=>{let t=e.decode();return t===""?void 0:t},Ka={init:Wa,convertChunk:{string:Ve,buffer:Se,arrayBuffer:Se,dataView:Se,typedArray:Se,others:ce},getSize:de,truncateChunk:Ya,addChunk:qa,getFinalChunk:za,finalize:He};var Xn=F(Kn(),1),Zn=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},no=({input:e,inputFile:t})=>typeof t!="string"?e:(Zn(e),eo(t)),er=e=>{let t=no(e);if(ue(t))throw new TypeError("The `input` option cannot be a stream in sync mode");return t},ro=({input:e,inputFile:t})=>typeof t!="string"?e:(Zn(e),Za(t)),tr=(e,t)=>{let n=ro(t);n!==void 0&&(ue(n)?n.pipe(e.stdin):e.stdin.end(n))},nr=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;let n=(0,Xn.default)();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},Qe=async(e,t)=>{if(!(!e||t===void 0)){await to(0),e.destroy();try{return await t}catch(n){return n.bufferedData}}},je=(e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t==="utf8"||t==="utf-8"?$e(e,{maxBuffer:r}):t===null||t==="buffer"?ye(e,{maxBuffer:r}):ao(e,r,t)},ao=async(e,t,n)=>(await ye(e,{maxBuffer:t})).toString(n),rr=async({stdout:e,stderr:t,all:n},{encoding:r,buffer:a,maxBuffer:o},s)=>{let i=je(e,{encoding:r,buffer:a,maxBuffer:o}),l=je(t,{encoding:r,buffer:a,maxBuffer:o}),p=je(n,{encoding:r,buffer:a,maxBuffer:o*2});try{return await Promise.all([s,i,l,p])}catch(c){return Promise.all([{error:c,signal:c.signal,timedOut:c.timedOut},Qe(e,i),Qe(t,l),Qe(n,p)])}};u();var oo=(async()=>{})().constructor.prototype,so=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(oo,e)]),Je=(e,t)=>{for(let[n,r]of so){let a=typeof t=="function"?(...o)=>Reflect.apply(r.value,t(),o):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:a})}},ar=e=>new Promise((t,n)=>{e.on("exit",(r,a)=>{t({exitCode:r,signal:a})}),e.on("error",r=>{n(r)}),e.stdin&&e.stdin.on("error",r=>{n(r)})});u();import{Buffer as io}from"node:buffer";import{ChildProcess as lo}from"node:child_process";var ir=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],uo=/^[\w.-]+$/,po=e=>typeof e!="string"||uo.test(e)?e:`"${e.replaceAll('"','\\"')}"`,We=(e,t)=>ir(e,t).join(" "),qe=(e,t)=>ir(e,t).map(n=>po(n)).join(" "),co=/ +/g;var or=e=>{let t=typeof e;if(t==="string")return e;if(t==="number")return String(e);if(t==="object"&&e!==null&&!(e instanceof lo)&&"stdout"in e){let n=typeof e.stdout;if(n==="string")return e.stdout;if(io.isBuffer(e.stdout))return e.stdout.toString();throw new TypeError(`Unexpected "${n}" stdout in template expression`)}throw new TypeError(`Unexpected "${t}" in template expression`)},sr=(e,t,n)=>n||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],yo=({templates:e,expressions:t,tokens:n,index:r,template:a})=>{let o=a??e.raw[r],s=o.split(co).filter(Boolean),i=sr(n,s,o.startsWith(" "));if(r===t.length)return i;let l=t[r],p=Array.isArray(l)?l.map(c=>or(c)):[or(l)];return sr(i,p,o.endsWith(" "))},Ye=(e,t)=>{let n=[];for(let[r,a]of e.entries())n=yo({templates:e,expressions:t,tokens:n,index:r,template:a});return n};u();import{debuglog as So}from"node:util";import mo from"node:process";var lr=So("execa").enabled,me=(e,t)=>String(e).padStart(t,"0"),go=()=>{let e=new Date;return`${me(e.getHours(),2)}:${me(e.getMinutes(),2)}:${me(e.getSeconds(),2)}.${me(e.getMilliseconds(),3)}`},ze=(e,{verbose:t})=>{t&&mo.stderr.write(`[${go()}] ${e}
|
|
169
|
+
`)};var bo=1e3*1e3*100,Eo=({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:a})=>{let o=t?{...ge.env,...e}:e;return n?Cn({env:o,cwd:r,execPath:a}):o},cr=(e,t,n={})=>{let r=pr.default._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:bo,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||ge.cwd(),execPath:ge.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:lr,...n},n.env=Eo(n),n.stdio=Bn(n),ge.platform==="win32"&&ho.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},z=(e,t,n)=>typeof t!="string"&&!fo.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?Be(t):t;function Xe(e,t,n){let r=cr(e,t,n),a=We(e,t),o=qe(e,t);ze(o,r.options),Gn(r.options);let s;try{s=Ke.spawn(r.file,r.args,r.options)}catch(S){let f=new Ke.ChildProcess,h=Promise.reject(q({error:S,stdout:"",stderr:"",all:"",command:a,escapedCommand:o,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return Je(f,h),f}let i=ar(s),l=Ln(s,r.options,i),p=Vn(s,r.options,l),c={isCanceled:!1};s.kill=Nn.bind(null,s.kill.bind(s)),s.cancel=kn.bind(null,s,c);let y=vn(async()=>{let[{error:S,exitCode:f,signal:h,timedOut:g},M,E,_]=await rr(s,r.options,p),C=z(r.options,M),T=z(r.options,E),X=z(r.options,_);if(S||f!==0||h!==null){let nt=q({error:S,exitCode:f,signal:h,stdout:C,stderr:T,all:X,command:a,escapedCommand:o,parsed:r,timedOut:g,isCanceled:c.isCanceled||(r.options.signal?r.options.signal.aborted:!1),killed:s.killed});if(!r.options.reject)return nt;throw nt}return{command:a,escapedCommand:o,exitCode:0,stdout:C,stderr:T,all:X,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return tr(s,r.options),s.all=nr(s,r.options),Dn(s),Je(s,y),s}function xo(e,t,n){let r=cr(e,t,n),a=We(e,t),o=qe(e,t);ze(o,r.options);let s=er(r.options),i;try{i=Ke.spawnSync(r.file,r.args,{...r.options,input:s})}catch(c){throw q({error:c,stdout:"",stderr:"",all:"",command:a,escapedCommand:o,parsed:r,timedOut:!1,isCanceled:!1,killed:!1})}let l=z(r.options,i.stdout,i.error),p=z(r.options,i.stderr,i.error);if(i.error||i.status!==0||i.signal!==null){let c=q({stdout:l,stderr:p,error:i.error,signal:i.signal,exitCode:i.status,command:a,escapedCommand:o,parsed:r,timedOut:i.error&&i.error.code==="ETIMEDOUT",isCanceled:!1,killed:i.signal!==null});if(!r.options.reject)return c;throw c}return{command:a,escapedCommand:o,exitCode:0,stdout:l,stderr:p,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}}var Mo=({input:e,inputFile:t,stdio:n})=>e===void 0&&t===void 0&&n===void 0?{stdin:"inherit"}:{},ur=(e={})=>({preferLocal:!0,...Mo(e),...e});function dr(e){function t(n,...r){if(!Array.isArray(n))return dr({...e,...n});let[a,...o]=Ye(n,r);return Xe(a,o,ur(e))}return t.sync=(n,...r)=>{if(!Array.isArray(n))throw new TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");let[a,...o]=Ye(n,r);return xo(a,o,ur(e))},t}var jl=dr();var A=F(Ar(),1),Mr=F(Ir(),1);import H from"node:assert";import fe from"node:path";import To from"node:process";u();async function K(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:a}={}){return new Promise((o,s)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(n)&&n>=1||n===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let i=[],l=[],p=new Map,c=!1,d=!1,y=!1,S=0,f=0,h=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),g=E=>{c=!0,d=!0,s(E)};a&&(a.aborted&&g(a.reason),a.addEventListener("abort",()=>{g(a.reason)}));let M=async()=>{if(d)return;let E=await h.next(),_=f;if(f++,E.done){if(y=!0,S===0&&!d){if(!r&&l.length>0){g(new AggregateError(l));return}if(d=!0,p.size===0){o(i);return}let C=[];for(let[T,X]of i.entries())p.get(T)!==yr&&C.push(X);o(C)}return}S++,(async()=>{try{let C=await E.value;if(d)return;let T=await t(C,_);T===yr&&p.set(_,T),i[_]=T,S--,await M()}catch(C){if(r)g(C);else{l.push(C),S--;try{await M()}catch(T){g(T)}}}})()};(async()=>{for(let E=0;E<n;E++){try{await M()}catch(_){g(_);break}if(y||c)break}})()})}var yr=Symbol("skip");u();var Er=F(hr(),1);u();var Ao=Object.prototype.toString,_o=e=>Ao.call(e)==="[object Error]",Co=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Load failed","Network request failed","fetch failed","terminated"]);function Ze(e){return e&&_o(e)&&e.name==="TypeError"&&typeof e.message=="string"?e.message==="Load failed"?e.stack===void 0:Co.has(e.message):!1}var et=class extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}},br=(e,t,n)=>{let r=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e};async function tt(e,t){return new Promise((n,r)=>{t={onFailedAttempt(){},retries:10,shouldRetry:()=>!0,...t};let a=Er.default.operation(t),o=()=>{a.stop(),r(t.signal?.reason)};t.signal&&!t.signal.aborted&&t.signal.addEventListener("abort",o,{once:!0});let s=()=>{t.signal?.removeEventListener("abort",o),a.stop()};a.attempt(async i=>{try{let l=await e(i);s(),n(l)}catch(l){try{if(!(l instanceof Error))throw new TypeError(`Non-error was thrown: "${l}". You should only throw errors.`);if(l instanceof et)throw l.originalError;if(l instanceof TypeError&&!Ze(l))throw l;if(br(l,i,t),await t.shouldRetry(l)||(a.stop(),r(l)),await t.onFailedAttempt(l),!a.retry(l))throw a.mainError()}catch(p){br(p,i,t),s(),r(p)}}})})}var U=F(yt(),1);u();var vo=50*1024*1024,xr=class{constructor(t){this.syncJson=t}_syncOperations=new bt({concurrency:1});async hashes(t,n){let r=n?void 0:$({ensureEmptyLineAbove:!0,content:"Calculating file changes."});try{let[a,{localFilesVersionHashes:o,environmentHashes:s,environmentFilesVersion:i}]=await Promise.all([this.syncJson.directory.hashes(),(async()=>{let h,g,M;if(this.syncJson.filesVersion===0n){let{fileSyncHashes:E}=await this.syncJson.edit.query({query:Ft});M=BigInt(E.filesVersion),g=E.hashes,h={}}else{let{fileSyncComparisonHashes:E}=await this.syncJson.edit.query({query:Rt,variables:{filesVersion:String(this.syncJson.filesVersion)}});h=E.filesVersionHashes.hashes,g=E.latestFilesVersionHashes.hashes,M=BigInt(E.latestFilesVersionHashes.filesVersion)}return{localFilesVersionHashes:h,environmentHashes:g,environmentFilesVersion:M}})()]),l=Ot(t,a,s),p=G(t,{from:o,to:a,existing:s,ignore:[".gadget/"]}),c=G(t,{from:o,to:s,existing:a});!l&&p.size===0&&c.size===0&&(c=G(t,{from:a,to:s}),H(c.size>0,"expected environmentChanges to have changes"),H(Array.from(c.keys()).every(h=>h.startsWith(".gadget/")),"expected all environmentChanges to be .gadget/ files")),H(l||p.size>0||c.size>0,"there must be changes if hashes don't match");let d=G(t,{from:s,to:a,ignore:[".gadget/"]}),y=G(t,{from:a,to:s}),S=y.size>0&&Array.from(y.keys()).every(h=>h.startsWith(".gadget/")),f=p.size>0&&c.size>0&&!S;return r&&(S?r.clear():l?r.succeed(`Your files are up to date. ${P()}`):r.succeed(`Calculated file changes. ${P()}`)),{inSync:l,localFilesVersionHashes:o,localHashes:a,localChanges:p,localChangesToPush:d,environmentHashes:s,environmentChanges:c,environmentChangesToPull:y,environmentFilesVersion:i,onlyDotGadgetFilesChanged:S,bothChanged:f}}catch(a){throw r&&r.fail(),a}}async print(t,{hashes:n}={}){let{inSync:r,localChanges:a,environmentChanges:o,onlyDotGadgetFilesChanged:s,bothChanged:i}=n??await this.hashes(t);r||(a.size>0?re(t,{changes:a,tense:"past",title:m`Your local files {underline have} changed.`}):R({ensureEmptyLineAbove:!0,content:m`Your local files {underline have not} changed.`}),o.size>0&&!s?re(t,{changes:o,tense:"past",title:m`Your environment's files {underline have}${i?" also":""} changed.`}):R({ensureEmptyLineAbove:!0,content:m`Your environment's files {underline have not} changed.`}))}async idle(){await this._syncOperations.onIdle()}async mergeChangesWithEnvironment(t,{changes:n,printLocalChangesOptions:r,printEnvironmentChangesOptions:a}){await this._syncOperations.add(async()=>{try{await this._sendChangesToEnvironment(t,{changes:n,printLocalChangesOptions:r})}catch(o){te(t,o),await this.merge(t,{printEnvironmentChangesOptions:a})}})}subscribeToEnvironmentLogs(t,{onError:n}){let r=Mt(this.syncJson.environment),a=Object.entries(Z).filter(([o,s])=>s>=t["--log-level"]).map(([o])=>o.toLowerCase()).join("|");return this.syncJson.edit.subscribe({subscription:_t,variables:()=>({query:`{environment_id="${this.syncJson.environment.id}"} | json | level=~"${a}"${t["--my-logs"]?' | source="user"':""}`,start:new Date}),onError:n,onData:({logsSearchV2:o})=>{for(let s of o.data.messages){let i=JSON.parse(s[1]),{msg:l,name:p,level:c,...d}=i;r(c,p,l,{...d},new Date(Number(s[0])/1e6))}}})}subscribeToEnvironmentChanges(t,{beforeChanges:n=be,printEnvironmentChangesOptions:r,afterChanges:a=be,onError:o}){return this.syncJson.edit.subscribe({subscription:Ct,variables:()=>({localFilesVersion:String(this.syncJson.filesVersion)}),onError:o,onData:({remoteFileSyncEvents:{changed:s,deleted:i,remoteFilesVersion:l}})=>{this._syncOperations.add(async()=>{if(BigInt(l)<this.syncJson.filesVersion){t.log.warn("skipping received changes because files version is outdated",{filesVersion:l});return}t.log.debug("received files",{remoteFilesVersion:l,changed:s.map(d=>d.path),deleted:i.map(d=>d.path)});let p=d=>{let y=this.syncJson.directory.ignores(d.path);return y&&t.log.warn("skipping received change because file is ignored",{path:d.path}),!y};if(s=s.filter(p),i=i.filter(p),s.length===0&&i.length===0){await this.syncJson.save(l);return}await n({changed:s.map(d=>d.path),deleted:i.map(d=>d.path)});let c=await this.writeToLocalFilesystem(t,{filesVersion:l,files:s,delete:i.map(d=>d.path),printEnvironmentChangesOptions:{tense:"past",ensureEmptyLineAbove:!0,title:k`{greenBright ${w.tick}} Pulled ${(0,U.default)("file",s.length+i.length)}. ${P()}`,limit:5,...r}});await a({changes:c})}).catch(o)}})}async merge(t,{hashes:n,prefer:r,maxAttempts:a=10,printLocalChangesOptions:o,printEnvironmentChangesOptions:s,quietly:i}={}){let l=0;do{if(l===0?n??=await this.hashes(t,i):n=await this.hashes(t,i),n.inSync){this._syncOperations.clear(),t.log.info("filesystem in sync"),await this.syncJson.save(n.environmentFilesVersion);return}l+=1,t.log.info("merging",{attempt:l,...n});try{await this._merge(t,{hashes:n,prefer:r,printLocalChangesOptions:o,printEnvironmentChangesOptions:s})}catch(p){te(t,p)}}while(l<a);throw new ht(a)}async push(t,{command:n,hashes:r,force:a,printLocalChangesOptions:o}){let{localChangesToPush:s,environmentChanges:i,environmentFilesVersion:l,onlyDotGadgetFilesChanged:p}=r??await this.hashes(t);H(s.size>0,"cannot push if there are no changes"),!a&&i.size>0&&!p&&await Me({ensureEmptyLineAbove:!0,content:m`Are you sure you want to {underline discard} your environment's changes?`});try{await this._sendChangesToEnvironment(t,{changes:s,expectedFilesVersion:l,printLocalChangesOptions:o})}catch(c){throw te(t,c),new Ee(m`
|
|
170
|
+
Your environment's files have changed since we last checked.
|
|
171
|
+
|
|
172
|
+
Please re-run "ggt ${n}" to see the changes and try again.
|
|
173
|
+
`)}}async pull(t,{hashes:n,force:r,printEnvironmentChangesOptions:a}={}){let{localChanges:o,environmentChangesToPull:s,environmentFilesVersion:i}=n??await this.hashes(t);H(s.size>0,"cannot push if there are no changes"),o.size>0&&!r&&await Me(m`
|
|
174
|
+
Are you sure you want to {underline discard} your local changes?
|
|
175
|
+
`),await this._getChangesFromEnvironment(t,{changes:s,filesVersion:i,printEnvironmentChangesOptions:a})}async writeToLocalFilesystem(t,n){let r=BigInt(n.filesVersion);H(r>=this.syncJson.filesVersion,"filesVersion must be greater than or equal to current filesVersion"),t.log.debug("writing to local filesystem",{filesVersion:r,files:n.files.map(s=>s.path),delete:n.delete});let a=new ne,o=new Set;await K(n.delete,async s=>{let i=fe.dirname(s);for(;i!==".";)o.add(this.syncJson.directory.normalize(i,!0)),i=fe.dirname(i);let l=this.syncJson.directory.absolute(s),p=this.syncJson.directory.absolute(".gadget/backup",this.syncJson.directory.relative(s));await tt(async()=>{try{await A.default.remove(p),await A.default.move(l,p),a.set(s,{type:"delete"})}catch(c){if(he(c))return;if(it(c)||lt(c)){let d=fe.dirname(p);for(;d!==this.syncJson.directory.absolute(".gadget/backup");)(await A.default.stat(d)).isDirectory()||(t.log.debug("removing file in the way of backup path",{currentPath:l,backupPath:p,file:d}),await A.default.remove(d)),d=fe.dirname(d)}throw c}},{retries:ee.windows?4:2,minTimeout:(0,Mr.default)("100ms"),onFailedAttempt:c=>{t.log.warn("failed to move file to backup",{error:c,currentPath:l,backupPath:p})}})});for(let s of Array.from(o.values()).sort().reverse())if(!n.files.some(i=>i.path===s))try{await A.default.rmdir(this.syncJson.directory.absolute(s)),a.set(s,{type:"delete"})}catch(i){if(he(i)||st(i))continue;throw i}if(await K(n.files,async s=>{let i=this.syncJson.directory.absolute(s.path);await A.default.pathExists(i)?s.path.endsWith("/")||a.set(s.path,{type:"update"}):a.set(s.path,{type:"create"}),s.path.endsWith("/")?await A.default.ensureDir(i):await A.default.outputFile(i,Buffer.from(s.content,s.encoding)),Et&&await A.default.chmod(i,s.mode&511),i===this.syncJson.directory.absolute(".ignore")&&await this.syncJson.directory.loadIgnoreFile()}),await this.syncJson.save(String(r)),n.spinner?.clear(),re(t,{changes:a,tense:"past",title:m`{greenBright ${w.arrowDown}} Pulled ${(0,U.default)("file",a.size)}. ${P()}`,...n.printEnvironmentChangesOptions}),a.has("yarn.lock")){let s=$({ensureEmptyLineAbove:!0,content:'Running "yarn install --check-files"'});try{await Xe("yarn",["install","--check-files"],{cwd:this.syncJson.directory.path}),s.succeed(`Ran "yarn install --check-files" ${P()}`)}catch(i){s.fail(),t.log.error("yarn install failed",{error:i});let l=ut(i).message;l&&R({ensureEmptyLineAbove:!0,indent:2,content:l})}}return a}async _merge(t,{hashes:{localChanges:n,environmentChanges:r,environmentFilesVersion:a},prefer:o,printLocalChangesOptions:s,printEnvironmentChangesOptions:i}){let l=Bt({localChanges:n,environmentChanges:r});if(l.size>0)switch(t.log.debug("conflicts detected",{conflicts:l}),o||(Nt({conflicts:l}),o=await It({choices:Object.values(O),content:b.bold("How should we resolve these conflicts?")})),o){case O.CANCEL:{To.exit(0);break}case O.LOCAL:{r=Ae({conflicts:l,changes:r});break}case O.ENVIRONMENT:{n=Ae({conflicts:l,changes:n});break}}r.size>0&&await this._getChangesFromEnvironment(t,{changes:r,filesVersion:a,printEnvironmentChangesOptions:i}),n.size>0&&await this._sendChangesToEnvironment(t,{changes:n,expectedFilesVersion:a,printLocalChangesOptions:s})}async _getChangesFromEnvironment(t,{filesVersion:n,changes:r,printEnvironmentChangesOptions:a}){t.log.debug("getting changes from gadget",{filesVersion:n,changes:r});let o=r.created(),s=r.updated(),i=$({ensureEmptyLineAbove:!0,content:j(t,{changes:r,tense:"present",title:m`Pulling ${(0,U.default)("file",r.size)}.`,...a})});try{let l=[];if(o.length>0||s.length>0){let{fileSyncFiles:p}=await this.syncJson.edit.query({query:vt,variables:{paths:[...o,...s],filesVersion:String(n),encoding:"base64"}});l=p.files}await this.writeToLocalFilesystem(t,{filesVersion:n,files:l,delete:r.deleted(),spinner:i,printEnvironmentChangesOptions:a})}catch(l){throw i.fail(),l}}async _sendChangesToEnvironment(t,{changes:n,expectedFilesVersion:r=this.syncJson.filesVersion,printLocalChangesOptions:a}){t.log.debug("sending changes to gadget",{expectedFilesVersion:r,changes:n});let o=[],s=[];if(await K(n,async([p,c])=>{if(c.type==="delete"){s.push({path:p});return}let d=this.syncJson.directory.absolute(p),y;try{y=await A.default.stat(d)}catch(h){xt(h),t.log.debug("skipping change because file doesn't exist",{path:p});return}let S="";y.isFile()&&(S=await A.default.readFile(d,"base64"));let f;c.type==="create"&&c.oldPath&&(f=c.oldPath),o.push({content:S,oldPath:f,path:p,mode:y.mode,encoding:"base64"})}),o.length===0&&s.length===0){t.log.debug("skipping send because there are no changes");return}if(o.map(p=>p.content.length).reduce((p,c)=>p+c,0)>vo)throw new Ee(m`
|
|
176
|
+
{underline Your file changes are too large to push.}
|
|
177
|
+
|
|
178
|
+
Run "ggt status" to see your changes and consider
|
|
179
|
+
ignoring some files or pushing in smaller batches.
|
|
180
|
+
`);let l=$({ensureEmptyLineAbove:!0,content:j(t,{changes:n,tense:"present",title:k`Pushing ${(0,U.default)("file",o.length+s.length)}. ${w.arrowRight}`,...a})});try{let{publishFileSyncEvents:{remoteFilesVersion:p,problems:c}}=await this.syncJson.edit.mutate({mutation:Tt,variables:{input:{expectedRemoteFilesVersion:String(r),changed:o,deleted:s}},http:{retry:{methods:["POST"],calculateDelay:({error:d,computedValue:y})=>xe(d.response?.body)?0:y}}});if(BigInt(p)>r+1n)throw new Error("Files version mismatch");await this.syncJson.save(p),l.succeed(j(t,{changes:n,tense:"past",title:k`Pushed ${(0,U.default)("file",o.length+s.length)}. ${w.arrowRight} ${P()}`,...a})),c.length>0&&R({ensureEmptyLineAbove:!0,content:m`
|
|
181
|
+
{red Gadget has detected the following fatal errors with your files:}
|
|
182
|
+
|
|
183
|
+
${gt({problems:ft(c),showFileTypes:!1,indent:12})}
|
|
184
|
+
|
|
185
|
+
{red Your app will not be operational until all fatal errors are fixed.}
|
|
186
|
+
`})}catch(p){throw xe(p)?l.clear():l.fail(),p}}};export{ne as a,Tr as b,vr as c,en as d,Uo as e,$o as f,Qo as g,jo as h,Jo as i,P as j,Bt as k,Nt as l,Ss as m,ms as n,xr as o};
|
|
187
|
+
//# sourceMappingURL=chunk-6BXHYE2C.js.map
|