UNPKG

@shopify/cli

Version:

A CLI tool to build for the Shopify platform

2 lines (1 loc) 1.44 kB
import{h as m}from"./chunk-CBXSPL4W.js";import{d as h}from"./chunk-M56NDIMD.js";import{g as i}from"./chunk-VPRTJUIN.js";i();var s=["live","unpublished","development"];async function A(r){let e=r.storeFqdn,t=(await m(r)).filter(c);if(t.length===0)throw new h(`There are no themes in the ${e} store`);return t.sort(p)}function c(r){return s.includes(r.role)}function p(r,e){return s.indexOf(r.role)-s.indexOf(e.role)}i();function R(r,e,t){return T(r,e,t)??d(r,e,t)}function T(r,e,t){let o=t.role;if(!o)return;let n=`No themes on the store ${r} match the role "${o}"`;return a(e,l=>l.role===o).orThrow(n)}function d(r,e,t){return t.themeIdentifiers.flatMap(n=>{let l=`No themes on the store ${r} match the ID or name "${n}"`;return a(e,u=>`${u.id}`===n||u.name.toLowerCase()===n.toLowerCase()?!0:g(u.name.toLowerCase(),n.toLowerCase())).orThrow(l)})}function a(r,e){let t=r.filter(e);return t.length>0?{orThrow:o=>t}:{orThrow:o=>{throw new h(o)}}}var f=class{constructor(e){this.queryProps=e}get role(){for(let e of s)if(this.queryProps[e])return e}get themeIdentifiers(){return[this.queryProps.theme,this.queryProps.themes].flat().filter(t=>!!t)}any(){return Object.values(this.queryProps).some(e=>e?.length!==void 0?e.length>0:!!e)}};function g(r,e){let t=e.replace(/(^\*)|(\*$)/g,"");return e.startsWith("*")&&e.endsWith("*")?r.includes(t):e.startsWith("*")?r.endsWith(t):e.endsWith("*")?r.startsWith(t):!1}export{s as a,A as b,R as c,f as d};