@gadgetinc/ggt 1.7.2 → 1.7.4

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 (55) hide show
  1. package/README.md +1 -0
  2. package/dist/{add-BIKODQCS.js → add-KJLV4API.js} +5 -5
  3. package/dist/add-KJLV4API.js.map +7 -0
  4. package/dist/{chunk-FGUWID6B.js → chunk-J2OYMAMD.js} +2 -2
  5. package/dist/{chunk-XQWSZW7K.js → chunk-L5H5T2T6.js} +2 -2
  6. package/dist/chunk-M6L2X3GX.js +194 -0
  7. package/dist/chunk-M6L2X3GX.js.map +7 -0
  8. package/dist/{chunk-ILB6CSBN.js → chunk-MHTXRD5G.js} +2 -2
  9. package/dist/{chunk-KMNQ3LJT.js → chunk-OIVNACS7.js} +2 -2
  10. package/dist/{chunk-KMNQ3LJT.js.map → chunk-OIVNACS7.js.map} +2 -2
  11. package/dist/{chunk-DYAWQS24.js → chunk-X47UA3VR.js} +2 -2
  12. package/dist/{chunk-MBWB2XUY.js → chunk-XKYYKHP4.js} +4 -4
  13. package/dist/chunk-XKYYKHP4.js.map +7 -0
  14. package/dist/chunk-YU6P3ESA.js +121 -0
  15. package/dist/chunk-YU6P3ESA.js.map +7 -0
  16. package/dist/{configure-LD5XC2MR.js → configure-CXY6JQB7.js} +2 -2
  17. package/dist/deploy-XFZBJJWP.js +25 -0
  18. package/dist/deploy-XFZBJJWP.js.map +7 -0
  19. package/dist/{dev-O5KGPP2V.js → dev-GG6TU3DJ.js} +4 -3
  20. package/dist/{dev-O5KGPP2V.js.map → dev-GG6TU3DJ.js.map} +2 -2
  21. package/dist/{list-O5JTZNKN.js → list-3QZTSHQV.js} +2 -2
  22. package/dist/login-HKGCVIWO.js +2 -0
  23. package/dist/{logout-ACRXIJEF.js → logout-SWWGI27Q.js} +2 -2
  24. package/dist/{logs-SS34WQ2K.js → logs-DW4PH3U6.js} +2 -2
  25. package/dist/main.js +1 -1
  26. package/dist/{open-JQTW6XFM.js → open-J2ZVNVJ6.js} +2 -2
  27. package/dist/{pull-5HLV3C74.js → pull-ORNQFSFG.js} +2 -2
  28. package/dist/push-KMZZ6JJL.js +2 -0
  29. package/dist/{status-PL7MJVN7.js → status-JAREJZ4X.js} +2 -2
  30. package/dist/{whoami-3RPUP2PK.js → whoami-MIJFO4MW.js} +2 -2
  31. package/package.json +1 -1
  32. package/dist/add-BIKODQCS.js.map +0 -7
  33. package/dist/chunk-D2R4J557.js +0 -116
  34. package/dist/chunk-D2R4J557.js.map +0 -7
  35. package/dist/chunk-MBWB2XUY.js.map +0 -7
  36. package/dist/chunk-VJTDX5WL.js +0 -194
  37. package/dist/chunk-VJTDX5WL.js.map +0 -7
  38. package/dist/deploy-3H3W42UM.js +0 -25
  39. package/dist/deploy-3H3W42UM.js.map +0 -7
  40. package/dist/login-6MLYS6A4.js +0 -2
  41. package/dist/push-62ZJ6D3R.js +0 -2
  42. /package/dist/{chunk-FGUWID6B.js.map → chunk-J2OYMAMD.js.map} +0 -0
  43. /package/dist/{chunk-XQWSZW7K.js.map → chunk-L5H5T2T6.js.map} +0 -0
  44. /package/dist/{chunk-ILB6CSBN.js.map → chunk-MHTXRD5G.js.map} +0 -0
  45. /package/dist/{chunk-DYAWQS24.js.map → chunk-X47UA3VR.js.map} +0 -0
  46. /package/dist/{configure-LD5XC2MR.js.map → configure-CXY6JQB7.js.map} +0 -0
  47. /package/dist/{list-O5JTZNKN.js.map → list-3QZTSHQV.js.map} +0 -0
  48. /package/dist/{login-6MLYS6A4.js.map → login-HKGCVIWO.js.map} +0 -0
  49. /package/dist/{logout-ACRXIJEF.js.map → logout-SWWGI27Q.js.map} +0 -0
  50. /package/dist/{logs-SS34WQ2K.js.map → logs-DW4PH3U6.js.map} +0 -0
  51. /package/dist/{open-JQTW6XFM.js.map → open-J2ZVNVJ6.js.map} +0 -0
  52. /package/dist/{pull-5HLV3C74.js.map → pull-ORNQFSFG.js.map} +0 -0
  53. /package/dist/{push-62ZJ6D3R.js.map → push-KMZZ6JJL.js.map} +0 -0
  54. /package/dist/{status-PL7MJVN7.js.map → status-JAREJZ4X.js.map} +0 -0
  55. /package/dist/{whoami-3RPUP2PK.js.map → whoami-MIJFO4MW.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{a as l}from"./chunk-JBY5A44K.js";import{c as g}from"./chunk-KMNQ3LJT.js";import{A as d,Z as i,ca as c,ja as r}from"./chunk-24OT7GHO.js";import{a as s,f as p,h as u}from"./chunk-7DYQUG5M.js";u();var f=p(d(),1);var D=s(async t=>{let o=i.defaultsConfigFile,e;if(await l({ensureEmptyLineAbove:!0,choices:["default","configure"],content:"Default configuration from Gadget or configure manually"})==="configure"){let n=await l({ensureEmptyLineAbove:!0,choices:["enable","disable"],content:"Automatically send crash reports and telemetry to Gadget"}),m=await l({ensureEmptyLineAbove:!0,choices:["disable","enable"],content:"ggt output as JSON"});e={telemetry:n==="enable",json:m==="enable"}}else e={telemetry:!0,json:!1};return await f.default.outputJSON(o,e).then(()=>{r("Default arguments were saved.")},n=>{t.log.error("failed to write config",{error:n.message})}),e},"promptDefaultsConfig"),x=s(async(t,o)=>{let e=i.defaultsConfigFile,a;try{a=await f.default.readJSON(e)}catch(n){g(n),c.isInteractive&&o?(r("No ggt defaults were found to have been configured. Please answer the prompts to configure your defaults."),a=await D(t),r("To update these options later, see `ggt configure`.")):a={}}return a},"loadDefaultsConfig"),v=s(async t=>{let o=i.defaultsConfigFile;await f.default.outputJSON(o,{}).then(()=>{r("Default arguments were saved.")},e=>{t.log.error("failed to write config",{error:e.message})})},"clearDefaultsConfig");export{D as a,x as b,v as c};
2
- //# sourceMappingURL=chunk-ILB6CSBN.js.map
1
+ import{a as l}from"./chunk-JBY5A44K.js";import{c as g}from"./chunk-OIVNACS7.js";import{A as d,Z as i,ca as c,ja as r}from"./chunk-24OT7GHO.js";import{a as s,f as p,h as u}from"./chunk-7DYQUG5M.js";u();var f=p(d(),1);var D=s(async t=>{let o=i.defaultsConfigFile,e;if(await l({ensureEmptyLineAbove:!0,choices:["default","configure"],content:"Default configuration from Gadget or configure manually"})==="configure"){let n=await l({ensureEmptyLineAbove:!0,choices:["enable","disable"],content:"Automatically send crash reports and telemetry to Gadget"}),m=await l({ensureEmptyLineAbove:!0,choices:["disable","enable"],content:"ggt output as JSON"});e={telemetry:n==="enable",json:m==="enable"}}else e={telemetry:!0,json:!1};return await f.default.outputJSON(o,e).then(()=>{r("Default arguments were saved.")},n=>{t.log.error("failed to write config",{error:n.message})}),e},"promptDefaultsConfig"),x=s(async(t,o)=>{let e=i.defaultsConfigFile,a;try{a=await f.default.readJSON(e)}catch(n){g(n),c.isInteractive&&o?(r("No ggt defaults were found to have been configured. Please answer the prompts to configure your defaults."),a=await D(t),r("To update these options later, see `ggt configure`.")):a={}}return a},"loadDefaultsConfig"),v=s(async t=>{let o=i.defaultsConfigFile;await f.default.outputJSON(o,{}).then(()=>{r("Default arguments were saved.")},e=>{t.log.error("failed to write config",{error:e.message})})},"clearDefaultsConfig");export{D as a,x as b,v as c};
2
+ //# sourceMappingURL=chunk-MHTXRD5G.js.map
@@ -1,4 +1,4 @@
1
- import{A as z}from"./chunk-24OT7GHO.js";import{a as n,d as $,f as _,h as c}from"./chunk-7DYQUG5M.js";var G=$((ht,H)=>{c();function v(e){return Array.isArray(e)?e:[e]}n(v,"makeArray");var m="",N=" ",d="\\",k=/^\s+$/,W=/(?:[^\\]|^)\\$/,j=/^\\!/,B=/^\\#/,V=/\r?\n/g,K=/^\.*\/|^\.+$/,E="/",C="node-ignore";typeof Symbol<"u"&&(C=Symbol.for("node-ignore"));var S=C,Y=n((e,t,s)=>Object.defineProperty(e,t,{value:s}),"define"),M=/([0-z])-([0-z])/g,I=n(()=>!1,"RETURN_FALSE"),q=n(e=>e.replace(M,(t,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?t:m),"sanitizeRange"),J=n(e=>{let{length:t}=e;return e.slice(0,t-t%2)},"cleanRangeBackSlash"),Q=[[/^\uFEFF/,()=>m],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,s)=>t+(s.indexOf("\\")===0?N:m)],[/(\\+?)\s/g,(e,t)=>{let{length:s}=t;return t.slice(0,s-s%2)+N}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,n(function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"},"startingReplacer")],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,s)=>t+6<s.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,s)=>{let r=s.replace(/\\\*/g,"[^\\/]*");return t+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>d],[/\\\\/g,()=>d],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,s,r,i)=>t===d?`\\[${s}${J(r)}${i}`:i==="]"&&r.length%2===0?`[${q(s)}${r}]`:"[]"],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(e,t)=>`${t?`${t}[^/]+`:"[^/]*"}(?=$|\\/$)`]],b=Object.create(null),U=n((e,t)=>{let s=b[e];return s||(s=Q.reduce((r,[i,o])=>r.replace(i,o.bind(e)),e),b[e]=s),t?new RegExp(s,"i"):new RegExp(s)},"makeRegex"),p=n(e=>typeof e=="string","isString"),Z=n(e=>e&&p(e)&&!k.test(e)&&!W.test(e)&&e.indexOf("#")!==0,"checkPattern"),tt=n(e=>e.split(V),"splitPattern"),y=class{static{n(this,"IgnoreRule")}constructor(t,s,r,i){this.origin=t,this.pattern=s,this.negative=r,this.regex=i}},et=n((e,t)=>{let s=e,r=!1;e.indexOf("!")===0&&(r=!0,e=e.substr(1)),e=e.replace(j,"!").replace(B,"#");let i=U(e,t);return new y(s,e,r,i)},"createRule"),st=n((e,t)=>{throw new t(e)},"throwError"),a=n((e,t,s)=>p(e)?e?a.isNotRelative(e)?s(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${t}\``,TypeError),"checkPath"),O=n(e=>K.test(e),"isNotRelative");a.isNotRelative=O;a.convert=e=>e;var R=class{static{n(this,"Ignore")}constructor({ignorecase:t=!0,ignoreCase:s=t,allowRelativePaths:r=!1}={}){Y(this,S,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(t){if(t&&t[S]){this._rules=this._rules.concat(t._rules),this._added=!0;return}if(Z(t)){let s=et(t,this._ignoreCase);this._added=!0,this._rules.push(s)}}add(t){return this._added=!1,v(p(t)?tt(t):t).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(t){return this.add(t)}_testOne(t,s){let r=!1,i=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(i===u&&r!==i||u&&!r&&!i&&!s)return;o.regex.test(t)&&(r=!u,i=u)}),{ignored:r,unignored:i}}_test(t,s,r,i){let o=t&&a.convert(t);return a(o,t,this._allowRelativePaths?I:st),this._t(o,s,r,i)}_t(t,s,r,i){if(t in s)return s[t];if(i||(i=t.split(E)),i.pop(),!i.length)return s[t]=this._testOne(t,r);let o=this._t(i.join(E)+E,s,r,i);return s[t]=o.ignored?o:this._testOne(t,r)}ignores(t){return this._test(t,this._ignoreCache,!1).ignored}createFilter(){return t=>!this.ignores(t)}filter(t){return v(t).filter(this.createFilter())}test(t){return this._test(t,this._testCache,!0)}},g=n(e=>new R(e),"factory"),rt=n(e=>a(e&&a.convert(e),e,I),"isPathValid");g.isPathValid=rt;g.default=g;H.exports=g;if(typeof process<"u"&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform==="win32")){let e=n(s=>/^\\\\\?\\/.test(s)||/["<>|\u0000-\u001F]+/u.test(s)?s:s.replace(/\\/g,"/"),"makePosix");a.convert=e;let t=/^[a-z]:\//i;a.isNotRelative=s=>t.test(s)||O(s)}});var L=$((Et,T)=>{c();T.exports=function(e,t){if(typeof e!="string")throw new TypeError("expected path to be a string");if(e==="\\"||e==="/")return"/";var s=e.length;if(s<=1)return e;var r="";if(s>4&&e[3]==="\\"){var i=e[2];(i==="?"||i===".")&&e.slice(0,2)==="\\\\"&&(e=e.slice(2),r="//")}var o=e.split(/[/\\]+/);return t!==!1&&o[o.length-1]===""&&o.pop(),r+o.join("/")}});c();var f=_(z(),1),D=_(G(),1),A=_(L(),1);import it from"node:assert";import{createHash as nt}from"node:crypto";import l from"node:path";import{Transform as ot}from"node:stream";import{pipeline as at}from"node:stream/promises";var ct=[".gadget/"],lt=[".DS_Store","node_modules",".git"],ut=[".gadget/sync.json",".gadget/backup","yarn-error.log"],F=class e{constructor(t){this.path=t}static{n(this,"Directory")}_ignorer;_isHashing=!1;static async init(t){let s=new e(t);return await s.loadIgnoreFile(),s}relative(t){return l.isAbsolute(t)?l.relative(this.path,t):t}absolute(...t){let s=l.resolve(this.path,...t);return it(s.startsWith(this.path),`expected ${s} to be within ${this.path}`),s}normalize(t,s){return l.isAbsolute(t)&&(t=this.relative(t)),t=(0,A.default)(t,!0),s&&(t+="/"),t}async loadIgnoreFile(){this._ignorer=D.default.default(),this._ignorer.add(lt);try{let t=await f.default.readFile(this.absolute(".ignore"),"utf8");this._ignorer.add(t)}catch(t){X(t)}}ignores(t){return t=this.relative(t),t===""?!1:t.startsWith("..")||(t=(0,A.default)(t,!1),this._isHashing&&ut.some(s=>t.startsWith(s)))?!0:ct.some(s=>t.startsWith(s))?!1:this._ignorer.ignores(t)}async*walk({dir:t=this.path}={}){t!==this.path&&(yield this.normalize(t,!0));for await(let s of await f.default.opendir(t)){let r=l.join(t,s.name);this.ignores(r)||(s.isDirectory()?yield*this.walk({dir:r}):s.isFile()&&(yield this.normalize(r,!1)))}}async hashes(){try{this._isHashing=!0;let t={};for await(let s of this.walk()){let r=this.absolute(s);t[s]=await gt(r)}return t}finally{this._isHashing=!1}}async hasFiles(){return!await this.isEmptyOrNonExistent()}async isEmptyOrNonExistent(){let t=!0;try{for await(let s of this.walk()){t=!1;break}}catch(s){X(s)}return t}},ft=process.platform==="linux"||process.platform==="darwin",gt=n(async e=>{let t=nt("sha1");t.update(l.basename(e));let s=await f.default.stat(e),r;if(ft&&(r=s.mode&511),s.isDirectory())return{sha1:t.digest("hex"),permissions:r};let i=new ot({transform(o,u,h){if(!o.includes(13)){h(void 0,o);return}let x=Buffer.alloc(o.length),P=0;for(let w of o)w!==13&&(x[P++]=w);h(void 0,x.subarray(0,P))}});return await at(f.default.createReadStream(e),i,t),{sha1:t.digest("hex"),permissions:r}},"hash"),X=n(e=>{if(!(e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT"))throw e},"swallowEnoent");export{F as a,ft as b,X as c};
1
+ import{A as z}from"./chunk-24OT7GHO.js";import{a as n,d as $,f as _,h as c}from"./chunk-7DYQUG5M.js";var G=$((ht,H)=>{c();function v(e){return Array.isArray(e)?e:[e]}n(v,"makeArray");var m="",N=" ",d="\\",k=/^\s+$/,W=/(?:[^\\]|^)\\$/,j=/^\\!/,B=/^\\#/,V=/\r?\n/g,K=/^\.*\/|^\.+$/,E="/",C="node-ignore";typeof Symbol<"u"&&(C=Symbol.for("node-ignore"));var S=C,Y=n((e,t,s)=>Object.defineProperty(e,t,{value:s}),"define"),M=/([0-z])-([0-z])/g,I=n(()=>!1,"RETURN_FALSE"),q=n(e=>e.replace(M,(t,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?t:m),"sanitizeRange"),J=n(e=>{let{length:t}=e;return e.slice(0,t-t%2)},"cleanRangeBackSlash"),Q=[[/^\uFEFF/,()=>m],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,s)=>t+(s.indexOf("\\")===0?N:m)],[/(\\+?)\s/g,(e,t)=>{let{length:s}=t;return t.slice(0,s-s%2)+N}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,n(function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"},"startingReplacer")],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,s)=>t+6<s.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,s)=>{let r=s.replace(/\\\*/g,"[^\\/]*");return t+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>d],[/\\\\/g,()=>d],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,s,r,i)=>t===d?`\\[${s}${J(r)}${i}`:i==="]"&&r.length%2===0?`[${q(s)}${r}]`:"[]"],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(e,t)=>`${t?`${t}[^/]+`:"[^/]*"}(?=$|\\/$)`]],b=Object.create(null),U=n((e,t)=>{let s=b[e];return s||(s=Q.reduce((r,[i,o])=>r.replace(i,o.bind(e)),e),b[e]=s),t?new RegExp(s,"i"):new RegExp(s)},"makeRegex"),p=n(e=>typeof e=="string","isString"),Z=n(e=>e&&p(e)&&!k.test(e)&&!W.test(e)&&e.indexOf("#")!==0,"checkPattern"),tt=n(e=>e.split(V),"splitPattern"),y=class{static{n(this,"IgnoreRule")}constructor(t,s,r,i){this.origin=t,this.pattern=s,this.negative=r,this.regex=i}},et=n((e,t)=>{let s=e,r=!1;e.indexOf("!")===0&&(r=!0,e=e.substr(1)),e=e.replace(j,"!").replace(B,"#");let i=U(e,t);return new y(s,e,r,i)},"createRule"),st=n((e,t)=>{throw new t(e)},"throwError"),a=n((e,t,s)=>p(e)?e?a.isNotRelative(e)?s(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${t}\``,TypeError),"checkPath"),O=n(e=>K.test(e),"isNotRelative");a.isNotRelative=O;a.convert=e=>e;var R=class{static{n(this,"Ignore")}constructor({ignorecase:t=!0,ignoreCase:s=t,allowRelativePaths:r=!1}={}){Y(this,S,!0),this._rules=[],this._ignoreCase=s,this._allowRelativePaths=r,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(t){if(t&&t[S]){this._rules=this._rules.concat(t._rules),this._added=!0;return}if(Z(t)){let s=et(t,this._ignoreCase);this._added=!0,this._rules.push(s)}}add(t){return this._added=!1,v(p(t)?tt(t):t).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(t){return this.add(t)}_testOne(t,s){let r=!1,i=!1;return this._rules.forEach(o=>{let{negative:u}=o;if(i===u&&r!==i||u&&!r&&!i&&!s)return;o.regex.test(t)&&(r=!u,i=u)}),{ignored:r,unignored:i}}_test(t,s,r,i){let o=t&&a.convert(t);return a(o,t,this._allowRelativePaths?I:st),this._t(o,s,r,i)}_t(t,s,r,i){if(t in s)return s[t];if(i||(i=t.split(E)),i.pop(),!i.length)return s[t]=this._testOne(t,r);let o=this._t(i.join(E)+E,s,r,i);return s[t]=o.ignored?o:this._testOne(t,r)}ignores(t){return this._test(t,this._ignoreCache,!1).ignored}createFilter(){return t=>!this.ignores(t)}filter(t){return v(t).filter(this.createFilter())}test(t){return this._test(t,this._testCache,!0)}},g=n(e=>new R(e),"factory"),rt=n(e=>a(e&&a.convert(e),e,I),"isPathValid");g.isPathValid=rt;g.default=g;H.exports=g;if(typeof process<"u"&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform==="win32")){let e=n(s=>/^\\\\\?\\/.test(s)||/["<>|\u0000-\u001F]+/u.test(s)?s:s.replace(/\\/g,"/"),"makePosix");a.convert=e;let t=/^[a-z]:\//i;a.isNotRelative=s=>t.test(s)||O(s)}});var L=$((Et,T)=>{c();T.exports=function(e,t){if(typeof e!="string")throw new TypeError("expected path to be a string");if(e==="\\"||e==="/")return"/";var s=e.length;if(s<=1)return e;var r="";if(s>4&&e[3]==="\\"){var i=e[2];(i==="?"||i===".")&&e.slice(0,2)==="\\\\"&&(e=e.slice(2),r="//")}var o=e.split(/[/\\]+/);return t!==!1&&o[o.length-1]===""&&o.pop(),r+o.join("/")}});c();var f=_(z(),1),D=_(G(),1),A=_(L(),1);import it from"node:assert";import{createHash as nt}from"node:crypto";import l from"node:path";import{Transform as ot}from"node:stream";import{pipeline as at}from"node:stream/promises";var ct=[".gadget/"],lt=[".DS_Store","node_modules",".git",".shopify"],ut=[".gadget/sync.json",".gadget/backup","yarn-error.log"],F=class e{constructor(t){this.path=t}static{n(this,"Directory")}_ignorer;_isHashing=!1;static async init(t){let s=new e(t);return await s.loadIgnoreFile(),s}relative(t){return l.isAbsolute(t)?l.relative(this.path,t):t}absolute(...t){let s=l.resolve(this.path,...t);return it(s.startsWith(this.path),`expected ${s} to be within ${this.path}`),s}normalize(t,s){return l.isAbsolute(t)&&(t=this.relative(t)),t=(0,A.default)(t,!0),s&&(t+="/"),t}async loadIgnoreFile(){this._ignorer=D.default.default(),this._ignorer.add(lt);try{let t=await f.default.readFile(this.absolute(".ignore"),"utf8");this._ignorer.add(t)}catch(t){X(t)}}ignores(t){return t=this.relative(t),t===""?!1:t.startsWith("..")||(t=(0,A.default)(t,!1),this._isHashing&&ut.some(s=>t.startsWith(s)))?!0:ct.some(s=>t.startsWith(s))?!1:this._ignorer.ignores(t)}async*walk({dir:t=this.path}={}){t!==this.path&&(yield this.normalize(t,!0));for await(let s of await f.default.opendir(t)){let r=l.join(t,s.name);this.ignores(r)||(s.isDirectory()?yield*this.walk({dir:r}):s.isFile()&&(yield this.normalize(r,!1)))}}async hashes(){try{this._isHashing=!0;let t={};for await(let s of this.walk()){let r=this.absolute(s);t[s]=await gt(r)}return t}finally{this._isHashing=!1}}async hasFiles(){return!await this.isEmptyOrNonExistent()}async isEmptyOrNonExistent(){let t=!0;try{for await(let s of this.walk()){t=!1;break}}catch(s){X(s)}return t}},ft=process.platform==="linux"||process.platform==="darwin",gt=n(async e=>{let t=nt("sha1");t.update(l.basename(e));let s=await f.default.stat(e),r;if(ft&&(r=s.mode&511),s.isDirectory())return{sha1:t.digest("hex"),permissions:r};let i=new ot({transform(o,u,h){if(!o.includes(13)){h(void 0,o);return}let x=Buffer.alloc(o.length),P=0;for(let w of o)w!==13&&(x[P++]=w);h(void 0,x.subarray(0,P))}});return await at(f.default.createReadStream(e),i,t),{sha1:t.digest("hex"),permissions:r}},"hash"),X=n(e=>{if(!(e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT"))throw e},"swallowEnoent");export{F as a,ft as b,X as c};
2
2
  /*! Bundled license information:
3
3
 
4
4
  normalize-path/index.js:
@@ -9,4 +9,4 @@ normalize-path/index.js:
9
9
  * Released under the MIT License.
10
10
  *)
11
11
  */
12
- //# sourceMappingURL=chunk-KMNQ3LJT.js.map
12
+ //# sourceMappingURL=chunk-OIVNACS7.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../node_modules/.pnpm/ignore@6.0.2/node_modules/ignore/index.js", "../node_modules/.pnpm/normalize-path@3.0.0/node_modules/normalize-path/index.js", "../src/services/filesync/directory.ts"],
4
- "sourcesContent": ["// A simple implementation of make-array\nfunction makeArray (subject) {\n return Array.isArray(subject)\n ? subject\n : [subject]\n}\n\nconst EMPTY = ''\nconst SPACE = ' '\nconst ESCAPE = '\\\\'\nconst REGEX_TEST_BLANK_LINE = /^\\s+$/\nconst REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\\\]|^)\\\\$/\nconst REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\\\!/\nconst REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\\\#/\nconst REGEX_SPLITALL_CRLF = /\\r?\\n/g\n// /foo,\n// ./foo,\n// ../foo,\n// .\n// ..\nconst REGEX_TEST_INVALID_PATH = /^\\.*\\/|^\\.+$/\n\nconst SLASH = '/'\n\n// Do not use ternary expression here, since \"istanbul ignore next\" is buggy\nlet TMP_KEY_IGNORE = 'node-ignore'\n/* istanbul ignore else */\nif (typeof Symbol !== 'undefined') {\n TMP_KEY_IGNORE = Symbol.for('node-ignore')\n}\nconst KEY_IGNORE = TMP_KEY_IGNORE\n\nconst define = (object, key, value) =>\n Object.defineProperty(object, key, {value})\n\nconst REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g\n\nconst RETURN_FALSE = () => false\n\n// Sanitize the range of a regular expression\n// The cases are complicated, see test cases for details\nconst sanitizeRange = range => range.replace(\n REGEX_REGEXP_RANGE,\n (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)\n ? match\n // Invalid range (out of order) which is ok for gitignore rules but\n // fatal for JavaScript regular expression, so eliminate it.\n : EMPTY\n)\n\n// See fixtures #59\nconst cleanRangeBackSlash = slashes => {\n const {length} = slashes\n return slashes.slice(0, length - length % 2)\n}\n\n// > If the pattern ends with a slash,\n// > it is removed for the purpose of the following description,\n// > but it would only find a match with a directory.\n// > In other words, foo/ will match a directory foo and paths underneath it,\n// > but will not match a regular file or a symbolic link foo\n// > (this is consistent with the way how pathspec works in general in Git).\n// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'\n// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call\n// you could use option `mark: true` with `glob`\n\n// '`foo/`' should not continue with the '`..`'\nconst REPLACERS = [\n\n [\n // remove BOM\n // TODO:\n // Other similar zero-width characters?\n /^\\uFEFF/,\n () => EMPTY\n ],\n\n // > Trailing spaces are ignored unless they are quoted with backslash (\"\\\")\n [\n // (a\\ ) -> (a )\n // (a ) -> (a)\n // (a ) -> (a)\n // (a \\ ) -> (a )\n /((?:\\\\\\\\)*?)(\\\\?\\s+)$/,\n (_, m1, m2) => m1 + (\n m2.indexOf('\\\\') === 0\n ? SPACE\n : EMPTY\n )\n ],\n\n // replace (\\ ) with ' '\n // (\\ ) -> ' '\n // (\\\\ ) -> '\\\\ '\n // (\\\\\\ ) -> '\\\\ '\n [\n /(\\\\+?)\\s/g,\n (_, m1) => {\n const {length} = m1\n return m1.slice(0, length - length % 2) + SPACE\n }\n ],\n\n // Escape metacharacters\n // which is written down by users but means special for regular expressions.\n\n // > There are 12 characters with special meanings:\n // > - the backslash \\,\n // > - the caret ^,\n // > - the dollar sign $,\n // > - the period or dot .,\n // > - the vertical bar or pipe symbol |,\n // > - the question mark ?,\n // > - the asterisk or star *,\n // > - the plus sign +,\n // > - the opening parenthesis (,\n // > - the closing parenthesis ),\n // > - and the opening square bracket [,\n // > - the opening curly brace {,\n // > These special characters are often called \"metacharacters\".\n [\n /[\\\\$.|*+(){^]/g,\n match => `\\\\${match}`\n ],\n\n [\n // > a question mark (?) matches a single character\n /(?!\\\\)\\?/g,\n () => '[^/]'\n ],\n\n // leading slash\n [\n\n // > A leading slash matches the beginning of the pathname.\n // > For example, \"/*.c\" matches \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n // A leading slash matches the beginning of the pathname\n /^\\//,\n () => '^'\n ],\n\n // replace special metacharacter slash after the leading slash\n [\n /\\//g,\n () => '\\\\/'\n ],\n\n [\n // > A leading \"**\" followed by a slash means match in all directories.\n // > For example, \"**/foo\" matches file or directory \"foo\" anywhere,\n // > the same as pattern \"foo\".\n // > \"**/foo/bar\" matches file or directory \"bar\" anywhere that is directly\n // > under directory \"foo\".\n // Notice that the '*'s have been replaced as '\\\\*'\n /^\\^*\\\\\\*\\\\\\*\\\\\\//,\n\n // '**/foo' <-> 'foo'\n () => '^(?:.*\\\\/)?'\n ],\n\n // starting\n [\n // there will be no leading '/'\n // (which has been replaced by section \"leading slash\")\n // If starts with '**', adding a '^' to the regular expression also works\n /^(?=[^^])/,\n function startingReplacer () {\n // If has a slash `/` at the beginning or middle\n return !/\\/(?!$)/.test(this)\n // > Prior to 2.22.1\n // > If the pattern does not contain a slash /,\n // > Git treats it as a shell glob pattern\n // Actually, if there is only a trailing slash,\n // git also treats it as a shell glob pattern\n\n // After 2.22.1 (compatible but clearer)\n // > If there is a separator at the beginning or middle (or both)\n // > of the pattern, then the pattern is relative to the directory\n // > level of the particular .gitignore file itself.\n // > Otherwise the pattern may also match at any level below\n // > the .gitignore level.\n ? '(?:^|\\\\/)'\n\n // > Otherwise, Git treats the pattern as a shell glob suitable for\n // > consumption by fnmatch(3)\n : '^'\n }\n ],\n\n // two globstars\n [\n // Use lookahead assertions so that we could match more than one `'/**'`\n /\\\\\\/\\\\\\*\\\\\\*(?=\\\\\\/|$)/g,\n\n // Zero, one or several directories\n // should not use '*', or it will be replaced by the next replacer\n\n // Check if it is not the last `'/**'`\n (_, index, str) => index + 6 < str.length\n\n // case: /**/\n // > A slash followed by two consecutive asterisks then a slash matches\n // > zero or more directories.\n // > For example, \"a/**/b\" matches \"a/b\", \"a/x/b\", \"a/x/y/b\" and so on.\n // '/**/'\n ? '(?:\\\\/[^\\\\/]+)*'\n\n // case: /**\n // > A trailing `\"/**\"` matches everything inside.\n\n // #21: everything inside but it should not include the current folder\n : '\\\\/.+'\n ],\n\n // normal intermediate wildcards\n [\n // Never replace escaped '*'\n // ignore rule '\\*' will match the path '*'\n\n // 'abc.*/' -> go\n // 'abc.*' -> skip this rule,\n // coz trailing single wildcard will be handed by [trailing wildcard]\n /(^|[^\\\\]+)(\\\\\\*)+(?=.+)/g,\n\n // '*.js' matches '.js'\n // '*.js' doesn't match 'abc'\n (_, p1, p2) => {\n // 1.\n // > An asterisk \"*\" matches anything except a slash.\n // 2.\n // > Other consecutive asterisks are considered regular asterisks\n // > and will match according to the previous rules.\n const unescaped = p2.replace(/\\\\\\*/g, '[^\\\\/]*')\n return p1 + unescaped\n }\n ],\n\n [\n // unescape, revert step 3 except for back slash\n // For example, if a user escape a '\\\\*',\n // after step 3, the result will be '\\\\\\\\\\\\*'\n /\\\\\\\\\\\\(?=[$.|*+(){^])/g,\n () => ESCAPE\n ],\n\n [\n // '\\\\\\\\' -> '\\\\'\n /\\\\\\\\/g,\n () => ESCAPE\n ],\n\n [\n // > The range notation, e.g. [a-zA-Z],\n // > can be used to match one of the characters in a range.\n\n // `\\` is escaped by step 3\n /(\\\\)?\\[([^\\]/]*?)(\\\\*)($|\\])/g,\n (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE\n // '\\\\[bar]' -> '\\\\\\\\[bar\\\\]'\n ? `\\\\[${range}${cleanRangeBackSlash(endEscape)}${close}`\n : close === ']'\n ? endEscape.length % 2 === 0\n // A normal case, and it is a range notation\n // '[bar]'\n // '[bar\\\\\\\\]'\n ? `[${sanitizeRange(range)}${endEscape}]`\n // Invalid range notaton\n // '[bar\\\\]' -> '[bar\\\\\\\\]'\n : '[]'\n : '[]'\n ],\n\n // ending\n [\n // 'js' will not match 'js.'\n // 'ab' will not match 'abc'\n /(?:[^*])$/,\n\n // WTF!\n // https://git-scm.com/docs/gitignore\n // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)\n // which re-fixes #24, #38\n\n // > If there is a separator at the end of the pattern then the pattern\n // > will only match directories, otherwise the pattern can match both\n // > files and directories.\n\n // 'js*' will not match 'a.js'\n // 'js/' will not match 'a.js'\n // 'js' will match 'a.js' and 'a.js/'\n match => /\\/$/.test(match)\n // foo/ will not match 'foo'\n ? `${match}$`\n // foo matches 'foo' and 'foo/'\n : `${match}(?=$|\\\\/$)`\n ],\n\n // trailing wildcard\n [\n /(\\^|\\\\\\/)?\\\\\\*$/,\n (_, p1) => {\n const prefix = p1\n // '\\^':\n // '/*' does not match EMPTY\n // '/*' does not match everything\n\n // '\\\\\\/':\n // 'abc/*' does not match 'abc/'\n ? `${p1}[^/]+`\n\n // 'a*' matches 'a'\n // 'a*' matches 'aa'\n : '[^/]*'\n\n return `${prefix}(?=$|\\\\/$)`\n }\n ],\n]\n\n// A simple cache, because an ignore rule only has only one certain meaning\nconst regexCache = Object.create(null)\n\n// @param {pattern}\nconst makeRegex = (pattern, ignoreCase) => {\n let source = regexCache[pattern]\n\n if (!source) {\n source = REPLACERS.reduce(\n (prev, [matcher, replacer]) =>\n prev.replace(matcher, replacer.bind(pattern)),\n pattern\n )\n regexCache[pattern] = source\n }\n\n return ignoreCase\n ? new RegExp(source, 'i')\n : new RegExp(source)\n}\n\nconst isString = subject => typeof subject === 'string'\n\n// > A blank line matches no files, so it can serve as a separator for readability.\nconst checkPattern = pattern => pattern\n && isString(pattern)\n && !REGEX_TEST_BLANK_LINE.test(pattern)\n && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)\n\n // > A line starting with # serves as a comment.\n && pattern.indexOf('#') !== 0\n\nconst splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF)\n\nclass IgnoreRule {\n constructor (\n origin,\n pattern,\n negative,\n regex\n ) {\n this.origin = origin\n this.pattern = pattern\n this.negative = negative\n this.regex = regex\n }\n}\n\nconst createRule = (pattern, ignoreCase) => {\n const origin = pattern\n let negative = false\n\n // > An optional prefix \"!\" which negates the pattern;\n if (pattern.indexOf('!') === 0) {\n negative = true\n pattern = pattern.substr(1)\n }\n\n pattern = pattern\n // > Put a backslash (\"\\\") in front of the first \"!\" for patterns that\n // > begin with a literal \"!\", for example, `\"\\!important!.txt\"`.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')\n // > Put a backslash (\"\\\") in front of the first hash for patterns that\n // > begin with a hash.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#')\n\n const regex = makeRegex(pattern, ignoreCase)\n\n return new IgnoreRule(\n origin,\n pattern,\n negative,\n regex\n )\n}\n\nconst throwError = (message, Ctor) => {\n throw new Ctor(message)\n}\n\nconst checkPath = (path, originalPath, doThrow) => {\n if (!isString(path)) {\n return doThrow(\n `path must be a string, but got \\`${originalPath}\\``,\n TypeError\n )\n }\n\n // We don't know if we should ignore EMPTY, so throw\n if (!path) {\n return doThrow(`path must not be empty`, TypeError)\n }\n\n // Check if it is a relative path\n if (checkPath.isNotRelative(path)) {\n const r = '`path.relative()`d'\n return doThrow(\n `path should be a ${r} string, but got \"${originalPath}\"`,\n RangeError\n )\n }\n\n return true\n}\n\nconst isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path)\n\ncheckPath.isNotRelative = isNotRelative\ncheckPath.convert = p => p\n\nclass Ignore {\n constructor ({\n ignorecase = true,\n ignoreCase = ignorecase,\n allowRelativePaths = false\n } = {}) {\n define(this, KEY_IGNORE, true)\n\n this._rules = []\n this._ignoreCase = ignoreCase\n this._allowRelativePaths = allowRelativePaths\n this._initCache()\n }\n\n _initCache () {\n this._ignoreCache = Object.create(null)\n this._testCache = Object.create(null)\n }\n\n _addPattern (pattern) {\n // #32\n if (pattern && pattern[KEY_IGNORE]) {\n this._rules = this._rules.concat(pattern._rules)\n this._added = true\n return\n }\n\n if (checkPattern(pattern)) {\n const rule = createRule(pattern, this._ignoreCase)\n this._added = true\n this._rules.push(rule)\n }\n }\n\n // @param {Array<string> | string | Ignore} pattern\n add (pattern) {\n this._added = false\n\n makeArray(\n isString(pattern)\n ? splitPattern(pattern)\n : pattern\n ).forEach(this._addPattern, this)\n\n // Some rules have just added to the ignore,\n // making the behavior changed.\n if (this._added) {\n this._initCache()\n }\n\n return this\n }\n\n // legacy\n addPattern (pattern) {\n return this.add(pattern)\n }\n\n // | ignored : unignored\n // negative | 0:0 | 0:1 | 1:0 | 1:1\n // -------- | ------- | ------- | ------- | --------\n // 0 | TEST | TEST | SKIP | X\n // 1 | TESTIF | SKIP | TEST | X\n\n // - SKIP: always skip\n // - TEST: always test\n // - TESTIF: only test if checkUnignored\n // - X: that never happen\n\n // @param {boolean} whether should check if the path is unignored,\n // setting `checkUnignored` to `false` could reduce additional\n // path matching.\n\n // @returns {TestResult} true if a file is ignored\n _testOne (path, checkUnignored) {\n let ignored = false\n let unignored = false\n\n this._rules.forEach(rule => {\n const {negative} = rule\n if (\n unignored === negative && ignored !== unignored\n || negative && !ignored && !unignored && !checkUnignored\n ) {\n return\n }\n\n const matched = rule.regex.test(path)\n\n if (matched) {\n ignored = !negative\n unignored = negative\n }\n })\n\n return {\n ignored,\n unignored\n }\n }\n\n // @returns {TestResult}\n _test (originalPath, cache, checkUnignored, slices) {\n const path = originalPath\n // Supports nullable path\n && checkPath.convert(originalPath)\n\n checkPath(\n path,\n originalPath,\n this._allowRelativePaths\n ? RETURN_FALSE\n : throwError\n )\n\n return this._t(path, cache, checkUnignored, slices)\n }\n\n _t (path, cache, checkUnignored, slices) {\n if (path in cache) {\n return cache[path]\n }\n\n if (!slices) {\n // path/to/a.js\n // ['path', 'to', 'a.js']\n slices = path.split(SLASH)\n }\n\n slices.pop()\n\n // If the path has no parent directory, just test it\n if (!slices.length) {\n return cache[path] = this._testOne(path, checkUnignored)\n }\n\n const parent = this._t(\n slices.join(SLASH) + SLASH,\n cache,\n checkUnignored,\n slices\n )\n\n // If the path contains a parent directory, check the parent first\n return cache[path] = parent.ignored\n // > It is not possible to re-include a file if a parent directory of\n // > that file is excluded.\n ? parent\n : this._testOne(path, checkUnignored)\n }\n\n ignores (path) {\n return this._test(path, this._ignoreCache, false).ignored\n }\n\n createFilter () {\n return path => !this.ignores(path)\n }\n\n filter (paths) {\n return makeArray(paths).filter(this.createFilter())\n }\n\n // @returns {TestResult}\n test (path) {\n return this._test(path, this._testCache, true)\n }\n}\n\nconst factory = options => new Ignore(options)\n\nconst isPathValid = path =>\n checkPath(path && checkPath.convert(path), path, RETURN_FALSE)\n\nfactory.isPathValid = isPathValid\n\n// Fixes typescript\nfactory.default = factory\n\nmodule.exports = factory\n\n// Windows\n// --------------------------------------------------------------\n/* istanbul ignore if */\nif (\n // Detect `process` so that it can run in browsers.\n typeof process !== 'undefined'\n && (\n process.env && process.env.IGNORE_TEST_WIN32\n || process.platform === 'win32'\n )\n) {\n /* eslint no-control-regex: \"off\" */\n const makePosix = str => /^\\\\\\\\\\?\\\\/.test(str)\n || /[\"<>|\\u0000-\\u001F]+/u.test(str)\n ? str\n : str.replace(/\\\\/g, '/')\n\n checkPath.convert = makePosix\n\n // 'C:\\\\foo' <- 'C:\\\\foo' has been converted to 'C:/'\n // 'd:\\\\foo'\n const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\\//i\n checkPath.isNotRelative = path =>\n REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)\n || isNotRelative(path)\n}\n", "/*!\n * normalize-path <https://github.com/jonschlinkert/normalize-path>\n *\n * Copyright (c) 2014-2018, Jon Schlinkert.\n * Released under the MIT License.\n */\n\nmodule.exports = function(path, stripTrailing) {\n if (typeof path !== 'string') {\n throw new TypeError('expected path to be a string');\n }\n\n if (path === '\\\\' || path === '/') return '/';\n\n var len = path.length;\n if (len <= 1) return path;\n\n // ensure that win32 namespaces has two leading slashes, so that the path is\n // handled properly by the win32 version of path.parse() after being normalized\n // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces\n var prefix = '';\n if (len > 4 && path[3] === '\\\\') {\n var ch = path[2];\n if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\\\\\') {\n path = path.slice(2);\n prefix = '//';\n }\n }\n\n var segs = path.split(/[/\\\\]+/);\n if (stripTrailing !== false && segs[segs.length - 1] === '') {\n segs.pop();\n }\n return prefix + segs.join('/');\n};\n", "/**\n * DO NOT MODIFY\n *\n * Everything in this file also exists in gadget to ensure that this logic\n * is the same between the two projects.\n */\nimport fs from \"fs-extra\";\nimport type { Ignore } from \"ignore\";\nimport ignore from \"ignore\";\nimport assert from \"node:assert\";\nimport { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport { Transform } from \"node:stream\";\nimport { pipeline } from \"node:stream/promises\";\nimport normalizePath from \"normalize-path\";\n\n/**\n * Paths that are never ignored, regardless of the contents of the `.ignore` file.\n */\nexport const NEVER_IGNORE_PATHS = [\".gadget/\"] as const;\n\n/**\n * Paths that are always ignored, regardless of the contents of the `.ignore` file.\n */\nexport const ALWAYS_IGNORE_PATHS = [\".DS_Store\", \"node_modules\", \".git\"] as const;\n\n/**\n * Paths that are ignored when hashing the directory.\n *\n * NOTE: This is the _only_ thing that is allowed to be different between gadget and ggt.\n */\nexport const HASHING_IGNORE_PATHS = [\".gadget/sync.json\", \".gadget/backup\", \"yarn-error.log\"] as const;\n\n/**\n * Represents a directory that is being synced.\n */\nexport class Directory {\n /**\n * A gitignore-style file parser used to determine which files to\n * ignore while syncing.\n *\n * @see https://www.npmjs.com/package/ignore\n */\n private _ignorer!: Ignore;\n\n /**\n * Whether the directory is currently being hashed.\n */\n private _isHashing = false;\n\n private constructor(\n /**\n * An absolute path to the directory that is being synced.\n */\n readonly path: string,\n ) {}\n\n /**\n * Initializes a directory to be synced.\n *\n * If the directory does not exist, it is created.\n *\n * @param dir - The directory to initialize.\n * @returns A Promise that resolves to a Directory instance.\n */\n static async init(dir: string): Promise<Directory> {\n const directory = new Directory(dir);\n await directory.loadIgnoreFile();\n return directory;\n }\n\n /**\n * Returns the relative path from this directory to the specified path.\n *\n * @param to - The path to which the relative path is calculated.\n * @returns The relative path from this directory to the specified path.\n */\n relative(to: string): string {\n if (!path.isAbsolute(to)) {\n // the filepath is already relative\n return to;\n }\n\n return path.relative(this.path, to);\n }\n\n /**\n * Returns the absolute path by resolving the given path segments\n * relative to the directory path.\n *\n * @param pathSegments - The path segments to resolve.\n * @returns The absolute path.\n */\n absolute(...pathSegments: string[]): string {\n const result = path.resolve(this.path, ...pathSegments);\n assert(result.startsWith(this.path), `expected ${result} to be within ${this.path}`);\n return result;\n }\n\n /**\n * Similar to {@linkcode relative} in that it converts an absolute\n * path into a relative one from {@linkcode path}. However, it also\n * changes any slashes to be posix/unix-like forward slashes,\n * condenses repeated slashes into a single slash, and adds a trailing\n * slash if the path is a directory.\n *\n * This is used when sending files to Gadget to ensure that the paths\n * are consistent across platforms.\n *\n * @see https://www.npmjs.com/package/normalize-path\n */\n normalize(filepath: string, isDirectory: boolean): string {\n if (path.isAbsolute(filepath)) {\n filepath = this.relative(filepath);\n }\n\n // true = trim trailing slashes\n filepath = normalizePath(filepath, true);\n\n if (isDirectory) {\n filepath += \"/\";\n }\n\n return filepath;\n }\n\n /**\n * Loads the `.ignore` file in the directory. If the file does not\n * exist, it is silently ignored.\n */\n async loadIgnoreFile(): Promise<void> {\n this._ignorer = ignore.default();\n this._ignorer.add(ALWAYS_IGNORE_PATHS);\n\n try {\n const content = await fs.readFile(this.absolute(\".ignore\"), \"utf8\");\n this._ignorer.add(content);\n } catch (error) {\n swallowEnoent(error);\n }\n }\n\n /**\n * Determines if a file should be ignored based on its filepath.\n *\n * @param filepath - The filepath of the file to check.\n * @returns True if the file should be ignored, false otherwise.\n */\n ignores(filepath: string): boolean {\n filepath = this.relative(filepath);\n if (filepath === \"\") {\n // don't ignore the root dir\n return false;\n }\n\n if (filepath.startsWith(\"..\")) {\n // anything above the root dir is ignored\n return true;\n }\n\n // false = don't trim trailing slashes\n filepath = normalizePath(filepath, false);\n if (this._isHashing && HASHING_IGNORE_PATHS.some((ignored) => filepath.startsWith(ignored))) {\n // special case for hashing\n return true;\n }\n\n if (NEVER_IGNORE_PATHS.some((neverIgnored) => filepath.startsWith(neverIgnored))) {\n // special case for never ignored paths\n return false;\n }\n\n return this._ignorer.ignores(filepath);\n }\n\n /**\n * Recursively walks through the directory and yields all non-ignored\n * files and directories within it.\n *\n * @yields - The normalized path of each file and directory.\n */\n async *walk({ dir = this.path } = {}): AsyncGenerator<string> {\n // don't yield the root directory\n if (dir !== this.path) {\n yield this.normalize(dir, true);\n }\n\n for await (const entry of await fs.opendir(dir)) {\n const filepath = path.join(dir, entry.name);\n if (this.ignores(filepath)) {\n continue;\n }\n\n if (entry.isDirectory()) {\n yield* this.walk({ dir: filepath });\n } else if (entry.isFile()) {\n yield this.normalize(filepath, false);\n }\n }\n }\n\n /**\n * Calculates the hash of each file and directory and returns an\n * object containing the hashes keyed by the normalized file path.\n *\n * @returns A Promise that resolves to an object containing the hashes\n * of each file.\n */\n async hashes(): Promise<Hashes> {\n try {\n this._isHashing = true;\n const files = {} as Hashes;\n\n for await (const normalizedPath of this.walk()) {\n const absolutePath = this.absolute(normalizedPath);\n files[normalizedPath] = await hash(absolutePath);\n }\n\n return files;\n } finally {\n this._isHashing = false;\n }\n }\n\n async hasFiles(): Promise<boolean> {\n return !(await this.isEmptyOrNonExistent());\n }\n\n async isEmptyOrNonExistent(): Promise<boolean> {\n let isEmptyOrNonExistent = true;\n try {\n for await (const _ of this.walk()) {\n isEmptyOrNonExistent = false;\n break;\n }\n } catch (error) {\n swallowEnoent(error);\n }\n return isEmptyOrNonExistent;\n }\n}\n\n/**\n * Key/value pairs where the key is the normalized path and the value is\n * the result of {@linkcode hash} for that path.\n */\nexport type Hashes = Record<string, Hash>;\n\nexport type Hash = {\n /**\n * The SHA-1 hash of the file or directory.\n *\n * If the path points to a directory, the hash is calculated based on\n * the directory's basename. If the path points to a file, the hash is\n * calculated based on the file's basename and contents.\n */\n sha1: string;\n\n /**\n * The Unix-style file permissions of the file or directory, or\n * undefined if the platform that generated this hash doesn't support\n * them.\n *\n * @example 0o644\n * @see supportsPermissions\n */\n permissions?: number;\n};\n\n/**\n * Whether the current platform supports Unix-style file permissions.\n *\n * Windows doesn't support Unix-style file permissions and all file\n * permissions retrieved via `node:fs` on Windows are translated to 666\n * or 444.\n */\nexport const supportsPermissions = process.platform === \"linux\" || process.platform === \"darwin\";\n\n/**\n * Calculates the {@linkcode Hash} of the file or directory at the\n * specified absolute path.\n *\n * @param absolutePath - The absolute path to the file or directory.\n * @returns A Promise that resolves to the {@linkcode Hash} of the file\n * or directory.\n */\nconst hash = async (absolutePath: string): Promise<Hash> => {\n const sha1 = createHash(\"sha1\");\n sha1.update(path.basename(absolutePath));\n\n const stats = await fs.stat(absolutePath);\n\n let permissions;\n if (supportsPermissions) {\n // strip everything but the permissions\n permissions = stats.mode & 0o777;\n }\n\n if (stats.isDirectory()) {\n return { sha1: sha1.digest(\"hex\"), permissions };\n }\n\n // windows uses CRLF line endings whereas unix uses LF line endings so\n // we always strip out CR bytes (0x0d) when hashing files. this does\n // make us blind to files that only differ by CR bytes, but that's a\n // tradeoff we're willing to make.\n const removeCR = new Transform({\n transform(chunk: Buffer, _encoding, callback) {\n if (!chunk.includes(0x0d)) {\n callback(undefined, chunk);\n return;\n }\n\n const filteredChunk = Buffer.alloc(chunk.length);\n let i = 0;\n for (const byte of chunk) {\n if (byte !== 0x0d) {\n filteredChunk[i++] = byte;\n }\n }\n\n callback(undefined, filteredChunk.subarray(0, i));\n },\n });\n\n await pipeline(fs.createReadStream(absolutePath), removeCR, sha1);\n\n return { sha1: sha1.digest(\"hex\"), permissions };\n};\n\n/**\n * Swallows ENOENT errors and throws any other errors.\n *\n * @param error - The error to handle.\n * @throws The original error if it is not an ENOENT error.\n */\nexport const swallowEnoent = (error: unknown): void => {\n if (error && typeof error === \"object\" && \"code\" in error && error.code === \"ENOENT\") {\n return;\n }\n throw error;\n};\n"],
5
- "mappings": "qGAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,CAAAC,IACA,SAASC,EAAWC,EAAS,CAC3B,OAAO,MAAM,QAAQA,CAAO,EACxBA,EACA,CAACA,CAAO,CACd,CAJSC,EAAAF,EAAA,aAMT,IAAMG,EAAQ,GACRC,EAAQ,IACRC,EAAS,KACTC,EAAwB,QACxBC,EAAmC,iBACnCC,EAA4C,OAC5CC,EAAqC,OACrCC,EAAsB,SAMtBC,EAA0B,eAE1BC,EAAQ,IAGVC,EAAiB,cAEjB,OAAO,OAAW,MACpBA,EAAiB,OAAO,IAAI,aAAa,GAE3C,IAAMC,EAAaD,EAEbE,EAASb,EAAA,CAACc,EAAQC,EAAKC,IAC3B,OAAO,eAAeF,EAAQC,EAAK,CAAC,MAAAC,CAAK,CAAC,EAD7B,UAGTC,EAAqB,mBAErBC,EAAelB,EAAA,IAAM,GAAN,gBAIfmB,EAAgBnB,EAAAoB,GAASA,EAAM,QACnCH,EACA,CAACI,EAAOC,EAAMC,IAAOD,EAAK,WAAW,CAAC,GAAKC,EAAG,WAAW,CAAC,EACtDF,EAGApB,CACN,EAPsB,iBAUhBuB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AAuB,GACvB,KACF,CACF,OAAST,EAAO,CACdC,EAAcD,CAAK,CACrB,CACA,OAAOS,CACT,CACF,EAoCaE,GAAsB,QAAQ,WAAa,SAAW,QAAQ,WAAa,SAUlFH,GAAOrB,EAAA,MAAOoB,GAAwC,CAC1D,IAAMK,EAAOC,GAAW,MAAM,EAC9BD,EAAK,OAAO1B,EAAK,SAASqB,CAAY,CAAC,EAEvC,IAAMO,EAAQ,MAAM,EAAAf,QAAG,KAAKQ,CAAY,EAEpCQ,EAMJ,GALIJ,KAEFI,EAAcD,EAAM,KAAO,KAGzBA,EAAM,YAAY,EACpB,MAAO,CAAE,KAAMF,EAAK,OAAO,KAAK,EAAG,YAAAG,CAAY,EAOjD,IAAMC,EAAW,IAAIC,GAAU,CAC7B,UAAUC,EAAeC,EAAWC,EAAU,CAC5C,GAAI,CAACF,EAAM,SAAS,EAAI,EAAG,CACzBE,EAAS,OAAWF,CAAK,EACzB,MACF,CAEA,IAAMG,EAAgB,OAAO,MAAMH,EAAM,MAAM,EAC3CI,EAAI,EACR,QAAWC,KAAQL,EACbK,IAAS,KACXF,EAAcC,GAAG,EAAIC,GAIzBH,EAAS,OAAWC,EAAc,SAAS,EAAGC,CAAC,CAAC,CAClD,CACF,CAAC,EAED,aAAME,GAAS,EAAAzB,QAAG,iBAAiBQ,CAAY,EAAGS,EAAUJ,CAAI,EAEzD,CAAE,KAAMA,EAAK,OAAO,KAAK,EAAG,YAAAG,CAAY,CACjD,EA1Ca,QAkDAd,EAAgBd,EAACa,GAAyB,CACrD,GAAI,EAAAA,GAAS,OAAOA,GAAU,UAAY,SAAUA,GAASA,EAAM,OAAS,UAG5E,MAAMA,CACR,EAL6B",
4
+ "sourcesContent": ["// A simple implementation of make-array\nfunction makeArray (subject) {\n return Array.isArray(subject)\n ? subject\n : [subject]\n}\n\nconst EMPTY = ''\nconst SPACE = ' '\nconst ESCAPE = '\\\\'\nconst REGEX_TEST_BLANK_LINE = /^\\s+$/\nconst REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\\\]|^)\\\\$/\nconst REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\\\!/\nconst REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\\\#/\nconst REGEX_SPLITALL_CRLF = /\\r?\\n/g\n// /foo,\n// ./foo,\n// ../foo,\n// .\n// ..\nconst REGEX_TEST_INVALID_PATH = /^\\.*\\/|^\\.+$/\n\nconst SLASH = '/'\n\n// Do not use ternary expression here, since \"istanbul ignore next\" is buggy\nlet TMP_KEY_IGNORE = 'node-ignore'\n/* istanbul ignore else */\nif (typeof Symbol !== 'undefined') {\n TMP_KEY_IGNORE = Symbol.for('node-ignore')\n}\nconst KEY_IGNORE = TMP_KEY_IGNORE\n\nconst define = (object, key, value) =>\n Object.defineProperty(object, key, {value})\n\nconst REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g\n\nconst RETURN_FALSE = () => false\n\n// Sanitize the range of a regular expression\n// The cases are complicated, see test cases for details\nconst sanitizeRange = range => range.replace(\n REGEX_REGEXP_RANGE,\n (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)\n ? match\n // Invalid range (out of order) which is ok for gitignore rules but\n // fatal for JavaScript regular expression, so eliminate it.\n : EMPTY\n)\n\n// See fixtures #59\nconst cleanRangeBackSlash = slashes => {\n const {length} = slashes\n return slashes.slice(0, length - length % 2)\n}\n\n// > If the pattern ends with a slash,\n// > it is removed for the purpose of the following description,\n// > but it would only find a match with a directory.\n// > In other words, foo/ will match a directory foo and paths underneath it,\n// > but will not match a regular file or a symbolic link foo\n// > (this is consistent with the way how pathspec works in general in Git).\n// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'\n// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call\n// you could use option `mark: true` with `glob`\n\n// '`foo/`' should not continue with the '`..`'\nconst REPLACERS = [\n\n [\n // remove BOM\n // TODO:\n // Other similar zero-width characters?\n /^\\uFEFF/,\n () => EMPTY\n ],\n\n // > Trailing spaces are ignored unless they are quoted with backslash (\"\\\")\n [\n // (a\\ ) -> (a )\n // (a ) -> (a)\n // (a ) -> (a)\n // (a \\ ) -> (a )\n /((?:\\\\\\\\)*?)(\\\\?\\s+)$/,\n (_, m1, m2) => m1 + (\n m2.indexOf('\\\\') === 0\n ? SPACE\n : EMPTY\n )\n ],\n\n // replace (\\ ) with ' '\n // (\\ ) -> ' '\n // (\\\\ ) -> '\\\\ '\n // (\\\\\\ ) -> '\\\\ '\n [\n /(\\\\+?)\\s/g,\n (_, m1) => {\n const {length} = m1\n return m1.slice(0, length - length % 2) + SPACE\n }\n ],\n\n // Escape metacharacters\n // which is written down by users but means special for regular expressions.\n\n // > There are 12 characters with special meanings:\n // > - the backslash \\,\n // > - the caret ^,\n // > - the dollar sign $,\n // > - the period or dot .,\n // > - the vertical bar or pipe symbol |,\n // > - the question mark ?,\n // > - the asterisk or star *,\n // > - the plus sign +,\n // > - the opening parenthesis (,\n // > - the closing parenthesis ),\n // > - and the opening square bracket [,\n // > - the opening curly brace {,\n // > These special characters are often called \"metacharacters\".\n [\n /[\\\\$.|*+(){^]/g,\n match => `\\\\${match}`\n ],\n\n [\n // > a question mark (?) matches a single character\n /(?!\\\\)\\?/g,\n () => '[^/]'\n ],\n\n // leading slash\n [\n\n // > A leading slash matches the beginning of the pathname.\n // > For example, \"/*.c\" matches \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n // A leading slash matches the beginning of the pathname\n /^\\//,\n () => '^'\n ],\n\n // replace special metacharacter slash after the leading slash\n [\n /\\//g,\n () => '\\\\/'\n ],\n\n [\n // > A leading \"**\" followed by a slash means match in all directories.\n // > For example, \"**/foo\" matches file or directory \"foo\" anywhere,\n // > the same as pattern \"foo\".\n // > \"**/foo/bar\" matches file or directory \"bar\" anywhere that is directly\n // > under directory \"foo\".\n // Notice that the '*'s have been replaced as '\\\\*'\n /^\\^*\\\\\\*\\\\\\*\\\\\\//,\n\n // '**/foo' <-> 'foo'\n () => '^(?:.*\\\\/)?'\n ],\n\n // starting\n [\n // there will be no leading '/'\n // (which has been replaced by section \"leading slash\")\n // If starts with '**', adding a '^' to the regular expression also works\n /^(?=[^^])/,\n function startingReplacer () {\n // If has a slash `/` at the beginning or middle\n return !/\\/(?!$)/.test(this)\n // > Prior to 2.22.1\n // > If the pattern does not contain a slash /,\n // > Git treats it as a shell glob pattern\n // Actually, if there is only a trailing slash,\n // git also treats it as a shell glob pattern\n\n // After 2.22.1 (compatible but clearer)\n // > If there is a separator at the beginning or middle (or both)\n // > of the pattern, then the pattern is relative to the directory\n // > level of the particular .gitignore file itself.\n // > Otherwise the pattern may also match at any level below\n // > the .gitignore level.\n ? '(?:^|\\\\/)'\n\n // > Otherwise, Git treats the pattern as a shell glob suitable for\n // > consumption by fnmatch(3)\n : '^'\n }\n ],\n\n // two globstars\n [\n // Use lookahead assertions so that we could match more than one `'/**'`\n /\\\\\\/\\\\\\*\\\\\\*(?=\\\\\\/|$)/g,\n\n // Zero, one or several directories\n // should not use '*', or it will be replaced by the next replacer\n\n // Check if it is not the last `'/**'`\n (_, index, str) => index + 6 < str.length\n\n // case: /**/\n // > A slash followed by two consecutive asterisks then a slash matches\n // > zero or more directories.\n // > For example, \"a/**/b\" matches \"a/b\", \"a/x/b\", \"a/x/y/b\" and so on.\n // '/**/'\n ? '(?:\\\\/[^\\\\/]+)*'\n\n // case: /**\n // > A trailing `\"/**\"` matches everything inside.\n\n // #21: everything inside but it should not include the current folder\n : '\\\\/.+'\n ],\n\n // normal intermediate wildcards\n [\n // Never replace escaped '*'\n // ignore rule '\\*' will match the path '*'\n\n // 'abc.*/' -> go\n // 'abc.*' -> skip this rule,\n // coz trailing single wildcard will be handed by [trailing wildcard]\n /(^|[^\\\\]+)(\\\\\\*)+(?=.+)/g,\n\n // '*.js' matches '.js'\n // '*.js' doesn't match 'abc'\n (_, p1, p2) => {\n // 1.\n // > An asterisk \"*\" matches anything except a slash.\n // 2.\n // > Other consecutive asterisks are considered regular asterisks\n // > and will match according to the previous rules.\n const unescaped = p2.replace(/\\\\\\*/g, '[^\\\\/]*')\n return p1 + unescaped\n }\n ],\n\n [\n // unescape, revert step 3 except for back slash\n // For example, if a user escape a '\\\\*',\n // after step 3, the result will be '\\\\\\\\\\\\*'\n /\\\\\\\\\\\\(?=[$.|*+(){^])/g,\n () => ESCAPE\n ],\n\n [\n // '\\\\\\\\' -> '\\\\'\n /\\\\\\\\/g,\n () => ESCAPE\n ],\n\n [\n // > The range notation, e.g. [a-zA-Z],\n // > can be used to match one of the characters in a range.\n\n // `\\` is escaped by step 3\n /(\\\\)?\\[([^\\]/]*?)(\\\\*)($|\\])/g,\n (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE\n // '\\\\[bar]' -> '\\\\\\\\[bar\\\\]'\n ? `\\\\[${range}${cleanRangeBackSlash(endEscape)}${close}`\n : close === ']'\n ? endEscape.length % 2 === 0\n // A normal case, and it is a range notation\n // '[bar]'\n // '[bar\\\\\\\\]'\n ? `[${sanitizeRange(range)}${endEscape}]`\n // Invalid range notaton\n // '[bar\\\\]' -> '[bar\\\\\\\\]'\n : '[]'\n : '[]'\n ],\n\n // ending\n [\n // 'js' will not match 'js.'\n // 'ab' will not match 'abc'\n /(?:[^*])$/,\n\n // WTF!\n // https://git-scm.com/docs/gitignore\n // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)\n // which re-fixes #24, #38\n\n // > If there is a separator at the end of the pattern then the pattern\n // > will only match directories, otherwise the pattern can match both\n // > files and directories.\n\n // 'js*' will not match 'a.js'\n // 'js/' will not match 'a.js'\n // 'js' will match 'a.js' and 'a.js/'\n match => /\\/$/.test(match)\n // foo/ will not match 'foo'\n ? `${match}$`\n // foo matches 'foo' and 'foo/'\n : `${match}(?=$|\\\\/$)`\n ],\n\n // trailing wildcard\n [\n /(\\^|\\\\\\/)?\\\\\\*$/,\n (_, p1) => {\n const prefix = p1\n // '\\^':\n // '/*' does not match EMPTY\n // '/*' does not match everything\n\n // '\\\\\\/':\n // 'abc/*' does not match 'abc/'\n ? `${p1}[^/]+`\n\n // 'a*' matches 'a'\n // 'a*' matches 'aa'\n : '[^/]*'\n\n return `${prefix}(?=$|\\\\/$)`\n }\n ],\n]\n\n// A simple cache, because an ignore rule only has only one certain meaning\nconst regexCache = Object.create(null)\n\n// @param {pattern}\nconst makeRegex = (pattern, ignoreCase) => {\n let source = regexCache[pattern]\n\n if (!source) {\n source = REPLACERS.reduce(\n (prev, [matcher, replacer]) =>\n prev.replace(matcher, replacer.bind(pattern)),\n pattern\n )\n regexCache[pattern] = source\n }\n\n return ignoreCase\n ? new RegExp(source, 'i')\n : new RegExp(source)\n}\n\nconst isString = subject => typeof subject === 'string'\n\n// > A blank line matches no files, so it can serve as a separator for readability.\nconst checkPattern = pattern => pattern\n && isString(pattern)\n && !REGEX_TEST_BLANK_LINE.test(pattern)\n && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)\n\n // > A line starting with # serves as a comment.\n && pattern.indexOf('#') !== 0\n\nconst splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF)\n\nclass IgnoreRule {\n constructor (\n origin,\n pattern,\n negative,\n regex\n ) {\n this.origin = origin\n this.pattern = pattern\n this.negative = negative\n this.regex = regex\n }\n}\n\nconst createRule = (pattern, ignoreCase) => {\n const origin = pattern\n let negative = false\n\n // > An optional prefix \"!\" which negates the pattern;\n if (pattern.indexOf('!') === 0) {\n negative = true\n pattern = pattern.substr(1)\n }\n\n pattern = pattern\n // > Put a backslash (\"\\\") in front of the first \"!\" for patterns that\n // > begin with a literal \"!\", for example, `\"\\!important!.txt\"`.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')\n // > Put a backslash (\"\\\") in front of the first hash for patterns that\n // > begin with a hash.\n .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#')\n\n const regex = makeRegex(pattern, ignoreCase)\n\n return new IgnoreRule(\n origin,\n pattern,\n negative,\n regex\n )\n}\n\nconst throwError = (message, Ctor) => {\n throw new Ctor(message)\n}\n\nconst checkPath = (path, originalPath, doThrow) => {\n if (!isString(path)) {\n return doThrow(\n `path must be a string, but got \\`${originalPath}\\``,\n TypeError\n )\n }\n\n // We don't know if we should ignore EMPTY, so throw\n if (!path) {\n return doThrow(`path must not be empty`, TypeError)\n }\n\n // Check if it is a relative path\n if (checkPath.isNotRelative(path)) {\n const r = '`path.relative()`d'\n return doThrow(\n `path should be a ${r} string, but got \"${originalPath}\"`,\n RangeError\n )\n }\n\n return true\n}\n\nconst isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path)\n\ncheckPath.isNotRelative = isNotRelative\ncheckPath.convert = p => p\n\nclass Ignore {\n constructor ({\n ignorecase = true,\n ignoreCase = ignorecase,\n allowRelativePaths = false\n } = {}) {\n define(this, KEY_IGNORE, true)\n\n this._rules = []\n this._ignoreCase = ignoreCase\n this._allowRelativePaths = allowRelativePaths\n this._initCache()\n }\n\n _initCache () {\n this._ignoreCache = Object.create(null)\n this._testCache = Object.create(null)\n }\n\n _addPattern (pattern) {\n // #32\n if (pattern && pattern[KEY_IGNORE]) {\n this._rules = this._rules.concat(pattern._rules)\n this._added = true\n return\n }\n\n if (checkPattern(pattern)) {\n const rule = createRule(pattern, this._ignoreCase)\n this._added = true\n this._rules.push(rule)\n }\n }\n\n // @param {Array<string> | string | Ignore} pattern\n add (pattern) {\n this._added = false\n\n makeArray(\n isString(pattern)\n ? splitPattern(pattern)\n : pattern\n ).forEach(this._addPattern, this)\n\n // Some rules have just added to the ignore,\n // making the behavior changed.\n if (this._added) {\n this._initCache()\n }\n\n return this\n }\n\n // legacy\n addPattern (pattern) {\n return this.add(pattern)\n }\n\n // | ignored : unignored\n // negative | 0:0 | 0:1 | 1:0 | 1:1\n // -------- | ------- | ------- | ------- | --------\n // 0 | TEST | TEST | SKIP | X\n // 1 | TESTIF | SKIP | TEST | X\n\n // - SKIP: always skip\n // - TEST: always test\n // - TESTIF: only test if checkUnignored\n // - X: that never happen\n\n // @param {boolean} whether should check if the path is unignored,\n // setting `checkUnignored` to `false` could reduce additional\n // path matching.\n\n // @returns {TestResult} true if a file is ignored\n _testOne (path, checkUnignored) {\n let ignored = false\n let unignored = false\n\n this._rules.forEach(rule => {\n const {negative} = rule\n if (\n unignored === negative && ignored !== unignored\n || negative && !ignored && !unignored && !checkUnignored\n ) {\n return\n }\n\n const matched = rule.regex.test(path)\n\n if (matched) {\n ignored = !negative\n unignored = negative\n }\n })\n\n return {\n ignored,\n unignored\n }\n }\n\n // @returns {TestResult}\n _test (originalPath, cache, checkUnignored, slices) {\n const path = originalPath\n // Supports nullable path\n && checkPath.convert(originalPath)\n\n checkPath(\n path,\n originalPath,\n this._allowRelativePaths\n ? RETURN_FALSE\n : throwError\n )\n\n return this._t(path, cache, checkUnignored, slices)\n }\n\n _t (path, cache, checkUnignored, slices) {\n if (path in cache) {\n return cache[path]\n }\n\n if (!slices) {\n // path/to/a.js\n // ['path', 'to', 'a.js']\n slices = path.split(SLASH)\n }\n\n slices.pop()\n\n // If the path has no parent directory, just test it\n if (!slices.length) {\n return cache[path] = this._testOne(path, checkUnignored)\n }\n\n const parent = this._t(\n slices.join(SLASH) + SLASH,\n cache,\n checkUnignored,\n slices\n )\n\n // If the path contains a parent directory, check the parent first\n return cache[path] = parent.ignored\n // > It is not possible to re-include a file if a parent directory of\n // > that file is excluded.\n ? parent\n : this._testOne(path, checkUnignored)\n }\n\n ignores (path) {\n return this._test(path, this._ignoreCache, false).ignored\n }\n\n createFilter () {\n return path => !this.ignores(path)\n }\n\n filter (paths) {\n return makeArray(paths).filter(this.createFilter())\n }\n\n // @returns {TestResult}\n test (path) {\n return this._test(path, this._testCache, true)\n }\n}\n\nconst factory = options => new Ignore(options)\n\nconst isPathValid = path =>\n checkPath(path && checkPath.convert(path), path, RETURN_FALSE)\n\nfactory.isPathValid = isPathValid\n\n// Fixes typescript\nfactory.default = factory\n\nmodule.exports = factory\n\n// Windows\n// --------------------------------------------------------------\n/* istanbul ignore if */\nif (\n // Detect `process` so that it can run in browsers.\n typeof process !== 'undefined'\n && (\n process.env && process.env.IGNORE_TEST_WIN32\n || process.platform === 'win32'\n )\n) {\n /* eslint no-control-regex: \"off\" */\n const makePosix = str => /^\\\\\\\\\\?\\\\/.test(str)\n || /[\"<>|\\u0000-\\u001F]+/u.test(str)\n ? str\n : str.replace(/\\\\/g, '/')\n\n checkPath.convert = makePosix\n\n // 'C:\\\\foo' <- 'C:\\\\foo' has been converted to 'C:/'\n // 'd:\\\\foo'\n const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\\//i\n checkPath.isNotRelative = path =>\n REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)\n || isNotRelative(path)\n}\n", "/*!\n * normalize-path <https://github.com/jonschlinkert/normalize-path>\n *\n * Copyright (c) 2014-2018, Jon Schlinkert.\n * Released under the MIT License.\n */\n\nmodule.exports = function(path, stripTrailing) {\n if (typeof path !== 'string') {\n throw new TypeError('expected path to be a string');\n }\n\n if (path === '\\\\' || path === '/') return '/';\n\n var len = path.length;\n if (len <= 1) return path;\n\n // ensure that win32 namespaces has two leading slashes, so that the path is\n // handled properly by the win32 version of path.parse() after being normalized\n // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces\n var prefix = '';\n if (len > 4 && path[3] === '\\\\') {\n var ch = path[2];\n if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\\\\\') {\n path = path.slice(2);\n prefix = '//';\n }\n }\n\n var segs = path.split(/[/\\\\]+/);\n if (stripTrailing !== false && segs[segs.length - 1] === '') {\n segs.pop();\n }\n return prefix + segs.join('/');\n};\n", "/**\n * DO NOT MODIFY\n *\n * Everything in this file also exists in gadget to ensure that this logic\n * is the same between the two projects.\n */\nimport fs from \"fs-extra\";\nimport type { Ignore } from \"ignore\";\nimport ignore from \"ignore\";\nimport assert from \"node:assert\";\nimport { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport { Transform } from \"node:stream\";\nimport { pipeline } from \"node:stream/promises\";\nimport normalizePath from \"normalize-path\";\n\n/**\n * Paths that are never ignored, regardless of the contents of the `.ignore` file.\n */\nexport const NEVER_IGNORE_PATHS = [\".gadget/\"] as const;\n\n/**\n * Paths that are always ignored, regardless of the contents of the `.ignore` file.\n */\nexport const ALWAYS_IGNORE_PATHS = [\".DS_Store\", \"node_modules\", \".git\", \".shopify\"] as const;\n\n/**\n * Paths that are ignored when hashing the directory.\n *\n * NOTE: This is the _only_ thing that is allowed to be different between gadget and ggt.\n */\nexport const HASHING_IGNORE_PATHS = [\".gadget/sync.json\", \".gadget/backup\", \"yarn-error.log\"] as const;\n\n/**\n * Represents a directory that is being synced.\n */\nexport class Directory {\n /**\n * A gitignore-style file parser used to determine which files to\n * ignore while syncing.\n *\n * @see https://www.npmjs.com/package/ignore\n */\n private _ignorer!: Ignore;\n\n /**\n * Whether the directory is currently being hashed.\n */\n private _isHashing = false;\n\n private constructor(\n /**\n * An absolute path to the directory that is being synced.\n */\n readonly path: string,\n ) {}\n\n /**\n * Initializes a directory to be synced.\n *\n * If the directory does not exist, it is created.\n *\n * @param dir - The directory to initialize.\n * @returns A Promise that resolves to a Directory instance.\n */\n static async init(dir: string): Promise<Directory> {\n const directory = new Directory(dir);\n await directory.loadIgnoreFile();\n return directory;\n }\n\n /**\n * Returns the relative path from this directory to the specified path.\n *\n * @param to - The path to which the relative path is calculated.\n * @returns The relative path from this directory to the specified path.\n */\n relative(to: string): string {\n if (!path.isAbsolute(to)) {\n // the filepath is already relative\n return to;\n }\n\n return path.relative(this.path, to);\n }\n\n /**\n * Returns the absolute path by resolving the given path segments\n * relative to the directory path.\n *\n * @param pathSegments - The path segments to resolve.\n * @returns The absolute path.\n */\n absolute(...pathSegments: string[]): string {\n const result = path.resolve(this.path, ...pathSegments);\n assert(result.startsWith(this.path), `expected ${result} to be within ${this.path}`);\n return result;\n }\n\n /**\n * Similar to {@linkcode relative} in that it converts an absolute\n * path into a relative one from {@linkcode path}. However, it also\n * changes any slashes to be posix/unix-like forward slashes,\n * condenses repeated slashes into a single slash, and adds a trailing\n * slash if the path is a directory.\n *\n * This is used when sending files to Gadget to ensure that the paths\n * are consistent across platforms.\n *\n * @see https://www.npmjs.com/package/normalize-path\n */\n normalize(filepath: string, isDirectory: boolean): string {\n if (path.isAbsolute(filepath)) {\n filepath = this.relative(filepath);\n }\n\n // true = trim trailing slashes\n filepath = normalizePath(filepath, true);\n\n if (isDirectory) {\n filepath += \"/\";\n }\n\n return filepath;\n }\n\n /**\n * Loads the `.ignore` file in the directory. If the file does not\n * exist, it is silently ignored.\n */\n async loadIgnoreFile(): Promise<void> {\n this._ignorer = ignore.default();\n this._ignorer.add(ALWAYS_IGNORE_PATHS);\n\n try {\n const content = await fs.readFile(this.absolute(\".ignore\"), \"utf8\");\n this._ignorer.add(content);\n } catch (error) {\n swallowEnoent(error);\n }\n }\n\n /**\n * Determines if a file should be ignored based on its filepath.\n *\n * @param filepath - The filepath of the file to check.\n * @returns True if the file should be ignored, false otherwise.\n */\n ignores(filepath: string): boolean {\n filepath = this.relative(filepath);\n if (filepath === \"\") {\n // don't ignore the root dir\n return false;\n }\n\n if (filepath.startsWith(\"..\")) {\n // anything above the root dir is ignored\n return true;\n }\n\n // false = don't trim trailing slashes\n filepath = normalizePath(filepath, false);\n if (this._isHashing && HASHING_IGNORE_PATHS.some((ignored) => filepath.startsWith(ignored))) {\n // special case for hashing\n return true;\n }\n\n if (NEVER_IGNORE_PATHS.some((neverIgnored) => filepath.startsWith(neverIgnored))) {\n // special case for never ignored paths\n return false;\n }\n\n return this._ignorer.ignores(filepath);\n }\n\n /**\n * Recursively walks through the directory and yields all non-ignored\n * files and directories within it.\n *\n * @yields - The normalized path of each file and directory.\n */\n async *walk({ dir = this.path } = {}): AsyncGenerator<string> {\n // don't yield the root directory\n if (dir !== this.path) {\n yield this.normalize(dir, true);\n }\n\n for await (const entry of await fs.opendir(dir)) {\n const filepath = path.join(dir, entry.name);\n if (this.ignores(filepath)) {\n continue;\n }\n\n if (entry.isDirectory()) {\n yield* this.walk({ dir: filepath });\n } else if (entry.isFile()) {\n yield this.normalize(filepath, false);\n }\n }\n }\n\n /**\n * Calculates the hash of each file and directory and returns an\n * object containing the hashes keyed by the normalized file path.\n *\n * @returns A Promise that resolves to an object containing the hashes\n * of each file.\n */\n async hashes(): Promise<Hashes> {\n try {\n this._isHashing = true;\n const files = {} as Hashes;\n\n for await (const normalizedPath of this.walk()) {\n const absolutePath = this.absolute(normalizedPath);\n files[normalizedPath] = await hash(absolutePath);\n }\n\n return files;\n } finally {\n this._isHashing = false;\n }\n }\n\n async hasFiles(): Promise<boolean> {\n return !(await this.isEmptyOrNonExistent());\n }\n\n async isEmptyOrNonExistent(): Promise<boolean> {\n let isEmptyOrNonExistent = true;\n try {\n for await (const _ of this.walk()) {\n isEmptyOrNonExistent = false;\n break;\n }\n } catch (error) {\n swallowEnoent(error);\n }\n return isEmptyOrNonExistent;\n }\n}\n\n/**\n * Key/value pairs where the key is the normalized path and the value is\n * the result of {@linkcode hash} for that path.\n */\nexport type Hashes = Record<string, Hash>;\n\nexport type Hash = {\n /**\n * The SHA-1 hash of the file or directory.\n *\n * If the path points to a directory, the hash is calculated based on\n * the directory's basename. If the path points to a file, the hash is\n * calculated based on the file's basename and contents.\n */\n sha1: string;\n\n /**\n * The Unix-style file permissions of the file or directory, or\n * undefined if the platform that generated this hash doesn't support\n * them.\n *\n * @example 0o644\n * @see supportsPermissions\n */\n permissions?: number;\n};\n\n/**\n * Whether the current platform supports Unix-style file permissions.\n *\n * Windows doesn't support Unix-style file permissions and all file\n * permissions retrieved via `node:fs` on Windows are translated to 666\n * or 444.\n */\nexport const supportsPermissions = process.platform === \"linux\" || process.platform === \"darwin\";\n\n/**\n * Calculates the {@linkcode Hash} of the file or directory at the\n * specified absolute path.\n *\n * @param absolutePath - The absolute path to the file or directory.\n * @returns A Promise that resolves to the {@linkcode Hash} of the file\n * or directory.\n */\nconst hash = async (absolutePath: string): Promise<Hash> => {\n const sha1 = createHash(\"sha1\");\n sha1.update(path.basename(absolutePath));\n\n const stats = await fs.stat(absolutePath);\n\n let permissions;\n if (supportsPermissions) {\n // strip everything but the permissions\n permissions = stats.mode & 0o777;\n }\n\n if (stats.isDirectory()) {\n return { sha1: sha1.digest(\"hex\"), permissions };\n }\n\n // windows uses CRLF line endings whereas unix uses LF line endings so\n // we always strip out CR bytes (0x0d) when hashing files. this does\n // make us blind to files that only differ by CR bytes, but that's a\n // tradeoff we're willing to make.\n const removeCR = new Transform({\n transform(chunk: Buffer, _encoding, callback) {\n if (!chunk.includes(0x0d)) {\n callback(undefined, chunk);\n return;\n }\n\n const filteredChunk = Buffer.alloc(chunk.length);\n let i = 0;\n for (const byte of chunk) {\n if (byte !== 0x0d) {\n filteredChunk[i++] = byte;\n }\n }\n\n callback(undefined, filteredChunk.subarray(0, i));\n },\n });\n\n await pipeline(fs.createReadStream(absolutePath), removeCR, sha1);\n\n return { sha1: sha1.digest(\"hex\"), permissions };\n};\n\n/**\n * Swallows ENOENT errors and throws any other errors.\n *\n * @param error - The error to handle.\n * @throws The original error if it is not an ENOENT error.\n */\nexport const swallowEnoent = (error: unknown): void => {\n if (error && typeof error === \"object\" && \"code\" in error && error.code === \"ENOENT\") {\n return;\n }\n throw error;\n};\n"],
5
+ "mappings": "qGAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,CAAAC,IACA,SAASC,EAAWC,EAAS,CAC3B,OAAO,MAAM,QAAQA,CAAO,EACxBA,EACA,CAACA,CAAO,CACd,CAJSC,EAAAF,EAAA,aAMT,IAAMG,EAAQ,GACRC,EAAQ,IACRC,EAAS,KACTC,EAAwB,QACxBC,EAAmC,iBACnCC,EAA4C,OAC5CC,EAAqC,OACrCC,EAAsB,SAMtBC,EAA0B,eAE1BC,EAAQ,IAGVC,EAAiB,cAEjB,OAAO,OAAW,MACpBA,EAAiB,OAAO,IAAI,aAAa,GAE3C,IAAMC,EAAaD,EAEbE,EAASb,EAAA,CAACc,EAAQC,EAAKC,IAC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AI,EAAAA,GAAS,OAAOA,GAAU,UAAY,SAAUA,GAASA,EAAM,OAAS,UAG5E,MAAMA,CACR,EAL6B",
6
6
  "names": ["require_ignore", "__commonJSMin", "exports", "module", "init_cjs", "makeArray", "subject", "__name", "EMPTY", "SPACE", "ESCAPE", "REGEX_TEST_BLANK_LINE", "REGEX_INVALID_TRAILING_BACKSLASH", "REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION", "REGEX_REPLACE_LEADING_EXCAPED_HASH", "REGEX_SPLITALL_CRLF", "REGEX_TEST_INVALID_PATH", "SLASH", "TMP_KEY_IGNORE", "KEY_IGNORE", "define", "object", "key", "value", "REGEX_REGEXP_RANGE", "RETURN_FALSE", "sanitizeRange", "range", "match", "from", "to", "cleanRangeBackSlash", "slashes", "length", "REPLACERS", "_", "m1", "m2", "index", "str", "p1", "p2", "unescaped", "leadEscape", "endEscape", "close", "regexCache", "makeRegex", "pattern", "ignoreCase", "source", "prev", "matcher", "replacer", "isString", "checkPattern", "splitPattern", "IgnoreRule", "origin", "negative", "regex", "createRule", "throwError", "message", "Ctor", "checkPath", "path", "originalPath", "doThrow", "isNotRelative", "p", "Ignore", "ignorecase", "allowRelativePaths", "rule", "checkUnignored", "ignored", "unignored", "cache", "slices", "parent", "paths", "factory", "options", "isPathValid", "makePosix", "REGIX_IS_WINDOWS_PATH_ABSOLUTE", "require_normalize_path", "__commonJSMin", "exports", "module", "init_cjs", "path", "stripTrailing", "len", "prefix", "ch", "segs", "init_cjs", "import_fs_extra", "import_ignore", "import_normalize_path", "assert", "createHash", "path", "Transform", "pipeline", "NEVER_IGNORE_PATHS", "ALWAYS_IGNORE_PATHS", "HASHING_IGNORE_PATHS", "Directory", "_Directory", "path", "__name", "dir", "directory", "to", "pathSegments", "result", "assert", "filepath", "isDirectory", "normalizePath", "ignore", "content", "fs", "error", "swallowEnoent", "ignored", "neverIgnored", "entry", "files", "normalizedPath", "absolutePath", "hash", "isEmptyOrNonExistent", "_", "supportsPermissions", "sha1", "createHash", "stats", "permissions", "removeCR", "Transform", "chunk", "_encoding", "callback", "filteredChunk", "i", "byte", "pipeline"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{c as d}from"./chunk-KMNQ3LJT.js";import{A as f,S as r,_ as n}from"./chunk-24OT7GHO.js";import{a as s,f as g,h as i}from"./chunk-7DYQUG5M.js";i();var t=g(f(),1);var m=r(e=>{if(process.env.GGT_SESSION)return e.log.debug("reading session from env"),process.env.GGT_SESSION;try{return e.log.debug("reading session from disk"),t.default.readFileSync(n("session.txt"),"utf8")}catch(o){d(o);return}}),c=s((e,o)=>{m.clear(),process.env.GGT_SESSION&&(e.log.debug("writing session to env",{session:!!o}),process.env.GGT_SESSION=o),e.log.debug("writing session to disk",{session:!!o,path:n("session.txt")}),o?t.default.outputFileSync(n("session.txt"),o):t.default.removeSync(n("session.txt"))},"writeSession"),a=r(e=>(e.log.debug("reading token from env"),process.env.GGT_TOKEN));export{m as a,c as b,a as c};
2
- //# sourceMappingURL=chunk-DYAWQS24.js.map
1
+ import{c as d}from"./chunk-OIVNACS7.js";import{A as f,S as r,_ as n}from"./chunk-24OT7GHO.js";import{a as s,f as g,h as i}from"./chunk-7DYQUG5M.js";i();var t=g(f(),1);var m=r(e=>{if(process.env.GGT_SESSION)return e.log.debug("reading session from env"),process.env.GGT_SESSION;try{return e.log.debug("reading session from disk"),t.default.readFileSync(n("session.txt"),"utf8")}catch(o){d(o);return}}),c=s((e,o)=>{m.clear(),process.env.GGT_SESSION&&(e.log.debug("writing session to env",{session:!!o}),process.env.GGT_SESSION=o),e.log.debug("writing session to disk",{session:!!o,path:n("session.txt")}),o?t.default.outputFileSync(n("session.txt"),o):t.default.removeSync(n("session.txt"))},"writeSession"),a=r(e=>(e.log.debug("reading token from env"),process.env.GGT_TOKEN));export{m as a,c as b,a as c};
2
+ //# sourceMappingURL=chunk-X47UA3VR.js.map
@@ -1,4 +1,4 @@
1
- import{p as m}from"./chunk-VJTDX5WL.js";import{l as g,m as h,n as p}from"./chunk-D2R4J557.js";import{c}from"./chunk-FGUWID6B.js";import{ha as a,ja as i}from"./chunk-24OT7GHO.js";import{a as s,h as r}from"./chunk-7DYQUG5M.js";r();var P={...g,"--env":{type:String,alias:["-e","--environment","--to"]},"--force":{type:Boolean,alias:"-f"}},S=s(e=>a`
1
+ import{p as y}from"./chunk-M6L2X3GX.js";import{m as p,n as h,o as m}from"./chunk-YU6P3ESA.js";import{c}from"./chunk-J2OYMAMD.js";import{u as g}from"./chunk-L5H5T2T6.js";import{ha as o,ja as i}from"./chunk-24OT7GHO.js";import{a as r,h as a}from"./chunk-7DYQUG5M.js";a();var b={...p,"--env":{type:String,alias:["-e","--environment","--to"]},"--force":{type:Boolean,alias:"-f"}},D=r(e=>o`
2
2
  Pushes your local files to your environment directory.
3
3
 
4
4
  This command first tracks changes in your environment directory since the last sync.
@@ -17,12 +17,12 @@ import{p as m}from"./chunk-VJTDX5WL.js";import{l as g,m as h,n as p}from"./chunk
17
17
  {gray Examples}
18
18
  Push all local changes to the main environment by discarding any changes made on main
19
19
  {cyanBright $ ggt push --env main --force}
20
- `,"usage"),A=s(async(e,o)=>{if(o._.length>0)throw new c(a`
20
+ `,"usage"),P=r(async(e,t)=>{if(t._.length>0)throw new c(o`
21
21
  "ggt push" does not take any positional arguments.
22
22
 
23
23
  If you are trying to push changes from a specific directory,
24
24
  you must "cd" to that directory and then run "ggt push".
25
25
 
26
26
  Run "ggt push -h" for more information.
27
- `);let y=await p(process.cwd()),l=await h.loadOrInit(e,{command:"push",args:o,directory:y}),t=new m(l),n=await t.hashes(e);if(n.localChangesToPush.size===0){i({ensureEmptyLineAbove:!0,content:"Nothing to push."});return}n.environmentChangesToPull.size>0&&!n.onlyDotGadgetFilesChanged&&await t.print(e,{hashes:n}),await t.push(e,{command:"push",hashes:n,force:o["--force"]})},"run");export{P as a,S as b,A as c};
28
- //# sourceMappingURL=chunk-MBWB2XUY.js.map
27
+ `);let u=await m(process.cwd()),l=await h.loadOrInit(e,{command:"push",args:t,directory:u}),s=new y(l),n=await s.hashes(e);if(n.localChangesToPush.size===0){i({ensureEmptyLineAbove:!0,content:"Nothing to push."});return}n.environmentChanges.size>0&&!n.onlyDotGadgetFilesChanged&&(await s.print(e,{hashes:n}),t["--force"]||await g({ensureEmptyLineAbove:!0,content:o`Are you sure you want to {underline discard} your environment's changes?`})),await s.push(e,{command:"push",hashes:n})},"run");export{b as a,D as b,P as c};
28
+ //# sourceMappingURL=chunk-XKYYKHP4.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/commands/push.ts"],
4
+ "sourcesContent": ["import { ArgError, type ArgsDefinition } from \"../services/command/arg.js\";\nimport type { Run, Usage } from \"../services/command/command.js\";\nimport { FileSync } from \"../services/filesync/filesync.js\";\nimport { SyncJson, SyncJsonArgs, loadSyncJsonDirectory } from \"../services/filesync/sync-json.js\";\nimport { confirm } from \"../services/output/confirm.js\";\nimport { println } from \"../services/output/print.js\";\nimport { sprint } from \"../services/output/sprint.js\";\n\nexport type PushArgs = typeof args;\n\nexport const args = {\n ...SyncJsonArgs,\n \"--env\": { type: String, alias: [\"-e\", \"--environment\", \"--to\"] },\n \"--force\": { type: Boolean, alias: \"-f\" },\n} satisfies ArgsDefinition;\n\nexport const usage: Usage = (_ctx) => {\n return sprint`\n Pushes your local files to your environment directory.\n\n This command first tracks changes in your environment directory since the last sync.\n If changes are detected, you will be prompted to discard them or abort the push.\n\n {gray Usage}\n ggt push [options]\n\n {gray Options}\n -a, --app <app_name> Selects the app to push local changes to. Default set on \".gadget/sync.json\"\n -e, --env, --to <env_name> Selects the environment to push local changes to. Default set on \".gadget/sync.json\"\n --force Forces a push by discarding any changes made on your environment directory since last sync\n --allow-different-directory Pushes changes from any local directory with existing files, even if the \".gadget/sync.json\" file is missing\n --allow-different-app Pushes changes to an app using --app command, instead of the one in the \u201C.gadget/sync.json\u201D file\n\n {gray Examples}\n Push all local changes to the main environment by discarding any changes made on main\n {cyanBright $ ggt push --env main --force}\n `;\n};\n\nexport const run: Run<typeof args> = async (ctx, args) => {\n if (args._.length > 0) {\n throw new ArgError(sprint`\n \"ggt push\" does not take any positional arguments.\n\n If you are trying to push changes from a specific directory,\n you must \"cd\" to that directory and then run \"ggt push\".\n\n Run \"ggt push -h\" for more information.\n `);\n }\n\n const directory = await loadSyncJsonDirectory(process.cwd());\n const syncJson = await SyncJson.loadOrInit(ctx, { command: \"push\", args, directory });\n const filesync = new FileSync(syncJson);\n const hashes = await filesync.hashes(ctx);\n\n if (hashes.localChangesToPush.size === 0) {\n println({ ensureEmptyLineAbove: true, content: \"Nothing to push.\" });\n return;\n }\n\n if (hashes.environmentChanges.size > 0 && !hashes.onlyDotGadgetFilesChanged) {\n // show them the environment changes they will discard\n await filesync.print(ctx, { hashes });\n\n if (!args[\"--force\"]) {\n // they didn't pass --force, so we need to ask them if they want to discard the environment changes\n await confirm({\n ensureEmptyLineAbove: true,\n content: sprint`Are you sure you want to {underline discard} your environment's changes?`,\n });\n }\n }\n\n await filesync.push(ctx, { command: \"push\", hashes });\n};\n"],
5
+ "mappings": "yQAAAA,IAUO,IAAMC,EAAO,CAClB,GAAGC,EACH,QAAS,CAAE,KAAM,OAAQ,MAAO,CAAC,KAAM,gBAAiB,MAAM,CAAE,EAChE,UAAW,CAAE,KAAM,QAAS,MAAO,IAAK,CAC1C,EAEaC,EAAeC,EAACC,GACpBC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IADmB,SAuBfC,EAAwBH,EAAA,MAAOI,EAAKP,IAAS,CACxD,GAAIA,EAAK,EAAE,OAAS,EAClB,MAAM,IAAIQ,EAASH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAOlB,EAGH,IAAMI,EAAY,MAAMC,EAAsB,QAAQ,IAAI,CAAC,EACrDC,EAAW,MAAMC,EAAS,WAAWL,EAAK,CAAE,QAAS,OAAQ,KAAAP,EAAM,UAAAS,CAAU,CAAC,EAC9EI,EAAW,IAAIC,EAASH,CAAQ,EAChCI,EAAS,MAAMF,EAAS,OAAON,CAAG,EAExC,GAAIQ,EAAO,mBAAmB,OAAS,EAAG,CACxCC,EAAQ,CAAE,qBAAsB,GAAM,QAAS,kBAAmB,CAAC,EACnE,MACF,CAEID,EAAO,mBAAmB,KAAO,GAAK,CAACA,EAAO,4BAEhD,MAAMF,EAAS,MAAMN,EAAK,CAAE,OAAAQ,CAAO,CAAC,EAE/Bf,EAAK,SAAS,GAEjB,MAAMiB,EAAQ,CACZ,qBAAsB,GACtB,QAASZ,2EACX,CAAC,GAIL,MAAMQ,EAAS,KAAKN,EAAK,CAAE,QAAS,OAAQ,OAAAQ,CAAO,CAAC,CACtD,EApCqC",
6
+ "names": ["init_cjs", "args", "SyncJsonArgs", "usage", "__name", "_ctx", "sprint", "run", "ctx", "ArgError", "directory", "loadSyncJsonDirectory", "syncJson", "SyncJson", "filesync", "FileSync", "hashes", "println", "confirm"]
7
+ }