@shopify/cli
Version:
A CLI tool to build for the Shopify platform
12 lines (9 loc) • 5.02 kB
JavaScript
import{b as $}from"./chunk-MOA33ZFO.js";import{a as F}from"./chunk-JUVAGMIH.js";import{R as _}from"./chunk-6G6TMKXF.js";import{d as T}from"./chunk-WSDN25F5.js";import{d}from"./chunk-M56NDIMD.js";import{r as I}from"./chunk-LDGAHMS7.js";import{Gb as h,Ib as g,Mb as P,aa as E}from"./chunk-N5PQPIBF.js";import{c as O}from"./chunk-YTNDFQJT.js";import{a as b}from"./chunk-ULQG3XQS.js";import{e as S,g as w}from"./chunk-VPRTJUIN.js";w();var u=S(I()),p=class extends u.Command{static descriptionWithoutMarkdown(){return(this.descriptionWithMarkdown??"").replace(/(\[)(.*?)(])(\()(.*?)(\))/gm,'"$2" ($5)')}static analyticsNameOverride(){}static analyticsStopCommand(){}async catch(n){n.skipOclifErrorHandling=!0;let{errorHandler:r}=await import("./error-handler-PRZFHPRG.js");return await r(n,this.config),u.Errors.handle(n)}async init(){if(this.exitWithTimestampWhenEnvVariablePresent(),$(this.id??""),!O()){let{registerCleanBugsnagErrorsFromWithinPlugins:r}=await import("./error-handler-PRZFHPRG.js");await r(this.config)}await x(this.config),this.showNpmFlagWarning();let{showNotificationsIfNeeded:n}=await import("./notifications-system-YX2GPLDW.js");return await n(),super.init()}showNpmFlagWarning(){let n=this.constructor;Object.keys(n.flags||{}).map(t=>`npm_config_${E(t).replace(/^no_/,"")}`).some(t=>process.env[t]!==void 0)&&import("./ui-WRS2IDPP.js").then(({renderWarning:t})=>{t({body:["NPM scripts require an extra",{command:"--"},"separator to pass the flags. Example:",{command:"npm run dev -- --reset"}]})})}exitWithTimestampWhenEnvVariablePresent(){b(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)&&(P(`
SHOPIFY_CLI_TIMESTAMP_START
{ "timestamp": ${Date.now()} }
SHOPIFY_CLI_TIMESTAMP_END
`),process.exit(0))}async parse(n,r){let e=await super.parse(n,r);return e=await this.resultWithEnvironment(e,n,r),await j(e.flags),{...e,argv:e.argv}}environmentsFilename(){}failMissingNonTTYFlags(n,r){_()||r.forEach(e=>{if(!(e in n))throw new d(g`Flag not specified:
${h.cyan(e)}
This flag is required in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,"To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.")})}async resultWithEnvironment(n,r,e){let t=n.flags,i=this.environmentsFilename();if(!i)return n;let{environmentFilePath:o}=await import("./environments-5X7S2O5U.js"),s=await o(i,{from:t.path}),m=[];t.environment&&(m=Array.isArray(t.environment)?t.environment:[t.environment]);let c=m.length>0;if(!s&&!c||c&&m.length>1)return n;let{environment:l,isDefaultEnvironment:f}=await this.loadEnvironmentForCommand(t.path,i,m[0]);if(!l||f&&!C(r?.flags,"environment"))return n;let v=await super.parse(N(r),e),y=await super.parse(r,[...e??this.argv,...W(l,r,v),...f?["--environment","default"]:[]]);return A(v.flags,y.flags,f?"default":m[0],l),y}async loadEnvironmentForCommand(n,r,e){let{loadEnvironment:t}=await import("./environments-5X7S2O5U.js");return e?{environment:await t(e,r,{from:n}),isDefaultEnvironment:!1}:{environment:await t("default",r,{from:n,silent:!0}),isDefaultEnvironment:!0}}};p.baseFlags={};async function j(a){await T(()=>({cmd_all_verbose:a.verbose,cmd_all_path_override:a.path!==void 0,cmd_all_path_override_hash:a.path===void 0?void 0:F(a.path)}))}function A(a,n,r,e){let t={};for(let[o,s]of Object.entries(n)){let m=Object.prototype.hasOwnProperty.call(a,o),c=Object.prototype.hasOwnProperty.call(e,o);if(!m&&c){let l=o==="password"?`********${s.substr(-4)}`:s;t[o]=l}}if(Object.keys(t).length===0)return;let i=Object.entries(t).map(([o,s])=>`${o}: ${s}`);import("./ui-WRS2IDPP.js").then(({renderInfo:o})=>{o({headline:["Using applicable flags from",{userInput:r},"environment:"],body:[{list:{items:i}}]})})}function N(a){return a?.flags?{...a,flags:Object.fromEntries(Object.entries(a.flags).map(([n,r])=>{let e={...r};return delete e.default,[n,e]}))}:a}function W(a,n,r){let e=[];for(let[t,i]of Object.entries(a)){let o=C(n?.flags,t),s=r.flags&&Object.prototype.hasOwnProperty.call(r.flags,t);if(o&&!s)if(typeof i=="boolean")if(i)e.push(`--${t}`);else throw new d(g`Environments can only specify true for boolean flags. Attempted to set ${h.yellow(t)} to false.`);else Array.isArray(i)?i.forEach(m=>e.push(`--${t}`,`${m}`)):e.push(`--${t}`,`${i}`)}return e}function C(a,n){return!!a&&Object.prototype.hasOwnProperty.call(a,n)}async function x(a){let n=Array.from(a.plugins.values()),r=["@shopify/app","@shopify/plugin-cloudflare"],e=n.filter(i=>r.includes(i.name));if(e.length>0){let i=e.map(s=>` - shopify plugins remove ${s.name}`).join(`
`),{renderWarning:o}=await import("./ui-WRS2IDPP.js");o({headline:`Unsupported plugins detected: ${e.map(s=>s.name).join(", ")}`,body:["They are already included in the CLI and installing them as custom plugins can cause conflicts.",`You can fix it by running:
${i}`]})}let t=n.filter(i=>!r.includes(i.name));a.plugins=new Map(t.map(i=>[i.name,i]))}var q=p;export{N as a,q as b};