UNPKG

@shopify/cli

Version:

A CLI tool to build for the Shopify platform

5 lines (3 loc) 3.59 kB
import{c as w}from"./chunk-QBSKKQBN.js";import{c as F,e as x}from"./chunk-FQWB2F75.js";import{B as h,m as S,t as L,u as P,v as f,z as N}from"./chunk-L2MGAEV3.js";import{o as $,q as m}from"./chunk-ZSBA6VIC.js";import{a as c}from"./chunk-F2QU6WWX.js";import{O as V,S as y,v as R}from"./chunk-6G6TMKXF.js";import{Cb as U,Db as D,Gb as u,Ib as p,Nb as d,Qb as l,Rb as E,zb as A}from"./chunk-N5PQPIBF.js";import{c as _}from"./chunk-YTNDFQJT.js";import{p as C,q as b,r as I}from"./chunk-IU2ZQ6TE.js";import{g as v}from"./chunk-VPRTJUIN.js";v();function M(){let e=U();if(!(!e||e==="unknown"))return e==="homebrew"?"brew upgrade shopify-cli":e==="yarn"?`${e} global add @shopify/cli@latest`:`${e} ${e==="pnpm"?"add":"install"} -g @shopify/cli@latest`}async function re(e={}){let n=I()??b(),o=D(n),t=A();if(_()){d("Skipping upgrade in development mode.");return}if(!(e.autoupgrade&&!t))if(t){let a=M();if(!a)throw new Error("Could not determine the package manager");let[r,...i]=a.split(" ");if(!r)throw new Error("Could not determine the command to run");let s=f("@shopify/cli",c),T=s?`\u2728 New version of Shopify CLI available! (${c} \u2192 ${s})`:"\u2728 New version of Shopify CLI available!";d(p`${T} Now upgrading by running: ${u.genericShellCommand(a)}...`),await V(r,i,{stdio:"inherit"}),R({headline:"Shopify CLI upgraded.",body:s?`You're now on version ${s}.`:"You're now on the latest version."})}else if(o)await Y(o,c);else throw new Error("Could not determine the local project directory")}function ie(){let e=c,n=f("@shopify/cli",e);if(!n){l("Auto-upgrade: No newer version available.");return}if(process.env.SHOPIFY_CLI_FORCE_AUTO_UPGRADE==="1")return l("Auto-upgrade: Forcing auto-upgrade because of SHOPIFY_CLI_FORCE_AUTO_UPGRADE."),n;if(!m()){l("Auto-upgrade: Skipping because auto-upgrade is not enabled.");return}if(y()){l("Auto-upgrade: Skipping auto-upgrade in CI.");return}if(w(e)){l("Auto-upgrade: Skipping auto-upgrade for pre-release version.");return}return n}async function se(){try{let{notifications:e}=await F();return x(e,"",["autoupgrade"]).some(o=>o.type==="error")}catch{return!1}}async function ce(){if(y()||w(c)||m())return;let e=f("@shopify/cli",c);e&&await $("warn-on-available-upgrade",{days:1},async()=>{E(G(e))})}function G(e,n=!1){let o=M(),t=o?p`💡 Version ${e} available! Run ${u.genericShellCommand(o)}`.value:p`💡 Version ${e} available!`.value;if(n){let a=`https://github.com/Shopify/cli/releases/tag/${e}`,r=p`⚠️ This is a major version — review breaking changes before upgrading:\n ${u.link(a,a)}`.value;return`${t} ${r}`}return t}async function Y(e,n){let o=(await h(e)).content,t=o.dependencies??{},a=o.devDependencies??{},i={...t,...a}[await k()];if(!i){l("Auto-upgrade: CLI dependency not found in project dependencies, skipping local upgrade.");return}i.slice(0,1).match(/[\^~]/)&&(i=n);let s=await P(await k(),i);s?q(i,s):W(i),await J("prod",t,e),await J("dev",a,e)}async function J(e,n,o){let t=[await k(),...await j()].filter(r=>!!n[r]).map(r=>({name:r,version:"latest"})),a=await L(o);t.length>0&&await N(t,{packageManager:await S(o),type:e,directory:o,stdout:process.stdout,stderr:process.stderr,addToRootDirectory:a})}async function k(){return(await O()).name}async function j(){return(await O())?.oclif?.plugins??[]}var g;async function O(){if(!g){let e=await h(C(import.meta.url));g=g??e.content}return g}function W(e){d(p`You're on the latest version, ${u.yellow(e)}, no need to upgrade!`)}function q(e,n){d(p`Upgrading CLI from ${u.yellow(e)} to ${u.yellow(n)}...`)}export{M as a,re as b,ie as c,se as d,ce as e,G as f};