@shopify/cli
Version:
A CLI tool to build for the Shopify platform
2 lines (1 loc) • 1.82 kB
JavaScript
import{n as R}from"./chunk-XONFGLJQ.js";import{a as T,b as k}from"./chunk-XULPJ6UG.js";import{f as G}from"./chunk-WSDN25F5.js";import{d as l}from"./chunk-M56NDIMD.js";import{Gb as u,Ib as h,Oa as y,Pa as x,Qb as f,ka as $,ua as b,wa as g}from"./chunk-N5PQPIBF.js";import{d,i as w}from"./chunk-IU2ZQ6TE.js";import{g as m}from"./chunk-VPRTJUIN.js";m();function U(a){let t=/^(?:(?:https:\/\/)?([^:/]+\.[^:/]+)\/|git@([^:/]+)[:/]|([^/]+):)?([^/\s]+)\/([^/\s#]+)(?:((?:\/[^/\s#]+)+))?(?:\/)?(?:#(.+))?/.exec(a);if(!t){let v=["github:user/repo","user/repo/subdirectory","git@github.com:user/repo","user/repo#dev","https://github.com/user/repo"];return k(new Error(`Parsing the url ${a} failed. Supported formats are ${v.join(", ")}.`))}let e=t[1]??t[2]??t[3]??"github.com",r=e==="github"?"github.com":e,s=t[4],i=t[5].replace(/\.git$/,""),n=t[6]?.slice(1),o=t[7],p=o?`#${o}`:"",c=`git@${r}:${s}/${i}`,H=`https://${r}/${s}/${i}`,P=["https:/",r,s,i,n].join("/").concat(p);return T({full:P,site:r,user:s,name:i,ref:o,subDirectory:n,ssh:c,http:H})}function A(a){let t=new URL(a),e=t.hash?t.hash.slice(1):void 0,[r,s,i,...n]=t.pathname.split("/"),o=n.length>0?n.join("/"):void 0;return{baseURL:`${t.origin}/${s}/${i}`,branch:e,filePath:o}}async function B(a,t,e,r){let s=`https://github.com/${a}/releases/download/${t}/${e}`;return G("cmd_all_timing_network_ms")(async()=>{f(h`Downloading ${u.link(e,s)}`),await $(async i=>{let n=d(i,e),o;try{if(o=await R(s,void 0,"slow-request"),!o.ok)throw new l(`Failed to download ${e}: ${o.statusText}`)}catch(c){throw new l(`Failed to download ${e}: ${c instanceof Error?c.message:"unknown error"}`)}let p=await o.arrayBuffer();await b(n,Buffer.from(p)),await x(n,493),await g(w(r)),await y(n,r)}),f(h`${u.successIcon()} Successfully downloaded ${u.path(r)}`)})}export{U as a,A as b,B as c};