@gadgetinc/ggt 1.7.4 → 2.2.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.
Files changed (154) hide show
  1. package/README.md +142 -31
  2. package/dist/{add-KJLV4API.js → add-TWLGKL2T.js} +8 -7
  3. package/dist/add-TWLGKL2T.js.map +7 -0
  4. package/dist/agent-plugin-TN24O7FB.js +10 -0
  5. package/dist/agent-plugin-TN24O7FB.js.map +7 -0
  6. package/dist/chunk-2742UPMB.js +10 -0
  7. package/dist/chunk-2742UPMB.js.map +7 -0
  8. package/dist/chunk-3OM5WM7E.js +2 -0
  9. package/dist/chunk-3OM5WM7E.js.map +7 -0
  10. package/dist/chunk-442CSROP.js +66 -0
  11. package/dist/chunk-442CSROP.js.map +7 -0
  12. package/dist/chunk-DR4CXBD6.js +11 -0
  13. package/dist/chunk-DR4CXBD6.js.map +7 -0
  14. package/dist/chunk-F255O64V.js +2 -0
  15. package/dist/chunk-F255O64V.js.map +7 -0
  16. package/dist/chunk-GJGBTM5Y.js +2 -0
  17. package/dist/chunk-GJGBTM5Y.js.map +7 -0
  18. package/dist/chunk-HCULGPBH.js +2 -0
  19. package/dist/chunk-HCULGPBH.js.map +7 -0
  20. package/dist/chunk-J232VCIM.js +2 -0
  21. package/dist/chunk-J232VCIM.js.map +7 -0
  22. package/dist/chunk-JG2QCDK2.js +118 -0
  23. package/dist/chunk-JG2QCDK2.js.map +7 -0
  24. package/dist/chunk-JKZNSRLU.js +8 -0
  25. package/dist/chunk-JKZNSRLU.js.map +7 -0
  26. package/dist/chunk-JYE5LLIF.js +9 -0
  27. package/dist/chunk-JYE5LLIF.js.map +7 -0
  28. package/dist/{chunk-SX5LO3XQ.js → chunk-KKIL22RY.js} +1 -1
  29. package/dist/{chunk-SX5LO3XQ.js.map → chunk-KKIL22RY.js.map} +1 -1
  30. package/dist/chunk-L2XBSR7G.js +2 -0
  31. package/dist/chunk-L2XBSR7G.js.map +7 -0
  32. package/dist/chunk-MW6MXMSN.js +2 -0
  33. package/dist/chunk-MW6MXMSN.js.map +7 -0
  34. package/dist/chunk-OUIZQC4D.js +12 -0
  35. package/dist/chunk-OUIZQC4D.js.map +7 -0
  36. package/dist/chunk-R6KJLEKY.js +28 -0
  37. package/dist/chunk-R6KJLEKY.js.map +7 -0
  38. package/dist/chunk-SIR6HLN3.js +69 -0
  39. package/dist/chunk-SIR6HLN3.js.map +7 -0
  40. package/dist/chunk-SVWK2NXG.js +2 -0
  41. package/dist/chunk-SVWK2NXG.js.map +7 -0
  42. package/dist/chunk-T6UHSWMT.js +2 -0
  43. package/dist/{chunk-J2OYMAMD.js.map → chunk-T6UHSWMT.js.map} +2 -2
  44. package/dist/{chunk-JSGXXXFU.js → chunk-WB6O2V5D.js} +6 -6
  45. package/dist/{chunk-JSGXXXFU.js.map → chunk-WB6O2V5D.js.map} +3 -3
  46. package/dist/chunk-XC4F2TLW.js +113 -0
  47. package/dist/chunk-XC4F2TLW.js.map +7 -0
  48. package/dist/chunk-YFUOXDPK.js +10 -0
  49. package/dist/chunk-YFUOXDPK.js.map +7 -0
  50. package/dist/chunk-ZSREFZXV.js +211 -0
  51. package/dist/chunk-ZSREFZXV.js.map +7 -0
  52. package/dist/chunk-ZYDMXS5R.js +6 -0
  53. package/dist/chunk-ZYDMXS5R.js.map +7 -0
  54. package/dist/{configure-CXY6JQB7.js → configure-UJS7V2JX.js} +2 -2
  55. package/dist/configure-UJS7V2JX.js.map +7 -0
  56. package/dist/debugger-QN2MCLBL.js +41 -0
  57. package/dist/debugger-QN2MCLBL.js.map +7 -0
  58. package/dist/deploy-J74PHPQA.js +25 -0
  59. package/dist/deploy-J74PHPQA.js.map +7 -0
  60. package/dist/dev-GGUSOOYP.js +59 -0
  61. package/dist/dev-GGUSOOYP.js.map +7 -0
  62. package/dist/esm-D77XRR65.js +38 -0
  63. package/dist/esm-D77XRR65.js.map +7 -0
  64. package/dist/eval-L6WHUFLU.js +54 -0
  65. package/dist/eval-L6WHUFLU.js.map +7 -0
  66. package/dist/getMachineId-bsd-QUXN4NKS.js +2 -0
  67. package/dist/getMachineId-bsd-QUXN4NKS.js.map +7 -0
  68. package/dist/getMachineId-darwin-TCXBAX22.js +3 -0
  69. package/dist/getMachineId-darwin-TCXBAX22.js.map +7 -0
  70. package/dist/getMachineId-linux-IJ3LYIOX.js +2 -0
  71. package/dist/getMachineId-linux-IJ3LYIOX.js.map +7 -0
  72. package/dist/getMachineId-unsupported-IKXBUCYY.js +2 -0
  73. package/dist/getMachineId-unsupported-IKXBUCYY.js.map +7 -0
  74. package/dist/getMachineId-win-6CX7VSFF.js +2 -0
  75. package/dist/getMachineId-win-6CX7VSFF.js.map +7 -0
  76. package/dist/ggt-5XNRJZSW.js +44 -0
  77. package/dist/ggt-5XNRJZSW.js.map +7 -0
  78. package/dist/{list-3QZTSHQV.js → list-756D46N5.js} +2 -2
  79. package/dist/list-756D46N5.js.map +7 -0
  80. package/dist/login-GMWQRH7V.js +2 -0
  81. package/dist/{logout-SWWGI27Q.js → logout-LQABTJFD.js} +2 -2
  82. package/dist/logout-LQABTJFD.js.map +7 -0
  83. package/dist/logs-AQZB272X.js +28 -0
  84. package/dist/logs-AQZB272X.js.map +7 -0
  85. package/dist/main.js +1 -43
  86. package/dist/main.js.map +4 -4
  87. package/dist/{open-J2ZVNVJ6.js → open-OMZWPQ66.js} +11 -11
  88. package/dist/open-OMZWPQ66.js.map +7 -0
  89. package/dist/problems-FZJKH52E.js +14 -0
  90. package/dist/problems-FZJKH52E.js.map +7 -0
  91. package/dist/pull-XYCYN7QN.js +28 -0
  92. package/dist/pull-XYCYN7QN.js.map +7 -0
  93. package/dist/push-3QM7ZFTC.js +2 -0
  94. package/dist/status-PWAXNK5G.js +14 -0
  95. package/dist/status-PWAXNK5G.js.map +7 -0
  96. package/dist/update-QIQFJFRQ.js +2 -0
  97. package/dist/update-QIQFJFRQ.js.map +7 -0
  98. package/dist/var-N4WGGJXZ.js +159 -0
  99. package/dist/var-N4WGGJXZ.js.map +7 -0
  100. package/dist/{version-NZHW3VLV.js → version-AJKSJJDC.js} +2 -2
  101. package/dist/version-AJKSJJDC.js.map +7 -0
  102. package/dist/{whoami-MIJFO4MW.js → whoami-KJYDSQSD.js} +2 -2
  103. package/dist/whoami-KJYDSQSD.js.map +7 -0
  104. package/package.json +64 -74
  105. package/dist/add-KJLV4API.js.map +0 -7
  106. package/dist/chunk-24OT7GHO.js +0 -65
  107. package/dist/chunk-24OT7GHO.js.map +0 -7
  108. package/dist/chunk-HN3YKQ3C.js +0 -6
  109. package/dist/chunk-HN3YKQ3C.js.map +0 -7
  110. package/dist/chunk-J2OYMAMD.js +0 -2
  111. package/dist/chunk-JBY5A44K.js +0 -7
  112. package/dist/chunk-JBY5A44K.js.map +0 -7
  113. package/dist/chunk-L5H5T2T6.js +0 -66
  114. package/dist/chunk-L5H5T2T6.js.map +0 -7
  115. package/dist/chunk-M6L2X3GX.js +0 -194
  116. package/dist/chunk-M6L2X3GX.js.map +0 -7
  117. package/dist/chunk-MHTXRD5G.js +0 -2
  118. package/dist/chunk-MHTXRD5G.js.map +0 -7
  119. package/dist/chunk-OIVNACS7.js +0 -12
  120. package/dist/chunk-OIVNACS7.js.map +0 -7
  121. package/dist/chunk-QXWICGG6.js +0 -2
  122. package/dist/chunk-QXWICGG6.js.map +0 -7
  123. package/dist/chunk-WNAYBYSG.js +0 -8
  124. package/dist/chunk-WNAYBYSG.js.map +0 -7
  125. package/dist/chunk-X47UA3VR.js +0 -2
  126. package/dist/chunk-X47UA3VR.js.map +0 -7
  127. package/dist/chunk-XGQQOMPO.js +0 -2
  128. package/dist/chunk-XGQQOMPO.js.map +0 -7
  129. package/dist/chunk-XKYYKHP4.js +0 -28
  130. package/dist/chunk-XKYYKHP4.js.map +0 -7
  131. package/dist/chunk-YU6P3ESA.js +0 -121
  132. package/dist/chunk-YU6P3ESA.js.map +0 -7
  133. package/dist/configure-CXY6JQB7.js.map +0 -7
  134. package/dist/deploy-XFZBJJWP.js +0 -25
  135. package/dist/deploy-XFZBJJWP.js.map +0 -7
  136. package/dist/dev-GG6TU3DJ.js +0 -59
  137. package/dist/dev-GG6TU3DJ.js.map +0 -7
  138. package/dist/esm-PLVGBDRY.js +0 -38
  139. package/dist/esm-PLVGBDRY.js.map +0 -7
  140. package/dist/list-3QZTSHQV.js.map +0 -7
  141. package/dist/login-HKGCVIWO.js +0 -2
  142. package/dist/logout-SWWGI27Q.js.map +0 -7
  143. package/dist/logs-DW4PH3U6.js +0 -28
  144. package/dist/logs-DW4PH3U6.js.map +0 -7
  145. package/dist/open-J2ZVNVJ6.js.map +0 -7
  146. package/dist/pull-ORNQFSFG.js +0 -28
  147. package/dist/pull-ORNQFSFG.js.map +0 -7
  148. package/dist/push-KMZZ6JJL.js +0 -2
  149. package/dist/status-JAREJZ4X.js +0 -14
  150. package/dist/status-JAREJZ4X.js.map +0 -7
  151. package/dist/version-NZHW3VLV.js.map +0 -7
  152. package/dist/whoami-MIJFO4MW.js.map +0 -7
  153. /package/dist/{login-HKGCVIWO.js.map → login-GMWQRH7V.js.map} +0 -0
  154. /package/dist/{push-KMZZ6JJL.js.map → push-3QM7ZFTC.js.map} +0 -0
@@ -1,194 +0,0 @@
1
- import{b as ht,e as bt,h as Et,i as xt,k as Ie,l as ne}from"./chunk-YU6P3ESA.js";import{a as gt,b as ft}from"./chunk-JSGXXXFU.js";import{b as J}from"./chunk-WNAYBYSG.js";import{c as mt}from"./chunk-J2OYMAMD.js";import{a as Tt}from"./chunk-JBY5A44K.js";import{F as Ct,h as Me,i as Fr,j as St,p as Mt,u as _t}from"./chunk-L5H5T2T6.js";import{b as N}from"./chunk-XGQQOMPO.js";import{b as It,c as At}from"./chunk-OIVNACS7.js";import{A as vr,O as pt,R as ct,S as D,V as xe,W as te,Z as dt,aa as yt,b as E,d as at,g as ot,ha as g,ia as G,ja as O,o as st,q as Ee,r as it,s as lt,t as ut}from"./chunk-24OT7GHO.js";import{a as Tr}from"./chunk-GFQYFEEH.js";import{a,b as F,d as x,f as w,h as p}from"./chunk-7DYQUG5M.js";var Qt=x((Rs,$t)=>{p();$t.exports=Ut;Ut.sync=kr;var Gt=F("fs");function Br(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 o=n[r].toLowerCase();if(o&&e.substr(-o.length).toLowerCase()===o)return!0}return!1}a(Br,"checkPathExt");function Ht(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:Br(t,n)}a(Ht,"checkStat");function Ut(e,t,n){Gt.stat(e,function(r,o){n(r,r?!1:Ht(o,e,t))})}a(Ut,"isexe");function kr(e,t){return Ht(Gt.statSync(e),e,t)}a(kr,"sync")});var Yt=x((Os,qt)=>{p();qt.exports=Jt;Jt.sync=Lr;var jt=F("fs");function Jt(e,t,n){jt.stat(e,function(r,o){n(r,r?!1:Wt(o,t))})}a(Jt,"isexe");function Lr(e,t){return Wt(jt.statSync(e),t)}a(Lr,"sync");function Wt(e,t){return e.isFile()&&Vr(e,t)}a(Wt,"checkStat");function Vr(e,t){var n=e.mode,r=e.uid,o=e.gid,s=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),i=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),l=parseInt("100",8),u=parseInt("010",8),c=parseInt("001",8),d=l|u,y=n&c||n&u&&o===i||n&l&&r===s||n&d&&s===0;return y}a(Vr,"checkMode")});var Kt=x((Ls,zt)=>{p();var ks=F("fs"),oe;process.platform==="win32"||global.TESTING_WINDOWS?oe=Qt():oe=Yt();zt.exports=Ce;Ce.sync=Dr;function Ce(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,o){Ce(e,t||{},function(s,i){s?o(s):r(i)})})}oe(e,t||{},function(r,o){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,o=!1),n(r,o)})}a(Ce,"isexe");function Dr(e,t){try{return oe.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}a(Dr,"sync")});var an=x((Gs,rn)=>{p();var $=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Xt=F("path"),Gr=$?";":":",Zt=Kt(),en=a(e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),"getNotFoundError"),tn=a((e,t)=>{let n=t.colon||Gr,r=e.match(/\//)||$&&e.match(/\\/)?[""]:[...$?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],o=$?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=$?o.split(n):[""];return $&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:r,pathExt:s,pathExtExe:o}},"getPathInfo"),nn=a((e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});let{pathEnv:r,pathExt:o,pathExtExe:s}=tn(e,t),i=[],l=a(c=>new Promise((d,y)=>{if(c===r.length)return t.all&&i.length?d(i):y(en(e));let m=r[c],S=/^".*"$/.test(m)?m.slice(1,-1):m,f=Xt.join(S,e),h=!S&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;d(u(h,c,0))}),"step"),u=a((c,d,y)=>new Promise((m,S)=>{if(y===o.length)return m(l(d+1));let f=o[y];Zt(c+f,{pathExt:s},(h,b)=>{if(!h&&b)if(t.all)i.push(c+f);else return m(c+f);return m(u(c,d,y+1))})}),"subStep");return n?l(0).then(c=>n(null,c),n):l(0)},"which"),Hr=a((e,t)=>{t=t||{};let{pathEnv:n,pathExt:r,pathExtExe:o}=tn(e,t),s=[];for(let i=0;i<n.length;i++){let l=n[i],u=/^".*"$/.test(l)?l.slice(1,-1):l,c=Xt.join(u,e),d=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+c:c;for(let y=0;y<r.length;y++){let m=d+r[y];try{if(Zt.sync(m,{pathExt:o}))if(t.all)s.push(m);else return m}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw en(e)},"whichSync");rn.exports=nn;nn.sync=Hr});var sn=x(($s,Te)=>{"use strict";p();var on=a((e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"},"pathKey");Te.exports=on;Te.exports.default=on});var cn=x((Js,pn)=>{"use strict";p();var ln=F("path"),Ur=an(),$r=sn();function un(e,t){let n=e.options.env||process.env,r=process.cwd(),o=e.options.cwd!=null,s=o&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let i;try{i=Ur.sync(e.command,{path:n[$r({env:n})],pathExt:t?ln.delimiter:void 0})}catch{}finally{s&&process.chdir(r)}return i&&(i=ln.resolve(o?e.options.cwd:"",i)),i}a(un,"resolveCommandAttempt");function Qr(e){return un(e)||un(e,!0)}a(Qr,"resolveCommand");pn.exports=Qr});var dn=x((Ys,Fe)=>{"use strict";p();var ve=/([()\][%!^"`<>&|;, *?])/g;function jr(e){return e=e.replace(ve,"^$1"),e}a(jr,"escapeCommand");function Jr(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(ve,"^$1"),t&&(e=e.replace(ve,"^$1")),e}a(Jr,"escapeArgument");Fe.exports.command=jr;Fe.exports.argument=Jr});var mn=x((Xs,yn)=>{"use strict";p();yn.exports=/^#!(.*)/});var gn=x((ei,Sn)=>{"use strict";p();var Wr=mn();Sn.exports=(e="")=>{let t=e.match(Wr);if(!t)return null;let[n,r]=t[0].replace(/#! ?/,"").split(" "),o=n.split("/").pop();return o==="env"?r:r?`${o} ${r}`:o}});var hn=x((ni,fn)=>{"use strict";p();var Re=F("fs"),qr=gn();function Yr(e){let n=Buffer.alloc(150),r;try{r=Re.openSync(e,"r"),Re.readSync(r,n,0,150,0),Re.closeSync(r)}catch{}return qr(n.toString())}a(Yr,"readShebang");fn.exports=Yr});var Mn=x((oi,xn)=>{"use strict";p();var zr=F("path"),bn=cn(),En=dn(),Kr=hn(),Xr=process.platform==="win32",Zr=/\.(?:com|exe)$/i,ea=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function ta(e){e.file=bn(e);let t=e.file&&Kr(e.file);return t?(e.args.unshift(e.file),e.command=t,bn(e)):e.file}a(ta,"detectShebang");function na(e){if(!Xr)return e;let t=ta(e),n=!Zr.test(t);if(e.options.forceShell||n){let r=ea.test(t);e.command=zr.normalize(e.command),e.command=En.command(e.command),e.args=e.args.map(s=>En.argument(s,r));let o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}a(na,"parseNonShell");function ra(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:na(r)}a(ra,"parse");xn.exports=ra});var _n=x((li,An)=>{"use strict";p();var we=process.platform==="win32";function Pe(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})}a(Pe,"notFoundError");function aa(e,t){if(!we)return;let n=e.emit;e.emit=function(r,o){if(r==="exit"){let s=In(o,t,"spawn");if(s)return n.call(e,"error",s)}return n.apply(e,arguments)}}a(aa,"hookChildProcess");function In(e,t){return we&&e===1&&!t.file?Pe(t.original,"spawn"):null}a(In,"verifyENOENT");function oa(e,t){return we&&e===1&&!t.file?Pe(t.original,"spawnSync"):null}a(oa,"verifyENOENTSync");An.exports={hookChildProcess:aa,verifyENOENT:In,verifyENOENTSync:oa,notFoundError:Pe}});var vn=x((ci,Q)=>{"use strict";p();var Cn=F("child_process"),Oe=Mn(),Ne=_n();function Tn(e,t,n){let r=Oe(e,t,n),o=Cn.spawn(r.command,r.args,r.options);return Ne.hookChildProcess(o,r),o}a(Tn,"spawn");function sa(e,t,n){let r=Oe(e,t,n),o=Cn.spawnSync(r.command,r.args,r.options);return o.error=o.error||Ne.verifyENOENTSync(o.status,r),o}a(sa,"spawnSync");Q.exports=Tn;Q.exports.spawn=Tn;Q.exports.sync=sa;Q.exports._parse=Oe;Q.exports._enoent=Ne});var er=x((Zl,Zn)=>{"use strict";p();var{PassThrough:no}=F("stream");Zn.exports=function(){var e=[],t=new no({objectMode:!0});return t.setMaxListeners(0),t.add=n,t.isEmpty=r,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(n),t;function n(s){return Array.isArray(s)?(s.forEach(n),this):(e.push(s),s.once("end",o.bind(null,s)),s.once("error",t.emit.bind(t,"error")),s.pipe(t,{end:!1}),this)}a(n,"add");function r(){return e.length==0}a(r,"isEmpty");function o(s){e=e.filter(function(i){return i!==s}),!e.length&&t.readable&&t.end()}a(o,"remove")}});var hr=x((Ju,fr)=>{p();function A(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))}a(A,"RetryOperation");fr.exports=A;A.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};A.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};A.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};A.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)};A.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};A.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};A.prototype.start=A.prototype.try;A.prototype.errors=function(){return this._errors};A.prototype.attempts=function(){return this._attempts};A.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 o=this._errors[r],s=o.message,i=(e[s]||0)+1;e[s]=i,i>=n&&(t=o,n=i)}return t}});var br=x(L=>{p();var To=hr();L.operation=function(e){var t=L.timeouts(e);return new To(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};L.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=[],o=0;o<t.retries;o++)r.push(this.createTimeout(o,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(o,t)),r.sort(function(s,i){return s-i}),r};L.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};L.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 o=0;o<n.length;o++){var s=n[o],i=e[s];e[s]=a(function(u){var c=L.operation(t),d=Array.prototype.slice.call(arguments,1),y=d.pop();d.push(function(m){c.retry(m)||(m&&(arguments[0]=c.mainError()),y.apply(this,arguments))}),c.attempt(function(){u.apply(e,d)})},"retryWrapper").bind(e,i),e[s].options=t}}});var xr=x((Xu,Er)=>{p();Er.exports=br()});p();var W=w(St(),1);var re=class extends Map{static{a(this,"Changes")}created=D(()=>Array.from(this.entries()).filter(([,t])=>t.type==="create").map(([t])=>t));updated=D(()=>Array.from(this.entries()).filter(([,t])=>t.type==="update").map(([t])=>t));deleted=D(()=>Array.from(this.entries()).filter(([,t])=>t.type==="delete").map(([t])=>t))},Rr=E.greenBright("+"),wr=E.blueBright("\xB1"),Pr=E.redBright("-"),vt=E.yellowBright("\u2192"),q=a((e,{changes:t,tense:n,limit:r=1/0,...o})=>{dt.logLevel<=te.TRACE&&(r=1/0);let s=Array.from(t.entries()).filter(([m])=>!m.startsWith(".gadget/"));if(s.length===0)return"";let i=E.yellowBright(n==="past"?"renamed":"rename"),l=E.greenBright(n==="past"?"created":"create"),u=E.blueBright(n==="past"?"updated":"update"),c=E.redBright(n==="past"?"deleted":"delete"),d=s.sort((m,S)=>m[0].localeCompare(S[0])).slice(0,r).map(([m,S])=>{switch(!0){case(S.type==="create"&&ot(S.oldPath)):return[vt,E.yellowBright(S.oldPath),i,vt,E.yellowBright(m)];case S.type==="create":return[Rr,E.greenBright(m),l];case S.type==="update":return[wr,E.blueBright(m),u];case S.type==="delete":return[Pr,E.redBright(m),c];default:return st(S)}});s.length>r&&d.push([E.gray(N.ellipsis),g`{gray ${s.length-r} more}`,""]);let y;if(s.length>=5){let m=[],S=s.filter(([,b])=>b.type==="create").length;if(S>0){let b=n==="past"?`${S} created`:(0,W.default)("create",S,!0);m.push(g`{greenBright ${b}}`)}let f=s.filter(([,b])=>b.type==="update").length;if(f>0){let b=n==="past"?`${f} updated`:(0,W.default)("update",f,!0);m.push(g`{blueBright ${b}}`)}let h=s.filter(([,b])=>b.type==="delete").length;if(h>0){let b=n==="past"?`${h} deleted`:(0,W.default)("delete",h,!0);m.push(g`{redBright ${b}}`)}y=G`
2
- ${(0,W.default)("change",s.length,!0)} in total. ${m.join(", ")}.
3
- `}return gt({rows:d,footer:y,ensureEmptyLineAbove:!0,ensureEmptyLineAboveBody:!1,ensureEmptyLineAboveFooter:!0,indent:0,...o})},"sprintChanges"),ae=a((e,t)=>{let n=q(e,t);n&&O(n)},"printChanges");p();var Ft=g(`
4
- subscription EnvironmentLogs($query: String!, $start: DateTime, $limit: Int) {
5
- logsSearchV2(query: $query, start: $start, limit: $limit) {
6
- status
7
- data
8
- }
9
- }
10
- `),Rt=g(`
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
- `),qo=g(`
26
- query RemoteFilesVersion {
27
- remoteFilesVersion
28
- }
29
- `),wt=g(`
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
- `),Pt=g(`
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
- `),Ot=g(`
54
- query FileSyncHashes($filesVersion: String) {
55
- fileSyncHashes(filesVersion: $filesVersion) {
56
- filesVersion
57
- hashes
58
- }
59
- }
60
- `),Nt=g(`
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
- `),Yo=g(`
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
- `),zo=g(`
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
- `),Ko=g(`
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
- `),Xo=g(`
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
- `),Zo=g(`
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
- `),es=g(`
159
- mutation CreateEnvironment($environment: EnvironmentInput!) {
160
- createEnvironment(environment: $environment) {
161
- slug
162
- status
163
- }
164
- }
165
- `);p();var kt=w(Fr(),1);p();var Bt=D(ct,e=>(e??="",["true","1"].includes(e.trim().toLowerCase())));var B=a(()=>!at.testLike&&Bt(process.env.CI)?new Date().toISOString():E.gray((0,kt.default)().format("hh:mm:ss A")),"ts");p();p();import Or from"node:assert";var H=class extends Map{static{a(this,"ChangesWithHash")}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)}},U=a((e,{from:t,to:n,existing:r,ignore:o})=>{let s=new H,i=Object.keys(n);for(let[l,u]of Object.entries(t)){if(o?.some(d=>l.startsWith(d)))continue;let c=n[l];c?Y(l,u,c)||(s.set(l,{type:"update",sourceHash:u,targetHash:c}),e.log.trace("file updated",{path:l,sourceHash:u,targetHash:c})):(!l.endsWith("/")||!i.some(d=>d.startsWith(l)))&&(s.set(l,{type:"delete",sourceHash:u}),e.log.trace("file deleted",{path:l,sourceHash:u}))}for(let l of i)if(!o?.some(u=>l.startsWith(u))&&!t[l]){let u=n[l];Or(u,"targetHash should exist"),s.set(l,{type:"create",targetHash:u}),e.log.trace("file created",{path:l,targetHash:u})}return r?Nr(e,{changes:s,existing:r}):s},"getNecessaryChanges"),Nr=a((e,{changes:t,existing:n})=>{let r=new H;for(let[o,s]of t){let i=n[o];if(s.type==="delete"&&!i){e.log.trace("already deleted",{path:o});continue}if(s.type!=="delete"&&i&&Y(o,s.targetHash,i)){e.log.trace("already created or updated",{path:o,existingHash:i,targetHash:s.targetHash});continue}r.set(o,s)}return r},"withoutUnnecessaryChanges"),Y=a((e,t,n)=>t.sha1===n.sha1,"isEqualHash"),Lt=a((e,t,n)=>{for(let[r,o]of Object.entries(t)){let s=n[r];if(!s||!Y(r,o,s))return e.log.debug("hashes are not equal",{path:r,aHash:o,bHash:s}),!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},"isEqualHashes");var Ae=class extends Map{static{a(this,"Conflicts")}},Vt=a(({localChanges:e,environmentChanges:t})=>{let n=new Ae;for(let[r,o]of e){let s=t.get(r);s&&(o.type==="delete"&&s.type==="delete"||"targetHash"in o&&"targetHash"in s&&Y(r,o.targetHash,s.targetHash)||n.set(r,{localChange:o,gadgetChange:s}))}for(let r of n.keys())r.startsWith(".gadget/")&&n.delete(r);return n},"getConflicts"),_e=a(({conflicts:e,changes:t})=>{let n=new H(t);for(let[r]of n)e.has(r)&&n.delete(r);return n},"withoutConflictingChanges"),Dt=a(({conflicts:e})=>{let t=E.greenBright("+ created"),n=E.blueBright("\xB1 updated"),r=E.redBright("- deleted");ft({title:"These files have conflicting changes.",ensureEmptyLineAbove:!0,ensureEmptyLineAboveBody:!0,colAligns:["left","center","center"],headers:["","You","Environment"],rows:Array.from(e.entries()).sort((o,s)=>o[0].localeCompare(s[0])).map(([o,{localChange:s,gadgetChange:i}])=>{switch(!0){case(s.type==="create"&&i.type==="create"):return[o,t,t];case(s.type==="create"&&i.type==="update"):return[o,t,n];case(s.type==="create"&&i.type==="delete"):return[o,t,r];case(s.type==="update"&&i.type==="create"):return[o,n,t];case(s.type==="update"&&i.type==="update"):return[o,n,n];case(s.type==="update"&&i.type==="delete"):return[o,n,r];case(s.type==="delete"&&i.type==="create"):return[o,r,t];case(s.type==="delete"&&i.type==="update"):return[o,r,n];default:throw new Error(`Unexpected conflict: ${s.type} vs ${i.type}`)}})})},"printConflicts");p();var _s=Object.freeze({CANCEL:"cancel",MERGE:"merge",PUSH:"push",PULL:"pull"}),k=Object.freeze({CANCEL:g`Cancel (Ctrl+C)`,LOCAL:g`Keep {underline local} conflicting changes`,ENVIRONMENT:g`Keep {underline environment}'s conflicting changes`}),Cs=a((e,t)=>{if(["local","environment"].includes(e))return k[e.toUpperCase()];if(e==="gadget")return k.ENVIRONMENT;throw new mt(g`
166
- ${t} must be {bold local} or {bold environment}
167
-
168
- {bold EXAMPLES:}
169
- ${t}=local
170
- ${t}=environment
171
- `)},"MergeConflictPreferenceArg");p();p();var yr=w(vn(),1);import{Buffer as xo}from"node:buffer";import Mo from"node:path";import Ze from"node:child_process";import fe from"node:process";p();function Be(e){let t=typeof e=="string"?`
172
- `: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}a(Be,"stripFinalNewline");p();import ie from"node:process";import z from"node:path";import{fileURLToPath as Fn}from"node:url";p();function se(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"}a(se,"pathKey");var ia=a(({cwd:e=ie.cwd(),path:t=ie.env[se()],preferLocal:n=!0,execPath:r=ie.execPath,addExecPath:o=!0}={})=>{let s=e instanceof URL?Fn(e):e,i=z.resolve(s),l=[];return n&&la(l,i),o&&ua(l,r,i),[...l,t].join(z.delimiter)},"npmRunPath"),la=a((e,t)=>{let n;for(;n!==t;)e.push(z.join(t,"node_modules/.bin")),n=t,t=z.resolve(t,"..")},"applyPreferLocal"),ua=a((e,t,n)=>{let r=t instanceof URL?Fn(t):t;e.push(z.resolve(n,r,".."))},"applyExecPath"),Rn=a(({env:e=ie.env,...t}={})=>{e={...e};let n=se({env:e});return t.path=e[n],e[n]=ia(t),e},"npmRunPathEnv");p();p();var pa=a((e,t,n,r)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;let o=Object.getOwnPropertyDescriptor(e,n),s=Object.getOwnPropertyDescriptor(t,n);!ca(o,s)&&r||Object.defineProperty(e,n,s)},"copyProperty"),ca=a(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)},"canCopyProperty"),da=a((e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},"changePrototype"),ya=a((e,t)=>`/* Wrapped ${e}*/
173
- ${t}`,"wrappedToString"),ma=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Sa=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),ga=a((e,t,n)=>{let r=n===""?"":`with ${n.trim()}() `,o=ya.bind(null,r,t.toString());Object.defineProperty(o,"name",Sa),Object.defineProperty(e,"toString",{...ma,value:o})},"changeToString");function ke(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let o of Reflect.ownKeys(t))pa(e,t,o,n);return da(e,t),ga(e,t,r),e}a(ke,"mimicFunction");var le=new WeakMap,wn=a((e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,r=0,o=e.displayName||e.name||"<anonymous>",s=a(function(...i){if(le.set(s,++r),r===1)n=e.apply(this,i),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return n},"onetime");return ke(s,e),le.set(s,r),s},"onetime");wn.callCount=e=>{if(!le.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return le.get(e)};var Pn=wn;p();import Ca from"node:process";p();import{constants as Ea}from"node:os";p();var On=a(()=>{let e=Le-Nn+1;return Array.from({length:e},fa)},"getRealtimeSignals"),fa=a((e,t)=>({name:`SIGRT${t+1}`,number:Nn+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),"getRealtimeSignal"),Nn=34,Le=64;p();import{constants as ha}from"node:os";p();var Bn=[{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 Ve=a(()=>{let e=On();return[...Bn,...e].map(ba)},"getSignals"),ba=a(({name:e,number:t,description:n,action:r,forced:o=!1,standard:s})=>{let{signals:{[e]:i}}=ha,l=i!==void 0;return{name:e,number:l?i:t,description:n,supported:l,action:r,forced:o,standard:s}},"normalizeSignal");var xa=a(()=>{let e=Ve();return Object.fromEntries(e.map(Ma))},"getSignalsByName"),Ma=a(({name:e,number:t,description:n,supported:r,action:o,forced:s,standard:i})=>[e,{name:e,number:t,description:n,supported:r,action:o,forced:s,standard:i}],"getSignalByName"),kn=xa(),Ia=a(()=>{let e=Ve(),t=Le+1,n=Array.from({length:t},(r,o)=>Aa(o,e));return Object.assign({},...n)},"getSignalsByNumber"),Aa=a((e,t)=>{let n=_a(e,t);if(n===void 0)return{};let{name:r,description:o,supported:s,action:i,forced:l,standard:u}=n;return{[e]:{name:r,number:e,description:o,supported:s,action:i,forced:l,standard:u}}},"getSignalByNumber"),_a=a((e,t)=>{let n=t.find(({name:r})=>Ea.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)},"findSignalByNumber"),qi=Ia();var Ta=a(({timedOut:e,timeout:t,errorCode:n,signal:r,signalDescription:o,exitCode:s,isCanceled:i})=>e?`timed out after ${t} milliseconds`:i?"was canceled":n!==void 0?`failed with ${n}`:r!==void 0?`was killed with ${r} (${o})`:s!==void 0?`failed with exit code ${s}`:"failed","getErrorPrefix"),K=a(({stdout:e,stderr:t,all:n,error:r,signal:o,exitCode:s,command:i,escapedCommand:l,timedOut:u,isCanceled:c,killed:d,parsed:{options:{timeout:y,cwd:m=Ca.cwd()}}})=>{s=s===null?void 0:s,o=o===null?void 0:o;let S=o===void 0?void 0:kn[o].description,f=r&&r.code,b=`Command ${Ta({timedOut:u,timeout:y,errorCode:f,signal:o,signalDescription:S,exitCode:s,isCanceled:c})}: ${i}`,C=Object.prototype.toString.call(r)==="[object Error]",M=C?`${b}
174
- ${r.message}`:b,T=[M,t,e].filter(Boolean).join(`
175
- `);return C?(r.originalMessage=r.message,r.message=T):r=new Error(T),r.shortMessage=M,r.command=i,r.escapedCommand=l,r.exitCode=s,r.signal=o,r.signalDescription=S,r.stdout=e,r.stderr=t,r.cwd=m,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!u,r.isCanceled=c,r.killed=d&&!u,r},"makeError");p();var ue=["stdin","stdout","stderr"],va=a(e=>ue.some(t=>e[t]!==void 0),"hasAlias"),Ln=a(e=>{if(!e)return;let{stdio:t}=e;if(t===void 0)return ue.map(r=>e[r]);if(va(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${ue.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,ue.length);return Array.from({length:n},(r,o)=>t[o])},"normalizeStdio");p();import Fa from"node:os";var Ra=1e3*5,Vn=a((e,t="SIGTERM",n={})=>{let r=e(t);return wa(e,t,n,r),r},"spawnedKill"),wa=a((e,t,n,r)=>{if(!Pa(t,n,r))return;let o=Na(n),s=setTimeout(()=>{e("SIGKILL")},o);s.unref&&s.unref()},"setKillTimeout"),Pa=a((e,{forceKillAfterTimeout:t},n)=>Oa(e)&&t!==!1&&n,"shouldForceKill"),Oa=a(e=>e===Fa.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM","isSigterm"),Na=a(({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Ra;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},"getForceKillAfterTimeout"),Dn=a((e,t)=>{e.kill()&&(t.isCanceled=!0)},"spawnedCancel"),Ba=a((e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},"timeoutKill"),Gn=a((e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let o,s=new Promise((l,u)=>{o=setTimeout(()=>{Ba(e,n,u)},t)}),i=r.finally(()=>{clearTimeout(o)});return Promise.race([s,i])},"setupTimeout"),Hn=a(({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})`)},"validateTimeout"),Un=a(async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;let o=yt(()=>{e.kill()});return r.finally(()=>{o()})},"setExitHandler");p();import{createWriteStream as ka}from"node:fs";import{ChildProcess as La}from"node:child_process";p();function pe(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}a(pe,"isStream");function De(e){return pe(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}a(De,"isWritableStream");var Va=a(e=>e instanceof La&&typeof e.then=="function","isExecaChildProcess"),Ge=a((e,t,n)=>{if(typeof n=="string")return e[t].pipe(ka(n)),e;if(De(n))return e[t].pipe(n),e;if(!Va(n))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!De(n.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(n.stdin),n},"pipeToTarget"),$n=a(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"))},"addPipeMethods");p();import{createReadStream as ro,readFileSync as ao}from"node:fs";import{setTimeout as oo}from"node:timers/promises";p();p();p();var X=a(async(e,{init:t,convertChunk:n,getSize:r,truncateChunk:o,addChunk:s,getFinalChunk:i,finalize:l},{maxBuffer:u=Number.POSITIVE_INFINITY}={})=>{if(!Ga(e))throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");let c=t();c.length=0;try{for await(let d of e){let y=Ha(d),m=n[y](d,c);Jn({convertedChunk:m,state:c,getSize:r,truncateChunk:o,addChunk:s,maxBuffer:u})}return Da({state:c,convertChunk:n,getSize:r,truncateChunk:o,addChunk:s,getFinalChunk:i,maxBuffer:u}),l(c)}catch(d){throw d.bufferedData=l(c),d}},"getStreamContents"),Da=a(({state:e,getSize:t,truncateChunk:n,addChunk:r,getFinalChunk:o,maxBuffer:s})=>{let i=o(e);i!==void 0&&Jn({convertedChunk:i,state:e,getSize:t,truncateChunk:n,addChunk:r,maxBuffer:s})},"appendFinalChunk"),Jn=a(({convertedChunk:e,state:t,getSize:n,truncateChunk:r,addChunk:o,maxBuffer:s})=>{let i=n(e),l=t.length+i;if(l<=s){Qn(e,t,o,l);return}let u=r(e,s-t.length);throw u!==void 0&&Qn(u,t,o,s),new ce},"appendChunk"),Qn=a((e,t,n,r)=>{t.contents=n(e,t,r),t.length=r},"addNewChunk"),Ga=a(e=>typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function","isAsyncIterable"),Ha=a(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=jn.call(e);return n==="[object ArrayBuffer]"?"arrayBuffer":n==="[object DataView]"?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&jn.call(e.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},"getChunkType"),{toString:jn}=Object.prototype,ce=class extends Error{static{a(this,"MaxBufferError")}name="MaxBufferError";constructor(){super("maxBuffer exceeded")}};p();var He=a(e=>e,"identity"),Ue=a(()=>{},"noop"),$e=a(({contents:e})=>e,"getContentsProp"),de=a(e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},"throwObjectStream"),ye=a(e=>e.length,"getLengthProp");p();async function Qe(e,t){return X(e,za,t)}a(Qe,"getStreamAsArrayBuffer");var Ua=a(()=>({contents:new ArrayBuffer(0)}),"initArrayBuffer"),$a=a(e=>Qa.encode(e),"useTextEncoder"),Qa=new TextEncoder,Wn=a(e=>new Uint8Array(e),"useUint8Array"),qn=a(e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),"useUint8ArrayWithOffset"),ja=a((e,t)=>e.slice(0,t),"truncateArrayBufferChunk"),Ja=a((e,{contents:t,length:n},r)=>{let o=Kn()?qa(t,r):Wa(t,r);return new Uint8Array(o).set(e,n),o},"addArrayBufferChunk"),Wa=a((e,t)=>{if(t<=e.byteLength)return e;let n=new ArrayBuffer(zn(t));return new Uint8Array(n).set(new Uint8Array(e),0),n},"resizeArrayBufferSlow"),qa=a((e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let n=new ArrayBuffer(t,{maxByteLength:zn(t)});return new Uint8Array(n).set(new Uint8Array(e),0),n},"resizeArrayBuffer"),zn=a(e=>Yn**Math.ceil(Math.log(e)/Math.log(Yn)),"getNewContentsLength"),Yn=2,Ya=a(({contents:e,length:t})=>Kn()?e:e.slice(0,t),"finalizeArrayBuffer"),Kn=a(()=>"resize"in ArrayBuffer.prototype,"hasArrayBufferResize"),za={init:Ua,convertChunk:{string:$a,buffer:Wn,arrayBuffer:Wn,dataView:qn,typedArray:qn,others:de},getSize:ye,truncateChunk:ja,addChunk:Ja,getFinalChunk:Ue,finalize:Ya};p();async function me(e,t){if(!("Buffer"in globalThis))throw new Error("getStreamAsBuffer() is only supported in Node.js");try{return Xn(await Qe(e,t))}catch(n){throw n.bufferedData!==void 0&&(n.bufferedData=Xn(n.bufferedData)),n}}a(me,"getStreamAsBuffer");var Xn=a(e=>globalThis.Buffer.from(e),"arrayBufferToNodeBuffer");p();async function je(e,t){return X(e,to,t)}a(je,"getStreamAsString");var Ka=a(()=>({contents:"",textDecoder:new TextDecoder}),"initString"),Se=a((e,{textDecoder:t})=>t.decode(e,{stream:!0}),"useTextDecoder"),Xa=a((e,{contents:t})=>t+e,"addStringChunk"),Za=a((e,t)=>e.slice(0,t),"truncateStringChunk"),eo=a(({textDecoder:e})=>{let t=e.decode();return t===""?void 0:t},"getFinalStringChunk"),to={init:Ka,convertChunk:{string:He,buffer:Se,arrayBuffer:Se,dataView:Se,typedArray:Se,others:de},getSize:ye,truncateChunk:Za,addChunk:Xa,getFinalChunk:eo,finalize:$e};var tr=w(er(),1);var nr=a(e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},"validateInputOptions"),so=a(({input:e,inputFile:t})=>typeof t!="string"?e:(nr(e),ao(t)),"getInputSync"),rr=a(e=>{let t=so(e);if(pe(t))throw new TypeError("The `input` option cannot be a stream in sync mode");return t},"handleInputSync"),io=a(({input:e,inputFile:t})=>typeof t!="string"?e:(nr(e),ro(t)),"getInput"),ar=a((e,t)=>{let n=io(t);n!==void 0&&(pe(n)?n.pipe(e.stdin):e.stdin.end(n))},"handleInput"),or=a((e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;let n=(0,tr.default)();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},"makeAllStream"),Je=a(async(e,t)=>{if(!(!e||t===void 0)){await oo(0),e.destroy();try{return await t}catch(n){return n.bufferedData}}},"getBufferedData"),We=a((e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t==="utf8"||t==="utf-8"?je(e,{maxBuffer:r}):t===null||t==="buffer"?me(e,{maxBuffer:r}):lo(e,r,t)},"getStreamPromise"),lo=a(async(e,t,n)=>(await me(e,{maxBuffer:t})).toString(n),"applyEncoding"),sr=a(async({stdout:e,stderr:t,all:n},{encoding:r,buffer:o,maxBuffer:s},i)=>{let l=We(e,{encoding:r,buffer:o,maxBuffer:s}),u=We(t,{encoding:r,buffer:o,maxBuffer:s}),c=We(n,{encoding:r,buffer:o,maxBuffer:s*2});try{return await Promise.all([i,l,u,c])}catch(d){return Promise.all([{error:d,signal:d.signal,timedOut:d.timedOut},Je(e,l),Je(t,u),Je(n,c)])}},"getSpawnedResult");p();var uo=(async()=>{})().constructor.prototype,po=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(uo,e)]),qe=a((e,t)=>{for(let[n,r]of po){let o=typeof t=="function"?(...s)=>Reflect.apply(r.value,t(),s):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:o})}},"mergePromise"),ir=a(e=>new Promise((t,n)=>{e.on("exit",(r,o)=>{t({exitCode:r,signal:o})}),e.on("error",r=>{n(r)}),e.stdin&&e.stdin.on("error",r=>{n(r)})}),"getSpawnedPromise");p();import{Buffer as co}from"node:buffer";import{ChildProcess as yo}from"node:child_process";var pr=a((e,t=[])=>Array.isArray(t)?[e,...t]:[e],"normalizeArgs"),mo=/^[\w.-]+$/,So=a(e=>typeof e!="string"||mo.test(e)?e:`"${e.replaceAll('"','\\"')}"`,"escapeArg"),Ye=a((e,t)=>pr(e,t).join(" "),"joinCommand"),ze=a((e,t)=>pr(e,t).map(n=>So(n)).join(" "),"getEscapedCommand"),go=/ +/g;var lr=a(e=>{let t=typeof e;if(t==="string")return e;if(t==="number")return String(e);if(t==="object"&&e!==null&&!(e instanceof yo)&&"stdout"in e){let n=typeof e.stdout;if(n==="string")return e.stdout;if(co.isBuffer(e.stdout))return e.stdout.toString();throw new TypeError(`Unexpected "${n}" stdout in template expression`)}throw new TypeError(`Unexpected "${t}" in template expression`)},"parseExpression"),ur=a((e,t,n)=>n||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],"concatTokens"),fo=a(({templates:e,expressions:t,tokens:n,index:r,template:o})=>{let s=o??e.raw[r],i=s.split(go).filter(Boolean),l=ur(n,i,s.startsWith(" "));if(r===t.length)return l;let u=t[r],c=Array.isArray(u)?u.map(d=>lr(d)):[lr(u)];return ur(l,c,s.endsWith(" "))},"parseTemplate"),Ke=a((e,t)=>{let n=[];for(let[r,o]of e.entries())n=fo({templates:e,expressions:t,tokens:n,index:r,template:o});return n},"parseTemplates");p();import{debuglog as ho}from"node:util";import bo from"node:process";var cr=ho("execa").enabled,ge=a((e,t)=>String(e).padStart(t,"0"),"padField"),Eo=a(()=>{let e=new Date;return`${ge(e.getHours(),2)}:${ge(e.getMinutes(),2)}:${ge(e.getSeconds(),2)}.${ge(e.getMilliseconds(),3)}`},"getTimestamp"),Xe=a((e,{verbose:t})=>{t&&bo.stderr.write(`[${Eo()}] ${e}
176
- `)},"logCommand");var Io=1e3*1e3*100,Ao=a(({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:o})=>{let s=t?{...fe.env,...e}:e;return n?Rn({env:s,cwd:r,execPath:o}):s},"getEnv"),mr=a((e,t,n={})=>{let r=yr.default._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:Io,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||fe.cwd(),execPath:fe.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:cr,...n},n.env=Ao(n),n.stdio=Ln(n),fe.platform==="win32"&&Mo.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},"handleArguments"),Z=a((e,t,n)=>typeof t!="string"&&!xo.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?Be(t):t,"handleOutput");function et(e,t,n){let r=mr(e,t,n),o=Ye(e,t),s=ze(e,t);Xe(s,r.options),Hn(r.options);let i;try{i=Ze.spawn(r.file,r.args,r.options)}catch(S){let f=new Ze.ChildProcess,h=Promise.reject(K({error:S,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return qe(f,h),f}let l=ir(i),u=Gn(i,r.options,l),c=Un(i,r.options,u),d={isCanceled:!1};i.kill=Vn.bind(null,i.kill.bind(i)),i.cancel=Dn.bind(null,i,d);let m=Pn(a(async()=>{let[{error:S,exitCode:f,signal:h,timedOut:b},C,M,T]=await sr(i,r.options,c),V=Z(r.options,C),I=Z(r.options,M),R=Z(r.options,T);if(S||f!==0||h!==null){let v=K({error:S,exitCode:f,signal:h,stdout:V,stderr:I,all:R,command:o,escapedCommand:s,parsed:r,timedOut:b,isCanceled:d.isCanceled||(r.options.signal?r.options.signal.aborted:!1),killed:i.killed});if(!r.options.reject)return v;throw v}return{command:o,escapedCommand:s,exitCode:0,stdout:V,stderr:I,all:R,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return ar(i,r.options),i.all=or(i,r.options),$n(i),qe(i,m),i}a(et,"execa");function _o(e,t,n){let r=mr(e,t,n),o=Ye(e,t),s=ze(e,t);Xe(s,r.options);let i=rr(r.options),l;try{l=Ze.spawnSync(r.file,r.args,{...r.options,input:i})}catch(d){throw K({error:d,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:r,timedOut:!1,isCanceled:!1,killed:!1})}let u=Z(r.options,l.stdout,l.error),c=Z(r.options,l.stderr,l.error);if(l.error||l.status!==0||l.signal!==null){let d=K({stdout:u,stderr:c,error:l.error,signal:l.signal,exitCode:l.status,command:o,escapedCommand:s,parsed:r,timedOut:l.error&&l.error.code==="ETIMEDOUT",isCanceled:!1,killed:l.signal!==null});if(!r.options.reject)return d;throw d}return{command:o,escapedCommand:s,exitCode:0,stdout:u,stderr:c,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}}a(_o,"execaSync");var Co=a(({input:e,inputFile:t,stdio:n})=>e===void 0&&t===void 0&&n===void 0?{stdin:"inherit"}:{},"normalizeScriptStdin"),dr=a((e={})=>({preferLocal:!0,...Co(e),...e}),"normalizeScriptOptions");function Sr(e){function t(n,...r){if(!Array.isArray(n))return Sr({...e,...n});let[o,...s]=Ke(n,r);return et(o,s,dr(e))}return a(t,"$"),t.sync=(n,...r)=>{if(!Array.isArray(n))throw new TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");let[o,...s]=Ke(n,r);return _o(o,s,dr(e))},t}a(Sr,"create$");var Du=Sr();var _=w(vr(),1),_r=w(Tr(),1);import ee from"node:assert";import be from"node:path";import wo from"node:process";p();async function he(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:o}={}){return new Promise((s,i)=>{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 l=[],u=[],c=new Map,d=!1,y=!1,m=!1,S=0,f=0,h=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),b=a(()=>{T(o.reason)},"signalListener"),C=a(()=>{o?.removeEventListener("abort",b)},"cleanup"),M=a(I=>{s(I),C()},"resolve"),T=a(I=>{d=!0,y=!0,i(I),C()},"reject");o&&(o.aborted&&T(o.reason),o.addEventListener("abort",b,{once:!0}));let V=a(async()=>{if(y)return;let I=await h.next(),R=f;if(f++,I.done){if(m=!0,S===0&&!y){if(!r&&u.length>0){T(new AggregateError(u));return}if(y=!0,c.size===0){M(l);return}let v=[];for(let[P,Cr]of l.entries())c.get(P)!==gr&&v.push(Cr);M(v)}return}S++,(async()=>{try{let v=await I.value;if(y)return;let P=await t(v,R);P===gr&&c.set(R,P),l[R]=P,S--,await V()}catch(v){if(r)T(v);else{u.push(v),S--;try{await V()}catch(P){T(P)}}}})()},"next");(async()=>{for(let I=0;I<n;I++){try{await V()}catch(R){T(R);break}if(m||d)break}})()})}a(he,"pMap");var gr=Symbol("skip");p();var Ir=w(xr(),1);p();var vo=Object.prototype.toString,Fo=a(e=>vo.call(e)==="[object Error]","isError"),Ro=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 tt(e){return e&&Fo(e)&&e.name==="TypeError"&&typeof e.message=="string"?e.message==="Load failed"?e.stack===void 0:Ro.has(e.message):!1}a(tt,"isNetworkError");var nt=class extends Error{static{a(this,"AbortError")}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}},Mr=a((e,t,n)=>{let r=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e},"decorateErrorWithCounts");async function rt(e,t){return new Promise((n,r)=>{t={...t},t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.retries??=10;let o=Ir.default.operation(t),s=a(()=>{o.stop(),r(t.signal?.reason)},"abortHandler");t.signal&&!t.signal.aborted&&t.signal.addEventListener("abort",s,{once:!0});let i=a(()=>{t.signal?.removeEventListener("abort",s),o.stop()},"cleanUp");o.attempt(async l=>{try{let u=await e(l);i(),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 nt)throw u.originalError;if(u instanceof TypeError&&!tt(u))throw u;if(Mr(u,l,t),await t.shouldRetry(u)||(o.stop(),r(u)),await t.onFailedAttempt(u),!o.retry(u))throw o.mainError()}catch(c){Mr(c,l,t),i(),r(c)}}})})}a(rt,"pRetry");var j=w(St(),1);p();var Po=10,Oo=10,No=50*1024*1024,Ar=class{constructor(t){this.syncJson=t}static{a(this,"FileSync")}_syncOperations=new Mt({concurrency:1});async hashes(t,{silent:n=!1}={}){let r=n?void 0:J({ensureEmptyLineAbove:!0,content:"Calculating file changes."});try{let[o,{localFilesVersionHashes:s,environmentHashes:i,environmentFilesVersion:l}]=await Promise.all([this.syncJson.directory.hashes(),(async()=>{let h,b,C;if(this.syncJson.filesVersion===0n){let{fileSyncHashes:M}=await this.syncJson.edit.query({query:Ot});C=BigInt(M.filesVersion),b=M.hashes,h={}}else{let{fileSyncComparisonHashes:M}=await this.syncJson.edit.query({query:Nt,variables:{filesVersion:String(this.syncJson.filesVersion)}});h=M.filesVersionHashes.hashes,b=M.latestFilesVersionHashes.hashes,C=BigInt(M.latestFilesVersionHashes.filesVersion)}return{localFilesVersionHashes:h,environmentHashes:b,environmentFilesVersion:C}})()]),u=Lt(t,o,i),c=U(t,{from:s,to:o,existing:i,ignore:[".gadget/"]}),d=U(t,{from:s,to:i,existing:o});!u&&c.size===0&&d.size===0&&(d=U(t,{from:o,to:i}),ee(d.size>0,"expected environmentChanges to have changes"),ee(Array.from(d.keys()).every(h=>h.startsWith(".gadget/")),"expected all environmentChanges to be .gadget/ files")),ee(u||c.size>0||d.size>0,"there must be changes if hashes don't match");let y=U(t,{from:i,to:o,ignore:[".gadget/"]}),m=U(t,{from:o,to:i}),S=d.size>0&&Array.from(d.keys()).every(h=>h.startsWith(".gadget/")),f=c.size>0&&d.size>0&&!S;return r&&(S?r.clear():u?r.succeed(`Your files are up to date. ${B()}`):r.succeed(`Calculated file changes. ${B()}`)),{inSync:u,localFilesVersionHashes:s,localHashes:o,localChanges:c,localChangesToPush:y,environmentHashes:i,environmentChanges:d,environmentChangesToPull:m,environmentFilesVersion:l,onlyDotGadgetFilesChanged:S,bothChanged:f}}catch(o){throw r&&r.fail(),o}}async print(t,{hashes:n}={}){let{inSync:r,localChanges:o,environmentChanges:s,onlyDotGadgetFilesChanged:i,bothChanged:l}=n??await this.hashes(t);r||(o.size>0?ae(t,{changes:o,tense:"past",title:g`Your local files {underline have} changed.`}):O({ensureEmptyLineAbove:!0,content:g`Your local files {underline have not} changed.`}),s.size>0&&!i?ae(t,{changes:s,tense:"past",title:g`Your environment's files {underline have}${l?" also":""} changed.`}):O({ensureEmptyLineAbove:!0,content:g`Your environment's files {underline have not} changed.`}))}async idle(){await this._syncOperations.onIdle()}async mergeChangesWithEnvironment(t,{changes:n,printLocalChangesOptions:r,printEnvironmentChangesOptions:o}){await this._syncOperations.add(async()=>{try{await this._sendChangesToEnvironment(t,{changes:n,printLocalChangesOptions:r})}catch(s){ne(t,s),await this.merge(t,{printEnvironmentChangesOptions:o})}})}subscribeToEnvironmentLogs(t,{onError:n}){let r=Ct(this.syncJson.environment),o=Object.entries(te).filter(([s,i])=>i>=t["--log-level"]).map(([s])=>s.toLowerCase()).join("|");return this.syncJson.edit.subscribe({subscription:Ft,variables:a(()=>({query:`{environment_id="${this.syncJson.environment.id}"} | json | level=~"${o}"${t["--my-logs"]?' | source="user"':""}`,start:new Date}),"variables"),onError:n,onData:a(({logsSearchV2:s})=>{for(let i of s.data.messages){let l=JSON.parse(i[1]),{msg:u,name:c,level:d,...y}=l;r(d,c,u,{...y},new Date(Number(i[0])/1e6))}},"onData")})}subscribeToEnvironmentChanges(t,{beforeChanges:n=xe,printEnvironmentChangesOptions:r,afterChanges:o=xe,onError:s}){return this.syncJson.edit.subscribe({subscription:Rt,variables:a(()=>({localFilesVersion:String(this.syncJson.filesVersion)}),"variables"),onError:s,onData:a(({remoteFileSyncEvents:{changed:i,deleted:l,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:i.map(y=>y.path),deleted:l.map(y=>y.path)});let c=a(y=>{let m=this.syncJson.directory.ignores(y.path);return m&&t.log.warn("skipping received change because file is ignored",{path:y.path}),!m},"filterIgnoredFiles");if(i=i.filter(c),l=l.filter(c),i.length===0&&l.length===0){await this.syncJson.save(u);return}await n({changed:i.map(y=>y.path),deleted:l.map(y=>y.path)});let d=await this.writeToLocalFilesystem(t,{filesVersion:u,files:i,delete:l.map(y=>y.path),printEnvironmentChangesOptions:{tense:"past",ensureEmptyLineAbove:!0,title:G`{greenBright ${N.tick}} Pulled ${(0,j.default)("file",i.length+l.length)}. ${B()}`,limit:5,...r}});await o({changes:d})}).catch(s)},"onData")})}async merge(t,{hashes:n,prefer:r,maxAttempts:o=Po,printLocalChangesOptions:s,printEnvironmentChangesOptions:i,silent:l}={}){let u=0;do{if(u===0?n??=await this.hashes(t,{silent:l}):n=await this.hashes(t,{silent:l}),n.inSync){this._syncOperations.clear(),t.log.info("filesystem in sync"),await this.syncJson.save(n.environmentFilesVersion);return}u+=1,t.log.info("merging",{attempt:u,...n});try{await this._merge(t,{hashes:n,prefer:r,printLocalChangesOptions:s,printEnvironmentChangesOptions:i})}catch(c){ne(t,c)}}while(u<o);throw new Et(o)}async push(t,{command:n,hashes:r,maxAttempts:o=Oo,printLocalChangesOptions:s}){let i=0;do{let{localChangesToPush:l,environmentFilesVersion:u}=r??await this.hashes(t);if(l.size===0)return;i+=1;try{await this._sendChangesToEnvironment(t,{changes:l,expectedFilesVersion:u,printLocalChangesOptions:s});return}catch(c){if(ne(t,c),r=await this.hashes(t,{silent:!0}),r.environmentFilesVersion>u+1n)return;if(r.onlyDotGadgetFilesChanged)continue;throw new Me(g`
177
- Your environment's files have changed since we last checked.
178
-
179
- Please re-run "ggt ${n}" to see the changes and try again.
180
- `)}}while(i<o);throw new xt(o,n)}async pull(t,{hashes:n,force:r,printEnvironmentChangesOptions:o}={}){let{localChanges:s,environmentChangesToPull:i,environmentFilesVersion:l}=n??await this.hashes(t);ee(i.size>0,"cannot pull if there are no changes"),s.size>0&&!r&&await _t(g`
181
- Are you sure you want to {underline discard} your local changes?
182
- `),await this._getChangesFromEnvironment(t,{changes:i,filesVersion:l,printEnvironmentChangesOptions:o})}async writeToLocalFilesystem(t,n){let r=BigInt(n.filesVersion);ee(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(i=>i.path),delete:n.delete});let o=new re,s=new Set;for(let i of n.delete.sort().reverse()){let l=be.dirname(i);for(;l!==".";)s.add(this.syncJson.directory.normalize(l,!0)),l=be.dirname(l);let u=this.syncJson.directory.absolute(i),c=this.syncJson.directory.absolute(".gadget/backup",this.syncJson.directory.relative(i));await rt(async()=>{try{await _.default.remove(c),await _.default.move(u,c),o.set(i,{type:"delete"})}catch(d){if(Ee(d))return;if(lt(d)||ut(d)){let y=be.dirname(c);for(;y!==this.syncJson.directory.absolute(".gadget/backup");)(await _.default.stat(y)).isDirectory()||(t.log.debug("removing file in the way of backup path",{currentPath:u,backupPath:c,file:y}),await _.default.remove(y)),y=be.dirname(y)}throw d}},{retries:5,minTimeout:(0,_r.default)("100ms"),onFailedAttempt:a(d=>{t.log.warn("failed to move file to backup",{error:d,currentPath:u,backupPath:c})},"onFailedAttempt")})}for(let i of Array.from(s.values()).sort().reverse())if(!n.files.some(l=>l.path===i))try{await _.default.rmdir(this.syncJson.directory.absolute(i)),o.set(i,{type:"delete"})}catch(l){if(Ee(l)||it(l))continue;throw l}if(await he(n.files,async i=>{let l=this.syncJson.directory.absolute(i.path);await _.default.pathExists(l)?i.path.endsWith("/")||o.set(i.path,{type:"update"}):o.set(i.path,{type:"create"}),i.path.endsWith("/")?await _.default.ensureDir(l):await _.default.outputFile(l,Buffer.from(i.content,i.encoding)),It&&await _.default.chmod(l,i.mode&511),l===this.syncJson.directory.absolute(".ignore")&&await this.syncJson.directory.loadIgnoreFile()}),await this.syncJson.save(String(r)),n.spinner?.clear(),ae(t,{changes:o,tense:"past",title:g`{greenBright ${N.arrowDown}} Pulled ${(0,j.default)("file",o.size)}. ${B()}`,...n.printEnvironmentChangesOptions}),o.has("yarn.lock")){let i=J({ensureEmptyLineAbove:!0,content:'Running "yarn install --check-files"'});try{await et("yarn",["install","--check-files"],{cwd:this.syncJson.directory.path}),i.succeed(`Ran "yarn install --check-files" ${B()}`)}catch(l){i.fail(),t.log.error("yarn install failed",{error:l});let u=pt(l).message;u&&O({ensureEmptyLineAbove:!0,indent:2,content:u})}}return o}async _merge(t,{hashes:{localChanges:n,environmentChanges:r,environmentFilesVersion:o},prefer:s,printLocalChangesOptions:i,printEnvironmentChangesOptions:l}){let u=Vt({localChanges:n,environmentChanges:r});if(u.size>0)switch(t.log.debug("conflicts detected",{conflicts:u}),s||(Dt({conflicts:u}),s=await Tt({choices:Object.values(k),content:E.bold("How should we resolve these conflicts?")})),s){case k.CANCEL:{wo.exit(0);break}case k.LOCAL:{r=_e({conflicts:u,changes:r});break}case k.ENVIRONMENT:{n=_e({conflicts:u,changes:n});break}}r.size>0&&await this._getChangesFromEnvironment(t,{changes:r,filesVersion:o,printEnvironmentChangesOptions:l}),n.size>0&&await this._sendChangesToEnvironment(t,{changes:n,expectedFilesVersion:o,printLocalChangesOptions:i})}async _getChangesFromEnvironment(t,{filesVersion:n,changes:r,printEnvironmentChangesOptions:o}){t.log.debug("getting changes from gadget",{filesVersion:n,changes:r});let s=r.created(),i=r.updated(),l=J({ensureEmptyLineAbove:!0,content:q(t,{changes:r,tense:"present",title:g`Pulling ${(0,j.default)("file",r.size)}.`,...o})});try{let u=[];if(s.length>0||i.length>0){let{fileSyncFiles:c}=await this.syncJson.edit.query({query:Pt,variables:{paths:[...s,...i],filesVersion:String(n),encoding:"base64"}});u=c.files}await this.writeToLocalFilesystem(t,{filesVersion:n,files:u,delete:r.deleted(),spinner:l,printEnvironmentChangesOptions:o})}catch(u){throw l.fail(),u}}async _sendChangesToEnvironment(t,{changes:n,expectedFilesVersion:r=this.syncJson.filesVersion,printLocalChangesOptions:o}){t.log.debug("sending changes to gadget",{expectedFilesVersion:r,changes:n});let s=[],i=[];if(await he(n,async([c,d])=>{if(d.type==="delete"){i.push({path:c});return}let y=this.syncJson.directory.absolute(c),m;try{m=await _.default.stat(y)}catch(h){At(h),t.log.debug("skipping change because file doesn't exist",{path:c});return}let S="";m.isFile()&&(S=await _.default.readFile(y,"base64"));let f;d.type==="create"&&d.oldPath&&(f=d.oldPath),s.push({content:S,oldPath:f,path:c,mode:m.mode,encoding:"base64"})}),s.length===0&&i.length===0){t.log.debug("skipping send because there are no changes");return}if(s.map(c=>c.content.length).reduce((c,d)=>c+d,0)>No)throw new Me(g`
183
- {underline Your file changes are too large to push.}
184
-
185
- Run "ggt status" to see your changes and consider
186
- ignoring some files or pushing in smaller batches.
187
- `);let u=J({ensureEmptyLineAbove:!0,content:q(t,{changes:n,tense:"present",title:G`Pushing ${(0,j.default)("file",s.length+i.length)}. ${N.arrowRight}`,...o})});try{let{publishFileSyncEvents:{remoteFilesVersion:c,problems:d}}=await this.syncJson.edit.mutate({mutation:wt,variables:{input:{expectedRemoteFilesVersion:String(r),changed:s,deleted:i}},http:{retry:{methods:["POST"],calculateDelay:a(({error:y,computedValue:m})=>Ie(y.response?.body)?0:m,"calculateDelay")}}});if(BigInt(c)>r+1n)throw new Error("Files version mismatch");await this.syncJson.save(c),u.succeed(q(t,{changes:n,tense:"past",title:G`Pushed ${(0,j.default)("file",s.length+i.length)}. ${N.arrowRight} ${B()}`,...o})),d.length>0&&O({ensureEmptyLineAbove:!0,content:g`
188
- {red Gadget has detected the following fatal errors with your files:}
189
-
190
- ${ht({problems:bt(d),showFileTypes:!1,indent:12})}
191
-
192
- {red Your app will not be operational until all fatal errors are fixed.}
193
- `})}catch(c){throw Ie(c)?u.clear():u.fail(),c}}};export{re as a,wr as b,Pr as c,an as d,Yo as e,zo as f,Ko as g,Xo as h,Zo as i,es as j,B as k,Vt as l,Dt as m,_s as n,Cs as o,Ar as p};
194
- //# sourceMappingURL=chunk-M6L2X3GX.js.map