shopify 3.94.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.js +5 -1
- package/dist/analytics-6IHHYAV6.js +1 -0
- package/dist/analytics-KKVP5DT3.js +1 -0
- package/dist/bootstrap.d.ts +5 -0
- package/dist/bootstrap.js +3 -0
- package/dist/chunk-22PCRFG4.js +1 -0
- package/dist/chunk-26D72ZNV.js +1 -0
- package/dist/chunk-2APPXD5Z.js +2 -0
- package/dist/chunk-2I4PRX2I.js +1 -0
- package/dist/chunk-2VQJQ36C.js +103 -0
- package/dist/chunk-323UTVMM.js +1 -0
- package/dist/chunk-3DQIVE24.js +9 -0
- package/dist/chunk-3F6NZK7S.js +2 -0
- package/dist/chunk-3LVGAQB4.js +1 -0
- package/dist/chunk-3TNEIDOD.js +1 -0
- package/dist/chunk-3VZEETAV.js +1 -0
- package/dist/chunk-4G7J6HIV.js +1 -0
- package/dist/chunk-4HHXSMD7.js +10 -0
- package/dist/chunk-4LNCYIS3.js +1 -0
- package/dist/chunk-4ZGSSQC6.js +1 -0
- package/dist/chunk-52GC6XUT.js +1 -0
- package/dist/chunk-5CH3B62S.js +2 -0
- package/dist/chunk-5Y7GIF2W.js +1 -0
- package/dist/chunk-66RJ5T7A.js +102 -0
- package/dist/chunk-6B53BWJW.js +1 -0
- package/dist/chunk-6BMMB2UO.js +1 -0
- package/dist/chunk-6HBRBQAN.js +6 -0
- package/dist/chunk-6M3ZYNGO.js +451 -0
- package/dist/chunk-6TZAAS5H.js +1 -0
- package/dist/chunk-72F3YBNA.js +1 -0
- package/dist/chunk-74HYYXXE.js +17 -0
- package/dist/chunk-75VPUOC5.js +1 -0
- package/dist/chunk-7BGM2GAH.js +1 -0
- package/dist/chunk-7UYZQN4V.js +18 -0
- package/dist/chunk-A74GETYC.js +1 -0
- package/dist/chunk-AIV5RI3X.js +1 -0
- package/dist/chunk-ALKTLKQ6.js +5 -0
- package/dist/chunk-B2EHO7ZC.js +847 -0
- package/dist/chunk-B2IVY4V5.js +1 -0
- package/dist/chunk-BDVAE5MS.js +28 -0
- package/dist/chunk-CERXUPGC.js +14 -0
- package/dist/chunk-D3TSJA5S.js +1 -0
- package/dist/chunk-D6JARNEH.js +1 -0
- package/dist/chunk-DFMQWJQ3.js +3 -0
- package/dist/chunk-DJONKJSZ.js +1 -0
- package/dist/chunk-DJQVNH7P.js +567 -0
- package/dist/chunk-DU4WR4OP.js +1 -0
- package/dist/chunk-ELVFJ7BR.js +4 -0
- package/dist/chunk-ELYP4KFP.js +8 -0
- package/dist/chunk-FFQ5EWII.js +294 -0
- package/dist/chunk-FUOIGXI4.js +1 -0
- package/dist/chunk-GD7FWXJ5.js +2 -0
- package/dist/chunk-GFEAKSGV.js +374 -0
- package/dist/chunk-GFJ7UV74.js +1 -0
- package/dist/chunk-GNPS5SBU.js +1 -0
- package/dist/chunk-GOJ2QHSR.js +1 -0
- package/dist/chunk-HSK7YMRE.js +359 -0
- package/dist/chunk-HUZUORYM.js +19 -0
- package/dist/chunk-HZA6IAA4.js +1 -0
- package/dist/chunk-IASVAERO.js +1 -0
- package/dist/chunk-IIIVWD4R.js +1 -0
- package/dist/chunk-INEU4XKS.js +6 -0
- package/dist/chunk-IOLVEXM6.js +1 -0
- package/dist/chunk-IU2ZQ6TE.js +2 -0
- package/dist/chunk-IX5ICOBV.js +7 -0
- package/dist/chunk-J3KVONB3.js +6 -0
- package/dist/chunk-JGXWQULI.js +1 -0
- package/dist/chunk-JHPRFW5B.js +19 -0
- package/dist/chunk-JLBH7RCF.js +4 -0
- package/dist/chunk-JPGO36XP.js +1 -0
- package/dist/chunk-JUVAGMIH.js +1 -0
- package/dist/chunk-JVIKCGDY.js +1 -0
- package/dist/chunk-K2WUCOQJ.js +32 -0
- package/dist/chunk-K5YV6UVF.js +4 -0
- package/dist/chunk-KBQ4LGFB.js +1 -0
- package/dist/chunk-KGXQS7LS.js +1 -0
- package/dist/chunk-KL5Z3T6L.js +1 -0
- package/dist/chunk-KLMDWDT2.js +1 -0
- package/dist/chunk-KNVM7N3U.js +1 -0
- package/dist/chunk-KWJ562F2.js +12 -0
- package/dist/chunk-LALIKZPS.js +5 -0
- package/dist/chunk-LAZJ47DZ.js +6 -0
- package/dist/chunk-LDGAHMS7.js +159 -0
- package/dist/chunk-LNHLDRC5.js +1 -0
- package/dist/chunk-LW7U753G.js +1 -0
- package/dist/chunk-LX3ZOW52.js +12 -0
- package/dist/chunk-LXFJDCNG.js +1 -0
- package/dist/chunk-MBAFWQSZ.js +7 -0
- package/dist/chunk-MOA33ZFO.js +1 -0
- package/dist/chunk-MQNYGGAM.js +1 -0
- package/dist/chunk-N5YIPQ6J.js +1 -0
- package/dist/chunk-N7RBSKYT.js +1 -0
- package/dist/chunk-NF2ABOOU.js +1 -0
- package/dist/chunk-NRAFVIU3.js +1 -0
- package/dist/chunk-OCOY5MV2.js +1 -0
- package/dist/chunk-ODNGDO4H.js +50 -0
- package/dist/chunk-OHY4ZL3U.js +2 -0
- package/dist/chunk-OLZHWPZP.js +1 -0
- package/dist/chunk-OUOYKNMY.js +1 -0
- package/dist/chunk-OXPWCC7I.js +64 -0
- package/dist/chunk-P5VVOLGV.js +1 -0
- package/dist/chunk-P6XE4MH5.js +1 -0
- package/dist/chunk-P7R7FBY2.js +3 -0
- package/dist/chunk-PD5ZHJWI.js +1 -0
- package/dist/chunk-PIBY5DDZ.js +1 -0
- package/dist/chunk-Q7ING5F5.js +1 -0
- package/dist/chunk-QFWIDATO.js +1 -0
- package/dist/chunk-QRRNOVJ3.js +1 -0
- package/dist/chunk-QSTEVZFQ.js +1 -0
- package/dist/chunk-R466TU3N.js +2 -0
- package/dist/chunk-RF2DPBA6.js +1 -0
- package/dist/chunk-RFG5RMPL.js +1 -0
- package/dist/chunk-RM5SJJN6.js +559 -0
- package/dist/chunk-RVNMVBPM.js +1 -0
- package/dist/chunk-SBEZBZM7.js +144 -0
- package/dist/chunk-SGQ6D3LU.js +15 -0
- package/dist/chunk-SRCQVUMC.js +1 -0
- package/dist/chunk-TFSBQ4RY.js +5 -0
- package/dist/chunk-TQYMC7TH.js +1 -0
- package/dist/chunk-UGDBJTLP.js +6 -0
- package/dist/chunk-UGXYQ23Y.js +1411 -0
- package/dist/chunk-UWJ73J4B.js +1 -0
- package/dist/chunk-V2CNCPIE.js +2 -0
- package/dist/chunk-VBUZWRUL.js +1 -0
- package/dist/chunk-VS3T5YOG.js +264 -0
- package/dist/chunk-VWYM4OWK.js +1 -0
- package/dist/chunk-VY6SNDKW.js +3 -0
- package/dist/chunk-WDC3KIZT.js +2 -0
- package/dist/chunk-WFXRSKRK.js +1 -0
- package/dist/chunk-WXVZJJOR.js +16 -0
- package/dist/chunk-WZBSLU4Q.js +6 -0
- package/dist/chunk-XBXMPFXM.js +1 -0
- package/dist/chunk-XEFQQPL4.js +1 -0
- package/dist/chunk-XLELNRFF.js +3 -0
- package/dist/chunk-XNO6DZYP.js +1 -0
- package/dist/chunk-Y5JKV2AI.js +1 -0
- package/dist/chunk-YC6G4MHD.js +3 -0
- package/dist/chunk-YI232QLS.js +1 -0
- package/dist/chunk-YMWHHINU.js +1 -0
- package/dist/chunk-YOZNRLFC.js +1 -0
- package/dist/chunk-YZDDTYTU.js +11 -0
- package/dist/chunk-Z35BTAM6.js +2 -0
- package/dist/chunk-ZR76GGZ6.js +5 -0
- package/dist/chunk-ZTMSBSYD.js +1 -0
- package/dist/chunk-ZV6NCNI4.js +586 -0
- package/dist/chunk-ZVJVDCIM.js +1 -0
- package/dist/cli/commands/app/app-logs/sources.js +2 -0
- package/dist/cli/commands/app/build.js +1 -0
- package/dist/cli/commands/app/bulk/cancel.js +1 -0
- package/dist/cli/commands/app/bulk/execute.js +9 -0
- package/dist/cli/commands/app/bulk/status.js +5 -0
- package/dist/cli/commands/app/config/link.js +4 -0
- package/dist/cli/commands/app/config/pull.js +1 -0
- package/dist/cli/commands/app/config/use.js +1 -0
- package/dist/cli/commands/app/config/validate.js +3 -0
- package/dist/cli/commands/app/demo/watcher.js +1 -0
- package/dist/cli/commands/app/deploy.js +22 -0
- package/dist/cli/commands/app/dev/clean.js +5 -0
- package/dist/cli/commands/app/dev.js +320 -0
- package/dist/cli/commands/app/env/pull.js +11 -0
- package/dist/cli/commands/app/env/show.js +1 -0
- package/dist/cli/commands/app/execute.js +1 -0
- package/dist/cli/commands/app/function/build.js +1 -0
- package/dist/cli/commands/app/function/info.js +16 -0
- package/dist/cli/commands/app/function/replay.js +5 -0
- package/dist/cli/commands/app/function/run.js +1 -0
- package/dist/cli/commands/app/function/schema.js +1 -0
- package/dist/cli/commands/app/function/typegen.js +1 -0
- package/dist/cli/commands/app/generate/extension.js +5 -0
- package/dist/cli/commands/app/import-custom-data-definitions.js +4 -0
- package/dist/cli/commands/app/import-extensions.js +1 -0
- package/dist/cli/commands/app/info.js +11 -0
- package/dist/cli/commands/app/init.js +10 -0
- package/dist/cli/commands/app/logs.js +2 -0
- package/dist/cli/commands/app/release.js +4 -0
- package/dist/cli/commands/app/versions/list.js +1 -0
- package/dist/cli/commands/app/webhook/trigger.js +25 -0
- package/dist/cli/commands/auth/login.js +1 -20
- package/dist/cli/commands/auth/logout.js +1 -12
- package/dist/cli/commands/cache/clear.js +1 -11
- package/dist/cli/commands/config/autoupgrade/constants.d.ts +0 -1
- package/dist/cli/commands/config/autoupgrade/constants.js +1 -6
- package/dist/cli/commands/config/autoupgrade/off.js +1 -22
- package/dist/cli/commands/config/autoupgrade/on.js +1 -22
- package/dist/cli/commands/config/autoupgrade/status.js +1 -30
- package/dist/cli/commands/debug/command-flags.js +1 -79
- package/dist/cli/commands/docs/generate.js +1 -157
- package/dist/cli/commands/doctor-release/doctor-release.js +1 -25
- package/dist/cli/commands/doctor-release/theme/index.js +1 -56
- package/dist/cli/commands/help.js +1 -26
- package/dist/cli/commands/kitchen-sink/async.js +1 -16
- package/dist/cli/commands/kitchen-sink/index.js +1 -21
- package/dist/cli/commands/kitchen-sink/prompts.js +1 -16
- package/dist/cli/commands/kitchen-sink/static.js +1 -16
- package/dist/cli/commands/notifications/generate.js +1 -11
- package/dist/cli/commands/notifications/list.js +1 -33
- package/dist/cli/commands/organization/list.js +1 -0
- package/dist/cli/commands/search.js +1 -27
- package/dist/cli/commands/theme/check.js +1 -0
- package/dist/cli/commands/theme/console.js +15 -0
- package/dist/cli/commands/theme/delete.js +7 -0
- package/dist/cli/commands/theme/dev.js +26 -0
- package/dist/cli/commands/theme/duplicate.js +32 -0
- package/dist/cli/commands/theme/info.js +1 -0
- package/dist/cli/commands/theme/init.js +8 -0
- package/dist/cli/commands/theme/language-server.js +1 -0
- package/dist/cli/commands/theme/list.js +1 -0
- package/dist/cli/commands/theme/metafields/pull.js +3 -0
- package/dist/cli/commands/theme/open.js +8 -0
- package/dist/cli/commands/theme/package.js +7 -0
- package/dist/cli/commands/theme/preview.js +1 -0
- package/dist/cli/commands/theme/profile.js +3 -0
- package/dist/cli/commands/theme/publish.js +7 -0
- package/dist/cli/commands/theme/pull.js +3 -0
- package/dist/cli/commands/theme/push.js +28 -0
- package/dist/cli/commands/theme/rename.js +6 -0
- package/dist/cli/commands/theme/share.js +3 -0
- package/dist/cli/commands/upgrade.js +1 -17
- package/dist/cli/commands/version.js +1 -10
- package/dist/command-registry.d.ts +8 -0
- package/dist/command-registry.js +1 -0
- package/dist/conf-store-U5ZITKJN.js +1 -0
- package/dist/custom-oclif-loader-DVFFWCBV.js +1 -0
- package/dist/deprecations-TU5UQJVV.js +1 -0
- package/dist/dist-2Z5TND4U.js +1 -0
- package/dist/dist-GYHFDHKP.js +1 -0
- package/dist/environments-Z5PR7DSI.js +1 -0
- package/dist/error-IJGNYKZ3.js +1 -0
- package/dist/error-handler-WSCGNS2P.js +1 -0
- package/dist/fs-5BDEA2KD.js +1 -0
- package/dist/hooks/app-init.d.ts +9 -0
- package/dist/hooks/app-init.js +1 -0
- package/dist/hooks/did-you-mean.d.ts +1 -0
- package/dist/hooks/did-you-mean.js +1 -0
- package/dist/hooks/hydrogen-init.d.ts +7 -0
- package/dist/hooks/hydrogen-init.js +1 -0
- package/dist/hooks/plugin-plugins.d.ts +1 -0
- package/dist/hooks/plugin-plugins.js +1 -0
- package/dist/hooks/postrun.js +1 -1
- package/dist/hooks/prerun.js +1 -1
- package/dist/hooks/public-metadata.d.ts +1 -0
- package/dist/hooks/public-metadata.js +1 -0
- package/dist/hooks/sensitive-metadata.d.ts +1 -0
- package/dist/hooks/sensitive-metadata.js +1 -0
- package/dist/hooks/tunnel-provider.d.ts +1 -0
- package/dist/hooks/tunnel-provider.js +1 -0
- package/dist/hooks/tunnel-start.d.ts +1 -0
- package/dist/hooks/tunnel-start.js +1 -0
- package/dist/http-proxy-node16-Q5DZMBHC.js +38 -0
- package/dist/index.js +254 -3668
- package/dist/is-global-V4ZRHQG2.js +1 -0
- package/dist/latest-version-EFWBOTWM.js +49 -0
- package/dist/lib-5L7UKDEK.js +1 -0
- package/dist/lib-C3VO2BQW.js +1 -0
- package/dist/lib-QB6I6CTC.js +1 -0
- package/dist/local-6QPX4GCJ.js +1 -0
- package/dist/local-storage-JLXBZVWO.js +1 -0
- package/dist/metadata-UDMOTRS7.js +1 -0
- package/dist/{morph-DQREIZD2.js → morph-EMYAITFM.js} +1 -1
- package/dist/node-package-manager-HAFRYGUM.js +1 -0
- package/dist/notifications-system-MP7WDOCS.js +1 -0
- package/dist/npa-ICFSA3NL.js +1 -0
- package/dist/output-YGMHXEIS.js +1 -0
- package/dist/{path-HUAU3YBW.js → path-CWUNINMX.js} +1 -1
- package/dist/{prettier-PGDJ5B7I.js → prettier-NVRHEAFO.js} +1 -1
- package/dist/system-KLXD4FXF.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typescript-K5CWIA4V.js +1 -0
- package/dist/ui-GHG3UGB3.js +1 -0
- package/dist/upgrade-OPZGPM5J.js +1 -0
- package/dist/version-D5PJZIRW.js +1 -0
- package/dist/version-KRQBMYCH.js +1 -0
- package/dist/workerd-L2EJKIAQ.js +18 -0
- package/oclif.manifest.json +5247 -6056
- package/package.json +17 -41
- package/dist/chunk-2E6Y4J4T.js +0 -3
- package/dist/chunk-45T5XUIM.js +0 -1
- package/dist/chunk-52KHWFYF.js +0 -1
- package/dist/chunk-FU2Y2M3M.js +0 -5
- package/dist/chunk-JBSYWYIP.js +0 -2
- package/dist/chunk-KVWHPGOA.js +0 -415
- package/dist/chunk-LH4VO6EV.js +0 -63
- package/dist/chunk-PRNHS74J.js +0 -847
- package/dist/chunk-RXF32AET.js +0 -396
- package/dist/chunk-SVA22NZQ.js +0 -607
- package/dist/chunk-YPE4BWWD.js +0 -3
- package/dist/error-handler-CRWXGODM.js +0 -1
- package/dist/http-proxy-node16-TTURN6MD.js +0 -38
- package/dist/lib-3WHF5XD3.js +0 -1
- package/dist/local-7MUCLBBI.js +0 -1
- package/dist/node-package-manager-GFIGZZ24.js +0 -1
- package/dist/npa-OKDXXRCU.js +0 -1
- package/dist/ui-AOFJCTTO.js +0 -1
- package/dist/workerd-VBG5LYNX.js +0 -18
- /package/dist/{chunk-KADPE3PY.js → chunk-7MUKLZOL.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as a}from"./chunk-VPRTJUIN.js";a();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Qb as m}from"./chunk-GFEAKSGV.js";import{g as p}from"./chunk-VPRTJUIN.js";p();import{spawn as h}from"child_process";function g(e=process.pid,i="SIGTERM",r=!0,s){k(e,i,r,s??(n=>{n&&m(`Failed to kill process ${e}: ${n}`)}))}function k(e,i,r,s){let t=typeof e=="number"?e.toString():e;if(!/^\d+$/.test(t))if(s){s(new Error("pid must be a number"));return}else throw new Error("pid must be a number");let n={};n[t]=[];let o=new Set;switch(o.add(t),process.platform){case"win32":{h("taskkill",["/pid",t,"/T","/F"]).on("close",u=>{s&&(u===0?s():s(new Error(`taskkill exited with code ${u}`)))});break}case"darwin":l(t,n,o,function(f){return h("pgrep",["-lfP",f])},function(){w(n,i,t,r,s)});break;default:l(t,n,o,function(f){return h("ps",["-o","pid command","--no-headers","--ppid",f])},function(){w(n,i,t,r,s)});break}}function w(e,i,r,s,t){let n=new Set;try{Object.keys(e).forEach(function(o){e[o].forEach(function(f){n.has(f)||(E(f,i),n.add(f))}),o===r&&s&&!n.has(o)&&(E(o,i),n.add(o))})}catch(o){if(t){t(o);return}else throw o}t&&t()}function E(e,i){try{process.kill(parseInt(e,10),i)}catch(r){if(r.code!=="ESRCH")throw r}}function l(e,i,r,s,t){let n=s(e),o="";n.stdout?.on("data",function(u){let a=u.toString("ascii");o+=a});let f=u=>{if(r.delete(e),u!==0){if(r.size===0){t();return}return}o.trim().split(`
|
|
2
|
+
`).forEach(function(a){let d=a.match(/^(\d+)\s(.*)$/);if(d){let c=d[1],$=d[2];i[e].push(c),i[c]=[],m(`Killing process ${c}: ${$}`),r.add(c),l(c,i,r,s,t)}})};n.on("close",f)}export{g as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as N,g}from"./chunk-VPRTJUIN.js";var B=N((V,L)=>{g();function d(e){return Array.isArray(e)?e:[e]}var a="",R=" ",u="\\",v=/^\s+$/,G=/(?:[^\\]|^)\\$/,I=/^\\!/,O=/^\\#/,T=/\r?\n/g,x=/^\.*\/|^\.+$/,l="/",C="node-ignore";typeof Symbol<"u"&&(C=Symbol.for("node-ignore"));var A=C,y=(e,t,s)=>Object.defineProperty(e,t,{value:s}),X=/([0-z])-([0-z])/g,P=()=>!1,b=e=>e.replace(X,(t,s,r)=>s.charCodeAt(0)<=r.charCodeAt(0)?t:a),m=e=>{let{length:t}=e;return e.slice(0,t-t%2)},w=[[/^\uFEFF/,()=>a],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,s)=>t+(s.indexOf("\\")===0?R:a)],[/(\\+?)\s/g,(e,t)=>{let{length:s}=t;return t.slice(0,s-s%2)+R}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,s)=>t+6<s.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,s)=>{let r=s.replace(/\\\*/g,"[^\\/]*");return t+r}],[/\\\\\\(?=[$.|*+(){^])/g,()=>u],[/\\\\/g,()=>u],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,s,r,n)=>t===u?`\\[${s}${m(r)}${n}`:n==="]"&&r.length%2===0?`[${b(s)}${r}]`:"[]"],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(e,t)=>`${t?`${t}[^/]+`:"[^/]*"}(?=$|\\/$)`]],$=Object.create(null),F=(e,t)=>{let s=$[e];return s||(s=w.reduce((r,[n,i])=>r.replace(n,i.bind(e)),e),$[e]=s),t?new RegExp(s,"i"):new RegExp(s)},f=e=>typeof e=="string",D=e=>e&&f(e)&&!v.test(e)&&!G.test(e)&&e.indexOf("#")!==0,H=e=>e.split(T),E=class{constructor(t,s,r,n){this.origin=t,this.pattern=s,this.negative=r,this.regex=n}},k=(e,t)=>{let s=e,r=!1;e.indexOf("!")===0&&(r=!0,e=e.substr(1)),e=e.replace(I,"!").replace(O,"#");let n=F(e,t);return new E(s,e,r,n)},p=(e,t)=>{throw new t(e)},o=(e,t,s)=>f(e)?e?o.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),S=e=>x.test(e);o.isNotRelative=S;o.convert=e=>e;var h=class{constructor({ignorecase:t=!0,ignoreCase:s=t,allowRelativePaths:r=!1}={}){y(this,A,!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[A]){this._rules=this._rules.concat(t._rules),this._added=!0;return}if(D(t)){let s=k(t,this._ignoreCase);this._added=!0,this._rules.push(s)}}add(t){return this._added=!1,d(f(t)?H(t):t).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(t){return this.add(t)}_testOne(t,s){let r=!1,n=!1;return this._rules.forEach(i=>{let{negative:c}=i;if(n===c&&r!==n||c&&!r&&!n&&!s)return;i.regex.test(t)&&(r=!c,n=c)}),{ignored:r,unignored:n}}_test(t,s,r,n){let i=t&&o.convert(t);return o(i,t,this._allowRelativePaths?P:p),this._t(i,s,r,n)}_t(t,s,r,n){if(t in s)return s[t];if(n||(n=t.split(l)),n.pop(),!n.length)return s[t]=this._testOne(t,r);let i=this._t(n.join(l)+l,s,r,n);return s[t]=i.ignored?i:this._testOne(t,r)}ignores(t){return this._test(t,this._ignoreCache,!1).ignored}createFilter(){return t=>!this.ignores(t)}filter(t){return d(t).filter(this.createFilter())}test(t){return this._test(t,this._testCache,!0)}},_=e=>new h(e),z=e=>o(e&&o.convert(e),e,P);_.isPathValid=z;_.default=_;L.exports=_;if(typeof process<"u"&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform==="win32")){let e=s=>/^\\\\\?\\/.test(s)||/["<>|\u0000-\u001F]+/u.test(s)?s:s.replace(/\\/g,"/");o.convert=e;let t=/^[a-z]:\//i;o.isNotRelative=s=>t.test(s)||S(s)}});export{B as a};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import{b as mi}from"./chunk-OLZHWPZP.js";import{$ as Xn,A as Un,Aa as ci,B as b,Ba as di,C as U,Ca as ui,D as Bn,E as ye,F as er,G as qe,H as rt,I as Se,Ia as Io,J as Vn,Ja as fi,K as Ne,Ka as pr,L as xe,La as ze,M as Gn,Ma as at,N as tr,Na as It,O as pe,Oa as hr,P as Co,Pa as lt,Q as qn,Qa as gr,R as ot,Ra as pi,S as nt,Sa as hi,T as Wn,Ta as gi,U as rr,Ua as yr,V as Yn,Va as yi,W as zn,Wa as wi,X as Jn,Xa as vi,Y as Qn,Z as Kn,_ as We,a as me,aa as W,b as xt,ba as it,c as Rn,ca as Zn,d as De,da as ei,e as Ee,ea as or,f as Ge,fa as nr,g as An,ga as ti,h as Fn,ha as he,i as jn,ia as ri,j as ko,ja as oi,k as tt,ka as To,l as Pt,la as ni,m as je,ma as ii,n as Nn,na as si,o as Kt,oa as ir,p as Eo,pa as sr,q as Ct,qa as ar,r as So,ra as ai,s as Ln,sa as lr,t as Mn,ta as cr,u as xo,ua as li,v as Hn,va as dr,w as Po,wa as ur,x as Xt,xa as Ye,y as Zt,ya as st,z as Tt,za as fr}from"./chunk-HSK7YMRE.js";import{a as Pn}from"./chunk-3VZEETAV.js";import{a as bi}from"./chunk-DJONKJSZ.js";import{b as Cn,c as Tn,d as Qt,g as In,i as Dn,j as On,k as _n}from"./chunk-P7R7FBY2.js";import{a as rl,b as $n,d as ol}from"./chunk-LX3ZOW52.js";import{a as wr}from"./chunk-WDC3KIZT.js";import{a as mr,b as Do,c as Oo}from"./chunk-ELYP4KFP.js";import{c as xn}from"./chunk-QSTEVZFQ.js";import{Aa as Za,Ba as bn,Ca as el,Da as tl,fa as fe,m as mn,n as ie}from"./chunk-B2EHO7ZC.js";import{B as vn,l as hn,m as be,p as et,s as gn,u as yn,x as wn}from"./chunk-LAZJ47DZ.js";import{b as D}from"./chunk-YZDDTYTU.js";import{b as fn}from"./chunk-JUVAGMIH.js";import{A as Ie,D as ee,O as kn,a as Yt,u as V,v as N,w as q,y as $e,z as Re}from"./chunk-BDVAE5MS.js";import{d as E,g as zt}from"./chunk-JPGO36XP.js";import{a as nl}from"./chunk-HZA6IAA4.js";import{b as Xa}from"./chunk-QYR5VPQA.js";import{$ as ln,Ca as wo,Cb as pn,Ea as qt,Ga as dn,Gb as ke,Ha as un,Ib as Y,Ka as vo,Kb as Ae,Nb as $,Oa as bo,Ob as En,Pb as Fe,Qb as Sn,Rb as B,Sb as se,Ta as G,V as Vt,Wa as St,ma as de,na as cn,pa as Gt,qa as yo,qb as Wt,tb as L,ua as J,wa as Et,ya as ve}from"./chunk-GFEAKSGV.js";import{t as Jt}from"./chunk-YC6G4MHD.js";import{d as x,f as C,g as ne,i as go,j as Ze,k as sn,q as an}from"./chunk-IU2ZQ6TE.js";import{a as we,c as ce,e as Q,g as l}from"./chunk-VPRTJUIN.js";var Ls=ce((Mw,Ns)=>{l();Ns.exports=Fc;function Fc(e){var t=e._readableState;return t?t.objectMode||typeof e._duplexState=="number"?e.read():e.read(jc(t)):null}function jc(e){if(e.buffer.length){var t=e.bufferIndex||0;if(e.buffer.head)return e.buffer.head.data.length;if(e.buffer.length-t>0&&e.buffer[t])return e.buffer[t].length}return e.length}});var Vo=ce((Uw,Bs)=>{l();var Wr=$n(),Ms=bn(),Nc=xn(),Lc=Ls(),Hs=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),Bo=function(e,t){e._corked?e.once("uncork",t):t()},Mc=function(e,t){e._autoDestroy&&e.destroy(t)},Us=function(e,t){return function(r){r?Mc(e,r.message==="premature close"?null:r):t&&!e._ended&&e.end()}},Hc=function(e,t){if(!e||e._writableState&&e._writableState.finished)return t();if(e._writableState)return e.end(t);e.end(),t()},Uc=function(e){return new Wr.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},K=function(e,t,r){if(!(this instanceof K))return new K(e,t,r);Wr.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||r.autoDestroy!==!1,this._forwardDestroy=!r||r.destroy!==!1,this._forwardEnd=!r||r.end!==!1,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};Nc(K,Wr.Duplex);K.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new K(e,t,r)};K.prototype.cork=function(){++this._corked===1&&this.emit("cork")};K.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit("uncork")};K.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.end();return}var t=this,r=Ms(e,{writable:!0,readable:!1},Us(this,this._forwardEnd)),o=function(){var i=t._ondrain;t._ondrain=null,i&&i()},n=function(){t._writable.removeListener("drain",o),r()};this._unwrite&&process.nextTick(o),this._writable=e,this._writable.on("drain",o),this._unwrite=n,this.uncork()};K.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.push(null),this.resume();return}var t=this,r=Ms(e,{writable:!1,readable:!0},Us(this)),o=function(){t._forward()},n=function(){t.push(null)},i=function(){t._readable2.removeListener("readable",o),t._readable2.removeListener("end",n),r()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:Uc(e),this._readable2.on("readable",o),this._readable2.on("end",n),this._unread=i,this._forward()};K.prototype._read=function(){this._drained=!0,this._forward()};K.prototype._forward=function(){if(!(this._forwarding||!this._readable2||!this._drained)){this._forwarding=!0;for(var e;this._drained&&(e=Lc(this._readable2))!==null;)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}};K.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;process.nextTick(function(){t._destroy(e)})}};K.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")};K.prototype._write=function(e,t,r){if(this.destroyed)return r();if(this._corked)return Bo(this,this._write.bind(this,e,t,r));if(e===Hs)return this._finish(r);if(!this._writable)return r();this._writable.write(e)===!1?this._ondrain=r:r()};K.prototype._finish=function(e){var t=this;this.emit("preend"),Bo(this,function(){Hc(t._forwardEnd&&t._writable,function(){t._writableState.prefinished===!1&&(t._writableState.prefinished=!0),t.emit("prefinish"),Bo(t,e)})})};K.prototype.end=function(e,t,r){return typeof e=="function"?this.end(null,null,e):typeof t=="function"?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(Hs),Wr.Writable.prototype.end.call(this,r))};Bs.exports=K});var Gs=ce((Vw,Vs)=>{l();Vs.exports=Vc;var Bc=Object.prototype.hasOwnProperty;function Vc(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var o in r)Bc.call(r,o)&&(e[o]=r[o])}return e}});var qo=ce((qw,Yr)=>{l();var qs=$n().Transform,Ws=we("util").inherits,Ys=Gs();function ht(e){qs.call(this,e),this._destroyed=!1}Ws(ht,qs);ht.prototype.destroy=function(e){if(!this._destroyed){this._destroyed=!0;var t=this;process.nextTick(function(){e&&t.emit("error",e),t.emit("close")})}};function Gc(e,t,r){r(null,e)}function Go(e){return function(t,r,o){return typeof t=="function"&&(o=r,r=t,t={}),typeof r!="function"&&(r=Gc),typeof o!="function"&&(o=null),e(t,r,o)}}Yr.exports=Go(function(e,t,r){var o=new ht(e);return o._transform=t,r&&(o._flush=r),o});Yr.exports.ctor=Go(function(e,t,r){function o(n){if(!(this instanceof o))return new o(n);this.options=Ys(e,n),ht.call(this,this.options)}return Ws(o,ht),o.prototype._transform=t,r&&(o.prototype._flush=r),o});Yr.exports.obj=Go(function(e,t,r){var o=new ht(Ys({objectMode:!0,highWaterMark:16},e));return o._transform=t,r&&(o._flush=r),o})});var Qs=ce((Yw,Js)=>{l();var qc=Vo(),Wc=qo(),Yc=Xa(),zc=function(e){return!Buffer.isBuffer(e)&&typeof e!="string"},zs=function(e,t){if(typeof e=="number"&&(e={maxBuffer:e}),typeof e=="function")return zs(null,e);e||(e={});var r=typeof e.maxBuffer=="number"?e.maxBuffer:65535,o=e.strict,n=e.newline!==!1,i=[],s=0,a=qc.obj(),c=Wc.obj({highWaterMark:1},function(m,f,p){if(zc(m))return d(m,null,p);if(Buffer.isBuffer(m)||(m=Yc(m)),n){var g=Array.prototype.indexOf.call(m,10);if(g>0&&m[g-1]===13&&g--,g>-1)return i.push(m.slice(0,g)),d(Buffer.concat(i),m.slice(g),p)}if(i.push(m),s+=m.length,s<r)return p();if(o)return p(new Error("No newline found"));d(Buffer.concat(i),null,p)}),u=function(){if(o)return a.destroy(new Error("No newline found"));a.cork(),d(Buffer.concat(i),null,function(m){if(m)return a.destroy(m);a.uncork()})},d=function(m,f,p){a.removeListener("preend",u),t(m,function(g,w){if(g)return p(g);a.setWritable(w),a.setReadable(w),m&&w.write(m),f&&w.write(f),f=i=c=null,p()})};return a.on("preend",u),a.setWritable(c),a};Js.exports=zs});var Zs=ce((Jw,Xs)=>{l();var Jc=Za(),Qc=bn(),Wo=we("fs"),Mt=function(){},Kc=/^v?\.0/.test(process.version),zr=function(e){return typeof e=="function"},Xc=function(e){return!Kc||!Wo?!1:(e instanceof(Wo.ReadStream||Mt)||e instanceof(Wo.WriteStream||Mt))&&zr(e.close)},Zc=function(e){return e.setHeader&&zr(e.abort)},ed=function(e,t,r,o){o=Jc(o);var n=!1;e.on("close",function(){n=!0}),Qc(e,{readable:t,writable:r},function(s){if(s)return o(s);n=!0,o()});var i=!1;return function(s){if(!n&&!i){if(i=!0,Xc(e))return e.close(Mt);if(Zc(e))return e.abort();if(zr(e.destroy))return e.destroy();o(s||new Error("stream was destroyed"))}}},Ks=function(e){e()},td=function(e,t){return e.pipe(t)},rd=function(){var e=Array.prototype.slice.call(arguments),t=zr(e[e.length-1]||Mt)&&e.pop()||Mt;if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new Error("pump requires two streams per minimum");var r,o=e.map(function(n,i){var s=i<e.length-1,a=i>0;return ed(n,s,a,function(c){r||(r=c),c&&o.forEach(Ks),!s&&(o.forEach(Ks),t(r))})});e.reduce(td)};Xs.exports=rd});var ra=ce((Kw,Jr)=>{l();var od=Zs(),nd=xn(),ea=Vo(),ta=function(e){return e.length?Array.isArray(e[0])?e[0]:Array.prototype.slice.call(e):[]},Yo=function(e){var t=function(){var r=ta(arguments);if(!(this instanceof t))return new t(r);ea.call(this,null,null,e),r.length&&this.setPipeline(r)};return nd(t,ea),t.prototype.setPipeline=function(){var r=ta(arguments),o=this,n=!1,i=r[0],s=r[r.length-1];s=s.readable?s:null,i=i.writable?i:null;var a=function(){r[0].emit("error",new Error("stream was destroyed"))};if(this.on("close",a),this.on("prefinish",function(){n||o.cork()}),od(r,function(c){if(o.removeListener("close",a),c)return o.destroy(c.message==="premature close"?null:c);n=!0,o._autoDestroy===!1&&(o._autoDestroy=!0),o.uncork()}),this.destroyed)return a();this.setWritable(i),this.setReadable(s)},t};Jr.exports=Yo({autoDestroy:!1,destroy:!1});Jr.exports.obj=Yo({autoDestroy:!1,destroy:!1,objectMode:!0,highWaterMark:16});Jr.exports.ctor=Yo});var na=ce((Zw,oa)=>{"use strict";l();oa.exports=function(e){return!e||e.length<3?!1:e[0]===31&&e[1]===139&&e[2]===8}});var sa=ce((tv,ia)=>{"use strict";l();ia.exports=function(e){return!e||e.length<2?!1:e[0]===120&&(e[1]===1||e[1]===156||e[1]===218)}});var da=ce((ov,ca)=>{l();var aa=we("zlib"),id=Qs(),sd=qo(),la=ra(),ad=na(),ld=sa(),cd=function(e){return ad(e)?1:ld(e)?2:0},zo=function(e){return e===void 0&&(e=3),id({newline:!1,maxBuffer:10},function(t,r){if(e<0)return r(new Error("Maximum recursion reached"));switch(cd(t)){case 1:r(null,la(aa.createGunzip(),zo(e-1)));break;case 2:r(null,la(aa.createInflate(),zo(e-1)));break;default:r(null,sd())}})};ca.exports=zo});var ya=ce((iv,ga)=>{"use strict";l();var ge=we("fs"),Ke=we("path"),dd=ge.lchown?"lchown":"chown",ud=ge.lchownSync?"lchownSync":"chownSync",fa=ge.lchown&&!process.version.match(/v1[1-9]+\./)&&!process.version.match(/v10\.[6-9]/),ua=(e,t,r)=>{try{return ge[ud](e,t,r)}catch(o){if(o.code!=="ENOENT")throw o}},fd=(e,t,r)=>{try{return ge.chownSync(e,t,r)}catch(o){if(o.code!=="ENOENT")throw o}},md=fa?(e,t,r,o)=>n=>{!n||n.code!=="EISDIR"?o(n):ge.chown(e,t,r,o)}:(e,t,r,o)=>o,Jo=fa?(e,t,r)=>{try{return ua(e,t,r)}catch(o){if(o.code!=="EISDIR")throw o;fd(e,t,r)}}:(e,t,r)=>ua(e,t,r),pd=process.version,ma=(e,t,r)=>ge.readdir(e,t,r),hd=(e,t)=>ge.readdirSync(e,t);/^v4\./.test(pd)&&(ma=(e,t,r)=>ge.readdir(e,r));var Qr=(e,t,r,o)=>{ge[dd](e,t,r,md(e,t,r,n=>{o(n&&n.code!=="ENOENT"?n:null)}))},pa=(e,t,r,o,n)=>{if(typeof t=="string")return ge.lstat(Ke.resolve(e,t),(i,s)=>{if(i)return n(i.code!=="ENOENT"?i:null);s.name=t,pa(e,s,r,o,n)});if(t.isDirectory())Qo(Ke.resolve(e,t.name),r,o,i=>{if(i)return n(i);let s=Ke.resolve(e,t.name);Qr(s,r,o,n)});else{let i=Ke.resolve(e,t.name);Qr(i,r,o,n)}},Qo=(e,t,r,o)=>{ma(e,{withFileTypes:!0},(n,i)=>{if(n){if(n.code==="ENOENT")return o();if(n.code!=="ENOTDIR"&&n.code!=="ENOTSUP")return o(n)}if(n||!i.length)return Qr(e,t,r,o);let s=i.length,a=null,c=u=>{if(!a){if(u)return o(a=u);if(--s===0)return Qr(e,t,r,o)}};i.forEach(u=>pa(e,u,t,r,c))})},gd=(e,t,r,o)=>{if(typeof t=="string")try{let n=ge.lstatSync(Ke.resolve(e,t));n.name=t,t=n}catch(n){if(n.code==="ENOENT")return;throw n}t.isDirectory()&&ha(Ke.resolve(e,t.name),r,o),Jo(Ke.resolve(e,t.name),r,o)},ha=(e,t,r)=>{let o;try{o=hd(e,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return;if(n.code==="ENOTDIR"||n.code==="ENOTSUP")return Jo(e,t,r);throw n}return o&&o.length&&o.forEach(n=>gd(e,n,t,r)),Jo(e,t,r)};ga.exports=Qo;Qo.sync=ha});var ka=ce((av,ba)=>{l();var Kr=we("path"),wa=we("fs"),va=parseInt("0777",8);ba.exports=gt.mkdirp=gt.mkdirP=gt;function gt(e,t,r,o){typeof t=="function"?(r=t,t={}):(!t||typeof t!="object")&&(t={mode:t});var n=t.mode,i=t.fs||wa;n===void 0&&(n=va&~process.umask()),o||(o=null);var s=r||function(){};e=Kr.resolve(e),i.mkdir(e,n,function(a){if(!a)return o=o||e,s(null,o);a.code==="ENOENT"?gt(Kr.dirname(e),t,function(c,u){c?s(c,u):gt(e,t,s,u)}):i.stat(e,function(c,u){c||!u.isDirectory()?s(a,o):s(null,o)})})}gt.sync=function e(t,r,o){(!r||typeof r!="object")&&(r={mode:r});var n=r.mode,i=r.fs||wa;n===void 0&&(n=va&~process.umask()),o||(o=null),t=Kr.resolve(t);try{i.mkdirSync(t,n),o=o||t}catch(a){switch(a.code){case"ENOENT":o=e(Kr.dirname(t),r,o),e(t,r,o);break;default:var s;try{s=i.statSync(t)}catch{throw a}if(!s.isDirectory())throw a;break}}return o}});var Oa=ce(Zo=>{l();var yd=ya(),xa=ol(),Pa=el(),wd=ka(),Ca=we("fs"),X=we("path"),vd=we("os"),Ht=vd.platform()==="win32",Ut=function(){},Xo=function(e){return e},Ko=Ht?function(e){return e.replace(/\\/g,"/").replace(/[:?<>|]/g,"_")}:Xo,bd=function(e,t,r,o,n,i){var s=n||["."];return function(c){if(!s.length)return c();var u=s.shift(),d=X.join(r,u);t.call(e,d,function(m,f){if(m)return c(m);if(!f.isDirectory())return c(null,u,f);e.readdir(d,function(p,g){if(p)return c(p);i&&g.sort();for(var w=0;w<g.length;w++)o(X.join(r,u,g[w]))||s.push(X.join(u,g[w]));c(null,u,f)})})}},Ta=function(e,t){return function(r){r.name=r.name.split("/").slice(t).join("/");var o=r.linkname;return o&&(r.type==="link"||X.isAbsolute(o))&&(r.linkname=o.split("/").slice(t).join("/")),e(r)}};Zo.pack=function(e,t){e||(e="."),t||(t={});var r=t.fs||Ca,o=t.ignore||t.filter||Ut,n=t.map||Ut,i=t.mapStream||Xo,s=bd(r,t.dereference?r.stat:r.lstat,e,o,t.entries,t.sort),a=t.strict!==!1,c=typeof t.umask=="number"?~t.umask:~Ia(),u=typeof t.dmode=="number"?t.dmode:0,d=typeof t.fmode=="number"?t.fmode:0,m=t.pack||xa.pack(),f=t.finish||Ut;t.strip&&(n=Ta(n,t.strip)),t.readable&&(u|=parseInt(555,8),d|=parseInt(444,8)),t.writable&&(u|=parseInt(333,8),d|=parseInt(222,8));var p=function(k,y){r.readlink(X.join(e,k),function(v,h){if(v)return m.destroy(v);y.linkname=Ko(h),m.entry(y,w)})},g=function(k,y,v){if(k)return m.destroy(k);if(!y)return t.finalize!==!1&&m.finalize(),f(m);if(v.isSocket())return w();var h={name:Ko(y),mode:(v.mode|(v.isDirectory()?u:d))&c,mtime:v.mtime,size:v.size,type:"file",uid:v.uid,gid:v.gid};if(v.isDirectory())return h.size=0,h.type="directory",h=n(h)||h,m.entry(h,w);if(v.isSymbolicLink())return h.size=0,h.type="symlink",h=n(h)||h,p(y,h);if(h=n(h)||h,!v.isFile())return a?m.destroy(new Error("unsupported type for "+y)):w();var S=m.entry(h,w);if(S){var P=i(r.createReadStream(X.join(e,y),{start:0,end:h.size>0?h.size-1:h.size}),h);P.on("error",function(_){S.destroy(_)}),Pa(P,S)}},w=function(k){if(k)return m.destroy(k);s(g)};return w(),m};var kd=function(e){return e.length?e[e.length-1]:null},Ed=function(){return process.getuid?process.getuid():-1},Ia=function(){return process.umask?process.umask():0};Zo.extract=function(e,t){e||(e="."),t||(t={});var r=t.fs||Ca,o=t.ignore||t.filter||Ut,n=t.map||Ut,i=t.mapStream||Xo,s=t.chown!==!1&&!Ht&&Ed()===0,a=t.extract||xa.extract(),c=[],u=new Date,d=typeof t.umask=="number"?~t.umask:~Ia(),m=typeof t.dmode=="number"?t.dmode:0,f=typeof t.fmode=="number"?t.fmode:0,p=t.strict!==!1;t.strip&&(n=Ta(n,t.strip)),t.readable&&(m|=parseInt(555,8),f|=parseInt(444,8)),t.writable&&(m|=parseInt(333,8),f|=parseInt(222,8));var g=function(y,v){for(var h;(h=kd(c))&&y.slice(0,h[0].length)!==h[0];)c.pop();if(!h)return v();r.utimes(h[0],u,h[1],v)},w=function(y,v,h){if(t.utimes===!1)return h();if(v.type==="directory")return r.utimes(y,u,v.mtime,h);if(v.type==="symlink")return g(y,h);r.utimes(y,u,v.mtime,function(S){if(S)return h(S);g(y,h)})},k=function(y,v,h){var S=v.type==="symlink",P=S?r.lchmod:r.chmod,_=S?r.lchown:r.chown;if(!P)return h();var I=(v.mode|(v.type==="directory"?m:f))&d;_&&s?_.call(r,y,v.uid,v.gid,F):F(null);function F(R){if(R)return h(R);if(!P)return h();P.call(r,y,I,h)}};return a.on("entry",function(y,v,h){y=n(y)||y,y.name=Ko(y.name);var S=X.join(e,X.join("/",y.name));if(o(S,y))return v.resume(),h();var P=function(T){if(T)return h(T);w(S,y,function(j){if(j)return h(j);if(Ht)return h();k(S,y,h)})},_=function(){if(Ht)return h();r.unlink(S,function(){var T=X.resolve(X.dirname(S),y.linkname);if(!Sa(T,e))return h(new Error(S+" is not a valid symlink"));r.symlink(y.linkname,S,P)})},I=function(){if(Ht)return h();r.unlink(S,function(){var T=X.join(e,X.join("/",y.linkname));r.realpath(T,function(j,H){if(j||!Sa(H,e))return h(new Error(S+" is not a valid hardlink"));r.link(H,S,function(A){if(A&&A.code==="EPERM"&&t.hardlinkAsFilesFallback)return v=r.createReadStream(T),F();P(A)})})})},F=function(){var T=r.createWriteStream(S),j=i(v,y);T.on("error",function(H){j.destroy(H)}),Pa(j,T,function(H){if(H)return h(H);T.on("close",P)})};if(y.type==="directory")return c.push([S,y.mtime]),Ea(S,{fs:r,own:s,uid:y.uid,gid:y.gid},P);var R=X.dirname(S);Da(r,R,X.join(e,"."),function(T,j){if(T)return h(T);if(!j)return h(new Error(R+" is not a valid path"));Ea(R,{fs:r,own:s,uid:y.uid,gid:y.gid},function(H){if(H)return h(H);switch(y.type){case"file":return F();case"link":return I();case"symlink":return _()}if(p)return h(new Error("unsupported type for "+S+" ("+y.type+")"));v.resume(),h()})})}),t.finish&&a.on("finish",t.finish),a};function Da(e,t,r,o){if(t===r)return o(null,!0);e.lstat(t,function(n,i){if(n&&n.code!=="ENOENT")return o(n);if(n||i.isDirectory())return Da(e,X.join(t,".."),r,o);o(null,!1)})}function Ea(e,t,r){wd(e,{fs:t.fs},function(o,n){!o&&n&&t.own?yd(n,t.uid,t.gid,r):r(o)})}function Sa(e,t){return t=X.resolve(t),t===e||e.startsWith(t+X.sep)}});l();l();var xr=Q(me(),1);l();l();var vr=[{name:"npm",lockfile:"package-lock.json",alternativeLockfiles:["npm-shrinkwrap.json"],installCommand:"npm ci"},{name:"yarn",lockfile:"yarn.lock",installCommand:"yarn install --frozen-lockfile"},{name:"pnpm",lockfile:"pnpm-lock.yaml",installCommand:"pnpm install --frozen-lockfile"},{name:"bun",lockfile:"bun.lockb",alternativeLockfiles:["bun.lock"],installCommand:"bun install --frozen-lockfile"}];function il(e){let t="No lockfile found",r="If you don\u2019t commit a lockfile, then your app might install the wrong package versions when deploying. To avoid versioning issues, generate a new lockfile and commit it to your repository.",o=[["Generate a lockfile. Run",{command:"npm|yarn|pnpm install"}],"Commit the new file to your repository"];if(e)throw new E(t,r,o);q({headline:t,body:r,nextSteps:o})}function sl(e,t){let r=e.map(({packageManager:s,foundLockfile:a})=>`${a} (created by ${s.name})`),o="Multiple lockfiles found",n=[`Your project contains more than one lockfile. This can cause version conflicts when installing and deploying your app. The following lockfiles were detected:
|
|
2
|
+
`,{list:{items:r}}],i=["Delete any unneeded lockfiles","Commit the change to your repository"];if(t)throw new E(o,n,i);q({headline:o,body:n,nextSteps:i})}function al(e){let t="Lockfile ignored by Git",r="Your project\u2019s lockfile isn\u2019t being tracked by Git. If you don\u2019t commit a lockfile, then your app might install the wrong package versions when deploying.",o=[`In your project\u2019s .gitignore file, delete any references to ${e}`,"Commit the change to your repository"];q({headline:t,body:r,nextSteps:o})}async function ki(e,t=!1){if(De&&!process.env.SHOPIFY_UNIT_TEST)return;let r=[];for(let i of vr){let s=[i.lockfile,...i.alternativeLockfiles||[]];for(let a of s)if(await G(C(e,a))){r.push({packageManager:i,foundLockfile:a});break}}if(r.length===0)return il(t);if(r.length>1)return sl(r,t);let o=r[0].foundLockfile;(await Cn(e,[o]).catch(()=>[])).length>0&&al(o)}l();var ll=["^cdn/","^_t/"];function br(e){let t=new Set;return Object.values(e.routes).filter(r=>ll.some(o=>new RegExp(o).test(r.path??""))).forEach(r=>{r.path&&t.add(r.path)}),[...t]}var cl=["","cart","products/:productHandle","collections","collections/:collectionHandle","sitemap.xml","robots.txt","pages/:pageHandle","policies/:policyHandle","search","account","account/login","account/orders/:orderId","account/authorize"];function kr(e,t=cl){let r=Object.values(e.routes),o=new Set(t);for(let n of t)for(let i of r)if(!n&&!i.path)o.delete(n);else if(n&&i.path){let s={path:i.path,parentId:i.parentId};for(;s.parentId&&s.parentId!=="root";){let u=r.find(d=>d.id===s.parentId);if(!u)break;s.path=u.path==null?s.path:`${u.path}/${s.path}`,s.parentId=u.parentId}let a=":?[^\\/\\?]+\\?",c=`^(${a}\\/)?`+n.replaceAll(".","\\.").replace(/\//g,`\\/(${a}\\/)?`).replace(/:[^/)?]+/g,"(:[^\\/]+|\\*)")+`(\\/${a})?$`;new RegExp(c).test(s.path)&&o.delete(n)}return[...o]}var Le=100;function Ei(e){e.length?q({headline:"Standard Shopify routes missing",body:`Your Hydrogen project is missing ${e.length} standard Shopify route${e.length>1?"s":""}.
|
|
3
|
+
Including these routes improves compatibility with Shopify\u2019s platform:
|
|
4
|
+
|
|
5
|
+
`+e.slice(0,Le-(e.length<=Le?0:1)).map(t=>`\u2022 /${t}`).join(`
|
|
6
|
+
`)+(e.length>Le?`
|
|
7
|
+
\u2022 ...and ${e.length-Le+1} more`:"")}):N({headline:"All standard Shopify routes present"})}function Er(e){e.length&&q({headline:"Reserved routes present",body:`Your Hydrogen project is using ${e.length} reserved route${e.length>1?"s":""}.
|
|
8
|
+
These routes are reserved by Shopify and may cause issues with your storefront:
|
|
9
|
+
|
|
10
|
+
`+e.slice(0,Le-(e.length<=Le?0:1)).map(t=>`\u2022 /${t}`).join(`
|
|
11
|
+
`)+(e.length>Le?`
|
|
12
|
+
\u2022 ...and ${e.length-Le+1} more`:"")})}l();l();var Me="metafile.server.json",Oe="server-bundle-analyzer.html";async function Si(){return de(await Ge("bundle","analyzer.html"))}function xi(e,t){return e.replace("globalThis.METAFILE = '';",`globalThis.METAFILE = '${Buffer.from(t,"utf-8").toString("base64")}';`)}async function Pi(e){try{return` \u2502
|
|
13
|
+
`+(await(await import("esbuild")).analyzeMetafile(await de(x(e,Me)),{color:!0})).split(`
|
|
14
|
+
`).filter(o=>!o.match(/(.*)(node_modules\/|server-assets-manifest:|server-entry-module:)(react-dom|@remix-run|@shopify\/hydrogen|react-router|react-router-dom)\/(.*)/g)).slice(2,12).join(`
|
|
15
|
+
`).replace(/dist\/worker\/_assets\/.*$/ms,`
|
|
16
|
+
`).replace(/\n/g,`
|
|
17
|
+
`).replace(/(\.\.\/)+node_modules\//g,o=>L.dim(o))}catch(t){console.warn("Could not generate bundle analysis summary:",t.message)}}function Ti(e){let t;return{name:"hydrogen:bundle-analyzer",configResolved(r){t=r},async generateBundle(r,o){if(!t.build.ssr)return;let{root:n}=t,i=Object.values(o).find(g=>g.type==="chunk");if(!i||i.type!=="chunk"||!i.facadeModuleId||!r.dir)return;let s=await Si().catch(()=>null);if(!s){console.warn("Bundle analyzer template not found");return}let a=new Set(Object.keys(i.modules)),c=[];for(let g of a){if(_o(g)||$o(g))continue;let w=this.getModuleInfo(g);if(w?.id){c.push(w);for(let k of[...w.importedIds,...w.dynamicallyImportedIds])!_o(k)&&!$o(k)&&a.add(k)}}let u=new Map,d=new Map,m=await Promise.all(c.map(async g=>{let w=ne(n,g.id),k=i.modules[g.id],y=k?.originalLength??g.code?.length??0,v=k?.renderedLength??0;if(e?.minify&&k?.code){let F=await e.minify(k.code,g.id).catch(()=>null);F&&(v=F.length)}d.set(w,v);let h=F=>this.resolve(F,g.id),S=!g.code||/(^\s*export\s+[\w\{]|^\s*import\s+[\w\{'"]|\bimport\()|\bcreateRequire\(/ms.test(g.code)||!/((^|\b)exports\b|\brequire\()/.test(g.code),P=Ci(g.importedIds,"import-statement",n,h,g.code),_=Ci(g.dynamicallyImportedIds,"dynamic-import",n,h,g.code),I=(await Promise.all([...P,..._])).reduce((F,{importedId:R,...T})=>(_o(R)?S=!1:$o(R)||F.push(T),F),[]);u.set(w,{bytes:y,format:S?"esm":"cjs",imports:I})})).then(()=>null).catch(g=>g);if(m){console.warn("Bundle analyzer failed to analyze the bundle:",m);return}let f=Object.fromEntries(u.entries()),p={inputs:f,outputs:{[ne(n,x(r.dir,i.fileName))]:{imports:i.imports,exports:i.exports,entryPoint:ne(n,i.facadeModuleId),bytes:i.code.length??0,inputs:Object.entries(f).reduce((g,[w,k])=>(g[w]={bytesInOutput:d.get(w)??k.bytes??0},g),{})}}};o[Me]={type:"asset",fileName:Me,needsCodeReference:!1,source:JSON.stringify(p,null,2),names:[Me],originalFileNames:[Me],name:Me,originalFileName:Me},o[Oe]={type:"asset",fileName:Oe,needsCodeReference:!1,source:xi(s,JSON.stringify(p)),names:[Oe],originalFileNames:[Oe],name:Oe,originalFileName:Oe}}}}function _o(e){return/(commonjsHelpers\.js$|\?commonjs\-)/.test(e)}function $o(e){return e.endsWith("?transform-only")}async function dl(e,t,r){let o=t.matchAll(/import\s[^'"]*?['"]([^'"]+)['"]/g)??[];for(let[,n]of o)if(n&&(await r(n))?.id===e)return n;return e}function Ci(e,t,r,o,n){return e.map(async i=>({importedId:i,path:ne(r,i),kind:t,original:n?await dl(i,n,o):i}))}l();import{spawn as ul}from"node:child_process";import{fileURLToPath as Di}from"node:url";var fl=process.argv[1],ml=Di(import.meta.url),pl=fl===ml;pl&&Dt({rootDirectory:process.argv[2],appDirectory:process.argv[3],configFilePath:process.argv[4],watch:!0});function Oi(e,t){if(e.includes("AbortError: ")){let s=e.split("AbortError: ")[1]??"",a=s.split(`
|
|
18
|
+
`)[0],c=s.match(/tryMessage: '(.*)',$/m)?.[1];if(a)return{message:a,details:c}}let[r="",...o]=e.replaceAll("[FAILED]","").replace(/\s{2,}/g,`
|
|
19
|
+
`).replace(/\n,\n/,`
|
|
20
|
+
`).trim().split(`
|
|
21
|
+
`),n="[Codegen] "+r,i=o.join(`
|
|
22
|
+
`);if(t){let s=t.replaceAll("\\","/")+"/";i=i.replaceAll(s,"")}return{message:n,details:i}}function Sr({rootDirectory:e,appDirectory:t,configFilePath:r}){let o,n,i=process.argv.findIndex(a=>a==="hydrogen");i>=1?(o=process.argv[0],n=[...process.argv.slice(1,i+1),"codegen","--watch","--path",e],r&&n.push("--codegen-config-path",r)):(o="node",n=[Di(import.meta.url),e,t??C("app"),r??""]);let s=ul(o,n,{stdio:["inherit","ignore","pipe"]});return s.stderr.on("data",a=>{let c=typeof a=="string"?a:a?.toString?.("utf8")??"";if(!c)return;let{message:u,details:d}=Oi(c,e);/`punycode`/.test(u)||/\.body\[\d\]/.test(u)||/console\.time(End)?\(\)/.test(u)||/─ (warning|info|success) ───/.test(u)||(V({body:""}),q({headline:u,body:d}))}),s.on("close",a=>{a&&a>0&&q({headline:"Codegen process exited with code "+a,body:"There should be more logs above."})}),s}async function Dt(e){return await hl(e),gl(e).catch(t=>{if(t instanceof E)throw t;let{message:r,details:o}=Oi(t.message,e.rootDirectory);throw new E(r,o)})}async function hl(e){let{execSync:t,exec:r}=await import("child_process");try{t("npx react-router --version",{cwd:e.rootDirectory,stdio:"ignore"})}catch{V({body:"React Router not found, skipping typegen"});return}e.watch?r("npx react-router typegen --watch",{cwd:e.rootDirectory}):t("npx react-router typegen",{cwd:e.rootDirectory,stdio:"inherit"})}async function gl({watch:e,configFilePath:t,forceSfapiVersion:r,...o}){let{generate:n,loadCodegenConfig:i,CodegenContext:s}=await qe("@graphql-codegen/cli",o.rootDirectory).catch(()=>{throw new E("Could not load GraphQL Codegen CLI.","Please make sure you have `@graphql-codegen/cli` installed as a dev dependency.")}),{config:a}=await i({configFilePath:t??o.rootDirectory})||await yl(o,r);await wl(a,o);let c=new s({config:{...a,watch:e,silent:!e,cwd:o.rootDirectory},filepath:"not-used-but-must-be-set"});return c.cwd=o.rootDirectory,await n(c,!0),Object.entries(a.generates).reduce((u,[d,m])=>("documents"in m&&(u[d]=(Array.isArray(m.documents)?m.documents:[m.documents]).filter(f=>typeof f=="string")),u),{})}async function yl({rootDirectory:e,appDirectory:t=C(e,"app")},r){let{getSchema:o,preset:n,pluckConfig:i}=await qe("@shopify/hydrogen-codegen",e).catch(()=>{throw new E("Could not load Hydrogen Codegen.","Please make sure you have `@shopify/hydrogen-codegen` installed as a dev dependency.")}),{loadConfig:s}=await qe("graphql-config",e).catch(()=>{throw new E("Could not load GraphQL Config.","Please make sure you have `graphql-config` installed as a dev dependency.")}),a=await s({rootDir:e,throwOnEmpty:!1,throwOnMissing:!1,legacy:!1}).catch(()=>{}),c=o("storefront"),u=Ii(c,a),d=o("customer-account",{throwIfMissing:!1}),m=d?Ii(d,a):void 0,f="*!(*.d).{ts,tsx,js,jsx}",p=ne(e,t),g=k=>{let y=Ze(c),v=d&&Ze(d);return!!(k.endsWith(y)||v&&k.endsWith(v))},w=Object.values(a?.projects??{}).filter(k=>k.hasExtension("codegen")&&(typeof k.schema!="string"||!g(k.schema)));return{filepath:"virtual:codegen",config:{overwrite:!0,pluckConfig:i,generates:{...Ro(u)??{"storefrontapi.generated.d.ts":{preset:n,schema:c,documents:u?.documents??[f,x(p,"**",f)],...!!r&&{presetConfig:{importTypes:!1},schema:{[`https://hydrogen-preview.myshopify.com/api/${r.split(":")[0]}/graphql.json`]:{headers:{"content-type":"application/json","X-Shopify-Storefront-Access-Token":r.split(":")[1]??"3b580e70970c4528da70c98e097c2fa0"}}},config:{defaultScalarType:"string",scalars:{JSON:"unknown"}}}}},...Ro(m)??(m?.documents?{"customer-accountapi.generated.d.ts":{preset:n,schema:d,documents:m.documents}}:{}),...w.reduce((k,y)=>({...k,...Ro(y)}),{})}}}}function Ro(e){if(e?.extensions?.codegen?.generates)return Object.entries(e.extensions.codegen.generates).reduce((t,[r,o])=>(t[r]={...e,...Array.isArray(o)?o[0]:o},t),{})}function Ii(e,t){if(!t)return;let r=Ze(e);return Object.values(t.projects||{}).find(o=>typeof o.schema=="string"&&o.schema.endsWith(r))}async function wl(e,{rootDirectory:t}){let r=Symbol.for("name"),o=Object.values(e.generates).filter(n=>{let i=(Array.isArray(n)?n[0]:n)?.preset;if(typeof i=="object"&&r in i)return i[r]==="hydrogen"||i[r]==="@shopify/graphql-codegen"});for(let n of o){let i=Array.isArray(n)?n[0]:n;if(i){let s=await tt(t);i.hooks={beforeOneFileWrite:(a,c)=>Pt(c,s,a),...i.hooks}}}}l();function Ot(){let{env:e}=process;return e.CI==="false"?!1:!!(e.CI||e.CI_NAME||e.BUILD_NUMBER||e.TF_BUILD)}l();function _t(){let e={state:"pending"};return e.promise=new Promise((t,r)=>{e.resolve=o=>(e.state==="pending"&&(e.state="resolved"),t(o)),e.reject=o=>(e.state==="pending"&&(e.state="rejected"),r(o))}),e}l();function He(e){let t,r=process.exit;process.exit=async o=>{t??=e();let n=setTimeout(()=>r(o),5e3);return await t,clearTimeout(n),r(o)}}var Pr=class e extends D{static descriptionWithMarkdown="Builds a Hydrogen storefront for production. The client and app worker files are compiled to a `/dist` folder in your Hydrogen project directory.";static description="Builds a Hydrogen storefront for production.";static flags={...b.path,...b.entry,...b.sourcemap,...b.lockfileCheck,...b.disableRouteWarning,...b.codegen,watch:xr.Flags.boolean({description:"Watches for changes and rebuilds the project writing output to disk.",env:"SHOPIFY_HYDROGEN_FLAG_WATCH"}),"bundle-stats":xr.Flags.boolean({description:"Show a bundle size summary after building. Defaults to true, use `--no-bundle-stats` to disable.",allowNo:!0}),"force-client-sourcemap":xr.Flags.boolean({description:"Client sourcemapping is avoided by default because it makes backend code visible in the browser. Use this flag to force enabling it.",env:"SHOPIFY_HYDROGEN_FLAG_FORCE_CLIENT_SOURCEMAP"})};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd(),o={...U(t),useCodegen:t.codegen,directory:r};if(!await tr(r))throw new E(xe);let i=await Je(o);o.watch?i?.close&&He(async()=>{await i?.close()}):process.exit(0)}},vl=5;async function Je({entry:e,directory:t,useCodegen:r=!1,codegenConfigPath:o,sourcemap:n=!0,forceClientSourcemap:i,disableRouteWarning:s=!1,lockfileCheck:a=!0,assetPath:c,bundleStats:u=!Ot(),watch:d=!1,onServerBuildStart:m,onServerBuildFinish:f}){process.env.NODE_ENV||(process.env.NODE_ENV="production"),c=c??process.env.HYDROGEN_ASSET_BASE_URL??"/";let p=t??process.cwd();a&&await ki(p,Ot());let[g,{userViteConfig:w,remixConfig:k,clientOutDir:y,serverOutDir:v,serverOutFile:h}]=await Promise.all([er(p),pe(p,e)]),S=g.createLogger(d?"warn":void 0);process.env.SHOPIFY_UNIT_TEST&&(S.info=A=>Ae("info",A),S.warn=A=>Ae("warn",A),S.error=A=>Ae("error",A));let P=w.build?.minify??!0,_={root:p,mode:process.env.NODE_ENV,base:c,customLogger:S},I,F=await g.build({..._,build:{emptyOutDir:!0,copyPublicDir:!0,sourcemap:i??(process.env.NODE_ENV!=="production"&&n),watch:d?{}:null},server:{watch:d?{}:null},plugins:[{name:"hydrogen:cli:client",buildStart(){I?.resolve(),I=_t()},buildEnd(A){A&&I.reject(A)},writeBundle(){I.resolve()},closeWatcher(){this.error(new Error("Process exited before client build finished."))}}]});console.log("");let R,T=await g.build({..._,build:{sourcemap:n,ssr:e??!0,emptyOutDir:!1,copyPublicDir:!1,minify:P,watch:d?{buildDelay:100}:null},server:{watch:d?{}:null},plugins:[{name:"hydrogen:cli:server",async buildStart(){await I.promise,R?.resolve(),R=_t(),await m?.()},async writeBundle(){R?.state!=="rejected"&&await f?.(),R.resolve()},closeWatcher(){this.error(new Error("Process exited before server build finished."))}},...u?[Ti({minify:P?(A,Z)=>g.transformWithEsbuild(A,Z,{minify:!0,minifyWhitespace:!0,minifySyntax:!0,minifyIdentifiers:!0,sourcemap:!1,treeShaking:!1,legalComments:"none",target:"esnext"}).then(Ce=>Ce.code):void 0})]:[]]});d||await Promise.all([ve(x(y,".vite")),ve(x(v,".vite")),ve(x(v,"assets"))]);let j={rootDirectory:p,appDirectory:k.appDirectory,configFilePath:o},H=r?d?Sr(j):await Dt(j).then(()=>{}):void 0;if(!d&&process.env.NODE_ENV!=="development"){if(u){let Z="file://"+x(v,Oe);$(Y`${await Pi(v)||`
|
|
23
|
+
`}\n │\n └─── ${ke.link("Complete analysis: "+Z,Z)}\n\n`)}await dn(h)/(1024*1024)>=vl&&B(`\u{1F6A8} Smaller worker bundles are faster to deploy and run.${P?"":"\n Minify your bundle by adding `build.minify: true` to vite.config.js."}
|
|
24
|
+
Learn more about optimizing your worker bundle file: https://h2o.fyi/debugging/bundle-size
|
|
25
|
+
`)}if(!d&&!s){let A=kr(k);if(A.length){let Z=await be(p),Ce=Z==="npm"?"npx":Z;B(`Heads up: Shopify stores have a number of standard routes that aren\u2019t set up yet.
|
|
26
|
+
Some functionality and backlinks might not work as expected until these are created or redirects are set up.
|
|
27
|
+
This build is missing ${A.length} route${A.length>1?"s":""}. For more details, run \`${Ce} shopify hydrogen check routes\`.
|
|
28
|
+
`)}}return!d&&!s&&Er(br(k)),{async close(){H?.removeAllListeners("close"),H?.kill("SIGINT");let A=[];"close"in F&&A.push(F.close()),"close"in T&&A.push(T.close()),await Promise.allSettled(A),(I?.state==="pending"||R?.state==="pending")&&(I?.promise.catch(()=>{}),I?.reject(),R?.promise.catch(()=>{}),R?.reject(),await new Promise(Z=>setTimeout(Z,500)))}}}l();var _i=Q(me(),1),Cr=class e extends D{static descriptionWithMarkdown="Checks whether your Hydrogen app includes a set of standard Shopify routes.";static description="Returns diagnostic information about a Hydrogen storefront.";static flags={...b.path};static args={resource:_i.Args.string({name:"resource",description:"The resource to check. Currently only 'routes' is supported.",required:!0,options:["routes"]})};async run(){let{flags:t,args:r}=await this.parse(e),o=t.path?C(t.path):process.cwd();if(r.resource==="routes")await bl({directory:o});else throw new Error("Invalid command argument.")}};async function bl({directory:e}){let t=await Ne(e);Ei(kr(t)),Er(br(t))}l();var Tr=Q(me(),1);var Ir=class e extends D{static descriptionWithMarkdown="Automatically generates GraphQL types for your project\u2019s Storefront API queries.";static description="Generate types for the Storefront API queries found in your project.";static flags={...b.path,"codegen-config-path":Tr.Flags.string({description:"Specify a path to a codegen configuration file. Defaults to `<root>/codegen.ts` if it exists.",required:!1}),"force-sfapi-version":Tr.Flags.string({description:"Force generating Storefront API types for a specific version instead of using the one provided in Hydrogen. A token can also be provided with this format: `<version>:<token>`.",hidden:!0}),watch:Tr.Flags.boolean({description:"Watch the project for changes to update types on file save.",required:!1,default:!1})};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd();await kl({...U(t),directory:r})}};async function kl({directory:e,codegenConfigPath:t,forceSfapiVersion:r,watch:o}){let{root:n}=Se(e),i=await Ne(n);console.log("");let s=await Dt({...i,configFilePath:t,forceSfapiVersion:r,watch:o});o||N({headline:"Generated types for GraphQL:",body:{list:{items:Object.entries(s).map(([a,c])=>a+`
|
|
29
|
+
`+c.map(u=>L.dim(`- ${u}`)).join(`
|
|
30
|
+
`))}}})}l();var Ai=Q(me(),1);l();import{Session as El}from"node:inspector";async function $i(e){let{createMiniOxygen:t}=await qe("@shopify/mini-oxygen/node",e).catch(Io),r=t({script:"export default {}",modules:!0,log:()=>{}});return{async run(o,n){let[i]=await Promise.all([de(o),r.ready()]),s=await Sl();await r.reload({script:i});let a=await s();return xl(a,o+".map",n)},async close(){await r.dispose()}}}function Sl(){let e=new El;return e.connect(),new Promise(t=>{e.post("Profiler.enable",()=>{e.post("Profiler.start",()=>{t(()=>new Promise((r,o)=>{e.post("Profiler.stop",(n,{profile:i})=>{if(e.disconnect(),n)return o(n);r(i)})}))})})})}async function xl(e,t,r){let{SourceMapConsumer:o}=await import("./source-map-3K6Y2OMO.js"),n=JSON.parse(await de(t)),i=await new o(n,"file://"+t),s=new Set,a=0,c=e.endTime-e.startTime,u=e.samples?.length?c/e.samples.length:0;for(let d of e.nodes)(d.callFrame.url==="<script>"||s.has(d.id))&&(s.add(d.id),d.children?.forEach(m=>s.add(m))),s.has(d.id)?(Pl(d,i),d.callFrame.url==="<script>"&&!d.callFrame.functionName&&!d.callFrame.lineNumber&&!d.callFrame.columnNumber&&(d.callFrame.url=r??"",d.callFrame.functionName="(top-level app code)"),a+=Math.round((d.hitCount??0)*u*1e3)/1e3):Cl(d);return i.destroy(),{profile:e,totalTimeMs:c/1e3,totalScriptTimeMs:a/1e3}}function Pl(e,t){let r=t.originalPositionFor({line:e.callFrame.lineNumber+1,column:e.callFrame.columnNumber+1});e.callFrame.url=r.source||e.callFrame.url,e.callFrame.functionName=r.name||e.callFrame.functionName,e.callFrame.lineNumber=r.line?r.line-1:e.callFrame.lineNumber,e.callFrame.columnNumber=r.column??e.callFrame.columnNumber}function Cl(e){Object.assign(e,{children:[],callFrame:{functionName:"(profiler)",scriptId:"0",url:"",lineNumber:-1,columnNumber:-1}})}var Ri="startup.cpuprofile",Dr=class e extends D{static descriptionWithMarkdown="Builds the app and runs the resulting code to profile the server startup time, watching for changes. This command can be used to [debug slow app startup times](https://shopify.dev/docs/custom-storefronts/hydrogen/debugging/cpu-startup) that cause failed deployments in Oxygen.\n\n The profiling results are written to a `.cpuprofile` file that can be viewed with certain tools such as [Flame Chart Visualizer for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-js-profile-flame).";static description="Builds and profiles the server startup time the app.";static flags={...b.path,...b.entry,output:Ai.Flags.string({description:`Specify a path to generate the profile file. Defaults to "${Ri}".`,default:Ri,required:!1})};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd(),{close:o}=await Tl({...U(t),directory:r,output:C(r,t.output)});He(async()=>{await o()})}};async function Tl({directory:e,entry:t,output:r}){process.env.NODE_ENV||(process.env.NODE_ENV="production"),it({workerReload:!1});let{buildPath:o,buildPathWorkerFile:n}=Se(e);$(`\u23F3\uFE0F Starting profiler for CPU startup... Profile will be written to:
|
|
31
|
+
`+L.dim(r));let i=0,s,a=await $i(e),c={onServerBuildStart(){i>0&&process.stdout.write(Wt.eraseLines(4)),$(`
|
|
32
|
+
#${++i} Building and profiling...`)},async onServerBuildFinish(){let{profile:f,totalScriptTimeMs:p}=await a.run(n,s);process.stdout.write(Wt.eraseLines(2)),$(`#${i} Total time: ${p.toLocaleString()} ms
|
|
33
|
+
${L.dim(r)}`),await J(r,JSON.stringify(f,null,2)),$(`
|
|
34
|
+
Waiting for changes...`)}};if(await rt(e))throw new E(xe);let d=await pe(e).catch(()=>null);n=d?.serverOutFile??x(o,"server","index.js"),s=d?.remixConfig.serverEntryPoint??"";let m=await Je({entry:t,directory:e,watch:!0,sourcemap:!0,disableRouteWarning:!0,lockfileCheck:!1,bundleStats:!1,...c,onServerBuildStart(){return i===0&&process.stdout.write(Wt.eraseLines(1)),c.onServerBuildStart()}});return{async close(){await Promise.allSettled([m.close(),a.close()])}}}l();var ae=Q(me(),1);l();l();import Fi from"fs";import ji,{dirname as Il}from"path";import{fileURLToPath as Dl}from"url";var Or={assetsDirDefault:"dist/client/",buildCommandDefault:"npm build",verificationDurationDefault:180,maxUploadAttempts:3,maxResumabeUploadAttempts:9,workerDirDefault:"dist/worker/"};function Pe(e){if(Ol(e)){if(e.statusCode===401)throw new E("You are not authorized to perform this action. Please check your deployment token.");if(e.statusCode===429)throw new E("You've made too many requests. Please try again later")}if(e instanceof E&&e.message.includes("503"))throw new E("The server is currently unavailable. Please try again later.")}var ue=(e=>(e.OxygenNamespaceHandle="X-Oxygen-Namespace-Handle",e))(ue||{});function Ol(e){return typeof e=="object"&&e!==null&&"statusCode"in e}function $t(e){let t;if(e)t=ji.join(e,"package.json");else{let o=Dl(import.meta.url),n=Il(o);t=ji.join(n,"../../package.json")}if(!Fi.existsSync(t))return{};let r=Fi.readFileSync(t,"utf8");return JSON.parse(r)}function Ao(e){process.stderr.write(`${e}
|
|
35
|
+
`)}var ct=375;function Fo(e){try{let t=Buffer.from(e,"base64").toString("utf-8"),r=JSON.parse(t);return Mi(r)}catch{throw new Error("Error processing deployment token. Please check your token and try again.")}}function Ni(e){if(!e)return;let t=Number(e);if(isNaN(t))throw new E("Invalid duration format. Please specify the duration in hours (e.g., '10').");if(t>12||t<1)throw new E("Invalid duration length. Please specify the duration (in hours) between 1 to 12 hours.");return t}async function Li({config:e,performedBuild:t=!1}){let{rootPath:r,workerDir:o,assetsDir:n,skipBuild:i,workerOnly:s}=e,a={root:r};(i||t)&&(a.worker=x(r,o),s||(a.assets=x(r,n)));for(let u of Object.keys(a))await _l(a[u],u);if(!/^https:\/\/(?:[\w-]+\.)*[\w-]+|^https:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/.test(e.deploymentUrl))throw new Error(`Invalid deployment service URL: ${e.deploymentUrl}`)}async function _l(e,t){if(!await G(e))throw t==="assets"&&B('Use the "workerOnly" flag to perform a worker-only deployment.',Ao),new Error(`Path not found: ${e}`)}function Mi(e){return typeof e=="object"?Object.keys(e).reduce((t,r)=>{let o=r.replace(/([-_][a-z])/gi,n=>n.toUpperCase().replace("-","").replace("_",""));if(e[r]===void 0)throw new Error(`Invalid token: ${r} is undefined`);return t[o]=Mi(e[r]),t},{}):e}l();var _r=Q(tl(),1);var Hi;function $l(e){if(e)return;if(_r.default._client)return _r.default;let r={apiKey:"21fd37fe87ead4b9c5a8eed90752b455",autoDetectErrors:!0,appVersion:$t().version,endpoints:{notify:"https://error-analytics-production.shopifysvc.com",sessions:"https://error-analytics-sessions-production.shopifysvc.com"},logger:null};return _r.default.start(r)}function Ui(e){Hi=$l(e)}function dt(){return Hi}function Bi(e,t){if(!t)return e;let r=o=>o.replace(new RegExp(t,"g"),"***");if(e instanceof Error){let o=Object.create(Object.getPrototypeOf(e));return Object.assign(o,e,{message:r(e.message),stack:e.stack?r(e.stack):void 0}),o}return r(e)}l();var re=(e=>(e.BuildTime="build_time",e.NumFilesRequested="num_files_requested",e.NumFilesUploaded="num_files_uploaded",e.TotalSizeUploaded="total_size_uploaded",e.TotalSizeRequested="total_size_requested",e.TotalTime="total_time",e.UploadTime="upload_time",e.DeploymentCompletedTime="deployment_completed_time",e.DeploymentRoutableTime="deployment_routable_time",e))(re||{}),$r=class{metrics={};metricPrefix="oxygen.cli";defaultTags;exportUrl;constructor(t){let{version:r}=$t(),{version:o}=$t(`${t.rootPath}/node_modules/@shopify/hydrogen`);this.defaultTags={ci_provider:t.ciProvider,cli_version:`oxygen-cli@${r||"unknown"}`,hydrogen_version:o||"unknown"},this.exportUrl="https://metrics.myshopify.dev"}add(t,r,o={}){let n={value:r,tags:o};this.metrics[t]?this.metrics[t].push(n):this.metrics[t]=[n]}formatTags(t){return Object.entries(t).map(([r,o])=>`${r}:${o}`)}async export(){let t=Object.entries(this.metrics).map(([r,o])=>{let n=`${this.metricPrefix}.${r}`;return o.map(({value:i,tags:s})=>({name:n,type:"gauge",value:i,tags:this.formatTags({...s,...this.defaultTags})}))}).flat();try{await ie(this.exportUrl,{method:"POST",body:JSON.stringify({events:t})})}catch(r){let o=dt();o&&(r instanceof Error||typeof r=="string")&&o.notify(r)}}};l();l();var Vi=`
|
|
36
|
+
mutation BuildInitiate($environment: EnvironmentSelectorInput, $labels: [String!]) {
|
|
37
|
+
buildInitiate(environment: $environment, labels: $labels) {
|
|
38
|
+
build {
|
|
39
|
+
id
|
|
40
|
+
assetPath
|
|
41
|
+
}
|
|
42
|
+
userErrors {
|
|
43
|
+
message
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;async function Gi(e){let{config:t,logger:r,environment:o,labels:n=[]}=e,i={environment:o,labels:n};try{let s=await fe({query:Vi,api:"Oxygen",url:`${t.deploymentUrl}/api/v2/admin/graphql`,token:t.deploymentToken.accessToken,variables:i,addedHeaders:{[ue.OxygenNamespaceHandle]:t.deploymentToken.namespace}});if(s.buildInitiate.userErrors.length>=1)throw new E(`Failed to create build. ${s.buildInitiate.userErrors[0]?.message}`);return Fe(`Build initiated successfully with id ${s.buildInitiate.build.id}.`,r),s.buildInitiate}catch(s){throw Pe(s),s}}l();l();var qi=`
|
|
48
|
+
mutation BuildCancel($buildId: ID!, $reason: String!) {
|
|
49
|
+
buildCancel(id: $buildId, reason: $reason) {
|
|
50
|
+
build {
|
|
51
|
+
id
|
|
52
|
+
}
|
|
53
|
+
userErrors {
|
|
54
|
+
message
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;async function Wi(e){let{config:t,buildId:r,reason:o,logger:n}=e,i={buildId:r,reason:o};try{let s=await fe({query:qi,api:"Oxygen",url:`${t.deploymentUrl}/api/v2/admin/graphql`,token:t.deploymentToken.accessToken,addedHeaders:{[ue.OxygenNamespaceHandle]:t.deploymentToken.namespace},variables:i});if(s.buildCancel.userErrors.length>=1)throw new E(`Failed to cancel build: ${s.buildCancel.userErrors[0]?.message}`);return $(`Build with id ${r} cancelled.`,n),s.buildCancel}catch(s){throw Pe(s),s}}l();l();var Rr=(e=>(e.Worker="WORKER",e.Asset="ASSET",e))(Rr||{}),ut=class extends Error{},Qe=class extends Error{};async function zi(e,t){let r=x(e.rootPath,e.workerDir),o=await St(`${r}/**`),n=Yi({files:o,basePath:r,type:Rr.Worker,filter:Al});if(!e.workerOnly){let s=x(e.rootPath,e.assetsDir),a=await St(`${s}/**`);n=[...n,...Yi({files:a,basePath:s,type:Rr.Asset,filter:Fl})]}t?.add(re.NumFilesRequested,n.length);let i=n.reduce((s,a)=>s+a.fileSize,0)/1024;return t?.add(re.TotalSizeRequested,i),n}function Rl(e){let t=cn(e);return fn(t)}function Yi(e){let{files:t,basePath:r,type:o,filter:n}=e,i=[];return t.forEach(s=>{let a=ne(r,s);n&&!n(a)||i.push({filePath:a,fileSize:un(s),mimeType:Pn(s),fileType:o,fileHash:Rl(s)})}),i}function Al(e){let t=["oxygen.json"],r=[".js.map",".mjs.map",".map",".js",".mjs"],n=`^(${["index"].join("|")})(${r.join("|")})$`;return new RegExp(n).test(e.toLowerCase())||t.includes(e)}function Fl(e){let r=`(${[".map"].join("|")})$`;return!new RegExp(r).test(e.toLowerCase())}l();l();var Ji=`
|
|
59
|
+
mutation DeploymentInitiate($buildId: ID, $environment: EnvironmentSelectorInput, $labels: [String!], $files: [FileInput!]!) {
|
|
60
|
+
deploymentInitiate(buildId: $buildId, environment: $environment, labels: $labels, files: $files) {
|
|
61
|
+
deployment {
|
|
62
|
+
id
|
|
63
|
+
}
|
|
64
|
+
deploymentTargets {
|
|
65
|
+
filePath
|
|
66
|
+
fileSize
|
|
67
|
+
uploadUrl
|
|
68
|
+
fileType
|
|
69
|
+
parameters {
|
|
70
|
+
name
|
|
71
|
+
value
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
deploymentConfiguration {
|
|
75
|
+
timeoutInSeconds
|
|
76
|
+
}
|
|
77
|
+
userErrors {
|
|
78
|
+
message
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`;async function Qi(e){let{config:t,input:r,logger:o}=e,n={buildId:r.buildId,environment:r.environment,files:r.manifest,labels:r.labels};try{let i=await fe({query:Ji,api:"Oxygen",url:`${t.deploymentUrl}/api/v2/admin/graphql`,token:t.deploymentToken.accessToken,variables:n,addedHeaders:{[ue.OxygenNamespaceHandle]:t.deploymentToken.namespace}});if(i.deploymentInitiate.userErrors.length>=1)throw new E(`Failed to create deployment. ${i.deploymentInitiate.userErrors[0]?.message}`);return Fe(`Deployment initiated, ${i.deploymentInitiate.deploymentTargets.length} files to upload.`,o),i.deploymentInitiate}catch(i){throw Pe(i),i}}l();l();var Ki=`
|
|
83
|
+
mutation DeploymentComplete($deploymentId: ID!, $generateAuthBypassToken: Boolean, $authBypassTokenDuration: Int, $environmentVariables: [EnvironmentVariableInput!]) {
|
|
84
|
+
deploymentComplete(id: $deploymentId, generateAuthBypassToken: $generateAuthBypassToken, authBypassTokenDuration: $authBypassTokenDuration, environmentVariables: $environmentVariables) {
|
|
85
|
+
deployment {
|
|
86
|
+
id
|
|
87
|
+
url
|
|
88
|
+
}
|
|
89
|
+
authBypassToken
|
|
90
|
+
userErrors {
|
|
91
|
+
message
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`;async function Xi(e,t){let r={deploymentId:t,generateAuthBypassToken:e.generateAuthBypassToken};if(e.generateAuthBypassToken)r.authBypassTokenDuration=Ni(e.authBypassTokenDuration);else if(e.authBypassTokenDuration)throw new E("authBypassTokenDuration is set but generateAuthBypassToken is not enabled");e.overriddenEnvironmentVariables&&(r.environmentVariables=e.overriddenEnvironmentVariables);try{let o=await fe({query:Ki,api:"Oxygen",url:`${e.deploymentUrl}/api/v2/admin/graphql`,token:e.deploymentToken.accessToken,variables:r,addedHeaders:{[ue.OxygenNamespaceHandle]:e.deploymentToken.namespace}});if(o.deploymentComplete.userErrors.length>=1)throw new E(`Failed to complete deployment: ${o.deploymentComplete.userErrors[0]?.message}`);return o.deploymentComplete}catch(o){throw Pe(o),o}}l();async function Zi(e){let{config:t,url:r,logger:o,hooks:n}=e;n?.onVerificationStart?.(),$("Verifying worker deployment is routable...",o);let i=0,s=0,a=!1,c=Date.now(),u=async()=>{if(i<10?s=500:i%5===0&&(s+=5e3),(Date.now()-c)/1e3+s/1e3>t.verificationMaxDuration){let f=new ut("Unable to verify that the worker is accessible.");throw a||(a=!0,n?.onVerificationError?.(f)),f}i++,await new Promise(f=>setTimeout(f,s)),await d()},d=async()=>{try{if((await ie(`${r}/.oxygen/deployment`,{method:"HEAD"})).status===200)return $("Deployment verification check passed",o),n?.onVerificationComplete?.(),Promise.resolve();await u()}catch{await u()}};await d()}l();l();var es=`
|
|
96
|
+
mutation DeploymentCancel($deploymentId: ID!, $reason: String!) {
|
|
97
|
+
deploymentCancel(id: $deploymentId, reason: $reason) {
|
|
98
|
+
deployment {
|
|
99
|
+
id
|
|
100
|
+
}
|
|
101
|
+
userErrors {
|
|
102
|
+
message
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`;async function ts(e){let{config:t,deploymentId:r,reason:o,logger:n}=e,i={deploymentId:r,reason:o};try{let s=await fe({query:es,api:"Oxygen",url:`${t.deploymentUrl}/api/v2/admin/graphql`,token:t.deploymentToken.accessToken,variables:i,addedHeaders:{[ue.OxygenNamespaceHandle]:t.deploymentToken.namespace}});if(s.deploymentCancel.userErrors.length>=1)throw new E(s.deploymentCancel.userErrors[0]?.message||"");return $(`Deployment with id ${r} cancelled.`,n),s.deploymentCancel}catch(s){throw Pe(s),s}}l();import{Agent as jl}from"https";var rs=Q(rl(),1);async function os(e){let{config:t,logger:r,targets:o,hooks:n}=e;$(`Uploading ${o.length} files...`,r);let i=o.reduce((c,u)=>c+u.fileSize,0)/1024;e.metricsExporter?.add(re.TotalSizeUploaded,i),e.metricsExporter?.add(re.NumFilesUploaded,o.length);let s=new jl({keepAlive:!0});n?.onUploadFilesStart?.();let a=performance.now();return(0,rs.mapLimit)(o,6,async c=>{await Nl(t,c,s)}).then(()=>{let c=performance.now();n?.onUploadFilesComplete?.(),e.metricsExporter?.add(re.UploadTime,c-a),Fe("Files uploaded successfully",r)}).catch(c=>{throw n?.onUploadFilesError?.(c),c}).finally(()=>{s.destroy()})}async function Nl(e,t,r){let o=t.fileType==="WORKER"?x(e.rootPath,e.workerDir):x(e.rootPath,e.assetsDir);if(t.parameters!==null&&t.parameters.length>0){let n=mn();t.parameters.forEach(i=>{n.append(i.name,i.value)}),n.append("file",vo(x(o,t.filePath))),await ns(n,t,r)}else{let n=await Ll(t,r);await is(x(o,t.filePath),n,r)}}async function ns(e,t,r,o=0){try{let i=new AbortController,s=setTimeout(()=>{i.abort()},12e4),a=await ie(t.uploadUrl,{method:"POST",body:e,signal:i.signal,headers:{Connection:"keep-alive"},agent:r});if(clearTimeout(s),!a.ok)throw new Error(`${a.status}`)}catch(n){if(ss(n,"ENOENT"))throw new Error(`File not found: ${t.filePath}`);if(o<Number(Or.maxUploadAttempts))await ns(e,t,r,o+1);else throw n instanceof Error&&n.name==="AbortError"?new Error(`Request timeout whilst uploading ${t.filePath}`):new Error(`Failed to upload file ${t.filePath}`)}}async function Ll(e,t){return ie(e.uploadUrl,{method:"POST",headers:{"x-goog-resumable":"start","X-Goog-Content-Length-Range":`0,${e.fileSize}`,"User-Agent":"oxygen-cli"},agent:t}).then(r=>({sessionUri:r.headers.get("x-guploader-uploadid"),location:r.headers.get("location"),target:e})).catch(r=>{throw new Error(`Failed to initiate resumable upload for file ${e.filePath} (status code ${r.statusCode})`)})}async function is(e,t,r,o=0,n=0){await Ml(t.location,e,o,r).catch(async i=>{if(ss(i,"ENOENT"))throw new Error(`File not found: ${t.target.filePath}`);if(i&&n>=Number(Or.maxResumabeUploadAttempts))throw new Error(`Failed to upload file ${t.target.filePath} after ${Or.maxResumabeUploadAttempts} attempts`);let s=await Hl(t.location,t.target.fileSize,r);if(!s.complete){let a=s.lastReceivedByte,c=n+1;await is(e,t,r,a,c)}})}async function Ml(e,t,r,o){let n=vo(t,{start:r});return ie(e,{method:"PUT",body:n,agent:o}).then(i=>i.status)}async function Hl(e,t,r){let o=n=>{if(!n||n.split("-").length!==2)return 0;let i=n.split("-");return parseInt(i[1],10)};return ie(e,{method:"PUT",headers:{"Content-Length":"0","Content-Range":`bytes */${t}`},agent:r}).then(n=>({complete:n.status===200,lastReceivedByte:o(n.headers.get("range"))})).catch(n=>(console.error(n),{complete:!1,lastReceivedByte:0}))}function ss(e,t){return e instanceof Error&&"code"in e&&e.code===t}l();l();var as=`
|
|
107
|
+
query DeploymentVerificationDetails($deploymentId: ID!) {
|
|
108
|
+
deploymentVerificationDetails(id: $deploymentId) {
|
|
109
|
+
url
|
|
110
|
+
status
|
|
111
|
+
error
|
|
112
|
+
startupTime
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
`,Rt=(e=>(e.Pending="PENDING",e.Deployed="DEPLOYED",e.Failed="FAILED",e.Cancelled="CANCELLED",e))(Rt||{});async function ls(e,t){let{config:r,logger:o,timeoutInSeconds:n,hooks:i}=e,s={deploymentId:t};i?.onDeploymentCompletedVerificationStart?.(),$("Verifying deployment completed...",o);let a=Date.now(),c=async()=>{if((Date.now()-a)/1e3+3e3/1e3>n)throw i?.onDeploymentCompletedVerificationError?.(),new Error(`Deployment not completed after ${n} seconds.`);return await new Promise(f=>setTimeout(f,3e3)),u()},u=async()=>{let m=(await fe({query:as,api:"Oxygen",url:`${r.deploymentUrl}/api/v2/admin/graphql`,token:r.deploymentToken.accessToken,variables:s,addedHeaders:{[ue.OxygenNamespaceHandle]:r.deploymentToken.namespace}})).deploymentVerificationDetails;if(m==null)throw i?.onDeploymentCompletedVerificationError?.(),new Qe("Deployment not found");if(m.status===Rt.Deployed)return Fe("Deployment to Oxygen completed successfully",o),i?.onDeploymentCompleted?.(),m;if(m.status===Rt.Failed||m.status===Rt.Cancelled)throw i?.onDeploymentFailed?.(m),new Qe(m.error?`Deployment ${m.status.toLocaleLowerCase()}, error: ${m.error}${m.startupTime&&m.error.includes("exceeded CPU time limit")?` (Startup time: ${m.startupTime}ms exceeded CPU time limit)`:""}`:`Deployment ${m.status.toLocaleLowerCase()}`);return c()};return u()}l();import{spawn as Ul}from"child_process";import{PassThrough as Bl}from"stream";async function cs(e){let{config:t,assetPath:r,hooks:o}=e,n=dt();if(o?.buildFunction){let s=performance.now();return o.buildFunction(r).then(()=>{e.metricsExporter?.add(re.BuildTime,performance.now()-s)}).catch(a=>{throw new Error(`Build function failed with error: ${a}`)})}let i=r?{HYDROGEN_ASSET_BASE_URL:r}:{};try{await new Promise((s,a)=>{let c="",u=new Bl;u.on("data",f=>{c+=f,process.stderr.write(f)});let d=performance.now(),m=Ul(t.buildCommand,[],{stdio:["inherit","pipe","pipe"],env:{...process.env,...i},cwd:t.rootPath,shell:!0});m.stderr?.pipe(u),m.stdout?.pipe(u),m.on("close",f=>{if(f===0&&e.metricsExporter?.add(re.BuildTime,performance.now()-d),n?.addMetadata("buildCommand",{command:t.buildCommand,stderr:c,code:f}),f!==0){a(f);return}s(f)})})}catch(s){throw new Error(`Build failed with error code: ${s}`)}}l();async function ds(e,t){let r=Jt(),o=r.metadata??{};try{let n=await Vl(e.rootPath);o.actor||(o.actor=n.author_name),o.commitDate||(o.commitDate=n.date),o.commitMessage||(o.commitMessage=n.message),n.branch&&(o.branch=n.branch),n.hash&&(o.commitSha=n.hash)}catch{B("Could not retrieve Git history, commit message will be unavailable.",t)}return{name:r.isCI?r.name:"none",...o,actor:e.metadata.user??o.actor,commitMessage:Gl(e.metadata.description??o.commitMessage),commitSha:e.metadata.version??o.commitSha,hydrogenVersion:e.metadata.hydrogenVersion,url:e.metadata.url??o.url}}async function Vl(e){let t=await Qt(e),r=(/HEAD -> ([^,]*)/.exec(t.refs)||[])[1],o=process.env.GITHUB_HEAD_REF;if(!o)return{...t,branch:r};let n=/Merge ([\w\d]+) into [\w\d]+/.exec(t.message);return{...t,branch:o,hash:n?n[1]:t.hash}}function Gl(e){if(!e)return;let t=e.split(/\r?\n/)[0]?.trim()||"",r=JSON.stringify(t),o=!1;for(;r.length>ct;){let n=t.lastIndexOf(" ",ct-3);t=`${t.substring(0,n>-1?n:ct-3)}`.trimEnd(),o=!0,r=JSON.stringify(t)}return o?`${t}...`:t}function us(e,t){if(e.defaultEnvironment)return;let r=e.environmentTag||t.branch;return r?{tag:r}:void 0}function fs(e){let t=[],r=(n,i)=>{let s=JSON.stringify(i);if(s.length>ct)throw new Error(`Provided ${n} metadata exceeds maximum length (max ${ct} characters).`);let a=`${n}=${s}`;t.push(a)};if(e.name!=="none"&&t.push(`ci-platform=${JSON.stringify(e.name)}`),e.name!=="unknown"){let n={attempt:"attempt",run:"runId"};for(let[i,s]of Object.entries(n)){let a=i;e[a]&&t.push(`${e.name}-${s}=${JSON.stringify(e[a])}`)}}let o={actor:"user",branch:"branch",commitDate:"commit-date",commitMessage:"description",commitSha:"version",hydrogenVersion:"hydrogen-version",url:"url"};for(let[n,i]of Object.entries(o)){let s=n;e[s]&&r(i,e[s])}return t}async function ms(e){let t=performance.now();Ui(!e.config.bugsnag);let r=dt();r?.addMetadata("config",{...e.config,deploymentToken:{...e.config.deploymentToken,accessToken:"***"},rootPath:"***"});let{config:o,hooks:n}=e,i=e.logger??Ao,s={},a,c,u;try{let d=await ds(o,i),m=fs(d),f=us(o,d);if(r?.addMetadata("metadata",{environment:f,labels:m,metadata:d}),u=new $r({ciProvider:d.name||"unknown",rootPath:o.rootPath}),!o.workerOnly&&!o.skipBuild){let h=await Gi({config:o,environment:f,labels:m,logger:i});s.id=h.build.id,s.assetPath=h.build.assetPath}o.skipBuild||(await cs({config:o,assetPath:s.assetPath,hooks:n,metricsExporter:u}),await Li({config:o,performedBuild:!0})),a=!0;let p=await zi(o,u);r?.addMetadata("manifest",p);let g=s.id?{buildId:s.id,manifest:p}:{environment:f,manifest:p,labels:m};c=await Qi({config:o,input:g,logger:i}),await os({config:o,targets:c.deploymentTargets,hooks:n,logger:i,metricsExporter:u});let w=performance.now(),k=await Xi(o,c.deployment.id);u.add(re.TotalTime,performance.now()-t),await ls({config:o,hooks:n,logger:i,timeoutInSeconds:c.deploymentConfiguration.timeoutInSeconds},c.deployment.id),u.add(re.DeploymentCompletedTime,performance.now()-w),o.skipVerification||(await Zi({config:o,url:k.deployment.url,logger:i,hooks:n}),u.add(re.DeploymentRoutableTime,performance.now()-w));let y={url:k.deployment.url},v=`
|
|
116
|
+
The deployment can be reached at the ${y.url} preview URL`;return k.authBypassToken&&(y.authBypassToken=k.authBypassToken,v+=`. The auth bypass token for the deployment is ${y.authBypassToken}`),En(v,i),y}catch(d){return o.bugsnag&&r&&(d instanceof Error||typeof d=="string")&&r.notify(Bi(d,o.rootPath)),d instanceof Error?(d instanceof ut||d instanceof Qe?B(d.message,i):s.id&&!a?(B(`Build failed with: ${d.message}, cancelling build.`,i),await Wi({config:o,buildId:s.id,reason:d.message,logger:i}).catch(m=>{m instanceof Error&&B(`Failed to cancel build: ${m.message}`,i)})):c?.deployment.id&&(B(`Deployment failed with: ${d.message}, cancelling deployment.`,i),await ts({config:o,deploymentId:c.deployment.id,reason:d.message,logger:i}).catch(m=>{m instanceof Error&&B(`Failed to cancel deployment: ${m.message}`,i)})),Promise.reject(d)):(console.error("Unknown error",d),Promise.reject(new Error("Unknown error")))}finally{u?.export()}}import{createRequire as Wl}from"node:module";l();l();l();function ps(e){let{storeFqdn:t}=e;return`https://${t}/admin/custom_storefronts/new`}function hs(e){let{storeFqdn:t}=e;return`https://${t}/admin/custom_storefronts`}function ft({session:e,storefront:t,cliCommand:r}){$e({name:"NoStorefrontError",type:0,message:Y`${ke.errorText("Couldn\u2019t find Hydrogen storefront.")}`.value,skipOclifErrorHandling:!0,tryMessage:Y`Couldn’t find ${t.title} (ID: ${nt(t.id)}) on ${e.storeFqdn}. Check that the storefront exists and run ${ke.genericShellCommand(`${r} link`)} to link this project to it.\n\n${ke.link("Hydrogen Storefronts Admin",hs(e))}`.value})}function gs({noStorefronts:e=!1}){V({headline:e?"You don't have a Hydrogen storefront to link to":"You haven't linked your project to a storefront yet",body:["Link your local environment to a Hydrogen storefront. Enable automatic environment variable injection and access to",{command:"env list"},",",{command:"env pull"},",",{command:"env push"},", and",{command:"deploy"},"commands. Use",{command:"unlink"},"to disconnect from the storefront."]})}l();var ql=`#graphql
|
|
117
|
+
query GetDeploymentToken($id: ID!) {
|
|
118
|
+
hydrogenStorefront(id: $id) {
|
|
119
|
+
oxygenDeploymentToken
|
|
120
|
+
environments {
|
|
121
|
+
name
|
|
122
|
+
handle
|
|
123
|
+
branch
|
|
124
|
+
type
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
`;async function ys(e,t){let{hydrogenStorefront:r}=await ot(ql,e,{id:t});return{storefront:r}}l();async function Ue({root:e,session:t,config:r,cliCommand:o}){let n=await Wn(t),i=r.storefront?.id?n.find(({id:s})=>s===r.storefront.id):void 0;return i||(gs({noStorefronts:!n.length}),await di(e,t,r,{force:!0,cliCommand:o,storefronts:n}))}async function ws({root:e}){let[{session:t,config:r},o]=await Promise.all([he(e),W()]),n=await Ue({root:e,session:t,config:r,cliCommand:o});if(!n)return;r.storefront=n;let{storefront:i}=await ys(t,r.storefront.id);if(!i){ft({session:t,storefront:r.storefront,cliCommand:o});return}if(!i.oxygenDeploymentToken){B("Could not retrieve a deployment token.");return}return i}var vs="h2_deploy_log.json",Yl=(e,t="info")=>{(t==="error"||t==="warn")&&B(e)},Ar=class e extends D{static descriptionWithMarkdown="Builds and deploys your Hydrogen storefront to Oxygen. Requires an Oxygen deployment token to be set with the `--token` flag or an environment variable (`SHOPIFY_HYDROGEN_DEPLOYMENT_TOKEN`). If the storefront is [linked](https://shopify.dev/docs/api/shopify-cli/hydrogen/hydrogen-link) then the Oxygen deployment token for the linked storefront will be used automatically.";static description="Builds and deploys a Hydrogen storefront to Oxygen.";static flags={...b.entry,...b.env,...b.envBranch,...ye(b.envFile,{"env-file":{description:"Path to an environment file to override existing environment variables for the deployment.",default:void 0}}),preview:ae.Flags.boolean({description:"Deploys to the Preview environment.",required:!1,default:!1}),force:ae.Flags.boolean({char:"f",description:"Forces a deployment to proceed if there are uncommited changes in its Git repository.",default:!1,env:"SHOPIFY_HYDROGEN_FLAG_FORCE",required:!1}),"no-verify":ae.Flags.boolean({description:"Skip the routability verification step after deployment.",default:!1,required:!1}),"auth-bypass-token":ae.Flags.boolean({description:"Generate an authentication bypass token, which can be used to perform end-to-end tests against the deployment.",required:!1,default:!1,env:"AUTH_BYPASS_TOKEN"}),"auth-bypass-token-duration":ae.Flags.string({description:"Specify the duration (in hours) up to 12 hours for the authentication bypass token. Defaults to `2`",required:!1,env:"AUTH_BYPASS_TOKEN_DURATION",dependsOn:["auth-bypass-token"]}),"build-command":ae.Flags.string({description:"Specify a build command to run before deploying. If not specified, `shopify hydrogen build` will be used.",required:!1}),...b.lockfileCheck,...b.path,...b.shop,"json-output":ae.Flags.boolean({allowNo:!0,description:"Create a JSON file containing the deployment details in CI environments. Defaults to true, use `--no-json-output` to disable.",required:!1,default:!0}),token:ae.Flags.string({char:"t",description:"Oxygen deployment token. Defaults to the linked storefront's token if available.",env:"SHOPIFY_HYDROGEN_DEPLOYMENT_TOKEN",required:!1}),"metadata-description":ae.Flags.string({description:"Description of the changes in the deployment. Defaults to the commit message of the latest commit if there are no uncommited changes.",required:!1,env:"SHOPIFY_HYDROGEN_FLAG_METADATA_DESCRIPTION"}),"metadata-url":ae.Flags.string({required:!1,env:"SHOPIFY_HYDROGEN_FLAG_METADATA_URL",hidden:!0}),"metadata-user":ae.Flags.string({description:"User that initiated the deployment. Will be saved and displayed in the Shopify admin",required:!1,env:"SHOPIFY_HYDROGEN_FLAG_METADATA_USER"}),"metadata-version":ae.Flags.string({required:!1,env:"SHOPIFY_HYDROGEN_FLAG_METADATA_VERSION",hidden:!0}),"force-client-sourcemap":ae.Flags.boolean({description:"Client sourcemapping is avoided by default because it makes backend code visible in the browser. Use this flag to force enabling it.",env:"SHOPIFY_HYDROGEN_FLAG_FORCE_CLIENT_SOURCEMAP"})};async run(){let{flags:t}=await this.parse(e),r=this.flagsToOxygenDeploymentOptions(t);await zl(r),process.exit(0)}flagsToOxygenDeploymentOptions(t){return{...U(t),defaultEnvironment:t.preview,environmentFile:t["env-file"],path:t.path?C(t.path):process.cwd()}}};function bs(e){return new E(e||"The deployment failed due to an unexpected error.","Retrying the deployment may succeed.",[["If the issue persists, please check the",{link:{label:"Shopify status page",url:"https://status.shopify.com/"}},"for any known issues."]])}async function zl(e){let{authBypassTokenDuration:t,authBypassToken:r,buildCommand:o,defaultEnvironment:n,env:i,envBranch:s,environmentFile:a,force:c,forceClientSourcemap:u=!1,noVerify:d,lockfileCheck:m,jsonOutput:f,path:p,shop:g,metadataUrl:w,metadataUser:k,metadataVersion:y,entry:v}=e,{metadataDescription:h}=e,S=!0;try{await On(p)}catch(O){if(O instanceof Dn&&(S=!1),!c&&!S){let te="Uncommitted changes detected",Te,kt=[["Commit your changes before deploying or use the",{command:"--force"},"flag to deploy with uncommitted changes."]];try{Te=(await xt("git status -s",{cwd:p})).stdout}catch{}throw Te&&(te+=`:
|
|
129
|
+
|
|
130
|
+
${Te.trimEnd()}`,vr.forEach(({name:po,lockfile:ho,alternativeLockfiles:Ja,installCommand:Qa})=>{let nn=[ho,...Ja||[]].find(Ka=>Te.includes(Ka));nn&&kt.push([`If you are using ${po}, try running`,{command:Qa},`to avoid changes to ${nn}.`])})),new E(te,null,kt)}}let P=Jt().isCI,_=e.token,I,F,R,T,j;try{j=await Qt(p),I=(/HEAD -> ([^,]*)/.exec(j.refs)||[])[1],F=j.hash}catch{B("Could not retrieve Git history."),I=void 0}!h&&!S&&(q({headline:"No deployment description provided",body:["Deploying uncommited changes, but no description has been provided. Use the ",{command:"--metadata-description"},"flag to provide a description. If no description is provided, the description defaults to ",{userInput:"<sha> with additional changes"}," using the SHA of the last commit."]}),h=`${F} with additional changes`);let H;if(a){let{variables:O}=await mr(a);H=Object.entries(O).map(([te,Te])=>({isSecret:!0,key:te,value:Te}))}let A=null,Z=!1;if(P&&i)throw new E("Can't specify an environment handle in CI","Environments are automatically picked up by the current Git branch.");if(P&&s&&(A=s),!P){if(R=await ws({root:p,flagShop:g}),!R)return;_=_||R.oxygenDeploymentToken,i?(A=at(R.environments||[],i).branch,A===null&&(Z=!0)):s&&(A=It(R.environments||[],s).branch)}if(!_){let O=P?["No deployment token provided. Use the ",{command:"--token"}," flag to provide a token."]:"Could not obtain an Oxygen deployment token, please try again or contact Shopify support.";throw new E(O)}if(!P&&!n&&!i&&!s&&R?.environments)if(R.environments.length>1){let te=pr(R.environments).map(({name:Te,branch:kt,handle:po,type:ho})=>({label:ze(Te,po,kt),value:ho==="PREVIEW"?"shopify-preview-environment.":kt}));T=await Re({message:"Select an environment to deploy to",choices:te,defaultValue:I})}else $(`Using current checked out branch ${I} as environment tag`);let Ce="https://oxygen.shopifyapps.com";process.env.UNSAFE_SHOPIFY_HYDROGEN_DEPLOYMENT_URL&&(Ce=process.env.UNSAFE_SHOPIFY_HYDROGEN_DEPLOYMENT_URL,B("Using a custom deployment service. Don't do this in production!"));let Ve=I;T==="shopify-preview-environment."&&(Ve=void 0,T=void 0,Z=!0);let Bt="dist/client",yt="dist/worker",wt=await rt(p);if(!wt){let O=await pe(p,v).catch(()=>null);O?(Bt=ne(p,O.clientOutDir),yt=ne(p,O.serverOutDir)):yt="dist/server"}let z=await Jl({appPath:p}),le={assetsDir:Bt,bugsnag:!0,deploymentUrl:Ce,defaultEnvironment:n||Z,deploymentToken:Fo(_),environmentTag:A||T||Ve,generateAuthBypassToken:r,authBypassTokenDuration:t,verificationMaxDuration:180,metadata:{...h?{description:h}:{},...w?{url:w}:{},...k?{user:k}:{},...y?{version:y}:{},...z?{hydrogenVersion:z}:{}},skipVerification:d,rootPath:p,skipBuild:!1,workerOnly:!1,workerDir:yt,overriddenEnvironmentVariables:H};if(!P&&!le.defaultEnvironment&&(A||T)){let O=It(R.environments,le.environmentTag),te=`Creating a deployment against ${ze(O.name,O.handle,O.branch)}`;if(!await Ie({confirmationMessage:"Yes, confirm deploy",cancellationMessage:"No, cancel deploy",message:Y`${te}
|
|
131
|
+
|
|
132
|
+
Continue?`.value}))return}let uo,fo=new Promise(O=>{uo=O}),vt,qa=new Promise(O=>{vt=O}),tn,Wa=new Promise(O=>{tn=O}),bt=null,rn,mo,Ya=new Promise((O,te)=>{rn=O,mo=te}),on={onDeploymentCompleted:()=>tn(),onVerificationComplete:()=>vt(),onDeploymentCompletedVerificationError(){bt=new E("Unable to verify the deployment was completed successfully","Please verify the deployment status in the Shopify Admin and retry deploying if necessary.")},onDeploymentFailed:O=>{bt=bs(O.error||O.status)},onUploadFilesStart:()=>za(),onUploadFilesComplete:()=>uo(),onVerificationError:O=>{bt=new E(O.message,"Please verify the deployment status in the Shopify Admin and retry deploying if necessary.")},onUploadFilesError:O=>{bt=new E(O.message,"Check your connection and try again. If the problem persists, try again later or contact support.")}};o?(u&&(console.log(""),V({headline:"The `--force-client-sourcemap` flag is not supported with a custom build command",body:"Client sourcemaps will not be generated."})),le.buildCommand=o):on.buildFunction=async O=>{if($(Y`${L.whiteBright("Building project...")}`.value),wt)throw new E(xe);await Je({directory:p,assetPath:O,lockfileCheck:m,sourcemap:!0,forceClientSourcemap:u,useCodegen:!1,entry:v})};let za=async()=>{$(Y`${L.whiteBright(`Deploying to Oxygen..
|
|
133
|
+
`)}`.value),await ee([{title:"Uploading files",task:async()=>await fo},{title:"Verifying deployment has been completed",task:async()=>await Wa},{title:"Verifying deployment is routable",task:async()=>await qa,skip:()=>d}])};return await ms({config:le,hooks:on,logger:Yl}).then(async O=>{if(!O){mo(bs());return}let te=[];P?f&&te.push(["View the deployment information in",{subdued:vs}]):(te.push(["Open",{link:{url:O.url}},"in your browser to view your deployment."]),O?.authBypassToken&&te.push(["Use the",{subdued:O.authBypassToken},"token to perform end-to-end tests against the deployment."])),N({body:["Successfully deployed to Oxygen"],nextSteps:te}),P&&f&&await J(vs,JSON.stringify(O)),rn()}).catch(O=>{mo(bt||O)}),Ya}async function Jl({appPath:e}){let{root:t}=Se(e),r=Wl(import.meta.url),{version:o}=r(r.resolve("@shopify/hydrogen/package.json",{paths:[t]}));return o}l();var Nt=Q(me(),1);l();var oe=Q(nl(),1);import{createRequire as Ql}from"node:module";var No=Q(me(),1);var ks=".hydrogen",Fr=class e extends D{static descriptionWithMarkdown="Upgrade Hydrogen project dependencies, preview features, fixes and breaking changes. The command also generates an instruction file for each upgrade.";static description="Upgrade Remix and Hydrogen npm dependencies.";static flags={...b.path,version:No.Flags.string({description:"A target hydrogen version to update to",required:!1,char:"v"}),force:No.Flags.boolean({description:"Ignore warnings and force the upgrade to the target version",env:"SHOPIFY_HYDROGEN_FLAG_FORCE",char:"f"})};async run(){let{flags:t}=await this.parse(e);await Kl({...U(t),appPath:t.path?C(t.path):process.cwd()})}},At=null;async function Kl({appPath:e,version:t,force:r}){if(t==="next"){let p=process.env.SHOPIFY_UNIT_TEST==="1",g=Ot();if(!await Xl()&&!p&&!g)throw new E("--version=next is only available when running from the Hydrogen monorepo","This feature is designed for internal development and testing of unreleased versions")}r||(await ec(e),await tc(e));let{currentVersion:o,currentDependencies:n}=await xs({appPath:e});if(t==="next"){let p=n["@shopify/hydrogen"]==="next",g=n["@shopify/mini-oxygen"]==="next";if(p||g)throw new E("Project already uses next versions",'Cannot upgrade to --version=next when @shopify/hydrogen or @shopify/mini-oxygen are already using "next" versions')}if(oe.default.prerelease(o))throw new E("The upgrade command cannot be run over a prerelease Hydrogen version");let s=await Ps(),{availableUpgrades:a}=Ts({releases:s.releases,currentVersion:o,currentDependencies:n});if(!a?.length){N({headline:`You are on the latest Hydrogen version: ${M(o)}`});return}let c=!1,u,d;do u=await oc({currentVersion:o,targetVersion:t,availableUpgrades:a,currentDependencies:n}),d=nc({availableUpgrades:a,currentVersion:o,currentDependencies:n,selectedRelease:u}),c=await ic({cumulativeRelease:d,selectedRelease:u,targetVersion:t});while(!c);let m=pc({appPath:e,cumulativeRelease:d,currentVersion:o,selectedRelease:u});await ac({appPath:e,selectedRelease:u,currentDependencies:n,targetVersion:t}),await mc({appPath:e,selectedRelease:u,targetVersion:t});let f=await m;await fc({appPath:e,currentVersion:o,instrunctionsFilePath:f,selectedRelease:u})}async function Xl(){try{let e=process.cwd(),t=[e,x(e,"../"),x(e,"../../")];for(let r of t)try{let o=x(r,"templates/skeleton"),n=x(r,"packages/cli"),i=await qt(o),s=await qt(n);if(i&&s)return!0}catch{continue}return!1}catch{return!1}}function Zl(e){let t={...e.dependencies},r={...e.devDependencies};return t["@shopify/hydrogen"]&&(t["@shopify/hydrogen"]="next"),r["@shopify/mini-oxygen"]&&(r["@shopify/mini-oxygen"]="next"),{...e,title:`${e.title} (next versions)`,dependencies:t,devDependencies:r}}function ec(e){return In(e).catch(()=>{throw new E("The upgrade command can only be run on a git repository","Please run the command inside a git repository or run 'git init' to create one")})}async function tc(e){if(!await _n(e))throw new E("The upgrade command can only be run on a clean git branch","Please commit your changes or re-run the command on a clean branch")}async function xs({appPath:e}){let{root:t}=Se(e),r=x(t,"package.json"),o;try{o=JSON.parse(await de(r))}catch{throw new E("Could not find a valid package.json","Please make sure you are running the command in a npm project")}let n={...o?.dependencies,...o?.devDependencies},i=n["@shopify/hydrogen"];if(!i)throw new E("Could not find a valid Hydrogen version in package.json","Please make sure you are running the command in a Hydrogen project");return{currentVersion:i,currentDependencies:n}}async function Ps(){if(At)return At;if(process.env.FORCE_CHANGELOG_SOURCE==="local"||De&&Ee&&process.env.FORCE_CHANGELOG_SOURCE!=="remote"){let e=Ql(import.meta.url),t=De&&Ee?x(go(Ee),"docs","changelog.json"):x(process.cwd(),"docs","changelog.json");try{let r=e(t);return At=r,r}catch(r){if(console.warn(`Failed to load local changelog from ${t}:`,r.message),process.env.FORCE_CHANGELOG_SOURCE==="local")throw new E("Failed to load local changelog",`Could not read changelog from ${t}`)}}try{let e=await ie("https://hydrogen.shopify.dev/changelog.json");if(!e.ok)throw new Error("Failed to fetch changelog.json");let t=await e.json();if("releases"in t&&"url"in t)return At=t,At}catch{}throw new E("Failed to fetch Hydrogen changelog","Ensure you have internet connection and try again")}function Cs({release:e,currentDependencies:t}){return Object.entries({...e.dependencies,...e.devDependencies}).some(([r,o])=>{if(r==="@shopify/cli")return!1;let n=t?.[r];return n?oe.default.gt(M(o),M(n)):!1})}function rc({currentDependencies:e,currentPinnedVersion:t,release:r}){return oe.default.gt(r.version,t)?!0:M(r.version)===t?Cs({release:r,currentDependencies:e}):!1}function Ts({releases:e,currentVersion:t,currentDependencies:r}){let o=M(t),n="",i=e.filter(a=>rc({release:a,currentPinnedVersion:o,currentDependencies:r})&&n!==a.version?(n=a.version,!0):!1),s=i.reduce((a,c)=>(a[c.version]||(a[c.version]=c),a),{});return{availableUpgrades:i,uniqueAvailableUpgrades:s}}async function oc({targetVersion:e,availableUpgrades:t,currentVersion:r,currentDependencies:o}){return(e?e==="next"?Zl(t[0]):t.find(i=>M(i.version)===M(e)):void 0)??uc(r,t)}function nc({availableUpgrades:e,selectedRelease:t,currentVersion:r,currentDependencies:o}){let n=M(r);return e?.length?t.dependencies?.["@shopify/hydrogen"]==="next"?{features:t.features||[],fixes:t.fixes||[]}:e.filter(s=>oe.default.gt(s.version,n)&&oe.default.lte(s.version,t.version)?!0:!(M(s.version)===n)||!o?!1:Cs({release:s,currentDependencies:o})).reduce((s,a)=>(s.features=[...s.features,...a.features],s.fixes=[...s.fixes,...a.fixes],s),{features:[],fixes:[]}):{features:[],fixes:[]}}function ic({cumulativeRelease:e,selectedRelease:t,targetVersion:r}){let{features:o,fixes:n}=e;return(o.length||n.length)&&V({headline:"Included in this upgrade:",customSections:[o.length&&{title:"Features",body:[{list:{items:o.map(i=>i.title)}}]},n.length&&{title:"Fixes",body:[{list:{items:n.map(i=>i.title)}}]}].filter(Boolean)}),r==="next"?!0:Ie({message:`Are you sure you want to upgrade to ${t.version}?`,cancellationMessage:"No, choose another version",defaultValue:!0})}function jr([e]){return!!e.includes("@remix-run")}function Lo([e]){return!!e.includes("react-router")}function Es(e,t,r){return r==="next"&&(e==="@shopify/hydrogen"||e==="@shopify/mini-oxygen")?"next":M(t)}function Ss({currentDependencies:e,dependency:[t,r],selectedRelease:o,targetVersion:n}){let i=e[t];return jr([t,r])||Lo([t,r])||i==="next"&&!(n==="next")?!1:o.dependenciesMeta?.[t]?!o.dependenciesMeta?.[t]?.required?!1:!!(!i||n==="next"&&(t==="@shopify/hydrogen"||t==="@shopify/mini-oxygen")||oe.default.lt(M(i),M(r))):!0}function sc({selectedRelease:e,currentDependencies:t,targetVersion:r}){let o=[];for(let c of Object.entries(e.dependencies))Ss({currentDependencies:t,dependency:c,selectedRelease:e,targetVersion:r})&&o.push(`${c[0]}@${Es(c[0],c[1],r)}`);for(let c of Object.entries(e.devDependencies))Ss({currentDependencies:t,dependency:c,selectedRelease:e,targetVersion:r})&&o.push(`${c[0]}@${Es(c[0],c[1],r)}`);let n=Object.entries(t).find(jr),i=Object.entries(e.dependencies).find(jr);n&&i&&oe.default.lt(M(n[1]),M(i[1]))&&o.push(...cc({currentDependencies:t,selectedRemix:i}));let s=Object.entries(t).find(Lo),a=Object.entries(e.dependencies).find(Lo);return a&&(!s||oe.default.lt(M(s[1]),M(a[1])))&&o.push(...dc({currentDependencies:t,selectedReactRouter:a})),o}async function ac({appPath:e,selectedRelease:t,currentDependencies:r,targetVersion:o}){let n=[],i=[...t.removeDependencies||[],...t.removeDevDependencies||[]].filter(a=>a in r);i.length>0&&n.push({title:"Removing deprecated dependencies",task:async()=>{await lc({directory:e,packageManager:await be(e),args:i})}});let s=sc({selectedRelease:t,currentDependencies:r,targetVersion:o});s.length>0&&n.push({title:"Upgrading dependencies",task:async()=>{await et({directory:e,packageManager:await be(e),args:s})}}),n.length>0&&await ee(n,{})}async function lc({directory:e,packageManager:t,args:r}){if(r.length===0)return;await kn(t==="unknown"?"npm":t,[t==="npm"?"uninstall":t==="yarn"||t==="pnpm"||t==="bun"?"remove":"uninstall",...r],{cwd:e})}function cc({currentDependencies:e,selectedRemix:t}){let r=[];for(let[o,n]of Object.entries(e))jr([o,n])&&r.push(`${o}@${M(t[1])}`);return r}function dc({currentDependencies:e,selectedReactRouter:t}){let r=[],o=M(t[1]),n=["react-router","react-router-dom","@react-router/dev","@react-router/fs-routes"];for(let i of n)r.push(`${i}@${o}`);return r}function M(e){if(e==="next")return"next";if(e.match(/^[\^~]?0\.0\.0-next-([a-f0-9]+)-(\d+)$/))return e.replace(/^[\^~]?/,"");let r=oe.default.minVersion(e);if(!r)throw new E(`Invalid version: ${e}`);return r.version}async function uc(e,t){if(!t?.length)throw new E("No upgrade options available");let r=t.map((o,n)=>{let{version:i,title:s}=o,a=n===0?"(latest)":oe.default.patch(i)===0?"(major)":M(e)===M(i)?"(outdated)":"";return`${oe.default.major(i)}${oe.default.minor(i)}`,{label:`${i} ${a} - ${mi(s,54)}`,value:o}});return Re({message:`Available Hydrogen versions (current: ${e})`,choices:r,defaultValue:r[0]?.value})}async function fc({appPath:e,currentVersion:t,selectedRelease:r,instrunctionsFilePath:o}){let n=[...Object.entries(r.dependencies||{}).map(([p,g])=>`${p}@${g}`),...Object.entries(r.devDependencies||{}).map(([p,g])=>`${p}@${g}`)],i=[];if(typeof o=="string"){let p=`Upgrade instructions created at:
|
|
134
|
+
file://${o}`;i.push(p)}let s=`https://hydrogen.shopify.dev/releases/${r.version}`;i.push(`Release notes:
|
|
135
|
+
${s}`);let a=M(t),c=M(r.version),u=a===c,d=`${a} \u2192 ${c}`,m=u?`You've upgraded Hydrogen ${c} dependencies`:`You've upgraded from ${d}`,f=await be(e);return N({headline:m,customSections:[{title:"Updated dependencies",body:[{list:{items:n}}]},{title:"What\u2019s next?",body:[{list:{items:i}}]},{title:"Undo these upgrades?",body:[{list:{items:[`Run \`git restore . && git clean -df && ${f} i\``]}}]}].filter(Boolean)})}async function mc({appPath:e,selectedRelease:t,targetVersion:r}){let n=(await gn(x(e,"package.json")))["@shopify/hydrogen"];if(!n)throw new E("Hydrogen version not found in package.json");let i=M(n);i.match(/^0\.0\.0-next-[a-f0-9]+-\d+$/);let s=t.dependencies?.["@shopify/hydrogen"]==="next";if(!(r==="next"&&s)&&i!==t.version)throw new E(`Failed to upgrade to Hydrogen version ${t.version}`,`You are still on version ${i}`)}function jo(e){let{steps:t}=e,r=`### ${e.title} [#${e.id}](${e.pr})
|
|
136
|
+
`,o=t?.map((n,i)=>{let s=e.pr?`[#${e.id}](${e.pr})
|
|
137
|
+
`:"",c=t.length>1?`#### Step: ${i+1}. ${n.title} ${s}
|
|
138
|
+
`:`#### ${n.title.trim()}
|
|
139
|
+
`,u=n.info?`> ${n.info}
|
|
140
|
+
`:"",d=n.code?`${Buffer.from(n.code,"base64")}
|
|
141
|
+
`:"",m=e.docs?`[docs](${e.docs})
|
|
142
|
+
`:"";return`${c}${u}${m}${s}${d}`}).join(`
|
|
143
|
+
`);return`${r}
|
|
144
|
+
${o}`}async function pc({appPath:e,cumulativeRelease:t,currentVersion:r,selectedRelease:o}){let n="",{featuresMd:i,breakingChangesMd:s}=t.features.filter(g=>g.steps).reduce((g,w)=>(w.breaking?g.breakingChangesMd.push(jo(w)):g.featuresMd.push(jo(w)),g),{featuresMd:[],breakingChangesMd:[]}),a=t.fixes.filter(g=>g.steps).map(jo);if(!i.length&&!a.length&&!s.length){V({headline:"No upgrade instructions generated",body:"There are no additional upgrade instructions for this version."});return}let c=M(r),u=M(o.version);n=`upgrade-${c}-to-${u}.md`;let d=x(e,ks),f=`${`# Hydrogen upgrade guide: ${c} to ${u}`}
|
|
145
|
+
|
|
146
|
+
----
|
|
147
|
+
`;s.length&&(f+=`
|
|
148
|
+
## Breaking changes
|
|
149
|
+
|
|
150
|
+
${s.join(`
|
|
151
|
+
`)}
|
|
152
|
+
----
|
|
153
|
+
`),i.length&&(f+=`
|
|
154
|
+
## Features
|
|
155
|
+
|
|
156
|
+
${i.join(`
|
|
157
|
+
`)}
|
|
158
|
+
----
|
|
159
|
+
`),a.length&&(f+=`
|
|
160
|
+
${i.length?`----
|
|
161
|
+
|
|
162
|
+
`:""}## Fixes
|
|
163
|
+
|
|
164
|
+
${a.join(`
|
|
165
|
+
`)}`);let p=x(d,n);try{await qt(d)}catch{await Et(d)}if(!await G(p))await yo(p);else{if(await Ie({message:`A previous upgrade instructions file already exists for this version.
|
|
166
|
+
Do you want to overwrite it?`,defaultValue:!1}))await ve(`${p}.old`);else return;await yo(p)}return await J(p,f),`${ks}/${n}`}async function Is({targetPath:e}){try{let t=e?C(e):process.cwd(),{currentVersion:r,currentDependencies:o}=await xs({appPath:t});if(r.startsWith("workspace:")){V({headline:"Using monorepo @shopify/hydrogen dependency",body:"This project uses the workspace protocol for @shopify/hydrogen, so upgrade notices are skipped during local monorepo development."});return}if(oe.default.prerelease(r)||/^[a-z]+$/i.test(r))return;let i=await Ps(),{availableUpgrades:s,uniqueAvailableUpgrades:a}=Ts({releases:i.releases,currentVersion:r,currentDependencies:o});if(s.length===0||!s[0]?.version)return;let c=M(s[0].version),u=M(r),d=u===c,m=d?i.releases.findIndex(k=>M(k.version)!==u):i.releases.findIndex(k=>M(k.version)===u),f;if(m===-1){let k=i.releases.findIndex(y=>oe.default.lte(M(y.version),u));f=k===-1?i.releases:i.releases.slice(0,k)}else f=i.releases.slice(0,m);let p=Object.values([...f].reverse().reduce((k,y)=>(k[y.version]??=`${y.version} - ${y.title}`,k),{})).reverse().slice(0,5),g=Object.keys(a).length>1?`There are ${Object.keys(a).length} new @shopify/hydrogen versions available.`:"There's a new @shopify/hydrogen version available.",w=await W();V({headline:g,body:[`Current: ${r} | Latest: ${c}`+(d?" with updated dependencies":"")],customSections:[...p.length>0?[{title:`The next ${p.length} version(s) include`,body:[{list:{items:[...p,s.length>5?"...more":""].flat().filter(Boolean)}}].filter(Boolean)}]:[],{title:"Next steps",body:[{list:{items:[`Run \`${w} upgrade\` or \`${w} upgrade --version ${f[0]?.version??"<version>"}\``,"Read release notes at https://hydrogen.shopify.dev/releases"]}}]}]})}catch(t){let r=t;q({headline:r.message,body:r.tryMessage??void 0})}}l();l();import hc from"node:net";import gc from"node:os";var Mr=class extends Error{constructor(t){super(`${t} is locked`)}},mt={old:new Set,young:new Set},yc=1e3*15,Nr=1024,Lr=65535,Ft,wc=()=>{let e=gc.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let o of r)t.add(o.address);return t},Ds=e=>new Promise((t,r)=>{let o=hc.createServer();o.unref(),o.on("error",r),o.listen(e,()=>{let{port:n}=o.address();o.close(()=>{t(n)})})}),Os=async(e,t)=>{if(e.host||e.port===0)return Ds(e);for(let r of t)try{await Ds({port:e.port,host:r})}catch(o){if(!["EADDRNOTAVAIL","EINVAL"].includes(o.code))throw o}return e.port},vc=function*(e){e&&(yield*e),yield 0};async function Mo(e){let t,r=new Set;if(e&&(e.port&&(t=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 i of n){if(typeof i!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(i))throw new TypeError(`Number ${i} in the exclude option is not a safe integer and can't be used`)}r=new Set(n)}Ft===void 0&&(Ft=setTimeout(()=>{Ft=void 0,mt.old=mt.young,mt.young=new Set},yc),Ft.unref&&Ft.unref());let o=wc();for(let n of vc(t))try{if(r.has(n))continue;let i=await Os({...e,port:n},o);for(;mt.old.has(i)||mt.young.has(i);){if(n!==0)throw new Mr(n);i=await Os({...e,port:n},o)}return mt.young.add(i),i}catch(i){if(!["EADDRINUSE","EACCES"].includes(i.code)&&!(i instanceof Mr))throw i}throw new Error("No available ports found")}function _s(e,t){if(!Number.isInteger(e)||!Number.isInteger(t))throw new TypeError("`from` and `to` must be integer numbers");if(e<Nr||e>Lr)throw new RangeError(`'from' must be between ${Nr} and ${Lr}`);if(t<Nr||t>Lr)throw new RangeError(`'to' must be between ${Nr} and ${Lr}`);if(e>t)throw new RangeError("`to` must be greater than or equal to `from`");return function*(o,n){for(let i=o;i<=n;i++)yield i}(e,t)}function jt(e,t=100){return Mo({port:_s(e,e+t)})}l();var Ho=new Set,Uo;function $s({disableDepsOptimizer:e,showSuccessBanner:t,configFile:r,formatOptionsPromise:o}){return async function({optimizableDependency:i,stack:s}){let a=s.split(`
|
|
167
|
+
`)[0]??s,c=s.split(`
|
|
168
|
+
`).filter(d=>!d.includes("virtual:remix")).join(`
|
|
169
|
+
`),u="MiniOxygen encountered an error while running your app's entry point";if(i)if(e||!r){let d=new zt(`${u}:
|
|
170
|
+
|
|
171
|
+
${L.dim(a)}`,`Try adding '${L.yellow(i)}' to your Vite config in ssr.optimizeDeps.include`);d.stack=c,$e(d)}else Ho.has(i)||(Ho.add(i),setTimeout(()=>Ho.delete(i),2e3),kc(i,r,await o,c).then(()=>{setTimeout(()=>{$(`
|
|
172
|
+
Added '${L.yellow(i)}' to your Vite config in ssr.optimizeDeps.include
|
|
173
|
+
`)},200),clearTimeout(Uo),Uo=setTimeout(t,2e3)}).catch(d=>{clearTimeout(Uo),$e(d)}));else{let d=new zt(u+`:
|
|
174
|
+
|
|
175
|
+
`+L.dim(a));d.stack=c,$e(d)}}}var bc={rule:{pattern:"[$$$]",inside:{kind:"pair",stopBy:"end",has:{field:"key",regex:"include",stopBy:"end"},inside:{kind:"pair",stopBy:"end",has:{field:"key",regex:"optimizeDeps",stopBy:"end"},inside:{kind:"pair",stopBy:"end",has:{field:"key",regex:"ssr",stopBy:"end"}}}}}};async function kc(e,t,r,o){let n=sn(t).replace(/^\.m?/,""),i=await Kt(n);await je(t,r,s=>{let c=i.parse(s).root().find(bc);if(!c)throw new E(`The dependency '${L.yellow(e)}' needs to be optimized by Vite, but couldn't be added to the Vite config.`,`Add the following code manually to your Vite config:
|
|
176
|
+
|
|
177
|
+
`+L.yellow(`ssr: {optimizeDeps: {include: ['${e}']}}`));if(!!c.find({rule:{kind:"string_fragment",regex:`^${e}$`}})){let m=new zt(`A dependency related to '${L.yellow(e)}' might need to be optimized by Vite but couldn't be configured automatically:
|
|
178
|
+
|
|
179
|
+
${L.dim(o.split(`
|
|
180
|
+
`)[0])}`,"If your app doesn't load, check the following stack trace and try fixing the problem by adding the imported dependency to the `ssr.optimizeDeps.include` array in your Vite config file.");throw m.stack=o,m}let{start:d}=c.range();return s.slice(0,d.index+1)+`'${e}',`+s.slice(d.index+1)})}var Hr=class e extends D{static descriptionWithMarkdown=`Runs a Hydrogen storefront in a local runtime that emulates an Oxygen worker for development.
|
|
181
|
+
|
|
182
|
+
If your project is [linked](https://shopify.dev/docs/api/shopify-cli/hydrogen/hydrogen-link) to a Hydrogen storefront, then its environment variables will be loaded with the runtime.`;static description="Runs Hydrogen storefront in an Oxygen worker for development.";static flags={...b.path,...b.entry,...ye(b.port,{port:{default:void 0,required:!1}}),...b.codegen,"disable-virtual-routes":Nt.Flags.boolean({description:"Disable rendering fallback routes when a route file doesn't exist.",env:"SHOPIFY_HYDROGEN_FLAG_DISABLE_VIRTUAL_ROUTES",default:!1}),...b.debug,...b.inspectorPort,...b.env,...b.envBranch,...b.envFile,"disable-version-check":Nt.Flags.boolean({description:"Skip the version check when running `hydrogen dev`",default:!1,required:!1}),...b.customerAccountPush,...b.verbose,host:Nt.Flags.boolean({description:"Expose the server to the local network",default:!1,required:!1}),"disable-deps-optimizer":Nt.Flags.boolean({description:"Disable adding dependencies to Vite's `ssr.optimizeDeps.include` automatically",env:"SHOPIFY_HYDROGEN_FLAG_DISABLE_DEPS_OPTIMIZER",default:!1})};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd(),o={...U(t),customerAccountPush:t["customer-account-push"],path:r,cliConfig:this.config};if(!await tr(r))throw new E(xe);let{close:i}=await Ec(o);He(async()=>{await i()})}};async function Ec({entry:e,port:t,path:r,host:o,codegen:n=!1,codegenConfigPath:i,disableVirtualRoutes:s,disableDepsOptimizer:a=!1,envBranch:c,env:u,debug:d=!1,disableVersionCheck:m=!1,inspectorPort:f,customerAccountPush:p=!1,envFile:g,cliConfig:w,verbose:k}){process.env.NODE_ENV||(process.env.NODE_ENV="development"),k&&or(),nr()||it();let y=r??process.cwd(),v=W(y),h=gi(y,p,g),S=h.then(({fetchRemote:z,localVariables:le})=>gr({root:y,envBranch:c,envHandle:u,fetchRemote:z,localVariables:le,envFile:g}));d&&!f&&(f=await jt(Un));let P=await er(y);Ee&&await ve(x(y,"node_modules/.vite"));let _=Promise.resolve().then(()=>tt(y)),I=await P.createServer({root:y,clearScreen:!1,cacheDir:process.env.SHOPIFY_UNIT_TEST?x(y,".vite"):void 0,customLogger:process.env.SHOPIFY_UNIT_TEST?Object.assign(P.createLogger(),{info:z=>Ae("info",z),warn:z=>Ae("warn",z),error:z=>Ae("error",z)}):void 0,server:{port:t??Tt,host:o?!0:void 0,fs:Ee?{allow:[y,Ee]}:void 0},plugins:[{name:"hydrogen:cli",configResolved(z){Co(z)?.api?.registerPluginOptions({disableVirtualRoutes:s}),qn(z)?.api?.registerPluginOptions({debug:d,entry:e,envPromise:S.then(({allVariables:le})=>le),inspectorPort:f,logRequestLine:fi,entryPointErrorHandler:$s({disableDepsOptimizer:a,configFile:z.configFile,formatOptionsPromise:_,showSuccessBanner:()=>Rs({disableVirtualRoutes:s,debug:d,inspectorPort:f,finalHost:Ve,storefrontTitle:wt})})})},configureServer:z=>{p&&z.middlewares.use((le,uo,fo)=>{let vt=le.headers.host;vt?.includes(yr.ORIGINAL)&&(le.headers.host=vt.replace(yr.ORIGINAL,yr.REBRANDED)),fo()})}}]}),F=Co(I.config);if(!F)throw await I.close(),new E("Hydrogen plugin not found.","Add `hydrogen()` plugin to your Vite config.");F.api?.getPluginOptions?.();let R=(await pe(y)).remixConfig,T,j=n?()=>{T?.kill(0),T=Sr({rootDirectory:y,configFilePath:i,appDirectory:R?.appDirectory})}:void 0;j?.(),Ee&&Sc(I,Ee,j);let H=t??I.config.server.port??Tt,[A,Z]=await Promise.all([h.then(({customerAccountPush:z,storefrontId:le})=>z?yi(y,w,H,le):void 0),v,I.listen(H)]),Ce=new URL(I.resolvedUrls.local[0]??I.resolvedUrls.network[0]),Ve=A?.host||Ce.toString()||Ce.origin;ei({rootDirectory:y,host:Ve,cliCommand:Z});let{logInjectedVariables:Bt,allVariables:yt}=await S;Bt(),console.log(""),I.printUrls(),I.bindCLIShortcuts({print:!0}),console.log(`
|
|
183
|
+
`);let wt=(await h).storefrontTitle;return Rs({disableVirtualRoutes:s,debug:d,inspectorPort:f,finalHost:Ve,storefrontTitle:wt}),m||Is({targetPath:y}),p&&pi(yt)&&hi(Z),{getUrl:()=>Ve,async close(){T?.removeAllListeners("close"),T?.kill("SIGINT"),await Promise.allSettled([I.close(),A?.cleanup?.()]),I.watcher.close()}}}function Rs({disableVirtualRoutes:e,debug:t,inspectorPort:r,finalHost:o,storefrontTitle:n}){let i=[];e||i.push({body:vi(o)}),t&&r&&i.push({body:{warn:wi(r)}}),N({body:[`View ${n?L.cyan(n):"Hydrogen"} app:`,{link:{url:o}}],customSections:i})}function Sc(e,t,r){e.httpServer?.once("listening",()=>{e.watcher.add(t+"hydrogen/dist/vite/plugin.js"),e.watcher.add(t+"mini-oxygen/dist/vite/plugin.js"),e.watcher.add(t+"mini-oxygen/dist/vite/worker-entry.js"),e.watcher.add(t+"hydrogen-codegen/dist/esm/index.js");let o;e.watcher.on("change",async n=>{n.includes(t)&&(n.includes("/packages/hydrogen-codegen/")?r&&(r(),V({headline:"The Hydrogen Codegen source has been modified.",body:"The codegen process has been restarted."})):(await e.restart(!0),clearTimeout(o),o=setTimeout(()=>{console.log(""),V({headline:"The H2O Vite plugins have been modified.",body:"The Vite server has been restarted to reflect the changes."})},100)))})})}l();var Ur=class e extends D{static descriptionWithMarkdown="Lists all environments available on the linked Hydrogen storefront.";static description="List the environments on your linked Hydrogen storefront.";static flags={...b.path};async run(){let{flags:t}=await this.parse(e);await xc(t)}};async function xc({path:e=process.cwd()}){let[{session:t,config:r},o]=await Promise.all([he(e),W()]),n=await Ue({root:e,session:t,config:r,cliCommand:o});if(!n)return;r.storefront=n;let i=await lt(t,r.storefront.id);if(!i){ft({session:t,storefront:r.storefront,cliCommand:o});return}let s=i.environments.findIndex(c=>c.type==="PREVIEW"),a=i.environments.splice(s,1);i.environments.push(a[0]),$(Pc({environments:i.environments,storefrontTitle:r.storefront.title}).toString()),i.environments.forEach(({name:c,handle:u,branch:d,type:m,url:f})=>{se();let p=m==="PRODUCTION"?i.productionUrl:f;$(Y`${ze(c,u,d)}`.value),p&&$(Y` ${p}`.value)}),se()}var Pc=({environments:e,storefrontTitle:t})=>Vt(e,r=>`Showing ${r.length} environments for the Hydrogen storefront ${t}`,r=>`Showing 1 environment for the Hydrogen storefront ${t}`,()=>`There are no environments for the Hydrogen storefront ${t}`);l();function Cc(e){return/[{}@#\s"'\\$`|;&<>()!?*\[\]]/.test(e)||/[\x00-\x1F\x7F]/.test(e)}function Tc(e){return Cc(e)?`"${e.replaceAll("\\","\\\\").replaceAll('"','\\"').replaceAll(`
|
|
184
|
+
`,"\\n").replaceAll("\r","\\r").replaceAll(" ","\\t")}"`:e}var Br=class e extends D{static descriptionWithMarkdown="Pulls environment variables from the linked Hydrogen storefront and writes them to an `.env` file.";static description="Populate your .env with variables from your Hydrogen storefront.";static flags={...b.env,...b.envBranch,...b.envFile,...b.path,...b.force};async run(){let{flags:t}=await this.parse(e);await Ic({...U(t)})}};async function Ic({env:e,envBranch:t,path:r=process.cwd(),envFile:o,force:n}){let[{session:i,config:s},a]=await Promise.all([he(r),W()]),c=await Ue({root:r,session:i,config:s,cliCommand:a});if(!c)return;if(s.storefront=c,e||t){let w=(await lt(i,s.storefront.id))?.environments||[];e?at(w,e):t&&(e=It(w,t).handle)}let u=await hr(i,s.storefront.id,e);if(!u){ft({session:i,storefront:s.storefront,cliCommand:a});return}if(!u.environmentVariables.length){$("No environment variables found.");return}let d=u.environmentVariables;if(!d.length)return;let m=L.whiteBright(o),f=C(r,o),p={};if(d.forEach(({isSecret:w,key:k,value:y})=>{p[k]=w?'""':Tc(y)}),await G(f)&&!n){let w=await de(f),k=Do(w,p);if(w===k){V({body:`No changes to your ${m} file`});return}let y=wr(w,k);if(!await Ie({confirmationMessage:"Yes, confirm changes",cancellationMessage:"No, make changes later",message:Y`We'll make the following changes to your ${m} file:
|
|
185
|
+
|
|
186
|
+
${ke.linesDiff(y)}
|
|
187
|
+
Continue?`.value}))return;await J(f,k)}else{let w=Do(null,p);await J(f,w)}d.some(({isSecret:w})=>w)&&q({body:`${s.storefront.title} contains environment variables marked as secret, so their values weren\u2019t pulled.`}),N({body:["Changes have been made to your",{filePath:m},"file"]})}l();l();var Dc=`#graphql
|
|
188
|
+
mutation PushVariables(
|
|
189
|
+
$storefrontId: ID!,
|
|
190
|
+
$environmentId: ID!,
|
|
191
|
+
$environmentVariablesInput: [HydrogenStorefrontEnvironmentVariableInput!]!,
|
|
192
|
+
) {
|
|
193
|
+
hydrogenStorefrontEnvironmentVariableBulkReplace(
|
|
194
|
+
storefrontId: $storefrontId,
|
|
195
|
+
environmentId: $environmentId,
|
|
196
|
+
environmentVariablesInput: $environmentVariablesInput,
|
|
197
|
+
) {
|
|
198
|
+
userErrors {
|
|
199
|
+
code
|
|
200
|
+
message
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
`;async function As(e,t,r,o){let{hydrogenStorefrontEnvironmentVariableBulkReplace:n}=await ot(Dc,e,{storefrontId:t,environmentId:r,environmentVariablesInput:o}),{userErrors:i}=n;return{userErrors:i}}var Vr=class e extends D{static description="Push environment variables from the local .env file to your linked Hydrogen storefront.";static flags={...b.env,...b.envFile,...b.path};async run(){let{flags:t}=await this.parse(e);await Oc({...U(t)})}};async function Oc({env:e,envFile:t,path:r=process.cwd()}){let o,n=C(r,t),{variables:i}=await mr(n),[{session:s,config:a},c]=await Promise.all([he(r),W()]),u=await Ue({root:r,session:s,config:a,cliCommand:c});if(!u)return;a.storefront=u;let{environments:d}=await lt(s,a.storefront.id)??{};if(!d)throw new E("Failed to fetch environments");let m=pr(d);if(m.length===0)throw new E("No environments found");if(e)o=at(m,e);else{let v=[...m.map(({id:S,name:P,branch:_,handle:I})=>({label:ze(P,I,_),value:S}))],h=await Re({message:"Select an environment to overwrite its environment variables:",choices:v});o=m.find(({id:S})=>S===h)}let{environmentVariables:f=[]}=await hr(s,a.storefront.id,o.handle)??{},g=f.filter(({isSecret:v,readOnly:h})=>!v&&!h).sort((v,h)=>v.key.localeCompare(h.key)).map(({key:v,value:h})=>Oo(v,h)).join(`
|
|
205
|
+
`)+`
|
|
206
|
+
`,w=Object.keys(i).sort((v,h)=>v.localeCompare(h)).reduce((v,h)=>{let{isSecret:S,readOnly:P}=f.find(_=>_.key===h)??{};return S||P?v:[...v,Oo(h,i[h])]},[]).join(`
|
|
207
|
+
`)+`
|
|
208
|
+
`;if(!o.name)throw new E("Missing environment name");let k=f.reduce((v,{isSecret:h,readOnly:S,key:P})=>{if(!h&&!S)return v;let _=i[P],I=f.find(F=>F.key===P);return _===I?.value?v:[...v,P]},[]);if(k.length&&B(`Variables that are read only or contain secret values cannot be pushed from the CLI: ${k.join(", ")}.
|
|
209
|
+
`),w===g){V({body:"No changes to your environment variables."});return}else{let v=wr(g,w);if(!await Ie({confirmationMessage:"Yes, confirm changes",cancellationMessage:"No, make changes later",message:Y`We'll make the following changes to your environment variables for ${o.name}:
|
|
210
|
+
|
|
211
|
+
${ke.linesDiff(v)}
|
|
212
|
+
Continue?`.value}))return}if(!o.id)throw new E("Missing environment ID");let{userErrors:y}=await As(s,a.storefront.id,o.id,Object.entries(i).map(([v,h])=>({key:v,value:h})));if(y.length)throw new E("Failed to upload and save environment variables.",y[0]?.message);N({body:`Environment variables push to ${o.name??"Preview"} was successful.`})}l();l();var pt=Q(me(),1);var _e=class e extends D{static descriptionWithMarkdown="Generates a set of default routes from the starter template.";static description="Generates a standard Shopify route.";static flags={adapter:pt.Flags.string({description:"Remix adapter used in the route. The default is `@shopify/remix-oxygen`.",env:"SHOPIFY_HYDROGEN_FLAG_ADAPTER"}),typescript:pt.Flags.boolean({description:"Generate TypeScript files",env:"SHOPIFY_HYDROGEN_FLAG_TYPESCRIPT"}),"locale-param":pt.Flags.string({description:"The param name in Remix routes for the i18n locale, if any. Example: `locale` becomes ($locale).",env:"SHOPIFY_HYDROGEN_FLAG_ADAPTER"}),...b.force,...b.path};static hidden;static args={routeName:pt.Args.string({name:"routeName",description:`The route to generate. One of ${To.join()}.`,required:!0,options:To,env:"SHOPIFY_HYDROGEN_ARG_ROUTE"})};async run(){let{flags:t,args:{routeName:r}}=await this.parse(e),o=t.path?C(t.path):process.cwd();await _c({...t,directory:o,routeName:r,localePrefix:t["locale-param"]})}};async function _c(e){let{routes:t}=await ni({...e,v1RouteConvention:oi()}),r=3+t.reduce((n,i)=>Math.max(n,i.destinationRoute.length),0),o=t.filter(({operation:n})=>n!=="skipped").length;N({headline:`${o} of ${t.length} route${t.length>1?"s":""} generated`,body:{list:{items:t.map(({operation:n,destinationRoute:i})=>i.padEnd(r)+L.dim(`[${n}]`))}}})}var Gr=class extends D{static description="Shortcut for `hydrogen generate`. See `hydrogen generate --help` for more information.";static strict=!1;static hidden=!0;async run(){let[t,...r]=this.argv;if(t==="r"||t==="route")return new _e(r,this.config).run();throw new Error(`Invalid command argument "${t}".`)}};l();var qr=class e extends D{static description="Generates all supported standard shopify routes.";static hidden;static flags=_e.flags;async run(){let{flags:t}=await this.parse(e);await _e.run(["all",...Object.entries(t).map(([r,o])=>o===!0?`--${r}`:`--${r}=${o}`)])}};l();var Be=Q(me(),1);l();import{fileURLToPath as $c}from"node:url";var Lt={cli:"@shopify/cli",cliHydrogen:"@shopify/cli-hydrogen",createApp:"@shopify/create-hydrogen"};async function Fs(){if(De&&!process.env.SHOPIFY_UNIT_TEST)return;let{content:e}=await vn($c(import.meta.url)).catch(()=>({content:void 0})),t=e?.name,r=e?.version;if(!t||!r||!Object.values(Lt).some(i=>i===t)||r.includes("next")||r.includes("experimental")||r.includes("snapshot"))return;let o=await yn(t,r);if(!o)return;let n=[{link:{label:"Hydrogen releases",url:"https://github.com/Shopify/hydrogen/releases"}}];return t===Lt.cli&&n.push({link:{label:"Global CLI reference",url:"https://shopify.dev/docs/api/shopify-cli/"}}),i=>{i??=hn(),(i==="unknown"||!i)&&(i=pn()),i==="unknown"&&(i="npm");let s=t===Lt.cli?`Please install the latest Shopify CLI version with \`${i==="yarn"?`yarn global add ${Lt.cli}`:`${i} install -g ${Lt.cli}`}\` and try again.`:`Please use the latest version with \`${i} create @shopify/hydrogen@latest\``;return V({headline:"Upgrade available",body:`Version ${o} of ${t} is now available.
|
|
213
|
+
You are currently running v${r}.
|
|
214
|
+
|
|
215
|
+
`+s,reference:n}),{currentVersion:r,newVersion:o}}}l();l();import{cp as Rc}from"node:fs/promises";async function js(e,t){let r=e.mockShop?"mock":await Re({message:"Connect to Shopify",choices:[{label:"Use sample data from mock.shop (You can connect a Shopify account later)",value:"mock"},{label:"Link your Shopify account",value:"link"}],defaultValue:"mock",abortSignal:t.signal}),o=r==="link"?await ai(t):void 0,n=await lr({...e,storefrontInfo:o,controller:t});if(!n)return;r==="mock"&&(n.storefrontTitle="Mock.shop");let i=fr(t,n),s=o&&!o.id&&Qn(o.session,o.title).then(async({storefront:T,jobId:j})=>(j&&await Kn(o.session,j),T)).catch(i),a=await Fn(),c=Rc(a,n.directory,{force:!0,recursive:!0,filter:T=>!/^(app(\/|$)|dist(\/|$)|node_modules(\/|$)|server\.ts$|\.shopify(\/|$))/i.test(ne(a,T))}).then(()=>sr({rootDirectory:n.directory,appDirectory:x(n.directory,"app"),typescript:!0})).catch(i),u={create:"Creating storefront",setup:`Setting up ${e.quickstart?"Quickstart ":""}project`,install:"Installing dependencies. This could take a few minutes"},d=[{title:u.create,task:async()=>{await s}},{title:u.setup,task:async()=>{await c}}],m=await W(),f=`# The variables added in this file are only available locally in MiniOxygen.
|
|
216
|
+
# Run \`${m} link\` to also inject environment variables from your storefront,
|
|
217
|
+
# or \`${m} env pull\` to populate this file.`;c=c.then(()=>{let T=[je(x(n.directory,"package.json"),!1,H=>(H=Ac(H),H.replace(/"name": "[^"]+"/,`"name": "${ln(o?.title??n.name)}"`)))],j;return o?(T.push(Yn(n.directory,o),J(x(n.directory,".env"),f)),o.id?j={id:o.id,title:o.title}:s&&T.push(s.then(H=>{j=H}))):r==="mock"&&T.push(J(x(n.directory,".env"),f+`
|
|
218
|
+
`+[["SESSION_SECRET","foobar"]].map(([H,A])=>`${H}="${A}"`).join(`
|
|
219
|
+
`)+`
|
|
220
|
+
`)),Promise.all(T).then(()=>{if(j)return zn(n.directory,j)}).catch(i)});let{language:p,transpileProject:g}=await cr(n.directory,t,e.language);c=c.then(()=>g().catch(i)).then(()=>e.git?ur(n.directory):void 0);let{setupCss:w,cssStrategy:k}=await li(n.directory,t,e.styling);k&&(c=c.then(()=>w().catch(i)).then(()=>e.git?Ye(n.directory,"Setup "+Ct[k]):void 0));let{packageManager:y,shouldInstallDeps:v,installDeps:h}=await dr(n.directory,t,e.packageManager,e.installDeps),S={language:p,packageManager:y,cssStrategy:k,depsInstalled:!1,cliCommand:await W("",y)};if(v){let T=c.then(async()=>{try{if(await h(),S.depsInstalled=!0,p==="ts")try{await xt("npx react-router typegen",{cwd:n.directory})}catch{B("Failed to generate React Router types. You may need to run `npx react-router typegen` manually.")}}catch(j){S.depsError=j}});d.push({title:u.install,task:async()=>{await T}})}let{createShortcut:P,showShortcutBanner:_}=await ar(t,S.cliCommand,e.shortcut);P&&(c=c.then(async()=>{await P()&&(S.cliCommand=We)}),_()),e.quickstart?console.log(`
|
|
221
|
+
`):N({headline:[{userInput:o?.title??n.name},"is ready to build."]});let{i18nStrategy:I,setupI18n:F}=await si(t,S.cliCommand,e.i18n),{setupRoutes:R}=ir(t);return S.i18n=I,c=c.then(async()=>{await F({rootDirectory:n.directory,contextCreate:p==="ts"?"app/lib/context.ts":"app/lib/context.js"}).then(()=>e.git?Ye(n.directory,`Setup markets support using ${I}`):void 0).catch(T=>{S.i18nError=T}),await R(n.directory,p,{i18nStrategy:I,overwriteFileDeps:!1}).then(async T=>{if(S.routes=T,p==="ts"&&S.depsInstalled)try{await xt("npx react-router typegen",{cwd:n.directory})}catch{B("Failed to generate React Router types after route generation. You may need to run `npx react-router typegen` manually.")}if(e.git&&T)return Ye(n.directory,"Generate routes for core functionality")}).catch(T=>{S.routesError=T})}),await ee(d),e.git&&await Ye(n.directory,"Lockfile"),await st(n,S),{...n,...S}}function Ac(e){let t=e.match(/^\s+"@shopify\/hydrogen":\s+"[^"]+",\n/m)?.[0];if(t&&/"0\.0\.0-\w+-/.test(t)){let r=t.replace("hydrogen","cli-hydrogen");e=e.replace(t,r+t)}return e}l();import{readdir as ja}from"node:fs/promises";l();var _a=Q(da(),1),$a=Q(Oa(),1);import Xe from"node:path";import{pipeline as Sd}from"stream/promises";var xd="https://api.github.com/repos/shopify/hydrogen/releases/latest",Ra=e=>e===403?"If you are using a VPN, WARP, or similar service, consider disabling it momentarily.":void 0;async function Pd(e){let t=await ie(xd,{signal:e});if(!t.ok||t.status>=400)throw new E(`Failed to fetch the latest release information. Status ${t.status} ${t.statusText.replace(/\.$/,"")}.`,Ra(t.status));let r=await t.json();return{version:r.name.split("/").pop()??r.name,url:r.tarball_url}}async function Cd(e,t,r){let o=await ie(e,{signal:r});if(!o.ok||o.status>=400)throw new E(`Failed to download the latest release files. Status ${o.status} ${o.statusText}}`,Ra(o.status));await Sd(o.body,(0,_a.default)(),(0,$a.extract)(t,{strip:1,filter:n=>(n=n.replace(t,""),!n.startsWith(Xe.normalize("/templates/"))&&!n.startsWith(Xe.normalize("/examples/")))}))}async function Aa({signal:e}={}){if(De&&process.env.FORCE_TEMPLATES_SOURCE!=="remote"){let t=Xe.dirname(jn());return{version:"local",templatesDir:t,examplesDir:Xe.resolve(t,"..","examples")}}try{let{version:t,url:r}=await Pd(e),o=await Ge("internal-templates");await G(o)||await Et(o);let n=Xe.join(o,t);return await G(n)||await Cd(r,n,e),{version:t,templatesDir:Xe.join(n,"templates"),examplesDir:Xe.join(n,"examples")}}catch(t){let r=t;throw new E(`Could not download Hydrogen templates from GitHub.
|
|
222
|
+
Please check your internet connection and the following error:
|
|
223
|
+
|
|
224
|
+
`+r.message,r.tryMessage)}}async function Fa(e,t){let r=bi(e);if(r.isErr())throw new E(r.error.message);let o=await Ge("external-templates");await G(o)||await Et(o);let n=r.value,i=x(o,n.full.replace(/^https?:\/\//,"").replace(/[^\w]+/,"_"));return await G(i)&&await wo(i,{force:!0}),await Tn({repoUrl:n.full,destination:i,shallow:!0}),await wo(x(i,".git"),{force:!0}),{templateDir:i}}var Na="shopify/hydrogen-demo-store";async function La(e,t){let r=e.template==="demo-store"?Na:e.template,o=await lr({...e,controller:t});if(!o)return;let n=fr(t,o),i=r.includes("/")?Td(r,t.signal).catch(n):Id(r,t.signal).catch(n),s=await i;if(t.signal.aborted)return;let a=Promise.resolve().then(async()=>{if(t.signal.aborted)return;let{sourcePath:k}=s;await Gt(k,o.directory)}).catch(n),c=await G(x(s.sourcePath,"tsconfig.json")),{language:u,transpileProject:d}=c?await cr(o.directory,t,e.language):{language:"js",transpileProject:()=>Promise.resolve()};a=a.then(()=>d().catch(n)).then(()=>e.git?ur(o.directory):void 0);let{packageManager:m,shouldInstallDeps:f,installDeps:p}=await dr(o.directory,t,e.packageManager,e.installDeps),g={language:u,packageManager:m,depsInstalled:!1,cliCommand:await W("",m)},w=[{title:"Downloading template",task:async()=>{await i}},{title:"Setting up project",task:async()=>{await a}}];if(f&&w.push({title:"Installing dependencies. This could take a few minutes",task:async()=>{try{await p(),g.depsInstalled=!0}catch(k){g.depsError=k}}}),!t.signal.aborted)return await ee(w),e.git&&await Ye(o.directory,"Lockfile"),await st(o,g),V({headline:`Your project will display inventory from ${e.template.endsWith(Na)?"the Hydrogen Demo Store":"Mock.shop"}.`,body:`To connect this project to your Shopify store\u2019s inventory, update \`${o.name}/.env\` with your store ID and Storefront API key.`}),{...o,...g}}async function Td(e,t){let{templateDir:r}=await Fa(e,t);return{sourcePath:r}}async function Id(e,t){let{templatesDir:r,examplesDir:o}=await Aa({signal:t}),n=x(r,"skeleton"),i=x(r,e),s=x(o,e);if(await G(i))return{skeletonPath:n,sourcePath:i};if(await G(s))return{skeletonPath:n,sourcePath:s};let a=(await Promise.all([ja(o),ja(r)]).catch(()=>[])).flat().filter(c=>c!=="skeleton"&&!c.endsWith(".md")).concat("demo-store").sort();throw new E(`Unknown value in \`--template\` flag "${e}".
|
|
225
|
+
Skip the flag or provide the name of a template or example in the Hydrogen repository or a URL to a git repository.`,a.length===0?"":{list:{title:"Available templates:",items:a}})}async function Ma(e){let t=new Yt;try{let r=e.template;return r?await La({...e,template:r},t):await js(e,t)}catch(r){throw t.abort(),r}}var Dd={f:"force"},Xr=class e extends D{static descriptionWithMarkdown="Creates a new Hydrogen storefront.";static description="Creates a new Hydrogen storefront.";static flags={...b.force,path:Be.Flags.string({description:"The path to the directory of the new Hydrogen storefront.",env:"SHOPIFY_HYDROGEN_FLAG_PATH"}),language:Be.Flags.string({description:"Sets the template language to use. One of `js` or `ts`.",choices:Object.keys(ii),env:"SHOPIFY_HYDROGEN_FLAG_LANGUAGE"}),template:Be.Flags.string({description:"Scaffolds project based on an existing template or example from the Hydrogen repository.",env:"SHOPIFY_HYDROGEN_FLAG_TEMPLATE"}),...b.installDeps,"mock-shop":Be.Flags.boolean({description:"Use mock.shop as the data source for the storefront.",env:"SHOPIFY_HYDROGEN_FLAG_MOCK_DATA"}),...b.styling,...b.markets,...b.shortcut,git:Be.Flags.boolean({description:"Init Git and create initial commits.",env:"SHOPIFY_HYDROGEN_FLAG_GIT",default:!0,allowNo:!0}),quickstart:Be.Flags.boolean({description:"Scaffolds a new Hydrogen project with a set of sensible defaults. Equivalent to `shopify hydrogen init --path hydrogen-quickstart --mock-shop --language js --shortcut --markets none`",env:"SHOPIFY_HYDROGEN_FLAG_QUICKSTART",default:!1}),"package-manager":Be.Flags.string({env:"SHOPIFY_HYDROGEN_FLAG_PACKAGE_MANAGER",hidden:!0,options:["npm","yarn","pnpm","unknown"]})};async run(){let{flags:t}=await this.parse(e);await Od(U(t))}};async function Od({markets:e,...t}=Bn(process.argv,Dd)){if(Rn(),!t.i18n&&e&&(t.i18n=e),t.i18n&&!Po.includes(t.i18n))throw new E(`Invalid URL structure strategy: ${t.i18n}. Must be one of ${Po.join(", ")}`);if(t.styling&&!Eo.includes(t.styling))throw new E(`Invalid styling strategy: ${t.styling}. Must be one of ${Eo.join(", ")}`);t.git??=!0,t.quickstart&&(t.i18n??="none",t.installDeps??=!0,t.language??="js",t.mockShop??=!0,t.path??="./hydrogen-quickstart",t.shortcut??=!0,t.styling??="none");let r=await Fs();return r&&r(t.packageManager),Ma(t)}l();l();var _d=`#graphql
|
|
226
|
+
query ListStorefronts {
|
|
227
|
+
hydrogenStorefronts {
|
|
228
|
+
id
|
|
229
|
+
title
|
|
230
|
+
productionUrl
|
|
231
|
+
currentProductionDeployment {
|
|
232
|
+
id
|
|
233
|
+
createdAt
|
|
234
|
+
commitMessage
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
`;async function Ha(e){let{hydrogenStorefronts:t}=await ot(_d,e);return t.map(r=>({...r,parsedId:nt(r.id)}))}var Zr=class e extends D{static descriptionWithMarkdown="Lists all remote Hydrogen storefronts available to link to your local development environment.";static description="Returns a list of Hydrogen storefronts available on a given shop.";static flags={...b.path};async run(){let{flags:t}=await this.parse(e);await $d(t)}};async function $d({path:e=process.cwd()}){let{session:t}=await he(e),r=await Ha(t);r.length>0?(se(),$(Fd({storefronts:r,shop:t.storeFqdn}).toString()),r.forEach(({currentProductionDeployment:o,id:n,productionUrl:i,title:s})=>{se(),$(Y`${L.whiteBright(s)} ${L.dim(`(id: ${nt(n)})`)}`.value),i&&$(Y` ${L.whiteBright(i)}`.value),o&&$(Y` ${L.dim(Ad(o))}`.value)})):V({headline:"Hydrogen storefronts",body:"There are no Hydrogen storefronts on your Shop.",nextSteps:[`Ensure you are logged in to the correct shop (currently: ${t.storeFqdn})`,`Create a new Hydrogen storefront: Run \`${await W(e)} link\` or visit ${ps(t)}`]})}var Rd=new Intl.DateTimeFormat("default",{year:"numeric",month:"numeric",day:"numeric"});function Ad(e){let t="";if(!e)return t;if(t+=Rd.format(new Date(e.createdAt)),e.commitMessage){let r=e.commitMessage.split(/\n/)[0];t+=`, ${r}`}return t}var Fd=({storefronts:e,shop:t})=>Vt(e,r=>`Showing ${r.length} Hydrogen storefronts for the store ${t}`,r=>`Showing 1 Hydrogen storefront for the store ${t}`);l();var eo=class e extends D{static descriptionWithMarkdown="Logs in to the specified shop and saves the shop domain to the project.";static description="Login to your Shopify account.";static flags={...b.path,...b.shop};async run(){let{flags:t}=await this.parse(e);await jd(t)}};async function jd({path:e=process.cwd(),shop:t}){se(),Zn(!0);let{config:r}=await he(e,t??!0);ri(r)}l();var to=class e extends D{static descriptionWithMarkdown="Log out from the current shop.";static description="Logout of your local session.";static flags={...b.path};async run(){let{flags:t}=await this.parse(e);await Nd(t)}};async function Nd({path:e=process.cwd()}){se(),await ti(e),N({body:"You are logged out from Shopify."})}l();var en=Q(me(),1);l();async function Ua(e){let{startWorkerdServer:t}=await import("./workerd-L2EJKIAQ.js");return t(e)}var ro=class e extends D{static descriptionWithMarkdown="Runs a server in your local development environment that serves your Hydrogen app's production build. Requires running the [build](https://shopify.dev/docs/api/shopify-cli/hydrogen/hydrogen-build) command first.";static description="Runs a Hydrogen storefront in an Oxygen worker for production.";static flags={...b.path,...b.port,...b.env,...b.envBranch,...b.envFile,...b.inspectorPort,...b.debug,...b.verbose,build:en.Flags.boolean({description:"Builds the app before starting the preview server."}),watch:en.Flags.boolean({description:"Watches for changes and rebuilds the project.",dependsOn:["build"]}),...ye(b.entry,{entry:{dependsOn:["build"]}}),...ye(b.codegen,{codegen:{dependsOn:["build"]}})};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd(),{close:o}=await Ld({...U(t),directory:r});He(async()=>{await o()})}};async function Ld({port:e,directory:t,env:r,envBranch:o,inspectorPort:n,debug:i,verbose:s,build:a=!1,watch:c=!1,codegen:u=!1,codegenConfigPath:d,entry:m,envFile:f}){process.env.NODE_ENV||(process.env.NODE_ENV=c?"development":"production"),s&&or(),nr()||it();let{root:p,buildPath:g,buildPathWorkerFile:w,buildPathClient:k}=Se(t),y=await rt(p);if(y)throw new E(xe);let v,h=_t(),P=a?await Je({...{directory:p,entry:m,disableRouteWarning:!1,lockfileCheck:!1,sourcemap:!0,bundleStats:!1,useCodegen:u,codegenConfigPath:d},watch:c,async onServerBuildFinish(){h.state==="pending"?h.resolve():$("\u{1F3D7}\uFE0F Project rebuilt. Reloading server..."),await v?.reload()}}):h.resolve();y||(w=(await pe(p).catch(()=>null))?.serverOutFile??x(g,"server","index.js"));let{shop:_,storefront:I}=await rr(p),F=!!_&&!!I?.id,{allVariables:R,logInjectedVariables:T}=await gr({root:p,fetchRemote:F,envBranch:o,envHandle:r,envFile:f});e||(e=await jt(Tt));let j=await jt(e+100);return await h.promise,T(),v=await Ua({root:p,appPort:e,assetsPort:j,env:R,buildPathClient:k,buildPathWorkerFile:w,inspectorPort:n,debug:i,watch:c}),v.showBanner({mode:"preview",headlinePrefix:c?"Watching for changes. ":""}),{async close(){await Promise.allSettled([v.close(),P?.close()])}}}l();var oo=class e extends D{static description="Scaffold routes and core functionality.";static flags={...b.path,...b.force,...b.markets,...b.shortcut,...ye(b.installDeps,{"install-deps":{default:!0}})};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd();await Md({...U(t),directory:r})}};async function Md(e){let t=new Yt,{rootDirectory:r,appDirectory:o}=await Ne(e.directory),n=Ze(r),i=W(),s=Promise.resolve(),a=[{title:"Setting up project",task:async()=>{await s}}],c=e.markets?e.markets:await Zt({abortSignal:t.signal,extraChoices:{none:"Set up later"}}),u=c==="none"?void 0:c,{setupRoutes:d}=ir(t),m,f=await An(".."),[p,g]=await Promise.all([G(x(r,"tsconfig.json")),St("*.d.ts",{cwd:f})]);s=s.then(()=>Promise.all([...g.map(v=>Gt(x(f,v),C(r,v))),sr({rootDirectory:r,appDirectory:o,typescript:p})])).then(async()=>{m=await d(r,p?"ts":"js",{i18nStrategy:u,overwriteFileDeps:!0})}),u&&(s=s.then(()=>Xt(u,{rootDirectory:r})));let w=await Promise.resolve(i),{createShortcut:k,showShortcutBanner:y}=await ar(t,w,e.shortcut);!u&&!k||(k&&(s=s.then(async()=>{await k()&&(w=We)}),y()),await ee(a),await st({location:n,name:n,directory:r},{cliCommand:w,depsInstalled:!0,packageManager:"npm",i18n:u,routes:m}))}l();var Ba=Q(me(),1);var no=class e extends D{static descriptionWithMarkdown="Adds support for certain CSS strategies to your project.";static description="Setup CSS strategies for your project.";static flags={...b.path,...b.force,...ye(b.installDeps,{"install-deps":{default:!0}})};static args={strategy:Ba.Args.string({name:"strategy",description:`The CSS strategy to setup. One of ${ko.join()}`,options:ko})};async run(){let{flags:t,args:r}=await this.parse(e),o=t.path?C(t.path):process.cwd();await Hd({...U(t),strategy:r.strategy,directory:o})}};async function Hd({strategy:e,directory:t,force:r=!1,installDeps:o=!0}){let n=await pe(t).catch(()=>null);if(!n)throw new E("No Vite config found. This command is only supported in Vite projects.");let{remixConfig:i}=n,s=e||await Mn();if(s==="css-modules"||s==="postcss"){N({headline:`Vite works out of the box with ${Ct[s]}.`,body:`See the Vite documentation for more information:
|
|
239
|
+
${So[s]}`});return}let a=await Ln(s,i,r);if(!a)return;let{workPromise:c,generatedAssets:u,needsInstallDeps:d}=a,m=[{title:"Updating files",task:async()=>{await c}}],f=!1;if(o&&d){let p=be(i.rootDirectory);m.push({title:"Installing new dependencies",task:async()=>{let g=await p;f=g==="npm"||g==="unknown",await et({directory:i.rootDirectory,packageManager:g,args:[]})}})}await ee(m),N({headline:`${Ct[s]} setup complete.`,body:(u.length>0?`You can now modify CSS configuration in the following files:
|
|
240
|
+
`+u.map(p=>` - ${p}`).join(`
|
|
241
|
+
`)+`
|
|
242
|
+
`:"")+`
|
|
243
|
+
For more information, visit ${So[s]}`}),d&&f&&s==="tailwind"&&q({body:[`Due to a bug in NPM, you might need to reinstall dependencies again.
|
|
244
|
+
Run`,{command:"npm install"}]})}l();var Va=Q(me(),1);var io=class e extends D{static descriptionWithMarkdown="Adds support for multiple [markets](https://shopify.dev/docs/custom-storefronts/hydrogen/markets) to your project by using the URL structure.";static description="Setup support for multiple markets in your project.";static flags={...b.path};static args={strategy:Va.Args.string({name:"strategy",description:`The URL structure strategy to setup multiple markets. One of ${xo.join()}`,options:xo})};async run(){let{flags:t,args:r}=await this.parse(e),o=t.path?C(t.path):process.cwd();await Ud({...U(t),strategy:r.strategy,directory:o})}};async function Ud({strategy:e,directory:t}){let r=Ne(t),o=e||await Zt(),n=await r;await ee([{title:"Updating files",task:async()=>{await Xt(o,n)}}]),N({headline:`Makerts support setup complete with strategy ${Hn[o].toLocaleLowerCase()}.`,body:`You can now modify the supported locales in ${n.serverEntryPoint??"your server entry file."}
|
|
245
|
+
`})}l();var so=class e extends D{static description="EXPERIMENTAL: Upgrades the project to use Vite.";static flags={...b.path};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd();await Vd({...U(t),directory:r})}},Bd=`export default {
|
|
246
|
+
plugins: {
|
|
247
|
+
tailwindcss: {},
|
|
248
|
+
autoprefixer: {},
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
`;async function Vd({directory:e}){if(se(),await Gn(e))throw new E("This project already has a Vite config file.");let[t,r,o]=await Promise.all([Vn(e),wn(x(e,"package.json")),tt(e)]),n=t.server||"server.js",i=n.endsWith(".ts"),s=i?"tsx":"jsx",a=await Ge("vite"),c=!!t.tailwind,u=C(e,"postcss.config.js"),d=()=>{},m=Promise.all([ve(C(e,"remix.config.js")).catch(d),bo(C(e,"remix.env.d.ts"),C(e,"env.d.ts")).then(()=>je(C(e,"env.d.ts"),!1,f=>f.replace('types="@remix-run/dev"','types="vite/client"'))).catch(d),bo(C(e,".eslintrc.js"),C(e,".eslintrc.cjs")).catch(d),de(C(e,"postcss.config.js")).then(async f=>{let p=f.includes("tailwindcss"),w=f.includes("module.exports")||f.includes("exports.")||f.includes("require(")?u.replace(".js",".cjs"):u;return!p&&c&&(f=await Pt(f.replace(/(plugins:\s+{)/,`$1
|
|
252
|
+
tailwindcss: {},`),o,w)),J(w,f)}).catch(async()=>{if(c&&!await G(u)&&!await G(u.replace(".js",".cjs")))return J(u,Bd)}).catch(d),Nn(a,e,{onResult(f){return f.dependencies&&delete f.dependencies["@remix-run/css-bundle"],f.devDependencies&&f.devDependencies["@vanilla-extract/css"]&&(f.devDependencies["@vanilla-extract/vite-plugin"]="^4.0.0",f.devDependencies=Object.keys(f.devDependencies).sort().reduce((p,g)=>(p[g]=f.devDependencies?.[g],p),{})),f}}),de(C(a,"vite.config.js")).then(async f=>{r.devDependencies?.["@vanilla-extract/css"]&&(f=f.replace(/\n\n/g,`
|
|
253
|
+
import {vanillaExtractPlugin} from '@vanilla-extract/vite-plugin';
|
|
254
|
+
|
|
255
|
+
`).replace(/^(\s+)\],/m,`$1 vanillaExtractPlugin(),
|
|
256
|
+
$1],`));let{future:g,appDirectory:w,ignoredRouteFiles:k,routes:y}=t;for(let h of["v3_fetcherPersist","v3_throwAbortReason","v3_relativeSplatPath"])g?.[h]||(f=f.replace(`${h}: true`,`${h}: false`));w&&w!=="app"&&(f=f.replace(/^(\s+)(future:)/m,`$1appDirectory: '${w}',
|
|
257
|
+
$1$2`)),k&&(f=f.replace(/^(\s+)(future:)/m,`$1ignoredRouteFiles: ${JSON.stringify(k)},
|
|
258
|
+
$1$2`)),y&&(f=f.replace(/^(\s+)(future:)/m,`$1routes: ${y.toString()},
|
|
259
|
+
$1$2`));let v=C(e,"vite.config."+s.slice(0,2));return f=await Pt(f,o,v),J(v,f)}),je(C(e,n),!1,f=>(i?`// @ts-ignore
|
|
260
|
+
`:"")+f.replace("@remix-run/dev/server-build","virtual:remix/server-build")),Kt(s).then(async f=>{let p=C(e,t.appDirectory??"app"),g=x(p,"root."+s);await new Promise(async(w,k)=>{await f.findInFiles({paths:[g,x(p,"routes")],matcher:{rule:{kind:"string_fragment",regex:"\\.css$",inside:{kind:"import_statement",stopBy:"end"}}}},async(v,h)=>{v&&k(v);let S={};h.forEach(P=>{if(P.text().endsWith(".module.css"))return;let _=P.getRoot().filename(),I=P.getRoot().root().text(),F=P.range().end.index,R=S[_]||{content:I,positions:[]};R.positions.push(F),S[_]=R}),await Promise.all(Object.entries(S).flatMap(([P,{content:_,positions:I}])=>{I.reverse();for(let F of I)_=_.slice(0,F)+"?url"+_.slice(F);return J(P,_)})),w(null)})===0&&w(null)}),await je(g,o,w=>{let k=f.parse(w).root(),y="LiveReload",v={kind:"identifier",regex:y},h=k.find({rule:{kind:"import_specifier",regex:y,inside:{kind:"import_statement",stopBy:"end"}}}),S=k.findAll({rule:{any:[{kind:"jsx_self_closing_element",has:v},{kind:"jsx_element",has:{kind:"jsx_opening_element",has:v}}]}});for(let P of[...S.reverse(),h]){if(!P)continue;let{start:_,end:I}=P.range();w=w.slice(0,_.index)+w.slice(I.index)}return w.replace(/,\s*,/g,",").replace(/import\s+{\s+cssBundleHref\s+}\s+from\s+['"]@remix-run\/css-bundle['"];?\n/,"").replace(/\.\.\.\(\s*cssBundleHref[^)]+\),?/,"")})})]);await ee([{title:"Updating files",task:async()=>{await m}},{title:"Installing new dependencies",task:async()=>{await et({directory:e,packageManager:await be(e),args:[]})}}]),N({headline:"Your Vite project is ready!",body:`We've modified your project to use Vite.
|
|
261
|
+
Please use Git to review the changes.`,nextSteps:[t.mdx?"Setup MDX support in Vite: https://remix.run/docs/en/main/future/vite#add-mdx-plugin":"","See more information about Vite in Remix at https://remix.run/docs/en/main/future/vite"].filter(Boolean)})}l();var ao=class extends D{static descriptionWithMarkdown="Creates a global h2 shortcut for Shopify CLI using shell aliases.\n\n The following shells are supported:\n\n - Bash (using `~/.bashrc`)\n - ZSH (using `~/.zshrc`)\n - Fish (using `~/.config/fish/functions`)\n - PowerShell (added to `$PROFILE`)\n\n After the alias is created, you can call Shopify CLI from anywhere in your project using `h2 <command>`.";static description=`Creates a global \`${We}\` shortcut for the Hydrogen CLI`;async run(){await Gd()}};async function Gd(){let e=await Xn();e.length>0?N({headline:`Shortcut ready for the following shells: ${e.join(", ")}.
|
|
262
|
+
Restart your terminal session and run \`${We}\` from your local project.`}):$e({name:"error",type:0,message:"No supported shell found.",skipOclifErrorHandling:!0,tryMessage:"Please create a shortcut manually."})}l();var lo=class e extends D{static descriptionWithMarkdown="Unlinks your local development environment from a remote Hydrogen storefront.";static description="Unlink a local project from a Hydrogen storefront.";static flags={...b.path};async run(){let{flags:t}=await this.parse(e);await qd(t)}};async function qd({path:e}){let t=e??process.cwd(),{storefront:r}=await rr(t);if(!r){B("This project isn't linked to a Hydrogen storefront.");return}let o=r.title;await Jn(t),N({body:["You are no longer linked to",{bold:o}]})}l();import{createRequire as Wd}from"node:module";import{spawnSync as Yd}from"node:child_process";var zd=async function(e){if(!e.id?.startsWith("hydrogen:")||e.id==="hydrogen:init")return;let t=an(),r=/^--path($|=)/,o=e.argv.findIndex(n=>r.test(n));if(o!==-1){let n=e.argv[o]?.split("=")[1]??e.argv[o+1];n&&!n.startsWith("--")&&(t=C(t,n))}if(Qd(t)||(se(),q({headline:"Looks like you're trying to run a Hydrogen command outside of a Hydrogen project.",body:["Run",{command:"shopify hydrogen init"},"to create a new Hydrogen project or use the",{command:"--path"},`flag to specify an existing Hydrogen project.
|
|
263
|
+
|
|
264
|
+
`,{subdued:t}],reference:["Getting started: https://shopify.dev/docs/storefronts/headless/hydrogen","CLI commands: https://shopify.dev/docs/api/shopify-cli/hydrogen"]}),process.exit(1)),Jd(e.id,e.argv)&&!process.execArgv.includes(co)&&!(process.env.NODE_OPTIONS??"").includes(co)){Sn(`Restarting CLI process with ${co} flag.`);let[n,...i]=process.argv;i.unshift(co);let s=Yd(n,i,{stdio:"inherit"});process.exit(s.status??1)}},co="--experimental-vm-modules";function Jd(e="",t=[]){return e==="hydrogen:debug:cpu"}function Qd(e){try{let t=Wd(import.meta.url),{dependencies:r,scripts:o}=t(x(e,"package.json"));return!!r?.["@shopify/hydrogen"]||!!o?.dev?.includes("--diff")}catch{return!1}}var Ga=zd;var RE={"hydrogen:dev":Hr,"hydrogen:build":Pr,"hydrogen:check":Cr,"hydrogen:codegen":Ir,"hydrogen:deploy":Ar,"hydrogen:g":Gr,"hydrogen:init":Xr,"hydrogen:link":ci,"hydrogen:list":Zr,"hydrogen:login":eo,"hydrogen:logout":to,"hydrogen:preview":ro,"hydrogen:setup":oo,"hydrogen:shortcut":ao,"hydrogen:unlink":lo,"hydrogen:upgrade":Fr,"hydrogen:customer-account-push":ui,"hydrogen:debug:cpu":Dr,"hydrogen:env:list":Ur,"hydrogen:env:pull":Br,"hydrogen:env:push":Vr,"hydrogen:generate:route":_e,"hydrogen:generate:routes":qr,"hydrogen:setup:css":no,"hydrogen:setup:markets":io,"hydrogen:setup:vite":so},AE={init:Ga};export{RE as a,AE as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as T}from"./chunk-2VQJQ36C.js";import{a as A}from"./chunk-2I4PRX2I.js";import{c as C}from"./chunk-KNVM7N3U.js";import{m as b}from"./chunk-DFMQWJQ3.js";import{s as w}from"./chunk-RFG5RMPL.js";import{a as P}from"./chunk-R466TU3N.js";import{O as u}from"./chunk-B2EHO7ZC.js";import{v as h,x as y}from"./chunk-BDVAE5MS.js";import{Qb as O,va as p}from"./chunk-GFEAKSGV.js";import{d,q as m}from"./chunk-IU2ZQ6TE.js";import{g as c}from"./chunk-VPRTJUIN.js";c();async function q(e){A({verbose:e.verbose,noColor:e.noColor});let o=b({store:e.store}),t=await u(o,e.password);await v(t,{path:e.path??m(),force:e.force??!1,silent:e.silent??!1})}var g={article:"ARTICLE",blog:"BLOG",collection:"COLLECTION",company:"COMPANY",company_location:"COMPANY_LOCATION",location:"LOCATION",market:"MARKET",order:"ORDER",page:"PAGE",product:"PRODUCT",variant:"PRODUCTVARIANT",shop:"SHOP"};async function v(e,o){let{force:t,path:i,silent:n}=o;if(!await T(i)&&(process.env.SHOPIFY_LANGUAGE_SERVER==="1"||!await C(t)))return;let l=[],r=[];for(let[a,s]of Object.entries(g))l.push(w(s,e).catch(f=>(r.push(s),[])).then(f=>({[a]:f})));let S=(await Promise.all(l)).reduce((a,s)=>({...a,...s}));if(r.length===Object.values(g).length){n||y({body:"Failed to fetch metafield definitions.",nextSteps:["Check your network connection and try again.","Ensure you have the permission to fetch metafield definitions."],reference:[{link:{label:"Metafield Definition API",url:"https://shopify.dev/docs/api/admin-graphql/latest/queries/metafieldDefinition"}}]});return}await D(i,S),r.length>0&&O(`Failed to fetch metafield definitions for the following owner types: ${r.join(", ")}`),n||h({body:"Metafield definitions have been successfully downloaded."})}async function D(e,o){let t=await P(e),i=d(t,"metafields.json"),n=JSON.stringify(o,null,2);p(i,n)}export{q as a};
|