UNPKG

@shopify/cli

Version:

A CLI tool to build for the Shopify platform

2 lines (1 loc) 2.41 kB
import{Ba as C,n as w}from"./chunk-54CAKCYR.js";import{B as I}from"./chunk-6G6TMKXF.js";import{d as s}from"./chunk-M56NDIMD.js";import{r as D}from"./chunk-LDGAHMS7.js";import{Ib as f,Mb as T,Nb as P,Ta as d,ua as F}from"./chunk-N5PQPIBF.js";import{a as v}from"./chunk-YTNDFQJT.js";import{d as p,f as y,q as S}from"./chunk-IU2ZQ6TE.js";import{e as G,g as m}from"./chunk-VPRTJUIN.js";m();async function x(i){let{extension:t,stdout:n,developerPlatformClient:r,app:o,orgId:e}=i,c=o.configuration.client_id,{api_version:a,type:l,targeting:u}=t.configuration,b=await(!!u?.length?E({localIdentifier:t.localIdentifier,developerPlatformClient:r,apiKey:c,target:u[0].target,version:a,orgId:e}):O({localIdentifier:t.localIdentifier,developerPlatformClient:r,apiKey:c,type:l,version:a,orgId:e})),h=w(b,a);if(n)T(h);else{let g=p(t.directory,"schema.graphql");await F(g,h),P(`GraphQL Schema for ${t.localIdentifier} written to ${g}`)}}async function E({localIdentifier:i,developerPlatformClient:t,apiKey:n,target:r,version:o,orgId:e}){let c={handle:r,version:o},a=await t.targetSchemaDefinition(c,n,e);if(!a)throw new s(f`A schema could not be generated for ${i}`,f`Check that the Function targets and version are valid.`);return a}async function O({localIdentifier:i,developerPlatformClient:t,apiKey:n,version:r,type:o,orgId:e}){let c={version:r,type:o},a=await t.apiSchemaDefinition(c,n,e);if(!a)throw new s(f`A schema could not be generated for ${i}`,f`Check that the Function API type and version are valid.`);return a}m();var A=G(D(),1);var J={path:A.Flags.string({hidden:!1,description:"The path to your function directory.",parse:async i=>y(i),default:async()=>S(),noCacheDefault:!0,env:"SHOPIFY_FLAG_PATH"})};async function M(i,t){let n=i.allExtensions.filter(o=>o.isFunctionExtension),r=n.find(o=>o.directory===t);if(r)return r;if(n.length===1&&n[0])return n[0];if(v())return await I({message:"Which function?",choices:n.map(e=>({label:e.handle,value:e}))});throw new s("Run this command from a function directory or use `--path` to specify a function directory.")}async function N(i,t,n,r,o){let e=p(i.directory,"schema.graphql");if(await d(e))return e;let{app:c,developerPlatformClient:a,organization:l}=await C({directory:t,clientId:n,forceRelink:r,userProvidedConfigName:o});return await x({app:c,developerPlatformClient:a,extension:i,stdout:!1,orgId:l.id}),await d(e)?e:void 0}export{x as a,J as b,M as c,N as d};