UNPKG

@shopify/cli

Version:

A CLI tool to build for the Shopify platform

4 lines (2 loc) 5.87 kB
import{b as $}from"../../../chunk-NF2ABOOU.js";import{a as H,j as R,l as Y}from"../../../chunk-OY3PNHPZ.js";import"../../../chunk-K6CTUBFC.js";import{a as V}from"../../../chunk-Y7JGYGV7.js";import{a as G,c as p}from"../../../chunk-GVQIPEZT.js";import{a as x}from"../../../chunk-CEIQFLCN.js";import{a as M}from"../../../chunk-DN2IE3VY.js";import"../../../chunk-JAO53IH2.js";import{k as O,l as I,m as _,p as W,q as L}from"../../../chunk-XITQULK4.js";import"../../../chunk-3VZEETAV.js";import"../../../chunk-IX5ICOBV.js";import"../../../chunk-SXTMSGUE.js";import{a as A,b as D}from"../../../chunk-QFWIDATO.js";import{k,n as P}from"../../../chunk-CBXSPL4W.js";import"../../../chunk-UJVH7FZS.js";import{h as C,k as E}from"../../../chunk-TYZXGSHO.js";import"../../../chunk-VBUZWRUL.js";import"../../../chunk-UXVZ2P63.js";import"../../../chunk-QSTEVZFQ.js";import"../../../chunk-5Y7GIF2W.js";import"../../../chunk-EKXY5COY.js";import"../../../chunk-4DCQNGUV.js";import{O as T,ua as m}from"../../../chunk-XONFGLJQ.js";import"../../../chunk-4LNCYIS3.js";import"../../../chunk-L2MGAEV3.js";import"../../../chunk-PRKBO42R.js";import"../../../chunk-ZSBA6VIC.js";import"../../../chunk-F2QU6WWX.js";import"../../../chunk-XULPJ6UG.js";import{b as S}from"../../../chunk-XR6GMMEU.js";import"../../../chunk-3TNEIDOD.js";import"../../../chunk-MHWV5RQV.js";import"../../../chunk-XOTA6JTZ.js";import"../../../chunk-MOA33ZFO.js";import"../../../chunk-JUVAGMIH.js";import{D as F,v}from"../../../chunk-6G6TMKXF.js";import"../../../chunk-P6XE4MH5.js";import"../../../chunk-KLMDWDT2.js";import"../../../chunk-5CH3B62S.js";import"../../../chunk-QUTQDXSL.js";import"../../../chunk-WSDN25F5.js";import"../../../chunk-M56NDIMD.js";import"../../../chunk-PD5ZHJWI.js";import{r as z}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-OBEWZXOQ.js";import{Wa as w}from"../../../chunk-N5PQPIBF.js";import"../../../chunk-CERXUPGC.js";import"../../../chunk-T4M5CWAO.js";import"../../../chunk-PRVQAHWI.js";import"../../../chunk-YTNDFQJT.js";import"../../../chunk-ULQG3XQS.js";import{q as f}from"../../../chunk-IU2ZQ6TE.js";import"../../../chunk-PIBY5DDZ.js";import{e as j,g as c}from"../../../chunk-VPRTJUIN.js";c();c();c();async function q(e,t,o,n,r,l){let i=J(o,n,r),a=Q(o,e,n,t),s=[...i,...a,{title:"Theme download complete",task:async()=>{}}];s.length>0&&await F(s,{renderOptions:{stdout:l?.stdout??process.stdout},noProgressBar:r.multiEnvironment})}function J(e,t,o){if(o.nodelete)return[];let n=new Set(e.map(i=>i.key));return t.applyIgnoreFilters([...t.files.values()]).map(({key:i})=>i).filter(i=>!n.has(i)).map(i=>({title:`Cleaning your local directory (removing ${i})`,task:async()=>t.delete(i)}))}function Q(e,t,o,n){let r=o.applyIgnoreFilters(e);r=r.filter(s=>{let u=s.checksum;return o.files.get(s.key)?.checksum!==u});let l=r.map(s=>s.key),i=s=>s.total===0?"[100%]":`[${Math.round(s.current/s.total*100)}%]`;return $(l,W,(s,u)=>({title:`Downloading files from remote theme ${i({current:u,total:l.length})}`,task:async()=>X(t,o,s,n)}))}async function X(e,t,o,n){let r=await k(e.id,o,n);r&&await Promise.all(r.map(l=>t.write(l)))}async function B(e,t,o,n){m("theme-service:pull:setup"),V({verbose:e.verbose,noColor:e.noColor});let r=t??await T(_({store:e.store}),e.password),l=new x(r),i=await(e.development?l.find():l.fetch()),{path:a,nodelete:s,live:u,development:h,only:K,ignore:N,force:g,environment:b}=e;if(!await te(a??f(),g??!1,b?.[0],o))return;let U=await M(r,{header:"Select a theme to open",filter:{live:u,theme:h?`${i?.id}`:e.theme}});m("theme-service:pull:setup"),await Z(U,r,{environment:b?.[0],force:g??!1,ignore:N??[],multiEnvironment:o,nodelete:s??!1,only:K??[],path:a??f()},n)}async function Z(e,t,o,n){m("theme-service:pull:file-system");let r=R(o.path,{filters:o}),[l]=await Promise.all([P(e.id,t),r.ready()]),i=H(l);m("theme-service:pull:file-system"),await q(e,t,i,r,o,n);let a=o.environment?`Environment: ${o.environment}`:"";v({headline:a,body:["The theme",...G(e),"has been pulled."],nextSteps:[[{link:{label:"View your theme",url:A(e,t)}}],[{link:{label:"Customize your theme at the theme editor",url:D(e,t)}}]]})}async function ee(e){return(await w("*",{cwd:e,deep:1,onlyFiles:!1})).length===0}async function te(e,t,o,n){return t?!0:!(!await ee(e)&&!await Y(e)&&!await p(t,void 0,o,n)||await C(e)&&!await E(e)&&!await p(t,"The current Git directory has uncommitted changes.",o,n))}var d=j(z(),1);var y=class extends L{static{this.summary="Download your remote theme files locally."}static{this.descriptionWithMarkdown=`Retrieves theme files from Shopify. If no theme is specified, then you're prompted to select the theme to pull from the list of the themes in your store.`}static{this.description=this.descriptionWithoutMarkdown()}static{this.flags={...S,...O,...I("download"),theme:d.Flags.string({char:"t",description:"Theme ID or name of the remote theme.",env:"SHOPIFY_FLAG_THEME_ID"}),development:d.Flags.boolean({char:"d",description:"Pull theme files from your remote development theme.",env:"SHOPIFY_FLAG_DEVELOPMENT"}),live:d.Flags.boolean({char:"l",description:"Pull theme files from your remote live theme.",env:"SHOPIFY_FLAG_LIVE"}),nodelete:d.Flags.boolean({char:"n",description:"Prevent deleting local files that don't exist remotely.",env:"SHOPIFY_FLAG_NODELETE"}),force:d.Flags.boolean({hidden:!0,char:"f",description:"Proceed without confirmation, if current directory does not seem to be theme directory.",env:"SHOPIFY_FLAG_FORCE"})}}static{this.multiEnvironmentsFlags=["store","password","path",["live","development","theme"]]}async command(t,o,n,r,l){m("theme-command:pull"),await B({...t,noColor:t["no-color"]},o,n,l),m("theme-command:pull")}};export{y as default};