@gadgetinc/ggt 1.0.6 → 1.1.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/add-RDTHYTCK.js +78 -0
- package/dist/add-RDTHYTCK.js.map +7 -0
- package/dist/chunk-3Q3GPB6Z.js +2 -0
- package/dist/chunk-3Q3GPB6Z.js.map +7 -0
- package/dist/chunk-457GEPUN.js +9 -0
- package/dist/chunk-457GEPUN.js.map +7 -0
- package/dist/{chunk-ERYUXLYS.js → chunk-5ONACLO6.js} +8 -8
- package/dist/{chunk-ERYUXLYS.js.map → chunk-5ONACLO6.js.map} +3 -3
- package/dist/chunk-CQLM5U6T.js +67 -0
- package/dist/chunk-CQLM5U6T.js.map +7 -0
- package/dist/chunk-FLXIAZND.js +12 -0
- package/dist/chunk-FLXIAZND.js.map +7 -0
- package/dist/chunk-JKDJXJKF.js +8 -0
- package/dist/{chunk-APHXRHNI.js.map → chunk-JKDJXJKF.js.map} +3 -3
- package/dist/chunk-LWW4E6P5.js +173 -0
- package/dist/chunk-LWW4E6P5.js.map +7 -0
- package/dist/chunk-M2OJZLL7.js +18 -0
- package/dist/chunk-M2OJZLL7.js.map +7 -0
- package/dist/{chunk-Q5N5L6H3.js → chunk-M4PNFOA5.js} +2 -2
- package/dist/chunk-M4PNFOA5.js.map +7 -0
- package/dist/chunk-NGTOMLDS.js +33 -0
- package/dist/{chunk-BOQUW6DS.js.map → chunk-NGTOMLDS.js.map} +3 -3
- package/dist/chunk-RYQWS5BH.js +117 -0
- package/dist/chunk-RYQWS5BH.js.map +7 -0
- package/dist/{chunk-GACF5GYF.js → chunk-TRHAPK2F.js} +4 -6
- package/dist/{chunk-GACF5GYF.js.map → chunk-TRHAPK2F.js.map} +2 -2
- package/dist/chunk-VICN6LTV.js +12 -0
- package/dist/chunk-VICN6LTV.js.map +7 -0
- package/dist/context-GN36UFJL.js +2 -0
- package/dist/deploy-BAMMI3ZA.js +24 -0
- package/dist/deploy-BAMMI3ZA.js.map +7 -0
- package/dist/{dev-VHJ52BEA.js → dev-5UFCKF4X.js} +9 -11
- package/dist/{dev-VHJ52BEA.js.map → dev-5UFCKF4X.js.map} +3 -3
- package/dist/esm-GJ7RK6IC.js +34 -0
- package/dist/esm-GJ7RK6IC.js.map +7 -0
- package/dist/list-WGRXHV2B.js +11 -0
- package/dist/list-WGRXHV2B.js.map +7 -0
- package/dist/login-5YZOB4XB.js +2 -0
- package/dist/logout-YXDH5ZZI.js +7 -0
- package/dist/{logout-HX6MM4S6.js.map → logout-YXDH5ZZI.js.map} +3 -3
- package/dist/main.js +6 -8
- package/dist/main.js.map +3 -3
- package/dist/{open-GEEWPSF4.js → open-EOH3Q5KP.js} +3 -3
- package/dist/{open-GEEWPSF4.js.map → open-EOH3Q5KP.js.map} +2 -2
- package/dist/{pull-T2Q4M4UN.js → pull-UAKKKJJP.js} +3 -5
- package/dist/{pull-T2Q4M4UN.js.map → pull-UAKKKJJP.js.map} +2 -2
- package/dist/push-7X4P2364.js +2 -0
- package/dist/push-7X4P2364.js.map +7 -0
- package/dist/status-UJUGP24U.js +14 -0
- package/dist/{status-5VZH3KXH.js.map → status-UJUGP24U.js.map} +1 -1
- package/dist/user-B2RIDVTH.js +2 -0
- package/dist/user-B2RIDVTH.js.map +7 -0
- package/dist/{version-OF4TQ2K6.js → version-VE55GG37.js} +2 -2
- package/dist/whoami-OAH55L4M.js +7 -0
- package/dist/{whoami-V3XD27QH.js.map → whoami-OAH55L4M.js.map} +2 -2
- package/package.json +20 -20
- package/dist/add-JIIVAOWH.js +0 -84
- package/dist/add-JIIVAOWH.js.map +0 -7
- package/dist/chunk-APHXRHNI.js +0 -8
- package/dist/chunk-AQRCAWW4.js +0 -24
- package/dist/chunk-AQRCAWW4.js.map +0 -7
- package/dist/chunk-BOQUW6DS.js +0 -33
- package/dist/chunk-CKSTMUDN.js +0 -17
- package/dist/chunk-CKSTMUDN.js.map +0 -7
- package/dist/chunk-GBCD37US.js +0 -57
- package/dist/chunk-GBCD37US.js.map +0 -7
- package/dist/chunk-P2XPMNL6.js +0 -183
- package/dist/chunk-P2XPMNL6.js.map +0 -7
- package/dist/chunk-PSRZ5JH5.js +0 -27
- package/dist/chunk-PSRZ5JH5.js.map +0 -7
- package/dist/chunk-Q5N5L6H3.js.map +0 -7
- package/dist/chunk-RJOIQTYZ.js +0 -126
- package/dist/chunk-RJOIQTYZ.js.map +0 -7
- package/dist/chunk-XCHCCJJZ.js +0 -2
- package/dist/chunk-XCHCCJJZ.js.map +0 -7
- package/dist/deploy-KMGAGIDE.js +0 -30
- package/dist/deploy-KMGAGIDE.js.map +0 -7
- package/dist/esm-BL3OM5UJ.js +0 -33
- package/dist/esm-BL3OM5UJ.js.map +0 -7
- package/dist/list-5E3R22IC.js +0 -11
- package/dist/list-5E3R22IC.js.map +0 -7
- package/dist/login-3DL45WY7.js +0 -2
- package/dist/logout-HX6MM4S6.js +0 -7
- package/dist/push-LUW25FYF.js +0 -2
- package/dist/status-5VZH3KXH.js +0 -14
- package/dist/whoami-V3XD27QH.js +0 -7
- /package/dist/{login-3DL45WY7.js.map → context-GN36UFJL.js.map} +0 -0
- /package/dist/{push-LUW25FYF.js.map → login-5YZOB4XB.js.map} +0 -0
- /package/dist/{version-OF4TQ2K6.js.map → version-VE55GG37.js.map} +0 -0
package/dist/chunk-P2XPMNL6.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import{b as gt,e as mt,h as ft,j as Ee,k as ee,l as At}from"./chunk-RJOIQTYZ.js";import{a as yt,b as dt}from"./chunk-ERYUXLYS.js";import{a as nt,c as ht}from"./chunk-BOQUW6DS.js";import{b as $}from"./chunk-APHXRHNI.js";import{c as xe}from"./chunk-PSRZ5JH5.js";import{g as be,i as bt}from"./chunk-CKSTMUDN.js";import{a as xr,b as Ar,c as w,k as St,p as Et,q as xt}from"./chunk-AQRCAWW4.js";import{A as he,B as ut,E as Mr,H as pt,I as Z,L as ct,U as m,V as N,W as R,b,g as rt,n as at,p as fe,q as ot,r as st,s as it,w as lt,x as k}from"./chunk-GBCD37US.js";import{a as v,c as x,e as F,g as l}from"./chunk-5WC5D4WL.js";var Lt=x((ms,Gt)=>{l();Gt.exports=Nt;Nt.sync=Rr;var Bt=v("fs");function Fr(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 kt(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:Fr(t,n)}function Nt(e,t,n){Bt.stat(e,function(r,a){n(r,r?!1:kt(a,e,t))})}function Rr(e,t){return kt(Bt.statSync(e),e,t)}});var $t=x((hs,Ut)=>{l();Ut.exports=Dt;Dt.sync=wr;var Vt=v("fs");function Dt(e,t,n){Vt.stat(e,function(r,a){n(r,r?!1:Ht(a,t))})}function wr(e,t){return Ht(Vt.statSync(e),t)}function Ht(e,t){return e.isFile()&&Pr(e,t)}function Pr(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),u=parseInt("010",8),p=parseInt("001",8),c=i|u,y=n&p||n&u&&a===s||n&i&&r===o||n&c&&o===0;return y}});var jt=x((xs,Qt)=>{l();var Es=v("fs"),re;process.platform==="win32"||global.TESTING_WINDOWS?re=Lt():re=$t();Qt.exports=Ie;Ie.sync=Or;function Ie(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){Ie(e,t||{},function(o,s){o?a(o):r(s)})})}re(e,t||{},function(r,a){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,a=!1),n(r,a)})}function Or(e,t){try{return re.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}});var Xt=x((Ms,Kt)=>{l();var V=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Jt=v("path"),Br=V?";":":",Wt=jt(),qt=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Yt=(e,t)=>{let n=t.colon||Br,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}},zt=(e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});let{pathEnv:r,pathExt:a,pathExtExe:o}=Yt(e,t),s=[],i=p=>new Promise((c,y)=>{if(p===r.length)return t.all&&s.length?c(s):y(qt(e));let d=r[p],S=/^".*"$/.test(d)?d.slice(1,-1):d,f=Jt.join(S,e),h=!S&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;c(u(h,p,0))}),u=(p,c,y)=>new Promise((d,S)=>{if(y===a.length)return d(i(c+1));let f=a[y];Wt(p+f,{pathExt:o},(h,g)=>{if(!h&&g)if(t.all)s.push(p+f);else return d(p+f);return d(u(p,c,y+1))})});return n?i(0).then(p=>n(null,p),n):i(0)},kr=(e,t)=>{t=t||{};let{pathEnv:n,pathExt:r,pathExtExe:a}=Yt(e,t),o=[];for(let s=0;s<n.length;s++){let i=n[s],u=/^".*"$/.test(i)?i.slice(1,-1):i,p=Jt.join(u,e),c=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+p:p;for(let y=0;y<r.length;y++){let d=c+r[y];try{if(Wt.sync(d,{pathExt:a}))if(t.all)o.push(d);else return d}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw qt(e)};Kt.exports=zt;zt.sync=kr});var en=x((Cs,Ce)=>{"use strict";l();var Zt=(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=Zt;Ce.exports.default=Zt});var an=x((Ts,rn)=>{"use strict";l();var tn=v("path"),Nr=Xt(),Gr=en();function nn(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=Nr.sync(e.command,{path:n[Gr({env:n})],pathExt:t?tn.delimiter:void 0})}catch{}finally{o&&process.chdir(r)}return s&&(s=tn.resolve(a?e.options.cwd:"",s)),s}function Lr(e){return nn(e)||nn(e,!0)}rn.exports=Lr});var on=x((Fs,Te)=>{"use strict";l();var _e=/([()\][%!^"`<>&|;, *?])/g;function Vr(e){return e=e.replace(_e,"^$1"),e}function Dr(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(_e,"^$1"),t&&(e=e.replace(_e,"^$1")),e}Te.exports.command=Vr;Te.exports.argument=Dr});var ln=x((ws,sn)=>{"use strict";l();sn.exports=/^#!(.*)/});var pn=x((Os,un)=>{"use strict";l();var Hr=ln();un.exports=(e="")=>{let t=e.match(Hr);if(!t)return null;let[n,r]=t[0].replace(/#! ?/,"").split(" "),a=n.split("/").pop();return a==="env"?r:r?`${a} ${r}`:a}});var yn=x((ks,cn)=>{"use strict";l();var ve=v("fs"),Ur=pn();function $r(e){let n=Buffer.alloc(150),r;try{r=ve.openSync(e,"r"),ve.readSync(r,n,0,150,0),ve.closeSync(r)}catch{}return Ur(n.toString())}cn.exports=$r});var mn=x((Gs,gn)=>{"use strict";l();var Qr=v("path"),dn=an(),Sn=on(),jr=yn(),Jr=process.platform==="win32",Wr=/\.(?:com|exe)$/i,qr=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Yr(e){e.file=dn(e);let t=e.file&&jr(e.file);return t?(e.args.unshift(e.file),e.command=t,dn(e)):e.file}function zr(e){if(!Jr)return e;let t=Yr(e),n=!Wr.test(t);if(e.options.forceShell||n){let r=qr.test(t);e.command=Qr.normalize(e.command),e.command=Sn.command(e.command),e.args=e.args.map(o=>Sn.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 Kr(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:zr(r)}gn.exports=Kr});var bn=x((Vs,hn)=>{"use strict";l();var Fe=process.platform==="win32";function Re(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 Xr(e,t){if(!Fe)return;let n=e.emit;e.emit=function(r,a){if(r==="exit"){let o=fn(a,t,"spawn");if(o)return n.call(e,"error",o)}return n.apply(e,arguments)}}function fn(e,t){return Fe&&e===1&&!t.file?Re(t.original,"spawn"):null}function Zr(e,t){return Fe&&e===1&&!t.file?Re(t.original,"spawnSync"):null}hn.exports={hookChildProcess:Xr,verifyENOENT:fn,verifyENOENTSync:Zr,notFoundError:Re}});var An=x((Hs,D)=>{"use strict";l();var En=v("child_process"),we=mn(),Pe=bn();function xn(e,t,n){let r=we(e,t,n),a=En.spawn(r.command,r.args,r.options);return Pe.hookChildProcess(a,r),a}function ea(e,t,n){let r=we(e,t,n),a=En.spawnSync(r.command,r.args,r.options);return a.error=a.error||Pe.verifyENOENTSync(a.status,r),a}D.exports=xn;D.exports.spawn=xn;D.exports.sync=ea;D.exports._parse=we;D.exports._enoent=Pe});var Yn=x((ll,qn)=>{"use strict";l();var{PassThrough:za}=v("stream");qn.exports=function(){var e=[],t=new za({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 dr=x((ql,yr)=>{l();function M(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))}yr.exports=M;M.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};M.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};M.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};M.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)};M.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};M.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};M.prototype.start=M.prototype.try;M.prototype.errors=function(){return this._errors};M.prototype.attempts=function(){return this._attempts};M.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 Sr=x(B=>{l();var xo=dr();B.operation=function(e){var t=B.timeouts(e);return new xo(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(u){var p=B.operation(t),c=Array.prototype.slice.call(arguments,1),y=c.pop();c.push(function(d){p.retry(d)||(d&&(arguments[0]=p.mainError()),y.apply(this,arguments))}),p.attempt(function(){u.apply(e,c)})}.bind(e,s),e[o].options=t}}});var mr=x((Xl,gr)=>{l();gr.exports=Sr()});l();var Q=F(nt(),1);var te=class extends Map{created=k(()=>Array.from(this.entries()).filter(([,t])=>t.type==="create").map(([t])=>t));updated=k(()=>Array.from(this.entries()).filter(([,t])=>t.type==="update").map(([t])=>t));deleted=k(()=>Array.from(this.entries()).filter(([,t])=>t.type==="delete").map(([t])=>t))},Ir=b.greenBright("+"),Cr=b.blueBright("\xB1"),_r=b.redBright("-"),Mt=b.yellowBright("\u2192"),j=(e,{changes:t,tense:n,limit:r=1/0,...a})=>{Z.logLevel<=ut.TRACE&&(r=1/0);let o=Array.from(t.entries()).filter(([d])=>!d.startsWith(".gadget/"));if(o.length===0)return"";let s=b.yellowBright(n==="past"?"renamed":"rename"),i=b.greenBright(n==="past"?"created":"create"),u=b.blueBright(n==="past"?"updated":"update"),p=b.redBright(n==="past"?"deleted":"delete"),c=o.sort((d,S)=>d[0].localeCompare(S[0])).slice(0,r).map(([d,S])=>{switch(!0){case(S.type==="create"&&rt(S.oldPath)):return[Mt,b.yellowBright(S.oldPath),s,Mt,b.yellowBright(d)];case S.type==="create":return[Ir,b.greenBright(d),i];case S.type==="update":return[Cr,b.blueBright(d),u];case S.type==="delete":return[_r,b.redBright(d),p];default:return at(S)}});o.length>r&&c.push([b.gray(w.ellipsis),m`{gray ${o.length-r} more}`,""]);let y;if(o.length>=5){let d=[],S=o.filter(([,g])=>g.type==="create").length;if(S>0){let g=n==="past"?`${S} created`:(0,Q.default)("create",S,!0);d.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);d.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);d.push(m`{redBright ${g}}`)}y=N`
|
|
2
|
-
${(0,Q.default)("change",o.length,!0)} in total. ${d.join(", ")}.
|
|
3
|
-
`}return yt({rows:c,footer:y,ensureEmptyLineAbove:!0,ensureEmptyLineAboveBody:!1,ensureEmptyLineAboveFooter:!0,indent:0,...a})},ne=(e,t)=>{let n=j(e,t);n&&R(n)};l();var It=m(`
|
|
4
|
-
subscription RemoteFileSyncEvents($localFilesVersion: String!) {
|
|
5
|
-
remoteFileSyncEvents(localFilesVersion: $localFilesVersion, encoding: base64) {
|
|
6
|
-
remoteFilesVersion
|
|
7
|
-
changed {
|
|
8
|
-
path
|
|
9
|
-
mode
|
|
10
|
-
content
|
|
11
|
-
encoding
|
|
12
|
-
}
|
|
13
|
-
deleted {
|
|
14
|
-
path
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
`),Vo=m(`
|
|
19
|
-
query RemoteFilesVersion {
|
|
20
|
-
remoteFilesVersion
|
|
21
|
-
}
|
|
22
|
-
`),Ct=m(`
|
|
23
|
-
mutation PublishFileSyncEvents($input: PublishFileSyncEventsInput!) {
|
|
24
|
-
publishFileSyncEvents(input: $input) {
|
|
25
|
-
remoteFilesVersion
|
|
26
|
-
problems {
|
|
27
|
-
level
|
|
28
|
-
message
|
|
29
|
-
path
|
|
30
|
-
type
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
`),_t=m(`
|
|
35
|
-
query FileSyncFiles($paths: [String!]!, $filesVersion: String, $encoding: FileSyncEncoding) {
|
|
36
|
-
fileSyncFiles(paths: $paths, filesVersion: $filesVersion, encoding: $encoding) {
|
|
37
|
-
filesVersion
|
|
38
|
-
files {
|
|
39
|
-
path
|
|
40
|
-
mode
|
|
41
|
-
content
|
|
42
|
-
encoding
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
`),Tt=m(`
|
|
47
|
-
query FileSyncHashes($filesVersion: String) {
|
|
48
|
-
fileSyncHashes(filesVersion: $filesVersion) {
|
|
49
|
-
filesVersion
|
|
50
|
-
hashes
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
`),vt=m(`
|
|
54
|
-
query FileSyncComparisonHashes($filesVersion: String!) {
|
|
55
|
-
fileSyncComparisonHashes(filesVersion: $filesVersion) {
|
|
56
|
-
filesVersionHashes {
|
|
57
|
-
filesVersion
|
|
58
|
-
hashes
|
|
59
|
-
}
|
|
60
|
-
latestFilesVersionHashes {
|
|
61
|
-
filesVersion
|
|
62
|
-
hashes
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
`),Do=m(`
|
|
67
|
-
subscription PublishStatus($localFilesVersion: String!, $force: Boolean, $allowCharges: Boolean) {
|
|
68
|
-
publishStatus(localFilesVersion: $localFilesVersion, force: $force, allowCharges: $allowCharges) {
|
|
69
|
-
publishStarted
|
|
70
|
-
remoteFilesVersion
|
|
71
|
-
progress
|
|
72
|
-
issues {
|
|
73
|
-
severity
|
|
74
|
-
message
|
|
75
|
-
node {
|
|
76
|
-
type
|
|
77
|
-
key
|
|
78
|
-
apiIdentifier
|
|
79
|
-
name
|
|
80
|
-
fieldType
|
|
81
|
-
parentKey
|
|
82
|
-
parentApiIdentifier
|
|
83
|
-
}
|
|
84
|
-
nodeLabels {
|
|
85
|
-
type
|
|
86
|
-
identifier
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
status {
|
|
90
|
-
code
|
|
91
|
-
message
|
|
92
|
-
output
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
`),Ho=m(`
|
|
97
|
-
mutation createModel($path: String!, $fields: [CreateModelFieldsInput!]) {
|
|
98
|
-
createModel(path: $path, fields: $fields) {
|
|
99
|
-
remoteFilesVersion
|
|
100
|
-
changed {
|
|
101
|
-
path
|
|
102
|
-
mode
|
|
103
|
-
content
|
|
104
|
-
encoding
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
`),Uo=m(`
|
|
109
|
-
mutation createAction($path: String!) {
|
|
110
|
-
createAction(path: $path) {
|
|
111
|
-
remoteFilesVersion
|
|
112
|
-
changed {
|
|
113
|
-
path
|
|
114
|
-
mode
|
|
115
|
-
content
|
|
116
|
-
encoding
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
`),$o=m(`
|
|
121
|
-
mutation createRoute($method: String!, $path: String!) {
|
|
122
|
-
createRoute(method: $method, path: $path) {
|
|
123
|
-
remoteFilesVersion
|
|
124
|
-
changed {
|
|
125
|
-
path
|
|
126
|
-
mode
|
|
127
|
-
content
|
|
128
|
-
encoding
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
`),Qo=m(`
|
|
133
|
-
mutation createModelFields($path: String!, $fields: [CreateModelFieldsInput!]!) {
|
|
134
|
-
createModelFields(path: $path, fields: $fields) {
|
|
135
|
-
remoteFilesVersion
|
|
136
|
-
changed {
|
|
137
|
-
path
|
|
138
|
-
mode
|
|
139
|
-
content
|
|
140
|
-
encoding
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
`);l();var Rt=F(Ar(),1);l();var Ft=k(lt,e=>(e??="",["true","1"].includes(e.trim().toLowerCase())));var P=()=>!pt.testLike&&Ft(process.env.CI)?new Date().toISOString():b.gray((0,Rt.default)().format("hh:mm:ss A"));l();l();import Tr from"node:assert";var G=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)}},L=(e,{from:t,to:n,existing:r,ignore:a})=>{let o=new G,s=Object.keys(n);for(let[i,u]of Object.entries(t)){if(a?.some(c=>i.startsWith(c)))continue;let p=n[i];p?J(i,u,p)||(o.set(i,{type:"update",sourceHash:u,targetHash:p}),e.log.trace("file updated",{path:i,sourceHash:u,targetHash:p})):(!i.endsWith("/")||!s.some(c=>c.startsWith(i)))&&(o.set(i,{type:"delete",sourceHash:u}),e.log.trace("file deleted",{path:i,sourceHash:u}))}for(let i of s)if(!a?.some(u=>i.startsWith(u))&&!t[i]){let u=n[i];Tr(u,"targetHash should exist"),o.set(i,{type:"create",targetHash:u}),e.log.trace("file created",{path:i,targetHash:u})}return r?vr(e,{changes:o,existing:r}):o},vr=(e,{changes:t,existing:n})=>{let r=new G;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,wt=(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 Ae=class extends Map{},Pt=({localChanges:e,environmentChanges:t})=>{let n=new Ae;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},Me=({conflicts:e,changes:t})=>{let n=new G(t);for(let[r]of n)e.has(r)&&n.delete(r);return n},Ot=({conflicts:e})=>{let t=b.greenBright("+ created"),n=b.blueBright("\xB1 updated"),r=b.redBright("- deleted");dt({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}`)}})})};l();var ys=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`}),ds=(e,t)=>{if(["local","environment"].includes(e))return O[e.toUpperCase()];if(e==="gadget")return O.ENVIRONMENT;throw new bt(m`
|
|
145
|
-
${t} must be {bold local} or {bold environment}
|
|
146
|
-
|
|
147
|
-
{bold EXAMPLES:}
|
|
148
|
-
${t}=local
|
|
149
|
-
${t}=environment
|
|
150
|
-
`)};l();l();var lr=F(An(),1);import{Buffer as go}from"node:buffer";import mo from"node:path";import ze from"node:child_process";import ge from"node:process";l();function Oe(e){let t=typeof e=="string"?`
|
|
151
|
-
`: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}l();import oe from"node:process";import W from"node:path";import{fileURLToPath as Mn}from"node:url";l();function ae(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 ta=({cwd:e=oe.cwd(),path:t=oe.env[ae()],preferLocal:n=!0,execPath:r=oe.execPath,addExecPath:a=!0}={})=>{let o=e instanceof URL?Mn(e):e,s=W.resolve(o),i=[];return n&&na(i,s),a&&ra(i,r,s),[...i,t].join(W.delimiter)},na=(e,t)=>{let n;for(;n!==t;)e.push(W.join(t,"node_modules/.bin")),n=t,t=W.resolve(t,"..")},ra=(e,t,n)=>{let r=t instanceof URL?Mn(t):t;e.push(W.resolve(n,r,".."))},In=({env:e=oe.env,...t}={})=>{e={...e};let n=ae({env:e});return t.path=e[n],e[n]=ta(t),e};l();l();var aa=(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);!oa(a,o)&&r||Object.defineProperty(e,n,o)},oa=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)},sa=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},ia=(e,t)=>`/* Wrapped ${e}*/
|
|
152
|
-
${t}`,la=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ua=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),pa=(e,t,n)=>{let r=n===""?"":`with ${n.trim()}() `,a=ia.bind(null,r,t.toString());Object.defineProperty(a,"name",ua),Object.defineProperty(e,"toString",{...la,value:a})};function Be(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let a of Reflect.ownKeys(t))aa(e,t,a,n);return sa(e,t),pa(e,t,r),e}var se=new WeakMap,Cn=(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(se.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 Be(o,e),se.set(o,r),o};Cn.callCount=e=>{if(!se.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return se.get(e)};var _n=Cn;l();import Ea from"node:process";l();import{constants as Sa}from"node:os";l();var Tn=()=>{let e=Fn-vn+1;return Array.from({length:e},ca)},ca=(e,t)=>({name:`SIGRT${t+1}`,number:vn+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),vn=34,Fn=64;l();import{constants as ya}from"node:os";l();var Rn=[{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=Tn();return[...Rn,...e].map(da)},da=({name:e,number:t,description:n,action:r,forced:a=!1,standard:o})=>{let{signals:{[e]:s}}=ya,i=s!==void 0;return{name:e,number:i?s:t,description:n,supported:i,action:r,forced:a,standard:o}};var ga=()=>{let e=ke();return Object.fromEntries(e.map(ma))},ma=({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}],wn=ga(),fa=()=>{let e=ke(),t=65,n=Array.from({length:t},(r,a)=>ha(a,e));return Object.assign({},...n)},ha=(e,t)=>{let n=ba(e,t);if(n===void 0)return{};let{name:r,description:a,supported:o,action:s,forced:i,standard:u}=n;return{[e]:{name:r,number:e,description:a,supported:o,action:s,forced:i,standard:u}}},ba=(e,t)=>{let n=t.find(({name:r})=>Sa.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)},gi=fa();var xa=({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:u,isCanceled:p,killed:c,parsed:{options:{timeout:y,cwd:d=Ea.cwd()}}})=>{o=o===null?void 0:o,a=a===null?void 0:a;let S=a===void 0?void 0:wn[a].description,f=r&&r.code,g=`Command ${xa({timedOut:u,timeout:y,errorCode:f,signal:a,signalDescription:S,exitCode:o,isCanceled:p})}: ${s}`,A=Object.prototype.toString.call(r)==="[object Error]",E=A?`${g}
|
|
153
|
-
${r.message}`:g,C=[E,t,e].filter(Boolean).join(`
|
|
154
|
-
`);return A?(r.originalMessage=r.message,r.message=C):r=new Error(C),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=d,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!u,r.isCanceled=p,r.killed=c&&!u,r};l();var ie=["stdin","stdout","stderr"],Aa=e=>ie.some(t=>e[t]!==void 0),Pn=e=>{if(!e)return;let{stdio:t}=e;if(t===void 0)return ie.map(r=>e[r]);if(Aa(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${ie.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,ie.length);return Array.from({length:n},(r,a)=>t[a])};l();import Ma from"node:os";var Ia=1e3*5,On=(e,t="SIGTERM",n={})=>{let r=e(t);return Ca(e,t,n,r),r},Ca=(e,t,n,r)=>{if(!_a(t,n,r))return;let a=va(n),o=setTimeout(()=>{e("SIGKILL")},a);o.unref&&o.unref()},_a=(e,{forceKillAfterTimeout:t},n)=>Ta(e)&&t!==!1&&n,Ta=e=>e===Ma.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",va=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Ia;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},Bn=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Fa=(e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},kn=(e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let a,o=new Promise((i,u)=>{a=setTimeout(()=>{Fa(e,n,u)},t)}),s=r.finally(()=>{clearTimeout(a)});return Promise.race([o,s])},Nn=({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})`)},Gn=async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;let a=ct(()=>{e.kill()});return r.finally(()=>{a()})};l();import{createWriteStream as Ra}from"node:fs";import{ChildProcess as wa}from"node:child_process";l();function le(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Ne(e){return le(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}var Pa=e=>e instanceof wa&&typeof e.then=="function",Ge=(e,t,n)=>{if(typeof n=="string")return e[t].pipe(Ra(n)),e;if(Ne(n))return e[t].pipe(n),e;if(!Pa(n))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Ne(n.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(n.stdin),n},Ln=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"))};l();import{createReadStream as Ka,readFileSync as Xa}from"node:fs";import{setTimeout as Za}from"node:timers/promises";l();l();l();var Y=async(e,{init:t,convertChunk:n,getSize:r,truncateChunk:a,addChunk:o,getFinalChunk:s,finalize:i},{maxBuffer:u=Number.POSITIVE_INFINITY}={})=>{if(!Ba(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 y=ka(c),d=n[y](c,p);Hn({convertedChunk:d,state:p,getSize:r,truncateChunk:a,addChunk:o,maxBuffer:u})}return Oa({state:p,convertChunk:n,getSize:r,truncateChunk:a,addChunk:o,getFinalChunk:s,maxBuffer:u}),i(p)}catch(c){throw c.bufferedData=i(p),c}},Oa=({state:e,getSize:t,truncateChunk:n,addChunk:r,getFinalChunk:a,maxBuffer:o})=>{let s=a(e);s!==void 0&&Hn({convertedChunk:s,state:e,getSize:t,truncateChunk:n,addChunk:r,maxBuffer:o})},Hn=({convertedChunk:e,state:t,getSize:n,truncateChunk:r,addChunk:a,maxBuffer:o})=>{let s=n(e),i=t.length+s;if(i<=o){Vn(e,t,a,i);return}let u=r(e,o-t.length);throw u!==void 0&&Vn(u,t,a,o),new ue},Vn=(e,t,n,r)=>{t.contents=n(e,t,r),t.length=r},Ba=e=>typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function",ka=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=Dn.call(e);return n==="[object ArrayBuffer]"?"arrayBuffer":n==="[object DataView]"?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&Dn.call(e.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:Dn}=Object.prototype,ue=class extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}};l();var Le=e=>e,Ve=()=>{},De=({contents:e})=>e,pe=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},ce=e=>e.length;l();async function He(e,t){return Y(e,Qa,t)}var Na=()=>({contents:new ArrayBuffer(0)}),Ga=e=>La.encode(e),La=new TextEncoder,Un=e=>new Uint8Array(e),$n=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Va=(e,t)=>e.slice(0,t),Da=(e,{contents:t,length:n},r)=>{let a=Jn()?Ua(t,r):Ha(t,r);return new Uint8Array(a).set(e,n),a},Ha=(e,t)=>{if(t<=e.byteLength)return e;let n=new ArrayBuffer(jn(t));return new Uint8Array(n).set(new Uint8Array(e),0),n},Ua=(e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let n=new ArrayBuffer(t,{maxByteLength:jn(t)});return new Uint8Array(n).set(new Uint8Array(e),0),n},jn=e=>Qn**Math.ceil(Math.log(e)/Math.log(Qn)),Qn=2,$a=({contents:e,length:t})=>Jn()?e:e.slice(0,t),Jn=()=>"resize"in ArrayBuffer.prototype,Qa={init:Na,convertChunk:{string:Ga,buffer:Un,arrayBuffer:Un,dataView:$n,typedArray:$n,others:pe},getSize:ce,truncateChunk:Va,addChunk:Da,getFinalChunk:Ve,finalize:$a};l();async function ye(e,t){if(!("Buffer"in globalThis))throw new Error("getStreamAsBuffer() is only supported in Node.js");try{return Wn(await He(e,t))}catch(n){throw n.bufferedData!==void 0&&(n.bufferedData=Wn(n.bufferedData)),n}}var Wn=e=>globalThis.Buffer.from(e);l();async function Ue(e,t){return Y(e,Ya,t)}var ja=()=>({contents:"",textDecoder:new TextDecoder}),de=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),Ja=(e,{contents:t})=>t+e,Wa=(e,t)=>e.slice(0,t),qa=({textDecoder:e})=>{let t=e.decode();return t===""?void 0:t},Ya={init:ja,convertChunk:{string:Le,buffer:de,arrayBuffer:de,dataView:de,typedArray:de,others:pe},getSize:ce,truncateChunk:Wa,addChunk:Ja,getFinalChunk:qa,finalize:De};var zn=F(Yn(),1),Kn=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},eo=({input:e,inputFile:t})=>typeof t!="string"?e:(Kn(e),Xa(t)),Xn=e=>{let t=eo(e);if(le(t))throw new TypeError("The `input` option cannot be a stream in sync mode");return t},to=({input:e,inputFile:t})=>typeof t!="string"?e:(Kn(e),Ka(t)),Zn=(e,t)=>{let n=to(t);n!==void 0&&(le(n)?n.pipe(e.stdin):e.stdin.end(n))},er=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;let n=(0,zn.default)();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},$e=async(e,t)=>{if(!(!e||t===void 0)){await Za(0),e.destroy();try{return await t}catch(n){return n.bufferedData}}},Qe=(e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t==="utf8"||t==="utf-8"?Ue(e,{maxBuffer:r}):t===null||t==="buffer"?ye(e,{maxBuffer:r}):no(e,r,t)},no=async(e,t,n)=>(await ye(e,{maxBuffer:t})).toString(n),tr=async({stdout:e,stderr:t,all:n},{encoding:r,buffer:a,maxBuffer:o},s)=>{let i=Qe(e,{encoding:r,buffer:a,maxBuffer:o}),u=Qe(t,{encoding:r,buffer:a,maxBuffer:o}),p=Qe(n,{encoding:r,buffer:a,maxBuffer:o*2});try{return await Promise.all([s,i,u,p])}catch(c){return Promise.all([{error:c,signal:c.signal,timedOut:c.timedOut},$e(e,i),$e(t,u),$e(n,p)])}};l();var ro=(async()=>{})().constructor.prototype,ao=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(ro,e)]),je=(e,t)=>{for(let[n,r]of ao){let a=typeof t=="function"?(...o)=>Reflect.apply(r.value,t(),o):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:a})}},nr=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)})});l();import{Buffer as oo}from"node:buffer";import{ChildProcess as so}from"node:child_process";var or=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],io=/^[\w.-]+$/,lo=e=>typeof e!="string"||io.test(e)?e:`"${e.replaceAll('"','\\"')}"`,Je=(e,t)=>or(e,t).join(" "),We=(e,t)=>or(e,t).map(n=>lo(n)).join(" "),uo=/ +/g;var rr=e=>{let t=typeof e;if(t==="string")return e;if(t==="number")return String(e);if(t==="object"&&e!==null&&!(e instanceof so)&&"stdout"in e){let n=typeof e.stdout;if(n==="string")return e.stdout;if(oo.isBuffer(e.stdout))return e.stdout.toString();throw new TypeError(`Unexpected "${n}" stdout in template expression`)}throw new TypeError(`Unexpected "${t}" in template expression`)},ar=(e,t,n)=>n||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],po=({templates:e,expressions:t,tokens:n,index:r,template:a})=>{let o=a??e.raw[r],s=o.split(uo).filter(Boolean),i=ar(n,s,o.startsWith(" "));if(r===t.length)return i;let u=t[r],p=Array.isArray(u)?u.map(c=>rr(c)):[rr(u)];return ar(i,p,o.endsWith(" "))},qe=(e,t)=>{let n=[];for(let[r,a]of e.entries())n=po({templates:e,expressions:t,tokens:n,index:r,template:a});return n};l();import{debuglog as co}from"node:util";import yo from"node:process";var sr=co("execa").enabled,Se=(e,t)=>String(e).padStart(t,"0"),So=()=>{let e=new Date;return`${Se(e.getHours(),2)}:${Se(e.getMinutes(),2)}:${Se(e.getSeconds(),2)}.${Se(e.getMilliseconds(),3)}`},Ye=(e,{verbose:t})=>{t&&yo.stderr.write(`[${So()}] ${e}
|
|
155
|
-
`)};var fo=1e3*1e3*100,ho=({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:a})=>{let o=t?{...ge.env,...e}:e;return n?In({env:o,cwd:r,execPath:a}):o},ur=(e,t,n={})=>{let r=lr.default._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:fo,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:sr,...n},n.env=ho(n),n.stdio=Pn(n),ge.platform==="win32"&&mo.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},z=(e,t,n)=>typeof t!="string"&&!go.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?Oe(t):t;function Ke(e,t,n){let r=ur(e,t,n),a=Je(e,t),o=We(e,t);Ye(o,r.options),Nn(r.options);let s;try{s=ze.spawn(r.file,r.args,r.options)}catch(S){let f=new ze.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=nr(s),u=kn(s,r.options,i),p=Gn(s,r.options,u),c={isCanceled:!1};s.kill=On.bind(null,s.kill.bind(s)),s.cancel=Bn.bind(null,s,c);let d=_n(async()=>{let[{error:S,exitCode:f,signal:h,timedOut:g},A,E,C]=await tr(s,r.options,p),_=z(r.options,A),T=z(r.options,E),X=z(r.options,C);if(S||f!==0||h!==null){let tt=q({error:S,exitCode:f,signal:h,stdout:_,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 tt;throw tt}return{command:a,escapedCommand:o,exitCode:0,stdout:_,stderr:T,all:X,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Zn(s,r.options),s.all=er(s,r.options),Ln(s),je(s,d),s}function bo(e,t,n){let r=ur(e,t,n),a=Je(e,t),o=We(e,t);Ye(o,r.options);let s=Xn(r.options),i;try{i=ze.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 u=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:u,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:u,stderr:p,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}}var Eo=({input:e,inputFile:t,stdio:n})=>e===void 0&&t===void 0&&n===void 0?{stdin:"inherit"}:{},ir=(e={})=>({preferLocal:!0,...Eo(e),...e});function pr(e){function t(n,...r){if(!Array.isArray(n))return pr({...e,...n});let[a,...o]=qe(n,r);return Ke(a,o,ir(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]=qe(n,r);return bo(a,o,ir(e))},t}var $l=pr();var I=F(Mr(),1),Er=F(xr(),1);import H from"node:assert";import me from"node:path";import Co from"node:process";l();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=[],u=[],p=new Map,c=!1,y=!1,d=!1,S=0,f=0,h=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),g=E=>{c=!0,y=!0,s(E)};a&&(a.aborted&&g(a.reason),a.addEventListener("abort",()=>{g(a.reason)}));let A=async()=>{if(y)return;let E=await h.next(),C=f;if(f++,E.done){if(d=!0,S===0&&!y){if(!r&&u.length>0){g(new AggregateError(u));return}if(y=!0,p.size===0){o(i);return}let _=[];for(let[T,X]of i.entries())p.get(T)!==cr&&_.push(X);o(_)}return}S++,(async()=>{try{let _=await E.value;if(y)return;let T=await t(_,C);T===cr&&p.set(C,T),i[C]=T,S--,await A()}catch(_){if(r)g(_);else{u.push(_),S--;try{await A()}catch(T){g(T)}}}})()};(async()=>{for(let E=0;E<n;E++){try{await A()}catch(C){g(C);break}if(d||c)break}})()})}var cr=Symbol("skip");l();var hr=F(mr(),1);l();var Ao=Object.prototype.toString,Mo=e=>Ao.call(e)==="[object Error]",Io=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 Xe(e){return e&&Mo(e)&&e.name==="TypeError"&&typeof e.message=="string"?e.message==="Load failed"?e.stack===void 0:Io.has(e.message):!1}var Ze=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}},fr=(e,t,n)=>{let r=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e};async function et(e,t){return new Promise((n,r)=>{t={onFailedAttempt(){},retries:10,shouldRetry:()=>!0,...t};let a=hr.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 u=await e(i);s(),n(u)}catch(u){try{if(!(u instanceof Error))throw new TypeError(`Non-error was thrown: "${u}". You should only throw errors.`);if(u instanceof Ze)throw u.originalError;if(u instanceof TypeError&&!Xe(u))throw u;if(fr(u,i,t),await t.shouldRetry(u)||(a.stop(),r(u)),await t.onFailedAttempt(u),!a.retry(u))throw a.mainError()}catch(p){fr(p,i,t),s(),r(p)}}})})}var U=F(nt(),1);l();var _o=50*1024*1024,br=class{constructor(t){this.syncJson=t}_syncOperations=new ht({concurrency:1});async hashes(t,n){let r=n?void 0:$({ensureEmptyLineAbove:!0})`
|
|
156
|
-
Calculating file changes.
|
|
157
|
-
`;try{let[a,{localFilesVersionHashes:o,environmentHashes:s,environmentFilesVersion:i}]=await Promise.all([this.syncJson.directory.hashes(),(async()=>{let h,g,A;if(this.syncJson.filesVersion===0n){let{fileSyncHashes:E}=await this.syncJson.edit.query({query:Tt});A=BigInt(E.filesVersion),g=E.hashes,h={}}else{let{fileSyncComparisonHashes:E}=await this.syncJson.edit.query({query:vt,variables:{filesVersion:String(this.syncJson.filesVersion)}});h=E.filesVersionHashes.hashes,g=E.latestFilesVersionHashes.hashes,A=BigInt(E.latestFilesVersionHashes.filesVersion)}return{localFilesVersionHashes:h,environmentHashes:g,environmentFilesVersion:A}})()]),u=wt(t,a,s),p=L(t,{from:o,to:a,existing:s,ignore:[".gadget/"]}),c=L(t,{from:o,to:s,existing:a});!u&&p.size===0&&c.size===0&&(c=L(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(u||p.size>0||c.size>0,"there must be changes if hashes don't match");let y=L(t,{from:s,to:a,ignore:[".gadget/"]}),d=L(t,{from:a,to:s}),S=d.size>0&&Array.from(d.keys()).every(h=>h.startsWith(".gadget/")),f=p.size>0&&c.size>0&&!S;return r&&(S?r.clear():u?r.succeed`Your files are up to date. ${P()}`:r.succeed`Calculated file changes. ${P()}`),{inSync:u,localFilesVersionHashes:o,localHashes:a,localChanges:p,localChangesToPush:y,environmentHashes:s,environmentChanges:c,environmentChangesToPull:d,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?ne(t,{changes:a,tense:"past",title:m`Your local files {underline have} changed.`}):R({ensureEmptyLineAbove:!0})`
|
|
158
|
-
Your local files {underline have not} changed.
|
|
159
|
-
`,o.size>0&&!s?ne(t,{changes:o,tense:"past",title:m`Your environment's files {underline have}${i?" also":""} changed.`}):R({ensureEmptyLineAbove:!0})`
|
|
160
|
-
Your environment's files {underline have not} changed.
|
|
161
|
-
`)}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){ee(t,o),await this.merge(t,{printEnvironmentChangesOptions:a})}})}subscribeToEnvironmentChanges(t,{beforeChanges:n=he,printEnvironmentChangesOptions:r,afterChanges:a=he,onError:o}){return this.syncJson.edit.subscribe({subscription:It,variables:()=>({localFilesVersion:String(this.syncJson.filesVersion)}),onError:o,onData:({remoteFileSyncEvents:{changed:s,deleted:i,remoteFilesVersion:u}})=>{this._syncOperations.add(async()=>{if(BigInt(u)<this.syncJson.filesVersion){t.log.warn("skipping received changes because files version is outdated",{filesVersion:u});return}t.log.debug("received files",{remoteFilesVersion:u,changed:s.map(y=>y.path),deleted:i.map(y=>y.path)});let p=y=>{let d=this.syncJson.directory.ignores(y.path);return d&&t.log.warn("skipping received change because file is ignored",{path:y.path}),!d};if(s=s.filter(p),i=i.filter(p),s.length===0&&i.length===0){await this.syncJson.save(u);return}await n({changed:s.map(y=>y.path),deleted:i.map(y=>y.path)});let c=await this.writeToLocalFilesystem(t,{filesVersion:u,files:s,delete:i.map(y=>y.path),printEnvironmentChangesOptions:{tense:"past",ensureEmptyLineAbove:!0,title:N`{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,maxAttempts:r=10,printLocalChangesOptions:a,printEnvironmentChangesOptions:o,quietly:s}={}){let i=0;do{if(i===0?n??=await this.hashes(t,s):n=await this.hashes(t,s),n.inSync){this._syncOperations.clear(),t.log.info("filesystem in sync"),await this.syncJson.save(n.environmentFilesVersion);return}i+=1,t.log.info("merging",{attempt:i,...n});try{await this._merge(t,{hashes:n,printLocalChangesOptions:a,printEnvironmentChangesOptions:o})}catch(u){ee(t,u)}}while(i<r);throw new ft(r)}async push(t,{hashes:n,force:r,printLocalChangesOptions:a}={}){let{localChangesToPush:o,environmentChanges:s,environmentFilesVersion:i,onlyDotGadgetFilesChanged:u}=n??await this.hashes(t);H(o.size>0,"cannot push if there are no changes"),!(r??t.args["--force"])&&s.size>0&&!u&&await xe({ensureEmptyLineAbove:!0})`
|
|
162
|
-
Are you sure you want to {underline discard} your environment's changes?
|
|
163
|
-
`;try{await this._sendChangesToEnvironment(t,{changes:o,expectedFilesVersion:i,printLocalChangesOptions:a})}catch(p){throw ee(t,p),new be(m`
|
|
164
|
-
Your environment's files have changed since we last checked.
|
|
165
|
-
|
|
166
|
-
Please re-run "ggt ${t.command}" to see the changes and try again.
|
|
167
|
-
`)}}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??t.args["--force"])&&await xe`
|
|
168
|
-
Are you sure you want to {underline discard} your local changes?
|
|
169
|
-
`,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 te,o=new Set;await K(n.delete,async s=>{let i=me.dirname(s);for(;i!==".";)o.add(this.syncJson.directory.normalize(i,!0)),i=me.dirname(i);let u=this.syncJson.directory.absolute(s),p=this.syncJson.directory.absolute(".gadget/backup",this.syncJson.directory.relative(s));await et(async()=>{try{await I.default.remove(p),await I.default.move(u,p),a.set(s,{type:"delete"})}catch(c){if(fe(c))return;if(st(c)||it(c)){let y=me.dirname(p);for(;y!==this.syncJson.directory.absolute(".gadget/backup");)(await I.default.stat(y)).isDirectory()||(t.log.debug("removing file in the way of backup path",{currentPath:u,backupPath:p,file:y}),await I.default.remove(y)),y=me.dirname(y)}throw c}},{retries:Z.windows?4:2,minTimeout:(0,Er.default)("100ms"),onFailedAttempt:c=>{t.log.warn("failed to move file to backup",{error:c,currentPath:u,backupPath:p})}})});for(let s of Array.from(o.values()).sort().reverse())if(!n.files.some(i=>i.path===s))try{await I.default.rmdir(this.syncJson.directory.absolute(s)),a.set(s,{type:"delete"})}catch(i){if(fe(i)||ot(i))continue;throw i}if(await K(n.files,async s=>{let i=this.syncJson.directory.absolute(s.path);await I.default.pathExists(i)?s.path.endsWith("/")||a.set(s.path,{type:"update"}):a.set(s.path,{type:"create"}),s.path.endsWith("/")?await I.default.ensureDir(i):await I.default.outputFile(i,Buffer.from(s.content,s.encoding)),Et&&await I.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(),ne(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})('Running "yarn install --check-files"');try{await Ke("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 u=St(i).message;u&&R({ensureEmptyLineAbove:!0,indent:2})(u)}}return a}async _merge(t,{hashes:{localChanges:n,environmentChanges:r,environmentFilesVersion:a},printLocalChangesOptions:o,printEnvironmentChangesOptions:s}){let i=Pt({localChanges:n,environmentChanges:r});if(i.size>0){t.log.debug("conflicts detected",{conflicts:i});let u=t.args["--prefer"];switch(u||(Ot({conflicts:i}),u=await At({choices:Object.values(O)})`
|
|
170
|
-
{bold How should we resolve these conflicts?}
|
|
171
|
-
`),u){case O.CANCEL:{Co.exit(0);break}case O.LOCAL:{r=Me({conflicts:i,changes:r});break}case O.ENVIRONMENT:{n=Me({conflicts:i,changes:n});break}}}r.size>0&&await this._getChangesFromEnvironment(t,{changes:r,filesVersion:a,printEnvironmentChangesOptions:s}),n.size>0&&await this._sendChangesToEnvironment(t,{changes:n,expectedFilesVersion:a,printLocalChangesOptions:o})}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})(j(t,{changes:r,tense:"present",title:m`Pulling ${(0,U.default)("file",r.size)}.`,...a}));try{let u=[];if(o.length>0||s.length>0){let{fileSyncFiles:p}=await this.syncJson.edit.query({query:_t,variables:{paths:[...o,...s],filesVersion:String(n),encoding:"base64"}});u=p.files}await this.writeToLocalFilesystem(t,{filesVersion:n,files:u,delete:r.deleted(),spinner:i,printEnvironmentChangesOptions:a})}catch(u){throw i.fail(),u}}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 y=this.syncJson.directory.absolute(p),d;try{d=await I.default.stat(y)}catch(h){xt(h),t.log.debug("skipping change because file doesn't exist",{path:p});return}let S="";d.isFile()&&(S=await I.default.readFile(y,"base64"));let f;c.type==="create"&&c.oldPath&&(f=c.oldPath),o.push({content:S,oldPath:f,path:p,mode:d.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)>_o)throw new be(m`
|
|
172
|
-
{underline Your file changes are too large to push.}
|
|
173
|
-
|
|
174
|
-
Run "ggt status" to see your changes and consider
|
|
175
|
-
ignoring some files or pushing in smaller batches.
|
|
176
|
-
`);let u=$({ensureEmptyLineAbove:!0})(j(t,{changes:n,tense:"present",title:N`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:Ct,variables:{input:{expectedRemoteFilesVersion:String(r),changed:o,deleted:s}},http:{retry:{methods:["POST"],calculateDelay:({error:y,computedValue:d})=>Ee(y.response?.body)?0:d}}});if(BigInt(p)>r+1n)throw new Error("Files version mismatch");await this.syncJson.save(p),u.succeed(j(t,{changes:n,tense:"past",title:N`Pushed ${(0,U.default)("file",o.length+s.length)}. ${w.arrowRight} ${P()}`,...a})),c.length>0&&R({ensureEmptyLineAbove:!0})`
|
|
177
|
-
{red Gadget has detected the following fatal errors with your files:}
|
|
178
|
-
|
|
179
|
-
${gt({problems:mt(c),showFileTypes:!1,indent:10})}
|
|
180
|
-
|
|
181
|
-
{red Your app will not be operational until all fatal errors are fixed.}
|
|
182
|
-
`}catch(p){throw Ee(p)?u.clear():u.fail(),p}}};export{te as a,Xt as b,Do as c,Ho as d,Uo as e,$o as f,Qo as g,P as h,Pt as i,Ot as j,ys as k,ds as l,br as m};
|
|
183
|
-
//# sourceMappingURL=chunk-P2XPMNL6.js.map
|