@gadgetinc/ggt 1.0.6 → 1.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 (90) hide show
  1. package/README.md +1 -0
  2. package/dist/add-DCE6CV2D.js +78 -0
  3. package/dist/add-DCE6CV2D.js.map +7 -0
  4. package/dist/chunk-3Q3GPB6Z.js +2 -0
  5. package/dist/chunk-3Q3GPB6Z.js.map +7 -0
  6. package/dist/chunk-6FBP46EB.js +18 -0
  7. package/dist/chunk-6FBP46EB.js.map +7 -0
  8. package/dist/chunk-AB4I3BMD.js +33 -0
  9. package/dist/{chunk-BOQUW6DS.js.map → chunk-AB4I3BMD.js.map} +3 -3
  10. package/dist/{chunk-GACF5GYF.js → chunk-BYMG3KOL.js} +4 -6
  11. package/dist/{chunk-GACF5GYF.js.map → chunk-BYMG3KOL.js.map} +2 -2
  12. package/dist/chunk-BZSAGSV3.js +8 -0
  13. package/dist/{chunk-APHXRHNI.js.map → chunk-BZSAGSV3.js.map} +3 -3
  14. package/dist/chunk-CXYA3RFX.js +117 -0
  15. package/dist/chunk-CXYA3RFX.js.map +7 -0
  16. package/dist/chunk-DVKNBG4P.js +180 -0
  17. package/dist/chunk-DVKNBG4P.js.map +7 -0
  18. package/dist/chunk-EFU2JNKY.js +9 -0
  19. package/dist/chunk-EFU2JNKY.js.map +7 -0
  20. package/dist/chunk-KGOVR5SK.js +67 -0
  21. package/dist/chunk-KGOVR5SK.js.map +7 -0
  22. package/dist/chunk-KMCOZJPU.js +12 -0
  23. package/dist/chunk-KMCOZJPU.js.map +7 -0
  24. package/dist/{chunk-Q5N5L6H3.js → chunk-M4PNFOA5.js} +2 -2
  25. package/dist/chunk-M4PNFOA5.js.map +7 -0
  26. package/dist/chunk-OLKWG2EP.js +12 -0
  27. package/dist/chunk-OLKWG2EP.js.map +7 -0
  28. package/dist/{chunk-ERYUXLYS.js → chunk-THZRTDWW.js} +8 -8
  29. package/dist/{chunk-ERYUXLYS.js.map → chunk-THZRTDWW.js.map} +3 -3
  30. package/dist/context-L5YSPF3X.js +2 -0
  31. package/dist/deploy-PBJEUYGH.js +25 -0
  32. package/dist/deploy-PBJEUYGH.js.map +7 -0
  33. package/dist/{dev-VHJ52BEA.js → dev-OT7PEKUN.js} +9 -11
  34. package/dist/{dev-VHJ52BEA.js.map → dev-OT7PEKUN.js.map} +3 -3
  35. package/dist/esm-GJ7RK6IC.js +34 -0
  36. package/dist/esm-GJ7RK6IC.js.map +7 -0
  37. package/dist/list-CC5PICEF.js +11 -0
  38. package/dist/list-CC5PICEF.js.map +7 -0
  39. package/dist/login-SE7XIHRW.js +2 -0
  40. package/dist/logout-B3YAZN6R.js +7 -0
  41. package/dist/{logout-HX6MM4S6.js.map → logout-B3YAZN6R.js.map} +3 -3
  42. package/dist/main.js +6 -8
  43. package/dist/main.js.map +3 -3
  44. package/dist/{open-GEEWPSF4.js → open-OVK3YL4O.js} +3 -3
  45. package/dist/{open-GEEWPSF4.js.map → open-OVK3YL4O.js.map} +2 -2
  46. package/dist/{pull-T2Q4M4UN.js → pull-SLPBOP6Z.js} +3 -5
  47. package/dist/{pull-T2Q4M4UN.js.map → pull-SLPBOP6Z.js.map} +2 -2
  48. package/dist/push-3HGVWCKW.js +2 -0
  49. package/dist/push-3HGVWCKW.js.map +7 -0
  50. package/dist/status-7GLNL7D5.js +14 -0
  51. package/dist/{status-5VZH3KXH.js.map → status-7GLNL7D5.js.map} +1 -1
  52. package/dist/user-C34J52UL.js +2 -0
  53. package/dist/user-C34J52UL.js.map +7 -0
  54. package/dist/{version-OF4TQ2K6.js → version-AUI4NRDS.js} +2 -2
  55. package/dist/whoami-TXO7VJXC.js +7 -0
  56. package/dist/{whoami-V3XD27QH.js.map → whoami-TXO7VJXC.js.map} +2 -2
  57. package/package.json +20 -20
  58. package/dist/add-JIIVAOWH.js +0 -84
  59. package/dist/add-JIIVAOWH.js.map +0 -7
  60. package/dist/chunk-APHXRHNI.js +0 -8
  61. package/dist/chunk-AQRCAWW4.js +0 -24
  62. package/dist/chunk-AQRCAWW4.js.map +0 -7
  63. package/dist/chunk-BOQUW6DS.js +0 -33
  64. package/dist/chunk-CKSTMUDN.js +0 -17
  65. package/dist/chunk-CKSTMUDN.js.map +0 -7
  66. package/dist/chunk-GBCD37US.js +0 -57
  67. package/dist/chunk-GBCD37US.js.map +0 -7
  68. package/dist/chunk-P2XPMNL6.js +0 -183
  69. package/dist/chunk-P2XPMNL6.js.map +0 -7
  70. package/dist/chunk-PSRZ5JH5.js +0 -27
  71. package/dist/chunk-PSRZ5JH5.js.map +0 -7
  72. package/dist/chunk-Q5N5L6H3.js.map +0 -7
  73. package/dist/chunk-RJOIQTYZ.js +0 -126
  74. package/dist/chunk-RJOIQTYZ.js.map +0 -7
  75. package/dist/chunk-XCHCCJJZ.js +0 -2
  76. package/dist/chunk-XCHCCJJZ.js.map +0 -7
  77. package/dist/deploy-KMGAGIDE.js +0 -30
  78. package/dist/deploy-KMGAGIDE.js.map +0 -7
  79. package/dist/esm-BL3OM5UJ.js +0 -33
  80. package/dist/esm-BL3OM5UJ.js.map +0 -7
  81. package/dist/list-5E3R22IC.js +0 -11
  82. package/dist/list-5E3R22IC.js.map +0 -7
  83. package/dist/login-3DL45WY7.js +0 -2
  84. package/dist/logout-HX6MM4S6.js +0 -7
  85. package/dist/push-LUW25FYF.js +0 -2
  86. package/dist/status-5VZH3KXH.js +0 -14
  87. package/dist/whoami-V3XD27QH.js +0 -7
  88. /package/dist/{login-3DL45WY7.js.map → context-L5YSPF3X.js.map} +0 -0
  89. /package/dist/{push-LUW25FYF.js.map → login-SE7XIHRW.js.map} +0 -0
  90. /package/dist/{version-OF4TQ2K6.js.map → version-AUI4NRDS.js.map} +0 -0
@@ -1,126 +0,0 @@
1
- import{a as Ji,b as J,d as fr,e as dr,f as re}from"./chunk-BOQUW6DS.js";import{a as lr,c as ee}from"./chunk-D2K5XPNJ.js";import{a as cr}from"./chunk-Q5N5L6H3.js";import{a as mr,b as hr,i as gr}from"./chunk-PSRZ5JH5.js";import{b as st,e as pt,f as ft,i as z}from"./chunk-CKSTMUDN.js";import{c as Et,i as lt,o as pr}from"./chunk-AQRCAWW4.js";import{D as ir,E as zi,I as or,K as ar,N as Pt,R as ur,U as T,V as R,W as H,b as Q,e as I,g as xt,h as Ze,l as tr,m as er,t as rr,u as nr,v as sr,z as ct}from"./chunk-GBCD37US.js";import{a as qi,c as te,e as nt,g as O}from"./chunk-5WC5D4WL.js";var wr=te(j=>{"use strict";O();var Qi=j&&j.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(j,"__esModule",{value:!0});var Hi=qi("fs"),Yi=Qi(cr()),it=Yi.default("@kwsites/file-exists");function Ki(t,e,r){it("checking %s",t);try{let n=Hi.statSync(t);return n.isFile()&&e?(it("[OK] path represents a file"),!0):n.isDirectory()&&r?(it("[OK] path represents a directory"),!0):(it("[FAIL] path represents something other than a file or directory"),!1)}catch(n){if(n.code==="ENOENT")return it("[FAIL] path is not accessible: %o",n),!1;throw it("[FATAL] %o",n),n}}function Xi(t,e=j.READABLE){return Ki(t,(e&j.FILE)>0,(e&j.FOLDER)>0)}j.exists=Xi;j.FILE=1;j.FOLDER=2;j.READABLE=j.FILE+j.FOLDER});var Tr=te(Rt=>{"use strict";O();function Zi(t){for(var e in t)Rt.hasOwnProperty(e)||(Rt[e]=t[e])}Object.defineProperty(Rt,"__esModule",{value:!0});Zi(wr())});var ue=te(Z=>{"use strict";O();Object.defineProperty(Z,"__esModule",{value:!0});Z.createDeferred=Z.deferred=void 0;function ae(){let t,e,r="pending";return{promise:new Promise((s,i)=>{t=s,e=i}),done(s){r==="pending"&&(r="resolved",t(s))},fail(s){r==="pending"&&(r="rejected",e(s))},get fulfilled(){return r!=="pending"},get status(){return r}}}Z.deferred=ae;Z.createDeferred=ae;Z.default=ae});O();var yr=nt(Ji(),1);var Tc=Object.freeze({Fatal:"Fatal",Error:"Error",Warning:"Warning",Info:"Info"}),ne=({problems:t,showFileTypes:e,...r})=>{let n="";for(let[s,i]of Object.entries(t)){n+=R(""),n+=R`• {cyan ${s}} {redBright ${(0,yr.default)("problem",i.length,!0)}}`;for(let o of i){let[a,...l]=o.message.split(`
2
- `);n+=T` {red ✖} `,(e??o.type==="SourceFile")&&(n+=T`${Vi(s)} `),n+=T(a);for(let p of l)n+=R(""),n+=T` ${p}`;for(let p of o.labels)n+=T` {dim ${p}}`;n+=R("")}}return R(r)(n)},Sc=t=>{H(ne(t))},Vi=t=>{switch(!0){case rr(t):return Q.yellowBright("JavaScript");case nr(t):return Q.blue("TypeScript");case sr(t):return Q.magenta("Gelly");default:return Q.gray("File")}},xc=t=>{let e={};for(let r of t){let n=r.node?.apiIdentifier??r.node?.name??"Other";e[n]??=[],e[n].push({type:r.node?.type??"Unknown",severity:r.severity,message:r.message,labels:lr(r.nodeLabels?.map(s=>s?.identifier)??[])})}return e},Pc=t=>{let e={};for(let r of t)e[r.path]??=[],e[r.path].push({type:r.type,severity:r.level,message:r.message,labels:[]});return e};O();var vr=class extends ft{isBug=pt.NO;constructor(){super("Yarn not found")}render(){return T`
3
- Yarn must be installed to sync your application. You can install it by running:
4
-
5
- $ npm install --global yarn
6
-
7
- For more information, see: https://classic.yarnpkg.com/en/docs/install
8
- `}},Ot=class extends ft{constructor(r,n){super('The ".gadget/sync.json" file was invalid or not found');this.ctx=r;this.opts=n}isBug=pt.NO;render(){let r=this.ctx.command,n=this.opts.directory.path;switch(r){case"add":case"open":case"status":return T`
9
- A ".gadget/sync.json" file is missing in this directory:
10
-
11
- ${n}
12
-
13
- In order to use "ggt ${r}", you must run it within a directory
14
- that has already been initialized with "ggt dev".
15
- `;case"dev":return T`
16
- A ".gadget/sync.json" file is missing in this directory:
17
-
18
- ${n}
19
-
20
- If you're running "ggt dev" for the first time, we recommend
21
- using a gadget specific directory like this:
22
-
23
- ggt dev ~/gadget/${this.ctx.args["--app"]??"<name>"}
24
-
25
- To use a non-empty directory without a ".gadget/sync.json" file,
26
- run "ggt dev" again with the "--allow-unknown-directory" flag:
27
-
28
- ggt dev ${n} --allow-unknown-directory
29
- `;default:return T`
30
- A ".gadget/sync.json" file is missing in this directory:
31
-
32
- ${n}
33
-
34
- If you're certain you want to use this directory, you can run
35
- "ggt ${r}" again with the "--allow-unknown-directory" flag:
36
-
37
- ggt ${r} --allow-unknown-directory
38
- `}}},br=class extends ft{constructor(r){super(`Failed to synchronize files after ${r} attempts.`);this.attempts=r}isBug=pt.MAYBE;render(){return T`
39
- We merged your local files with your environment's files ${this.attempts} times,
40
- but your local and environment's files still don't match.
41
-
42
- Make sure no one else is editing files on your environment, and try again.
43
- `}},_r=class extends ft{constructor(r){super("This application is not allowed to be deployed due to fatal errors.");this.fatalErrors=r}isBug=pt.MAYBE;render(){let r=R`{red Gadget has detected the following fatal errors with your files:}`;return r+=ne({ensureEmptyLineAbove:!0,problems:this.fatalErrors,showFileTypes:!1}),r+=R({ensureEmptyLineAbove:!0})`{red Please fix these errors and try again.}`,r}},Wi=t=>(t instanceof J&&(t=t.cause),tr(t)&&(t=t.errors),er(t)&&(t=t[0]),Ze(t)&&"message"in t&&xt(t.message)&&t.message.includes("Files version mismatch")),Dc=(t,e)=>{if(Wi(e)){t.log.debug("swallowing files version mismatch",{error:e});return}throw e};O();import kr from"node:assert";import se from"node:process";var oe=t=>(t=lt(t,{ensureEmptyLineAbove:!0}),(e,...r)=>{let n=e;return xt(n)||(n=T(e,...r)),Pt.isInteractive||(H(t)(n),H({ensureEmptyLineAbove:!0})`
44
- Aborting because ggt is not running in an interactive terminal.
45
- `,se.exit(1)),new Promise(s=>{let i=new ie(n,{formatChoice:o=>o,formatSelection:o=>o,...t});i.on("submit",s),i.on("exit",()=>se.exit(0)),i.on("abort",()=>se.exit(0))})}),ie=class extends mr{constructor(r,n){super();this.text=r;this.options=lt(n,{formatChoice:s=>s,formatSelection:s=>s,...n}),this.options.ensureEmptyLineAbove&&(this.text=`
46
- `+this.text),this.render()}cursor=0;optionsPerPage=10;options;get selection(){let r=this.options.choices[this.cursor];return kr(r,`choices[${this.cursor}] is not defined`),r}moveCursor(r){this.cursor=r,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render("Cancel (Ctrl+C)"),this.close()}submit(){this.done=!0,this.aborted=!1,this.value=this.selection,this.fire(),this.render(),this.close()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.options.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.options.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.options.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.options.choices.length),this.render()}_(r,n){if(r===" "){this.submit();return}}render(r){if(this.closed)return;super.render();let n=this.text;if(this.done){Pt.persistPrompt(R`
47
- ${n.trimEnd()} ${this.options.formatChoice(r??this.selection)}
48
- `);return}n+=` ${Q.gray("Use arrow keys to move")}
49
-
50
- `;let s="",{startIndex:i,endIndex:o}=hr(this.cursor,this.options.choices.length,this.optionsPerPage);for(let a=i;a<o;a++){let l;this.cursor===a?l=`${Et.arrowRight} `:a===i&&i>0?l=`${Et.arrowUp} `:a===o-1&&o<this.options.choices.length?l=`${Et.arrowDown} `:l=" ";let p=this.options.choices[a];kr(p,`choices[${a}] is not defined`);let _=this.options.formatChoice(p);this.cursor===a&&(_=Q.blue.underline(_)),s+=`${l}${_}
51
- `}this.options.indent&&(s=ur(s,this.options.indent)),Pt.updatePrompt(n+s)}};O();var Xt=nt(zi(),1);import Kt from"node:assert";import ai from"node:path";O();var Ut=nt(Tr(),1),It=nt(cr(),1),Ls=nt(ue(),1),ot=nt(ue(),1);import{spawn as Uo}from"child_process";import{EventEmitter as sc}from"node:events";var Nt=Object.defineProperty,to=Object.defineProperties,eo=Object.getOwnPropertyDescriptor,ro=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertyNames,Sr=Object.getOwnPropertySymbols,nn=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable,xr=(t,e,r)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,F=(t,e)=>{for(var r in e||(e={}))nn.call(e,r)&&xr(t,r,e[r]);if(Sr)for(var r of Sr(e))no.call(e,r)&&xr(t,r,e[r]);return t},dt=(t,e)=>to(t,ro(e)),c=(t,e)=>function(){return t&&(e=(0,t[Ee(t)[0]])(t=0)),e},so=(t,e)=>function(){return e||(0,t[Ee(t)[0]])((e={exports:{}}).exports,e),e.exports},E=(t,e)=>{for(var r in e)Nt(t,r,{get:e[r],enumerable:!0})},io=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ee(e))!nn.call(t,s)&&s!==r&&Nt(t,s,{get:()=>e[s],enumerable:!(n=eo(e,s))||n.enumerable});return t},S=t=>io(Nt({},"__esModule",{value:!0}),t),ht=(t,e,r)=>new Promise((n,s)=>{var i=l=>{try{a(r.next(l))}catch(p){s(p)}},o=l=>{try{a(r.throw(l))}catch(p){s(p)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,o);a((r=r.apply(t,e)).next())});function oo(...t){let e=new String(t);return Gt.set(e,t),e}function jt(t){return t instanceof String&&Gt.has(t)}function Pr(t){return Gt.get(t)||[]}var Gt,bt=c({"src/lib/args/pathspec.ts"(){"use strict";Gt=new WeakMap}}),W,K=c({"src/lib/errors/git-error.ts"(){"use strict";W=class extends Error{constructor(t,e){super(e),this.task=t,Object.setPrototypeOf(this,new.target.prototype)}}}}),_t,ut=c({"src/lib/errors/git-response-error.ts"(){"use strict";K(),_t=class extends W{constructor(t,e){super(void 0,e||String(t)),this.git=t}}}}),sn,on=c({"src/lib/errors/task-configuration-error.ts"(){"use strict";K(),sn=class extends W{constructor(t){super(void 0,t)}}}});function an(t){return typeof t=="function"?t:rt}function un(t){return typeof t=="function"&&t!==rt}function cn(t,e){let r=t.indexOf(e);return r<=0?[t,""]:[t.substr(0,r),t.substr(r+1)]}function ln(t,e=0){return pn(t)&&t.length>e?t[e]:void 0}function et(t,e=0){if(pn(t)&&t.length>e)return t[t.length-1-e]}function pn(t){return!!(t&&typeof t.length=="number")}function kt(t="",e=!0,r=`
52
- `){return t.split(r).reduce((n,s)=>{let i=e?s.trim():s;return i&&n.push(i),n},[])}function Oe(t,e){return kt(t,!0).map(r=>e(r))}function Re(t){return(0,Ut.exists)(t,Ut.FOLDER)}function b(t,e){return Array.isArray(t)?t.includes(e)||t.push(e):t.add(e),e}function fn(t,e){return Array.isArray(t)&&!t.includes(e)&&t.push(e),t}function qt(t,e){if(Array.isArray(t)){let r=t.indexOf(e);r>=0&&t.splice(r,1)}else t.delete(e);return e}function U(t){return Array.isArray(t)?t:[t]}function mn(t){return t.replace(/[\s-]+(.)/g,(e,r)=>r.toUpperCase())}function hn(t){return U(t).map(String)}function w(t,e=0){if(t==null)return e;let r=parseInt(t,10);return isNaN(r)?e:r}function gt(t,e){let r=[];for(let n=0,s=t.length;n<s;n++)r.push(e,t[n]);return r}function yt(t){return(Array.isArray(t)?Buffer.concat(t):t).toString("utf-8")}function dn(t,e){return Object.assign({},...e.map(r=>r in t?{[r]:t[r]}:{}))}function de(t=0){return new Promise(e=>setTimeout(e,t))}function gn(t){if(t!==!1)return t}var at,rt,wt,Jt=c({"src/lib/utils/util.ts"(){"use strict";at="\0",rt=()=>{},wt=Object.prototype.toString.call.bind(Object.prototype.toString)}});function q(t,e,r){return e(t)?t:arguments.length>2?r:void 0}function Ae(t,e){let r=jt(t)?"string":typeof t;return/number|string|boolean/.test(r)&&(!e||!e.includes(r))}function Ce(t){return!!t&&wt(t)==="[object Object]"}function yn(t){return typeof t=="function"}var Tt,A,vn,Bt,$e,bn=c({"src/lib/utils/argument-filters.ts"(){"use strict";Jt(),bt(),Tt=t=>Array.isArray(t),A=t=>typeof t=="string",vn=t=>Array.isArray(t)&&t.every(A),Bt=t=>A(t)||Array.isArray(t)&&t.every(A),$e=t=>t==null||"number|boolean|function".includes(typeof t)?!1:Array.isArray(t)||typeof t=="string"||typeof t.length=="number"}}),ge,ao=c({"src/lib/utils/exit-codes.ts"(){"use strict";ge=(t=>(t[t.SUCCESS=0]="SUCCESS",t[t.ERROR=1]="ERROR",t[t.NOT_FOUND=-2]="NOT_FOUND",t[t.UNCLEAN=128]="UNCLEAN",t))(ge||{})}}),vt,uo=c({"src/lib/utils/git-output-streams.ts"(){"use strict";vt=class{constructor(t,e){this.stdOut=t,this.stdErr=e}asStrings(){return new vt(this.stdOut.toString("utf8"),this.stdErr.toString("utf8"))}}}}),g,Y,co=c({"src/lib/utils/line-parser.ts"(){"use strict";g=class{constructor(t,e){this.matches=[],this.parse=(r,n)=>(this.resetMatches(),this._regExp.every((s,i)=>this.addMatch(s,i,r(i)))?this.useMatches(n,this.prepareMatches())!==!1:!1),this._regExp=Array.isArray(t)?t:[t],e&&(this.useMatches=e)}useMatches(t,e){throw new Error("LineParser:useMatches not implemented")}resetMatches(){this.matches.length=0}prepareMatches(){return this.matches}addMatch(t,e,r){let n=r&&t.exec(r);return n&&this.pushMatch(e,n),!!n}pushMatch(t,e){this.matches.push(...e.slice(1))}},Y=class extends g{addMatch(t,e,r){return/^remote:\s/.test(String(r))&&super.addMatch(t,e,r)}pushMatch(t,e){(t>0||e.length>1)&&super.pushMatch(t,e)}}}});function _n(...t){let e=process.cwd(),r=Object.assign(F({baseDir:e},kn),...t.filter(n=>typeof n=="object"&&n));return r.baseDir=r.baseDir||e,r.trimmed=r.trimmed===!0,r}var kn,lo=c({"src/lib/utils/simple-git-options.ts"(){"use strict";kn={binary:"git",maxConcurrentProcesses:5,config:[],trimmed:!1}}});function Le(t,e=[]){return Ce(t)?Object.keys(t).reduce((r,n)=>{let s=t[n];return jt(s)?r.push(s):Ae(s,["boolean"])?r.push(n+"="+s):r.push(n),r},e):e}function L(t,e=0,r=!1){let n=[];for(let s=0,i=e<0?t.length:e;s<i;s++)"string|number".includes(typeof t[s])&&n.push(String(t[s]));return Le(De(t),n),r||n.push(...po(t)),n}function po(t){let e=typeof et(t)=="function";return q(et(t,e?1:0),Tt,[])}function De(t){let e=yn(et(t));return q(et(t,e?1:0),Ce)}function x(t,e=!0){let r=an(et(t));return e||un(r)?r:void 0}var fo=c({"src/lib/utils/task-options.ts"(){"use strict";bn(),Jt(),bt()}});function ye(t,e){return t(e.stdOut,e.stdErr)}function M(t,e,r,n=!0){return U(r).forEach(s=>{for(let i=kt(s,n),o=0,a=i.length;o<a;o++){let l=(p=0)=>{if(!(o+p>=a))return i[o+p]};e.some(({parse:p})=>p(l,t))}}),t}var mo=c({"src/lib/utils/task-parser.ts"(){"use strict";Jt()}}),wn={};E(wn,{ExitCodes:()=>ge,GitOutputStreams:()=>vt,LineParser:()=>g,NOOP:()=>rt,NULL:()=>at,RemoteLineParser:()=>Y,append:()=>b,appendTaskOptions:()=>Le,asArray:()=>U,asCamelCase:()=>mn,asFunction:()=>an,asNumber:()=>w,asStringArray:()=>hn,bufferToString:()=>yt,callTaskParser:()=>ye,createInstanceConfig:()=>_n,delay:()=>de,filterArray:()=>Tt,filterFunction:()=>yn,filterHasLength:()=>$e,filterPlainObject:()=>Ce,filterPrimitives:()=>Ae,filterString:()=>A,filterStringArray:()=>vn,filterStringOrStringArray:()=>Bt,filterType:()=>q,first:()=>ln,folderExists:()=>Re,forEachLineWithContent:()=>Oe,getTrailingOptions:()=>L,including:()=>fn,isUserFunction:()=>un,last:()=>et,objectToString:()=>wt,orVoid:()=>gn,parseStringResponse:()=>M,pick:()=>dn,prefixedArray:()=>gt,remove:()=>qt,splitOn:()=>cn,toLinesWithContent:()=>kt,trailingFunctionArgument:()=>x,trailingOptionsArgument:()=>De});var d=c({"src/lib/utils/index.ts"(){"use strict";bn(),ao(),uo(),co(),lo(),fo(),mo(),Jt()}}),Tn={};E(Tn,{CheckRepoActions:()=>ve,checkIsBareRepoTask:()=>xn,checkIsRepoRootTask:()=>Sn,checkIsRepoTask:()=>ho});function ho(t){switch(t){case"bare":return xn();case"root":return Sn()}return{commands:["rev-parse","--is-inside-work-tree"],format:"utf-8",onError:zt,parser:Me}}function Sn(){return{commands:["rev-parse","--git-dir"],format:"utf-8",onError:zt,parser(e){return/^\.(git)?$/.test(e.trim())}}}function xn(){return{commands:["rev-parse","--is-bare-repository"],format:"utf-8",onError:zt,parser:Me}}function go(t){return/(Not a git repository|Kein Git-Repository)/i.test(String(t))}var ve,zt,Me,Pn=c({"src/lib/tasks/check-is-repo.ts"(){"use strict";d(),ve=(t=>(t.BARE="bare",t.IN_TREE="tree",t.IS_REPO_ROOT="root",t))(ve||{}),zt=({exitCode:t},e,r,n)=>{if(t===128&&go(e))return r(Buffer.from("false"));n(e)},Me=t=>t.trim()==="true"}});function yo(t,e){let r=new En(t),n=t?Rn:On;return kt(e).forEach(s=>{let i=s.replace(n,"");r.paths.push(i),(An.test(i)?r.folders:r.files).push(i)}),r}var En,On,Rn,An,vo=c({"src/lib/responses/CleanSummary.ts"(){"use strict";d(),En=class{constructor(t){this.dryRun=t,this.paths=[],this.files=[],this.folders=[]}},On=/^[a-z]+\s*/i,Rn=/^[a-z]+\s+[a-z]+\s*/i,An=/\/$/}}),be={};E(be,{EMPTY_COMMANDS:()=>Vt,adhocExecTask:()=>Cn,configurationErrorTask:()=>D,isBufferTask:()=>Ln,isEmptyTask:()=>Dn,straightThroughBufferTask:()=>$n,straightThroughStringTask:()=>$});function Cn(t){return{commands:Vt,format:"empty",parser:t}}function D(t){return{commands:Vt,format:"empty",parser(){throw typeof t=="string"?new sn(t):t}}}function $(t,e=!1){return{commands:t,format:"utf-8",parser(r){return e?String(r).trim():r}}}function $n(t){return{commands:t,format:"buffer",parser(e){return e}}}function Ln(t){return t.format==="buffer"}function Dn(t){return t.format==="empty"||!t.commands.length}var Vt,P=c({"src/lib/tasks/task.ts"(){"use strict";on(),Vt=[]}}),Mn={};E(Mn,{CONFIG_ERROR_INTERACTIVE_MODE:()=>je,CONFIG_ERROR_MODE_REQUIRED:()=>Be,CONFIG_ERROR_UNKNOWN_OPTION:()=>Ie,CleanOptions:()=>$t,cleanTask:()=>jn,cleanWithOptionsTask:()=>bo,isCleanOptionsArray:()=>_o});function bo(t,e){let{cleanMode:r,options:n,valid:s}=ko(t);return r?s.options?(n.push(...e),n.some(So)?D(je):jn(r,n)):D(Ie+JSON.stringify(t)):D(Be)}function jn(t,e){return{commands:["clean",`-${t}`,...e],format:"utf-8",parser(n){return yo(t==="n",n)}}}function _o(t){return Array.isArray(t)&&t.every(e=>Fe.has(e))}function ko(t){let e,r=[],n={cleanMode:!1,options:!0};return t.replace(/[^a-z]i/g,"").split("").forEach(s=>{wo(s)?(e=s,n.cleanMode=!0):n.options=n.options&&To(r[r.length]=`-${s}`)}),{cleanMode:e,options:r,valid:n}}function wo(t){return t==="f"||t==="n"}function To(t){return/^-[a-z]$/i.test(t)&&Fe.has(t.charAt(1))}function So(t){return/^-[^\-]/.test(t)?t.indexOf("i")>0:t==="--interactive"}var je,Be,Ie,$t,Fe,Bn=c({"src/lib/tasks/clean.ts"(){"use strict";vo(),d(),P(),je="Git clean interactive mode is not supported",Be='Git clean mode parameter ("n" or "f") is required',Ie="Git clean unknown option found in: ",$t=(t=>(t.DRY_RUN="n",t.FORCE="f",t.IGNORED_INCLUDED="x",t.IGNORED_ONLY="X",t.EXCLUDING="e",t.QUIET="q",t.RECURSIVE="d",t))($t||{}),Fe=new Set(["i",...hn(Object.values($t))])}});function xo(t){let e=new Fn;for(let r of In(t))e.addValue(r.file,String(r.key),r.value);return e}function Po(t,e){let r=null,n=[],s=new Map;for(let i of In(t,e))i.key===e&&(n.push(r=i.value),s.has(i.file)||s.set(i.file,[]),s.get(i.file).push(r));return{key:e,paths:Array.from(s.keys()),scopes:s,value:r,values:n}}function Eo(t){return t.replace(/^(file):/,"")}function*In(t,e=null){let r=t.split("\0");for(let n=0,s=r.length-1;n<s;){let i=Eo(r[n++]),o=r[n++],a=e;if(o.includes(`
53
- `)){let l=cn(o,`
54
- `);a=l[0],o=l[1]}yield{file:i,key:a,value:o}}}var Fn,Oo=c({"src/lib/responses/ConfigList.ts"(){"use strict";d(),Fn=class{constructor(){this.files=[],this.values=Object.create(null)}get all(){return this._all||(this._all=this.files.reduce((t,e)=>Object.assign(t,this.values[e]),{})),this._all}addFile(t){if(!(t in this.values)){let e=et(this.files);this.values[t]=e?Object.create(this.values[e]):{},this.files.push(t)}return this.values[t]}addValue(t,e,r){let n=this.addFile(t);n.hasOwnProperty(e)?Array.isArray(n[e])?n[e].push(r):n[e]=[n[e],r]:n[e]=r,this._all=void 0}}}});function ce(t,e){return typeof t=="string"&&_e.hasOwnProperty(t)?t:e}function Ro(t,e,r,n){let s=["config",`--${n}`];return r&&s.push("--add"),s.push(t,e),{commands:s,format:"utf-8",parser(i){return i}}}function Ao(t,e){let r=["config","--null","--show-origin","--get-all",t];return e&&r.splice(1,0,`--${e}`),{commands:r,format:"utf-8",parser(n){return Po(n,t)}}}function Co(t){let e=["config","--list","--show-origin","--null"];return t&&e.push(`--${t}`),{commands:e,format:"utf-8",parser(r){return xo(r)}}}function $o(){return{addConfig(t,e,...r){return this._runTask(Ro(t,e,r[0]===!0,ce(r[1],"local")),x(arguments))},getConfig(t,e){return this._runTask(Ao(t,ce(e,void 0)),x(arguments))},listConfig(...t){return this._runTask(Co(ce(t[0],void 0)),x(arguments))}}}var _e,Nn=c({"src/lib/tasks/config.ts"(){"use strict";Oo(),d(),_e=(t=>(t.system="system",t.global="global",t.local="local",t.worktree="worktree",t))(_e||{})}});function Lo(t){return Gn.has(t)}var le,Gn,Un=c({"src/lib/tasks/diff-name-status.ts"(){"use strict";le=(t=>(t.ADDED="A",t.COPIED="C",t.DELETED="D",t.MODIFIED="M",t.RENAMED="R",t.CHANGED="T",t.UNMERGED="U",t.UNKNOWN="X",t.BROKEN="B",t))(le||{}),Gn=new Set(Object.values(le))}});function Do(...t){return new Jn().param(...t)}function Mo(t){let e=new Set,r={};return Oe(t,n=>{let[s,i,o]=n.split(at);e.add(s),(r[s]=r[s]||[]).push({line:w(i),path:s,preview:o})}),{paths:e,results:r}}function jo(){return{grep(t){let e=x(arguments),r=L(arguments);for(let s of qn)if(r.includes(s))return this._runTask(D(`git.grep: use of "${s}" is not supported.`),e);typeof t=="string"&&(t=Do().param(t));let n=["grep","--null","-n","--full-name",...r,...t];return this._runTask({commands:n,format:"utf-8",parser(s){return Mo(s)}},e)}}}var qn,mt,Er,Jn,zn=c({"src/lib/tasks/grep.ts"(){"use strict";d(),P(),qn=["-h"],mt=Symbol("grepQuery"),Jn=class{constructor(){this[Er]=[]}*[(Er=mt,Symbol.iterator)](){for(let t of this[mt])yield t}and(...t){return t.length&&this[mt].push("--and","(",...gt(t,"-e"),")"),this}param(...t){return this[mt].push(...gt(t,"-e")),this}}}}),Vn={};E(Vn,{ResetMode:()=>Lt,getResetMode:()=>Io,resetTask:()=>Bo});function Bo(t,e){let r=["reset"];return Wn(t)&&r.push(`--${t}`),r.push(...e),$(r)}function Io(t){if(Wn(t))return t;switch(typeof t){case"string":case"undefined":return"soft"}}function Wn(t){return Qn.includes(t)}var Lt,Qn,Hn=c({"src/lib/tasks/reset.ts"(){"use strict";P(),Lt=(t=>(t.MIXED="mixed",t.SOFT="soft",t.HARD="hard",t.MERGE="merge",t.KEEP="keep",t))(Lt||{}),Qn=Array.from(Object.values(Lt))}});function Fo(){return(0,It.default)("simple-git")}function Or(t,e,r){return!e||!String(e).replace(/\s*/,"")?r?(n,...s)=>{t(n,...s),r(n,...s)}:t:(n,...s)=>{t(`%s ${n}`,e,...s),r&&r(n,...s)}}function No(t,e,{namespace:r}){if(typeof t=="string")return t;let n=e&&e.namespace||"";return n.startsWith(r)?n.substr(r.length+1):n||r}function Ne(t,e,r,n=Fo()){let s=t&&`[${t}]`||"",i=[],o=typeof e=="string"?n.extend(e):e,a=No(q(e,A),o,n);return p(r);function l(_,y){return b(i,Ne(t,a.replace(/^[^:]+/,_),y,n))}function p(_){let y=_&&`[${_}]`||"",v=o&&Or(o,y)||rt,h=Or(n,`${s} ${y}`,v);return Object.assign(o?v:h,{label:t,sibling:l,info:h,step:p})}}var Yn=c({"src/lib/git-logger.ts"(){"use strict";d(),It.default.formatters.L=t=>String($e(t)?t.length:"-"),It.default.formatters.B=t=>Buffer.isBuffer(t)?t.toString("utf8"):wt(t)}}),At,ke,Go=c({"src/lib/runners/tasks-pending-queue.ts"(){"use strict";K(),Yn(),At=class{constructor(t="GitExecutor"){this.logLabel=t,this._queue=new Map}withProgress(t){return this._queue.get(t)}createProgress(t){let e=At.getName(t.commands[0]),r=Ne(this.logLabel,e);return{task:t,logger:r,name:e}}push(t){let e=this.createProgress(t);return e.logger("Adding task to the queue, commands = %o",t.commands),this._queue.set(t,e),e}fatal(t){for(let[e,{logger:r}]of Array.from(this._queue.entries()))e===t.task?(r.info("Failed %o",t),r("Fatal exception, any as-yet un-started tasks run through this executor will not be attempted")):r.info("A fatal exception occurred in a previous task, the queue has been purged: %o",t.message),this.complete(e);if(this._queue.size!==0)throw new Error(`Queue size should be zero after fatal: ${this._queue.size}`)}complete(t){this.withProgress(t)&&this._queue.delete(t)}attempt(t){let e=this.withProgress(t);if(!e)throw new W(void 0,"TasksPendingQueue: attempt called for an unknown task");return e.logger("Starting task"),e}static getName(t="empty"){return`task:${t}:${++At.counter}`}},ke=At,ke.counter=0}});function tt(t,e){return{method:ln(t.commands)||"",commands:e}}function qo(t,e){return r=>{e("[ERROR] child process exception %o",r),t.push(Buffer.from(String(r.stack),"ascii"))}}function Rr(t,e,r,n){return s=>{r("%s received %L bytes",e,s),n("%B",s),t.push(s)}}var we,Jo=c({"src/lib/runners/git-executor-chain.ts"(){"use strict";K(),P(),d(),Go(),we=class{constructor(t,e,r){this._executor=t,this._scheduler=e,this._plugins=r,this._chain=Promise.resolve(),this._queue=new ke}get cwd(){return this._cwd||this._executor.cwd}set cwd(t){this._cwd=t}get env(){return this._executor.env}get outputHandler(){return this._executor.outputHandler}chain(){return this}push(t){return this._queue.push(t),this._chain=this._chain.then(()=>this.attemptTask(t))}attemptTask(t){return ht(this,null,function*(){let e=yield this._scheduler.next(),r=()=>this._queue.complete(t);try{let{logger:n}=this._queue.attempt(t);return yield Dn(t)?this.attemptEmptyTask(t,n):this.attemptRemoteTask(t,n)}catch(n){throw this.onFatalException(t,n)}finally{r(),e()}})}onFatalException(t,e){let r=e instanceof W?Object.assign(e,{task:t}):new W(t,e&&String(e));return this._chain=Promise.resolve(),this._queue.fatal(r),r}attemptRemoteTask(t,e){return ht(this,null,function*(){let r=this._plugins.exec("spawn.binary","",tt(t,t.commands)),n=this._plugins.exec("spawn.args",[...t.commands],tt(t,t.commands)),s=yield this.gitResponse(t,r,n,this.outputHandler,e.step("SPAWN")),i=yield this.handleTaskData(t,n,s,e.step("HANDLE"));return e("passing response to task's parser as a %s",t.format),Ln(t)?ye(t.parser,i):ye(t.parser,i.asStrings())})}attemptEmptyTask(t,e){return ht(this,null,function*(){return e("empty task bypassing child process to call to task's parser"),t.parser(this)})}handleTaskData(t,e,r,n){let{exitCode:s,rejection:i,stdOut:o,stdErr:a}=r;return new Promise((l,p)=>{n("Preparing to handle process response exitCode=%d stdOut=",s);let{error:_}=this._plugins.exec("task.error",{error:i},F(F({},tt(t,e)),r));if(_&&t.onError)return n.info("exitCode=%s handling with custom error handler"),t.onError(r,_,y=>{n.info("custom error handler treated as success"),n("custom error returned a %s",wt(y)),l(new vt(Array.isArray(y)?Buffer.concat(y):y,Buffer.concat(a)))},p);if(_)return n.info("handling as error: exitCode=%s stdErr=%s rejection=%o",s,a.length,i),p(_);n.info("retrieving task output complete"),l(new vt(Buffer.concat(o),Buffer.concat(a)))})}gitResponse(t,e,r,n,s){return ht(this,null,function*(){let i=s.sibling("output"),o=this._plugins.exec("spawn.options",{cwd:this.cwd,env:this.env,windowsHide:!0},tt(t,t.commands));return new Promise(a=>{let l=[],p=[];s.info("%s %o",e,r),s("%O",o);let _=this._beforeSpawn(t,r);if(_)return a({stdOut:l,stdErr:p,exitCode:9901,rejection:_});this._plugins.exec("spawn.before",void 0,dt(F({},tt(t,r)),{kill(v){_=v||_}}));let y=Uo(e,r,o);y.stdout.on("data",Rr(l,"stdOut",s,i.step("stdOut"))),y.stderr.on("data",Rr(p,"stdErr",s,i.step("stdErr"))),y.on("error",qo(p,s)),n&&(s("Passing child process stdOut/stdErr to custom outputHandler"),n(e,y.stdout,y.stderr,[...r])),this._plugins.exec("spawn.after",void 0,dt(F({},tt(t,r)),{spawned:y,close(v,h){a({stdOut:l,stdErr:p,exitCode:v,rejection:_||h})},kill(v){y.killed||(_=v,y.kill("SIGINT"))}}))})})}_beforeSpawn(t,e){let r;return this._plugins.exec("spawn.before",void 0,dt(F({},tt(t,e)),{kill(n){r=n||r}})),r}}}}),Kn={};E(Kn,{GitExecutor:()=>Xn});var Xn,zo=c({"src/lib/runners/git-executor.ts"(){"use strict";Jo(),Xn=class{constructor(t,e,r){this.cwd=t,this._scheduler=e,this._plugins=r,this._chain=new we(this,this._scheduler,this._plugins)}chain(){return new we(this,this._scheduler,this._plugins)}push(t){return this._chain.push(t)}}}});function Vo(t,e,r=rt){let n=i=>{r(null,i)},s=i=>{i?.task===t&&r(i instanceof _t?Wo(i):i,void 0)};e.then(n,s)}function Wo(t){let e=n=>{console.warn(`simple-git deprecation notice: accessing GitResponseError.${n} should be GitResponseError.git.${n}, this will no longer be available in version 3`),e=rt};return Object.create(t,Object.getOwnPropertyNames(t.git).reduce(r,{}));function r(n,s){return s in t||(n[s]={enumerable:!1,configurable:!1,get(){return e(s),t.git[s]}}),n}}var Qo=c({"src/lib/task-callback.ts"(){"use strict";ut(),d()}});function Ar(t,e){return Cn(r=>{if(!Re(t))throw new Error(`Git.cwd: cannot change to non-directory "${t}"`);return(e||r).cwd=t})}var Ho=c({"src/lib/tasks/change-working-directory.ts"(){"use strict";d(),P()}});function pe(t){let e=["checkout",...t];return e[1]==="-b"&&e.includes("-B")&&(e[1]=qt(e,"-B")),$(e)}function Yo(){return{checkout(){return this._runTask(pe(L(arguments,1)),x(arguments))},checkoutBranch(t,e){return this._runTask(pe(["-b",t,e,...L(arguments)]),x(arguments))},checkoutLocalBranch(t){return this._runTask(pe(["-b",t,...L(arguments)]),x(arguments))}}}var Ko=c({"src/lib/tasks/checkout.ts"(){"use strict";d(),P()}});function Xo(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function Zo(){return{countObjects(){return this._runTask({commands:["count-objects","--verbose"],format:"utf-8",parser(t){return M(Xo(),[Zn],t)}})}}}var Zn,ta=c({"src/lib/tasks/count-objects.ts"(){"use strict";d(),Zn=new g(/([a-z-]+): (\d+)$/,(t,[e,r])=>{let n=mn(e);t.hasOwnProperty(n)&&(t[n]=w(r))})}});function ea(t){return M({author:null,branch:"",commit:"",root:!1,summary:{changes:0,insertions:0,deletions:0}},ts,t)}var ts,ra=c({"src/lib/parsers/parse-commit.ts"(){"use strict";d(),ts=[new g(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/,(t,[e,r,n])=>{t.branch=e,t.commit=n,t.root=!!r}),new g(/\s*Author:\s(.+)/i,(t,[e])=>{let r=e.split("<"),n=r.pop();!n||!n.includes("@")||(t.author={email:n.substr(0,n.length-1),name:r.join("<").trim()})}),new g(/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g,(t,[e,r,n])=>{t.summary.changes=parseInt(e,10)||0,t.summary.insertions=parseInt(r,10)||0,t.summary.deletions=parseInt(n,10)||0}),new g(/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/,(t,[e,r,n])=>{t.summary.changes=parseInt(e,10)||0;let s=parseInt(r,10)||0;n==="-"?t.summary.deletions=s:n==="+"&&(t.summary.insertions=s)})]}});function na(t,e,r){return{commands:["-c","core.abbrev=40","commit",...gt(t,"-m"),...e,...r],format:"utf-8",parser:ea}}function sa(){return{commit(e,...r){let n=x(arguments),s=t(e)||na(U(e),U(q(r[0],Bt,[])),[...q(r[1],Tt,[]),...L(arguments,0,!0)]);return this._runTask(s,n)}};function t(e){return!Bt(e)&&D("git.commit: requires the commit message to be supplied as a string/string[]")}}var ia=c({"src/lib/tasks/commit.ts"(){"use strict";ra(),d(),P()}});function oa(){return{firstCommit(){return this._runTask($(["rev-list","--max-parents=0","HEAD"],!0),x(arguments))}}}var aa=c({"src/lib/tasks/first-commit.ts"(){"use strict";d(),P()}});function ua(t,e){let r=["hash-object",t];return e&&r.push("-w"),$(r,!0)}var ca=c({"src/lib/tasks/hash-object.ts"(){"use strict";P()}});function la(t,e,r){let n=String(r).trim(),s;if(s=es.exec(n))return new Dt(t,e,!1,s[1]);if(s=rs.exec(n))return new Dt(t,e,!0,s[1]);let i="",o=n.split(" ");for(;o.length;)if(o.shift()==="in"){i=o.join(" ");break}return new Dt(t,e,/^re/i.test(n),i)}var Dt,es,rs,pa=c({"src/lib/responses/InitSummary.ts"(){"use strict";Dt=class{constructor(t,e,r,n){this.bare=t,this.path=e,this.existing=r,this.gitDir=n}},es=/^Init.+ repository in (.+)$/,rs=/^Rein.+ in (.+)$/}});function fa(t){return t.includes(Ge)}function ma(t=!1,e,r){let n=["init",...r];return t&&!fa(n)&&n.splice(1,0,Ge),{commands:n,format:"utf-8",parser(s){return la(n.includes("--bare"),e,s)}}}var Ge,ha=c({"src/lib/tasks/init.ts"(){"use strict";pa(),Ge="--bare"}});function Ue(t){for(let e=0;e<t.length;e++){let r=qe.exec(t[e]);if(r)return`--${r[1]}`}return""}function da(t){return qe.test(t)}var qe,St=c({"src/lib/args/log-format.ts"(){"use strict";qe=/^--(stat|numstat|name-only|name-status)(=|$)/}}),ns,ga=c({"src/lib/responses/DiffSummary.ts"(){"use strict";ns=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function ss(t=""){let e=is[t];return r=>M(new ns,e,r,!1)}var fe,Cr,$r,Lr,is,os=c({"src/lib/parsers/parse-diff-summary.ts"(){"use strict";St(),ga(),Un(),d(),fe=[new g(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(t,[e,r,n=""])=>{t.files.push({file:e.trim(),changes:w(r),insertions:n.replace(/[^+]/g,"").length,deletions:n.replace(/[^-]/g,"").length,binary:!1})}),new g(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,(t,[e,r,n])=>{t.files.push({file:e.trim(),before:w(r),after:w(n),binary:!0})}),new g(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,(t,[e,r])=>{let n=/(\d+) i/.exec(r),s=/(\d+) d/.exec(r);t.changed=w(e),t.insertions=w(n?.[1]),t.deletions=w(s?.[1])})],Cr=[new g(/(\d+)\t(\d+)\t(.+)$/,(t,[e,r,n])=>{let s=w(e),i=w(r);t.changed++,t.insertions+=s,t.deletions+=i,t.files.push({file:n,changes:s+i,insertions:s,deletions:i,binary:!1})}),new g(/-\t-\t(.+)$/,(t,[e])=>{t.changed++,t.files.push({file:e,after:0,before:0,binary:!0})})],$r=[new g(/(.+)$/,(t,[e])=>{t.changed++,t.files.push({file:e,changes:0,insertions:0,deletions:0,binary:!1})})],Lr=[new g(/([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/,(t,[e,r,n,s,i])=>{t.changed++,t.files.push({file:i??n,changes:0,status:gn(Lo(e)&&e),insertions:0,deletions:0,binary:!1})})],is={"":fe,"--stat":fe,"--numstat":Cr,"--name-status":Lr,"--name-only":$r}}});function ya(t,e){return e.reduce((r,n,s)=>(r[n]=t[s]||"",r),Object.create({diff:null}))}function as(t=Ve,e=us,r=""){let n=ss(r);return function(s){let i=kt(s,!0,Je).map(function(o){let a=o.trim().split(ze),l=ya(a[0].trim().split(t),e);return a.length>1&&a[1].trim()&&(l.diff=n(a[1])),l});return{all:i,latest:i.length&&i[0]||null,total:i.length}}}var Je,ze,Ve,us,cs=c({"src/lib/parsers/parse-list-log-summary.ts"(){"use strict";d(),os(),St(),Je="\xF2\xF2\xF2\xF2\xF2\xF2 ",ze=" \xF2\xF2",Ve=" \xF2 ",us=["hash","date","message","refs","author_name","author_email"]}}),ls={};E(ls,{diffSummaryTask:()=>va,validateLogFormatConfig:()=>Wt});function va(t){let e=Ue(t),r=["diff"];return e===""&&(e="--stat",r.push("--stat=4096")),r.push(...t),Wt(r)||{commands:r,format:"utf-8",parser:ss(e)}}function Wt(t){let e=t.filter(da);if(e.length>1)return D(`Summary flags are mutually exclusive - pick one of ${e.join(",")}`);if(e.length&&t.includes("-z"))return D(`Summary flag ${e} parsing is not compatible with null termination option '-z'`)}var We=c({"src/lib/tasks/diff.ts"(){"use strict";St(),os(),P()}});function ba(t,e){let r=[],n=[];return Object.keys(t).forEach(s=>{r.push(s),n.push(String(t[s]))}),[r,n.join(e)]}function _a(t){return Object.keys(t).reduce((e,r)=>(r in Te||(e[r]=t[r]),e),{})}function ps(t={},e=[]){let r=q(t.splitter,A,Ve),n=!Ae(t.format)&&t.format?t.format:{hash:"%H",date:t.strictDate===!1?"%ai":"%aI",message:"%s",refs:"%D",body:t.multiLine?"%B":"%b",author_name:t.mailMap!==!1?"%aN":"%an",author_email:t.mailMap!==!1?"%aE":"%ae"},[s,i]=ba(n,r),o=[],a=[`--pretty=format:${Je}${i}${ze}`,...e],l=t.n||t["max-count"]||t.maxCount;if(l&&a.push(`--max-count=${l}`),t.from||t.to){let p=t.symmetric!==!1?"...":"..";o.push(`${t.from||""}${p}${t.to||""}`)}return A(t.file)&&a.push("--follow",oo(t.file)),Le(_a(t),a),{fields:s,splitter:r,commands:[...a,...o]}}function ka(t,e,r){let n=as(t,e,Ue(r));return{commands:["log",...r],format:"utf-8",parser:n}}function wa(){return{log(...r){let n=x(arguments),s=ps(De(arguments),q(arguments[0],Tt)),i=e(...r)||Wt(s.commands)||t(s);return this._runTask(i,n)}};function t(r){return ka(r.splitter,r.fields,r.commands)}function e(r,n){return A(r)&&A(n)&&D("git.log(string, string) should be replaced with git.log({ from: string, to: string })")}}var Te,fs=c({"src/lib/tasks/log.ts"(){"use strict";St(),bt(),cs(),d(),P(),We(),Te=(t=>(t[t["--pretty"]=0]="--pretty",t[t["max-count"]=1]="max-count",t[t.maxCount=2]="maxCount",t[t.n=3]="n",t[t.file=4]="file",t[t.format=5]="format",t[t.from=6]="from",t[t.to=7]="to",t[t.splitter=8]="splitter",t[t.symmetric=9]="symmetric",t[t.mailMap=10]="mailMap",t[t.multiLine=11]="multiLine",t[t.strictDate=12]="strictDate",t))(Te||{})}}),Mt,ms,Ta=c({"src/lib/responses/MergeSummary.ts"(){"use strict";Mt=class{constructor(t,e=null,r){this.reason=t,this.file=e,this.meta=r}toString(){return`${this.file}:${this.reason}`}},ms=class{constructor(){this.conflicts=[],this.merges=[],this.result="success"}get failed(){return this.conflicts.length>0}get reason(){return this.result}toString(){return this.conflicts.length?`CONFLICTS: ${this.conflicts.join(", ")}`:"OK"}}}}),Se,hs,Sa=c({"src/lib/responses/PullSummary.ts"(){"use strict";Se=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},hs=class{constructor(){this.remote="",this.hash={local:"",remote:""},this.branch={local:"",remote:""},this.message=""}toString(){return this.message}}}});function me(t){return t.objects=t.objects||{compressing:0,counting:0,enumerating:0,packReused:0,reused:{count:0,delta:0},total:{count:0,delta:0}}}function Dr(t){let e=/^\s*(\d+)/.exec(t),r=/delta (\d+)/i.exec(t);return{count:w(e&&e[1]||"0"),delta:w(r&&r[1]||"0")}}var ds,xa=c({"src/lib/parsers/parse-remote-objects.ts"(){"use strict";d(),ds=[new Y(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(t,[e,r])=>{let n=e.toLowerCase(),s=me(t.remoteMessages);Object.assign(s,{[n]:w(r)})}),new Y(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(t,[e,r])=>{let n=e.toLowerCase(),s=me(t.remoteMessages);Object.assign(s,{[n]:w(r)})}),new Y(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(t,[e,r,n])=>{let s=me(t.remoteMessages);s.total=Dr(e),s.reused=Dr(r),s.packReused=w(n)})]}});function gs(t,e){return M({remoteMessages:new vs},ys,e)}var ys,vs,bs=c({"src/lib/parsers/parse-remote-messages.ts"(){"use strict";d(),xa(),ys=[new Y(/^remote:\s*(.+)$/,(t,[e])=>(t.remoteMessages.all.push(e.trim()),!1)),...ds,new Y([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(t,[e])=>{t.remoteMessages.pullRequestUrl=e}),new Y([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(t,[e,r,n])=>{t.remoteMessages.vulnerabilities={count:w(e),summary:r,url:n}})],vs=class{constructor(){this.all=[]}}}});function Pa(t,e){let r=M(new hs,_s,[t,e]);return r.message&&r}var Mr,jr,Br,Ir,_s,Fr,Qe,ks=c({"src/lib/parsers/parse-pull.ts"(){"use strict";Sa(),d(),bs(),Mr=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,jr=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,Br=/^(create|delete) mode \d+ (.+)/,Ir=[new g(Mr,(t,[e,r,n])=>{t.files.push(e),r&&(t.insertions[e]=r.length),n&&(t.deletions[e]=n.length)}),new g(jr,(t,[e,,r,,n])=>r!==void 0||n!==void 0?(t.summary.changes=+e||0,t.summary.insertions=+r||0,t.summary.deletions=+n||0,!0):!1),new g(Br,(t,[e,r])=>{b(t.files,r),b(e==="create"?t.created:t.deleted,r)})],_s=[new g(/^from\s(.+)$/i,(t,[e])=>void(t.remote=e)),new g(/^fatal:\s(.+)$/,(t,[e])=>void(t.message=e)),new g(/([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/,(t,[e,r,n,s])=>{t.branch.local=n,t.hash.local=e,t.branch.remote=s,t.hash.remote=r})],Fr=(t,e)=>M(new Se,Ir,[t,e]),Qe=(t,e)=>Object.assign(new Se,Fr(t,e),gs(t,e))}}),Nr,ws,Gr,Ea=c({"src/lib/parsers/parse-merge.ts"(){"use strict";Ta(),d(),ks(),Nr=[new g(/^Auto-merging\s+(.+)$/,(t,[e])=>{t.merges.push(e)}),new g(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/,(t,[e,r])=>{t.conflicts.push(new Mt(e,r))}),new g(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(t,[e,r,n])=>{t.conflicts.push(new Mt(e,r,{deleteRef:n}))}),new g(/^CONFLICT\s+\((.+)\):/,(t,[e])=>{t.conflicts.push(new Mt(e,null))}),new g(/^Automatic merge failed;\s+(.+)$/,(t,[e])=>{t.result=e})],ws=(t,e)=>Object.assign(Gr(t,e),Qe(t,e)),Gr=t=>M(new ms,Nr,t)}});function Ur(t){return t.length?{commands:["merge",...t],format:"utf-8",parser(e,r){let n=ws(e,r);if(n.failed)throw new _t(n);return n}}:D("Git.merge requires at least one option")}var Oa=c({"src/lib/tasks/merge.ts"(){"use strict";ut(),Ea(),P()}});function Ra(t,e,r){let n=r.includes("deleted"),s=r.includes("tag")||/^refs\/tags/.test(t),i=!r.includes("new");return{deleted:n,tag:s,branch:!s,new:!i,alreadyUpdated:i,local:t,remote:e}}var qr,Ts,Jr,Aa=c({"src/lib/parsers/parse-push.ts"(){"use strict";d(),bs(),qr=[new g(/^Pushing to (.+)$/,(t,[e])=>{t.repo=e}),new g(/^updating local tracking ref '(.+)'/,(t,[e])=>{t.ref=dt(F({},t.ref||{}),{local:e})}),new g(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/,(t,[e,r,n])=>{t.pushed.push(Ra(e,r,n))}),new g(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,(t,[e,r,n])=>{t.branch=dt(F({},t.branch||{}),{local:e,remote:r,remoteName:n})}),new g(/^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/,(t,[e,r,n,s])=>{t.update={head:{local:e,remote:r},hash:{from:n,to:s}}})],Ts=(t,e)=>{let r=Jr(t,e),n=gs(t,e);return F(F({},r),n)},Jr=(t,e)=>M({pushed:[]},qr,[t,e])}}),Ss={};E(Ss,{pushTagsTask:()=>Ca,pushTask:()=>He});function Ca(t={},e){return b(e,"--tags"),He(t,e)}function He(t={},e){let r=["push",...e];return t.branch&&r.splice(1,0,t.branch),t.remote&&r.splice(1,0,t.remote),qt(r,"-v"),b(r,"--verbose"),b(r,"--porcelain"),{commands:r,format:"utf-8",parser:Ts}}var xs=c({"src/lib/tasks/push.ts"(){"use strict";Aa(),d()}});function $a(){return{showBuffer(){let t=["show",...L(arguments,1)];return t.includes("--binary")||t.splice(1,0,"--binary"),this._runTask($n(t),x(arguments))},show(){let t=["show",...L(arguments,1)];return this._runTask($(t),x(arguments))}}}var La=c({"src/lib/tasks/show.ts"(){"use strict";d(),P()}}),zr,Ps,Da=c({"src/lib/responses/FileStatusSummary.ts"(){"use strict";zr=/^(.+) -> (.+)$/,Ps=class{constructor(t,e,r){if(this.path=t,this.index=e,this.working_dir=r,e+r==="R"){let n=zr.exec(t)||[null,t,t];this.from=n[1]||"",this.path=n[2]||""}}}}});function Vr(t){let[e,r]=t.split(at);return{from:r||e,to:e}}function B(t,e,r){return[`${t}${e}`,r]}function he(t,...e){return e.map(r=>B(t,r,(n,s)=>b(n.conflicted,s)))}function Ma(t,e){let r=e.trim();switch(" "){case r.charAt(2):return n(r.charAt(0),r.charAt(1),r.substr(3));case r.charAt(1):return n(" ",r.charAt(0),r.substr(2));default:return}function n(s,i,o){let a=`${s}${i}`,l=Es.get(a);l&&l(t,o),a!=="##"&&a!=="!!"&&t.files.push(new Ps(o.replace(/\0.+$/,""),s,i))}}var Wr,Es,Os,ja=c({"src/lib/responses/StatusSummary.ts"(){"use strict";d(),Da(),Wr=class{constructor(){this.not_added=[],this.conflicted=[],this.created=[],this.deleted=[],this.ignored=void 0,this.modified=[],this.renamed=[],this.files=[],this.staged=[],this.ahead=0,this.behind=0,this.current=null,this.tracking=null,this.detached=!1,this.isClean=()=>!this.files.length}},Es=new Map([B(" ","A",(t,e)=>b(t.created,e)),B(" ","D",(t,e)=>b(t.deleted,e)),B(" ","M",(t,e)=>b(t.modified,e)),B("A"," ",(t,e)=>b(t.created,e)&&b(t.staged,e)),B("A","M",(t,e)=>b(t.created,e)&&b(t.staged,e)&&b(t.modified,e)),B("D"," ",(t,e)=>b(t.deleted,e)&&b(t.staged,e)),B("M"," ",(t,e)=>b(t.modified,e)&&b(t.staged,e)),B("M","M",(t,e)=>b(t.modified,e)&&b(t.staged,e)),B("R"," ",(t,e)=>{b(t.renamed,Vr(e))}),B("R","M",(t,e)=>{let r=Vr(e);b(t.renamed,r),b(t.modified,r.to)}),B("!","!",(t,e)=>{b(t.ignored=t.ignored||[],e)}),B("?","?",(t,e)=>b(t.not_added,e)),...he("A","A","U"),...he("D","D","U"),...he("U","A","D","U"),["##",(t,e)=>{let r=/ahead (\d+)/,n=/behind (\d+)/,s=/^(.+?(?=(?:\.{3}|\s|$)))/,i=/\.{3}(\S*)/,o=/\son\s([\S]+)$/,a;a=r.exec(e),t.ahead=a&&+a[1]||0,a=n.exec(e),t.behind=a&&+a[1]||0,a=s.exec(e),t.current=a&&a[1],a=i.exec(e),t.tracking=a&&a[1],a=o.exec(e),t.current=a&&a[1]||t.current,t.detached=/\(no branch\)/.test(e)}]]),Os=function(t){let e=t.split(at),r=new Wr;for(let n=0,s=e.length;n<s;){let i=e[n++].trim();i&&(i.charAt(0)==="R"&&(i+=at+(e[n++]||"")),Ma(r,i))}return r}}});function Ba(t){return{format:"utf-8",commands:["status","--porcelain","-b","-u","--null",...t.filter(r=>!Rs.includes(r))],parser(r){return Os(r)}}}var Rs,Ia=c({"src/lib/tasks/status.ts"(){"use strict";ja(),Rs=["--null","-z"]}});function Ft(t=0,e=0,r=0,n="",s=!0){return Object.defineProperty({major:t,minor:e,patch:r,agent:n,installed:s},"toString",{value(){return`${this.major}.${this.minor}.${this.patch}`},configurable:!1,enumerable:!1})}function Fa(){return Ft(0,0,0,"",!1)}function Na(){return{version(){return this._runTask({commands:["--version"],format:"utf-8",parser:Ga,onError(t,e,r,n){if(t.exitCode===-2)return r(Buffer.from(Ye));n(e)}})}}}function Ga(t){return t===Ye?Fa():M(Ft(0,0,0,t),As,t)}var Ye,As,Ua=c({"src/lib/tasks/version.ts"(){"use strict";d(),Ye="installed=false",As=[new g(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(t,[e,r,n,s=""])=>{Object.assign(t,Ft(w(e),w(r),w(n),s))}),new g(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(t,[e,r,n,s=""])=>{Object.assign(t,Ft(w(e),w(r),n,s))})]}}),Cs={};E(Cs,{SimpleGitApi:()=>xe});var xe,qa=c({"src/lib/simple-git-api.ts"(){"use strict";Qo(),Ho(),Ko(),ta(),ia(),Nn(),aa(),zn(),ca(),ha(),fs(),Oa(),xs(),La(),Ia(),P(),Ua(),d(),xe=class{constructor(t){this._executor=t}_runTask(t,e){let r=this._executor.chain(),n=r.push(t);return e&&Vo(t,n,e),Object.create(this,{then:{value:n.then.bind(n)},catch:{value:n.catch.bind(n)},_executor:{value:r}})}add(t){return this._runTask($(["add",...U(t)]),x(arguments))}cwd(t){let e=x(arguments);return typeof t=="string"?this._runTask(Ar(t,this._executor),e):typeof t?.path=="string"?this._runTask(Ar(t.path,t.root&&this._executor||void 0),e):this._runTask(D("Git.cwd: workingDirectory must be supplied as a string"),e)}hashObject(t,e){return this._runTask(ua(t,e===!0),x(arguments))}init(t){return this._runTask(ma(t===!0,this._executor.cwd,L(arguments)),x(arguments))}merge(){return this._runTask(Ur(L(arguments)),x(arguments))}mergeFromTo(t,e){return A(t)&&A(e)?this._runTask(Ur([t,e,...L(arguments)]),x(arguments,!1)):this._runTask(D("Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings"))}outputHandler(t){return this._executor.outputHandler=t,this}push(){let t=He({remote:q(arguments[0],A),branch:q(arguments[1],A)},L(arguments));return this._runTask(t,x(arguments))}stash(){return this._runTask($(["stash",...L(arguments)]),x(arguments))}status(){return this._runTask(Ba(L(arguments)),x(arguments))}},Object.assign(xe.prototype,Yo(),sa(),$o(),Zo(),oa(),jo(),wa(),$a(),Na())}}),$s={};E($s,{Scheduler:()=>Ds});var Qr,Ds,Ja=c({"src/lib/runners/scheduler.ts"(){"use strict";d(),Yn(),Qr=(()=>{let t=0;return()=>{t++;let{promise:e,done:r}=(0,Ls.createDeferred)();return{promise:e,done:r,id:t}}})(),Ds=class{constructor(t=2){this.concurrency=t,this.logger=Ne("","scheduler"),this.pending=[],this.running=[],this.logger("Constructed, concurrency=%s",t)}schedule(){if(!this.pending.length||this.running.length>=this.concurrency){this.logger("Schedule attempt ignored, pending=%s running=%s concurrency=%s",this.pending.length,this.running.length,this.concurrency);return}let t=b(this.running,this.pending.shift());this.logger("Attempting id=%s",t.id),t.done(()=>{this.logger("Completing id=",t.id),qt(this.running,t),this.schedule()})}next(){let{promise:t,id:e}=b(this.pending,Qr());return this.logger("Scheduling id=%s",e),this.schedule(),t}}}}),Ms={};E(Ms,{applyPatchTask:()=>za});function za(t,e){return $(["apply",...e,...t])}var Va=c({"src/lib/tasks/apply-patch.ts"(){"use strict";P()}});function Wa(t,e){return{branch:t,hash:e,success:!0}}function Qa(t){return{branch:t,hash:null,success:!1}}var js,Ha=c({"src/lib/responses/BranchDeleteSummary.ts"(){"use strict";js=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function Bs(t,e){return e===1&&Pe.test(t)}var Hr,Pe,Yr,Qt,Ya=c({"src/lib/parsers/parse-branch-delete.ts"(){"use strict";Ha(),d(),Hr=/(\S+)\s+\(\S+\s([^)]+)\)/,Pe=/^error[^']+'([^']+)'/m,Yr=[new g(Hr,(t,[e,r])=>{let n=Wa(e,r);t.all.push(n),t.branches[e]=n}),new g(Pe,(t,[e])=>{let r=Qa(e);t.errors.push(r),t.all.push(r),t.branches[e]=r})],Qt=(t,e)=>M(new js,Yr,[t,e])}}),Is,Ka=c({"src/lib/responses/BranchSummary.ts"(){"use strict";Is=class{constructor(){this.all=[],this.branches={},this.current="",this.detached=!1}push(t,e,r,n,s){t==="*"&&(this.detached=e,this.current=r),this.all.push(r),this.branches[r]={current:t==="*",linkedWorkTree:t==="+",name:r,commit:n,label:s}}}}});function Kr(t){return t?t.charAt(0):""}function Fs(t){return M(new Is,Ns,t)}var Ns,Xa=c({"src/lib/parsers/parse-branch.ts"(){"use strict";Ka(),d(),Ns=[new g(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(t,[e,r,n,s])=>{t.push(Kr(e),!0,r,n,s)}),new g(new RegExp("^([*+]\\s)?(\\S+)\\s+([a-z0-9]+)\\s?(.*)$","s"),(t,[e,r,n,s])=>{t.push(Kr(e),!1,r,n,s)})]}}),Gs={};E(Gs,{branchLocalTask:()=>tu,branchTask:()=>Za,containsDeleteBranchCommand:()=>Us,deleteBranchTask:()=>ru,deleteBranchesTask:()=>eu});function Us(t){let e=["-d","-D","--delete"];return t.some(r=>e.includes(r))}function Za(t){let e=Us(t),r=["branch",...t];return r.length===1&&r.push("-a"),r.includes("-v")||r.splice(1,0,"-v"),{format:"utf-8",commands:r,parser(n,s){return e?Qt(n,s).all[0]:Fs(n)}}}function tu(){return{format:"utf-8",commands:["branch","-v"],parser:Fs}}function eu(t,e=!1){return{format:"utf-8",commands:["branch","-v",e?"-D":"-d",...t],parser(r,n){return Qt(r,n)},onError({exitCode:r,stdOut:n},s,i,o){if(!Bs(String(s),r))return o(s);i(n)}}}function ru(t,e=!1){let r={format:"utf-8",commands:["branch","-v",e?"-D":"-d",t],parser(n,s){return Qt(n,s).branches[t]},onError({exitCode:n,stdErr:s,stdOut:i},o,a,l){if(!Bs(String(o),n))return l(o);throw new _t(r.parser(yt(i),yt(s)),String(o))}};return r}var nu=c({"src/lib/tasks/branch.ts"(){"use strict";ut(),Ya(),Xa(),d()}}),qs,su=c({"src/lib/responses/CheckIgnore.ts"(){"use strict";qs=t=>t.split(/\n/g).map(e=>e.trim()).filter(e=>!!e)}}),Js={};E(Js,{checkIgnoreTask:()=>iu});function iu(t){return{commands:["check-ignore",...t],format:"utf-8",parser:qs}}var ou=c({"src/lib/tasks/check-ignore.ts"(){"use strict";su()}}),zs={};E(zs,{cloneMirrorTask:()=>uu,cloneTask:()=>Vs});function au(t){return/^--upload-pack(=|$)/.test(t)}function Vs(t,e,r){let n=["clone",...r];return A(t)&&n.push(t),A(e)&&n.push(e),n.find(au)?D("git.fetch: potential exploit argument blocked."):$(n)}function uu(t,e,r){return b(r,"--mirror"),Vs(t,e,r)}var cu=c({"src/lib/tasks/clone.ts"(){"use strict";P(),d()}});function lu(t,e){return M({raw:t,remote:null,branches:[],tags:[],updated:[],deleted:[]},Ws,[t,e])}var Ws,pu=c({"src/lib/parsers/parse-fetch.ts"(){"use strict";d(),Ws=[new g(/From (.+)$/,(t,[e])=>{t.remote=e}),new g(/\* \[new branch]\s+(\S+)\s*-> (.+)$/,(t,[e,r])=>{t.branches.push({name:e,tracking:r})}),new g(/\* \[new tag]\s+(\S+)\s*-> (.+)$/,(t,[e,r])=>{t.tags.push({name:e,tracking:r})}),new g(/- \[deleted]\s+\S+\s*-> (.+)$/,(t,[e])=>{t.deleted.push({tracking:e})}),new g(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,(t,[e,r,n,s])=>{t.updated.push({name:n,tracking:s,to:r,from:e})})]}}),Qs={};E(Qs,{fetchTask:()=>mu});function fu(t){return/^--upload-pack(=|$)/.test(t)}function mu(t,e,r){let n=["fetch",...r];return t&&e&&n.push(t,e),n.find(fu)?D("git.fetch: potential exploit argument blocked."):{commands:n,format:"utf-8",parser:lu}}var hu=c({"src/lib/tasks/fetch.ts"(){"use strict";pu(),P()}});function du(t){return M({moves:[]},Hs,t)}var Hs,gu=c({"src/lib/parsers/parse-move.ts"(){"use strict";d(),Hs=[new g(/^Renaming (.+) to (.+)$/,(t,[e,r])=>{t.moves.push({from:e,to:r})})]}}),Ys={};E(Ys,{moveTask:()=>yu});function yu(t,e){return{commands:["mv","-v",...U(t),e],format:"utf-8",parser:du}}var vu=c({"src/lib/tasks/move.ts"(){"use strict";gu(),d()}}),Ks={};E(Ks,{pullTask:()=>bu});function bu(t,e,r){let n=["pull",...r];return t&&e&&n.splice(1,0,t,e),{commands:n,format:"utf-8",parser(s,i){return Qe(s,i)},onError(s,i,o,a){let l=Pa(yt(s.stdOut),yt(s.stdErr));if(l)return a(new _t(l));a(i)}}}var _u=c({"src/lib/tasks/pull.ts"(){"use strict";ut(),ks(),d()}});function ku(t){let e={};return Xs(t,([r])=>e[r]={name:r}),Object.values(e)}function wu(t){let e={};return Xs(t,([r,n,s])=>{e.hasOwnProperty(r)||(e[r]={name:r,refs:{fetch:"",push:""}}),s&&n&&(e[r].refs[s.replace(/[^a-z]/g,"")]=n)}),Object.values(e)}function Xs(t,e){Oe(t,r=>e(r.split(/\s+/)))}var Tu=c({"src/lib/responses/GetRemoteSummary.ts"(){"use strict";d()}}),Zs={};E(Zs,{addRemoteTask:()=>Su,getRemotesTask:()=>xu,listRemotesTask:()=>Pu,remoteTask:()=>Eu,removeRemoteTask:()=>Ou});function Su(t,e,r){return $(["remote","add",...r,t,e])}function xu(t){let e=["remote"];return t&&e.push("-v"),{commands:e,format:"utf-8",parser:t?wu:ku}}function Pu(t){let e=[...t];return e[0]!=="ls-remote"&&e.unshift("ls-remote"),$(e)}function Eu(t){let e=[...t];return e[0]!=="remote"&&e.unshift("remote"),$(e)}function Ou(t){return $(["remote","remove",t])}var Ru=c({"src/lib/tasks/remote.ts"(){"use strict";Tu(),P()}}),ti={};E(ti,{stashListTask:()=>Au});function Au(t={},e){let r=ps(t),n=["stash","list",...r.commands,...e],s=as(r.splitter,r.fields,Ue(n));return Wt(n)||{commands:n,format:"utf-8",parser:s}}var Cu=c({"src/lib/tasks/stash-list.ts"(){"use strict";St(),cs(),We(),fs()}}),ei={};E(ei,{addSubModuleTask:()=>$u,initSubModuleTask:()=>Lu,subModuleTask:()=>Ht,updateSubModuleTask:()=>Du});function $u(t,e){return Ht(["add",t,e])}function Lu(t){return Ht(["init",...t])}function Ht(t){let e=[...t];return e[0]!=="submodule"&&e.unshift("submodule"),$(e)}function Du(t){return Ht(["update",...t])}var Mu=c({"src/lib/tasks/sub-module.ts"(){"use strict";P()}});function ju(t,e){let r=isNaN(t),n=isNaN(e);return r!==n?r?1:-1:r?ri(t,e):0}function ri(t,e){return t===e?0:t>e?1:-1}function Bu(t){return t.trim()}function Ct(t){return typeof t=="string"&&parseInt(t.replace(/^\D+/g,""),10)||0}var Xr,ni,Iu=c({"src/lib/responses/TagList.ts"(){"use strict";Xr=class{constructor(t,e){this.all=t,this.latest=e}},ni=function(t,e=!1){let r=t.split(`
55
- `).map(Bu).filter(Boolean);e||r.sort(function(s,i){let o=s.split("."),a=i.split(".");if(o.length===1||a.length===1)return ju(Ct(o[0]),Ct(a[0]));for(let l=0,p=Math.max(o.length,a.length);l<p;l++){let _=ri(Ct(o[l]),Ct(a[l]));if(_)return _}return 0});let n=e?r[0]:[...r].reverse().find(s=>s.indexOf(".")>=0);return new Xr(r,n)}}}),si={};E(si,{addAnnotatedTagTask:()=>Gu,addTagTask:()=>Nu,tagListTask:()=>Fu});function Fu(t=[]){let e=t.some(r=>/^--sort=/.test(r));return{format:"utf-8",commands:["tag","-l",...t],parser(r){return ni(r,e)}}}function Nu(t){return{format:"utf-8",commands:["tag",t],parser(){return{name:t}}}}function Gu(t,e){return{format:"utf-8",commands:["tag","-a","-m",e,t],parser(){return{name:t}}}}var Uu=c({"src/lib/tasks/tag.ts"(){"use strict";Iu()}}),qu=so({"src/git.js"(t,e){"use strict";var{GitExecutor:r}=(zo(),S(Kn)),{SimpleGitApi:n}=(qa(),S(Cs)),{Scheduler:s}=(Ja(),S($s)),{configurationErrorTask:i}=(P(),S(be)),{asArray:o,filterArray:a,filterPrimitives:l,filterString:p,filterStringOrStringArray:_,filterType:y,getTrailingOptions:v,trailingFunctionArgument:h,trailingOptionsArgument:X}=(d(),S(wn)),{applyPatchTask:pi}=(Va(),S(Ms)),{branchTask:fi,branchLocalTask:mi,deleteBranchesTask:hi,deleteBranchTask:di}=(nu(),S(Gs)),{checkIgnoreTask:gi}=(ou(),S(Js)),{checkIsRepoTask:yi}=(Pn(),S(Tn)),{cloneTask:vi,cloneMirrorTask:bi}=(cu(),S(zs)),{cleanWithOptionsTask:_i,isCleanOptionsArray:ki}=(Bn(),S(Mn)),{diffSummaryTask:wi}=(We(),S(ls)),{fetchTask:Ti}=(hu(),S(Qs)),{moveTask:Si}=(vu(),S(Ys)),{pullTask:xi}=(_u(),S(Ks)),{pushTagsTask:Pi}=(xs(),S(Ss)),{addRemoteTask:Ei,getRemotesTask:Oi,listRemotesTask:Ri,remoteTask:Ai,removeRemoteTask:Ci}=(Ru(),S(Zs)),{getResetMode:$i,resetTask:Li}=(Hn(),S(Vn)),{stashListTask:Di}=(Cu(),S(ti)),{addSubModuleTask:Mi,initSubModuleTask:ji,subModuleTask:Bi,updateSubModuleTask:Ii}=(Mu(),S(ei)),{addAnnotatedTagTask:Fi,addTagTask:Ni,tagListTask:Gi}=(Uu(),S(si)),{straightThroughBufferTask:Ui,straightThroughStringTask:G}=(P(),S(be));function m(u,f){this._plugins=f,this._executor=new r(u.baseDir,new s(u.maxConcurrentProcesses),f),this._trimmed=u.trimmed}(m.prototype=Object.create(n.prototype)).constructor=m,m.prototype.customBinary=function(u){return this._plugins.reconfigure("binary",u),this},m.prototype.env=function(u,f){return arguments.length===1&&typeof u=="object"?this._executor.env=u:(this._executor.env=this._executor.env||{})[u]=f,this},m.prototype.stashList=function(u){return this._runTask(Di(X(arguments)||{},a(u)&&u||[]),h(arguments))};function Xe(u,f,k,C){return typeof k!="string"?i(`git.${u}() requires a string 'repoPath'`):f(k,y(C,p),v(arguments))}m.prototype.clone=function(){return this._runTask(Xe("clone",vi,...arguments),h(arguments))},m.prototype.mirror=function(){return this._runTask(Xe("mirror",bi,...arguments),h(arguments))},m.prototype.mv=function(u,f){return this._runTask(Si(u,f),h(arguments))},m.prototype.checkoutLatestTag=function(u){var f=this;return this.pull(function(){f.tags(function(k,C){f.checkout(C.latest,u)})})},m.prototype.pull=function(u,f,k,C){return this._runTask(xi(y(u,p),y(f,p),v(arguments)),h(arguments))},m.prototype.fetch=function(u,f){return this._runTask(Ti(y(u,p),y(f,p),v(arguments)),h(arguments))},m.prototype.silent=function(u){return console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this will be an error in version 3"),this},m.prototype.tags=function(u,f){return this._runTask(Gi(v(arguments)),h(arguments))},m.prototype.rebase=function(){return this._runTask(G(["rebase",...v(arguments)]),h(arguments))},m.prototype.reset=function(u){return this._runTask(Li($i(u),v(arguments)),h(arguments))},m.prototype.revert=function(u){let f=h(arguments);return typeof u!="string"?this._runTask(i("Commit must be a string"),f):this._runTask(G(["revert",...v(arguments,0,!0),u]),f)},m.prototype.addTag=function(u){let f=typeof u=="string"?Ni(u):i("Git.addTag requires a tag name");return this._runTask(f,h(arguments))},m.prototype.addAnnotatedTag=function(u,f){return this._runTask(Fi(u,f),h(arguments))},m.prototype.deleteLocalBranch=function(u,f,k){return this._runTask(di(u,typeof f=="boolean"?f:!1),h(arguments))},m.prototype.deleteLocalBranches=function(u,f,k){return this._runTask(hi(u,typeof f=="boolean"?f:!1),h(arguments))},m.prototype.branch=function(u,f){return this._runTask(fi(v(arguments)),h(arguments))},m.prototype.branchLocal=function(u){return this._runTask(mi(),h(arguments))},m.prototype.raw=function(u){let f=!Array.isArray(u),k=[].slice.call(f?arguments:u,0);for(let N=0;N<k.length&&f;N++)if(!l(k[N])){k.splice(N,k.length-N);break}k.push(...v(arguments,0,!0));var C=h(arguments);return k.length?this._runTask(G(k,this._trimmed),C):this._runTask(i("Raw: must supply one or more command to execute"),C)},m.prototype.submoduleAdd=function(u,f,k){return this._runTask(Mi(u,f),h(arguments))},m.prototype.submoduleUpdate=function(u,f){return this._runTask(Ii(v(arguments,!0)),h(arguments))},m.prototype.submoduleInit=function(u,f){return this._runTask(ji(v(arguments,!0)),h(arguments))},m.prototype.subModule=function(u,f){return this._runTask(Bi(v(arguments)),h(arguments))},m.prototype.listRemote=function(){return this._runTask(Ri(v(arguments)),h(arguments))},m.prototype.addRemote=function(u,f,k){return this._runTask(Ei(u,f,v(arguments)),h(arguments))},m.prototype.removeRemote=function(u,f){return this._runTask(Ci(u),h(arguments))},m.prototype.getRemotes=function(u,f){return this._runTask(Oi(u===!0),h(arguments))},m.prototype.remote=function(u,f){return this._runTask(Ai(v(arguments)),h(arguments))},m.prototype.tag=function(u,f){let k=v(arguments);return k[0]!=="tag"&&k.unshift("tag"),this._runTask(G(k),h(arguments))},m.prototype.updateServerInfo=function(u){return this._runTask(G(["update-server-info"]),h(arguments))},m.prototype.pushTags=function(u,f){let k=Pi({remote:y(u,p)},v(arguments));return this._runTask(k,h(arguments))},m.prototype.rm=function(u){return this._runTask(G(["rm","-f",...o(u)]),h(arguments))},m.prototype.rmKeepLocal=function(u){return this._runTask(G(["rm","--cached",...o(u)]),h(arguments))},m.prototype.catFile=function(u,f){return this._catFile("utf-8",arguments)},m.prototype.binaryCatFile=function(){return this._catFile("buffer",arguments)},m.prototype._catFile=function(u,f){var k=h(f),C=["cat-file"],N=f[0];if(typeof N=="string")return this._runTask(i("Git.catFile: options must be supplied as an array of strings"),k);Array.isArray(N)&&C.push.apply(C,N);let Zt=u==="buffer"?Ui(C):G(C);return this._runTask(Zt,k)},m.prototype.diff=function(u,f){let k=p(u)?i("git.diff: supplying options as a single string is no longer supported, switch to an array of strings"):G(["diff",...v(arguments)]);return this._runTask(k,h(arguments))},m.prototype.diffSummary=function(){return this._runTask(wi(v(arguments,1)),h(arguments))},m.prototype.applyPatch=function(u){let f=_(u)?pi(o(u),v([].slice.call(arguments,1))):i("git.applyPatch requires one or more string patches as the first argument");return this._runTask(f,h(arguments))},m.prototype.revparse=function(){let u=["rev-parse",...v(arguments,!0)];return this._runTask(G(u,!0),h(arguments))},m.prototype.clean=function(u,f,k){let C=ki(u),N=C&&u.join("")||y(u,p)||"",Zt=v([].slice.call(arguments,C?1:0));return this._runTask(_i(N,Zt),h(arguments))},m.prototype.exec=function(u){let f={commands:[],format:"utf-8",parser(){typeof u=="function"&&u()}};return this._runTask(f)},m.prototype.clearQueue=function(){return this},m.prototype.checkIgnore=function(u,f){return this._runTask(gi(o(y(u,_,[]))),h(arguments))},m.prototype.checkIsRepo=function(u,f){return this._runTask(yi(y(u,p)),h(arguments))},e.exports=m}});bt();K();var Ju=class extends W{constructor(t,e){super(void 0,e),this.config=t}};K();K();var V=class extends W{constructor(t,e,r){super(t,r),this.task=t,this.plugin=e,Object.setPrototypeOf(this,new.target.prototype)}};ut();on();Pn();Bn();Nn();Un();zn();Hn();function zu(t){return t?[{type:"spawn.before",action(n,s){t.aborted&&s.kill(new V(void 0,"abort","Abort already signaled"))}},{type:"spawn.after",action(n,s){function i(){s.kill(new V(void 0,"abort","Abort signal received"))}t.addEventListener("abort",i),s.spawned.on("close",()=>t.removeEventListener("abort",i))}}]:void 0}function Vu(t){return typeof t=="string"&&t.trim().toLowerCase()==="-c"}function Wu(t,e){if(Vu(t)&&/^\s*protocol(.[a-z]+)?.allow/.test(e))throw new V(void 0,"unsafe","Configuring protocol.allow is not permitted without enabling allowUnsafeExtProtocol")}function Qu(t,e){if(/^\s*--(upload|receive)-pack/.test(t))throw new V(void 0,"unsafe","Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack");if(e==="clone"&&/^\s*-u\b/.test(t))throw new V(void 0,"unsafe","Use of clone with option -u is not permitted without enabling allowUnsafePack");if(e==="push"&&/^\s*--exec\b/.test(t))throw new V(void 0,"unsafe","Use of push with option --exec is not permitted without enabling allowUnsafePack")}function Hu({allowUnsafeProtocolOverride:t=!1,allowUnsafePack:e=!1}={}){return{type:"spawn.args",action(r,n){return r.forEach((s,i)=>{let o=i<r.length?r[i+1]:"";t||Wu(s,o),e||Qu(s,n.method)}),r}}}d();function Yu(t){let e=gt(t,"-c");return{type:"spawn.args",action(r){return[...e,...r]}}}d();var Zr=(0,ot.deferred)().promise;function Ku({onClose:t=!0,onExit:e=50}={}){function r(){let s=-1,i={close:(0,ot.deferred)(),closeTimeout:(0,ot.deferred)(),exit:(0,ot.deferred)(),exitTimeout:(0,ot.deferred)()},o=Promise.race([t===!1?Zr:i.closeTimeout.promise,e===!1?Zr:i.exitTimeout.promise]);return n(t,i.close,i.closeTimeout),n(e,i.exit,i.exitTimeout),{close(a){s=a,i.close.done()},exit(a){s=a,i.exit.done()},get exitCode(){return s},result:o}}function n(s,i,o){s!==!1&&(s===!0?i.promise:i.promise.then(()=>de(s))).then(o.done)}return{type:"spawn.after",action(s,i){return ht(this,arguments,function*(o,{spawned:a,close:l}){var p,_;let y=r(),v=!0,h=()=>void(v=!1);(p=a.stdout)==null||p.on("data",h),(_=a.stderr)==null||_.on("data",h),a.on("error",h),a.on("close",X=>y.close(X)),a.on("exit",X=>y.exit(X));try{yield y.result,v&&(yield de(50)),l(y.exitCode)}catch(X){l(y.exitCode,X)}})}}}d();var Xu="Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings",tn="Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option";function Zu(t){return!t||!/^([a-z]:)?([a-z0-9/.\\_-]+)$/i.test(t)}function en(t,e){if(t.length<1||t.length>2)throw new V(void 0,"binary",Xu);if(t.some(Zu))if(e)console.warn(tn);else throw new V(void 0,"binary",tn);let[n,s]=t;return{binary:n,prefix:s}}function tc(t,e=["git"],r=!1){let n=en(U(e),r);t.on("binary",s=>{n=en(U(s),r)}),t.append("spawn.binary",()=>n.binary),t.append("spawn.args",s=>n.prefix?[n.prefix,...s]:s)}K();function ec(t){return!!(t.exitCode&&t.stdErr.length)}function rc(t){return Buffer.concat([...t.stdOut,...t.stdErr])}function nc(t=!1,e=ec,r=rc){return(n,s)=>!t&&n||!e(s)?n:r(s)}function rn(t){return{type:"task.error",action(e,r){let n=t(e.error,{stdErr:r.stdErr,stdOut:r.stdOut,exitCode:r.exitCode});return Buffer.isBuffer(n)?{error:new W(void 0,n.toString("utf-8"))}:{error:n}}}}d();var ic=class{constructor(){this.plugins=new Set,this.events=new sc}on(t,e){this.events.on(t,e)}reconfigure(t,e){this.events.emit(t,e)}append(t,e){let r=b(this.plugins,{type:t,action:e});return()=>this.plugins.delete(r)}add(t){let e=[];return U(t).forEach(r=>r&&this.plugins.add(b(e,r))),()=>{e.forEach(r=>this.plugins.delete(r))}}exec(t,e,r){let n=e,s=Object.freeze(Object.create(r));for(let i of this.plugins)i.type===t&&(n=i.action(n,s));return n}};d();function oc(t){let e="--progress",r=["checkout","clone","fetch","pull","push"];return[{type:"spawn.args",action(i,o){return r.includes(o.method)?fn(i,e):i}},{type:"spawn.after",action(i,o){var a;o.commands.includes(e)&&((a=o.spawned.stderr)==null||a.on("data",l=>{let p=/^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(l.toString("utf8"));p&&t({method:o.method,stage:ac(p[1]),progress:w(p[2]),processed:w(p[3]),total:w(p[4])})}))}}]}function ac(t){return String(t.toLowerCase().split(" ",1))||"unknown"}d();function uc(t){let e=dn(t,["uid","gid"]);return{type:"spawn.options",action(r){return F(F({},e),r)}}}function cc({block:t,stdErr:e=!0,stdOut:r=!0}){if(t>0)return{type:"spawn.after",action(n,s){var i,o;let a;function l(){a&&clearTimeout(a),a=setTimeout(_,t)}function p(){var y,v;(y=s.spawned.stdout)==null||y.off("data",l),(v=s.spawned.stderr)==null||v.off("data",l),s.spawned.off("exit",p),s.spawned.off("close",p),a&&clearTimeout(a)}function _(){p(),s.kill(new V(void 0,"timeout","block timeout reached"))}r&&((i=s.spawned.stdout)==null||i.on("data",l)),e&&((o=s.spawned.stderr)==null||o.on("data",l)),s.spawned.on("exit",p),s.spawned.on("close",p),l()}}}bt();function lc(){return{type:"spawn.args",action(t){let e=[],r;function n(s){(r=r||[]).push(...s)}for(let s=0;s<t.length;s++){let i=t[s];if(jt(i)){n(Pr(i));continue}if(i==="--"){n(t.slice(s+1).flatMap(o=>jt(o)&&Pr(o)||o));break}e.push(i)}return r?[...e,"--",...r.map(String)]:e}}}d();var pc=qu();function fc(t,e){var r;let n=new ic,s=_n(t&&(typeof t=="string"?{baseDir:t}:t)||{},e);if(!Re(s.baseDir))throw new Ju(s,"Cannot use simple-git on a directory that does not exist");return Array.isArray(s.config)&&n.add(Yu(s.config)),n.add(Hu(s.unsafe)),n.add(lc()),n.add(Ku(s.completion)),s.abort&&n.add(zu(s.abort)),s.progress&&n.add(oc(s.progress)),s.timeout&&n.add(cc(s.timeout)),s.spawnOptions&&n.add(uc(s.spawnOptions)),n.add(rn(nc(!0))),s.errors&&n.add(rn(s.errors)),tc(n,s.binary,(r=s.unsafe)==null?void 0:r.allowUnsafeCustomBinary),new pc(s,n)}ut();var ii=fc;O();var oi=(t,e)=>{let r=/^(https:\/\/)?(?<slug>[\w-]+?)(--development)?(\..*)?$/.exec(t)?.groups?.slug;if(r)return r;throw new z(T`
56
- ${e} must be the application's {bold slug} or {bold URL}
57
-
58
- {bold EXAMPLES:}
59
- ${e} my-app
60
- ${e} my-app.gadget.app
61
- ${e} https://my-app.gadget.app
62
- ${e} https://my-app.gadget.app/edit
63
- ${e} https://my-app--development.gadget.app/edit
64
- `)};O();import Ke from"node:assert";var Yt=class{ctx;#t;constructor(e){this.ctx=e.child({name:"edit"}),this.#t=new fr(this.ctx,"/edit/api/graphql")}async query({query:e,variables:r,...n}){let s=e.match(/query (\w+)/)?.[1];Ke(s,"query name not found");let i=this.ctx.child({fields:{edit:{query:s}},devFields:{edit:{query:s,variables:ct(r)}}});i.log.info("executing graphql query");let o=await this.#t.execute(i,{operation:e,variables:r,...n,http:{retry:{methods:["POST"]},...n.http}});if(o.errors)throw new J(e,o.errors);if(!o.data)throw new J(e,"Query response did not contain data");return o.data}async mutate({mutation:e,variables:r,...n}){let s=e.match(/mutation (\w+)/)?.[1];Ke(s,"mutation name not found");let i=this.ctx.child({fields:{edit:{mutation:s}},devFields:{edit:{mutation:s,variables:ct(r)}}});i.log.info("executing graphql mutation");let o=await this.#t.execute(i,{operation:e,variables:r,...n});if(o.errors)throw new J(e,o.errors);if(!o.data)throw new J(e,"Mutation response did not contain data");return o.data}subscribe({onData:e,...r}){let n=r.subscription.match(/subscription (\w+)/)?.[1];Ke(n,"subscription name not found");let s=this.ctx.child({fields:{edit:{subscription:n}},devFields:{edit:{subscription:n,variables:ct(r.variables)}}}),i=async a=>{if(a.errors){o(),await r.onError(new J(r.subscription,a.errors));return}if(!a.data){o(),await r.onError(new J(r.subscription,"Subscription response did not contain data"));return}await e(a.data)};s.log.info("subscribing to graphql subscription");let o=this.#t.subscribe(s,{...r,onResponse:i});return{unsubscribe:()=>{o()},resubscribe:a=>{o(),a!==void 0&&(r.variables=a),s=this.ctx.child({fields:{edit:{subscription:n}},devFields:{edit:{subscription:n,variables:ct(r.variables)}}}),s.log.info("re-subscribing to graphql subscription"),o=this.#t.subscribe(s,{...r,onResponse:i})}}}async dispose(){await this.#t.dispose()}};var pp={"--app":{type:oi,alias:["-a","--application"]},"--env":{type:String,alias:["-e","--environment"]},"--allow-unknown-directory":Boolean,"--allow-different-app":Boolean},ui=class t{constructor(e,r,n,s){this.ctx=e;this.directory=r;this.previousEnvironment=n;this.state=s;this.ctx=e.child({fields:()=>({syncJson:{directory:this.directory.path,branch:this.gitBranch,...this.state}})}),Kt(this.ctx.app,"app must be set on syncJson context"),this.app=this.ctx.app,Kt(this.ctx.env,"env must be set on syncJson context"),this.env=this.ctx.env,this.edit=new Yt(this.ctx)}app;env;gitBranch;edit;_mtime;get filesVersion(){let e=this.state.environments[this.state.environment];return Kt(e,"environment must exist in environments"),BigInt(e.filesVersion)}static async load(e,{directory:r}){e=e.child({name:"sync-json"});let n=await gr(e),s=await re(e);if(s.length===0)throw new z(T`
65
- You (${n.email}) don't have have any Gadget applications.
66
-
67
- Visit https://gadget.new to create one!
68
- `);let i=await Xt.default.readFile(r.absolute(".gadget/sync.json"),"utf8").catch(p=>e.log.warn("failed to read .gadget/sync.json",{error:p}));if(!i)return;let o;try{o=yc.parse(JSON.parse(i))}catch(p){e.log.warn("failed to parse .gadget/sync.json",{error:p,syncJsonFile:i});return}if(e.app=await ci(e,{availableApps:s,state:o}),e.env=await li(e,{app:e.app,state:o}),o.application!==e.app.slug){if(e.args["--allow-different-app"]){let p=new t(e,r,void 0,{application:e.app.slug,environment:e.env.name,environments:{[e.env.name]:{filesVersion:"0"}}});return await p.loadGitBranch(),p}throw new z(T`
69
- You were about to sync the following app to the following directory:
70
-
71
- ${e.app.slug} (${e.env.name}) → ${r.path}
72
-
73
- However, that directory has already been synced with this app:
74
-
75
- ${o.application} (${o.environment})
76
-
77
- If you're sure that you want to sync:
78
-
79
- ${e.app.slug} (${e.env.name}) → ${r.path}
80
-
81
- Run "ggt dev" with the {bold --allow-different-app} flag.
82
- `)}let a;o.environment!==e.env.name&&(H({ensureEmptyLineAbove:!0})`
83
- Changing environment.
84
-
85
- ${o.environment} → ${e.env.name}
86
- `,a=o.environment,o.environment=e.env.name,o.environments[e.env.name]||(o.environments[e.env.name]={filesVersion:"0"}));let l=new t(e,r,a,o);return await l.save(l.filesVersion),await l.loadGitBranch(),l}static async loadOrInit(e,{directory:r}){e=e.child({name:"sync-json"});let n=await t.load(e,{directory:r});if(n)return n;if(await r.hasFiles()&&!e.args["--allow-unknown-directory"])throw new Ot(e,{directory:r});return e.app=await ci(e,{availableApps:await re(e)}),e.env=await li(e,{app:e.app}),await Xt.default.ensureDir(r.path),n=new t(e,r,void 0,{application:e.app.slug,environment:e.env.name,environments:{[e.env.name]:{filesVersion:"0"}}}),await n.save(n.filesVersion),await n.loadGitBranch(),n}async save(e){let r=this.state.environments[this.state.environment];Kt(r,"environment must exist in environments"),r.filesVersion=String(e),this.ctx.log.debug("saving .gadget/sync.json"),this._mtime=Date.now(),await Xt.default.outputJSON(this.directory.absolute(".gadget/sync.json"),{...this.state,app:this.state.application,filesVersion:String(e),mtime:this._mtime},{spaces:2})}async loadGitBranch(){this.gitBranch=await mc(this.ctx,{directory:this.directory})}sprint(e={}){let r=R`
87
- Application ${this.app.slug}
88
- Environment ${this.env.name}
89
- `;return this.gitBranch&&(r+=R({indent:5})`Branch ${this.gitBranch}`),st.isSupported?r+=R({ensureEmptyLineAbove:!0})`
90
- ${st("Preview",`https://${this.app.slug}--${this.env.name}.gadget.app`)} ${st("Editor",`https://${this.app.primaryDomain}/edit/${this.env.name}`)} ${st("Playground",`https://${this.app.primaryDomain}/api/playground/graphql?environment=${this.env.name}`)} ${st("Docs",`https://docs.gadget.dev/api/${this.app.slug}`)}
91
- `:r+=R`
92
- ------------------------
93
- Preview https://${this.app.slug}--${this.env.name}.gadget.app
94
- Editor https://${this.app.primaryDomain}/edit/${this.env.name}
95
- Playground https://${this.app.primaryDomain}/api/playground/graphql?environment=${this.env.name}
96
- Docs https://docs.gadget.dev/api/${this.app.slug}
97
- `,R(e)(r)}print(e){e=lt(e,{ensureEmptyLineAbove:!0}),H(this.sprint(e))}},fp=async t=>{or.windows&&t.startsWith("~/")&&(t=ar(t.slice(2)));let e=await ir(".gadget/sync.json",{cwd:t});return e&&(t=ai.join(e,"../..")),t=ai.resolve(t),await pr.init(t)},ci=async(t,{availableApps:e,state:r})=>{let n=t.args["--app"]||r?.application;n||(n=await oe({choices:e.map(o=>o.slug)})`
98
- Which application do you want to develop?
99
- `);let s=e.find(o=>o.slug===n);if(s)return s;let i=ee(n,e.map(o=>o.slug)).slice(0,5);throw new z(T`
100
- Unknown application:
101
-
102
- ${n}
103
-
104
- Did you mean one of these?
105
-
106
- • ${i.join(`
107
- \u2022 `)}
108
- `)},li=async(t,{app:e,state:r})=>{if(t.args["--env"]&&!e.multiEnvironmentEnabled)throw new z(T`
109
- You specified an environment but your app doesn't have multiple environments.
110
-
111
- Remove the "--env" flag to sync to the {bold ${e.primaryDomain}} environment.
112
- `);let n=e.environments.filter(a=>a.type===dr.Development),s=t.args["--env"]||r?.environment;if(s||(s=await oe({choices:n.map(a=>a.name)})`
113
- Which environment do you want to develop on?
114
- `),s.toLowerCase()==="production")throw new z(T`
115
- You cannot "ggt ${t.command}" your {bold production} environment.
116
- `);let i=n.find(a=>a.name===s.toLowerCase());if(i)return i;let o=ee(s,n.map(a=>a.name)).slice(0,5);throw new z(T`
117
- Unknown environment:
118
-
119
- ${s}
120
-
121
- Did you mean one of these?
122
-
123
- • ${o.join(`
124
- \u2022 `)}
125
- `)},mc=async(t,{directory:e})=>{try{return await ii(e.path).revparse(["--abbrev-ref","HEAD"])}catch(r){t.log.warn("failed to read git branch",{error:r});return}},hc=I.object({application:I.string(),environment:I.string(),environments:I.record(I.object({filesVersion:I.string()}))}),dc=I.object({app:I.string(),filesVersion:I.string(),mtime:I.number()}),gc=I.union([hc,dc]),yc=gc.transform(t=>"environment"in t?t:{application:t.app,environment:"development",environments:{development:{filesVersion:t.filesVersion}}});export{Tc as a,ne as b,Sc as c,xc as d,Pc as e,vr as f,Ot as g,br as h,_r as i,Wi as j,Dc as k,oe as l,pp as m,ui as n,fp as o};
126
- //# sourceMappingURL=chunk-RJOIQTYZ.js.map