UNPKG

@shopify/cli

Version:

A CLI tool to build for the Shopify platform

12 lines (10 loc) • 8.08 kB
import{b as j}from"../../../chunk-PYVAWAUO.js";import{a as w}from"../../../chunk-JCL2RRU6.js";import{a as P}from"../../../chunk-AGNMOFJS.js";import{Ba as T,h as k}from"../../../chunk-54CAKCYR.js";import{b as f}from"../../../chunk-7ESSIN27.js";import"../../../chunk-GZS44BUW.js";import"../../../chunk-K2WUCOQJ.js";import"../../../chunk-7QIOUDCX.js";import"../../../chunk-7MUKLZOL.js";import"../../../chunk-VBUZWRUL.js";import"../../../chunk-DCPBRWVC.js";import"../../../chunk-KR6QDE7D.js";import"../../../chunk-UXVZ2P63.js";import"../../../chunk-QSTEVZFQ.js";import"../../../chunk-5Y7GIF2W.js";import"../../../chunk-EKXY5COY.js";import"../../../chunk-4DCQNGUV.js";import"../../../chunk-QBSKKQBN.js";import"../../../chunk-FQWB2F75.js";import{H as g,I as y}from"../../../chunk-XONFGLJQ.js";import"../../../chunk-4LNCYIS3.js";import"../../../chunk-L2MGAEV3.js";import"../../../chunk-PRKBO42R.js";import"../../../chunk-ZSBA6VIC.js";import{a as d}from"../../../chunk-F2QU6WWX.js";import"../../../chunk-XULPJ6UG.js";import{b as E,c as O}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{g as S,u as A}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 F}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{Hb as b,Ib as v,Mb as C,Xb as I}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{g as a,j as h}from"../../../chunk-IU2ZQ6TE.js";import"../../../chunk-PIBY5DDZ.js";import{e as D,g as c}from"../../../chunk-VPRTJUIN.js";c();c();async function x(r,e,t,o,n){return n.webEnv?$(r,e,t,n):M(r,e,o,n)}async function $(r,e,t,{format:o}){return j(r,e,t,o)}async function M(r,e,t,o){if(o.format==="json"){let n=_(r.allExtensions.filter(s=>s.isReturnedAsInfo())),i={...r,packageManager:t.packageManager,nodeDependencies:t.nodeDependencies,usesWorkspaces:t.usesWorkspaces,allExtensions:n};return"realExtensions"in i&&(i.realExtensions=_(i.realExtensions)),"specifications"in i&&(i={...i,specifications:i.specifications?.map(s=>L(s))}),v`${JSON.stringify(Object.fromEntries(Object.entries(i).filter(([s])=>s!=="configSchema")),null,2)}`}else return new l(r,e,t,o).output()}function L(r){if("schema"in r){let{schema:e,...t}=r;return t}return r}function _(r){return r.map(e=>{if("specification"in e&&e.specification){let t=e.specification,o=L(t);return{...e,specification:o}}else return e})}var U="unknown",u={subdued:"Not yet configured"},W="NOT LOADED",l=class{constructor(e,t,o,n){this.app=e,this.remoteApp=t,this.project=o,this.options=n}async output(){return[...await this.devConfigsSection(),this.projectSettingsSection(),...await this.appComponentsSection(),await this.systemInfoSection()]}async devConfigsSection(){let e=u;this.app.configuration.build?.automatically_update_urls_on_dev!==void 0&&(e=this.app.configuration.build.automatically_update_urls_on_dev?"Yes":"No");let t=["User","unknown"],o=await this.options.developerPlatformClient.accountInfo();return y(o)?t=["Service account",o.orgName]:g(o)&&(t[1]=o.email),[this.tableSection("Current app configuration",[["Configuration file",{filePath:h(this.app.configPath)||f.app}],["App name",this.remoteApp.title?{userInput:this.remoteApp.title}:u],["Client ID",this.remoteApp.apiKey||u],["Access scopes",k(this.app.configuration)],["Dev store",this.app.configuration.build?.dev_store_url??this.app.hiddenConfig.dev_store_url??u],["Update URLs",e],t],{isFirstItem:!0}),{body:["\u{1F4A1} To change these, run",{command:b(this.project.packageManager,"shopify app config link")}]}]}projectSettingsSection(){return this.tableSection("Your Project",[["Root location",{filePath:this.app.directory}]])}async appComponentsSection(){let e=this.webComponentsSection();return[{title:` Directory components`.toUpperCase(),body:""},...e?[e]:[],...this.extensionsSections()]}webComponentsSection(){let e=[],t=[];if(this.app.webs[0])return this.app.webs.forEach(o=>{if(o.configuration)if(o.configuration.name){let{name:n,roles:i}=o.configuration,s=a(this.app.directory,o.directory);t.push([` \u{1F4C2} ${n}`,{filePath:s||"/"}]),i.length>0&&t.push([" roles",i.join(", ")])}else o.configuration.roles.forEach(n=>{t.push([` \u{1F4C2} ${n}`,{filePath:a(this.app.directory,o.directory)}])});else t.push([{subdued:` \u{1F4C2} ${U}`},{filePath:a(this.app.directory,o.directory)}]);if(!this.app.errors.isEmpty()){let n=this.app.errors.getErrors(`${o.directory}/${f.web}`);e.push(...n.map(i=>i.message))}}),this.subtableSection("web",[["\u{1F4C2} web",""],...t,...e.map(o=>[{error:"error"},{error:this.formattedError(o)}])])}extensionsSections(){let e=this.app.allExtensions.filter(o=>o.isReturnedAsInfo());return Array.from(new Set(e.map(o=>o.type))).map(o=>{let n=e.filter(i=>i.type===o);if(n[0])return this.subtableSection(n[0].externalType,n.map(i=>this.extensionSubSection(i)).flat())}).filter(o=>o!==void 0)}extensionSubSection(e){let t=e.configuration,o=[[`\u{1F4C2} ${e.handle||W}`,{filePath:a(this.app.directory,e.directory)}],[" config file",{filePath:a(e.directory,e.configurationPath)}]];t&&"metafields"in t&&Array.isArray(t.metafields)&&t.metafields.length>0&&o.push([" metafields",`${t.metafields.length}`]);let n=this.app.errors.getErrors(e.configurationPath);for(let i of n)o.push([{error:" error"},{error:this.formattedError(i.message)}]);return o}formattedError(e){let t=e.trim();if(I())return t;let[o,...n]=t.split(` `);return[`! ${o}`,...n.map(i=>` ${i}`)].join(` `)}async systemInfoSection(){let{platform:e,arch:t}=S();return this.tableSection("Tooling and System",[["Shopify CLI",d],["Package manager",this.project.packageManager],["OS",`${e}-${t}`],["Shell",process.env.SHELL??"unknown"],["Node version",process.version]])}tableSection(e,t,{isFirstItem:o=!1}={}){return{title:`${o?"":` `}${e.toUpperCase()} `,body:{tabularData:t,firstColumnSubdued:!0}}}subtableSection(e,t){return{title:e,body:{tabularData:t,firstColumnSubdued:!0}}}};var N=D(F(),1);var m=class r extends w{static{this.summary="Print basic information about your app and extensions."}static{this.descriptionWithMarkdown=`The information returned includes the following: - The app and dev store that's used when you run the [dev](https://shopify.dev/docs/api/shopify-cli/app/app-dev) command. You can reset these configurations using [\`dev --reset\`](https://shopify.dev/docs/api/shopify-cli/app/app-dev#flags-propertydetail-reset). - The [structure](https://shopify.dev/docs/apps/tools/cli/structure) of your app project. - The [access scopes](https://shopify.dev/docs/api/usage) your app has requested. - System information, including the package manager and version of Shopify CLI used in the project.`}static{this.description=this.descriptionWithoutMarkdown()}static{this.flags={...E,...P,...O,"web-env":N.Flags.boolean({hidden:!1,description:"Outputs environment variables necessary for running and deploying web/.",env:"SHOPIFY_FLAG_OUTPUT_WEB_ENV",default:!1})}}async run(){let{flags:e}=await this.parse(r),{app:t,project:o,remoteApp:n,organization:i,developerPlatformClient:s}=await T({directory:e.path,clientId:e["client-id"],forceRelink:e.reset,userProvidedConfigName:e.config,unsafeTolerateErrors:!0}),p=await x(t,n,i,o,{format:e.json?"json":"text",webEnv:e["web-env"],configName:e.config,developerPlatformClient:s});return typeof p=="string"||"value"in p?C(p):A({customSections:p}),t.errors.isEmpty()||process.exit(2),{app:t}}};export{m as default};