UNPKG

@shopify/cli

Version:

A CLI tool to build for the Shopify platform

6 lines (3 loc) 3.84 kB
import{b as j}from"./chunk-FYFNUDOC.js";import{a as H}from"./chunk-JQJBBXMX.js";import{i as U,j as W,l as q}from"./chunk-OY3PNHPZ.js";import{a as J}from"./chunk-Y7JGYGV7.js";import{a as g,c as D}from"./chunk-GVQIPEZT.js";import{a as F}from"./chunk-CEIQFLCN.js";import{a as N}from"./chunk-DN2IE3VY.js";import{m as A}from"./chunk-XITQULK4.js";import{a as f,b}from"./chunk-QFWIDATO.js";import{b as C,c as M,d as L,f as $,j as k,n as x,p as _}from"./chunk-CBXSPL4W.js";import{aa as z}from"./chunk-UXVZ2P63.js";import{O as y,ua as h,va as E}from"./chunk-XONFGLJQ.js";import{A as P,v as d,w as p,x as O}from"./chunk-6G6TMKXF.js";import{d as R}from"./chunk-M56NDIMD.js";import{Mb as S}from"./chunk-N5PQPIBF.js";import{f as T,q as c}from"./chunk-IU2ZQ6TE.js";import{e as Y,g as v}from"./chunk-VPRTJUIN.js";v();var I=Y(z(),1);async function Ee(e,t,r,n){let o=e.environment?.[0],s=t??await y(A({store:e.store}),e.password);if(e.strict){let m=e.json?"json":"text",{offenses:u}=await j(e.path??c(),m);if(u.length>0&&u.filter(V=>V.severity===I.Severity.ERROR).length>0)throw E(new R(o?`[${o}] Theme check failed. Please fix the errors before pushing.`:"Theme check failed. Please fix the errors before pushing."))}h("theme-service:push:setup"),J({verbose:e.verbose,noColor:e.noColor});let i=e.force??!1,a=e.path?T(e.path):c();if(!await q(a)&&!await D(i,void 0,o,r))return;e.listing&&await U(a,e.listing);let l=await Z(s,e,r);l&&(h("theme-service:push:setup"),await B(l,s,{allowLive:e.allowLive??!1,environment:o,force:i,ignore:e.ignore??[],json:e.json??!1,multiEnvironment:r,nodelete:e.nodelete??!1,only:e.only??[],path:a,publish:e.publish??!1,listing:e.listing},n))}async function B(e,t,r,n){h("theme-service:push:file-system");let o=await x(e.id,t),s=W(r.path,{filters:r,listing:r.listing});h("theme-service:push:file-system");let{uploadResults:i,renderThemeSyncProgress:a}=H(e,t,o,s,r,n);await a(),r.publish&&await _(e.id,t),await G(i,e,t,r)}function w(e){for(let[t,r]of e.entries())if(!r.success)return!0;return!1}async function G(e,t,r,n){n.json?K(t,r,e,n.environment):n.publish?Q(r,e,n.environment):X(t,r,e,n.environment)}function K(e,t,r,n){let o={environment:n,theme:{id:e.id,name:e.name,role:e.role,shop:t.storeFqdn,editor_url:b(e,t),preview_url:f(e,t)}};if(w(r)){let i=`${n?`[${n}] `:""}The theme '${e.name}' was pushed with errors`;o.theme.warning=i;let a={};for(let[l,m]of r.entries())!m.success&&m.errors?.asset&&(a[l]=m.errors.asset);Object.keys(a).length>0&&(o.theme.errors=a)}S(JSON.stringify(o))}function Q(e,t,r){let n=r?[{subdued:`Environment: ${r} `}]:[];w(t)?p({body:[...n,`Your theme was published with errors and is now live at https://${e.storeFqdn}`]}):d({body:[...n,`Your theme is now live at https://${e.storeFqdn}`]})}function X(e,t,r,n){let o=n?[{subdued:`Environment: ${n} `}]:[],s=w(r),i=[[{link:{label:"View your theme",url:f(e,t)}}],[{link:{label:"Customize your theme at the theme editor",url:b(e,t)}}]];s?p({body:[...o,"The theme",...g(e),"was pushed with errors"],nextSteps:i}):d({body:[...o,"The theme",...g(e),"was pushed successfully."],nextSteps:i})}async function Z(e,t,r){let{live:n,development:o,unpublished:s,theme:i,environment:a,developmentContext:l}=t;if(o)return new F(e).findOrCreate(l,C);if(s){let m=i??await $("Name of the new theme");return k({name:m,role:L},e)}else{let m=await N(e,{create:!0,header:"Select a theme to push to:",filter:{live:n,theme:i}});return await ee(m.role,t.allowLive,e.storeFqdn,a,r)?m:void 0}}async function ee(e,t,r,n,o){if(e===M){if(t)return!0;if(o)return O({headline:`Environment: ${n}`,body:[`Can't push theme files to the live theme on ${r}`,"Use the --allow-live flag to push to a live theme."]}),!1;let s={message:`Push theme files to the ${e} theme on ${r}?`,confirmationMessage:"Yes, confirm changes",cancellationMessage:"Cancel"};return P(s)}return!0}export{Ee as a};