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,320 @@
|
|
|
1
|
+
import{a as An,b as Un}from"../../../chunk-AIV5RI3X.js";import{a as Cn}from"../../../chunk-J3KVONB3.js";import{a as kn,e as Dn,f as Tn,g as kt,h as Ln,i as In,j as On,k as Mn,l as _n,m as Rn,n as $n,o as Fn,p as Wn,u as Nn,w as qn,y as Dt}from"../../../chunk-ALKTLKQ6.js";import{c as Bn}from"../../../chunk-K5YV6UVF.js";import{a as wn,b as xn,c as bn,d as Sn,e as En}from"../../../chunk-6BMMB2UO.js";import{a as qr}from"../../../chunk-N5YIPQ6J.js";import{a as Pn}from"../../../chunk-QRRNOVJ3.js";import{a as yn}from"../../../chunk-D3TSJA5S.js";import{a as Nr}from"../../../chunk-RF2DPBA6.js";import{Ba as vn,D as rn,F as nn,H as ve,P as on,Q as ln,R as cn,V as dn,Y as un,ba as mn,ea as fn,f as Br,fa as gn,ga as hn,h as Gr,i as zr,j as jr,l as ee,m as Kr,p as Qr,q as Ut,r as Vr,s as Yr,t as Jr,u as Xr,v as Zr,va as et,w as en,wa as tt,x as tn}from"../../../chunk-SBEZBZM7.js";import{H as sn,I as an,W as pn,a as Ze,f as Te,l as Hr}from"../../../chunk-DJQVNH7P.js";import{a as br,b as Er,d as Dr,h as Rr,i as $r,j as Fr,k as Ct,l as At,m as Wr}from"../../../chunk-ZV6NCNI4.js";import{a as Qt}from"../../../chunk-AKML26N3.js";import"../../../chunk-RM5SJJN6.js";import{a as Tr,b as Lr,c as Ir}from"../../../chunk-4G7J6HIV.js";import{a as Z,b as St}from"../../../chunk-KL5Z3T6L.js";import"../../../chunk-3VZEETAV.js";import{a as Cr,b as Ar,c as bt,d as Ae,e as Ur,f as Ue,h as kr,l as ke,m as Qe,n as z,s as R,u as Ve,v as Ye,w as Je}from"../../../chunk-IX5ICOBV.js";import{a as Sr}from"../../../chunk-YMWHHINU.js";import"../../../chunk-QFWIDATO.js";import{b as xr,g as Ke,j as xt}from"../../../chunk-RFG5RMPL.js";import"../../../chunk-KBQ4LGFB.js";import{c as Or}from"../../../chunk-DJONKJSZ.js";import"../../../chunk-UWJ73J4B.js";import{a as _r,b as Et}from"../../../chunk-WFXRSKRK.js";import"../../../chunk-YOZNRLFC.js";import"../../../chunk-XEFQQPL4.js";import{a as De}from"../../../chunk-SGQ6D3LU.js";import"../../../chunk-P7R7FBY2.js";import"../../../chunk-OXPWCC7I.js";import"../../../chunk-LX3ZOW52.js";import"../../../chunk-NKQBEFPS.js";import{a as Mr}from"../../../chunk-66RJ5T7A.js";import"../../../chunk-K2WUCOQJ.js";import"../../../chunk-ELYP4KFP.js";import"../../../chunk-7MUKLZOL.js";import"../../../chunk-VBUZWRUL.js";import"../../../chunk-XBXMPFXM.js";import"../../../chunk-R466TU3N.js";import"../../../chunk-UGXYQ23Y.js";import"../../../chunk-QSTEVZFQ.js";import"../../../chunk-5Y7GIF2W.js";import{c as Pr,e as wr}from"../../../chunk-TQYMC7TH.js";import{c as vr}from"../../../chunk-HUZUORYM.js";import"../../../chunk-4ZGSSQC6.js";import"../../../chunk-52GC6XUT.js";import"../../../chunk-XLELNRFF.js";import{$ as ir,A as vt,N as sr,Z as ge,a as Zt,c as er,h as tr,l as rr,n as Ee,q as nr,t as or,ta as pr,u as Fe,z as re}from"../../../chunk-B2EHO7ZC.js";import"../../../chunk-4LNCYIS3.js";import"../../../chunk-LAZJ47DZ.js";import"../../../chunk-PRKBO42R.js";import"../../../chunk-GOJ2QHSR.js";import{a as Ht}from"../../../chunk-7BGM2GAH.js";import"../../../chunk-XNO6DZYP.js";import{b as yr}from"../../../chunk-323UTVMM.js";import"../../../chunk-3TNEIDOD.js";import"../../../chunk-4HHXSMD7.js";import"../../../chunk-YZDDTYTU.js";import"../../../chunk-MOA33ZFO.js";import{a as ht,c as Xt}from"../../../chunk-JUVAGMIH.js";import{D as He,H as dr,J as se,O as Ge,P as Ce,Q as wt,R as mr,T as fr,a as Jt,g as ar,i as yt,j as We,k as J,l as X,m as Ne,n as Pt,o as cr,p as qe,u as Be,w as ae}from"../../../chunk-BDVAE5MS.js";import"../../../chunk-P6XE4MH5.js";import"../../../chunk-KLMDWDT2.js";import"../../../chunk-5CH3B62S.js";import{a as ss}from"../../../chunk-QUTQDXSL.js";import{d as lr}from"../../../chunk-IASVAERO.js";import{d as O,g as he,l as ur}from"../../../chunk-JPGO36XP.js";import"../../../chunk-PD5ZHJWI.js";import{r as os}from"../../../chunk-LDGAHMS7.js";import"../../../chunk-ZR76GGZ6.js";import"../../../chunk-EENHXSWU.js";import"../../../chunk-FUOIGXI4.js";import"../../../chunk-6M3ZYNGO.js";import"../../../chunk-QYR5VPQA.js";import{a as Xe}from"../../../chunk-KGXQS7LS.js";import"../../../chunk-V2CNCPIE.js";import{$a as Se,Ea as jt,Gb as U,Hb as hr,Ib as T,Na as Re,Nb as ne,Q as gt,Qb as y,Rb as G,Ta as oe,Wa as $e,cb as Kt,eb as ie,fb as N,gb as A,jb as ue,kb as me,ma as W,mb as Vt,nb as Yt,ua as Me,ub as fe,wa as _e}from"../../../chunk-GFEAKSGV.js";import"../../../chunk-CERXUPGC.js";import"../../../chunk-T4M5CWAO.js";import"../../../chunk-PRVQAHWI.js";import{d as gr,f as ze,k as je}from"../../../chunk-YC6G4MHD.js";import{a as Ie}from"../../../chunk-N7RBSKYT.js";import{d as I,f as ft,g as ce,h as Gt,i as de,j as zt,k as Oe,p as be}from"../../../chunk-IU2ZQ6TE.js";import"../../../chunk-PIBY5DDZ.js";import{e as Y,g as c}from"../../../chunk-VPRTJUIN.js";c();c();c();c();c();c();var is=300*1e3,as='The host theme could not be created to host your theme app extension. Please try again or use the "--theme" flag to use an existing theme as the host theme.';async function Hn(t,e,r=Date.now()){for(;await ps(t,e,r););}async function ps(t,e,r){let n=await Ke(t,e);if(!n||ls(n,r))throw new O(as);return await Ce(3),n.processing}function ls(t,e){return t.processing&&Date.now()-e>=is}var cs="https://codeload.github.com/Shopify/dawn/zip/refs/tags/v15.0.0",ds="https://cdn.shopify.com/theme-store/uhrdefhlndzaoyrgylhto59sx2i7.jpg",Tt=3,rt=class extends Sr{constructor(r,n={devPreview:!1}){super(r);this.context="App Ext. Host";this.themeId=Tr(r.storeFqdn),this.devPreview=n.devPreview}async findOrCreate(){let r=await this.fetch();return r??=this.devPreview?await this.createHostTheme():await this.create(),r}setTheme(r){Lr(this.adminSession.storeFqdn,r)}removeTheme(){Ir(this.adminSession.storeFqdn)}async createHostTheme(){let r={role:xr,name:this.generateThemeName(this.context),src:cs};for(let o=0;o<Tt;o++){y(`Attempt ${o}/${Tt}: Creating theme with name "${r.name}" and role "${r.role}"`);try{let s=await xt(r,this.adminSession);if(s)return this.setTheme(s.id.toString()),y(`Waiting for theme with id "${s.id}" to be processed`),await Hn(s.id,this.adminSession),s;throw new Error}catch{y(`Failed to create theme with name "${r.name}" and role "${r.role}". Retrying...`)}}y(`Theme creation failed after ${Tt} retries. Creating theme using fallback theme zip`);let n=await xt({...r,src:ds},this.adminSession);if(!n)throw y("Theme creation failed. Exiting process."),new he(`Could not create theme with name "${r.name}" and role "${r.role}"`);return n}};async function Gn(t){let{remoteApp:e,localApp:r}=t,o=r.allExtensions.filter(m=>m.isThemeExtension);if(o.length===0)return;let i=o[0].directory,a=t.themeExtensionPort??9293,[l,d]=await Promise.all([sr(t.storeFqdn),fs(e)]),p=l.storeFqdn,u=await br(l)?await Er("",p):void 0,f=await ms(l,t.theme),h=f.id.toString();return Be({headline:"The theme app extension development server is ready.",orderedNextSteps:!0,nextSteps:[[{link:{label:"Install your app in your development store",url:d}}],[{link:{label:"Setup your theme app extension in the host theme",url:`https://${p}/admin/themes/${h}/editor`}}],["Preview your theme app extension at",{link:{label:`http://127.0.0.1:${a}`,url:`http://127.0.0.1:${a}`}}]]}),{type:"theme-app-extensions",prefix:"theme-extensions",function:us,options:{theme:f,adminSession:l,storefrontPassword:u,themeExtensionDirectory:i,themeExtensionPort:a}}}var us=async(t,{theme:e,adminSession:r,storefrontPassword:n,themeExtensionDirectory:o,themeExtensionPort:s})=>{await(await Dr(e,{adminSession:r,storefrontPassword:n,themeExtensionDirectory:o,themeExtensionPort:s})).start()};async function ms(t,e){let r;if(e)y(`Fetching theme with provided id ${e}`),r=await Ke(parseInt(e,10),t);else{let n=new rt(t,{devPreview:!0});await He([{title:"Configuring host theme for theme app extension",task:async()=>{y("Finding or creating host theme for theme app extensions"),r=await n.findOrCreate()}}])}if(!r)throw new O("Could not find or create a host theme for theme app extensions");return r}async function fs(t){return t.developerPlatformClient?.clientName==="app-management"?`https://${await Fe()}/?organization_id=${t.organizationId}&no_redirect=true&redirect=/oauth/redirect_from_developer_dashboard?client_id%3D${t.apiKey}`:`https://${await or()}/${t.organizationId}/apps/${t.id}/test`}c();c();c();c();c();c();async function gs(t){let e=I(t.directory,"locales");return $e([I(e,"*.json")])}async function zn(t,e){let r=await gs(t);if(!r.length)return{localization:void 0,status:""};let n=e.currentLocalizationPayload??{defaultLocale:"en",translations:{},lastUpdated:0},o="success";try{await Promise.all(r.map(async s=>{let[i,...a]=s.split("/").pop().split(".");if(i)return a[0]==="default"&&(n.defaultLocale=i),hs(i,s,n,t,e)})),n.lastUpdated=Date.now(),y(`Parsed locales for extension ${t.handle} at ${t.directory}`,e.stdout)}catch{o="error"}return{localization:n,status:o}}async function hs(t,e,r,n,o){let s;try{s=await W(e),r.translations[t]=JSON.parse(s)}catch(i){let a=`Error parsing ${t} locale for ${n.handle} at ${e}: ${i.message}`;throw G(a,o.stderr),new ur.ExtendableError(a)}}c();function nt(t,e){switch(t){case"checkout_ui_extension":return{url:e.checkoutCartUrl};case"checkout_post_purchase":return{url:e.checkoutCartUrl};case"product_subscription":return{url:e.subscriptionProductUrl??""};default:return{url:""}}}async function ye(t,e,r,n){return X({outputPrefix:t.outputPrefix},async()=>{n?.clear();let o=t.getOutputPathForDirectory(e),s=`${r.url}/extensions/${t.devUUID}`,{localization:i,status:a}=await zn(t,r),l=await jr(t),d=t.outputRelativePath?de(o):o,p=await vs(t,s,d,n),u=null;return"metafields"in t.configuration&&Array.isArray(t.configuration.metafields)&&t.configuration.metafields.length>0&&(u=t.configuration.metafields),{assets:{main:Le(p)&&p[0]?.assets?.main?p[0].assets.main:{name:"main",url:`${s}/assets/${t.outputFileName}`,lastUpdated:await Re(o)??0}},supportedFeatures:{runsOffline:t.configuration.supported_features?.runs_offline??!1},capabilities:{blockProgress:t.configuration.capabilities?.block_progress??!1,networkAccess:t.configuration.capabilities?.network_access??!1,apiAccess:t.configuration.capabilities?.api_access??!1,collectBuyerConsent:{smsMarketing:t.configuration.capabilities?.collect_buyer_consent?.sms_marketing??!1,customerPrivacy:t.configuration.capabilities?.collect_buyer_consent?.customer_privacy??!1},iframe:{sources:t.configuration.capabilities?.iframe?.sources??[]}},development:{...r.currentDevelopmentPayload,resource:nt(t.type,r),root:{url:s},hidden:r.currentDevelopmentPayload?.hidden??!1,localizationStatus:a,status:r.currentDevelopmentPayload?.status??"success",...r.currentDevelopmentPayload??{status:"success"}},extensionPoints:p,localization:i??null,metafields:u,type:t.type,externalType:t.externalType,uuid:t.devUUID,surface:t.surface,version:l?.version,title:t.name,handle:t.handle,name:t.name,description:t.configuration.description,apiVersion:t.configuration.api_version,approvalScopes:r.grantedScopes,settings:t.configuration.settings}})}async function vs(t,e,r,n){let o=t.configuration,s=o.extension_points??o.targeting;if(t.type==="checkout_post_purchase"&&(s=[{target:"purchase.post.render"}]),Le(s)){let i=await ys(r);return Promise.all(s.map(async a=>{let{target:l,resource:d}=a,p={...a,surface:tt(l),root:{url:`${e}/${l}`},resource:d||{url:""}},u=i?.[l];if(!u)return p;let h=await Ss(u,{target:l,extensionPoint:a,url:e,extension:t,buildDirectory:r,resolver:n});return{...p,...h}}))}return s}async function ys(t){try{let e=I(t,"manifest.json"),r=await W(e);return JSON.parse(r)}catch(e){if(e instanceof SyntaxError)throw new Error(`Invalid manifest.json in ${t}: ${e.message}`);return null}}async function Ps({target:t,extensionPoint:e,url:r,extension:n,resolver:o},s,i){let a=`${t}/${s}`,l=e[s];if(typeof l=="string"){let h=await ot(s,a,typeof i=="string"?i:l,r,n,o,typeof i=="string"?l:void 0);return{assets:{[h.name]:h}}}let p=e.build_manifest?.assets?.[s];if(p?.filepath){let u=await ot(s,a,p.filepath,r,n,o,p.module);return{assets:{[u.name]:u}}}return{}}async function ws({target:t,url:e,buildDirectory:r,resolver:n},o,s){if(s.length===0)return{};for(let a of s)n?.set(`${t}/${a}`,a);let i=await Promise.all(s.map(async a=>await Re(I(r,a))??0));return{assets:{[o]:{name:o,url:`${e}/assets/${t}/`,lastUpdated:Math.max(...i)}}}}async function xs({target:t,extensionPoint:e,url:r,extension:n,resolver:o},s){return e.intents?{intents:await Promise.all(e.intents.map(async(a,l)=>{let d=a.schema,p=s[l]?.schema,u=typeof p=="string"?p:d,f=typeof p=="string"?d:void 0;return{...a,schema:await ot("schema",`${t}/intents/${l}/schema`,u,r,n,o,f)}}))}:{}}async function bs({target:t,url:e,extension:r,resolver:n},o,s){let i=await ot(o,`${t}/${o}`,s,e,r,n);return{assets:{[i.name]:i}}}async function Ss(t,e){return(await Promise.all(Object.keys(t).map(async n=>{let o=t[n];return Es(n,o)?xs(e,o):Cs(n,o)?bs(e,n,o):As(n,o)?ws(e,n,o):Ps(e,n,o)}))).reduce((n,o)=>({...n,...o,assets:{...n.assets,...o.assets}}),{})}function Le(t){return Array.isArray(t)&&t.every(e=>typeof e=="object")}async function ot(t,e,r,n,o,s,i){let a=`${e}${Oe(r)}`;return s?.set(a,r),{name:t,url:`${n}/assets/${a}`,lastUpdated:await Re(I(o.directory,i??r))??0}}function Es(t,e){return t==="intents"&&Array.isArray(e)}function Cs(t,e){return(t==="main"||t==="should_render")&&typeof e=="string"}function As(t,e){return t==="assets"&&Array.isArray(e)&&e.every(r=>typeof r=="string")}c();function st(t,e){let r=re(t);return`https://${vt(r)}/admin/oauth/redirect_from_cli?client_id=${e}`}function jn(t,e,r){let o=re(t).split(".")[0];return`https://${r}/store/${o}/apps/${e}?dev-console=show`}function Lt(t){return`https://${re(t)}/admin?dev-console=show`}function Kn(t,e){let r=re(t),o=`${vt(r)}/admin/apps/${e}`,s=Buffer.from(o).toString("base64").replace(/[=]/g,"");return`https://${o}?shop=${r}&host=${s}`}import{EventEmitter as Us}from"events";async function Qn(t,e,r){return{app:{title:t.appName,apiKey:t.apiKey,url:st(t.storeFqdn,t.apiKey),mobileUrl:Kn(t.storeFqdn,t.apiKey)},appId:t.id,version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:t.websocketURL},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extensions:await Promise.all(t.extensions.filter(o=>o.isPreviewable).map(o=>ye(o,e,t,r&&It(r,o.devUUID))))}}function It(t,e){let r=t.get(e);return r||(r=new Map,t.set(e,r)),r}var it=class extends Us{constructor(e,r,n=new Map){super(),this.rawPayload=e,this.options=r,this.assetResolvers=n}getAssetResolver(e){return this.assetResolvers.get(e)}getConnectedPayload(){let e=this.getRawPayload();return{app:e.app,appId:e.appId,store:e.store,extensions:e.extensions}}getRawPayloadFilteredByExtensionIds(e){return{...this.rawPayload,extensions:this.rawPayload.extensions.filter(r=>e.includes(r.uuid))}}getRawPayload(){return this.rawPayload}updateApp(e){this.rawPayload=ge(this.rawPayload,{app:e}),this.emitUpdate([])}updateExtensions(e){let r=this.rawPayload.extensions.map(n=>{let o=e.find(s=>s.uuid===n.uuid);if(o){if(Le(o.extensionPoints)&&Le(n.extensionPoints)){let s=o.extensionPoints.reduce((l,d)=>({...l,[d.target]:d}),{});n.extensionPoints=ge(n.extensionPoints,o.extensionPoints,l=>l.map(d=>{let p=s[d.target];return p?ge(d,p,(u,f)=>f):d}));let{extensionPoints:i,...a}=o;return ge(n,a)}return ge(n,o)}return n});this.rawPayload={...this.rawPayload,extensions:r},this.emitUpdate(e.map(n=>n.uuid))}async updateExtension(e,r,n,o){let s=this.rawPayload.extensions,i=s.findIndex(a=>a.uuid===e.devUUID);if(i===-1){y(T`Could not updateExtension() for extension with uuid: ${e.devUUID}`,r.stderr);return}s[i]=await ye(e,n,{...this.options,currentDevelopmentPayload:o??{status:s[i]?.development.status},currentLocalizationPayload:s[i]?.localization},It(this.assetResolvers,e.devUUID)),this.rawPayload.extensions=s,this.emitUpdate([e.devUUID])}deleteExtension(e){let r=this.rawPayload.extensions.findIndex(n=>n.uuid===e.devUUID);r!==-1&&(this.rawPayload.extensions.splice(r,1),this.assetResolvers.delete(e.devUUID),this.emitUpdate([e.devUUID]))}async addExtension(e,r){this.rawPayload.extensions.push(await ye(e,r,this.options,It(this.assetResolvers,e.devUUID))),this.emitUpdate([e.devUUID])}emitUpdate(e){this.emit("PayloadUpdatedEvent:UPDATE",e)}};c();c();function Vn(t,e){return(r,n,o)=>{r.url==="/extensions"&&(y("Upgrading HTTP request to a websocket connection",e.stdout),t.handleUpgrade(r,n,o,ks(t,e)))}}function ks(t,e){return r=>{y("Websocket connection successfully established",e.stdout);let n={event:"connected",data:e.payloadStore.getConnectedPayload(),version:e.manifestVersion};y(T`Sending connected payload: ${U.json(n)}`,e.stdout),r.send(JSON.stringify(n)),r.on("message",Os(t,e))}}function Ds(t){try{let e=JSON.parse(t);if(!Array.isArray(e))return t;let r=e.map(n=>typeof n=="object"&&n!==null?U.json(n).output():String(n)).join(" ");return T`${r}`.value}catch(e){if(e instanceof SyntaxError)return t;throw e}}var Ts={debug:t=>U.gray(t),warn:t=>U.yellow(t),error:t=>U.errorText(t)};function Ls({type:t,message:e}){let r=Ds(e);switch(t){case"debug":case"warn":case"error":return T`${Ts[t](t.toUpperCase())}: ${r}`.value;case"log":case"info":return r;default:return`${t.toUpperCase()}: ${r}`}}function Is(t,e){X({outputPrefix:t.extensionName,stripAnsi:!1},()=>{e.stdout.write(Ls(t))})}function Os(t,e){return r=>{let n=JSON.parse(r.toString()),{event:o,data:s}=n;if(y(T`Received websocket message with event type ${o} and data:
|
|
2
|
+
${U.json(s)}
|
|
3
|
+
`,e.stdout),o==="update"){let i=e.payloadStore.getRawPayload().app.apiKey,a=s.app?.apiKey;if(s.app){if(i!==a)return;e.payloadStore.updateApp(s.app)}s.extensions&&e.payloadStore.updateExtensions(s.extensions)}else if(o==="dispatch"){let i=Ms(n,e);Jn(t,i,e)}else o==="log"&&Is(s,e)}}function Yn(t,e){return r=>{let n={event:"update",version:e.manifestVersion,data:{...e.payloadStore.getRawPayloadFilteredByExtensionIds(r)}};y(T`Sending websocket update event to the websocket clients:
|
|
4
|
+
${U.json(n)}
|
|
5
|
+
`,e.stdout),Jn(t,n,e)}}function Jn(t,e,r){y(T`Sending websocket with event type ${e.event} and data:
|
|
6
|
+
${U.json(e.data)}
|
|
7
|
+
`,r.stdout);let n=JSON.stringify(e);t.clients.forEach(o=>o.send(n))}function Ms(t,e){let r=e.payloadStore.getRawPayload();return{...t,version:e.manifestVersion,data:{...t.data,extensions:[],store:r.store,app:r.app}}}var _s=10;function Xn(t){let e=new Qt.default({noServer:!0,clientTracking:!0}),r=Rs(e);return t.httpServer.on("upgrade",Vn(e,t)),t.payloadStore.on("PayloadUpdatedEvent:UPDATE",Yn(e,t)),{close:()=>{e.close(),clearInterval(r)}}}function Rs(t){return setInterval(()=>{t.clients.forEach(e=>{e.readyState<2&&e.ping()})},_s*1e3)}c();c();c();function Zn(t,e){let{url:r}=nt(t.type,e);if(t.surface==="checkout"&&r){let n=new URL(`https://${e.storeFqdn}/`);return n.pathname=r,n.searchParams.append("dev",`${e.url}/extensions`),n.toString()}else{let n=new URL(`https://${e.storeFqdn}/`);return n.pathname="admin/extensions-dev",n.searchParams.append("url",at(t,e)),n.toString()}}function eo(t,e,r){let n=tt(t),o=new URL(`https://${r.storeFqdn}/`);switch(n){case"checkout":o.pathname=r.checkoutCartUrl,o.searchParams.append("dev",`${r.url}/extensions`);break;case"post_purchase":if(o.pathname=r.checkoutCartUrl,o.searchParams.set("script_url",`${r.url}/extensions/${e.devUUID}/assets/${e.localIdentifier}.js`),o.searchParams.set("post_purchase_dev_api_key",r.apiKey),e.devUUID&&r.websocketURL&&(o.searchParams.set("uuid",e.devUUID),o.searchParams.set("socket_url",r.websocketURL)),"metafields"in e.configuration){let s={config:{metafields:e.configuration.metafields}};o.searchParams.set("config",JSON.stringify(s))}break;case"admin":o.pathname="admin/extensions-dev",o.searchParams.append("url",at(e,r)),o.searchParams.append("target",t);break;case"customer-accounts":o=$s(e,r,t);break;default:return}return o.toString()}function $s(t,e,r=""){let n=`${e.url}/extensions`,o=e.storeId,s="shopify.com",i=new URL(`https://${s}/${o}/account/extensions-development`);return i.searchParams.append("origin",n),i.searchParams.append("extensionId",t.devUUID),i.searchParams.append("source","CUSTOMER_ACCOUNT_EXTENSION"),i.searchParams.append("appId",e.id??""),r!==""&&i.searchParams.append("target",r),i}function at(t,e){let r=new URL(e.url);return r.pathname=`/extensions/${t.devUUID}`,r.toString()}function te(t,e){Ar(t,Cr(e))}c();var Ot=class extends he{constructor(e){super(`Couldn't find template ${e.template} for extension surface ${e.extensionSurface}`)}};async function to(t){let e=await Fs(t),r=await W(e);return De(r,t.data)}async function Fs(t){let e=await Ws(),r=[];t.extensionSurface&&r.push(I(e,`${t.extensionSurface}/${t.template}.html.liquid`)),r.push(I(e,`${t.template}.html.liquid`));let n=await $e(r);if(n.length===0)throw new Ot(t);return n[0]}async function Ws(){return await Se("templates/ui-extensions/html",{type:"directory",cwd:be(import.meta.url)})}var ro=R(t=>{z(t,"Access-Control-Allow-Origin","*"),z(t,"Access-Control-Allow-Methods","GET, OPTIONS"),z(t,"Access-Control-Allow-Headers","Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, ngrok-skip-browser-warning")}),no=R(t=>{z(t,"Cache-Control","no-cache")}),oo=R(async t=>Qe(t,"/extensions/dev-console",307));async function Mt(t,e){let{filePath:r}=e;if(!await oe(r))return te(t,{statusCode:404,statusMessage:`Not Found: ${r}`});if(await jt(r)&&(r+=r.endsWith("/")?"index.html":"/index.html",!await oe(r)))return te(t,{statusCode:404,statusMessage:`Not Found: ${r}`});let n=await W(r,{}),o={".ico":"image/x-icon",".html":"text/html",".js":"text/javascript",".json":"application/json",".wasm":"application/wasm",".css":"text/css",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".wav":"audio/wav",".mp3":"audio/mpeg",".svg":"image/svg+xml",".pdf":"application/pdf",".doc":"application/msword"},s=Oe(r),i=o[s]||"text/plain";return z(t,"Content-Type",i),n}function so({getExtensions:t,payloadStore:e}){return R(async r=>{let{extensionId:n,assetPath:o=""}=Ae(r),s=t().find(u=>u.devUUID===n);if(!s)return te(r,{statusCode:404,statusMessage:`Extension with id ${n} not found`});let a=e.getAssetResolver(s.devUUID)?.get(o)??o,l=ft(Qr(s.outputPath)),d=ft(I(l,a)),p=ce(l,d);return p.startsWith("..")||Gt(p)?te(r,{statusCode:404,statusMessage:"Not Found"}):Mt(r,{filePath:d})})}function _t({payloadStore:t}){return R(e=>(z(e,"content-type","application/json"),t.getRawPayload()))}var io=R(async t=>{let e=await Se(I("assets","dev-console"),{type:"directory",cwd:be(import.meta.url)});return e?Mt(t,{filePath:e}):te(t,{statusCode:404,statusMessage:"Could not find root directory for dev console"})}),ao=R(async t=>{let{assetPath:e=""}=Ae(t),r=await Se(I("assets","dev-console","extensions","dev-console","assets"),{type:"directory",cwd:be(import.meta.url)});return r?Mt(t,{filePath:I(r,e)}):te(t,{statusCode:404,statusMessage:"Could not find root directory for dev console asset"})});function po({devOptions:t}){return R(e=>{y(`UI extensions server received a ${e.method} request to URL ${e.path}`,t.stdout)})}function Rt({devOptions:t,getExtensions:e}){return R(async r=>{let{extensionId:n}=Ae(r),o=e().find(a=>a.devUUID===n);if(!o)return te(r,{statusCode:404,statusMessage:`Extension with id ${n} not found`});if(Ue(r,"accept")?.startsWith("text/html")){if(o.type==="checkout_post_purchase")return to({data:{url:at(o,t)},template:"index",extensionSurface:"post_purchase"});{let a=Zn(o,t);return Qe(r,a,307)}}let i=t.appWatcher.buildOutputPath;return z(r,"content-type","application/json"),{app:{apiKey:t.apiKey},version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:Pe(t.url)},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extension:await ye(o,i,t)}})}function lo({devOptions:t,getExtensions:e}){return R(async r=>{let{extensionId:n,extensionPointTarget:o=""}=Ae(r),s=e().find(a=>a.devUUID===n);if(!s)return te(r,{statusCode:404,statusMessage:`Extension with id ${n} not found`});if(s.configuration.type!=="checkout_post_purchase"&&!s.hasExtensionPointTarget(o))return te(r,{statusCode:404,statusMessage:`Extension with id ${n} has not configured the "${o}" extension target`});let i=eo(o,s,t);return i?Qe(r,i,307):te(r,{statusCode:404,statusMessage:`Redirect url can't be constructed for extension with id ${n} and extension target "${o}"`})})}import{createServer as Ns}from"http";function co(t){let e=Ve(),r=Ye();e.use(po(t)),e.use(ro),e.use(no),r.use("/extensions/dev-console",io),r.use("/extensions/dev-console/assets/**:assetPath",ao),r.use("/extensions/:extensionId",Rt(t)),r.use("/extensions/:extensionId/",Rt(t)),r.use("/extensions/:extensionId/:extensionPointTarget",lo(t)),r.use("/extensions/:extensionId/assets/**:assetPath",so(t)),r.use("/extensions",_t(t)),r.use("/extensions/",_t(t)),r.use("/",oo),e.use(r);let n=Ns(Je(e));return n.listen(t.devOptions.port,"localhost"),n}async function mo(t){let e={...t,websocketURL:Pe(t.url)},r=e.appWatcher.buildOutputPath,n=new Map,o=await Qn(e,r,n),s=new it(o,e,n),i=e.extensions.filter(u=>u.isPreviewable),a=()=>i;y("Setting up the UI extensions HTTP server...",e.stdout);let l=co({devOptions:e,payloadStore:s,getExtensions:a});y("Setting up the UI extensions Websocket server...",e.stdout);let d=Xn({...e,httpServer:l,payloadStore:s});y("Setting up the UI extensions bundler and file watching...",e.stdout);let p=async({appWasReloaded:u,app:f,extensionEvents:h})=>{u&&(i=f.allExtensions.filter(m=>m.isPreviewable));for(let m of h){if(!m.extension.isPreviewable)continue;let g=m.buildResult?.status==="ok"?"success":"error",w=m.buildResult?.status==="error"?{message:m.buildResult.error,file:m.buildResult.file}:void 0;switch(m.type){case"created":if(e.extensions.push(m.extension),!e.checkoutCartUrl){let x=await et(e.extensions,e.storeFqdn);e.checkoutCartUrl=x}await s.addExtension(m.extension,r);break;case"changed":await s.updateExtension(m.extension,e,r,{status:g,error:w});break;case"deleted":e.extensions=e.extensions.filter(x=>x.devUUID!==m.extension.devUUID),await s.deleteExtension(m.extension);break}}};e.appWatcher.onEvent(p).onStart(p),e.signal.addEventListener("abort",()=>{y("Closing the UI extensions dev server..."),d.close(),l.close()})}function Pe(t){let e=new URL("/extensions",t);return e.protocol="wss:",e.toString()}var qs="3",Bs=async({stderr:t,stdout:e,abortSignal:r},{apiKey:n,storeFqdn:o,storeId:s,subscriptionProductUrl:i,port:a,cartUrl:l,proxyUrl:d,appName:p,appDotEnvFile:u,appId:f,grantedScopes:h,allExtensions:m,appDirectory:g,appWatcher:w})=>{await mo({appName:p,appDotEnvFile:u,appDirectory:g,id:f,extensions:m,stdout:e,stderr:t,signal:r,url:d,port:a,storeFqdn:re(o),storeId:s,apiKey:n,grantedScopes:h,checkoutCartUrl:l,subscriptionProductUrl:i,manifestVersion:qs,appWatcher:w})};async function fo({allExtensions:t,storeFqdn:e,checkoutCartUrl:r,...n}){let o=t.filter(i=>i.isPreviewable),s=await et(o,e,r);return{prefix:"extensions",type:"previewable-extension",function:Bs,options:{pathPrefix:"/extensions",port:-1,storeFqdn:e,allExtensions:t,cartUrl:s,...n}}}c();c();c();async function go(t){let e={},r=await Kr(t);return await Promise.all(r.map(async n=>{let o=ce(t.directory,n),i=de(o)==="assets"?"binary":"utf8",a=await W(n,{encoding:i});e[o]=Buffer.from(a,i).toString("base64")})),{theme_extension:{files:e}}}async function ho({extension:t,developerPlatformClient:e,apiKey:r,registrationId:n,stdout:o,stderr:s,appConfiguration:i,bundlePath:a}){let l,d=t.getOutputPathForDirectory(a);if(t.features.includes("esbuild")){let w=await W(d);if(!w)return;l=Buffer.from(w).toString("base64")}let p;t.isThemeExtension?p=await go(t):p=await t.deployConfig({apiKey:r,appConfiguration:i})??{};let u={...p,serialized_script:l};if(t.isFunctionExtension){let w=await W(t.outputPath,{encoding:"base64"});u.uploaded_files={"dist/index.wasm":w}}let f={apiKey:r,config:JSON.stringify(u),handle:t.handle,context:t.contextValue,registrationId:n},h,m=[];try{h=await e.updateExtension(f)}catch(w){if(m=[{message:"Unknown error"}],w&&typeof w=="object"){let x=w;x.errors?.length?m=x.errors:x.message&&(m=[{message:x.message}])}else typeof w=="string"&&(m=[{message:w}])}let g=h?.extensionUpdateDraft?.userErrors;if(g?.length&&m.push(...g),m.length>0){let w=m.map(x=>x.message).join(", ");s.write(`${t.draftMessages.errorMessage}: ${w}`)}else{let w=t.draftMessages.successMessage;w&&ne(w,o)}}var Hs=async({stderr:t,stdout:e},{developerPlatformClient:r,apiKey:n,remoteExtensionIds:o,localApp:s,appWatcher:i})=>{await Br(s);let a=s.draftableExtensions.map(d=>d.handle),l=async d=>{let u=d.extensionEvents.filter(f=>f.type==="changed").filter(f=>f.buildResult?.status==="ok").filter(f=>a.includes(f.extension.handle)).map(async f=>{let h=f.extension,m=o[h.localIdentifier];if(!m)throw new O(`Extension ${h.localIdentifier} not found on remote app.`);await X({outputPrefix:h.outputPrefix},async()=>{await ho({extension:h,developerPlatformClient:r,apiKey:n,registrationId:m,stdout:e,stderr:t,appConfiguration:s.configuration,bundlePath:i.buildOutputPath})})});await Promise.all(u)};i.onEvent(l).onStart(l)};async function vo({localApp:t,apiKey:e,developerPlatformClient:r,remoteApp:n,...o}){let s=t.draftableExtensions;if(s.length===0)return;let i=un({app:t}),{extensionIds:a,extensions:l}=await dn({app:t,remoteApp:n,appId:e,appName:n.title,force:!0,release:!0,developerPlatformClient:r,envIdentifiers:i,includeDraftExtensions:!0});return t.updateExtensionUUIDS(l),{type:"draftable-extension",prefix:"extensions",function:Hs,options:{localApp:t,apiKey:e,developerPlatformClient:r,...o,extensions:s,remoteExtensionIds:a}}}c();c();function pe(t){let e=t.find(n=>ve(n,"frontend")),r=t.find(n=>ve(n,"backend"));return{frontendConfig:e,backendConfig:r}}c();async function Po(t){let r={topic:"app/uninstalled",api_version:(await an(t.developerPlatformClient,t.organizationId))[1],address:t.address,delivery_method:Un.LOCALHOST,shared_secret:t.sharedSecret},n=await sn(t.developerPlatformClient,r,t.organizationId);t.stdout.write("Sending APP_UNINSTALLED webhook to app server"),await Ce(3);let o=await Gs(t,n);return t.stdout.write(o?"APP_UNINSTALLED webhook delivered":"APP_UNINSTALLED webhook delivery failed"),o}async function Gs(t,e){let r=0;for(;r<3;){try{return await An(t.address,e.samplePayload,JSON.stringify({...JSON.parse(e.headers),"X-Shopify-Shop-Domain":t.storeFqdn}))}catch(n){if(n instanceof rr&&n.code==="ECONNREFUSED")r<3&&(t.stdout.write("App isn't responding yet, retrying in 5 seconds"),await Ce(5));else throw n}r++}return t.stdout.write("App hasn't started in time, giving up"),!1}var zs=async({stdout:t},e)=>{await Po({stdout:t,developerPlatformClient:e.developerPlatformClient,address:`http://localhost:${e.deliveryPort}${e.webhooksPath}`,sharedSecret:e.apiSecret,storeFqdn:e.storeFqdn,organizationId:e.organizationId})};function wo({webs:t,remoteAppUpdated:e,backendPort:r,frontendPort:n,organizationId:o,...s}){let{backendConfig:i,frontendConfig:a}=pe(t),l=t.map(({configuration:p})=>p.webhooks_path).find(p=>p)??"/api/webhooks";if(l&&e&&(a??i))return{type:"send-webhook",prefix:"webhooks",function:zs,options:{deliveryPort:i?r:n,webhooksPath:l,organizationId:o,...s}}}c();c();c();var C=Y(ie(),1),$t=Y(Rr(),1),L=Y($r(),1);var pt=ar().platform==="darwin"?"MAC_COMMAND_KEY":"Ctrl",js=`
|
|
8
|
+
# Welcome to GraphiQL for the Shopify Admin API! If you've used
|
|
9
|
+
# GraphiQL before, you can jump to the next tab.
|
|
10
|
+
#
|
|
11
|
+
# GraphiQL is an in-browser tool for writing, validating, and
|
|
12
|
+
# testing GraphQL queries.
|
|
13
|
+
#
|
|
14
|
+
# Type queries into this side of the screen, and you will see intelligent
|
|
15
|
+
# typeaheads aware of the current GraphQL type schema and live syntax and
|
|
16
|
+
# validation errors highlighted within the text.
|
|
17
|
+
#
|
|
18
|
+
# GraphQL queries typically start with a "{" character. Lines that start
|
|
19
|
+
# with a # are ignored.
|
|
20
|
+
#
|
|
21
|
+
# Keyboard shortcuts:
|
|
22
|
+
#
|
|
23
|
+
# Prettify query: Shift-${pt}-P (or press the prettify button)
|
|
24
|
+
#
|
|
25
|
+
# Merge fragments: Shift-${pt}-M (or press the merge button)
|
|
26
|
+
#
|
|
27
|
+
# Run Query: ${pt}-Enter (or press the play button)
|
|
28
|
+
#
|
|
29
|
+
# Auto Complete: ${pt}-Space (or just start typing)
|
|
30
|
+
#
|
|
31
|
+
`,bo=`query shopInfo {
|
|
32
|
+
shop {
|
|
33
|
+
name
|
|
34
|
+
url
|
|
35
|
+
myshopifyDomain
|
|
36
|
+
plan {
|
|
37
|
+
displayName
|
|
38
|
+
partnerDevelopment
|
|
39
|
+
shopifyPlus
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`.replace(/\n/g,"\\n");function So({apiVersion:t,apiVersions:e,appName:r,appUrl:n,key:o,storeFqdn:s}){return`<!DOCTYPE html>
|
|
44
|
+
<html lang="en">
|
|
45
|
+
<head>
|
|
46
|
+
<title>GraphiQL</title>
|
|
47
|
+
<link rel="shortcut icon" href="{{url}}/graphiql/favicon.ico" type="image/x-icon" />
|
|
48
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shopify/polaris@12.10.0/build/esm/styles.css" />
|
|
49
|
+
<style>
|
|
50
|
+
body {
|
|
51
|
+
height: 100%;
|
|
52
|
+
margin: 0;
|
|
53
|
+
width: 100%;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
}
|
|
56
|
+
.Polaris-Page--fullWidth {
|
|
57
|
+
width: 100%;
|
|
58
|
+
}
|
|
59
|
+
#top-bar {
|
|
60
|
+
border-bottom: 1px solid var(--p-color-border);
|
|
61
|
+
}
|
|
62
|
+
#top-bar #top-error-bar {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
#top-error-bar .Polaris-FullscreenBar__BackAction {
|
|
66
|
+
/* hide default back button in FullscreenBar component */
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
#top-error-bar button {
|
|
70
|
+
/* hide X to dismiss banner */
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
73
|
+
#top-bar .top-bar-section {
|
|
74
|
+
display: inline-flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
gap: 8px;
|
|
77
|
+
}
|
|
78
|
+
#top-bar .Polaris-Grid-Cell:nth-child(2) {
|
|
79
|
+
justify-self: right;
|
|
80
|
+
}
|
|
81
|
+
#top-bar #scopes-note {
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
height: 100%;
|
|
85
|
+
}
|
|
86
|
+
#top-bar .status-badge-option {
|
|
87
|
+
gap: 8px;
|
|
88
|
+
display: none;
|
|
89
|
+
}
|
|
90
|
+
#top-bar #status-badge-running {
|
|
91
|
+
display: flex;
|
|
92
|
+
}
|
|
93
|
+
#graphiql {
|
|
94
|
+
height: 100vh;
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
}
|
|
98
|
+
#graphiql-explorer {
|
|
99
|
+
flex-grow: 1;
|
|
100
|
+
overflow: auto;
|
|
101
|
+
}
|
|
102
|
+
#top-bar #outbound-links a {
|
|
103
|
+
line-height: 0;
|
|
104
|
+
}
|
|
105
|
+
#top-bar #outbound-links a:hover .Polaris-Text--root {
|
|
106
|
+
text-decoration: underline;
|
|
107
|
+
}
|
|
108
|
+
#top-bar #outbound-links a span.Polaris-Text--root {
|
|
109
|
+
max-width: max(12vw, 150px);
|
|
110
|
+
text-overflow: ellipsis;
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
white-space: nowrap;
|
|
113
|
+
}
|
|
114
|
+
.with-shrunk-icon .Polaris-Icon {
|
|
115
|
+
height: 1rem;
|
|
116
|
+
width: 1rem;
|
|
117
|
+
margin: 0.125rem;
|
|
118
|
+
}
|
|
119
|
+
@media only screen and (max-width: 1550px) {
|
|
120
|
+
.top-bar-section-title {
|
|
121
|
+
display: none;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
@media only screen and (max-width: 1150px) {
|
|
125
|
+
#top-bar #outbound-links a span.Polaris-Text--root {
|
|
126
|
+
max-width: max(12vw, 140px);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
@media only screen and (max-width: 1080px) {
|
|
130
|
+
#top-bar .Polaris-Grid-Cell:nth-child(2) {
|
|
131
|
+
justify-self: left;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
@media only screen and (max-width: 650px) {
|
|
135
|
+
#top-bar #outbound-links a span.Polaris-Text--root {
|
|
136
|
+
max-width: 17vw;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
</style>
|
|
140
|
+
|
|
141
|
+
<script
|
|
142
|
+
src="https://cdn.jsdelivr.net/npm/react@17/umd/react.development.js"
|
|
143
|
+
integrity="sha512-Vf2xGDzpqUOEIKO+X2rgTLWPY+65++WPwCHkX2nFMu9IcstumPsf/uKKRd5prX3wOu8Q0GBylRpsDB26R6ExOg=="
|
|
144
|
+
crossorigin="anonymous"
|
|
145
|
+
></script>
|
|
146
|
+
<script
|
|
147
|
+
src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.development.js"
|
|
148
|
+
integrity="sha512-Wr9OKCTtq1anK0hq5bY3X/AvDI5EflDSAh0mE9gma+4hl+kXdTJPKZ3TwLMBcrgUeoY0s3dq9JjhCQc7vddtFg=="
|
|
149
|
+
crossorigin="anonymous"
|
|
150
|
+
></script>
|
|
151
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/graphiql@3.0.4/graphiql.min.css" />
|
|
152
|
+
</head>
|
|
153
|
+
<body>
|
|
154
|
+
<div id="graphiql">
|
|
155
|
+
${(0,$t.renderToStaticMarkup)(C.default.createElement(L.AppProvider,{i18n:{}},C.default.createElement("div",{id:"top-bar"},C.default.createElement(L.Box,{background:"bg-surface",padding:"400"},C.default.createElement(L.BlockStack,{gap:"300"},C.default.createElement(L.Grid,{columns:{xs:3,sm:3,md:3}},C.default.createElement(L.Grid.Cell,{columnSpan:{xs:3,sm:3,md:3,lg:7,xl:7}},C.default.createElement(L.InlineStack,{gap:"400"},C.default.createElement("div",{id:"status-badge",className:"top-bar-section"},C.default.createElement("div",{className:"status-badge-option",id:"status-badge-running"},C.default.createElement("span",{className:"top-bar-section-title"},"Status: "),C.default.createElement(L.Badge,{tone:"success",progress:"complete"},"Running")),C.default.createElement("div",{className:"status-badge-option with-shrunk-icon",id:"status-badge-unauthorized"},C.default.createElement("span",{className:"top-bar-section-title"},"Status: "),C.default.createElement(L.Badge,{tone:"attention",icon:Fr},"App uninstalled")),C.default.createElement("div",{className:"status-badge-option with-shrunk-icon",id:"status-badge-disconnected"},C.default.createElement("span",{className:"top-bar-section-title"},"Status: "),C.default.createElement(L.Badge,{tone:"critical",icon:Ct},"Disconnected"))),C.default.createElement("div",{id:"version-select",className:"top-bar-section"},C.default.createElement("span",{className:"top-bar-section-title"},"API version: "),C.default.createElement(L.Select,{label:"API version",labelHidden:!0,options:e,value:t,onChange:()=>{}})),xo({storeFqdn:s,appName:r,appUrl:n}))),C.default.createElement(L.Grid.Cell,{columnSpan:{xs:3,sm:3,md:3,lg:5,xl:5}},C.default.createElement("div",{id:"scopes-note",className:"top-bar-section"},C.default.createElement(L.Text,{as:"span",tone:"subdued"},"GraphiQL runs on the same access scopes you've defined in the TOML file for your app.")))),C.default.createElement("div",{id:"top-error-bar"},C.default.createElement(L.Banner,{tone:"critical",onDismiss:()=>{},icon:Ct},C.default.createElement("p",null,"The server has been stopped. Restart ",C.default.createElement("code",null,"dev")," from the CLI."))))))))}
|
|
156
|
+
<div id="graphiql-explorer">Loading...</div>
|
|
157
|
+
</div>
|
|
158
|
+
<script
|
|
159
|
+
src="https://cdn.jsdelivr.net/npm/graphiql@3.0.4/graphiql.min.js"
|
|
160
|
+
type="application/javascript"
|
|
161
|
+
></script>
|
|
162
|
+
<script>
|
|
163
|
+
const macCommandKey = String.fromCodePoint(8984)
|
|
164
|
+
const renderGraphiQL = function(apiVersion) {
|
|
165
|
+
ReactDOM.render(
|
|
166
|
+
React.createElement(GraphiQL, {
|
|
167
|
+
fetcher: GraphiQL.createFetcher({
|
|
168
|
+
url: '{{url}}/graphiql/graphql.json?key=${encodeURIComponent(o)}&api_version=' + apiVersion,
|
|
169
|
+
}),
|
|
170
|
+
defaultEditorToolsVisibility: true,
|
|
171
|
+
{% if query %}
|
|
172
|
+
query: {{query}},
|
|
173
|
+
{% endif %}
|
|
174
|
+
{% if variables %}
|
|
175
|
+
variables: {{variables}},
|
|
176
|
+
{% endif %}
|
|
177
|
+
defaultTabs: [
|
|
178
|
+
{query: "${js.replace(/"/g,'\\"').replace(/\n/g,"\\n")}".replace(/MAC_COMMAND_KEY/g, macCommandKey)},
|
|
179
|
+
{%for query in defaultQueries%}
|
|
180
|
+
{query: "{%if query.preface %}{{query.preface}}\\n{% endif %}{{query.query}}", variables: "{{query.variables}}"},
|
|
181
|
+
{%endfor%}
|
|
182
|
+
],
|
|
183
|
+
isHeadersEditorEnabled: true,
|
|
184
|
+
}),
|
|
185
|
+
document.getElementById('graphiql-explorer'),
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
renderGraphiQL('${t}')
|
|
189
|
+
|
|
190
|
+
// Update the version when the select changes
|
|
191
|
+
document.getElementById('version-select').addEventListener('change', function(event) {
|
|
192
|
+
document.querySelector('#version-select .Polaris-Select__SelectedOption').innerText = event.target.value
|
|
193
|
+
renderGraphiQL(event.target.value)
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
// Start out optimistic
|
|
197
|
+
let serverIsLive = true
|
|
198
|
+
let appIsInstalled = true
|
|
199
|
+
|
|
200
|
+
const updateBadge = function() {
|
|
201
|
+
const topErrorBar = document.querySelector('#graphiql #top-error-bar')
|
|
202
|
+
const statusDiv = document.querySelector('#graphiql #status-badge')
|
|
203
|
+
const allBadgeDivs = Array.from(statusDiv.querySelectorAll('.status-badge-option'))
|
|
204
|
+
let activeBadge = 'running'
|
|
205
|
+
if (!appIsInstalled) activeBadge = 'unauthorized'
|
|
206
|
+
if (!serverIsLive) activeBadge = 'disconnected'
|
|
207
|
+
allBadgeDivs.forEach(function(badge) {
|
|
208
|
+
if (badge.id == ('status-badge-' + activeBadge)) {
|
|
209
|
+
badge.style.display = 'flex'
|
|
210
|
+
} else {
|
|
211
|
+
badge.style.display = 'none'
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
topErrorBar.style.display = serverIsLive ? 'none' : 'block'
|
|
215
|
+
}
|
|
216
|
+
const statusInterval = setInterval(updateBadge, 1000)
|
|
217
|
+
|
|
218
|
+
// Warn when the server has been stopped
|
|
219
|
+
const displayErrorServerStoppedTimeouts = []
|
|
220
|
+
const pingInterval = setInterval(function() {
|
|
221
|
+
displayErrorServerStoppedTimeouts.push(setTimeout(function() { serverIsLive = false }, 3000))
|
|
222
|
+
fetch('{{url}}/graphiql/ping')
|
|
223
|
+
.then(function(response) {
|
|
224
|
+
if (response.status === 200) {
|
|
225
|
+
while (displayErrorServerStoppedTimeouts.length > 0) {
|
|
226
|
+
const timeout = displayErrorServerStoppedTimeouts.pop()
|
|
227
|
+
clearTimeout(timeout)
|
|
228
|
+
}
|
|
229
|
+
serverIsLive = true
|
|
230
|
+
} else {
|
|
231
|
+
serverIsLive = false
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
}, 2000)
|
|
235
|
+
|
|
236
|
+
// Verify the current store/app connection
|
|
237
|
+
setInterval(function() {
|
|
238
|
+
fetch('{{ url }}/graphiql/status?key=${encodeURIComponent(o)}')
|
|
239
|
+
.then(async function(response) {
|
|
240
|
+
const {status, storeFqdn, appName, appUrl} = await response.json()
|
|
241
|
+
appIsInstalled = status === 'OK'
|
|
242
|
+
if (storeFqdn) {
|
|
243
|
+
document.getElementById('outbound-links').innerHTML = \`${(0,$t.renderToStaticMarkup)(C.default.createElement(L.AppProvider,{i18n:{}},xo({storeFqdn:"${storeFqdn}",appName:"${appName}",appUrl:"${appUrl}"})))}\`
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
}, 5000)
|
|
247
|
+
</script>
|
|
248
|
+
</body>
|
|
249
|
+
</html>
|
|
250
|
+
`}function xo({storeFqdn:t,appName:e,appUrl:r}){return C.default.createElement("div",{id:"outbound-links",className:"top-bar-section with-shrunk-icon"},C.default.createElement("span",{className:"top-bar-section-title"},"Store: "),C.default.createElement(L.Link,{url:`https://${t}/admin`,target:"_blank"},C.default.createElement(L.Badge,{tone:"info",icon:At,children:t})),C.default.createElement("span",{className:"top-bar-section-title"},"App: "),C.default.createElement(L.Link,{url:r,target:"_blank"},C.default.createElement(L.Badge,{tone:"info",icon:At,children:e})))}c();var k=Y(ie(),1),Eo=Y(Rr(),1),H=Y($r(),1),Ks=k.default.createElement("svg",{width:"102",height:"28",viewBox:"0 0 102 28",fill:"none",xmlns:"http://www.w3.org/2000/svg"},k.default.createElement("path",{d:"M21.4028 5.3032C21.3836 5.16414 21.2615 5.08697 21.16 5.07856C21.0594 5.07016 19.0881 5.04036 19.0881 5.04036C19.0881 5.04036 17.4395 3.44802 17.2767 3.28603C17.1138 3.12405 16.7957 3.17295 16.6721 3.20962C16.6705 3.21039 16.3625 3.30513 15.8439 3.46483C15.7571 3.18517 15.6296 2.84134 15.4475 2.49597C14.8606 1.38194 14.0009 0.792838 12.9623 0.79131C12.9608 0.79131 12.96 0.79131 12.9585 0.79131C12.8862 0.79131 12.8148 0.798187 12.7426 0.804299C12.7119 0.767624 12.6811 0.731712 12.6489 0.696564C12.1964 0.215194 11.6164 -0.0193788 10.9211 0.00125134C9.57979 0.0394553 8.24384 1.00296 7.16064 2.7145C6.39856 3.91869 5.81855 5.43157 5.65415 6.6029C4.11386 7.0774 3.0368 7.40901 3.01299 7.41665C2.23554 7.65962 2.21096 7.68331 2.10955 8.41224C2.03427 8.96314 0 24.6084 0 24.6084L17.0477 27.541L24.4365 25.7141C24.4365 25.7141 21.422 5.44226 21.4028 5.3032ZM14.9904 3.72767C14.5979 3.84839 14.1515 3.98593 13.6675 4.13492C13.6575 3.45948 13.5769 2.51966 13.2604 1.70744C14.2783 1.89923 14.7792 3.04458 14.9904 3.72767ZM12.7756 4.40999C11.8822 4.68506 10.9073 4.98534 9.92933 5.28639C10.2044 4.23884 10.726 3.19587 11.3667 2.51202C11.6048 2.25758 11.9382 1.97411 12.3331 1.81212C12.7042 2.58231 12.7848 3.67266 12.7756 4.40999ZM10.948 0.889112C11.263 0.882236 11.528 0.951003 11.7546 1.09923C11.392 1.28643 11.0417 1.55539 10.7129 1.9061C9.86096 2.81536 9.20797 4.22661 8.94754 5.5882C8.13552 5.83806 7.34118 6.08333 6.60983 6.30797C7.07153 4.16472 8.87763 0.94871 10.948 0.889112Z",fill:"#95BF47"}),k.default.createElement("path",{d:"M21.1611 5.07934C21.0605 5.07093 19.0892 5.04114 19.0892 5.04114C19.0892 5.04114 17.4406 3.44879 17.2778 3.28681C17.2171 3.22645 17.1349 3.19512 17.0488 3.18213L17.0496 27.5402L24.4376 25.7141C24.4376 25.7141 21.4231 5.44304 21.4039 5.30398C21.3847 5.16492 21.2618 5.08774 21.1611 5.07934Z",fill:"#5E8E3E"}),k.default.createElement("path",{d:"M12.9528 8.85773L12.0947 12.0508C12.0947 12.0508 11.1375 11.6176 10.0028 11.6886C8.33885 11.7933 8.32118 12.8371 8.33808 13.0991C8.42873 14.5272 12.2061 14.8389 12.4181 18.1841C12.5848 20.8156 11.0146 22.6158 8.75216 22.7579C6.03647 22.9283 4.5415 21.3352 4.5415 21.3352L5.11691 18.9008C5.11691 18.9008 6.62186 20.0301 7.82644 19.9545C8.61311 19.9048 8.89428 19.2683 8.86585 18.8183C8.74755 16.9554 5.67157 17.0655 5.4772 14.0046C5.31357 11.4289 7.01443 8.81876 10.7672 8.58343C12.213 8.49097 12.9528 8.85773 12.9528 8.85773Z",fill:"white"}),k.default.createElement("path",{d:"M34.1664 15.544C33.3168 15.0855 32.8802 14.699 32.8802 14.1677C32.8802 13.4917 33.4867 13.0575 34.4338 13.0575C35.5364 13.0575 36.5208 13.516 36.5208 13.516L37.2973 11.15C37.2973 11.15 36.5833 10.5945 34.4818 10.5945C31.5574 10.5945 29.5306 12.2602 29.5306 14.602C29.5306 15.9297 30.4769 16.9437 31.7395 17.6675C32.759 18.2465 33.1232 18.6572 33.1232 19.2605C33.1232 19.888 32.6135 20.395 31.6671 20.395C30.2567 20.395 28.9248 19.6705 28.9248 19.6705L28.0996 22.0365C28.0996 22.0365 29.3302 22.8572 31.4004 22.8572C34.4102 22.8572 36.5704 21.3847 36.5704 18.7292C36.5696 17.306 35.4777 16.292 34.1664 15.544Z",fill:"black"}),k.default.createElement("path",{d:"M46.1564 10.571C44.6759 10.571 43.5108 11.2712 42.6132 12.333L42.5645 12.3087L43.8507 5.62222H40.5011L37.249 22.6405H40.5986L41.7149 16.8232C42.1515 14.6262 43.2922 13.275 44.3604 13.275C45.1125 13.275 45.4043 13.782 45.4043 14.5065C45.4043 14.965 45.3555 15.5205 45.2588 15.979L43.997 22.6412H47.3466L48.6571 15.7615C48.8027 15.037 48.9002 14.1685 48.9002 13.5887C48.8987 11.7055 47.9036 10.571 46.1564 10.571Z",fill:"black"}),k.default.createElement("path",{d:"M56.4709 10.571C52.4416 10.571 49.7725 14.192 49.7725 18.223C49.7725 20.8058 51.3741 22.8815 54.3839 22.8815C58.34 22.8815 61.0099 19.3575 61.0099 15.2295C61.0099 12.84 59.6018 10.571 56.4709 10.571ZM54.8205 20.3238C53.6798 20.3238 53.1944 19.3583 53.1944 18.151C53.1944 16.2443 54.1896 13.1303 56.0099 13.1303C57.1993 13.1303 57.5872 14.1443 57.5872 15.134C57.5872 17.1855 56.5928 20.3238 54.8205 20.3238Z",fill:"black"}),k.default.createElement("path",{d:"M69.5778 10.571C67.3171 10.571 66.0339 12.5505 66.0339 12.5505H65.9859L66.1802 10.7643H63.2192C63.0737 11.9715 62.8062 13.8055 62.5396 15.1818L60.2095 27.3718H63.5591L64.481 22.4473H64.5542C64.5542 22.4473 65.2415 22.8815 66.5201 22.8815C70.4518 22.8815 73.0242 18.8748 73.0242 14.8187C73.0242 12.5748 72.029 10.571 69.5778 10.571ZM66.3738 20.3715C65.5044 20.3715 64.99 19.8888 64.99 19.8888L65.5485 16.7748C65.9371 14.699 67.029 13.3228 68.1941 13.3228C69.2136 13.3228 69.529 14.264 69.529 15.1575C69.529 17.306 68.2428 20.3715 66.3738 20.3715Z",fill:"black"}),k.default.createElement("path",{d:"M77.8058 5.79121C76.7383 5.79121 75.8887 6.63622 75.8887 7.72221C75.8887 8.71197 76.5196 9.38797 77.4659 9.38797H77.5147C78.5586 9.38797 79.4562 8.68771 79.4806 7.45697C79.4806 6.49147 78.8253 5.79121 77.8058 5.79121Z",fill:"black"}),k.default.createElement("path",{d:"M73.1216 22.6405H76.4704L78.7525 10.837H75.3785L73.1216 22.6405Z",fill:"black"}),k.default.createElement("path",{d:"M87.2711 10.8127H84.9411L85.0622 10.2572C85.2565 9.12274 85.9362 8.10874 87.0525 8.10874C87.6483 8.10874 88.12 8.27774 88.12 8.27774L88.7753 5.67074C88.7753 5.67074 88.1931 5.38124 86.9549 5.38124C85.7655 5.38124 84.5768 5.71924 83.6785 6.49149C82.5378 7.45699 82.0037 8.85674 81.737 10.2572L81.6402 10.8127H80.0866L79.6012 13.3235H81.1549L79.3833 22.6413H82.7329L84.5045 13.3235H86.8102L87.2711 10.8127Z",fill:"black"}),k.default.createElement("path",{d:"M95.3288 10.837C95.3288 10.837 93.2349 16.0836 92.2947 18.9475H92.2459C92.1819 18.0252 91.4207 10.837 91.4207 10.837H87.9012L89.9166 21.675C89.9653 21.916 89.9409 22.0615 89.8434 22.2305C89.4548 22.9785 88.7995 23.703 88.0231 24.2343C87.3922 24.6928 86.6881 24.9823 86.1304 25.1755L87.0523 28C87.732 27.8553 89.1394 27.2998 90.3288 26.1895C91.858 24.7655 93.2654 22.5685 94.7215 19.575L98.8231 10.8362H95.3288V10.837Z",fill:"black"})),Qs=(0,Eo.renderToStaticMarkup)(k.default.createElement(H.AppProvider,{i18n:{}},k.default.createElement(H.Page,{narrowWidth:!0},k.default.createElement("div",{className:"card-wrapper"},k.default.createElement(H.Card,{padding:"600"},k.default.createElement(H.BlockStack,{gap:"500"},Ks,k.default.createElement("div",{id:"pre-install"},k.default.createElement(H.BlockStack,{gap:"200"},k.default.createElement(H.Text,{variant:"headingMd",as:"h2"},"Install your app to access GraphiQL"),k.default.createElement("p",null,"The GraphiQL Explorer relies on your app being installed on your dev store to access its data."),k.default.createElement("p",{id:"card-cta"},k.default.createElement(H.Button,{id:"app-install-button"},"Install your app")))),k.default.createElement("div",{id:"post-install"},k.default.createElement(H.BlockStack,{gap:"200"},k.default.createElement(H.Text,{variant:"headingMd",as:"h2"},"Loading GraphiQL..."),k.default.createElement("p",null,"If you're not redirected automatically, ",k.default.createElement(H.Link,{url:"{{url}}/graphiql"},"click here"),"."))))))))),Co=`
|
|
251
|
+
<!DOCTYPE html>
|
|
252
|
+
<html>
|
|
253
|
+
<head>
|
|
254
|
+
<title>GraphiQL Explorer - App Not Installed</title>
|
|
255
|
+
<meta charset="UTF-8">
|
|
256
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
257
|
+
|
|
258
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
259
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shopify/polaris@12.10.0/build/esm/styles.css" />
|
|
260
|
+
<style>
|
|
261
|
+
.vertical-center {
|
|
262
|
+
display: flex;
|
|
263
|
+
flex-direction: row;
|
|
264
|
+
align-items: center;
|
|
265
|
+
height: 100%;
|
|
266
|
+
}
|
|
267
|
+
.card-wrapper {
|
|
268
|
+
max-width: 480px;
|
|
269
|
+
margin-left: 20px;
|
|
270
|
+
margin-right: 20px;
|
|
271
|
+
}
|
|
272
|
+
#post-install {
|
|
273
|
+
display: none;
|
|
274
|
+
}
|
|
275
|
+
</style>
|
|
276
|
+
|
|
277
|
+
<script type="text/javascript">
|
|
278
|
+
let appInstalled = false
|
|
279
|
+
let newTab = null
|
|
280
|
+
|
|
281
|
+
setInterval(function() {
|
|
282
|
+
fetch('{{ url }}/graphiql/status')
|
|
283
|
+
.then(async function(response) {
|
|
284
|
+
const body = await response.json()
|
|
285
|
+
if (body.status === 'OK') {
|
|
286
|
+
if (newTab) newTab.close()
|
|
287
|
+
document.getElementById('pre-install').style.display = 'none'
|
|
288
|
+
document.getElementById('post-install').style.display = 'block'
|
|
289
|
+
window.location.href = window.location.href
|
|
290
|
+
}
|
|
291
|
+
})
|
|
292
|
+
}, 5000)
|
|
293
|
+
|
|
294
|
+
function openAppInstallTab() {
|
|
295
|
+
newTab = window.open('{{ previewUrl }}', '_blank')
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
document.addEventListener("DOMContentLoaded", function() {
|
|
299
|
+
document.getElementById('app-install-button').onclick = openAppInstallTab
|
|
300
|
+
})
|
|
301
|
+
</script>
|
|
302
|
+
</head>
|
|
303
|
+
<body>
|
|
304
|
+
<div class="vertical-center">
|
|
305
|
+
${Qs}
|
|
306
|
+
</div>
|
|
307
|
+
</body>
|
|
308
|
+
</html>
|
|
309
|
+
`;c();var Vs=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","host","content-length","content-type","accept","user-agent","authorization","cookie","x-shopify-access-token"]);function Ao(t){let e={};for(let[r,n]of Object.entries(t))!Vs.has(r.toLowerCase())&&typeof n=="string"&&(e[r]=n);return e}import{createHmac as Ys}from"crypto";import{createServer as Js}from"http";import{readFileSync as Uo}from"fs";import{createRequire as Xs}from"module";function Zs(t,e){return Ys("sha256",t).update(`graphiql:${e}`).digest("hex")}function Ft(t,e,r){return t?.trim()||Zs(e,r)}var ko=Xs(import.meta.url),lt=class extends O{constructor(){super("Failed to refresh credentials. Check that your app is installed, and try again.")}};function Do({stdout:t,port:e,appName:r,appUrl:n,apiKey:o,apiSecret:s,key:i,storeFqdn:a}){let l=Ft(i,s,a);y(`Setting up GraphiQL HTTP server on port ${e}...`,t);let d=Ve(),p=Ye(),u;async function f(){return u??=await h(),u}async function h(){try{y("refreshing token",t),u=void 0;let S={client_id:o,client_secret:s,grant_type:"client_credentials"};return(await(await Ee(`https://${a}/admin/oauth/access_token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)})).json()).access_token}catch{throw new lt}}async function m(){return Mr(async()=>Pr({storeFqdn:a,token:await f()}),h)}let g=ko.resolve("../../../assets/graphiql/favicon.ico"),w=Uo(g),x=ko.resolve("../../../assets/graphiql/style.css"),D=Uo(x,"utf8");d.use(R(S=>{z(S,"Access-Control-Allow-Origin","*"),z(S,"Access-Control-Allow-Methods","GET, OPTIONS"),z(S,"Access-Control-Allow-Headers","Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, ngrok-skip-browser-warning")})),p.get("/graphiql/ping",R(()=>"pong")),p.get("/graphiql/favicon.ico",R(S=>(z(S,"Content-Type","image/x-icon"),w))),p.get("/graphiql/simple.css",R(S=>(z(S,"Content-Type","text/css"),D))),p.get("/graphiql/status",R(async()=>{try{return await m(),{status:"OK",storeFqdn:a,appName:r,appUrl:n}}catch{return{status:"UNAUTHENTICATED"}}})),p.get("/graphiql",R(async S=>{y("Handling /graphiql request",t);let q=bt(S);if(l&&q.key!==l)return ke(S,404),`Invalid path ${S.path}`;let $=Ue(S,"x-forwarded-proto")==="https",V=Ue(S,"host"),v=`http${$?"s":""}://${V}`,_;try{_=await m()}catch(xe){if(xe instanceof lt)return De(Co,{previewUrl:n,url:v});throw xe}let B=_.sort().reverse()[0];function F(xe){return xe?decodeURIComponent(xe).replace(/\n/g,"\\n"):void 0}let K=F(q.query),Bt=F(q.variables);return De(So({apiVersion:B,apiVersions:[..._,"unstable"],appName:r,appUrl:n,key:l,storeFqdn:a}),{url:v,defaultQueries:[{query:bo}],query:K?JSON.stringify(K):void 0,variables:Bt?JSON.stringify(Bt):void 0})})),p.post("/graphiql/graphql.json",R(async S=>{y("Handling /graphiql/graphql.json request",t);let q=bt(S);if(l&&q.key!==l)return ke(S,404),`Invalid path ${S.path}`;let j=wr(a,q.api_version);try{let $=await kr(S),V=JSON.stringify($),v=Ur(S),_=Ao(v),B=async()=>{let K={..._,Accept:"application/json","Content-Type":"application/json","X-Shopify-Access-Token":await f(),"User-Agent":`ShopifyCLIGraphiQL/${Ht}`};return Ee(j,{method:"POST",headers:K,body:V})},F=await B();return F.status===401&&(y("Token expired, fetching new token",t),await h(),F=await B()),z(S,"Content-Type","application/json"),ke(S,F.status),F.json()}catch($){return ke(S,500),$ instanceof Error?{errors:[$.message]}:{errors:["Unknown error"]}}})),d.use(p);let P=Js(Je(d));return P.listen(e,"localhost",()=>t.write(`GraphiQL server started on port ${e}`)),P}async function To(t){return{type:"graphiql",prefix:"graphiql",options:t,function:ei}}var ei=async({stdout:t,abortSignal:e},r)=>{let n=Do({...r,stdout:t});e.addEventListener("abort",async()=>{n.close()})};c();async function Io({webs:t,proxyUrl:e,frontendPort:r,backendPort:n,apiKey:o,apiSecret:s,scopes:i}){let{frontendConfig:a}=pe(t),l=a?.configuration.hmr_server?await Z():void 0,d=void 0,p=t.map(async u=>{let f=await ti({web:u,frontendPort:r,backendPort:n}),h=l&&u.configuration.roles.includes("frontend")?{port:l,httpPaths:u.configuration.hmr_server.http_paths}:void 0;return{type:"web",prefix:u.configuration.name??["web",...u.configuration.roles].join("-"),function:ri,options:{port:f,portFromConfig:u.configuration.port,apiKey:o,apiSecret:s,hostname:e,backendPort:n,frontendServerPort:r,directory:u.directory,devCommand:u.configuration.commands.dev,preDevCommand:u.configuration.commands.predev,scopes:i,shopCustomDomain:d,hmrServerOptions:h,roles:u.configuration.roles}}});return Promise.all(p)}async function ti({web:t,frontendPort:e,backendPort:r}){return ve(t,"frontend")?e:ve(t,"backend")?r:Z()}async function ri({stdout:t,stderr:e,abortSignal:r},{port:n,apiKey:o,apiSecret:s,hostname:i,backendPort:a,frontendServerPort:l,directory:d,devCommand:p,preDevCommand:u,scopes:f,shopCustomDomain:h,hmrServerOptions:m}){let g=m?.port,w={SHOPIFY_API_KEY:o,SHOPIFY_API_SECRET:s,HOST:i,SCOPES:f,NODE_ENV:"development",...h&&{SHOP_CUSTOM_DOMAIN:h},BACKEND_PORT:`${a}`,FRONTEND_PORT:`${l}`,...g&&{HMR_SERVER_PORT:`${g}`},APP_URL:i,APP_ENV:"development",REMIX_DEV_ORIGIN:i},x={signal:r,directory:d,port:n,env:w,stdout:t,stderr:e};u&&(t.write(`Running pre-dev command: "${u}"`),await Lo({...x,command:u,showOutput:gr()})),await Lo({...x,command:p,showOutput:!0})}async function Lo({command:t,signal:e,directory:r,port:n,env:o,showOutput:s,stdout:i,stderr:a}){let l=t.split("&&").map(d=>d.trim())??[];for(let d of l){let[p,...u]=d.split(" ");p?.length!==0&&await Ge(p,u,{cwd:r,stdout:s?i:void 0,stderr:a,signal:e,env:{...o,PORT:`${n}`,SERVER_PORT:`${n}`}})}}c();c();c();var ct=class{constructor(e){this.stdout=e}async info(e){await this.log(e)}async warning(e){await this.log(T`${U.yellow(e)}`.value)}async success(e){await this.log(T`${U.green(e)}`.value)}async debug(e){y(e,this.stdout)}async error(e,r){let n=U.errorText("\u274C Error"),o=U.errorText(`\u2514 ${e}`);await this.log(T`${n}`.value,r),await this.log(T`${o}`.value,r)}async logUserErrors(e,r){if(typeof e=="string")await this.error(e);else if(e instanceof Error)await this.error(e.message);else{let n=e.map(o=>{let s=o.on?o.on[0]:void 0,i=r.find(a=>a.uid===s?.user_identifier);return{error:o.message,prefix:i?.handle??"app-preview"}});await this.logMultipleErrors(n)}}async logExtensionEvents(e){let r=e.extensionEvents.filter(o=>o.extension.isAppConfigExtension),n=e.extensionEvents.filter(o=>!o.extension.isAppConfigExtension);r.length&&await this.log("App config updated","app-config"),n.forEach(async o=>{let s=o.extension.handle,i=`Extension ${o.type}`;await this.log(i,s)})}async logExtensionUpdateMessages(e){if(!e)return;let r=e.extensionEvents??[],o=(await Promise.all(r.map(async i=>i.type==="deleted"?[]:(await i.extension.getDevSessionUpdateMessages())?.map(l=>({message:l,prefix:i.extension.handle}))??[]))).flat(),s=o.map((i,a)=>{let l=T`${U.gray(a===o.length-1?"\u2514 ":"\u2502 ")}${i.message}`.value;return this.log(l,i.prefix)});await Promise.all(s)}async logMultipleErrors(e){let r=U.errorText("\u274C Error");await this.log(T`${r}`.value,"app-preview");let n=e.map(o=>{let s=U.errorText(`\u2514 ${o.error}`);return this.log(T`${s}`.value,o.prefix)});await Promise.all(n)}async log(e,r){await X({outputPrefix:r??"app-preview",stripAnsi:!1},()=>{this.stdout.write(e)})}};var dt=class t{constructor(e,r){this.failedEvents=[];this.currentSessionState=null;this.statusManager=e.devSessionStatusManager,this.logger=new ct(r),this.options=e,this.appWatcher=e.appWatcher,this.bundlePath=e.appWatcher.buildOutputPath,this.appEventsProcessor=new Wr(n=>this.processEvents(n))}static async start(e,r){let n=new t(e,r);return await n.start(),n}async start(){await this.logger.info(`Preparing dev preview on ${this.options.storeFqdn}`),this.statusManager.setMessage("LOADING"),this.appWatcher.onEvent(async e=>this.onEvent(e)).onStart(async e=>this.onStart(e)).onError(async e=>this.handleDevSessionResult({status:"unknown-error",error:e}))}async onEvent(e){await this.validateAppEvent(e)&&this.appEventsProcessor.enqueue(e)}async processEvents(e){let r=[...this.failedEvents,...e],n=this.consolidateAppEvents(r);if(this.failedEvents=[],!n)return;this.statusManager.setMessage("CHANGE_DETECTED"),this.updatePreviewURL(n),await this.logger.logExtensionEvents(n);let o=_r(),s=await this.bundleExtensionsAndUpload(n);await this.handleDevSessionResult(s,n),await this.logger.debug(`\u2705 Event handled [Network: ${Et(o)}ms - Total: ${Et(n.startTime)}ms]`)}consolidateAppEvents(e){if(e.length===0)return;if(e.length===1)return e[0];let r=e[0],n=e[e.length-1];if(!r||!n)return;let o=new Map;for(let i of e)for(let a of i.extensionEvents)o.set(a.extension.uid,a);return{app:n.app,path:n.path,extensionEvents:Array.from(o.values()),startTime:r.startTime,appWasReloaded:e.some(i=>i.appWasReloaded)}}async onStart(e){let r=this.parseBuildErrors(e);if(r.length)await this.logger.logMultipleErrors(r),await setImmediate(()=>{let n=r.map(o=>o.prefix);throw new O(`Dev preview aborted, build errors detected in extensions: ${n}`)});else{let n=await this.bundleExtensionsAndUpload(e);await this.handleDevSessionResult(n,e)}}async validateAppEvent(e){if(!this.statusManager.status.isReady)return await this.logger.warning("Change detected, but dev preview is not ready yet."),!1;let r=this.parseBuildErrors(e);return r.length?(await this.logger.logMultipleErrors(r),this.statusManager.setMessage("BUILD_ERROR"),!1):e.extensionEvents.length===0?(this.statusManager.setMessage("READY"),!1):!0}parseBuildErrors(e){return e.extensionEvents.filter(n=>n.buildResult?.status==="error").map(n=>({error:"Build error. Please review your code and try again.",prefix:n.extension.handle}))}async handleDevSessionResult(e,r){e.status==="updated"?(await this.logger.success(`\u2705 Updated dev preview on ${this.options.storeFqdn}`),await this.logger.logExtensionUpdateMessages(r),await this.setUpdatedStatusMessage()):e.status==="created"?(this.statusManager.updateStatus({isReady:!0}),await this.logger.success("\u2705 Ready, watching for changes in your app "),await this.logger.logExtensionUpdateMessages(r),this.statusManager.setMessage("READY")):e.status==="aborted"?await this.logger.debug("\u274C Dev preview update aborted (new change detected or error during update)"):(e.status==="remote-error"||e.status==="unknown-error")&&(await this.logger.logUserErrors(e.error,r?.app.allExtensions??[]),e.error instanceof Error&&e.error.cause==="validation-error"?this.statusManager.setMessage("VALIDATION_ERROR"):(r&&this.failedEvents.push(r),this.statusManager.setMessage("REMOTE_ERROR"))),!this.statusManager.status.isReady&&!ze()&&setImmediate(()=>{throw new O("Failed to start dev preview.")})}updatePreviewURL(e){let r=e.app.allExtensions.filter(i=>i.isPreviewable).length>0,o=je()&&r?this.options.appLocalProxyURL:this.options.appPreviewURL,s=e.app.nonConfigExtensions.length>0;this.statusManager.updateStatus({previewURL:o,appEmbedded:e.app.configuration.embedded,hasExtensions:s})}async setUpdatedStatusMessage(){this.statusManager.setMessage("UPDATED"),setTimeout(async()=>{this.statusManager.status.statusMessage?.message==="Updated"&&this.statusManager.setMessage("READY")},2e3)}async bundleExtensionsAndUpload(e){try{let{manifest:r,inheritedModuleUids:n,assets:o}=await this.createManifest(e),s=await this.uploadAssetsIfNeeded(o,!this.statusManager.status.isReady),i=Pe(this.options.url);if(this.statusManager.status.isReady){let a={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:s,manifest:r,inheritedModuleUids:n};return this.devSessionUpdateWithRetry(a)}else{let a={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:s,websocketUrl:i};return this.devSessionCreateWithRetry(a)}}catch(r){if(r.statusCode===401)throw new Error("Unauthorized");if(r instanceof tr)throw r.response.status===401||r.response.status===403?new O("Auth session expired. Please run `shopify app dev` again."):(await this.logger.debug(JSON.stringify(r.response,null,2)),new O("Unknown error"));return r.code==="ETIMEDOUT"?{status:"unknown-error",error:new Error("Request timed out, please check your internet connection and try again.")}:{status:"unknown-error",error:r}}}async createManifest(e){let r=e.extensionEvents.filter(a=>a.type!=="deleted").map(a=>a.extension.uid);e.app.allExtensions.some(a=>a.type==="admin")&&!r.includes("admin")&&r.push("admin");let n=e.app.allExtensions.filter(a=>!r.includes(a.uid)).map(a=>a.uid),o=await e.app.manifest(void 0);await wn(o,this.bundlePath),this.statusManager.status.isReady&&(o.modules=o.modules.filter(a=>r.includes(a.uid)));let s=await Kt(this.bundlePath),i=o.modules.map(a=>a.assets).filter(a=>s.includes(a));return{manifest:o,inheritedModuleUids:n,assets:i}}async uploadAssetsIfNeeded(e,r){if(!e.length&&!r)return;let n=I(de(this.bundlePath),`dev-bundle.${this.options.developerPlatformClient.bundleFormat}`),o=[...e.map(i=>`${i}/**`),...xn];r&&o.push("manifest.json"),await bn(this.bundlePath,n,o);let s=await this.getSignedURLWithRetry();return await Sn(s,n),s}async getSignedURLWithRetry(){return En(this.options.developerPlatformClient,{apiKey:this.options.appId,organizationId:this.options.organizationId,id:this.options.appId})}async devSessionUpdateWithRetry(e){let r=await this.options.developerPlatformClient.devSessionUpdate(e),n=r.devSessionUpdate?.userErrors??[],o=r.devSessionUpdate?.devSession;if(o&&this.currentSessionState){let s=Pe(this.options.url),i=this.currentSessionState?.userId;if(o.websocketUrl!==s||o.user?.id!==i){let a=o.user?.email;await this.logger.error(`Another developer ${a?`(${a}) `:""}has taken ownership of this dev preview.`);let l=`Another user${a?` (${a})`:""} has taken ownership of this dev preview. Your preview is no longer active.`,d=["You can restart by running",{command:"shopify app dev"},"again."];throw new O(l,d)}this.currentSessionState={websocketUrl:o.websocketUrl,userId:o.user?.id??null,userEmail:o.user?.email??null}}return n.length?{status:"remote-error",error:n}:{status:"updated"}}async devSessionCreateWithRetry(e){let r=await this.options.developerPlatformClient.devSessionCreate(e),n=r.devSessionCreate?.userErrors??[],o=r.devSessionCreate?.warnings??[],s=r.devSessionCreate?.devSession;return s&&(this.currentSessionState={websocketUrl:s.websocketUrl,userId:s.user?.id??null,userEmail:s.user?.email??null}),o.length>0&&await Promise.all(o.map(i=>{let a=i.code==="SESSION_TAKEOVER"?`\u26A0\uFE0F ${i.message}`:i.message;return this.logger.warning(a)})),n.length?{status:"remote-error",error:n}:{status:"created"}}};async function Oo({app:t,apiKey:e,developerPlatformClient:r,...n}){return{type:"dev-session",prefix:"app-preview",function:ni,options:{app:t,apiKey:e,developerPlatformClient:r,...n}}}var ni=async({stdout:t},e)=>{await dt.start(e,t)};c();c();c();var Mo=async({appLog:t,appLogPayload:e,stdout:r,storeName:n,logsDir:o})=>{let s=Xt().substring(0,6),a=`${oi(t.log_timestamp)}_${t.source_namespace}_${t.source}_${s}.json`,l=qn({appLog:t,appLogPayload:e,prettyPrint:!0,storeName:n}),d=I(o,a);try{return await _e(o),await Me(d,l),{fullOutputPath:d,identifier:s}}catch(p){throw r.write(`Error while writing log to file: ${p}
|
|
310
|
+
`),p}};function oi(t){let e=new Date(t),r=e.getUTCFullYear(),n=(e.getUTCMonth()+1).toString().padStart(2,"0"),o=e.getUTCDate().toString().padStart(2,"0"),s=e.getUTCHours().toString().padStart(2,"0"),i=e.getUTCMinutes().toString().padStart(2,"0"),a=e.getUTCSeconds().toString().padStart(2,"0"),l=e.getUTCMilliseconds().toString().padStart(3,"0");return`${r}${n}${o}_${s}${i}${a}_${l}Z`}var ut=async({stdout:t,appLogsFetchInput:{jwtToken:e,cursor:r},developerPlatformClient:n,resubscribeCallback:o,storeName:s,organizationId:i,abortSignal:a,logsDir:l,consecutiveResubscribeFailures:d=0})=>{if(!a?.aborted)try{let p=e,u=Tn,f=d,h=await n.appLogs({jwtToken:e,cursor:r},i),{errors:m,status:g}=h;if(g===200){f=0;let{app_logs:x}=h;for(let D of x){let P=JSON.parse(D.payload);await X({outputPrefix:D.source,stripAnsi:!1},async()=>{D.log_type===On?(si(D,P,t),P=new kn(Dn(P))):D.log_type.startsWith(Mn)?ii(D,P,t):t.write(JSON.stringify(P));let S=await Mo({appLog:D,appLogPayload:P,stdout:t,storeName:s,logsDir:l});t.write(T`${U.gray("\u2514 ")}${U.link("Open log file",`file://${S.fullOutputPath}`,`Log: ${S.fullOutputPath}`)} ${U.gray(`(${S.identifier})`)}\n`.value)})}}else{let x={errors:m.map(P=>({message:P,status:g}))},D=await Nn({response:x,onThrottle:P=>{G("Request throttled while polling app logs.",t),G(`Retrying in ${P/1e3} seconds.`,t)},onUnknownError:P=>{G("Error while polling app logs.",t),G(`Retrying in ${P/1e3} seconds.`,t)},onResubscribe:()=>o()});if(D.resubscribeResult==="failed"){if(f+=1,f>=Ln){G("App log streaming session has expired. Please restart your dev session.",t);return}}else D.resubscribeResult==="succeeded"&&(f=0);D.nextJwtToken&&(p=D.nextJwtToken),u=D.retryIntervalMs}let{cursor:w}=h;setTimeout(()=>{ut({stdout:t,appLogsFetchInput:{jwtToken:p,cursor:w??r},developerPlatformClient:n,resubscribeCallback:o,storeName:s,organizationId:i,abortSignal:a,logsDir:l,consecutiveResubscribeFailures:f}).catch(x=>{y(`Unexpected error during polling: ${x}}
|
|
311
|
+
`)})},u)}catch(p){G("Error while polling app logs.",t),G(`Retrying in ${kt/1e3} seconds.`,t),y(`${p}}
|
|
312
|
+
`),setTimeout(()=>{ut({stdout:t,appLogsFetchInput:{jwtToken:e,cursor:void 0},developerPlatformClient:n,resubscribeCallback:o,storeName:s,organizationId:i,abortSignal:a,logsDir:l}).catch(u=>{y(`Unexpected error during polling: ${u}}
|
|
313
|
+
`)})},kt)}};function si(t,e,r){let n=(e.fuel_consumed/In).toFixed(4);t.status==="success"?r.write(`Function export "${e.export}" executed successfully using ${n}M instructions.`):t.status==="failure"&&r.write(`\u274C Function export "${e.export}" failed to execute with error: ${e.error_type}`);let o=e.logs;o.length>0&&r.write(o.split(`
|
|
314
|
+
`).filter(Boolean).map(s=>T`${U.gray("\u2502 ")}${s}`.value).join(`
|
|
315
|
+
`))}function ii(t,e,r){t.log_type===_n?r.write("Function network access response retrieved from cache."):t.log_type===Rn?e.reason===Fn?r.write("Function network access request executing in background because there is no cached response."):e.reason===Wn&&r.write("Function network access request executing in background because the cached response is about to expire."):t.log_type===$n&&(t.status==="success"?r.write("Function network access request executed successfully."):t.status==="failure"&&r.write(`\u274C Function network access request failed to execute with error: ${e.error}.`))}function ai(t){return t.allExtensions.some(e=>e.isFunctionExtension)}async function _o({developerPlatformClient:t,subscription:{shopIds:e,apiKey:r},storeName:n,organizationId:o,appWatcher:s,localApp:i}){return{type:"app-logs-subscribe",prefix:"app-logs",function:pi,options:{developerPlatformClient:t,appLogsSubscribeVariables:{shopIds:e,apiKey:r},storeName:n,organizationId:o,appWatcher:s,localApp:i}}}var pi=async({stdout:t,stderr:e,abortSignal:r},{developerPlatformClient:n,appLogsSubscribeVariables:o,storeName:s,organizationId:i,appWatcher:a,localApp:l})=>{async function d(p){let u=await Dt(n,o,i,t),f=l.getLogsDir();await _e(f),await ut({stdout:t,appLogsFetchInput:{jwtToken:u},resubscribeCallback:()=>Dt(n,o,i),developerPlatformClient:n,storeName:s,organizationId:i,abortSignal:p,logsDir:f})}try{let p=!1,u,f=async h=>{let m=ai(h.app);if(m&&!p){y("Function extensions detected, starting logs polling"),p=!0,u=new AbortController;try{await d(u.signal)}catch(g){y(`Failed to start function logs: ${g}`,e)}}else!m&&p&&(y("No function extensions detected, stopping logs polling"),p=!1,u?.abort(),u=void 0)};a.onStart(f).onEvent(f)}catch{}};c();async function Ro(t){return{type:"app-watcher",prefix:"app-preview",options:t,function:li}}var li=async({stdout:t,stderr:e,abortSignal:r},n)=>{let{appWatcher:o}=n;await o.start({stdout:t,stderr:e,signal:r})};c();import{EventEmitter as ci}from"events";var di={BUILD_ERROR:{message:"Build error. Please review your code and try again",type:"error"},READY:{message:"Ready, watching for changes in your app",type:"success"},LOADING:{message:"Preparing dev preview",type:"loading"},UPDATED:{message:"Updated",type:"success"},VALIDATION_ERROR:{message:"Validation error in your app configuration",type:"error"},REMOTE_ERROR:{message:"Error updating dev preview",type:"error"},CHANGE_DETECTED:{message:"Change detected, updating dev preview",type:"loading"}},mt=class extends ci{constructor(r){super();this.currentStatus={isReady:!1,previewURL:void 0,graphiqlURL:void 0,statusMessage:void 0};r&&(this.currentStatus=r)}updateStatus(r){let n={...this.currentStatus,...r};ir(this.currentStatus,n)||(this.currentStatus=n,this.emit("dev-session-update",n))}setMessage(r){this.updateStatus({statusMessage:di[r]})}get status(){return this.currentStatus}reset(){this.currentStatus={isReady:!1,previewURL:void 0,graphiqlURL:void 0,statusMessage:void 0}}};c();import*as $o from"http";import*as Fo from"https";function Wo(t){return"errors"in t&&Array.isArray(t.errors)}async function No(t,e,r,n){let s=(await import("../../../http-proxy-node16-Q5DZMBHC.js")).default.createProxyServer(),i=mi(t,s,n),a=r?Fo.createServer(r,i):$o.createServer(i);return a.on("upgrade",ui(t,s,n)),e.addEventListener("abort",()=>{y("Closing reverse HTTP proxy"),a.close()}),{server:a}}function ui(t,e,r){return function(n,o,s){let i=qo(t,n,!0);if(i)return e.ws(n,o,s,{target:i},a=>{X({outputPrefix:"proxy",stripAnsi:!1},()=>{let d=(Wo(a)?a.errors[a.errors.length-1]:void 0)??a;G(`Error forwarding websocket request: ${d.message}`,r),G(`\u2514 Unreachable target "${i}" for path: "${n.url}"`,r)})});o.destroy()}}function mi(t,e,r){return function(n,o){let s=qo(t,n);if(s)return n.method==="OPTIONS"?(o.writeHead(204,{"Access-Control-Allow-Origin":n.headers.origin??"*","Access-Control-Allow-Methods":n.headers["access-control-request-method"]??"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":n.headers["access-control-request-headers"]??"Content-Type, Authorization","Access-Control-Max-Age":"86400"}),o.end()):e.web(n,o,{target:s},i=>{X({outputPrefix:"proxy",stripAnsi:!1},()=>{let l=(Wo(i)?i.errors[i.errors.length-1]:void 0)??i;G(`Error forwarding web request: ${l.message}`,r),G(`\u2514 Unreachable target "${s}" for path: "${n.url}"`,r)})});y(T`
|
|
316
|
+
Reverse HTTP proxy error - Invalid path: ${n.url??""}
|
|
317
|
+
These are the allowed paths:
|
|
318
|
+
${U.json(JSON.stringify(t))}
|
|
319
|
+
`),o.statusCode=500,o.end(`Invalid path ${n.url}`)}}function qo(t,e,r=!1){let n=e.url??"/";for(let o in t)if(n.startsWith(o))return t[o];return r&&t.websocket?t.websocket:t.default}async function Bo({localApp:t,remoteAppUpdated:e,developerPlatformClient:r,remoteApp:n,storeFqdn:o,storeId:s,commandOptions:i,network:a,graphiqlPort:l,graphiqlKey:d}){let p=n.apiKey,u=n.apiSecretKeys[0]?.secret??"",f=Zt(),h=!Ie(f[Ze.disableGraphiQLExplorer]),m=await nn(t),g=new Cn(m,a.proxyUrl),w=m.allExtensions.some(K=>K.isPreviewable),x=`${a.proxyUrl}/extensions/dev-console`,D=je(),P;if(D)P=st(o,p);else{let K=await Fe();P=jn(o,p,K)}let q=D&&w?x:P,j=Ft(d,u,o),$=h?`http://localhost:${l}/graphiql?key=${encodeURIComponent(j)}`:void 0,V=m.configuration.embedded,v=m.nonConfigExtensions.length>0,_=new mt({isReady:!1,previewURL:q,graphiqlURL:$,appEmbedded:V,hasExtensions:v}),B=[...await Io({webs:m.webs,proxyUrl:a.proxyUrl,frontendPort:a.frontendPort,backendPort:a.backendPort,apiKey:p,apiSecret:u,scopes:Gr(m.configuration)}),h?await To({appName:n.title,appUrl:P,port:l,apiKey:p,apiSecret:u,key:j,storeFqdn:o}):void 0,await fo({allExtensions:m.realExtensions,storeFqdn:o,storeId:s,apiKey:p,subscriptionProductUrl:i.subscriptionProductUrl,checkoutCartUrl:i.checkoutCartUrl,proxyUrl:a.proxyUrl,appName:m.name,appDotEnvFile:m.dotenv,grantedScopes:n.grantedScopes,appId:n.id,appDirectory:m.directory,appWatcher:g}),r.supportsDevSessions?await Oo({app:m,apiKey:p,developerPlatformClient:r,url:a.proxyUrl,appId:n.id,organizationId:n.organizationId,storeFqdn:o,appWatcher:g,appPreviewURL:P,appLocalProxyURL:x,devSessionStatusManager:_}):await vo({localApp:m,remoteApp:n,apiKey:p,developerPlatformClient:r,proxyUrl:a.proxyUrl,appWatcher:g}),await Gn({remoteApp:n,localApp:m,storeFqdn:o,theme:i.theme,themeExtensionPort:i.themeExtensionPort}),wo({webs:m.webs,backendPort:a.backendPort,frontendPort:a.frontendPort,organizationId:n.organizationId,developerPlatformClient:r,storeFqdn:o,apiSecret:u,remoteAppUpdated:e}),await _o({developerPlatformClient:r,subscription:{shopIds:[Number(s)],apiKey:p},storeName:o,organizationId:n.organizationId,localApp:t,appWatcher:g}),await Ro({appWatcher:g})].filter(fi);return{processes:await gi(B,a.proxyPort,a.reverseProxyCert),previewUrl:q,graphiqlUrl:$,devSessionStatusManager:_}}var fi=t=>t!==void 0&&t!==!1;async function gi(t,e,r){let n=await Promise.all(t.map(async i=>{let a={};if(i.type==="web"&&i.options.roles.includes("frontend")){let l=i.options.portFromConfig??i.options.port;a.default=`http://localhost:${l}`;let d=i.options.hmrServerOptions;d&&(a.websocket=`http://localhost:${d.port}`,d.httpPaths.forEach(p=>a[p]=`http://localhost:${d.port}`)),i.options.port=l}else if(i.type==="previewable-extension"){let l=await Z();a[i.options.pathPrefix]=`http://localhost:${l}`,i.options.port=l}return{process:i,rules:a}})),o=n.map(({process:i})=>i),s=n.map(({rules:i})=>i).reduce((i,a)=>({...i,...a}),{});return Object.keys(s).length>0&&o.push({type:"proxy-server",prefix:"proxy",function:hi,options:{port:e,rules:s,localhostCert:r}}),o}var hi=async({abortSignal:t,stdout:e},{port:r,rules:n,localhostCert:o})=>{let{server:s}=await No(n,t,o,e);ne(`Proxy server started on port ${r} ${o?`with certificate ${o.certPath}`:""}`,e),await s.listen(r,"localhost")};c();c();var E=Y(ie(),1);var vi=(t,e)=>Math.max(...t.map(r=>r.prefix.length),...e.map(r=>r.handle.length)),Ho=({abortController:t,processes:e,previewUrl:r,graphiqlUrl:n="",graphiqlPort:o,app:s,pollingTime:i=5e3,developerPreview:a,isEditionWeek:l})=>{let{canEnablePreviewMode:d,developmentStorePreviewEnabled:p}=s,{isRawModeSupported:u}=ue(),f=(0,E.useRef)(),h=`http://localhost:${o}/graphiql`,[m,g]=(0,E.useState)(void 0),[w,x]=(0,E.useState)(!0),[D,P]=(0,E.useState)(void 0),{isAborted:S}=qe(t.signal,async v=>{v?g("Shutting down dev because of an error ..."):(g("Shutting down dev ..."),Xe()),clearInterval(f.current),await a.disable()}),q=(0,E.useMemo)(()=>e.map(v=>({...v,action:async(_,B,F)=>{try{return await v.action(_,B,F)}catch(K){t.abort(K)}}})),[e,t]);(0,E.useEffect)(()=>{let v=async()=>{try{let B=await a.fetchMode();x(B??!1),P("")}catch{P("Failed to fetch the latest status of the development store preview, trying again in 5 seconds.")}},_=async()=>{try{await a.enable(),P("")}catch{P("Failed to turn on development store preview automatically.\nTry turning it on manually by pressing `d`."),x(!!p)}};if(d){_();let B=()=>setInterval(()=>v(),i);f.current=B()}return()=>{clearInterval(f.current)}},[d]),me((v,_)=>{We(v,_,()=>t.abort()),(async()=>{try{if(P(""),v==="p"&&r)await ee.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),await se(r);else if(v==="g"&&n)await ee.addPublicMetadata(()=>({cmd_dev_graphiql_opened:!0})),await se(h);else if(v==="q")t.abort();else if(v==="e"&&l)await se("https://shopify.link/yQmk");else if(v==="d"&&d){await ee.addPublicMetadata(()=>({cmd_dev_dev_preview_toggle_used:!0}));let F=!w;x(F);try{if(!await a.update(F))throw new Error(`Failed to turn ${F?"on":"off"} development store preview.`)}catch{x(w),P(`Failed to turn ${F?"on":"off"} development store preview.`)}}}catch{P("Failed to handle your input.")}})()},{isActive:!!u});let j=new Date,$=j.getMonth()>3?"Summer":"Winter",V=j.getFullYear();return E.default.createElement(E.default.Fragment,null,E.default.createElement(Ne,{processes:q,prefixColumnSize:vi(q,s.extensions),abortSignal:t.signal,keepRunningAfterProcessesResolve:!0,useAlternativeColorPalette:!1}),S?null:E.default.createElement(N,{marginY:1,paddingTop:1,flexDirection:"column",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},u?E.default.createElement(N,{flexDirection:"column"},l?E.default.createElement(A,null,J.pointerSmall," Press ",E.default.createElement(A,{bold:!0},"e")," ",J.lineVertical," check out ",$," Edition",` ${V}`,", live NOW with 100+ product announcements!"):null,d?E.default.createElement(A,null,J.pointerSmall," Press ",E.default.createElement(A,{bold:!0},"d")," ",J.lineVertical," toggle development store preview: ",w?E.default.createElement(A,{color:"green"},"\u2714 on"):E.default.createElement(A,{color:"red"},"\u2716 off")):null,n?E.default.createElement(A,null,J.pointerSmall," Press ",E.default.createElement(A,{bold:!0},"g")," ",J.lineVertical," open GraphiQL (Admin API) in your browser"):null,E.default.createElement(A,null,J.pointerSmall," Press ",E.default.createElement(A,{bold:!0},"p")," ",J.lineVertical," preview in your browser"),E.default.createElement(A,null,J.pointerSmall," Press ",E.default.createElement(A,{bold:!0},"q")," ",J.lineVertical," quit")):null,E.default.createElement(N,{marginTop:u?1:0,flexDirection:"column"},m?E.default.createElement(A,null,m):E.default.createElement(E.default.Fragment,null,E.default.createElement(A,null,"Preview URL: ",E.default.createElement(fe,{url:r})),n?E.default.createElement(A,null,"GraphiQL URL: ",E.default.createElement(fe,{url:h})):null)),D?E.default.createElement(A,{color:"red"},D):null))};c();c();var we=Y(ie(),1);var Go=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function zo(){let[t,e]=(0,we.useState)(0);return(0,we.useEffect)(()=>{let r=setInterval(()=>{e(n=>(n+1)%Go.length)},70);return()=>clearInterval(r)},[]),we.default.createElement(A,null,Go[t])}c();var M=Y(ie(),1);var jo=.9,Ko=({tabs:t,initialActiveTab:e})=>{let{stdout:r}=Vt(),{isRawModeSupported:n}=ue(),[o,s]=(0,M.useState)(e),[i,a]=(0,M.useState)(Math.floor(r.columns*jo)),[l,d]=(0,M.useState)(!0),p=(0,M.useRef)(null);if(!o)throw new Error("No tabs provided");me((m,g)=>{(async()=>{if(g?.leftArrow||g?.rightArrow||g?.tab){let P=Object.entries(t).filter(([V,v])=>v.content),S=P.findIndex(([V])=>V===o);if(S===-1)return;let q=g?.leftArrow?-1:1,j=(S+q+P.length)%P.length,$=P[j];$&&s($[0])}let x=t[m];if(x){x.action?await x.action():s(m);return}let D=t[o];if(D?.shortcuts){let P=D.shortcuts.find(S=>S.key===m);P&&(!P.condition||P.condition())&&await P.action()}})()},{isActive:!!n}),(0,M.useLayoutEffect)(()=>{let m=()=>{if(a(Math.floor(r.columns*jo)),!p.current)return;let g=Yt(p.current);d(g.width<r.columns)};return r.on("resize",m),()=>{r.off("resize",m)}},[r]);let u=Object.entries(t).map(([m,g])=>({...g,inputKey:m,header:` (${m}) ${g.label} `})),f=u.filter(m=>!m.action),h=u.filter(m=>m.action);return M.default.createElement(M.default.Fragment,null,M.default.createElement(N,{paddingTop:0,width:i,flexDirection:"row",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},M.default.createElement(N,{ref:p,flexDirection:"row",flexWrap:"nowrap",flexShrink:0,marginRight:3},M.default.createElement(A,{wrap:"truncate-end"},"\u2502",f.map(m=>M.default.createElement(M.default.Fragment,{key:m.inputKey},M.default.createElement(A,{bold:o===m.inputKey,inverse:o===m.inputKey,wrap:"truncate"},m.header),"\u2502")))),l&&M.default.createElement(N,{flexGrow:1,justifyContent:"flex-end"},h.map((m,g)=>M.default.createElement(A,{wrap:"truncate",key:m.inputKey},"(",m.inputKey,") ",m.label,g<h.length-1&&" \u2502 ")))),M.default.createElement(N,{flexDirection:"column",marginLeft:1,marginRight:1,marginTop:1},t[o]?.content))};var b=Y(ie(),1);var Qo=({abortController:t,processes:e,devSessionStatusManager:r,shopFqdn:n,appURL:o,appName:s,organizationName:i,configPath:a,localURL:l,onAbort:d})=>{let{isRawModeSupported:p}=ue(),[u,f]=(0,b.useState)(void 0),[h,m]=(0,b.useState)(void 0),[g,w]=(0,b.useState)(r.status),[x,D]=(0,b.useState)(!1),{isAborted:P}=qe(t.signal,async v=>{v&&m(typeof v=="string"?v:v.message),r.status.isReady?D(!0):(f("Shutting down dev ..."),await d()),Xe()}),S=(0,b.useMemo)(()=>e.map(v=>({...v,action:async(_,B,F)=>{try{return await v.action(_,B,F)}catch(K){t.abort(K)}}})),[e,t]);(0,b.useEffect)(()=>(r.on("dev-session-update",w),()=>{r.off("dev-session-update",w)}),[]),me((v,_)=>{We(v,_,()=>t.abort())},{isActive:!!p});let q=v=>{switch(v){case"loading":return b.default.createElement(zo,null);case"success":return"\u2705";case"error":return"\u274C"}},j=[{key:"p",shortcutLabel:"Open app preview",linkLabel:"Preview",url:g.previewURL,condition:()=>!!(g.isReady&&g.previewURL),action:async()=>{await ee.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),g.previewURL&&await se(g.previewURL)}},{key:"c",shortcutLabel:"Open Dev Console for extension previews",linkLabel:"Dev Console",url:Lt(n),condition:()=>!!(g.isReady&&g.appEmbedded===!1&&g.hasExtensions),action:async()=>{await ee.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),await se(Lt(n))}},{key:"g",shortcutLabel:"Open GraphiQL (Admin API)",linkLabel:"GraphiQL",url:g.graphiqlURL,condition:()=>!!(g.isReady&&g.graphiqlURL),action:async()=>{await ee.addPublicMetadata(()=>({cmd_dev_graphiql_opened:!0})),g.graphiqlURL&&await se(g.graphiqlURL)}}],$=j.filter(v=>v.condition?.()??!0),V={d:{label:"Dev status",shortcuts:j,content:b.default.createElement(b.default.Fragment,null,g.statusMessage&&b.default.createElement(A,null,q(g.statusMessage.type)," ",g.statusMessage.message),p&&$.length>0&&b.default.createElement(N,{marginTop:1,flexDirection:"column"},$.map(v=>b.default.createElement(A,{key:v.key},J.pointerSmall," ",b.default.createElement(A,{bold:!0},"(",v.key,")")," ",wt()&&v.url?b.default.createElement(fe,{url:v.url,label:v.shortcutLabel}):v.shortcutLabel))),b.default.createElement(N,{marginTop:p?1:0,flexDirection:"column"},u?b.default.createElement(A,null,u):b.default.createElement(b.default.Fragment,null,g.isReady&&!(p&&wt())&&b.default.createElement(b.default.Fragment,null,$.filter(v=>v.url).map(v=>b.default.createElement(A,{key:v.key},v.linkLabel," URL: ",b.default.createElement(fe,{url:v.url})))))))},a:{label:"App info",content:b.default.createElement(N,{flexDirection:"column"},b.default.createElement(Pt,{tabularData:[["App:",s??""],["App URL:",o??""],["Local URL:",o?"":l??""],["Config:",a?.split("/").pop()??""],["Org:",i??""]].filter(([,v])=>v)}))},s:{label:"Store info",content:b.default.createElement(N,{flexDirection:"column"},b.default.createElement(Pt,{tabularData:[["Dev store:",{link:{url:`https://${n}`}}],["Dev store admin:",{link:{url:`https://${n}/admin`}}],["Org:",i??""]].filter(([,v])=>v)}))},q:{label:"Quit",action:async()=>{t.abort()}}};return b.default.createElement(b.default.Fragment,null,b.default.createElement(Ne,{processes:S,prefixColumnSize:Hr,abortSignal:t.signal,keepRunningAfterProcessesResolve:!0,useAlternativeColorPalette:!0}),x&&b.default.createElement(N,{marginTop:1,flexDirection:"column"},b.default.createElement(cr,{type:"info",headline:`A preview of your development changes is still available on ${n}.`,body:["Run",{command:"shopify app dev clean"},"to restore the latest released version of your app."],link:{label:"Learn more about dev previews",url:"https://shopify.dev/beta/developer-dashboard/shopify-app-dev"}})),P?null:b.default.createElement(N,{paddingTop:1,flexDirection:"column",flexGrow:1},p?b.default.createElement(Ko,{tabs:V,initialActiveTab:"d"}):b.default.createElement(N,{marginY:1,paddingTop:0,flexDirection:"column",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},V.d?.content)),h?b.default.createElement(N,{marginTop:1,flexDirection:"column"},b.default.createElement(A,{color:"red"},h)):null)};var Wt=Y(ie(),1);async function Vo({processes:t,previewUrl:e,app:r,abortController:n,graphiqlUrl:o,graphiqlPort:s,developerPreview:i,shopFqdn:a,devSessionStatusManager:l,appURL:d,appName:p,organizationName:u,configPath:f,localURL:h}){if(!mr())await yi({processes:t,app:r,abortController:n,developerPreview:i,shopFqdn:a});else return r.developerPlatformClient.supportsDevSessions?yt(Wt.default.createElement(Qo,{processes:t,abortController:n,devSessionStatusManager:l,shopFqdn:a,appURL:d,appName:p,organizationName:u,configPath:f,localURL:h,onAbort:async()=>{await r.developerPlatformClient.devSessionDelete({appId:r.id,shopFqdn:a})}}),{exitOnCtrlC:!1}):yt(Wt.default.createElement(Ho,{processes:t,abortController:n,previewUrl:e,app:r,graphiqlUrl:o,graphiqlPort:s,developerPreview:i,isEditionWeek:Pi(),shopFqdn:a}),{exitOnCtrlC:!1})}async function yi({processes:t,app:{canEnablePreviewMode:e},abortController:r,developerPreview:n}){return e&&(await n.enable(),r?.signal.addEventListener("abort",async()=>{await n.disable()})),Promise.all(t.map(async o=>{await o.action(process.stdout,process.stderr,r.signal)}))}function Pi(){if(Ie(process.env.IS_EDITION_WEEK))return!0;if(ze())return!1;let t=new Date("2024-01-31T17:00:00.000Z"),e=new Date("2024-02-07T17:00:00.000Z"),r=new Date;return r>=t&&r<=e}c();function Yo(t){if(!t.length)return;let e=t.filter(o=>o.requested!==o.actual);if(e.length===0)return;if(e.length===1&&e[0]){let o=e[0];ae({headline:[`A random port will be used for ${o.for} because ${o?.requested} is not available.`],body:["If you want to use a specific port, you can choose a different one by setting the ",{command:o?.flagToRemedy}," flag."]});return}let r=gt(e.map(o=>o.for)).join(" "),n=gt(e.map(o=>({command:o.flagToRemedy})));ae({headline:[`Random ports will be used for ${r} because the requested ports are not available.`],body:["If you want to use specific ports, you can choose different ports using the",...n,"flags."]})}c();async function Jo(t,e){return e?e.includes("localhost")?"localhost":(await nr(t)).plugins.find(n=>e?.includes(n))??"custom":void 0}c();var Xo=Y(ss(),1);var le="v1.4.4",Zo="FiloSottile/mkcert",Nt=U.genericShellCommand("mkcert");async function wi(t,e,r,n){let o=e[Ze.mkcertBinaryPath];if(o)return o;let i=I(t,r==="win32"?"mkcert.exe":"mkcert");if(await oe(i))return i;let a=await(0,Xo.default)("mkcert",{nothrow:!0});return a?(y(T`Found ${Nt} at ${U.path(a)}`),a):(await xi(i,r,n),i)}async function xi(t,e,r){let n;switch(e){case"darwin":n=r==="arm64"?`mkcert-${le}-darwin-arm64`:`mkcert-${le}-darwin-amd64`;break;case"linux":n=r==="arm64"?`mkcert-${le}-linux-arm64`:`mkcert-${le}-linux-amd64`;break;case"win32":n=`mkcert-${le}-windows-amd64.exe`;break;default:throw new he(`Unsupported platform: ${e}`)}await Or(Zo,le,n,t),y(T`${Nt} saved to ${U.path(t)}`)}async function bi(t){let e=I(t,"mkcert-LICENSE");if(await oe(e))return;let r=`https://raw.githubusercontent.com/${Zo}/refs/tags/${le}/LICENSE`,n={headline:"Failed to download mkcert license.",body:["We tried to download the license for mkcert, but the request failed. You can ",{link:{url:r,label:"view the license here"}}]},o;try{if(o=await Ee(r),!o.ok)return n}catch{return n}let s=await o.text();await Me(e,s)}async function es({appDirectory:t,env:e=process.env,platform:r=process.platform,arch:n=process.arch}){let o=I(".shopify","localhost-key.pem"),s=I(".shopify","localhost.pem"),i=I(t,o),a=I(t,s);if(await oe(i)&&await oe(a))return{keyContent:await W(i),certContent:await W(a),certPath:s};if(!await on())throw new O(`Localhost certificate and key are required at ${s} and ${o}`);let d="",p;return await He([{title:"Finding or downloading mkcert binary",task:async()=>{let f=I(t,".shopify");d=await wi(f,e,r,n),p=await bi(f),y(T`${Nt} found at: ${U.path(d)}`)}}]),p&&Be(p),ne(T`Generating self-signed certificate for localhost. You may be prompted for your password.`),await Ge(d,["-install","-key-file",i,"-cert-file",a,"localhost"]),ne(T`${U.successIcon()} Certificate generated at ${s}\n`),await fr()&&(ae({headline:"It looks like you're using WSL.",body:["Additional steps are required to configure certificate trust in Windows."],link:{label:"See Shopify CLI documentation",url:"https://shopify.dev/docs/apps/build/cli-for-apps/networking-options#localhost-based-development-with-windows-subsystem-for-linux-wsl"}}),ne("\u{1F449} Press any key to continue"),await dr(),ne("")),{keyContent:await W(i),certContent:await W(a),certPath:ce(t,a)}}async function rs(t){let e=await Si(t);await Ei(e);let{processes:r,graphiqlUrl:n,previewUrl:o,devSessionStatusManager:s}=await Bo(e);await Ui(e),await Ti({processes:r,previewUrl:o,graphiqlUrl:n,config:e,devSessionStatusManager:s})}async function Si(t){let{app:e,remoteApp:r,developerPlatformClient:n,store:o,specifications:s,tunnel:i}=t,a;if(i.mode==="auto"){let x=await Z();a=await tn(t.commandConfig,x,"cloudflare")}let l=await ln(r,n,s,r.flags);r.configuration=l,mn({app:e,remoteApp:r,selectedStore:o,cachedInfo:Ut(t.directory),organization:t.organization,tunnelMode:i.mode}),e.configuration.build?.dev_store_url&&(e.configuration.build={...e.configuration.build,dev_store_url:o.shopDomain},await(await vr.read(e.configPath)).patch({build:{dev_store_url:o.shopDomain}})),!t.skipDependenciesInstallation&&!t.project.usesWorkspaces&&await qr(t.project);let d=t.graphiqlPort??await Z(Te.graphiql),p=[{for:"GraphiQL",flagToRemedy:"--graphiql-port",requested:t.graphiqlPort??Te.graphiql,actual:d}];i.mode==="use-localhost"&&p.push({for:"localhost",flagToRemedy:"--localhost-port",requested:i.requestedPort,actual:i.actualPort}),Yo(p);let{webs:u,...f}=await Di(e.directory,e.webs,d,i,a,r.configuration);e.webs=u;let h=e.configuration.build?.automatically_update_urls_on_dev,m=Ut(t.directory)?.previousAppId,g=r.apiKey,w=await ki(u,t.update,f,e,h,r,g,n);return{storeFqdn:o.shopDomain,storeId:o.shopId,remoteApp:r,remoteAppUpdated:r.apiKey!==m,localApp:e,developerPlatformClient:n,commandOptions:t,network:f,partnerUrlsUpdated:w,graphiqlPort:d,graphiqlKey:t.graphiqlKey}}async function Ei(t){await Ci(t),await Ai(t)}async function Ci({localApp:t,remoteApp:e,developerPlatformClient:r,commandOptions:n}){if(r.supportsDevSessions)return;let o=t.configuration.access_scopes,s=e.configuration?.access_scopes,i=d=>d&&d.split(",").map(p=>p.trim()).sort().join(","),a=i(o?.scopes),l=i(s?.scopes);if(!o?.use_legacy_install_flow&&a!==l){let d=[["Run",{command:hr(n.project.packageManager,"shopify app deploy")},"to push your scopes to the Partner Dashboard"]];ae({headline:["The scopes in your TOML don't match the scopes in your Partner Dashboard"],body:[`Scopes in ${zt(t.configPath)}:`,ts(zr(t.configuration)),`
|
|
320
|
+
`,"Scopes in Partner Dashboard:",ts(s?.scopes?.split(",")??[])],nextSteps:d})}}async function Ai(t){let{developerPlatformClient:e,remoteApp:r}=t;if(!e.supportsDevSessions)return;(await e.appExtensionRegistrations(r)).app.extensionRegistrations.filter(o=>o.type.toLowerCase()!=="webhook_subscription").every(o=>o.id)||cn()}async function Ui(t){Vr({directory:t.commandOptions.directory,previousAppId:t.remoteApp.apiKey}),await Ii({devOptions:t.commandOptions,tunnelUrl:t.network.proxyUrl,shouldUpdateURLs:t.partnerUrlsUpdated,storeFqdn:t.storeFqdn}),await pr({config:t.commandOptions.commandConfig,exitMode:"ok"})}async function ki(t,e,r,n,o,s,i,a){let{backendConfig:l,frontendConfig:d}=pe(t),p=!1;if((d??l)&&e){let u=Jr(r.proxyUrl,t.map(({configuration:f})=>f.auth_callback_path).find(f=>f),n.configuration.app_proxy);p=await en({currentURLs:r.currentUrls,appDirectory:n.directory,cachedUpdateURLs:o,newApp:s.newApp,localApp:n,apiKey:i,newURLs:u,developerPlatformClient:a}),p&&(a.supportsDevSessions?n.setDevApplicationURLs(u):await Xr(u,i,a,n))}return p}async function Di(t,e,r,n,o,s){let{backendConfig:i,frontendConfig:a}=pe(e);await Oi(e,r);let l=n.mode==="use-localhost"?{noTunnelUseLocalhost:!0,port:n.actualPort}:{noTunnelUseLocalhost:!1,tunnelUrl:n.mode==="custom"?n.url:void 0,tunnelClient:o},[{frontendUrl:d,frontendPort:p,usingLocalhost:u},f,h]=await Promise.all([Yr(l),er()??i?.configuration.port??Z(),Zr(s)]),m=u?`${d}:${p}`:d,g=a?.configuration.port;a&&(g??=a===i?f:await Z(),a.configuration.port=g),g=g??await Z();let w;if(n.mode==="use-localhost"){let{keyContent:x,certContent:D,certPath:P}=await es({appDirectory:t});w={key:x,cert:D,certPath:P,port:n.actualPort}}return{proxyUrl:m,proxyPort:p,frontendPort:g,backendPort:f,currentUrls:h,webs:e,reverseProxyCert:w}}async function Ti({processes:t,previewUrl:e,graphiqlUrl:r,config:n,devSessionStatusManager:o}){let s=new Jt,i=t.map(p=>({prefix:p.prefix,action:async(f,h,m)=>{let g=p.function;return g({stdout:f,stderr:h,abortSignal:m},p.options)}})),a=n.remoteApp.apiKey,l=n.developerPlatformClient,d={canEnablePreviewMode:l.supportsDevSessions?!1:await Bn({localApp:n.localApp,developerPlatformClient:l,apiKey:a,organizationId:n.remoteApp.organizationId}),developmentStorePreviewEnabled:n.remoteApp.developmentStorePreviewEnabled,apiKey:a,id:n.remoteApp.id,developerPlatformClient:l,extensions:n.localApp.allExtensions};return Vo({processes:i,previewUrl:e,graphiqlUrl:r,graphiqlPort:n.graphiqlPort,app:d,abortController:s,developerPreview:Li(a,l),shopFqdn:n.storeFqdn,devSessionStatusManager:o,appURL:n.localApp.devApplicationURLs?.applicationUrl,appName:n.remoteApp.title,organizationName:n.commandOptions.organization.businessName,configPath:n.localApp.configPath,localURL:n.network.proxyUrl})}function Li(t,e){return e.supportsDevSessions?{fetchMode:()=>Promise.resolve(!1),enable:()=>Promise.resolve(!1),disable:()=>Promise.resolve(),update:()=>Promise.resolve(!1)}:{fetchMode:async()=>!!await pn(t,e),enable:async()=>fn({apiKey:t,developerPlatformClient:e}),disable:async()=>gn({apiKey:t,developerPlatformClient:e}),update:async r=>hn({apiKey:t,developerPlatformClient:e,enabled:r})}}async function Ii(t){let e=await Jo(t.devOptions.commandConfig,t.tunnelUrl);await ee.addPublicMetadata(()=>({cmd_dev_tunnel_type:e,cmd_dev_tunnel_custom_hash:e==="custom"?ht(t.tunnelUrl):void 0,cmd_dev_urls_updated:t.shouldUpdateURLs,store_fqdn_hash:ht(t.storeFqdn),cmd_app_dependency_installation_skipped:t.devOptions.skipDependenciesInstallation})),await ee.addSensitiveMetadata(()=>({store_fqdn:t.storeFqdn,cmd_dev_tunnel_custom:e==="custom"?t.tunnelUrl:void 0}))}function ts(t){return{list:{items:t.length===0?["No scopes"]:t}}}async function Oi(t,e){let r=t.map(o=>o.configuration.port).filter(o=>o),n=r.find((o,s)=>r.indexOf(o)!==s);if(n)throw new O(`Found port ${n} for multiple webs.`,"Please define a unique port for each web.");await Promise.all([...r.map(async o=>{if(!await St(o))throw new O(`Hard-coded port ${o} is not available, please choose a different one.`)}),(async()=>{if(!await St(e)){let s=`Port ${e} is not available for serving GraphiQL.`,i=["Choose a different port for the",{command:"--graphiql-port"},"flag."];throw new O(s,i)}})()])}c();async function ns({useLocalhost:t,localhostPort:e,tunnelUrl:r}){if(r)return{mode:"custom",url:r};if(!t&&!e)return{mode:"auto"};let n=e??Te.localhost,o=await Z(n);if(e&&o!==n){let s=`Port ${e} is not available.`,i=["Choose a different port for the",{command:"--localhost-port"},"flag."];throw new O(s,i)}return{mode:"use-localhost",requestedPort:n,actualPort:o}}var Q=Y(os(),1);var qt=class t extends yn{static{this.summary="Run the app."}static{this.descriptionWithMarkdown="Builds and previews your app on a dev store, and watches for changes. [Read more about testing apps locally](https://shopify.dev/docs/apps/build/cli-for-apps/test-apps-locally)."}static{this.description=this.descriptionWithoutMarkdown()}static{this.flags={...yr,...Nr,store:Q.Flags.string({char:"s",description:"Store URL. Must be an existing development or Shopify Plus sandbox store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>re(e)}),"skip-dependencies-installation":Q.Flags.boolean({description:"Skips the installation of dependencies. Deprecated, use workspaces instead.",env:"SHOPIFY_FLAG_SKIP_DEPENDENCIES_INSTALLATION",default:!1}),"no-update":Q.Flags.boolean({description:"Uses the app URL from the toml file instead an autogenerated URL for dev.",env:"SHOPIFY_FLAG_NO_UPDATE",default:!1}),"subscription-product-url":Q.Flags.string({description:'Resource URL for subscription UI extension. Format: "/products/{productId}"',env:"SHOPIFY_FLAG_SUBSCRIPTION_PRODUCT_URL"}),"checkout-cart-url":Q.Flags.string({description:'Resource URL for checkout UI extension. Format: "/cart/{productVariantID}:{productQuantity}"',env:"SHOPIFY_FLAG_CHECKOUT_CART_URL"}),"tunnel-url":Q.Flags.string({description:'Use a custom tunnel, it must be running before executing dev. Format: "https://my-tunnel-url:port".',env:"SHOPIFY_FLAG_TUNNEL_URL",exclusive:["tunnel"]}),"use-localhost":Q.Flags.boolean({description:"Service entry point will listen to localhost. A tunnel won't be used. Will work for testing many app features, but not those that directly invoke your app (E.g: Webhooks)",env:"SHOPIFY_FLAG_USE_LOCALHOST",default:!1,exclusive:["tunnel-url"]}),"localhost-port":Q.Flags.integer({description:"Port to use for localhost.",env:"SHOPIFY_FLAG_LOCALHOST_PORT"}),theme:Q.Flags.string({char:"t",description:"Theme ID or name of the theme app extension host theme.",env:"SHOPIFY_FLAG_THEME"}),"theme-app-extension-port":Q.Flags.integer({description:"Local port of the theme app extension development server.",env:"SHOPIFY_FLAG_THEME_APP_EXTENSION_PORT"}),notify:Q.Flags.string({description:"The file path or URL. The file path is to a file that you want updated on idle. The URL path is where you want a webhook posted to report on file changes.",env:"SHOPIFY_FLAG_NOTIFY"}),"graphiql-port":Q.Flags.integer({hidden:!0,description:"Local port of the GraphiQL development server.",env:"SHOPIFY_FLAG_GRAPHIQL_PORT"}),"graphiql-key":Q.Flags.string({hidden:!0,description:"Key used to authenticate GraphiQL requests. By default, a key is automatically derived from the app secret. Use this flag to override with a custom key.",env:"SHOPIFY_FLAG_GRAPHIQL_KEY"})}}static analyticsStopCommand(){return"app dev stop"}async run(){let{flags:e}=await this.parse(t),r=await ns({useLocalhost:e["use-localhost"],tunnelUrl:e["tunnel-url"],localhostPort:e["localhost-port"]});await lr(()=>({cmd_app_dependency_installation_skipped:e["skip-dependencies-installation"],cmd_app_reset_used:e.reset,cmd_dev_tunnel_type:r.mode})),await rn(e.path);let n=await vn({directory:e.path,clientId:e["client-id"],forceRelink:e.reset,userProvidedConfigName:e.config}),o=await Pn({appContextResult:n,storeFqdn:e.store,forceReselectStore:e.reset}),s={...n,store:o,directory:e.path,update:!e["no-update"],skipDependenciesInstallation:e["skip-dependencies-installation"],commandConfig:this.config,subscriptionProductUrl:e["subscription-product-url"],checkoutCartUrl:e["checkout-cart-url"],theme:e.theme,themeExtensionPort:e["theme-app-extension-port"],notify:e.notify,graphiqlPort:e["graphiql-port"],graphiqlKey:e["graphiql-key"],tunnel:r};return await rs(s),{app:n.app}}};export{qt as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{a as F}from"../../../../chunk-D3TSJA5S.js";import{a as C}from"../../../../chunk-RF2DPBA6.js";import{Ba as A,G as w,da as P,h as O}from"../../../../chunk-SBEZBZM7.js";import"../../../../chunk-DJQVNH7P.js";import{a as E}from"../../../../chunk-WDC3KIZT.js";import"../../../../chunk-66RJ5T7A.js";import"../../../../chunk-K2WUCOQJ.js";import{b as l}from"../../../../chunk-ELYP4KFP.js";import"../../../../chunk-7MUKLZOL.js";import"../../../../chunk-VBUZWRUL.js";import"../../../../chunk-XBXMPFXM.js";import"../../../../chunk-R466TU3N.js";import"../../../../chunk-UGXYQ23Y.js";import"../../../../chunk-QSTEVZFQ.js";import"../../../../chunk-5Y7GIF2W.js";import"../../../../chunk-TQYMC7TH.js";import"../../../../chunk-HUZUORYM.js";import"../../../../chunk-52GC6XUT.js";import"../../../../chunk-XLELNRFF.js";import"../../../../chunk-B2EHO7ZC.js";import"../../../../chunk-4LNCYIS3.js";import"../../../../chunk-LAZJ47DZ.js";import"../../../../chunk-PRKBO42R.js";import"../../../../chunk-GOJ2QHSR.js";import"../../../../chunk-7BGM2GAH.js";import"../../../../chunk-XNO6DZYP.js";import{b as v}from"../../../../chunk-323UTVMM.js";import"../../../../chunk-3TNEIDOD.js";import"../../../../chunk-4HHXSMD7.js";import"../../../../chunk-YZDDTYTU.js";import"../../../../chunk-MOA33ZFO.js";import"../../../../chunk-JUVAGMIH.js";import"../../../../chunk-BDVAE5MS.js";import"../../../../chunk-P6XE4MH5.js";import"../../../../chunk-KLMDWDT2.js";import"../../../../chunk-5CH3B62S.js";import"../../../../chunk-QUTQDXSL.js";import"../../../../chunk-IASVAERO.js";import"../../../../chunk-JPGO36XP.js";import"../../../../chunk-PD5ZHJWI.js";import{r as L}from"../../../../chunk-LDGAHMS7.js";import"../../../../chunk-ZR76GGZ6.js";import"../../../../chunk-EENHXSWU.js";import"../../../../chunk-FUOIGXI4.js";import"../../../../chunk-6M3ZYNGO.js";import"../../../../chunk-QYR5VPQA.js";import"../../../../chunk-V2CNCPIE.js";import{Gb as a,Ib as s,Mb as h,Ta as g,ma as u,ua as m}from"../../../../chunk-GFEAKSGV.js";import"../../../../chunk-CERXUPGC.js";import"../../../../chunk-T4M5CWAO.js";import"../../../../chunk-PRVQAHWI.js";import"../../../../chunk-YC6G4MHD.js";import"../../../../chunk-N7RBSKYT.js";import{d as c}from"../../../../chunk-IU2ZQ6TE.js";import"../../../../chunk-PIBY5DDZ.js";import{e as I,g as p}from"../../../../chunk-VPRTJUIN.js";p();p();async function k({app:d,remoteApp:t,organization:n,envFile:e}){await P(t,n.source);let o={SHOPIFY_API_KEY:t.apiKey,SHOPIFY_API_SECRET:t.apiSecretKeys[0]?.secret,SCOPES:O(d.configuration)};if(await g(e)){let i=await u(e),r=l(i,o);if(r===i)return s`No changes to ${a.path(e)}`;{await m(e,r);let y=E(i??"",r);return s`Updated ${a.path(e)} to be:
|
|
2
|
+
|
|
3
|
+
${r}
|
|
4
|
+
|
|
5
|
+
Here's what changed:
|
|
6
|
+
|
|
7
|
+
${a.linesDiff(y)}
|
|
8
|
+
`}}else{let i=l(null,o);return await m(e,i),s`Created ${a.path(e)}:
|
|
9
|
+
|
|
10
|
+
${i}
|
|
11
|
+
`}}var x=I(L(),1);var f=class d extends F{static{this.summary="Pull app and extensions environment variables."}static{this.descriptionWithMarkdown="Creates or updates an `.env` files that contains app and app extension environment variables.\n\n When an existing `.env` file is updated, changes to the variables are displayed in the terminal output. Existing variables and commented variables are preserved."}static{this.description=this.descriptionWithoutMarkdown()}static{this.flags={...v,...C,"env-file":x.Flags.string({hidden:!1,description:"Specify an environment file to update if the update flag is set",env:"SHOPIFY_FLAG_ENV_FILE"})}}async run(){let{flags:t}=await this.parse(d),{app:n,remoteApp:e,organization:o}=await A({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config}),i=c(n.directory,t["env-file"]??w(n.configPath));return h(await k({app:n,remoteApp:e,organization:o,envFile:i})),{app:n}}};export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"../../../../chunk-LALIKZPS.js";import{a as r}from"../../../../chunk-D3TSJA5S.js";import{a as p}from"../../../../chunk-RF2DPBA6.js";import{Ba as s}from"../../../../chunk-SBEZBZM7.js";import"../../../../chunk-DJQVNH7P.js";import"../../../../chunk-66RJ5T7A.js";import"../../../../chunk-K2WUCOQJ.js";import"../../../../chunk-ELYP4KFP.js";import"../../../../chunk-7MUKLZOL.js";import"../../../../chunk-VBUZWRUL.js";import"../../../../chunk-XBXMPFXM.js";import"../../../../chunk-R466TU3N.js";import"../../../../chunk-UGXYQ23Y.js";import"../../../../chunk-QSTEVZFQ.js";import"../../../../chunk-5Y7GIF2W.js";import"../../../../chunk-TQYMC7TH.js";import"../../../../chunk-HUZUORYM.js";import"../../../../chunk-52GC6XUT.js";import"../../../../chunk-XLELNRFF.js";import"../../../../chunk-B2EHO7ZC.js";import"../../../../chunk-4LNCYIS3.js";import"../../../../chunk-LAZJ47DZ.js";import"../../../../chunk-PRKBO42R.js";import"../../../../chunk-GOJ2QHSR.js";import"../../../../chunk-7BGM2GAH.js";import"../../../../chunk-XNO6DZYP.js";import{b as n}from"../../../../chunk-323UTVMM.js";import"../../../../chunk-3TNEIDOD.js";import"../../../../chunk-4HHXSMD7.js";import"../../../../chunk-YZDDTYTU.js";import"../../../../chunk-MOA33ZFO.js";import"../../../../chunk-JUVAGMIH.js";import"../../../../chunk-BDVAE5MS.js";import"../../../../chunk-P6XE4MH5.js";import"../../../../chunk-KLMDWDT2.js";import"../../../../chunk-5CH3B62S.js";import"../../../../chunk-QUTQDXSL.js";import"../../../../chunk-IASVAERO.js";import"../../../../chunk-JPGO36XP.js";import"../../../../chunk-PD5ZHJWI.js";import"../../../../chunk-LDGAHMS7.js";import"../../../../chunk-ZR76GGZ6.js";import"../../../../chunk-EENHXSWU.js";import"../../../../chunk-FUOIGXI4.js";import"../../../../chunk-6M3ZYNGO.js";import"../../../../chunk-QYR5VPQA.js";import"../../../../chunk-V2CNCPIE.js";import{Mb as e}from"../../../../chunk-GFEAKSGV.js";import"../../../../chunk-CERXUPGC.js";import"../../../../chunk-T4M5CWAO.js";import"../../../../chunk-PRVQAHWI.js";import"../../../../chunk-YC6G4MHD.js";import"../../../../chunk-N7RBSKYT.js";import"../../../../chunk-IU2ZQ6TE.js";import"../../../../chunk-PIBY5DDZ.js";import{g as o}from"../../../../chunk-VPRTJUIN.js";o();var i=class d extends r{static{this.summary="Display app and extensions environment variables."}static{this.descriptionWithMarkdown="Displays environment variables that can be used to deploy apps and app extensions."}static{this.description=this.descriptionWithoutMarkdown()}static{this.flags={...n,...p}}async run(){let{flags:t}=await this.parse(d),{app:a,remoteApp:l,organization:c}=await s({directory:t.path,clientId:t["client-id"],forceRelink:t.reset,userProvidedConfigName:t.config});return e(await m(a,l,c)),{app:a}}};export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as E,b as z,c as C,f as F,h as J}from"../../../chunk-LXFJDCNG.js";import"../../../chunk-QRRNOVJ3.js";import{a as x}from"../../../chunk-D3TSJA5S.js";import{a as k,c as b}from"../../../chunk-RF2DPBA6.js";import"../../../chunk-SBEZBZM7.js";import"../../../chunk-DJQVNH7P.js";import"../../../chunk-66RJ5T7A.js";import"../../../chunk-K2WUCOQJ.js";import"../../../chunk-ELYP4KFP.js";import"../../../chunk-7MUKLZOL.js";import"../../../chunk-VBUZWRUL.js";import"../../../chunk-XBXMPFXM.js";import"../../../chunk-R466TU3N.js";import"../../../chunk-UGXYQ23Y.js";import"../../../chunk-QSTEVZFQ.js";import"../../../chunk-5Y7GIF2W.js";import{b as A}from"../../../chunk-TQYMC7TH.js";import"../../../chunk-HUZUORYM.js";import"../../../chunk-52GC6XUT.js";import"../../../chunk-XLELNRFF.js";import{g as G,h as v}from"../../../chunk-B2EHO7ZC.js";import"../../../chunk-4LNCYIS3.js";import"../../../chunk-LAZJ47DZ.js";import"../../../chunk-PRKBO42R.js";import"../../../chunk-GOJ2QHSR.js";import"../../../chunk-7BGM2GAH.js";import"../../../chunk-XNO6DZYP.js";import{b as S}from"../../../chunk-323UTVMM.js";import"../../../chunk-3TNEIDOD.js";import"../../../chunk-4HHXSMD7.js";import"../../../chunk-YZDDTYTU.js";import"../../../chunk-MOA33ZFO.js";import"../../../chunk-JUVAGMIH.js";import{E as m,v as c,x as O}from"../../../chunk-BDVAE5MS.js";import"../../../chunk-P6XE4MH5.js";import"../../../chunk-KLMDWDT2.js";import"../../../chunk-5CH3B62S.js";import"../../../chunk-QUTQDXSL.js";import"../../../chunk-IASVAERO.js";import{d as u}from"../../../chunk-JPGO36XP.js";import"../../../chunk-PD5ZHJWI.js";import"../../../chunk-LDGAHMS7.js";import"../../../chunk-ZR76GGZ6.js";import"../../../chunk-EENHXSWU.js";import"../../../chunk-FUOIGXI4.js";import"../../../chunk-6M3ZYNGO.js";import"../../../chunk-QYR5VPQA.js";import"../../../chunk-V2CNCPIE.js";import{Gb as l,Ib as a,Mb as y,Ta as w,ma as g,ua as h}from"../../../chunk-GFEAKSGV.js";import"../../../chunk-CERXUPGC.js";import"../../../chunk-T4M5CWAO.js";import"../../../chunk-PRVQAHWI.js";import"../../../chunk-YC6G4MHD.js";import"../../../chunk-N7RBSKYT.js";import"../../../chunk-IU2ZQ6TE.js";import"../../../chunk-PIBY5DDZ.js";import{e as V,g as p}from"../../../chunk-VPRTJUIN.js";p();p();var N=V(G(),1);async function Q(i,e){if(i)try{return JSON.parse(i)}catch(t){let r=t instanceof Error?t.message:"Unknown error";throw new u(a`Invalid JSON in ${l.yellow("--variables")} flag: ${r}`,"Please provide valid JSON format.")}else if(e){if(!await w(e))throw new u(a`Variable file not found at ${l.path(e)}. Please check the path and try again.`);let t=await g(e,{encoding:"utf8"});try{return JSON.parse(t)}catch(r){let s=r instanceof Error?r.message:"Unknown error";throw new u(a`Invalid JSON in variable file ${l.path(e)}: ${s}`,"Please provide valid JSON format.")}}}async function P(i){let{remoteApp:e,store:t,query:r,variables:s,variableFile:q,version:L,outputFile:d}=i,{adminSession:M,version:$}=await m({title:a`Authenticating`,task:async()=>{let o=await E(e,t.shopDomain),n=await C({adminSession:o,userSpecifiedVersion:L});return{adminSession:o,version:n}},renderOptions:{stdout:process.stderr}}),I=await Q(s,q);z(r),F(r,t);try{let o=await m({title:a`Executing GraphQL operation`,task:async()=>A({query:(0,N.parse)(r),session:M,variables:I,version:$,responseOptions:{handleErrors:!1}}),renderOptions:{stdout:process.stderr}}),n=JSON.stringify(o,null,2);d?(await h(d,n),c({headline:"Operation succeeded.",body:`Results written to ${d}`})):(c({headline:"Operation succeeded."}),y(n))}catch(o){if(o instanceof v){let n={errors:o.response.errors},R=JSON.stringify(n,null,2);O({headline:"GraphQL operation failed.",body:R});return}throw o}}var f=class i extends x{static{this.summary="Execute GraphQL queries and mutations."}static{this.descriptionWithMarkdown="Executes an Admin API GraphQL query or mutation on the specified store. Mutations are only allowed on dev stores.\n\n For operations that process large amounts of data, use [`bulk execute`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-execute) instead."}static{this.description=this.descriptionWithoutMarkdown()}static{this.flags={...S,...k,...b}}async run(){let{flags:e}=await this.parse(i),{query:t,appContextResult:r,store:s}=await J(e);return await P({organization:r.organization,remoteApp:r.remoteApp,store:s,query:t,variables:e.variables,variableFile:e["variable-file"],outputFile:e["output-file"],...e.version&&{version:e.version}}),{app:r.app}}};export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as m,c as u}from"../../../../chunk-IIIVWD4R.js";import{a as c}from"../../../../chunk-ZVJVDCIM.js";import{a as e}from"../../../../chunk-RF2DPBA6.js";import{Ca as p,o as a}from"../../../../chunk-SBEZBZM7.js";import"../../../../chunk-DJQVNH7P.js";import"../../../../chunk-66RJ5T7A.js";import"../../../../chunk-K2WUCOQJ.js";import"../../../../chunk-ELYP4KFP.js";import"../../../../chunk-7MUKLZOL.js";import"../../../../chunk-VBUZWRUL.js";import"../../../../chunk-XBXMPFXM.js";import"../../../../chunk-R466TU3N.js";import"../../../../chunk-UGXYQ23Y.js";import"../../../../chunk-QSTEVZFQ.js";import"../../../../chunk-5Y7GIF2W.js";import"../../../../chunk-TQYMC7TH.js";import"../../../../chunk-HUZUORYM.js";import"../../../../chunk-52GC6XUT.js";import"../../../../chunk-XLELNRFF.js";import"../../../../chunk-B2EHO7ZC.js";import"../../../../chunk-4LNCYIS3.js";import"../../../../chunk-LAZJ47DZ.js";import"../../../../chunk-PRKBO42R.js";import"../../../../chunk-GOJ2QHSR.js";import"../../../../chunk-7BGM2GAH.js";import"../../../../chunk-XNO6DZYP.js";import{b as n}from"../../../../chunk-323UTVMM.js";import"../../../../chunk-3TNEIDOD.js";import"../../../../chunk-4HHXSMD7.js";import"../../../../chunk-YZDDTYTU.js";import"../../../../chunk-MOA33ZFO.js";import"../../../../chunk-JUVAGMIH.js";import{v as r}from"../../../../chunk-BDVAE5MS.js";import"../../../../chunk-P6XE4MH5.js";import"../../../../chunk-KLMDWDT2.js";import"../../../../chunk-5CH3B62S.js";import"../../../../chunk-QUTQDXSL.js";import"../../../../chunk-IASVAERO.js";import"../../../../chunk-JPGO36XP.js";import"../../../../chunk-PD5ZHJWI.js";import"../../../../chunk-LDGAHMS7.js";import"../../../../chunk-ZR76GGZ6.js";import"../../../../chunk-EENHXSWU.js";import"../../../../chunk-FUOIGXI4.js";import"../../../../chunk-6M3ZYNGO.js";import"../../../../chunk-QYR5VPQA.js";import"../../../../chunk-V2CNCPIE.js";import"../../../../chunk-GFEAKSGV.js";import"../../../../chunk-CERXUPGC.js";import"../../../../chunk-T4M5CWAO.js";import"../../../../chunk-PRVQAHWI.js";import"../../../../chunk-YC6G4MHD.js";import"../../../../chunk-N7RBSKYT.js";import"../../../../chunk-IU2ZQ6TE.js";import"../../../../chunk-PIBY5DDZ.js";import{g as i}from"../../../../chunk-VPRTJUIN.js";i();var s=class d extends c{static{this.summary="Compile a function to wasm."}static{this.descriptionWithMarkdown="Compiles the function in your current directory to WebAssembly (Wasm) for testing purposes."}static{this.description=this.descriptionWithoutMarkdown()}static{this.flags={...n,...e,...m}}async run(){let{flags:t}=await this.parse(d),{app:o}=await p({directory:t.path,userProvidedConfigName:t.config}),l=await u(o,t.path);return await a(l,{app:o,stdout:process.stdout,stderr:process.stderr,useTasks:!0,environment:"production"}),r({headline:"Function built successfully."}),{app:o}}};export{s as default};
|