@shopify/cli
Version:
A CLI tool to build for the Shopify platform
2 lines (1 loc) • 2.87 kB
JavaScript
import{K as h,L as y,N as _,l as S}from"./chunk-54CAKCYR.js";import{Y as E}from"./chunk-7ESSIN27.js";import{z as T}from"./chunk-XONFGLJQ.js";import{a as D}from"./chunk-JUVAGMIH.js";import{D as O,P as l,u as b}from"./chunk-6G6TMKXF.js";import{b as m,d as p,g as P}from"./chunk-M56NDIMD.js";import{Ob as z}from"./chunk-N5PQPIBF.js";import{j as C}from"./chunk-YTNDFQJT.js";import{g as d}from"./chunk-VPRTJUIN.js";d();d();async function u(e,t,r){let s=r.clientName==="app-management",n;r.supportsStoreSearch&&(n=async a=>r.devStoresForOrg(t.id,a));let o=await h({onSearchForStoresByName:n,...e,showDomainOnPrompt:s});if(!o){if(b({body:await r.getCreateDevStoreLink(t)}),await l(5),!await _(t))throw new m;let f=await I(t.id,r);o=await u({stores:f,hasMorePages:!1},t,r)}let i=await c(o,t.id,r,"prompt-first");for(;!i;){if(o=await h({stores:[o],hasMorePages:!1,showDomainOnPrompt:s}),!o)throw new m;i=await c(o,t.id,r,"prompt-first")}return o}async function I(e,t){let n=[];return await O([{title:"Fetching organization data",task:async()=>{for(let i=0;i<10;i++){let{stores:a}=await t.devStoresForOrg(e);if(a.length>0){n=a;return}await l(3)}}}]),n}async function c(e,t,r,s){if(e.transferDisabled||C())return!0;if(!e.transferDisabled&&!e.convertableToPartnerTest)throw new p(`The store you specified (${e.shopDomain}) is not a dev store`,"Run dev --reset and select an eligible dev store.");switch(s){case"prompt-first":return await y()?(await A(e,t,r),!0):!1;case"never":throw new p("The store you specified is not transfer-disabled","Try running 'dev --reset' and selecting a different store, or choosing to convert this one.")}}async function A(e,t,r){let s={input:{organizationID:parseInt(t,10),shopId:e.shopId}},n=await r.convertToTransferDisabledStore(s);if(!n.convertDevToTestStore.convertedToTestStore){let o=n.convertDevToTestStore.userErrors.map(i=>i.message).join(", ");throw new P(`Error converting store ${e.shopDomain} to a transfer-disabled store: ${o}`,"This store might not be compatible with draft apps, please try a different store")}z(`Converted ${e.shopDomain} to a transfer-disabled store`)}async function Z({appContextResult:e,storeFqdn:t,forceReselectStore:r,storeTypes:s=["APP_DEVELOPMENT"]}){let{app:n,organization:o,developerPlatformClient:i}=e,a,f=n.configuration.build?.dev_store_url,g=n.hiddenConfig.dev_store_url,v=f??g,w=t??(r?void 0:v),F=s.length===1&&s[0]==="APP_DEVELOPMENT";if(w)a=await E(o,w,i,s),F&&await c(a,o.id,i,"never");else{let x=await i.devStoresForOrg(o.id);a=await u(x,o,i)}return await M(a,r),a.shopDomain=T(a.shopDomain),(a.shopDomain!==v||!g)&&await n.updateHiddenConfig({dev_store_url:a.shopDomain}),await i.ensureUserAccessToStore(o.id,a),a}async function M(e,t){await S.addPublicMetadata(()=>({cmd_app_reset_used:t,store_fqdn_hash:D(e.shopDomain)})),await S.addSensitiveMetadata(()=>({store_fqdn:e.shopDomain}))}export{Z as a};