@gadgetinc/ggt 1.5.1 → 1.6.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 (71) hide show
  1. package/README.md +16 -0
  2. package/dist/{add-XHMGXWYX.js → add-FGXJSCE2.js} +2 -2
  3. package/dist/{add-XHMGXWYX.js.map → add-FGXJSCE2.js.map} +1 -1
  4. package/dist/{chunk-A75V6SNW.js → chunk-2CKK6A2Y.js} +2 -2
  5. package/dist/{chunk-A75V6SNW.js.map → chunk-2CKK6A2Y.js.map} +1 -1
  6. package/dist/{chunk-Z7JIVKEF.js → chunk-4WFO3NAS.js} +2 -2
  7. package/dist/{chunk-XOSBJSTW.js → chunk-5NCJDCIZ.js} +23 -23
  8. package/dist/{chunk-XOSBJSTW.js.map → chunk-5NCJDCIZ.js.map} +3 -3
  9. package/dist/{chunk-XE5GH5GR.js → chunk-72YIA2TT.js} +2 -2
  10. package/dist/chunk-F4S4AEEO.js +2 -0
  11. package/dist/chunk-F4S4AEEO.js.map +7 -0
  12. package/dist/chunk-I6BQ7MRE.js +116 -0
  13. package/dist/chunk-I6BQ7MRE.js.map +7 -0
  14. package/dist/chunk-IYQBG4II.js +7 -0
  15. package/dist/chunk-IYQBG4II.js.map +7 -0
  16. package/dist/chunk-JHWQLV6Y.js +2 -0
  17. package/dist/chunk-JHWQLV6Y.js.map +7 -0
  18. package/dist/{chunk-WQ4SFIE4.js → chunk-L2MG47NS.js} +2 -2
  19. package/dist/chunk-LPBWX353.js +50 -0
  20. package/dist/chunk-LPBWX353.js.map +7 -0
  21. package/dist/chunk-PA2LOSVH.js +18 -0
  22. package/dist/{chunk-KW4V2PJW.js.map → chunk-PA2LOSVH.js.map} +4 -4
  23. package/dist/chunk-SIAMHUOB.js +2 -0
  24. package/dist/{chunk-U5I2YBJK.js.map → chunk-SIAMHUOB.js.map} +2 -2
  25. package/dist/chunk-VJVFVZNR.js +12 -0
  26. package/dist/{chunk-5VLIBRPJ.js.map → chunk-VJVFVZNR.js.map} +4 -4
  27. package/dist/chunk-XK6JJEHJ.js +2 -0
  28. package/dist/chunk-XK6JJEHJ.js.map +7 -0
  29. package/dist/{chunk-HAYHNB7Q.js → chunk-YT2LSGNB.js} +2 -2
  30. package/dist/configure-L4U26WFP.js +12 -0
  31. package/dist/configure-L4U26WFP.js.map +7 -0
  32. package/dist/{deploy-QW6KPNDB.js → deploy-6JWXSMQJ.js} +2 -2
  33. package/dist/{deploy-QW6KPNDB.js.map → deploy-6JWXSMQJ.js.map} +1 -1
  34. package/dist/{dev-KUTYS7OU.js → dev-M2PFPQXX.js} +2 -2
  35. package/dist/{dev-KUTYS7OU.js.map → dev-M2PFPQXX.js.map} +1 -1
  36. package/dist/{list-OSMGHITM.js → list-LNXNHS2W.js} +2 -2
  37. package/dist/{list-OSMGHITM.js.map → list-LNXNHS2W.js.map} +1 -1
  38. package/dist/login-4F3H443A.js +2 -0
  39. package/dist/logout-JA5JBU3G.js +7 -0
  40. package/dist/{logout-XPKPHMRV.js.map → logout-JA5JBU3G.js.map} +1 -1
  41. package/dist/main.js +6 -6
  42. package/dist/main.js.map +3 -3
  43. package/dist/{open-SP5XOXPG.js → open-TWQBAPIT.js} +2 -2
  44. package/dist/{open-SP5XOXPG.js.map → open-TWQBAPIT.js.map} +1 -1
  45. package/dist/{pull-7JMGBM4A.js → pull-VWGETR4M.js} +2 -2
  46. package/dist/{pull-7JMGBM4A.js.map → pull-VWGETR4M.js.map} +1 -1
  47. package/dist/push-KWUMHQCJ.js +2 -0
  48. package/dist/{status-CJVN2UZ6.js → status-OYEFON4A.js} +2 -2
  49. package/dist/{status-CJVN2UZ6.js.map → status-OYEFON4A.js.map} +1 -1
  50. package/dist/{version-NFFT7WG5.js → version-4QPNJ5VH.js} +2 -2
  51. package/dist/whoami-TIGWXVEY.js +7 -0
  52. package/dist/{whoami-MU3POPXB.js.map → whoami-TIGWXVEY.js.map} +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunk-3B2GY4UU.js +0 -121
  55. package/dist/chunk-3B2GY4UU.js.map +0 -7
  56. package/dist/chunk-5VLIBRPJ.js +0 -12
  57. package/dist/chunk-KW4V2PJW.js +0 -18
  58. package/dist/chunk-LPIHKY3M.js +0 -50
  59. package/dist/chunk-LPIHKY3M.js.map +0 -7
  60. package/dist/chunk-U5I2YBJK.js +0 -2
  61. package/dist/login-UU4MWB6Y.js +0 -2
  62. package/dist/logout-XPKPHMRV.js +0 -7
  63. package/dist/push-7S6V2HSB.js +0 -2
  64. package/dist/whoami-MU3POPXB.js +0 -7
  65. /package/dist/{chunk-Z7JIVKEF.js.map → chunk-4WFO3NAS.js.map} +0 -0
  66. /package/dist/{chunk-XE5GH5GR.js.map → chunk-72YIA2TT.js.map} +0 -0
  67. /package/dist/{chunk-WQ4SFIE4.js.map → chunk-L2MG47NS.js.map} +0 -0
  68. /package/dist/{chunk-HAYHNB7Q.js.map → chunk-YT2LSGNB.js.map} +0 -0
  69. /package/dist/{login-UU4MWB6Y.js.map → login-4F3H443A.js.map} +0 -0
  70. /package/dist/{push-7S6V2HSB.js.map → push-KWUMHQCJ.js.map} +0 -0
  71. /package/dist/{version-NFFT7WG5.js.map → version-4QPNJ5VH.js.map} +0 -0
@@ -0,0 +1,18 @@
1
+ import{D as q,b as V,q as X,r as Y}from"./chunk-LPBWX353.js";import{b as T}from"./chunk-F4S4AEEO.js";import{c as J}from"./chunk-XK6JJEHJ.js";import{M as I,O as K,P as h,Y as w,b as P,ba as L,e as d,ga as E,ha as B,ia as u}from"./chunk-5NCJDCIZ.js";import{a as i,h as a}from"./chunk-7DYQUG5M.js";a();a();import pe from"node:net";import de from"node:os";var C=class extends Error{static{i(this,"Locked")}constructor(r){super(`${r} is locked`)}},y={old:new Set,young:new Set},ge=1e3*15;var S,he=i(()=>{let e=de.networkInterfaces(),r=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(e))for(let o of t)r.add(o.address);return r},"getLocalHosts"),Q=i(e=>new Promise((r,t)=>{let o=pe.createServer();o.unref(),o.on("error",t),o.listen(e,()=>{let{port:n}=o.address();o.close(()=>{r(n)})})}),"checkAvailablePort"),Z=i(async(e,r)=>{if(e.host||e.port===0)return Q(e);for(let t of r)try{await Q({port:e.port,host:t})}catch(o){if(!["EADDRNOTAVAIL","EINVAL"].includes(o.code))throw o}return e.port},"getAvailablePort"),we=i(function*(e){e&&(yield*e),yield 0},"portCheckSequence");async function O(e){let r,t=new Set;if(e&&(e.port&&(r=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let n=e.exclude;if(typeof n[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let s of n){if(typeof s!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(s))throw new TypeError(`Number ${s} in the exclude option is not a safe integer and can't be used`)}t=new Set(n)}S===void 0&&(S=setTimeout(()=>{S=void 0,y.old=y.young,y.young=new Set},ge),S.unref&&S.unref());let o=he();for(let n of we(r))try{if(t.has(n))continue;let s=await Z({...e,port:n},o);for(;y.old.has(s)||y.young.has(s);){if(n!==0)throw new C(n);s=await Z({...e,port:n},o)}return y.young.add(s),s}catch(s){if(!["EADDRINUSE","EACCES"].includes(s.code)&&!(s instanceof C))throw s}throw new Error("No available ports found")}i(O,"getPorts");import G from"node:assert";import _e from"node:http";a();import N from"node:process";import{Buffer as ie}from"node:buffer";import se from"node:path";import{fileURLToPath as Te}from"node:url";import Oe from"node:util";import ae from"node:child_process";import z,{constants as ce}from"node:fs/promises";a();function g(e,r,t){let o=i(n=>Object.defineProperty(e,r,{value:n,enumerable:!0,writable:!0}),"define");return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){let n=t();return o(n),n},set(n){o(n)}}),e}i(g,"defineLazyProperty");a();import{promisify as Ue}from"node:util";import H from"node:process";import{execFile as Fe}from"node:child_process";a();import{promisify as ye}from"node:util";import xe from"node:process";import{execFile as be}from"node:child_process";var ve=ye(be);async function M(){if(xe.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await ve("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]);return/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari"}i(M,"defaultBrowserId");a();a();import Pe from"node:process";import{promisify as Ee}from"node:util";import{execFile as Se,execFileSync as ar}from"node:child_process";var Ae=Ee(Se);async function ee(e,{humanReadableOutput:r=!0}={}){if(Pe.platform!=="darwin")throw new Error("macOS only");let t=r?[]:["-ss"],{stdout:o}=await Ae("osascript",["-e",e,t]);return o.trim()}i(ee,"runAppleScript");async function R(e){return ee(`tell application "Finder" to set app_path to application file id "${e}" as string
2
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}i(R,"bundleName");a();import{promisify as Le}from"node:util";import{execFile as Ce}from"node:child_process";var $e=Le(Ce),Ne={AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},MSEdgeDHTML:{name:"Edge",id:"com.microsoft.edge"},MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"}},$=class extends Error{static{i(this,"UnknownBrowserError")}};async function W(e=$e){let{stdout:r}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(r);if(!t)throw new $(`Cannot find Windows browser in stdout: ${JSON.stringify(r)}`);let{id:o}=t.groups,n=Ne[o];if(!n)throw new $(`Unknown browser ID: ${o}`);return n}i(W,"defaultBrowser");var Ie=Ue(Fe),Be=i(e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,r=>r.toUpperCase()),"titleize");async function k(){if(H.platform==="darwin"){let e=await M();return{name:await R(e),id:e}}if(H.platform==="linux"){let{stdout:e}=await Ie("xdg-mime",["query","default","x-scheme-handler/http"]),r=e.trim();return{name:Be(r.replace(/.desktop$/,"").replace("-"," ")),id:r}}if(H.platform==="win32")return W();throw new Error("Only macOS, Linux, and Windows are supported")}i(k,"defaultBrowser");var Me=Oe.promisify(ae.execFile),_=se.dirname(Te(import.meta.url)),re=se.join(_,"xdg-open"),{platform:x,arch:te}=N,Re=(()=>{let e="/mnt/",r;return async function(){if(r)return r;let t="/etc/wsl.conf",o=!1;try{await z.access(t,ce.F_OK),o=!0}catch{}if(!o)return e;let n=await z.readFile(t,{encoding:"utf8"}),s=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(n);return s?(r=s.groups.mountPoint.trim(),r=r.endsWith("/")?r:`${r}/`,r):e}})(),me=i(async()=>`${await Re()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,"getPowershellPathFromWsl");async function We(){let e=await me(),t=ie.from('(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId',"utf16le").toString("base64"),{stdout:o}=await Me(e,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",t],{encoding:"utf8"}),n=o.trim(),s={ChromeHTML:"com.google.chrome",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return s[n]?{id:s[n]}:{}}i(We,"getWindowsDefaultBrowserFromWsl");var oe=i(async(e,r)=>{let t;for(let o of e)try{return await r(o)}catch(n){t=n}throw t},"pTryEach"),U=i(async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return oe(e.app,c=>U({...e,app:c}));let{name:r,arguments:t=[]}=e.app??{};if(t=[...t],Array.isArray(r))return oe(r,c=>U({...e,app:{name:c,arguments:t}}));if(r==="browser"||r==="browserPrivate"){let c={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},m={chrome:"--incognito",firefox:"--private-window",edge:"--inPrivate"},l=h?await We():await k();if(l.id in c){let p=c[l.id];return r==="browserPrivate"&&t.push(m[p]),U({...e,app:{name:b[p],arguments:t}})}throw new Error(`${l.name} is not supported as a default browser`)}let o,n=[],s={};if(x==="darwin")o="open",e.wait&&n.push("--wait-apps"),e.background&&n.push("--background"),e.newInstance&&n.push("--new"),r&&n.push("-a",r);else if(x==="win32"||h&&!K()&&!r){o=h?await me():`${N.env.SYSTEMROOT||N.env.windir||"C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`,n.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),h||(s.windowsVerbatimArguments=!0);let c=["Start"];e.wait&&c.push("-Wait"),r?(c.push(`"\`"${r}\`""`),e.target&&t.push(e.target)):e.target&&c.push(`"${e.target}"`),t.length>0&&(t=t.map(m=>`"\`"${m}\`""`),c.push("-ArgumentList",t.join(","))),e.target=ie.from(c.join(" "),"utf16le").toString("base64")}else{if(r)o=r;else{let c=!_||_==="/",m=!1;try{await z.access(re,ce.X_OK),m=!0}catch{}o=N.versions.electron??(x==="android"||c||!m)?"xdg-open":re}t.length>0&&n.push(...t),e.wait||(s.stdio="ignore",s.detached=!0)}x==="darwin"&&t.length>0&&n.push("--args",...t),e.target&&n.push(e.target);let f=ae.spawn(o,n,s);return e.wait?new Promise((c,m)=>{f.once("error",m),f.once("close",l=>{if(!e.allowNonzeroExitCode&&l>0){m(new Error(`Exited with code ${l}`));return}c(f)})}):(f.unref(),f)},"baseOpen"),He=i((e,r)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return U({...r,target:e})},"open");function ne(e){if(typeof e=="string"||Array.isArray(e))return e;let{[te]:r}=e;if(!r)throw new Error(`${te} is not supported`);return r}i(ne,"detectArchBinary");function j({[x]:e},{wsl:r}){if(r&&h)return ne(r);if(!e)throw new Error(`${x} is not supported`);return ne(e)}i(j,"detectPlatformBinary");var b={};g(b,"chrome",()=>j({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));g(b,"firefox",()=>j({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));g(b,"edge",()=>j({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));g(b,"browser",()=>"browser");g(b,"browserPrivate",()=>"browserPrivate");var le=He;a();import ke from"node:assert";a();import A from"node:process";var ue=i(e=>{let r;if(typeof e=="string"?r={content:e}:r=e,r=I(r,{ensureEmptyLineAbove:!0,ensureNewLine:!0,exitWhenNo:!0}),!L.isInteractive){let t=r.whenNotInteractive??(()=>{u(r),u({ensureEmptyLineAbove:!0,content:"Aborting because ggt is not running in an interactive terminal."}),A.exit(1)});return Promise.resolve(t())}return new Promise(t=>{let o=new D(r);o.on("submit",t),o.on("exit",()=>A.exit(0)),o.on("abort",()=>A.exit(1))})},"confirm"),D=class extends J{static{i(this,"Confirm")}value=void 0;defaultValue=!1;options;constructor(r){super(),this.options=I(r,{exitWhenNo:!0,ensureEmptyLineAbove:!0}),this.render()}reset(){this.value=this.defaultValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=!1,this.done=this.aborted=!0,this.fire(),this.render(!1),this.close(),this.options.exitWhenNo&&A.exit(0)}submit(){this.value=this.value??!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.close(),this.options.exitWhenNo&&!this.value&&A.exit(0)}_(r,t){if(r.toLowerCase()==="y"){this.value=!0,this.submit();return}if(r.toLowerCase()==="n"){this.value=!1,this.submit();return}this.bell()}render(r=this.value){if(super.render(),this.done){L.persistPrompt(B({...this.options,content:`${this.options.content} ${r?P.bold.greenBright("Yes."):P.bold.redBright("No.")}`}));return}L.updatePrompt(B({...this.options,content:`${this.options.content} ${this.defaultValue?P.blueBright("[Y/n] "):P.blueBright("[y/N] ")}`}))}};var ze=d.object({id:d.union([d.string(),d.number()]).transform(Number),name:d.string().nullish(),email:d.string()}),F=i(async e=>{let r=X(e);if(r)try{let t=await q({context:{ctx:e},url:`https://${w.domains.services}/auth/api/current-user`,headers:r,responseType:"json",resolveBodyOnly:!0}),o=ze.parse(t);return e.log.info("loaded user",{user:{id:o.id}},{user:o}),V(o),o}catch(t){Y(e,t);return}},"getUser"),ct=i(async(e,r)=>{let t=await F(e);return t||(e.log.info("prompting user to log in"),u({ensureEmptyLineAbove:!0,content:`You must be logged in to use "ggt ${r}".`}),await ue({ensureEmptyLineAbove:!0,content:"Would you like to log in?"}),await fe(e,{_:[]}),t=await F(e),ke(t,"missing user after successful login"),t)},"getUserOrLogin");var vt=i(()=>E`
3
+ Log in to your account.
4
+
5
+ {bold Usage}
6
+ ggt login
7
+ `,"usage"),je=i(async e=>{let r;try{let t=await O(),o=new Promise((s,f)=>{r=_e.createServer(async(c,m)=>{let l=new URL(`https://${w.domains.services}/auth/cli`);try{G(c.url,"missing url");let p=new URL(c.url,`http://localhost:${t}`).searchParams.get("session");G(p,"missing session"),T(e,p);let v=await F(e);G(v,"missing user after successful login"),v.name?u({ensureEmptyLineAbove:!0,content:E`Hello, ${v.name} {gray (${v.email})}`}):u({ensureEmptyLineAbove:!0,content:`Hello, ${v.email}`}),l.searchParams.set("success","true"),s()}catch(p){T(e,void 0),l.searchParams.set("success","false"),f(p)}finally{m.writeHead(303,{Location:l.toString()}),m.end()}}),e.log.info("starting login server",{port:t}),r.listen(t)}),n=new URL(`https://${w.domains.services}/auth/login`);n.searchParams.set("returnTo",`https://${w.domains.services}/auth/cli/callback?port=${t}`);try{e.log.info("opening browser",{url:n.toString()}),await le(n.toString()),u({ensureEmptyLineAbove:!0,content:E`
8
+ We've opened Gadget's login page using your default browser.
9
+
10
+ Please log in and then return to this terminal.
11
+ `})}catch(s){e.log.error("failed to open browser",{error:s}),u({ensureEmptyLineAbove:!0,content:E`
12
+ Please open the following URL in your browser and log in:
13
+
14
+ {gray ${n.toString()}}
15
+
16
+ Once logged in, return to this terminal.
17
+ `})}await o}finally{r?.close()}},"run"),fe=je;export{ue as a,le as b,vt as c,je as d,fe as e,F as f,ct as g};
18
+ //# sourceMappingURL=chunk-PA2LOSVH.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/commands/login.ts", "../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js", "../node_modules/.pnpm/open@10.1.2/node_modules/open/index.js", "../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js", "../node_modules/.pnpm/default-browser@5.2.1/node_modules/default-browser/index.js", "../node_modules/.pnpm/default-browser-id@5.0.0/node_modules/default-browser-id/index.js", "../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js", "../node_modules/.pnpm/run-applescript@7.0.0/node_modules/run-applescript/index.js", "../node_modules/.pnpm/default-browser@5.2.1/node_modules/default-browser/windows.js", "../src/services/user/user.ts", "../src/services/output/confirm.ts", "../src/services/output/prompt.ts"],
4
- "sourcesContent": ["import getPort from \"get-port\";\nimport assert from \"node:assert\";\nimport http, { type Server } from \"node:http\";\nimport open from \"open\";\nimport type { Run, Usage } from \"../services/command/command.js\";\nimport { config } from \"../services/config/config.js\";\nimport { println } from \"../services/output/print.js\";\nimport { sprint } from \"../services/output/sprint.js\";\nimport { writeSession } from \"../services/user/session.js\";\nimport { getUser } from \"../services/user/user.js\";\n\nexport const usage: Usage = () => sprint`\n Log in to your account.\n\n {bold Usage}\n ggt login\n`;\n\nexport const run: Run = async (ctx): Promise<void> => {\n let server: Server | undefined;\n\n try {\n const port = await getPort();\n const receiveSession = new Promise<void>((resolve, reject) => {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n server = http.createServer(async (req, res) => {\n const landingPage = new URL(`https://${config.domains.services}/auth/cli`);\n\n try {\n assert(req.url, \"missing url\");\n const session = new URL(req.url, `http://localhost:${port}`).searchParams.get(\"session\");\n assert(session, \"missing session\");\n\n writeSession(ctx, session);\n\n const user = await getUser(ctx);\n assert(user, \"missing user after successful login\");\n\n if (user.name) {\n println({ ensureEmptyLineAbove: true, content: sprint`Hello, ${user.name} {gray (${user.email})}` });\n } else {\n println({ ensureEmptyLineAbove: true, content: `Hello, ${user.email}` });\n }\n\n landingPage.searchParams.set(\"success\", \"true\");\n resolve();\n } catch (error) {\n writeSession(ctx, undefined);\n landingPage.searchParams.set(\"success\", \"false\");\n reject(error as Error);\n } finally {\n res.writeHead(303, { Location: landingPage.toString() });\n res.end();\n }\n });\n\n ctx.log.info(\"starting login server\", { port });\n server.listen(port);\n });\n\n // open the login page in the user's default browser have it\n // redirect to the cli callback route. The cli callback route will\n // send the session to the server we just started.\n const url = new URL(`https://${config.domains.services}/auth/login`);\n url.searchParams.set(\"returnTo\", `https://${config.domains.services}/auth/cli/callback?port=${port}`);\n\n try {\n ctx.log.info(\"opening browser\", { url: url.toString() });\n await open(url.toString());\n println({\n ensureEmptyLineAbove: true,\n content: sprint`\n We've opened Gadget's login page using your default browser.\n\n Please log in and then return to this terminal.\n `,\n });\n } catch (error) {\n ctx.log.error(\"failed to open browser\", { error });\n println({\n ensureEmptyLineAbove: true,\n content: sprint`\n Please open the following URL in your browser and log in:\n\n {gray ${url.toString()}}\n\n Once logged in, return to this terminal.\n `,\n });\n }\n\n await receiveSession;\n } finally {\n server?.close();\n }\n};\n\n// alias\nexport const login = run;\n", "import net from 'node:net';\nimport os from 'node:os';\n\nclass Locked extends Error {\n\tconstructor(port) {\n\t\tsuper(`${port} is locked`);\n\t}\n}\n\nconst lockedPorts = {\n\told: new Set(),\n\tyoung: new Set(),\n};\n\n// On this interval, the old locked ports are discarded,\n// the young locked ports are moved to old locked ports,\n// and a new young set for locked ports are created.\nconst releaseOldLockedPortsIntervalMs = 1000 * 15;\n\nconst minPort = 1024;\nconst maxPort = 65_535;\n\n// Lazily create timeout on first use\nlet timeout;\n\nconst getLocalHosts = () => {\n\tconst interfaces = os.networkInterfaces();\n\n\t// Add undefined value for createServer function to use default host,\n\t// and default IPv4 host in case createServer defaults to IPv6.\n\tconst results = new Set([undefined, '0.0.0.0']);\n\n\tfor (const _interface of Object.values(interfaces)) {\n\t\tfor (const config of _interface) {\n\t\t\tresults.add(config.address);\n\t\t}\n\t}\n\n\treturn results;\n};\n\nconst checkAvailablePort = options =>\n\tnew Promise((resolve, reject) => {\n\t\tconst server = net.createServer();\n\t\tserver.unref();\n\t\tserver.on('error', reject);\n\n\t\tserver.listen(options, () => {\n\t\t\tconst {port} = server.address();\n\t\t\tserver.close(() => {\n\t\t\t\tresolve(port);\n\t\t\t});\n\t\t});\n\t});\n\nconst getAvailablePort = async (options, hosts) => {\n\tif (options.host || options.port === 0) {\n\t\treturn checkAvailablePort(options);\n\t}\n\n\tfor (const host of hosts) {\n\t\ttry {\n\t\t\tawait checkAvailablePort({port: options.port, host}); // eslint-disable-line no-await-in-loop\n\t\t} catch (error) {\n\t\t\tif (!['EADDRNOTAVAIL', 'EINVAL'].includes(error.code)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn options.port;\n};\n\nconst portCheckSequence = function * (ports) {\n\tif (ports) {\n\t\tyield * ports;\n\t}\n\n\tyield 0; // Fall back to 0 if anything else failed\n};\n\nexport default async function getPorts(options) {\n\tlet ports;\n\tlet exclude = new Set();\n\n\tif (options) {\n\t\tif (options.port) {\n\t\t\tports = typeof options.port === 'number' ? [options.port] : options.port;\n\t\t}\n\n\t\tif (options.exclude) {\n\t\t\tconst excludeIterable = options.exclude;\n\n\t\t\tif (typeof excludeIterable[Symbol.iterator] !== 'function') {\n\t\t\t\tthrow new TypeError('The `exclude` option must be an iterable.');\n\t\t\t}\n\n\t\t\tfor (const element of excludeIterable) {\n\t\t\t\tif (typeof element !== 'number') {\n\t\t\t\t\tthrow new TypeError('Each item in the `exclude` option must be a number corresponding to the port you want excluded.');\n\t\t\t\t}\n\n\t\t\t\tif (!Number.isSafeInteger(element)) {\n\t\t\t\t\tthrow new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\texclude = new Set(excludeIterable);\n\t\t}\n\t}\n\n\tif (timeout === undefined) {\n\t\ttimeout = setTimeout(() => {\n\t\t\ttimeout = undefined;\n\n\t\t\tlockedPorts.old = lockedPorts.young;\n\t\t\tlockedPorts.young = new Set();\n\t\t}, releaseOldLockedPortsIntervalMs);\n\n\t\t// Does not exist in some environments (Electron, Jest jsdom env, browser, etc).\n\t\tif (timeout.unref) {\n\t\t\ttimeout.unref();\n\t\t}\n\t}\n\n\tconst hosts = getLocalHosts();\n\n\tfor (const port of portCheckSequence(ports)) {\n\t\ttry {\n\t\t\tif (exclude.has(port)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet availablePort = await getAvailablePort({...options, port}, hosts); // eslint-disable-line no-await-in-loop\n\t\t\twhile (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {\n\t\t\t\tif (port !== 0) {\n\t\t\t\t\tthrow new Locked(port);\n\t\t\t\t}\n\n\t\t\t\tavailablePort = await getAvailablePort({...options, port}, hosts); // eslint-disable-line no-await-in-loop\n\t\t\t}\n\n\t\t\tlockedPorts.young.add(availablePort);\n\n\t\t\treturn availablePort;\n\t\t} catch (error) {\n\t\t\tif (!['EADDRINUSE', 'EACCES'].includes(error.code) && !(error instanceof Locked)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\tthrow new Error('No available ports found');\n}\n\nexport function portNumbers(from, to) {\n\tif (!Number.isInteger(from) || !Number.isInteger(to)) {\n\t\tthrow new TypeError('`from` and `to` must be integer numbers');\n\t}\n\n\tif (from < minPort || from > maxPort) {\n\t\tthrow new RangeError(`'from' must be between ${minPort} and ${maxPort}`);\n\t}\n\n\tif (to < minPort || to > maxPort) {\n\t\tthrow new RangeError(`'to' must be between ${minPort} and ${maxPort}`);\n\t}\n\n\tif (from > to) {\n\t\tthrow new RangeError('`to` must be greater than or equal to `from`');\n\t}\n\n\tconst generator = function * (from, to) {\n\t\tfor (let port = from; port <= to; port++) {\n\t\t\tyield port;\n\t\t}\n\t};\n\n\treturn generator(from, to);\n}\n\nexport function clearLockedPorts() {\n\tlockedPorts.old.clear();\n\tlockedPorts.young.clear();\n}\n", "import process from 'node:process';\nimport {Buffer} from 'node:buffer';\nimport path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport util from 'node:util';\nimport childProcess from 'node:child_process';\nimport fs, {constants as fsConstants} from 'node:fs/promises';\nimport isWsl from 'is-wsl';\nimport defineLazyProperty from 'define-lazy-prop';\nimport defaultBrowser from 'default-browser';\nimport isInsideContainer from 'is-inside-container';\n\nconst execFile = util.promisify(childProcess.execFile);\n\n// Path to included `xdg-open`.\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst localXdgOpenPath = path.join(__dirname, 'xdg-open');\n\nconst {platform, arch} = process;\n\n/**\nGet the mount point for fixed drives in WSL.\n\n@inner\n@returns {string} The mount point.\n*/\nconst getWslDrivesMountPoint = (() => {\n\t// Default value for \"root\" param\n\t// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config\n\tconst defaultMountPoint = '/mnt/';\n\n\tlet mountPoint;\n\n\treturn async function () {\n\t\tif (mountPoint) {\n\t\t\t// Return memoized mount point value\n\t\t\treturn mountPoint;\n\t\t}\n\n\t\tconst configFilePath = '/etc/wsl.conf';\n\n\t\tlet isConfigFileExists = false;\n\t\ttry {\n\t\t\tawait fs.access(configFilePath, fsConstants.F_OK);\n\t\t\tisConfigFileExists = true;\n\t\t} catch {}\n\n\t\tif (!isConfigFileExists) {\n\t\t\treturn defaultMountPoint;\n\t\t}\n\n\t\tconst configContent = await fs.readFile(configFilePath, {encoding: 'utf8'});\n\t\tconst configMountPoint = /(?<!#.*)root\\s*=\\s*(?<mountPoint>.*)/g.exec(configContent);\n\n\t\tif (!configMountPoint) {\n\t\t\treturn defaultMountPoint;\n\t\t}\n\n\t\tmountPoint = configMountPoint.groups.mountPoint.trim();\n\t\tmountPoint = mountPoint.endsWith('/') ? mountPoint : `${mountPoint}/`;\n\n\t\treturn mountPoint;\n\t};\n})();\n\n/**\nGet the PowerShell executable path in WSL environment.\n\n@returns {Promise<string>} The absolute path to the PowerShell executable in WSL.\n*/\nconst getPowershellPathFromWsl = async () => {\n\tconst mountPoint = await getWslDrivesMountPoint();\n\treturn `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;\n};\n\n/**\nGet the default browser name in Windows from WSL.\n\n@returns {Promise<string>} Browser name.\n*/\nasync function getWindowsDefaultBrowserFromWsl() {\n\tconst powershellPath = await getPowershellPathFromWsl();\n\tconst rawCommand = '(Get-ItemProperty -Path \"HKCU:\\\\Software\\\\Microsoft\\\\Windows\\\\Shell\\\\Associations\\\\UrlAssociations\\\\http\\\\UserChoice\").ProgId';\n\tconst encodedCommand = Buffer.from(rawCommand, 'utf16le').toString('base64');\n\n\tconst {stdout} = await execFile(\n\t\tpowershellPath,\n\t\t[\n\t\t\t'-NoProfile',\n\t\t\t'-NonInteractive',\n\t\t\t'-ExecutionPolicy',\n\t\t\t'Bypass',\n\t\t\t'-EncodedCommand',\n\t\t\tencodedCommand,\n\t\t],\n\t\t{encoding: 'utf8'},\n\t);\n\n\tconst progId = stdout.trim();\n\n\t// Map ProgId to browser IDs\n\tconst browserMap = {\n\t\tChromeHTML: 'com.google.chrome',\n\t\tMSEdgeHTM: 'com.microsoft.edge',\n\t\tFirefoxURL: 'org.mozilla.firefox',\n\t};\n\n\treturn browserMap[progId] ? {id: browserMap[progId]} : {};\n}\n\nconst pTryEach = async (array, mapper) => {\n\tlet latestError;\n\n\tfor (const item of array) {\n\t\ttry {\n\t\t\treturn await mapper(item); // eslint-disable-line no-await-in-loop\n\t\t} catch (error) {\n\t\t\tlatestError = error;\n\t\t}\n\t}\n\n\tthrow latestError;\n};\n\nconst baseOpen = async options => {\n\toptions = {\n\t\twait: false,\n\t\tbackground: false,\n\t\tnewInstance: false,\n\t\tallowNonzeroExitCode: false,\n\t\t...options,\n\t};\n\n\tif (Array.isArray(options.app)) {\n\t\treturn pTryEach(options.app, singleApp => baseOpen({\n\t\t\t...options,\n\t\t\tapp: singleApp,\n\t\t}));\n\t}\n\n\tlet {name: app, arguments: appArguments = []} = options.app ?? {};\n\tappArguments = [...appArguments];\n\n\tif (Array.isArray(app)) {\n\t\treturn pTryEach(app, appName => baseOpen({\n\t\t\t...options,\n\t\t\tapp: {\n\t\t\t\tname: appName,\n\t\t\t\targuments: appArguments,\n\t\t\t},\n\t\t}));\n\t}\n\n\tif (app === 'browser' || app === 'browserPrivate') {\n\t\t// IDs from default-browser for macOS and windows are the same\n\t\tconst ids = {\n\t\t\t'com.google.chrome': 'chrome',\n\t\t\t'google-chrome.desktop': 'chrome',\n\t\t\t'org.mozilla.firefox': 'firefox',\n\t\t\t'firefox.desktop': 'firefox',\n\t\t\t'com.microsoft.msedge': 'edge',\n\t\t\t'com.microsoft.edge': 'edge',\n\t\t\t'com.microsoft.edgemac': 'edge',\n\t\t\t'microsoft-edge.desktop': 'edge',\n\t\t};\n\n\t\t// Incognito flags for each browser in `apps`.\n\t\tconst flags = {\n\t\t\tchrome: '--incognito',\n\t\t\tfirefox: '--private-window',\n\t\t\tedge: '--inPrivate',\n\t\t};\n\n\t\tconst browser = isWsl ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser();\n\t\tif (browser.id in ids) {\n\t\t\tconst browserName = ids[browser.id];\n\n\t\t\tif (app === 'browserPrivate') {\n\t\t\t\tappArguments.push(flags[browserName]);\n\t\t\t}\n\n\t\t\treturn baseOpen({\n\t\t\t\t...options,\n\t\t\t\tapp: {\n\t\t\t\t\tname: apps[browserName],\n\t\t\t\t\targuments: appArguments,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tthrow new Error(`${browser.name} is not supported as a default browser`);\n\t}\n\n\tlet command;\n\tconst cliArguments = [];\n\tconst childProcessOptions = {};\n\n\tif (platform === 'darwin') {\n\t\tcommand = 'open';\n\n\t\tif (options.wait) {\n\t\t\tcliArguments.push('--wait-apps');\n\t\t}\n\n\t\tif (options.background) {\n\t\t\tcliArguments.push('--background');\n\t\t}\n\n\t\tif (options.newInstance) {\n\t\t\tcliArguments.push('--new');\n\t\t}\n\n\t\tif (app) {\n\t\t\tcliArguments.push('-a', app);\n\t\t}\n\t} else if (platform === 'win32' || (isWsl && !isInsideContainer() && !app)) {\n\t\tcommand = isWsl\n\t\t\t? await getPowershellPathFromWsl()\n\t\t\t: `${process.env.SYSTEMROOT || process.env.windir || 'C:\\\\Windows'}\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell`;\n\n\t\tcliArguments.push(\n\t\t\t'-NoProfile',\n\t\t\t'-NonInteractive',\n\t\t\t'-ExecutionPolicy',\n\t\t\t'Bypass',\n\t\t\t'-EncodedCommand',\n\t\t);\n\n\t\tif (!isWsl) {\n\t\t\tchildProcessOptions.windowsVerbatimArguments = true;\n\t\t}\n\n\t\tconst encodedArguments = ['Start'];\n\n\t\tif (options.wait) {\n\t\t\tencodedArguments.push('-Wait');\n\t\t}\n\n\t\tif (app) {\n\t\t\t// Double quote with double quotes to ensure the inner quotes are passed through.\n\t\t\t// Inner quotes are delimited for PowerShell interpretation with backticks.\n\t\t\tencodedArguments.push(`\"\\`\"${app}\\`\"\"`);\n\t\t\tif (options.target) {\n\t\t\t\tappArguments.push(options.target);\n\t\t\t}\n\t\t} else if (options.target) {\n\t\t\tencodedArguments.push(`\"${options.target}\"`);\n\t\t}\n\n\t\tif (appArguments.length > 0) {\n\t\t\tappArguments = appArguments.map(argument => `\"\\`\"${argument}\\`\"\"`);\n\t\t\tencodedArguments.push('-ArgumentList', appArguments.join(','));\n\t\t}\n\n\t\t// Using Base64-encoded command, accepted by PowerShell, to allow special characters.\n\t\toptions.target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');\n\t} else {\n\t\tif (app) {\n\t\t\tcommand = app;\n\t\t} else {\n\t\t\t// When bundled by Webpack, there's no actual package file path and no local `xdg-open`.\n\t\t\tconst isBundled = !__dirname || __dirname === '/';\n\n\t\t\t// Check if local `xdg-open` exists and is executable.\n\t\t\tlet exeLocalXdgOpen = false;\n\t\t\ttry {\n\t\t\t\tawait fs.access(localXdgOpenPath, fsConstants.X_OK);\n\t\t\t\texeLocalXdgOpen = true;\n\t\t\t} catch {}\n\n\t\t\tconst useSystemXdgOpen = process.versions.electron\n\t\t\t\t?? (platform === 'android' || isBundled || !exeLocalXdgOpen);\n\t\t\tcommand = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;\n\t\t}\n\n\t\tif (appArguments.length > 0) {\n\t\t\tcliArguments.push(...appArguments);\n\t\t}\n\n\t\tif (!options.wait) {\n\t\t\t// `xdg-open` will block the process unless stdio is ignored\n\t\t\t// and it's detached from the parent even if it's unref'd.\n\t\t\tchildProcessOptions.stdio = 'ignore';\n\t\t\tchildProcessOptions.detached = true;\n\t\t}\n\t}\n\n\tif (platform === 'darwin' && appArguments.length > 0) {\n\t\tcliArguments.push('--args', ...appArguments);\n\t}\n\n\t// This has to come after `--args`.\n\tif (options.target) {\n\t\tcliArguments.push(options.target);\n\t}\n\n\tconst subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);\n\n\tif (options.wait) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tsubprocess.once('error', reject);\n\n\t\t\tsubprocess.once('close', exitCode => {\n\t\t\t\tif (!options.allowNonzeroExitCode && exitCode > 0) {\n\t\t\t\t\treject(new Error(`Exited with code ${exitCode}`));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(subprocess);\n\t\t\t});\n\t\t});\n\t}\n\n\tsubprocess.unref();\n\n\treturn subprocess;\n};\n\nconst open = (target, options) => {\n\tif (typeof target !== 'string') {\n\t\tthrow new TypeError('Expected a `target`');\n\t}\n\n\treturn baseOpen({\n\t\t...options,\n\t\ttarget,\n\t});\n};\n\nexport const openApp = (name, options) => {\n\tif (typeof name !== 'string' && !Array.isArray(name)) {\n\t\tthrow new TypeError('Expected a valid `name`');\n\t}\n\n\tconst {arguments: appArguments = []} = options ?? {};\n\tif (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {\n\t\tthrow new TypeError('Expected `appArguments` as Array type');\n\t}\n\n\treturn baseOpen({\n\t\t...options,\n\t\tapp: {\n\t\t\tname,\n\t\t\targuments: appArguments,\n\t\t},\n\t});\n};\n\nfunction detectArchBinary(binary) {\n\tif (typeof binary === 'string' || Array.isArray(binary)) {\n\t\treturn binary;\n\t}\n\n\tconst {[arch]: archBinary} = binary;\n\n\tif (!archBinary) {\n\t\tthrow new Error(`${arch} is not supported`);\n\t}\n\n\treturn archBinary;\n}\n\nfunction detectPlatformBinary({[platform]: platformBinary}, {wsl}) {\n\tif (wsl && isWsl) {\n\t\treturn detectArchBinary(wsl);\n\t}\n\n\tif (!platformBinary) {\n\t\tthrow new Error(`${platform} is not supported`);\n\t}\n\n\treturn detectArchBinary(platformBinary);\n}\n\nexport const apps = {};\n\ndefineLazyProperty(apps, 'chrome', () => detectPlatformBinary({\n\tdarwin: 'google chrome',\n\twin32: 'chrome',\n\tlinux: ['google-chrome', 'google-chrome-stable', 'chromium'],\n}, {\n\twsl: {\n\t\tia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',\n\t\tx64: ['/mnt/c/Program Files/Google/Chrome/Application/chrome.exe', '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'],\n\t},\n}));\n\ndefineLazyProperty(apps, 'firefox', () => detectPlatformBinary({\n\tdarwin: 'firefox',\n\twin32: 'C:\\\\Program Files\\\\Mozilla Firefox\\\\firefox.exe',\n\tlinux: 'firefox',\n}, {\n\twsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe',\n}));\n\ndefineLazyProperty(apps, 'edge', () => detectPlatformBinary({\n\tdarwin: 'microsoft edge',\n\twin32: 'msedge',\n\tlinux: ['microsoft-edge', 'microsoft-edge-dev'],\n}, {\n\twsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe',\n}));\n\ndefineLazyProperty(apps, 'browser', () => 'browser');\n\ndefineLazyProperty(apps, 'browserPrivate', () => 'browserPrivate');\n\nexport default open;\n", "export default function defineLazyProperty(object, propertyName, valueGetter) {\n\tconst define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});\n\n\tObject.defineProperty(object, propertyName, {\n\t\tconfigurable: true,\n\t\tenumerable: true,\n\t\tget() {\n\t\t\tconst result = valueGetter();\n\t\t\tdefine(result);\n\t\t\treturn result;\n\t\t},\n\t\tset(value) {\n\t\t\tdefine(value);\n\t\t}\n\t});\n\n\treturn object;\n}\n", "import {promisify} from 'node:util';\nimport process from 'node:process';\nimport {execFile} from 'node:child_process';\nimport defaultBrowserId from 'default-browser-id';\nimport bundleName from 'bundle-name';\nimport windows from './windows.js';\n\nconst execFileAsync = promisify(execFile);\n\n// Inlined: https://github.com/sindresorhus/titleize/blob/main/index.js\nconst titleize = string => string.toLowerCase().replaceAll(/(?:^|\\s|-)\\S/g, x => x.toUpperCase());\n\nexport default async function defaultBrowser() {\n\tif (process.platform === 'darwin') {\n\t\tconst id = await defaultBrowserId();\n\t\tconst name = await bundleName(id);\n\t\treturn {name, id};\n\t}\n\n\tif (process.platform === 'linux') {\n\t\tconst {stdout} = await execFileAsync('xdg-mime', ['query', 'default', 'x-scheme-handler/http']);\n\t\tconst id = stdout.trim();\n\t\tconst name = titleize(id.replace(/.desktop$/, '').replace('-', ' '));\n\t\treturn {name, id};\n\t}\n\n\tif (process.platform === 'win32') {\n\t\treturn windows();\n\t}\n\n\tthrow new Error('Only macOS, Linux, and Windows are supported');\n}\n", "import {promisify} from 'node:util';\nimport process from 'node:process';\nimport {execFile} from 'node:child_process';\n\nconst execFileAsync = promisify(execFile);\n\nexport default async function defaultBrowserId() {\n\tif (process.platform !== 'darwin') {\n\t\tthrow new Error('macOS only');\n\t}\n\n\tconst {stdout} = await execFileAsync('defaults', ['read', 'com.apple.LaunchServices/com.apple.launchservices.secure', 'LSHandlers']);\n\n\t// `(?!-)` is to prevent matching `LSHandlerRoleAll = \"-\";`.\n\tconst match = /LSHandlerRoleAll = \"(?!-)(?<id>[^\"]+?)\";\\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);\n\n\treturn match?.groups.id ?? 'com.apple.Safari';\n}\n", "import {runAppleScript} from 'run-applescript';\n\nexport default async function bundleName(bundleId) {\n\treturn runAppleScript(`tell application \"Finder\" to set app_path to application file id \"${bundleId}\" as string\\ntell application \"System Events\" to get value of property list item \"CFBundleName\" of property list file (app_path & \":Contents:Info.plist\")`);\n}\n", "import process from 'node:process';\nimport {promisify} from 'node:util';\nimport {execFile, execFileSync} from 'node:child_process';\n\nconst execFileAsync = promisify(execFile);\n\nexport async function runAppleScript(script, {humanReadableOutput = true} = {}) {\n\tif (process.platform !== 'darwin') {\n\t\tthrow new Error('macOS only');\n\t}\n\n\tconst outputArguments = humanReadableOutput ? [] : ['-ss'];\n\n\tconst {stdout} = await execFileAsync('osascript', ['-e', script, outputArguments]);\n\treturn stdout.trim();\n}\n\nexport function runAppleScriptSync(script, {humanReadableOutput = true} = {}) {\n\tif (process.platform !== 'darwin') {\n\t\tthrow new Error('macOS only');\n\t}\n\n\tconst outputArguments = humanReadableOutput ? [] : ['-ss'];\n\n\tconst stdout = execFileSync('osascript', ['-e', script, ...outputArguments], {\n\t\tencoding: 'utf8',\n\t\tstdio: ['ignore', 'pipe', 'ignore'],\n\t\ttimeout: 500,\n\t});\n\n\treturn stdout.trim();\n}\n", "import {promisify} from 'node:util';\nimport {execFile} from 'node:child_process';\n\nconst execFileAsync = promisify(execFile);\n\n// Windows doesn't have browser IDs in the same way macOS/Linux does so we give fake\n// ones that look real and match the macOS/Linux versions for cross-platform apps.\nconst windowsBrowserProgIds = {\n\tAppXq0fevzme2pys62n3e0fbqa7peapykr8v: {name: 'Edge', id: 'com.microsoft.edge.old'},\n\tMSEdgeDHTML: {name: 'Edge', id: 'com.microsoft.edge'}, // On macOS, it's \"com.microsoft.edgemac\"\n\tMSEdgeHTM: {name: 'Edge', id: 'com.microsoft.edge'}, // Newer Edge/Win10 releases\n\t'IE.HTTP': {name: 'Internet Explorer', id: 'com.microsoft.ie'},\n\tFirefoxURL: {name: 'Firefox', id: 'org.mozilla.firefox'},\n\tChromeHTML: {name: 'Chrome', id: 'com.google.chrome'},\n\tBraveHTML: {name: 'Brave', id: 'com.brave.Browser'},\n\tBraveBHTML: {name: 'Brave Beta', id: 'com.brave.Browser.beta'},\n\tBraveSSHTM: {name: 'Brave Nightly', id: 'com.brave.Browser.nightly'},\n};\n\nexport class UnknownBrowserError extends Error {}\n\nexport default async function defaultBrowser(_execFileAsync = execFileAsync) {\n\tconst {stdout} = await _execFileAsync('reg', [\n\t\t'QUERY',\n\t\t' HKEY_CURRENT_USER\\\\Software\\\\Microsoft\\\\Windows\\\\Shell\\\\Associations\\\\UrlAssociations\\\\http\\\\UserChoice',\n\t\t'/v',\n\t\t'ProgId',\n\t]);\n\n\tconst match = /ProgId\\s*REG_SZ\\s*(?<id>\\S+)/.exec(stdout);\n\tif (!match) {\n\t\tthrow new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);\n\t}\n\n\tconst {id} = match.groups;\n\n\tconst browser = windowsBrowserProgIds[id];\n\tif (!browser) {\n\t\tthrow new UnknownBrowserError(`Unknown browser ID: ${id}`);\n\t}\n\n\treturn browser;\n}\n", "import assert from \"node:assert\";\nimport { z } from \"zod\";\nimport { login } from \"../../commands/login.js\";\nimport type { Command } from \"../command/command.js\";\nimport type { Context } from \"../command/context.js\";\nimport { config } from \"../config/config.js\";\nimport { maybeLoadAuthHeaders, swallowUnauthorized } from \"../http/auth.js\";\nimport { http } from \"../http/http.js\";\nimport { confirm } from \"../output/confirm.js\";\nimport { println } from \"../output/print.js\";\nimport { setSentryUser } from \"../output/sentry.js\";\n\nconst User = z.object({\n id: z.union([z.string(), z.number()]).transform(Number),\n name: z.string().nullish(),\n email: z.string(),\n});\n\nexport type User = z.infer<typeof User>;\n\n/**\n * Retrieves the currently logged in user from Gadgets API.\n *\n * @returns A Promise that resolves to a User object representing the\n * current user, or undefined if the user is not authenticated.\n */\nexport const getUser = async (ctx: Context): Promise<User | undefined> => {\n const headers = maybeLoadAuthHeaders(ctx);\n if (!headers) {\n return undefined;\n }\n\n try {\n const json = await http({\n context: { ctx },\n url: `https://${config.domains.services}/auth/api/current-user`,\n headers,\n responseType: \"json\",\n resolveBodyOnly: true,\n });\n\n const user = User.parse(json);\n ctx.log.info(\"loaded user\", { user: { id: user.id } }, { user });\n\n setSentryUser(user);\n\n return user;\n } catch (error) {\n swallowUnauthorized(ctx, error);\n return undefined;\n }\n};\n\n/**\n * Retrieves the current user or prompts the user to log in if not\n * already logged in.\n *\n * @param ctx - The current context.\n * @returns A Promise that resolves to the current user.\n */\nexport const getUserOrLogin = async (ctx: Context, command: Command): Promise<User> => {\n let user = await getUser(ctx);\n if (user) {\n return user;\n }\n\n ctx.log.info(\"prompting user to log in\");\n println({\n ensureEmptyLineAbove: true,\n content: `You must be logged in to use \"ggt ${command}\".`,\n });\n\n await confirm({ ensureEmptyLineAbove: true, content: \"Would you like to log in?\" });\n await login(ctx, { _: [] });\n\n user = await getUser(ctx);\n assert(user, \"missing user after successful login\");\n\n return user;\n};\n", "import chalk from \"chalk\";\nimport process from \"node:process\";\nimport type { Promisable } from \"type-fest\";\nimport { defaults } from \"../util/object.js\";\nimport type { PartialExcept } from \"../util/types.js\";\nimport { output } from \"./output.js\";\nimport { println, type PrintOptions } from \"./print.js\";\nimport { Prompt, type StdinKey } from \"./prompt.js\";\nimport { sprintln } from \"./sprint.js\";\n\nexport type ConfirmOptions = PrintOptions & {\n /**\n * If `true`, ggt will exit if the user selects \"No\".\n *\n * @default true\n */\n exitWhenNo?: boolean;\n\n /**\n * What to do if ggt is not running in an interactive terminal.\n *\n * @default ```\n * println(options)(text);\n * println({ ensureEmptyLineAbove: true })`\n * Aborting because ggt is not running in an interactive terminal.\n * `;\n * process.exit(1);\n * ```\n */\n whenNotInteractive?: () => Promisable<void>;\n};\n\nexport type confirm = typeof confirm;\n\nexport const confirm = (contentOrOptions: string | ConfirmOptions): Promise<void> => {\n let options: ConfirmOptions;\n if (typeof contentOrOptions === \"string\") {\n options = { content: contentOrOptions };\n } else {\n options = contentOrOptions;\n }\n\n options = defaults(options, {\n ensureEmptyLineAbove: true,\n ensureNewLine: true,\n exitWhenNo: true,\n });\n\n if (!output.isInteractive) {\n const whenNotInteractive =\n options.whenNotInteractive ??\n (() => {\n println(options);\n println({ ensureEmptyLineAbove: true, content: \"Aborting because ggt is not running in an interactive terminal.\" });\n process.exit(1);\n });\n\n return Promise.resolve(whenNotInteractive());\n }\n\n return new Promise((resolve) => {\n const conf = new Confirm(options);\n conf.on(\"submit\", resolve);\n conf.on(\"exit\", () => process.exit(0));\n conf.on(\"abort\", () => process.exit(1));\n });\n};\n\n/**\n * Inspired by `prompts`:\n * https://github.com/terkelg/prompts/blob/e0519913ec4fcc6746bb3d97d8cd0960c3f3ffde/lib/elements/confirm.js\n *\n * MIT License\n *\n * Copyright (c) 2018 Terkel Gjervig Nielsen\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nexport class Confirm extends Prompt {\n override value: boolean | undefined = undefined;\n defaultValue = false;\n options;\n\n constructor(options: PartialExcept<ConfirmOptions, \"content\">) {\n super();\n\n this.options = defaults(options, {\n exitWhenNo: true,\n ensureEmptyLineAbove: true,\n });\n\n this.render();\n }\n\n reset(): void {\n this.value = this.defaultValue;\n this.fire();\n this.render();\n }\n\n exit(): void {\n this.abort();\n }\n\n abort(): void {\n this.value = false;\n this.done = this.aborted = true;\n this.fire();\n this.render(false);\n this.close();\n\n if (this.options.exitWhenNo) {\n process.exit(0);\n }\n }\n\n submit(): void {\n this.value = this.value ?? false;\n this.done = true;\n this.aborted = false;\n this.fire();\n this.render();\n this.close();\n\n if (this.options.exitWhenNo && !this.value) {\n process.exit(0);\n }\n }\n\n override _(char: string, _key: StdinKey): void {\n if (char.toLowerCase() === \"y\") {\n this.value = true;\n this.submit();\n return;\n }\n\n if (char.toLowerCase() === \"n\") {\n this.value = false;\n this.submit();\n return;\n }\n\n this.bell();\n }\n\n override render(value = this.value): void {\n super.render();\n\n if (this.done) {\n output.persistPrompt(\n sprintln({\n ...this.options,\n content: `${this.options.content} ${value ? chalk.bold.greenBright(\"Yes.\") : chalk.bold.redBright(\"No.\")}`,\n }),\n );\n return;\n }\n\n output.updatePrompt(\n sprintln({\n ...this.options,\n content: `${this.options.content} ${this.defaultValue ? chalk.blueBright(\"[Y/n] \") : chalk.blueBright(\"[y/N] \")}`,\n }),\n );\n }\n}\n", "import ansiEscapes from \"ansi-escapes\";\nimport assert from \"node:assert\";\nimport EventEmitter from \"node:events\";\nimport process from \"node:process\";\nimport readline from \"node:readline\";\nimport { output } from \"./output.js\";\n\n/**\n * Inspired by `prompts`:\n * https://github.com/terkelg/prompts/blob/e0519913ec4fcc6746bb3d97d8cd0960c3f3ffde/lib/elements/prompt.js\n *\n * MIT License\n *\n * Copyright (c) 2018 Terkel Gjervig Nielsen\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nexport class Prompt extends EventEmitter {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [action: string]: any; // (key: StdinKey) => void;\n\n static active = false;\n\n // state\n value: unknown = undefined;\n firstRender = true;\n done = false;\n closed = false;\n aborted = false;\n exited = false;\n\n // methods that rely on constructor closure\n close: () => void;\n\n constructor() {\n super();\n assert(!Prompt.active, \"only one prompt can be active at a time\");\n Prompt.active = true;\n\n const rl = readline.createInterface({ input: process.stdin, escapeCodeTimeout: 50 });\n readline.emitKeypressEvents(process.stdin, rl);\n\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(true);\n }\n\n const isSelect = [\"SelectPrompt\"].includes(this.constructor.name);\n const keypress = (str: string, key: StdinKey): void => {\n const action = getPromptAction(key, isSelect);\n if (action === false) {\n this._(str, key);\n } else if (action && typeof this[action] === \"function\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this[action](key);\n } else {\n this.bell();\n }\n };\n\n this.close = () => {\n process.stdin.removeListener(\"keypress\", keypress);\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false);\n }\n\n rl.close();\n this.emit(this.aborted ? \"abort\" : this.exited ? \"exit\" : \"submit\", this.value);\n this.closed = true;\n Prompt.active = false;\n };\n\n process.stdin.on(\"keypress\", keypress);\n }\n\n _(_str: string, _key: StdinKey): void {\n // noop\n }\n\n onRender(): void {\n // noop\n }\n\n fire(): void {\n this.emit(\"state\", {\n value: this.value,\n aborted: this.aborted,\n exited: this.exited,\n });\n }\n\n bell(): void {\n output.writeStdout(ansiEscapes.beep);\n }\n\n render(): void {\n this.onRender();\n if (this.firstRender) {\n this.firstRender = false;\n }\n }\n}\n\nexport type PromptAction =\n | \"abort\"\n | \"exit\"\n | \"submit\"\n | \"next\"\n | \"nextPage\"\n | \"prevPage\"\n | \"home\"\n | \"end\"\n | \"up\"\n | \"down\"\n | \"right\"\n | \"left\"\n | \"reset\"\n | \"delete\"\n | \"deleteForward\"\n | \"first\"\n | \"last\";\n\nexport type StdinKey = {\n name: string;\n ctrl: boolean;\n meta: boolean;\n};\n\nconst getPromptAction = (key: StdinKey, isSelect: boolean): PromptAction | false | undefined => {\n if (key.meta && key.name !== \"escape\") {\n return;\n }\n\n if (key.ctrl) {\n switch (key.name) {\n case \"a\":\n return \"first\";\n case \"c\":\n case \"d\":\n return \"abort\";\n case \"e\":\n return \"last\";\n case \"g\":\n return \"reset\";\n }\n }\n\n if (isSelect) {\n if (key.name === \"j\") {\n return \"down\";\n }\n if (key.name === \"k\") {\n return \"up\";\n }\n }\n\n switch (key.name) {\n case \"return\":\n case \"enter\":\n return \"submit\";\n case \"backspace\":\n return \"delete\";\n case \"delete\":\n return \"deleteForward\";\n case \"abort\":\n return \"abort\";\n case \"escape\":\n return \"exit\";\n case \"tab\":\n return \"next\";\n case \"pagedown\":\n return \"nextPage\";\n case \"pageup\":\n return \"prevPage\";\n case \"home\":\n return \"home\";\n case \"end\":\n return \"end\";\n case \"up\":\n return \"up\";\n case \"down\":\n return \"down\";\n case \"right\":\n return \"right\";\n case \"left\":\n return \"left\";\n default:\n return false;\n }\n};\n\n/**\n * Determine what entries should be displayed on the screen, based on the\n * currently selected index and the maximum visible. Used in list-based\n * prompts like `select` and `multiselect`.\n *\n * @param cursor - the currently selected entry\n * @param total - the total entries available to display\n * @param [maxVisible] - the number of entries that can be displayed\n */\nexport const entriesToDisplay = (cursor: number, total: number, maxVisible: number): { startIndex: number; endIndex: number } => {\n maxVisible = maxVisible || total;\n\n let startIndex = Math.min(total - maxVisible, cursor - Math.floor(maxVisible / 2));\n if (startIndex < 0) {\n startIndex = 0;\n }\n\n const endIndex = Math.min(startIndex + maxVisible, total);\n\n return { startIndex, endIndex };\n};\n"],
5
- "mappings": "sQAAAA,ICAAC,IAAA,OAAOC,OAAS,WAChB,OAAOC,OAAQ,UAEf,IAAMC,EAAN,cAAqB,KAAM,CAH3B,MAG2B,CAAAC,EAAA,eAC1B,YAAYC,EAAM,CACjB,MAAM,GAAGA,CAAI,YAAY,CAC1B,CACD,EAEMC,EAAc,CACnB,IAAK,IAAI,IACT,MAAO,IAAI,GACZ,EAKMC,GAAkC,IA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ACR,QAAE,CACAH,GAAQ,MAAM,CAChB,CACF,EA7EwB,OAgFXoB,GAAQtB",
6
- "names": ["init_cjs", "init_cjs", "net", "os", "Locked", "__name", "port", "lockedPorts", "releaseOldLockedPortsIntervalMs", "timeout", "getLocalHosts", "__name", "interfaces", "os", "results", "_interface", "config", "checkAvailablePort", "options", "resolve", "reject", "server", "net", "port", "getAvailablePort", "hosts", "host", "error", "portCheckSequence", "ports", "getPorts", "exclude", "excludeIterable", "element", "lockedPorts", "releaseOldLockedPortsIntervalMs", "availablePort", "Locked", "assert", "http", "init_cjs", "process", "Buffer", "path", "fileURLToPath", "util", "childProcess", "fs", "fsConstants", "init_cjs", "defineLazyProperty", "object", "propertyName", "valueGetter", "define", "__name", "value", "result", "init_cjs", "promisify", "process", "execFile", "init_cjs", "promisify", "process", "execFile", "execFileAsync", "promisify", "execFile", "defaultBrowserId", "process", "stdout", "__name", "init_cjs", "init_cjs", "process", "promisify", "execFile", "execFileSync", "execFileAsync", "promisify", "execFile", "runAppleScript", "script", "humanReadableOutput", "process", "outputArguments", "stdout", "__name", "bundleName", "bundleId", "runAppleScript", "__name", "init_cjs", "promisify", "execFile", "execFileAsync", "promisify", "execFile", "windowsBrowserProgIds", "UnknownBrowserError", "__name", "defaultBrowser", "_execFileAsync", "stdout", "match", "id", "browser", "execFileAsync", "promisify", "execFile", "titleize", "__name", "string", "x", "defaultBrowser", "process", "id", "defaultBrowserId", "bundleName", "stdout", "execFile", "util", "childProcess", "__dirname", "path", "fileURLToPath", "localXdgOpenPath", "platform", "arch", "process", "getWslDrivesMountPoint", "defaultMountPoint", "mountPoint", "configFilePath", "isConfigFileExists", "fs", "fsConstants", "configContent", "configMountPoint", "getPowershellPathFromWsl", "__name", "getWindowsDefaultBrowserFromWsl", "powershellPath", "encodedCommand", "Buffer", "stdout", "progId", "browserMap", "pTryEach", "array", "mapper", "latestError", "item", "error", "baseOpen", "options", "singleApp", "app", "appArguments", "appName", "ids", "flags", "browser", "is_wsl_default", "defaultBrowser", "browserName", "apps", "command", "cliArguments", "childProcessOptions", "isInsideContainer", "encodedArguments", "argument", "isBundled", "exeLocalXdgOpen", "subprocess", "resolve", "reject", "exitCode", "open", "target", "detectArchBinary", "binary", "arch", "archBinary", "__name", "detectPlatformBinary", "platform", "platformBinary", "wsl", "is_wsl_default", "apps", "defineLazyProperty", "open_default", "open", "init_cjs", "assert", "init_cjs", "process", "init_cjs", "assert", "EventEmitter", "process", "readline", "Prompt", "_Prompt", "EventEmitter", "__name", "assert", "rl", "readline", "process", "isSelect", "keypress", "str", "key", "action", "getPromptAction", "_str", "_key", "output", "base_exports", "entriesToDisplay", "cursor", "total", "maxVisible", "startIndex", "endIndex", "confirm", "__name", "contentOrOptions", "options", "defaults", "output", "whenNotInteractive", "println", "process", "resolve", "conf", "Confirm", "Prompt", "char", "_key", "value", "sprintln", "source_default", "User", "z", "getUser", "__name", "ctx", "headers", "maybeLoadAuthHeaders", "json", "http", "config", "user", "setSentryUser", "error", "swallowUnauthorized", "getUserOrLogin", "command", "println", "confirm", "login", "assert", "usage", "__name", "sprint", "run", "ctx", "server", "port", "getPorts", "receiveSession", "resolve", "reject", "http", "req", "res", "landingPage", "config", "assert", "session", "writeSession", "user", "getUser", "println", "error", "url", "open_default", "login"]
3
+ "sources": ["../src/commands/login.ts", "../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js", "../node_modules/.pnpm/open@10.1.2/node_modules/open/index.js", "../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js", "../node_modules/.pnpm/default-browser@5.2.1/node_modules/default-browser/index.js", "../node_modules/.pnpm/default-browser-id@5.0.0/node_modules/default-browser-id/index.js", "../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js", "../node_modules/.pnpm/run-applescript@7.0.0/node_modules/run-applescript/index.js", "../node_modules/.pnpm/default-browser@5.2.1/node_modules/default-browser/windows.js", "../src/services/user/user.ts", "../src/services/output/confirm.ts"],
4
+ "sourcesContent": ["import getPort from \"get-port\";\nimport assert from \"node:assert\";\nimport http, { type Server } from \"node:http\";\nimport open from \"open\";\nimport type { Run, Usage } from \"../services/command/command.js\";\nimport { config } from \"../services/config/config.js\";\nimport { println } from \"../services/output/print.js\";\nimport { sprint } from \"../services/output/sprint.js\";\nimport { writeSession } from \"../services/user/session.js\";\nimport { getUser } from \"../services/user/user.js\";\n\nexport const usage: Usage = () => sprint`\n Log in to your account.\n\n {bold Usage}\n ggt login\n`;\n\nexport const run: Run = async (ctx): Promise<void> => {\n let server: Server | undefined;\n\n try {\n const port = await getPort();\n const receiveSession = new Promise<void>((resolve, reject) => {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n server = http.createServer(async (req, res) => {\n const landingPage = new URL(`https://${config.domains.services}/auth/cli`);\n\n try {\n assert(req.url, \"missing url\");\n const session = new URL(req.url, `http://localhost:${port}`).searchParams.get(\"session\");\n assert(session, \"missing session\");\n\n writeSession(ctx, session);\n\n const user = await getUser(ctx);\n assert(user, \"missing user after successful login\");\n\n if (user.name) {\n println({ ensureEmptyLineAbove: true, content: sprint`Hello, ${user.name} {gray (${user.email})}` });\n } else {\n println({ ensureEmptyLineAbove: true, content: `Hello, ${user.email}` });\n }\n\n landingPage.searchParams.set(\"success\", \"true\");\n resolve();\n } catch (error) {\n writeSession(ctx, undefined);\n landingPage.searchParams.set(\"success\", \"false\");\n reject(error as Error);\n } finally {\n res.writeHead(303, { Location: landingPage.toString() });\n res.end();\n }\n });\n\n ctx.log.info(\"starting login server\", { port });\n server.listen(port);\n });\n\n // open the login page in the user's default browser have it\n // redirect to the cli callback route. The cli callback route will\n // send the session to the server we just started.\n const url = new URL(`https://${config.domains.services}/auth/login`);\n url.searchParams.set(\"returnTo\", `https://${config.domains.services}/auth/cli/callback?port=${port}`);\n\n try {\n ctx.log.info(\"opening browser\", { url: url.toString() });\n await open(url.toString());\n println({\n ensureEmptyLineAbove: true,\n content: sprint`\n We've opened Gadget's login page using your default browser.\n\n Please log in and then return to this terminal.\n `,\n });\n } catch (error) {\n ctx.log.error(\"failed to open browser\", { error });\n println({\n ensureEmptyLineAbove: true,\n content: sprint`\n Please open the following URL in your browser and log in:\n\n {gray ${url.toString()}}\n\n Once logged in, return to this terminal.\n `,\n });\n }\n\n await receiveSession;\n } finally {\n server?.close();\n }\n};\n\n// alias\nexport const login = run;\n", "import net from 'node:net';\nimport os from 'node:os';\n\nclass Locked extends Error {\n\tconstructor(port) {\n\t\tsuper(`${port} is locked`);\n\t}\n}\n\nconst lockedPorts = {\n\told: new Set(),\n\tyoung: new Set(),\n};\n\n// On this interval, the old locked ports are discarded,\n// the young locked ports are moved to old locked ports,\n// and a new young set for locked ports are created.\nconst releaseOldLockedPortsIntervalMs = 1000 * 15;\n\nconst minPort = 1024;\nconst maxPort = 65_535;\n\n// Lazily create timeout on first use\nlet timeout;\n\nconst getLocalHosts = () => {\n\tconst interfaces = os.networkInterfaces();\n\n\t// Add undefined value for createServer function to use default host,\n\t// and default IPv4 host in case createServer defaults to IPv6.\n\tconst results = new Set([undefined, '0.0.0.0']);\n\n\tfor (const _interface of Object.values(interfaces)) {\n\t\tfor (const config of _interface) {\n\t\t\tresults.add(config.address);\n\t\t}\n\t}\n\n\treturn results;\n};\n\nconst checkAvailablePort = options =>\n\tnew Promise((resolve, reject) => {\n\t\tconst server = net.createServer();\n\t\tserver.unref();\n\t\tserver.on('error', reject);\n\n\t\tserver.listen(options, () => {\n\t\t\tconst {port} = server.address();\n\t\t\tserver.close(() => {\n\t\t\t\tresolve(port);\n\t\t\t});\n\t\t});\n\t});\n\nconst getAvailablePort = async (options, hosts) => {\n\tif (options.host || options.port === 0) {\n\t\treturn checkAvailablePort(options);\n\t}\n\n\tfor (const host of hosts) {\n\t\ttry {\n\t\t\tawait checkAvailablePort({port: options.port, host}); // eslint-disable-line no-await-in-loop\n\t\t} catch (error) {\n\t\t\tif (!['EADDRNOTAVAIL', 'EINVAL'].includes(error.code)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn options.port;\n};\n\nconst portCheckSequence = function * (ports) {\n\tif (ports) {\n\t\tyield * ports;\n\t}\n\n\tyield 0; // Fall back to 0 if anything else failed\n};\n\nexport default async function getPorts(options) {\n\tlet ports;\n\tlet exclude = new Set();\n\n\tif (options) {\n\t\tif (options.port) {\n\t\t\tports = typeof options.port === 'number' ? [options.port] : options.port;\n\t\t}\n\n\t\tif (options.exclude) {\n\t\t\tconst excludeIterable = options.exclude;\n\n\t\t\tif (typeof excludeIterable[Symbol.iterator] !== 'function') {\n\t\t\t\tthrow new TypeError('The `exclude` option must be an iterable.');\n\t\t\t}\n\n\t\t\tfor (const element of excludeIterable) {\n\t\t\t\tif (typeof element !== 'number') {\n\t\t\t\t\tthrow new TypeError('Each item in the `exclude` option must be a number corresponding to the port you want excluded.');\n\t\t\t\t}\n\n\t\t\t\tif (!Number.isSafeInteger(element)) {\n\t\t\t\t\tthrow new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\texclude = new Set(excludeIterable);\n\t\t}\n\t}\n\n\tif (timeout === undefined) {\n\t\ttimeout = setTimeout(() => {\n\t\t\ttimeout = undefined;\n\n\t\t\tlockedPorts.old = lockedPorts.young;\n\t\t\tlockedPorts.young = new Set();\n\t\t}, releaseOldLockedPortsIntervalMs);\n\n\t\t// Does not exist in some environments (Electron, Jest jsdom env, browser, etc).\n\t\tif (timeout.unref) {\n\t\t\ttimeout.unref();\n\t\t}\n\t}\n\n\tconst hosts = getLocalHosts();\n\n\tfor (const port of portCheckSequence(ports)) {\n\t\ttry {\n\t\t\tif (exclude.has(port)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet availablePort = await getAvailablePort({...options, port}, hosts); // eslint-disable-line no-await-in-loop\n\t\t\twhile (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {\n\t\t\t\tif (port !== 0) {\n\t\t\t\t\tthrow new Locked(port);\n\t\t\t\t}\n\n\t\t\t\tavailablePort = await getAvailablePort({...options, port}, hosts); // eslint-disable-line no-await-in-loop\n\t\t\t}\n\n\t\t\tlockedPorts.young.add(availablePort);\n\n\t\t\treturn availablePort;\n\t\t} catch (error) {\n\t\t\tif (!['EADDRINUSE', 'EACCES'].includes(error.code) && !(error instanceof Locked)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\tthrow new Error('No available ports found');\n}\n\nexport function portNumbers(from, to) {\n\tif (!Number.isInteger(from) || !Number.isInteger(to)) {\n\t\tthrow new TypeError('`from` and `to` must be integer numbers');\n\t}\n\n\tif (from < minPort || from > maxPort) {\n\t\tthrow new RangeError(`'from' must be between ${minPort} and ${maxPort}`);\n\t}\n\n\tif (to < minPort || to > maxPort) {\n\t\tthrow new RangeError(`'to' must be between ${minPort} and ${maxPort}`);\n\t}\n\n\tif (from > to) {\n\t\tthrow new RangeError('`to` must be greater than or equal to `from`');\n\t}\n\n\tconst generator = function * (from, to) {\n\t\tfor (let port = from; port <= to; port++) {\n\t\t\tyield port;\n\t\t}\n\t};\n\n\treturn generator(from, to);\n}\n\nexport function clearLockedPorts() {\n\tlockedPorts.old.clear();\n\tlockedPorts.young.clear();\n}\n", "import process from 'node:process';\nimport {Buffer} from 'node:buffer';\nimport path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport util from 'node:util';\nimport childProcess from 'node:child_process';\nimport fs, {constants as fsConstants} from 'node:fs/promises';\nimport isWsl from 'is-wsl';\nimport defineLazyProperty from 'define-lazy-prop';\nimport defaultBrowser from 'default-browser';\nimport isInsideContainer from 'is-inside-container';\n\nconst execFile = util.promisify(childProcess.execFile);\n\n// Path to included `xdg-open`.\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst localXdgOpenPath = path.join(__dirname, 'xdg-open');\n\nconst {platform, arch} = process;\n\n/**\nGet the mount point for fixed drives in WSL.\n\n@inner\n@returns {string} The mount point.\n*/\nconst getWslDrivesMountPoint = (() => {\n\t// Default value for \"root\" param\n\t// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config\n\tconst defaultMountPoint = '/mnt/';\n\n\tlet mountPoint;\n\n\treturn async function () {\n\t\tif (mountPoint) {\n\t\t\t// Return memoized mount point value\n\t\t\treturn mountPoint;\n\t\t}\n\n\t\tconst configFilePath = '/etc/wsl.conf';\n\n\t\tlet isConfigFileExists = false;\n\t\ttry {\n\t\t\tawait fs.access(configFilePath, fsConstants.F_OK);\n\t\t\tisConfigFileExists = true;\n\t\t} catch {}\n\n\t\tif (!isConfigFileExists) {\n\t\t\treturn defaultMountPoint;\n\t\t}\n\n\t\tconst configContent = await fs.readFile(configFilePath, {encoding: 'utf8'});\n\t\tconst configMountPoint = /(?<!#.*)root\\s*=\\s*(?<mountPoint>.*)/g.exec(configContent);\n\n\t\tif (!configMountPoint) {\n\t\t\treturn defaultMountPoint;\n\t\t}\n\n\t\tmountPoint = configMountPoint.groups.mountPoint.trim();\n\t\tmountPoint = mountPoint.endsWith('/') ? mountPoint : `${mountPoint}/`;\n\n\t\treturn mountPoint;\n\t};\n})();\n\n/**\nGet the PowerShell executable path in WSL environment.\n\n@returns {Promise<string>} The absolute path to the PowerShell executable in WSL.\n*/\nconst getPowershellPathFromWsl = async () => {\n\tconst mountPoint = await getWslDrivesMountPoint();\n\treturn `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;\n};\n\n/**\nGet the default browser name in Windows from WSL.\n\n@returns {Promise<string>} Browser name.\n*/\nasync function getWindowsDefaultBrowserFromWsl() {\n\tconst powershellPath = await getPowershellPathFromWsl();\n\tconst rawCommand = '(Get-ItemProperty -Path \"HKCU:\\\\Software\\\\Microsoft\\\\Windows\\\\Shell\\\\Associations\\\\UrlAssociations\\\\http\\\\UserChoice\").ProgId';\n\tconst encodedCommand = Buffer.from(rawCommand, 'utf16le').toString('base64');\n\n\tconst {stdout} = await execFile(\n\t\tpowershellPath,\n\t\t[\n\t\t\t'-NoProfile',\n\t\t\t'-NonInteractive',\n\t\t\t'-ExecutionPolicy',\n\t\t\t'Bypass',\n\t\t\t'-EncodedCommand',\n\t\t\tencodedCommand,\n\t\t],\n\t\t{encoding: 'utf8'},\n\t);\n\n\tconst progId = stdout.trim();\n\n\t// Map ProgId to browser IDs\n\tconst browserMap = {\n\t\tChromeHTML: 'com.google.chrome',\n\t\tMSEdgeHTM: 'com.microsoft.edge',\n\t\tFirefoxURL: 'org.mozilla.firefox',\n\t};\n\n\treturn browserMap[progId] ? {id: browserMap[progId]} : {};\n}\n\nconst pTryEach = async (array, mapper) => {\n\tlet latestError;\n\n\tfor (const item of array) {\n\t\ttry {\n\t\t\treturn await mapper(item); // eslint-disable-line no-await-in-loop\n\t\t} catch (error) {\n\t\t\tlatestError = error;\n\t\t}\n\t}\n\n\tthrow latestError;\n};\n\nconst baseOpen = async options => {\n\toptions = {\n\t\twait: false,\n\t\tbackground: false,\n\t\tnewInstance: false,\n\t\tallowNonzeroExitCode: false,\n\t\t...options,\n\t};\n\n\tif (Array.isArray(options.app)) {\n\t\treturn pTryEach(options.app, singleApp => baseOpen({\n\t\t\t...options,\n\t\t\tapp: singleApp,\n\t\t}));\n\t}\n\n\tlet {name: app, arguments: appArguments = []} = options.app ?? {};\n\tappArguments = [...appArguments];\n\n\tif (Array.isArray(app)) {\n\t\treturn pTryEach(app, appName => baseOpen({\n\t\t\t...options,\n\t\t\tapp: {\n\t\t\t\tname: appName,\n\t\t\t\targuments: appArguments,\n\t\t\t},\n\t\t}));\n\t}\n\n\tif (app === 'browser' || app === 'browserPrivate') {\n\t\t// IDs from default-browser for macOS and windows are the same\n\t\tconst ids = {\n\t\t\t'com.google.chrome': 'chrome',\n\t\t\t'google-chrome.desktop': 'chrome',\n\t\t\t'org.mozilla.firefox': 'firefox',\n\t\t\t'firefox.desktop': 'firefox',\n\t\t\t'com.microsoft.msedge': 'edge',\n\t\t\t'com.microsoft.edge': 'edge',\n\t\t\t'com.microsoft.edgemac': 'edge',\n\t\t\t'microsoft-edge.desktop': 'edge',\n\t\t};\n\n\t\t// Incognito flags for each browser in `apps`.\n\t\tconst flags = {\n\t\t\tchrome: '--incognito',\n\t\t\tfirefox: '--private-window',\n\t\t\tedge: '--inPrivate',\n\t\t};\n\n\t\tconst browser = isWsl ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser();\n\t\tif (browser.id in ids) {\n\t\t\tconst browserName = ids[browser.id];\n\n\t\t\tif (app === 'browserPrivate') {\n\t\t\t\tappArguments.push(flags[browserName]);\n\t\t\t}\n\n\t\t\treturn baseOpen({\n\t\t\t\t...options,\n\t\t\t\tapp: {\n\t\t\t\t\tname: apps[browserName],\n\t\t\t\t\targuments: appArguments,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tthrow new Error(`${browser.name} is not supported as a default browser`);\n\t}\n\n\tlet command;\n\tconst cliArguments = [];\n\tconst childProcessOptions = {};\n\n\tif (platform === 'darwin') {\n\t\tcommand = 'open';\n\n\t\tif (options.wait) {\n\t\t\tcliArguments.push('--wait-apps');\n\t\t}\n\n\t\tif (options.background) {\n\t\t\tcliArguments.push('--background');\n\t\t}\n\n\t\tif (options.newInstance) {\n\t\t\tcliArguments.push('--new');\n\t\t}\n\n\t\tif (app) {\n\t\t\tcliArguments.push('-a', app);\n\t\t}\n\t} else if (platform === 'win32' || (isWsl && !isInsideContainer() && !app)) {\n\t\tcommand = isWsl\n\t\t\t? await getPowershellPathFromWsl()\n\t\t\t: `${process.env.SYSTEMROOT || process.env.windir || 'C:\\\\Windows'}\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell`;\n\n\t\tcliArguments.push(\n\t\t\t'-NoProfile',\n\t\t\t'-NonInteractive',\n\t\t\t'-ExecutionPolicy',\n\t\t\t'Bypass',\n\t\t\t'-EncodedCommand',\n\t\t);\n\n\t\tif (!isWsl) {\n\t\t\tchildProcessOptions.windowsVerbatimArguments = true;\n\t\t}\n\n\t\tconst encodedArguments = ['Start'];\n\n\t\tif (options.wait) {\n\t\t\tencodedArguments.push('-Wait');\n\t\t}\n\n\t\tif (app) {\n\t\t\t// Double quote with double quotes to ensure the inner quotes are passed through.\n\t\t\t// Inner quotes are delimited for PowerShell interpretation with backticks.\n\t\t\tencodedArguments.push(`\"\\`\"${app}\\`\"\"`);\n\t\t\tif (options.target) {\n\t\t\t\tappArguments.push(options.target);\n\t\t\t}\n\t\t} else if (options.target) {\n\t\t\tencodedArguments.push(`\"${options.target}\"`);\n\t\t}\n\n\t\tif (appArguments.length > 0) {\n\t\t\tappArguments = appArguments.map(argument => `\"\\`\"${argument}\\`\"\"`);\n\t\t\tencodedArguments.push('-ArgumentList', appArguments.join(','));\n\t\t}\n\n\t\t// Using Base64-encoded command, accepted by PowerShell, to allow special characters.\n\t\toptions.target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');\n\t} else {\n\t\tif (app) {\n\t\t\tcommand = app;\n\t\t} else {\n\t\t\t// When bundled by Webpack, there's no actual package file path and no local `xdg-open`.\n\t\t\tconst isBundled = !__dirname || __dirname === '/';\n\n\t\t\t// Check if local `xdg-open` exists and is executable.\n\t\t\tlet exeLocalXdgOpen = false;\n\t\t\ttry {\n\t\t\t\tawait fs.access(localXdgOpenPath, fsConstants.X_OK);\n\t\t\t\texeLocalXdgOpen = true;\n\t\t\t} catch {}\n\n\t\t\tconst useSystemXdgOpen = process.versions.electron\n\t\t\t\t?? (platform === 'android' || isBundled || !exeLocalXdgOpen);\n\t\t\tcommand = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;\n\t\t}\n\n\t\tif (appArguments.length > 0) {\n\t\t\tcliArguments.push(...appArguments);\n\t\t}\n\n\t\tif (!options.wait) {\n\t\t\t// `xdg-open` will block the process unless stdio is ignored\n\t\t\t// and it's detached from the parent even if it's unref'd.\n\t\t\tchildProcessOptions.stdio = 'ignore';\n\t\t\tchildProcessOptions.detached = true;\n\t\t}\n\t}\n\n\tif (platform === 'darwin' && appArguments.length > 0) {\n\t\tcliArguments.push('--args', ...appArguments);\n\t}\n\n\t// This has to come after `--args`.\n\tif (options.target) {\n\t\tcliArguments.push(options.target);\n\t}\n\n\tconst subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);\n\n\tif (options.wait) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tsubprocess.once('error', reject);\n\n\t\t\tsubprocess.once('close', exitCode => {\n\t\t\t\tif (!options.allowNonzeroExitCode && exitCode > 0) {\n\t\t\t\t\treject(new Error(`Exited with code ${exitCode}`));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(subprocess);\n\t\t\t});\n\t\t});\n\t}\n\n\tsubprocess.unref();\n\n\treturn subprocess;\n};\n\nconst open = (target, options) => {\n\tif (typeof target !== 'string') {\n\t\tthrow new TypeError('Expected a `target`');\n\t}\n\n\treturn baseOpen({\n\t\t...options,\n\t\ttarget,\n\t});\n};\n\nexport const openApp = (name, options) => {\n\tif (typeof name !== 'string' && !Array.isArray(name)) {\n\t\tthrow new TypeError('Expected a valid `name`');\n\t}\n\n\tconst {arguments: appArguments = []} = options ?? {};\n\tif (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {\n\t\tthrow new TypeError('Expected `appArguments` as Array type');\n\t}\n\n\treturn baseOpen({\n\t\t...options,\n\t\tapp: {\n\t\t\tname,\n\t\t\targuments: appArguments,\n\t\t},\n\t});\n};\n\nfunction detectArchBinary(binary) {\n\tif (typeof binary === 'string' || Array.isArray(binary)) {\n\t\treturn binary;\n\t}\n\n\tconst {[arch]: archBinary} = binary;\n\n\tif (!archBinary) {\n\t\tthrow new Error(`${arch} is not supported`);\n\t}\n\n\treturn archBinary;\n}\n\nfunction detectPlatformBinary({[platform]: platformBinary}, {wsl}) {\n\tif (wsl && isWsl) {\n\t\treturn detectArchBinary(wsl);\n\t}\n\n\tif (!platformBinary) {\n\t\tthrow new Error(`${platform} is not supported`);\n\t}\n\n\treturn detectArchBinary(platformBinary);\n}\n\nexport const apps = {};\n\ndefineLazyProperty(apps, 'chrome', () => detectPlatformBinary({\n\tdarwin: 'google chrome',\n\twin32: 'chrome',\n\tlinux: ['google-chrome', 'google-chrome-stable', 'chromium'],\n}, {\n\twsl: {\n\t\tia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',\n\t\tx64: ['/mnt/c/Program Files/Google/Chrome/Application/chrome.exe', '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'],\n\t},\n}));\n\ndefineLazyProperty(apps, 'firefox', () => detectPlatformBinary({\n\tdarwin: 'firefox',\n\twin32: 'C:\\\\Program Files\\\\Mozilla Firefox\\\\firefox.exe',\n\tlinux: 'firefox',\n}, {\n\twsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe',\n}));\n\ndefineLazyProperty(apps, 'edge', () => detectPlatformBinary({\n\tdarwin: 'microsoft edge',\n\twin32: 'msedge',\n\tlinux: ['microsoft-edge', 'microsoft-edge-dev'],\n}, {\n\twsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe',\n}));\n\ndefineLazyProperty(apps, 'browser', () => 'browser');\n\ndefineLazyProperty(apps, 'browserPrivate', () => 'browserPrivate');\n\nexport default open;\n", "export default function defineLazyProperty(object, propertyName, valueGetter) {\n\tconst define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});\n\n\tObject.defineProperty(object, propertyName, {\n\t\tconfigurable: true,\n\t\tenumerable: true,\n\t\tget() {\n\t\t\tconst result = valueGetter();\n\t\t\tdefine(result);\n\t\t\treturn result;\n\t\t},\n\t\tset(value) {\n\t\t\tdefine(value);\n\t\t}\n\t});\n\n\treturn object;\n}\n", "import {promisify} from 'node:util';\nimport process from 'node:process';\nimport {execFile} from 'node:child_process';\nimport defaultBrowserId from 'default-browser-id';\nimport bundleName from 'bundle-name';\nimport windows from './windows.js';\n\nconst execFileAsync = promisify(execFile);\n\n// Inlined: https://github.com/sindresorhus/titleize/blob/main/index.js\nconst titleize = string => string.toLowerCase().replaceAll(/(?:^|\\s|-)\\S/g, x => x.toUpperCase());\n\nexport default async function defaultBrowser() {\n\tif (process.platform === 'darwin') {\n\t\tconst id = await defaultBrowserId();\n\t\tconst name = await bundleName(id);\n\t\treturn {name, id};\n\t}\n\n\tif (process.platform === 'linux') {\n\t\tconst {stdout} = await execFileAsync('xdg-mime', ['query', 'default', 'x-scheme-handler/http']);\n\t\tconst id = stdout.trim();\n\t\tconst name = titleize(id.replace(/.desktop$/, '').replace('-', ' '));\n\t\treturn {name, id};\n\t}\n\n\tif (process.platform === 'win32') {\n\t\treturn windows();\n\t}\n\n\tthrow new Error('Only macOS, Linux, and Windows are supported');\n}\n", "import {promisify} from 'node:util';\nimport process from 'node:process';\nimport {execFile} from 'node:child_process';\n\nconst execFileAsync = promisify(execFile);\n\nexport default async function defaultBrowserId() {\n\tif (process.platform !== 'darwin') {\n\t\tthrow new Error('macOS only');\n\t}\n\n\tconst {stdout} = await execFileAsync('defaults', ['read', 'com.apple.LaunchServices/com.apple.launchservices.secure', 'LSHandlers']);\n\n\t// `(?!-)` is to prevent matching `LSHandlerRoleAll = \"-\";`.\n\tconst match = /LSHandlerRoleAll = \"(?!-)(?<id>[^\"]+?)\";\\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);\n\n\treturn match?.groups.id ?? 'com.apple.Safari';\n}\n", "import {runAppleScript} from 'run-applescript';\n\nexport default async function bundleName(bundleId) {\n\treturn runAppleScript(`tell application \"Finder\" to set app_path to application file id \"${bundleId}\" as string\\ntell application \"System Events\" to get value of property list item \"CFBundleName\" of property list file (app_path & \":Contents:Info.plist\")`);\n}\n", "import process from 'node:process';\nimport {promisify} from 'node:util';\nimport {execFile, execFileSync} from 'node:child_process';\n\nconst execFileAsync = promisify(execFile);\n\nexport async function runAppleScript(script, {humanReadableOutput = true} = {}) {\n\tif (process.platform !== 'darwin') {\n\t\tthrow new Error('macOS only');\n\t}\n\n\tconst outputArguments = humanReadableOutput ? [] : ['-ss'];\n\n\tconst {stdout} = await execFileAsync('osascript', ['-e', script, outputArguments]);\n\treturn stdout.trim();\n}\n\nexport function runAppleScriptSync(script, {humanReadableOutput = true} = {}) {\n\tif (process.platform !== 'darwin') {\n\t\tthrow new Error('macOS only');\n\t}\n\n\tconst outputArguments = humanReadableOutput ? [] : ['-ss'];\n\n\tconst stdout = execFileSync('osascript', ['-e', script, ...outputArguments], {\n\t\tencoding: 'utf8',\n\t\tstdio: ['ignore', 'pipe', 'ignore'],\n\t\ttimeout: 500,\n\t});\n\n\treturn stdout.trim();\n}\n", "import {promisify} from 'node:util';\nimport {execFile} from 'node:child_process';\n\nconst execFileAsync = promisify(execFile);\n\n// Windows doesn't have browser IDs in the same way macOS/Linux does so we give fake\n// ones that look real and match the macOS/Linux versions for cross-platform apps.\nconst windowsBrowserProgIds = {\n\tAppXq0fevzme2pys62n3e0fbqa7peapykr8v: {name: 'Edge', id: 'com.microsoft.edge.old'},\n\tMSEdgeDHTML: {name: 'Edge', id: 'com.microsoft.edge'}, // On macOS, it's \"com.microsoft.edgemac\"\n\tMSEdgeHTM: {name: 'Edge', id: 'com.microsoft.edge'}, // Newer Edge/Win10 releases\n\t'IE.HTTP': {name: 'Internet Explorer', id: 'com.microsoft.ie'},\n\tFirefoxURL: {name: 'Firefox', id: 'org.mozilla.firefox'},\n\tChromeHTML: {name: 'Chrome', id: 'com.google.chrome'},\n\tBraveHTML: {name: 'Brave', id: 'com.brave.Browser'},\n\tBraveBHTML: {name: 'Brave Beta', id: 'com.brave.Browser.beta'},\n\tBraveSSHTM: {name: 'Brave Nightly', id: 'com.brave.Browser.nightly'},\n};\n\nexport class UnknownBrowserError extends Error {}\n\nexport default async function defaultBrowser(_execFileAsync = execFileAsync) {\n\tconst {stdout} = await _execFileAsync('reg', [\n\t\t'QUERY',\n\t\t' HKEY_CURRENT_USER\\\\Software\\\\Microsoft\\\\Windows\\\\Shell\\\\Associations\\\\UrlAssociations\\\\http\\\\UserChoice',\n\t\t'/v',\n\t\t'ProgId',\n\t]);\n\n\tconst match = /ProgId\\s*REG_SZ\\s*(?<id>\\S+)/.exec(stdout);\n\tif (!match) {\n\t\tthrow new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);\n\t}\n\n\tconst {id} = match.groups;\n\n\tconst browser = windowsBrowserProgIds[id];\n\tif (!browser) {\n\t\tthrow new UnknownBrowserError(`Unknown browser ID: ${id}`);\n\t}\n\n\treturn browser;\n}\n", "import assert from \"node:assert\";\nimport { z } from \"zod\";\nimport { login } from \"../../commands/login.js\";\nimport type { Command } from \"../command/command.js\";\nimport type { Context } from \"../command/context.js\";\nimport { config } from \"../config/config.js\";\nimport { maybeLoadAuthHeaders, swallowUnauthorized } from \"../http/auth.js\";\nimport { http } from \"../http/http.js\";\nimport { confirm } from \"../output/confirm.js\";\nimport { println } from \"../output/print.js\";\nimport { setSentryUser } from \"../output/sentry.js\";\n\nconst User = z.object({\n id: z.union([z.string(), z.number()]).transform(Number),\n name: z.string().nullish(),\n email: z.string(),\n});\n\nexport type User = z.infer<typeof User>;\n\n/**\n * Retrieves the currently logged in user from Gadgets API.\n *\n * @returns A Promise that resolves to a User object representing the\n * current user, or undefined if the user is not authenticated.\n */\nexport const getUser = async (ctx: Context): Promise<User | undefined> => {\n const headers = maybeLoadAuthHeaders(ctx);\n if (!headers) {\n return undefined;\n }\n\n try {\n const json = await http({\n context: { ctx },\n url: `https://${config.domains.services}/auth/api/current-user`,\n headers,\n responseType: \"json\",\n resolveBodyOnly: true,\n });\n\n const user = User.parse(json);\n ctx.log.info(\"loaded user\", { user: { id: user.id } }, { user });\n\n setSentryUser(user);\n\n return user;\n } catch (error) {\n swallowUnauthorized(ctx, error);\n return undefined;\n }\n};\n\n/**\n * Retrieves the current user or prompts the user to log in if not\n * already logged in.\n *\n * @param ctx - The current context.\n * @returns A Promise that resolves to the current user.\n */\nexport const getUserOrLogin = async (ctx: Context, command: Command): Promise<User> => {\n let user = await getUser(ctx);\n if (user) {\n return user;\n }\n\n ctx.log.info(\"prompting user to log in\");\n println({\n ensureEmptyLineAbove: true,\n content: `You must be logged in to use \"ggt ${command}\".`,\n });\n\n await confirm({ ensureEmptyLineAbove: true, content: \"Would you like to log in?\" });\n await login(ctx, { _: [] });\n\n user = await getUser(ctx);\n assert(user, \"missing user after successful login\");\n\n return user;\n};\n", "import chalk from \"chalk\";\nimport process from \"node:process\";\nimport type { Promisable } from \"type-fest\";\nimport { defaults } from \"../util/object.js\";\nimport type { PartialExcept } from \"../util/types.js\";\nimport { output } from \"./output.js\";\nimport { println, type PrintOptions } from \"./print.js\";\nimport { Prompt, type StdinKey } from \"./prompt.js\";\nimport { sprintln } from \"./sprint.js\";\n\nexport type ConfirmOptions = PrintOptions & {\n /**\n * If `true`, ggt will exit if the user selects \"No\".\n *\n * @default true\n */\n exitWhenNo?: boolean;\n\n /**\n * What to do if ggt is not running in an interactive terminal.\n *\n * @default ```\n * println(options)(text);\n * println({ ensureEmptyLineAbove: true })`\n * Aborting because ggt is not running in an interactive terminal.\n * `;\n * process.exit(1);\n * ```\n */\n whenNotInteractive?: () => Promisable<void>;\n};\n\nexport type confirm = typeof confirm;\n\nexport const confirm = (contentOrOptions: string | ConfirmOptions): Promise<void> => {\n let options: ConfirmOptions;\n if (typeof contentOrOptions === \"string\") {\n options = { content: contentOrOptions };\n } else {\n options = contentOrOptions;\n }\n\n options = defaults(options, {\n ensureEmptyLineAbove: true,\n ensureNewLine: true,\n exitWhenNo: true,\n });\n\n if (!output.isInteractive) {\n const whenNotInteractive =\n options.whenNotInteractive ??\n (() => {\n println(options);\n println({ ensureEmptyLineAbove: true, content: \"Aborting because ggt is not running in an interactive terminal.\" });\n process.exit(1);\n });\n\n return Promise.resolve(whenNotInteractive());\n }\n\n return new Promise((resolve) => {\n const conf = new Confirm(options);\n conf.on(\"submit\", resolve);\n conf.on(\"exit\", () => process.exit(0));\n conf.on(\"abort\", () => process.exit(1));\n });\n};\n\n/**\n * Inspired by `prompts`:\n * https://github.com/terkelg/prompts/blob/e0519913ec4fcc6746bb3d97d8cd0960c3f3ffde/lib/elements/confirm.js\n *\n * MIT License\n *\n * Copyright (c) 2018 Terkel Gjervig Nielsen\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nexport class Confirm extends Prompt {\n override value: boolean | undefined = undefined;\n defaultValue = false;\n options;\n\n constructor(options: PartialExcept<ConfirmOptions, \"content\">) {\n super();\n\n this.options = defaults(options, {\n exitWhenNo: true,\n ensureEmptyLineAbove: true,\n });\n\n this.render();\n }\n\n reset(): void {\n this.value = this.defaultValue;\n this.fire();\n this.render();\n }\n\n exit(): void {\n this.abort();\n }\n\n abort(): void {\n this.value = false;\n this.done = this.aborted = true;\n this.fire();\n this.render(false);\n this.close();\n\n if (this.options.exitWhenNo) {\n process.exit(0);\n }\n }\n\n submit(): void {\n this.value = this.value ?? false;\n this.done = true;\n this.aborted = false;\n this.fire();\n this.render();\n this.close();\n\n if (this.options.exitWhenNo && !this.value) {\n process.exit(0);\n }\n }\n\n override _(char: string, _key: StdinKey): void {\n if (char.toLowerCase() === \"y\") {\n this.value = true;\n this.submit();\n return;\n }\n\n if (char.toLowerCase() === \"n\") {\n this.value = false;\n this.submit();\n return;\n }\n\n this.bell();\n }\n\n override render(value = this.value): void {\n super.render();\n\n if (this.done) {\n output.persistPrompt(\n sprintln({\n ...this.options,\n content: `${this.options.content} ${value ? chalk.bold.greenBright(\"Yes.\") : chalk.bold.redBright(\"No.\")}`,\n }),\n );\n return;\n }\n\n output.updatePrompt(\n sprintln({\n ...this.options,\n content: `${this.options.content} ${this.defaultValue ? chalk.blueBright(\"[Y/n] \") : chalk.blueBright(\"[y/N] \")}`,\n }),\n );\n }\n}\n"],
5
+ "mappings": "uSAAAA,ICAAC,IAAA,OAAOC,OAAS,WAChB,OAAOC,OAAQ,UAEf,IAAMC,EAAN,cAAqB,KAAM,CAH3B,MAG2B,CAAAC,EAAA,eAC1B,YAAYC,EAAM,CACjB,MAAM,GAAGA,CAAI,YAAY,CAC1B,CACD,EAEMC,EAAc,CACnB,IAAK,IAAI,IACT,MAAO,IAAI,GACZ,EAKMC,GAAkC,IAAO,GAM/C,IAAIC,EAEEC,GAAgBC,EAAA,IAAM,CAC3B,IAAMC,EAAaC,GAAG,kBAAkB,EAIlCC,EAAU,IAAI,IAAI,CAAC,OAAW,SAAS,CAAC,EAE9C,QAAWC,KAAc,OAAO,OAAOH,CAAU,EAChD,QAAWI,KAAUD,EACpBD,EAAQ,IAAIE,EAAO,OAAO,EAI5B,OAAOF,CACR,EAdsB,iBAgBhBG,EAAqBN,EAAAO,GAC1B,IAAI,QAAQ,CAACC,EAASC,IAAW,CAChC,IAAMC,EAASC,GAAI,aAAa,EAChCD,EAAO,MAAM,EACbA,EAAO,GAAG,QAASD,CAAM,EAEzBC,EAAO,OAAOH,EAAS,IAAM,CAC5B,GAAM,CAAC,KAAAK,CAAI,EAAIF,EAAO,QAAQ,EAC9BA,EAAO,MAAM,IAAM,CAClBF,EAAQI,CAAI,CACb,CAAC,CACF,CAAC,CACF,CAAC,EAZyB,sBAcrBC,EA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SAAS,CAAE,CAAC,EACvDD,EAAI,IAAI,CACV,CACF,CAAC,EAEDT,EAAI,IAAI,KAAK,wBAAyB,CAAE,KAAAE,CAAK,CAAC,EAC9CD,EAAO,OAAOC,CAAI,CACpB,CAAC,EAKKiB,EAAM,IAAI,IAAI,WAAWR,EAAO,QAAQ,QAAQ,aAAa,EACnEQ,EAAI,aAAa,IAAI,WAAY,WAAWR,EAAO,QAAQ,QAAQ,2BAA2BT,CAAI,EAAE,EAEpG,GAAI,CACFF,EAAI,IAAI,KAAK,kBAAmB,CAAE,IAAKmB,EAAI,SAAS,CAAE,CAAC,EACvD,MAAMC,GAAKD,EAAI,SAAS,CAAC,EACzBF,EAAQ,CACN,qBAAsB,GACtB,QAASnB;AAAA;AAAA;AAAA;AAAA,SAKX,CAAC,CACH,OAASoB,EAAO,CACdlB,EAAI,IAAI,MAAM,yBAA0B,CAAE,MAAAkB,CAAM,CAAC,EACjDD,EAAQ,CACN,qBAAsB,GACtB,QAASnB;AAAA;AAAA;AAAA,oBAGGqB,EAAI,SAAS,CAAC;AAAA;AAAA;AAAA,SAI5B,CAAC,CACH,CAEA,MAAMf,CACR,QAAE,CACAH,GAAQ,MAAM,CAChB,CACF,EA7EwB,OAgFXoB,GAAQtB",
6
+ "names": ["init_cjs", "init_cjs", "net", "os", "Locked", "__name", "port", "lockedPorts", "releaseOldLockedPortsIntervalMs", "timeout", "getLocalHosts", "__name", "interfaces", "os", "results", "_interface", "config", "checkAvailablePort", "options", "resolve", "reject", "server", "net", "port", "getAvailablePort", "hosts", "host", "error", "portCheckSequence", "ports", "getPorts", "exclude", "excludeIterable", "element", "lockedPorts", "releaseOldLockedPortsIntervalMs", "availablePort", "Locked", "assert", "http", "init_cjs", "process", "Buffer", "path", "fileURLToPath", "util", "childProcess", "fs", "fsConstants", "init_cjs", "defineLazyProperty", "object", "propertyName", "valueGetter", "define", "__name", "value", "result", "init_cjs", "promisify", "process", "execFile", "init_cjs", "promisify", "process", "execFile", "execFileAsync", "promisify", "execFile", "defaultBrowserId", "process", "stdout", "__name", "init_cjs", "init_cjs", "process", "promisify", "execFile", "execFileSync", "execFileAsync", "promisify", "execFile", "runAppleScript", "script", "humanReadableOutput", "process", "outputArguments", "stdout", "__name", "bundleName", "bundleId", "runAppleScript", "__name", "init_cjs", "promisify", "execFile", "execFileAsync", "promisify", "execFile", "windowsBrowserProgIds", "UnknownBrowserError", "__name", "defaultBrowser", "_execFileAsync", "stdout", "match", "id", "browser", "execFileAsync", "promisify", "execFile", "titleize", "__name", "string", "x", "defaultBrowser", "process", "id", "defaultBrowserId", "bundleName", "stdout", "execFile", "util", "childProcess", "__dirname", "path", "fileURLToPath", "localXdgOpenPath", "platform", "arch", "process", "getWslDrivesMountPoint", "defaultMountPoint", "mountPoint", "configFilePath", "isConfigFileExists", "fs", "fsConstants", "configContent", "configMountPoint", "getPowershellPathFromWsl", "__name", "getWindowsDefaultBrowserFromWsl", "powershellPath", "encodedCommand", "Buffer", "stdout", "progId", "browserMap", "pTryEach", "array", "mapper", "latestError", "item", "error", "baseOpen", "options", "singleApp", "app", "appArguments", "appName", "ids", "flags", "browser", "is_wsl_default", "defaultBrowser", "browserName", "apps", "command", "cliArguments", "childProcessOptions", "isInsideContainer", "encodedArguments", "argument", "isBundled", "exeLocalXdgOpen", "subprocess", "resolve", "reject", "exitCode", "open", "target", "detectArchBinary", "binary", "arch", "archBinary", "__name", "detectPlatformBinary", "platform", "platformBinary", "wsl", "is_wsl_default", "apps", "defineLazyProperty", "open_default", "open", "init_cjs", "assert", "init_cjs", "process", "confirm", "__name", "contentOrOptions", "options", "defaults", "output", "whenNotInteractive", "println", "process", "resolve", "conf", "Confirm", "Prompt", "char", "_key", "value", "sprintln", "source_default", "User", "z", "getUser", "__name", "ctx", "headers", "maybeLoadAuthHeaders", "json", "http", "config", "user", "setSentryUser", "error", "swallowUnauthorized", "getUserOrLogin", "command", "println", "confirm", "login", "assert", "usage", "__name", "sprint", "run", "ctx", "server", "port", "getPorts", "receiveSession", "resolve", "reject", "http", "req", "res", "landingPage", "config", "assert", "session", "writeSession", "user", "getUser", "println", "error", "url", "open_default", "login"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{f as C,g as b,h as E}from"./chunk-LPBWX353.js";import{b as D}from"./chunk-XK6JJEHJ.js";import{b as N,f as G}from"./chunk-5NCJDCIZ.js";import{a as m,d as $,f as P,h as y}from"./chunk-7DYQUG5M.js";var S=$((F,I)=>{y();var _=Symbol("arg flag"),a=class n extends Error{static{m(this,"ArgError")}constructor(t,p){super(t),this.name="ArgError",this.code=p,Object.setPrototypeOf(this,n.prototype)}};function A(n,{argv:t=process.argv.slice(2),permissive:p=!1,stopAtPositional:w=!1}={}){if(!n)throw new a("argument specification object is required","ARG_CONFIG_NO_SPEC");let e={_:[]},s={},c={};for(let r of Object.keys(n)){if(!r)throw new a("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY");if(r[0]!=="-")throw new a(`argument key must start with '-' but found: '${r}'`,"ARG_CONFIG_NONOPT_KEY");if(r.length===1)throw new a(`argument key must have a name; singular '-' keys are not allowed: ${r}`,"ARG_CONFIG_NONAME_KEY");if(typeof n[r]=="string"){s[r]=n[r];continue}let l=n[r],i=!1;if(Array.isArray(l)&&l.length===1&&typeof l[0]=="function"){let[u]=l;l=m((f,d,g=[])=>(g.push(u(f,d,g[g.length-1])),g),"type"),i=u===Boolean||u[_]===!0}else if(typeof l=="function")i=l===Boolean||l[_]===!0;else throw new a(`type missing or not a function or valid array type: ${r}`,"ARG_CONFIG_VAD_TYPE");if(r[1]!=="-"&&r.length>2)throw new a(`short argument keys (with a single hyphen) must have only one character: ${r}`,"ARG_CONFIG_SHORTOPT_TOOLONG");c[r]=[l,i]}for(let r=0,l=t.length;r<l;r++){let i=t[r];if(w&&e._.length>0){e._=e._.concat(t.slice(r));break}if(i==="--"){e._=e._.concat(t.slice(r+1));break}if(i.length>1&&i[0]==="-"){let u=i[1]==="-"||i.length===2?[i]:i.slice(1).split("").map(f=>`-${f}`);for(let f=0;f<u.length;f++){let d=u[f],[g,k]=d[1]==="-"?d.split(/=(.*)/,2):[d,void 0],o=g;for(;o in s;)o=s[o];if(!(o in c))if(p){e._.push(d);continue}else throw new a(`unknown or unexpected option: ${g}`,"ARG_UNKNOWN_OPTION");let[h,R]=c[o];if(!R&&f+1<u.length)throw new a(`option requires argument (but was followed by another short argument): ${g}`,"ARG_MISSING_REQUIRED_SHORTARG");if(R)e[o]=h(!0,o,e[o]);else if(k===void 0){if(t.length<r+2||t[r+1].length>1&&t[r+1][0]==="-"&&!(t[r+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(h===Number||typeof BigInt<"u"&&h===BigInt))){let T=g===o?"":` (alias for ${o})`;throw new a(`option requires argument: ${g}${T}`,"ARG_MISSING_REQUIRED_LONGARG")}e[o]=h(t[r+1],o,e[o]),++r}else e[o]=h(k,o,e[o])}}else e._.push(i)}return e}m(A,"arg");A.flag=n=>(n[_]=!0,n);A.COUNT=A.flag((n,t,p)=>(p||0)+1);A.ArgError=a;I.exports=A});y();var x=P(S(),1);var L=m((n,t)=>{let p={},w={};for(let[e,s]of Object.entries(n)){if(!("type"in s)){p[e]=s;continue}if(p[e]=s.type,w[e]=s.default,s.alias)for(let c of Array.isArray(s.alias)?s.alias:[s.alias])p[c]=e}try{let e=(0,x.default)(p,t);for(let[s,c]of Object.entries(w))G(e[s])&&(e[s]=c);return e}catch(e){throw e instanceof x.default.ArgError&&(e=new O(e.message)),e instanceof b?e:new E(e)}},"parseArgs"),O=class extends b{static{m(this,"ArgError")}isBug=C.NO;render(){return`${N.redBright(D.cross)} `+this.message}};y();import j from"node:assert";var H=["dev","deploy","status","push","pull","add","open","list","login","logout","whoami","configure","version"],K=m(n=>H.includes(n),"isCommand"),J=m(async n=>{j(K(n),`invalid command: ${n}`);let t;switch(n){case"dev":t=await import("./dev-M2PFPQXX.js");break;case"deploy":t=await import("./deploy-6JWXSMQJ.js");break;case"status":t=await import("./status-OYEFON4A.js");break;case"push":t=await import("./push-KWUMHQCJ.js");break;case"pull":t=await import("./pull-VWGETR4M.js");break;case"add":t=await import("./add-FGXJSCE2.js");break;case"open":t=await import("./open-TWQBAPIT.js");break;case"list":t=await import("./list-LNXNHS2W.js");break;case"login":t=await import("./login-4F3H443A.js");break;case"logout":t=await import("./logout-JA5JBU3G.js");break;case"whoami":t=await import("./whoami-TIGWXVEY.js");break;case"configure":t=await import("./configure-L4U26WFP.js");break;case"version":t=await import("./version-4QPNJ5VH.js");break}return t},"importCommand");export{S as a,L as b,O as c,H as d,K as e,J as f};
2
+ //# sourceMappingURL=chunk-SIAMHUOB.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../node_modules/.pnpm/arg@5.0.2/node_modules/arg/index.js", "../src/services/command/arg.ts", "../src/services/command/command.ts"],
4
- "sourcesContent": ["const flagSymbol = Symbol('arg flag');\n\nclass ArgError extends Error {\n\tconstructor(msg, code) {\n\t\tsuper(msg);\n\t\tthis.name = 'ArgError';\n\t\tthis.code = code;\n\n\t\tObject.setPrototypeOf(this, ArgError.prototype);\n\t}\n}\n\nfunction arg(\n\topts,\n\t{\n\t\targv = process.argv.slice(2),\n\t\tpermissive = false,\n\t\tstopAtPositional = false\n\t} = {}\n) {\n\tif (!opts) {\n\t\tthrow new ArgError(\n\t\t\t'argument specification object is required',\n\t\t\t'ARG_CONFIG_NO_SPEC'\n\t\t);\n\t}\n\n\tconst result = { _: [] };\n\n\tconst aliases = {};\n\tconst handlers = {};\n\n\tfor (const key of Object.keys(opts)) {\n\t\tif (!key) {\n\t\t\tthrow new ArgError(\n\t\t\t\t'argument key cannot be an empty string',\n\t\t\t\t'ARG_CONFIG_EMPTY_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key[0] !== '-') {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must start with '-' but found: '${key}'`,\n\t\t\t\t'ARG_CONFIG_NONOPT_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key.length === 1) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must have a name; singular '-' keys are not allowed: ${key}`,\n\t\t\t\t'ARG_CONFIG_NONAME_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (typeof opts[key] === 'string') {\n\t\t\taliases[key] = opts[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet type = opts[key];\n\t\tlet isFlag = false;\n\n\t\tif (\n\t\t\tArray.isArray(type) &&\n\t\t\ttype.length === 1 &&\n\t\t\ttypeof type[0] === 'function'\n\t\t) {\n\t\t\tconst [fn] = type;\n\t\t\ttype = (value, name, prev = []) => {\n\t\t\t\tprev.push(fn(value, name, prev[prev.length - 1]));\n\t\t\t\treturn prev;\n\t\t\t};\n\t\t\tisFlag = fn === Boolean || fn[flagSymbol] === true;\n\t\t} else if (typeof type === 'function') {\n\t\t\tisFlag = type === Boolean || type[flagSymbol] === true;\n\t\t} else {\n\t\t\tthrow new ArgError(\n\t\t\t\t`type missing or not a function or valid array type: ${key}`,\n\t\t\t\t'ARG_CONFIG_VAD_TYPE'\n\t\t\t);\n\t\t}\n\n\t\tif (key[1] !== '-' && key.length > 2) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`short argument keys (with a single hyphen) must have only one character: ${key}`,\n\t\t\t\t'ARG_CONFIG_SHORTOPT_TOOLONG'\n\t\t\t);\n\t\t}\n\n\t\thandlers[key] = [type, isFlag];\n\t}\n\n\tfor (let i = 0, len = argv.length; i < len; i++) {\n\t\tconst wholeArg = argv[i];\n\n\t\tif (stopAtPositional && result._.length > 0) {\n\t\t\tresult._ = result._.concat(argv.slice(i));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg === '--') {\n\t\t\tresult._ = result._.concat(argv.slice(i + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg.length > 1 && wholeArg[0] === '-') {\n\t\t\t/* eslint-disable operator-linebreak */\n\t\t\tconst separatedArguments =\n\t\t\t\twholeArg[1] === '-' || wholeArg.length === 2\n\t\t\t\t\t? [wholeArg]\n\t\t\t\t\t: wholeArg\n\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t.split('')\n\t\t\t\t\t\t\t.map((a) => `-${a}`);\n\t\t\t/* eslint-enable operator-linebreak */\n\n\t\t\tfor (let j = 0; j < separatedArguments.length; j++) {\n\t\t\t\tconst arg = separatedArguments[j];\n\t\t\t\tconst [originalArgName, argStr] =\n\t\t\t\t\targ[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];\n\n\t\t\t\tlet argName = originalArgName;\n\t\t\t\twhile (argName in aliases) {\n\t\t\t\t\targName = aliases[argName];\n\t\t\t\t}\n\n\t\t\t\tif (!(argName in handlers)) {\n\t\t\t\t\tif (permissive) {\n\t\t\t\t\t\tresult._.push(arg);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`unknown or unexpected option: ${originalArgName}`,\n\t\t\t\t\t\t\t'ARG_UNKNOWN_OPTION'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst [type, isFlag] = handlers[argName];\n\n\t\t\t\tif (!isFlag && j + 1 < separatedArguments.length) {\n\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t`option requires argument (but was followed by another short argument): ${originalArgName}`,\n\t\t\t\t\t\t'ARG_MISSING_REQUIRED_SHORTARG'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isFlag) {\n\t\t\t\t\tresult[argName] = type(true, argName, result[argName]);\n\t\t\t\t} else if (argStr === undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\targv.length < i + 2 ||\n\t\t\t\t\t\t(argv[i + 1].length > 1 &&\n\t\t\t\t\t\t\targv[i + 1][0] === '-' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\targv[i + 1].match(/^-?\\d*(\\.(?=\\d))?\\d*$/) &&\n\t\t\t\t\t\t\t\t(type === Number ||\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-undef\n\t\t\t\t\t\t\t\t\t(typeof BigInt !== 'undefined' && type === BigInt))\n\t\t\t\t\t\t\t))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst extended =\n\t\t\t\t\t\t\toriginalArgName === argName ? '' : ` (alias for ${argName})`;\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`option requires argument: ${originalArgName}${extended}`,\n\t\t\t\t\t\t\t'ARG_MISSING_REQUIRED_LONGARG'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult[argName] = type(argv[i + 1], argName, result[argName]);\n\t\t\t\t\t++i;\n\t\t\t\t} else {\n\t\t\t\t\tresult[argName] = type(argStr, argName, result[argName]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresult._.push(wholeArg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\narg.flag = (fn) => {\n\tfn[flagSymbol] = true;\n\treturn fn;\n};\n\n// Utility types\narg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);\n\n// Expose error class\narg.ArgError = ArgError;\n\nmodule.exports = arg;\n", "import arg from \"arg\";\nimport chalk from \"chalk\";\nimport type { Simplify } from \"type-fest\";\nimport { GGTError, IsBug, UnexpectedError } from \"../output/report.js\";\nimport { symbol } from \"../output/symbols.js\";\nimport { isNil } from \"../util/is.js\";\n\nexport type ArgsDefinition = Record<string, ArgDefinition>;\n\ntype ArgDefinition<Handler extends arg.Handler = arg.Handler> =\n | Handler\n | {\n type: Handler;\n alias?: string | string[];\n default?: ReturnType<Handler>;\n };\n\nexport type ParseArgsOptions = {\n /**\n * A list of arguments to parse.\n */\n argv?: string[];\n\n /**\n * When permissive set to `true`, arg will push any unknown arguments\n * onto the \"extra\" argument array (`ctx.args._`) instead of throwing\n * an error about an unknown flag.\n *\n * @default false\n */\n permissive?: boolean;\n\n /**\n * When stopAtPositional is set to true, context will stop parsing at\n * the first positional argument.\n *\n * @default false\n */\n stopAtPositional?: boolean;\n};\n\nexport const parseArgs = <Args extends ArgsDefinition>(args: Args, options?: arg.Options): ArgsDefinitionResult<Args> => {\n const spec: arg.Spec = {};\n const defaultValues: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n if (!(\"type\" in value)) {\n spec[key] = value;\n continue;\n }\n\n spec[key] = value.type;\n defaultValues[key] = value.default;\n\n if (value.alias) {\n for (const alias of Array.isArray(value.alias) ? value.alias : [value.alias]) {\n spec[alias] = key;\n }\n }\n }\n\n try {\n const parsed = arg(spec, options);\n for (const [key, value] of Object.entries(defaultValues)) {\n if (isNil(parsed[key])) {\n parsed[key] = value as never;\n }\n }\n return parsed as ArgsDefinitionResult<Args>;\n } catch (error: unknown) {\n if (error instanceof arg.ArgError) {\n // convert arg.ArgError to GGTError\n // eslint-disable-next-line no-ex-assign\n error = new ArgError(error.message);\n }\n if (error instanceof GGTError) {\n throw error;\n }\n throw new UnexpectedError(error);\n }\n};\n\nexport class ArgError extends GGTError {\n isBug = IsBug.NO;\n\n protected override render(): string {\n return `${chalk.redBright(symbol.cross)} ` + this.message;\n }\n}\n\n/**\n * Turns this:\n * ```ts\n * type Args = {\n * \"--string\": { type: String; alias: \"s\" };\n * \"--number\": { type: Number; default: 42 };\n * };\n * ```\n *\n * Into this:\n * ```ts\n * type Result = {\n * \"--string\": string | undefined;\n * \"--number\": number;\n * };\n * ```\n */\nexport type ArgsDefinitionResult<Args extends ArgsDefinition, Keys extends keyof Args = keyof Args> = Simplify<{\n [Key in Keys]: Args[Key] extends ArgDefinition<infer Handler>\n ? Args[Key] extends { default: unknown }\n ? NonNullable<ReturnType<Handler>>\n : ReturnType<Handler> | undefined\n : never;\n}> & { _: string[] };\n", "import assert from \"node:assert\";\nimport type { EmptyObject, Promisable } from \"type-fest\";\nimport type { ArgsDefinition, ArgsDefinitionResult } from \"./arg.js\";\nimport type { Context } from \"./context.js\";\n\n/**\n * The list of available commands.\n *\n * 1. Every command corresponds to a file inside of src/commands/\n * 2. The order determines the order of commands in the README\n */\nexport const Commands = [\"dev\", \"deploy\", \"status\", \"push\", \"pull\", \"add\", \"open\", \"list\", \"login\", \"logout\", \"whoami\", \"version\"] as const;\n\n/**\n * One of the commands in {@link Commands}.\n */\nexport type Command = (typeof Commands)[number];\n\n/**\n * Checks if a string is a valid command.\n *\n * @param command - The string to check\n * @returns Whether the string is a valid command\n */\nexport const isCommand = (command: string): command is Command => {\n return Commands.includes(command as Command);\n};\n\n/**\n * A command module is a file in the src/commands/ directory.\n */\nexport type CommandModule<Args extends ArgsDefinition = EmptyObject> = {\n /**\n * The command's {@link ArgsDefinition args}.\n */\n args?: Args;\n\n /**\n * The command's {@link Usage usage}.\n */\n usage: Usage;\n\n /**\n * The command's {@link Run run} function.\n */\n run: Run<Args>;\n};\n\n/**\n * A {@linkcode Command command}'s usage is a function that returns a\n * string describing how to use the command.\n */\nexport type Usage = (ctx: Context) => string;\n\n/**\n * The function that is run when the command is called.\n */\nexport type Run<Args extends ArgsDefinition = EmptyObject> = (ctx: Context, args: ArgsDefinitionResult<Args>) => Promisable<void>;\n\n/**\n * Imports a command module.\n *\n * @param cmd - The command to import\n * @see {@linkcode CommandModule}\n */\nexport const importCommand = async (cmd: Command): Promise<CommandModule> => {\n assert(isCommand(cmd), `invalid command: ${cmd}`);\n\n let module;\n switch (cmd) {\n case \"dev\":\n module = await import(\"../../commands/dev.js\");\n break;\n case \"deploy\":\n module = await import(\"../../commands/deploy.js\");\n break;\n case \"status\":\n module = await import(\"../../commands/status.js\");\n break;\n case \"push\":\n module = await import(\"../../commands/push.js\");\n break;\n case \"pull\":\n module = await import(\"../../commands/pull.js\");\n break;\n case \"add\":\n module = await import(\"../../commands/add.js\");\n break;\n case \"open\":\n module = await import(\"../../commands/open.js\");\n break;\n case \"list\":\n module = await import(\"../../commands/list.js\");\n break;\n case \"login\":\n module = await import(\"../../commands/login.js\");\n break;\n case \"logout\":\n module = await import(\"../../commands/logout.js\");\n break;\n case \"whoami\":\n module = await import(\"../../commands/whoami.js\");\n break;\n case \"version\":\n module = await import(\"../../commands/version.js\");\n break;\n }\n\n return module as CommandModule;\n};\n"],
5
- "mappings": "yKAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAAAC,IAAA,IAAMC,EAAa,OAAO,UAAU,EAE9BC,EAAN,MAAMC,UAAiB,KAAM,CAF7B,MAE6B,CAAAC,EAAA,iBAC5B,YAAYC,EAAKC,EAAM,CACtB,MAAMD,CAAG,EACT,KAAK,KAAO,WACZ,KAAK,KAAOC,EAEZ,OAAO,eAAe,KAAMH,EAAS,SAAS,CAC/C,CACD,EAEA,SAASI,EACRC,EACA,CACC,KAAAC,EAAO,QAAQ,KAAK,MAAM,CAAC,EAC3B,WAAAC,EAAa,GACb,iBAAAC,EAAmB,EACpB,EAAI,CAAC,EACJ,CACD,GAAI,CAACH,EACJ,MAAM,IAAIN,EACT,4CACA,oBACD,EAGD,IAAMU,EAAS,CAAE,EAAG,CAAC,CAAE,EAEjBC,EAAU,CAAC,EACXC,EAAW,CAAC,EAElB,QAAWC,KAAO,OAAO,KAAKP,CAAI,EAAG,CACpC,GAAI,CAACO,EACJ,MAAM,IAAIb,EACT,yCACA,sBACD,EAGD,GAAIa,EAAI,CAAC,IAAM,IACd,MAAM,IAAIb,EACT,gDAAgDa,CAAG,IACnD,uBACD,EAGD,GAAIA,EAAI,SAAW,EAClB,MAAM,IAAIb,EACT,qEAAqEa,CAAG,GACxE,uBACD,EAGD,GAAI,OAAOP,EAAKO,CAAG,GAAM,SAAU,CAClCF,EAAQE,CAAG,EAAIP,EAAKO,CAAG,EACvB,QACD,CAEA,IAAIC,EAAOR,EAAKO,CAAG,EACfE,EAAS,GAEb,GACC,MAAM,QAAQD,CAAI,GAClBA,EAAK,SAAW,GAChB,OAAOA,EAAK,CAAC,GAAM,WAClB,CACD,GAAM,CAACE,CAAE,EAAIF,EACbA,EAAOZ,EAAA,CAACe,EAAOC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AoBA,CAAG,EAAE,EAEhD,IAAIE,EACJ,OAAQF,EAAK,CACX,IAAK,MACHE,EAAS,KAAM,QAAO,mBAAuB,EAC7C,MACF,IAAK,SACHA,EAAS,KAAM,QAAO,sBAA0B,EAChD,MACF,IAAK,SACHA,EAAS,KAAM,QAAO,sBAA0B,EAChD,MACF,IAAK,OACHA,EAAS,KAAM,QAAO,oBAAwB,EAC9C,MACF,IAAK,OACHA,EAAS,KAAM,QAAO,oBAAwB,EAC9C,MACF,IAAK,MACHA,EAAS,KAAM,QAAO,mBAAuB,EAC7C,MACF,IAAK,OACHA,EAAS,KAAM,QAAO,oBAAwB,EAC9C,MACF,IAAK,OACHA,EAAS,KAAM,QAAO,oBAAwB,EAC9C,MACF,IAAK,QACHA,EAAS,KAAM,QAAO,qBAAyB,EAC/C,MACF,IAAK,SACHA,EAAS,KAAM,QAAO,sBAA0B,EAChD,MACF,IAAK,SACHA,EAAS,KAAM,QAAO,sBAA0B,EAChD,MACF,IAAK,UACHA,EAAS,KAAM,QAAO,uBAA2B,EACjD,KACJ,CAEA,OAAOA,CACT,EA5C6B",
4
+ "sourcesContent": ["const flagSymbol = Symbol('arg flag');\n\nclass ArgError extends Error {\n\tconstructor(msg, code) {\n\t\tsuper(msg);\n\t\tthis.name = 'ArgError';\n\t\tthis.code = code;\n\n\t\tObject.setPrototypeOf(this, ArgError.prototype);\n\t}\n}\n\nfunction arg(\n\topts,\n\t{\n\t\targv = process.argv.slice(2),\n\t\tpermissive = false,\n\t\tstopAtPositional = false\n\t} = {}\n) {\n\tif (!opts) {\n\t\tthrow new ArgError(\n\t\t\t'argument specification object is required',\n\t\t\t'ARG_CONFIG_NO_SPEC'\n\t\t);\n\t}\n\n\tconst result = { _: [] };\n\n\tconst aliases = {};\n\tconst handlers = {};\n\n\tfor (const key of Object.keys(opts)) {\n\t\tif (!key) {\n\t\t\tthrow new ArgError(\n\t\t\t\t'argument key cannot be an empty string',\n\t\t\t\t'ARG_CONFIG_EMPTY_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key[0] !== '-') {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must start with '-' but found: '${key}'`,\n\t\t\t\t'ARG_CONFIG_NONOPT_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key.length === 1) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must have a name; singular '-' keys are not allowed: ${key}`,\n\t\t\t\t'ARG_CONFIG_NONAME_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (typeof opts[key] === 'string') {\n\t\t\taliases[key] = opts[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet type = opts[key];\n\t\tlet isFlag = false;\n\n\t\tif (\n\t\t\tArray.isArray(type) &&\n\t\t\ttype.length === 1 &&\n\t\t\ttypeof type[0] === 'function'\n\t\t) {\n\t\t\tconst [fn] = type;\n\t\t\ttype = (value, name, prev = []) => {\n\t\t\t\tprev.push(fn(value, name, prev[prev.length - 1]));\n\t\t\t\treturn prev;\n\t\t\t};\n\t\t\tisFlag = fn === Boolean || fn[flagSymbol] === true;\n\t\t} else if (typeof type === 'function') {\n\t\t\tisFlag = type === Boolean || type[flagSymbol] === true;\n\t\t} else {\n\t\t\tthrow new ArgError(\n\t\t\t\t`type missing or not a function or valid array type: ${key}`,\n\t\t\t\t'ARG_CONFIG_VAD_TYPE'\n\t\t\t);\n\t\t}\n\n\t\tif (key[1] !== '-' && key.length > 2) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`short argument keys (with a single hyphen) must have only one character: ${key}`,\n\t\t\t\t'ARG_CONFIG_SHORTOPT_TOOLONG'\n\t\t\t);\n\t\t}\n\n\t\thandlers[key] = [type, isFlag];\n\t}\n\n\tfor (let i = 0, len = argv.length; i < len; i++) {\n\t\tconst wholeArg = argv[i];\n\n\t\tif (stopAtPositional && result._.length > 0) {\n\t\t\tresult._ = result._.concat(argv.slice(i));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg === '--') {\n\t\t\tresult._ = result._.concat(argv.slice(i + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg.length > 1 && wholeArg[0] === '-') {\n\t\t\t/* eslint-disable operator-linebreak */\n\t\t\tconst separatedArguments =\n\t\t\t\twholeArg[1] === '-' || wholeArg.length === 2\n\t\t\t\t\t? [wholeArg]\n\t\t\t\t\t: wholeArg\n\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t.split('')\n\t\t\t\t\t\t\t.map((a) => `-${a}`);\n\t\t\t/* eslint-enable operator-linebreak */\n\n\t\t\tfor (let j = 0; j < separatedArguments.length; j++) {\n\t\t\t\tconst arg = separatedArguments[j];\n\t\t\t\tconst [originalArgName, argStr] =\n\t\t\t\t\targ[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];\n\n\t\t\t\tlet argName = originalArgName;\n\t\t\t\twhile (argName in aliases) {\n\t\t\t\t\targName = aliases[argName];\n\t\t\t\t}\n\n\t\t\t\tif (!(argName in handlers)) {\n\t\t\t\t\tif (permissive) {\n\t\t\t\t\t\tresult._.push(arg);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`unknown or unexpected option: ${originalArgName}`,\n\t\t\t\t\t\t\t'ARG_UNKNOWN_OPTION'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst [type, isFlag] = handlers[argName];\n\n\t\t\t\tif (!isFlag && j + 1 < separatedArguments.length) {\n\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t`option requires argument (but was followed by another short argument): ${originalArgName}`,\n\t\t\t\t\t\t'ARG_MISSING_REQUIRED_SHORTARG'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isFlag) {\n\t\t\t\t\tresult[argName] = type(true, argName, result[argName]);\n\t\t\t\t} else if (argStr === undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\targv.length < i + 2 ||\n\t\t\t\t\t\t(argv[i + 1].length > 1 &&\n\t\t\t\t\t\t\targv[i + 1][0] === '-' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\targv[i + 1].match(/^-?\\d*(\\.(?=\\d))?\\d*$/) &&\n\t\t\t\t\t\t\t\t(type === Number ||\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-undef\n\t\t\t\t\t\t\t\t\t(typeof BigInt !== 'undefined' && type === BigInt))\n\t\t\t\t\t\t\t))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst extended =\n\t\t\t\t\t\t\toriginalArgName === argName ? '' : ` (alias for ${argName})`;\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`option requires argument: ${originalArgName}${extended}`,\n\t\t\t\t\t\t\t'ARG_MISSING_REQUIRED_LONGARG'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult[argName] = type(argv[i + 1], argName, result[argName]);\n\t\t\t\t\t++i;\n\t\t\t\t} else {\n\t\t\t\t\tresult[argName] = type(argStr, argName, result[argName]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresult._.push(wholeArg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\narg.flag = (fn) => {\n\tfn[flagSymbol] = true;\n\treturn fn;\n};\n\n// Utility types\narg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);\n\n// Expose error class\narg.ArgError = ArgError;\n\nmodule.exports = arg;\n", "import arg from \"arg\";\nimport chalk from \"chalk\";\nimport type { Simplify } from \"type-fest\";\nimport { GGTError, IsBug, UnexpectedError } from \"../output/report.js\";\nimport { symbol } from \"../output/symbols.js\";\nimport { isNil } from \"../util/is.js\";\n\nexport type ArgsDefinition = Record<string, ArgDefinition>;\n\ntype ArgDefinition<Handler extends arg.Handler = arg.Handler> =\n | Handler\n | {\n type: Handler;\n alias?: string | string[];\n default?: ReturnType<Handler>;\n };\n\nexport type ParseArgsOptions = {\n /**\n * A list of arguments to parse.\n */\n argv?: string[];\n\n /**\n * When permissive set to `true`, arg will push any unknown arguments\n * onto the \"extra\" argument array (`ctx.args._`) instead of throwing\n * an error about an unknown flag.\n *\n * @default false\n */\n permissive?: boolean;\n\n /**\n * When stopAtPositional is set to true, context will stop parsing at\n * the first positional argument.\n *\n * @default false\n */\n stopAtPositional?: boolean;\n};\n\nexport const parseArgs = <Args extends ArgsDefinition>(args: Args, options?: arg.Options): ArgsDefinitionResult<Args> => {\n const spec: arg.Spec = {};\n const defaultValues: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n if (!(\"type\" in value)) {\n spec[key] = value;\n continue;\n }\n\n spec[key] = value.type;\n defaultValues[key] = value.default;\n\n if (value.alias) {\n for (const alias of Array.isArray(value.alias) ? value.alias : [value.alias]) {\n spec[alias] = key;\n }\n }\n }\n\n try {\n const parsed = arg(spec, options);\n for (const [key, value] of Object.entries(defaultValues)) {\n if (isNil(parsed[key])) {\n parsed[key] = value as never;\n }\n }\n return parsed as ArgsDefinitionResult<Args>;\n } catch (error: unknown) {\n if (error instanceof arg.ArgError) {\n // convert arg.ArgError to GGTError\n // eslint-disable-next-line no-ex-assign\n error = new ArgError(error.message);\n }\n if (error instanceof GGTError) {\n throw error;\n }\n throw new UnexpectedError(error);\n }\n};\n\nexport class ArgError extends GGTError {\n isBug = IsBug.NO;\n\n protected override render(): string {\n return `${chalk.redBright(symbol.cross)} ` + this.message;\n }\n}\n\n/**\n * Turns this:\n * ```ts\n * type Args = {\n * \"--string\": { type: String; alias: \"s\" };\n * \"--number\": { type: Number; default: 42 };\n * };\n * ```\n *\n * Into this:\n * ```ts\n * type Result = {\n * \"--string\": string | undefined;\n * \"--number\": number;\n * };\n * ```\n */\nexport type ArgsDefinitionResult<Args extends ArgsDefinition, Keys extends keyof Args = keyof Args> = Simplify<{\n [Key in Keys]: Args[Key] extends ArgDefinition<infer Handler>\n ? Args[Key] extends { default: unknown }\n ? NonNullable<ReturnType<Handler>>\n : ReturnType<Handler> | undefined\n : never;\n}> & { _: string[] };\n", "import assert from \"node:assert\";\nimport type { EmptyObject, Promisable } from \"type-fest\";\nimport type { ArgsDefinition, ArgsDefinitionResult } from \"./arg.js\";\nimport type { Context } from \"./context.js\";\n\n/**\n * The list of available commands.\n *\n * 1. Every command corresponds to a file inside of src/commands/\n * 2. The order determines the order of commands in the README\n */\nexport const Commands = [\n \"dev\",\n \"deploy\",\n \"status\",\n \"push\",\n \"pull\",\n \"add\",\n \"open\",\n \"list\",\n \"login\",\n \"logout\",\n \"whoami\",\n \"configure\",\n \"version\",\n] as const;\n\n/**\n * One of the commands in {@link Commands}.\n */\nexport type Command = (typeof Commands)[number];\n\n/**\n * Checks if a string is a valid command.\n *\n * @param command - The string to check\n * @returns Whether the string is a valid command\n */\nexport const isCommand = (command: string): command is Command => {\n return Commands.includes(command as Command);\n};\n\n/**\n * A command module is a file in the src/commands/ directory.\n */\nexport type CommandModule<Args extends ArgsDefinition = EmptyObject> = {\n /**\n * The command's {@link ArgsDefinition args}.\n */\n args?: Args;\n\n /**\n * The command's {@link Usage usage}.\n */\n usage: Usage;\n\n /**\n * The command's {@link Run run} function.\n */\n run: Run<Args>;\n};\n\n/**\n * A {@linkcode Command command}'s usage is a function that returns a\n * string describing how to use the command.\n */\nexport type Usage = (ctx: Context) => string;\n\n/**\n * The function that is run when the command is called.\n */\nexport type Run<Args extends ArgsDefinition = EmptyObject> = (ctx: Context, args: ArgsDefinitionResult<Args>) => Promisable<void>;\n\n/**\n * Imports a command module.\n *\n * @param cmd - The command to import\n * @see {@linkcode CommandModule}\n */\nexport const importCommand = async (cmd: Command): Promise<CommandModule> => {\n assert(isCommand(cmd), `invalid command: ${cmd}`);\n\n let module;\n switch (cmd) {\n case \"dev\":\n module = await import(\"../../commands/dev.js\");\n break;\n case \"deploy\":\n module = await import(\"../../commands/deploy.js\");\n break;\n case \"status\":\n module = await import(\"../../commands/status.js\");\n break;\n case \"push\":\n module = await import(\"../../commands/push.js\");\n break;\n case \"pull\":\n module = await import(\"../../commands/pull.js\");\n break;\n case \"add\":\n module = await import(\"../../commands/add.js\");\n break;\n case \"open\":\n module = await import(\"../../commands/open.js\");\n break;\n case \"list\":\n module = await import(\"../../commands/list.js\");\n break;\n case \"login\":\n module = await import(\"../../commands/login.js\");\n break;\n case \"logout\":\n module = await import(\"../../commands/logout.js\");\n break;\n case \"whoami\":\n module = await import(\"../../commands/whoami.js\");\n break;\n case \"configure\":\n module = await import(\"../../commands/configure.js\");\n break;\n case \"version\":\n module = await import(\"../../commands/version.js\");\n break;\n }\n\n return module as CommandModule;\n};\n"],
5
+ "mappings": "0MAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAAAC,IAAA,IAAMC,EAAa,OAAO,UAAU,EAE9BC,EAAN,MAAMC,UAAiB,KAAM,CAF7B,MAE6B,CAAAC,EAAA,iBAC5B,YAAYC,EAAKC,EAAM,CACtB,MAAMD,CAAG,EACT,KAAK,KAAO,WACZ,KAAK,KAAOC,EAEZ,OAAO,eAAe,KAAMH,EAAS,SAAS,CAC/C,CACD,EAEA,SAASI,EACRC,EACA,CACC,KAAAC,EAAO,QAAQ,KAAK,MAAM,CAAC,EAC3B,WAAAC,EAAa,GACb,iBAAAC,EAAmB,EACpB,EAAI,CAAC,EACJ,CACD,GAAI,CAACH,EACJ,MAAM,IAAIN,EACT,4CACA,oBACD,EAGD,IAAMU,EAAS,CAAE,EAAG,CAAC,CAAE,EAEjBC,EAAU,CAAC,EACXC,EAAW,CAAC,EAElB,QAAWC,KAAO,OAAO,KAAKP,CAAI,EAAG,CACpC,GAAI,CAACO,EACJ,MAAM,IAAIb,EACT,yCACA,sBACD,EAGD,GAAIa,EAAI,CAAC,IAAM,IACd,MAAM,IAAIb,EACT,gDAAgDa,CAAG,IACnD,uBACD,EAGD,GAAIA,EAAI,SAAW,EAClB,MAAM,IAAIb,EACT,qEAAqEa,CAAG,GACxE,uBACD,EAGD,GAAI,OAAOP,EAAKO,CAAG,GAAM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C,IAAA,OAAOC,MAAY,cAWZ,IAAMC,EAAW,CACtB,MACA,SACA,SACA,OACA,OACA,MACA,OACA,OACA,QACA,SACA,SACA,YACA,SACF,EAaaC,EAAYC,EAACC,GACjBH,EAAS,SAASG,CAAkB,EADpB,aAyCZC,EAAgBF,EAAA,MAAOG,GAAyC,CAC3EC,EAAOL,EAAUI,CAAG,EAAG,oBAAoBA,CAAG,EAAE,EAEhD,IAAIE,EACJ,OAAQF,EAAK,CACX,IAAK,MACHE,EAAS,KAAM,QAAO,mBAAuB,EAC7C,MACF,IAAK,SACHA,EAAS,KAAM,QAAO,sBAA0B,EAChD,MACF,IAAK,SACHA,EAAS,KAAM,QAAO,sBAA0B,EAChD,MACF,IAAK,OACHA,EAAS,KAAM,QAAO,oBAAwB,EAC9C,MACF,IAAK,OACHA,EAAS,KAAM,QAAO,oBAAwB,EAC9C,MACF,IAAK,MACHA,EAAS,KAAM,QAAO,mBAAuB,EAC7C,MACF,IAAK,OACHA,EAAS,KAAM,QAAO,oBAAwB,EAC9C,MACF,IAAK,OACHA,EAAS,KAAM,QAAO,oBAAwB,EAC9C,MACF,IAAK,QACHA,EAAS,KAAM,QAAO,qBAAyB,EAC/C,MACF,IAAK,SACHA,EAAS,KAAM,QAAO,sBAA0B,EAChD,MACF,IAAK,SACHA,EAAS,KAAM,QAAO,sBAA0B,EAChD,MACF,IAAK,YACHA,EAAS,KAAM,QAAO,yBAA6B,EACnD,MACF,IAAK,UACHA,EAAS,KAAM,QAAO,uBAA2B,EACjD,KACJ,CAEA,OAAOA,CACT,EA/C6B",
6
6
  "names": ["require_arg", "__commonJSMin", "exports", "module", "init_cjs", "flagSymbol", "ArgError", "_ArgError", "__name", "msg", "code", "arg", "opts", "argv", "permissive", "stopAtPositional", "result", "aliases", "handlers", "key", "type", "isFlag", "fn", "value", "name", "prev", "i", "len", "wholeArg", "separatedArguments", "a", "j", "originalArgName", "argStr", "argName", "extended", "v", "existingCount", "init_cjs", "import_arg", "parseArgs", "__name", "args", "options", "spec", "defaultValues", "key", "value", "alias", "parsed", "arg", "isNil", "error", "ArgError", "GGTError", "UnexpectedError", "IsBug", "source_default", "symbol", "init_cjs", "assert", "Commands", "isCommand", "__name", "command", "importCommand", "cmd", "assert", "module"]
7
7
  }
@@ -0,0 +1,12 @@
1
+ import{z}from"./chunk-5NCJDCIZ.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};
2
+ /*! Bundled license information:
3
+
4
+ normalize-path/index.js:
5
+ (*!
6
+ * normalize-path <https://github.com/jonschlinkert/normalize-path>
7
+ *
8
+ * Copyright (c) 2014-2018, Jon Schlinkert.
9
+ * Released under the MIT License.
10
+ *)
11
+ */
12
+ //# sourceMappingURL=chunk-VJVFVZNR.js.map