@shopify/cli
Version:
A CLI tool to build for the Shopify platform
95 lines (93 loc) • 130 kB
JavaScript
import{b as mi}from"./chunk-OLZHWPZP.js";import{$ as Xn,A as Un,Aa as ci,B as b,Ba as di,C as U,Ca as ui,D as Bn,E as ye,F as er,G as qe,H as rt,I as Se,Ia as Io,J as Vn,Ja as fi,K as Ne,Ka as pr,L as xe,La as ze,M as Gn,Ma as at,N as tr,Na as It,O as pe,Oa as hr,P as Co,Pa as lt,Q as qn,Qa as gr,R as ot,Ra as pi,S as nt,Sa as hi,T as Wn,Ta as gi,U as rr,Ua as yr,V as Yn,Va as yi,W as zn,Wa as wi,X as Jn,Xa as vi,Y as Qn,Z as Kn,_ as We,a as me,aa as W,b as xt,ba as it,c as Rn,ca as Zn,d as De,da as ei,e as Ee,ea as or,f as Ge,fa as nr,g as An,ga as ti,h as Fn,ha as he,i as jn,ia as ri,j as ko,ja as oi,k as tt,ka as To,l as Pt,la as ni,m as je,ma as ii,n as Nn,na as si,o as Kt,oa as ir,p as Eo,pa as sr,q as Ct,qa as ar,r as So,ra as ai,s as Ln,sa as lr,t as Mn,ta as cr,u as xo,ua as li,v as Hn,va as dr,w as Po,wa as ur,x as Xt,xa as Ye,y as Zt,ya as st,z as Tt,za as fr}from"./chunk-JXW374CL.js";import{a as Pn}from"./chunk-3VZEETAV.js";import{a as bi}from"./chunk-E3EMHAJB.js";import{b as Cn,c as Tn,d as Qt,g as In,i as Dn,j as On,k as _n}from"./chunk-TYZXGSHO.js";import{a as rl,b as $n,d as ol}from"./chunk-KHTV6PBV.js";import{a as wr}from"./chunk-WDC3KIZT.js";import{a as mr,b as Do,c as Oo}from"./chunk-7QIOUDCX.js";import{c as xn}from"./chunk-QSTEVZFQ.js";import{Aa as Za,Ba as bn,Ca as el,Da as tl,fa as fe,m as mn,n as ie}from"./chunk-XONFGLJQ.js";import{B as vn,l as hn,m as be,p as et,s as gn,u as yn,x as wn}from"./chunk-L2MGAEV3.js";import{b as D}from"./chunk-XOTA6JTZ.js";import{b as fn}from"./chunk-JUVAGMIH.js";import{A as Ie,D as ee,O as kn,a as Yt,u as V,v as N,w as q,y as $e,z as Re}from"./chunk-6G6TMKXF.js";import{d as E,g as zt}from"./chunk-M56NDIMD.js";import{a as nl}from"./chunk-HZA6IAA4.js";import{b as Xa}from"./chunk-QYR5VPQA.js";import{$ as ln,Ca as wo,Cb as pn,Ea as qt,Ga as dn,Gb as ke,Ha as un,Ib as Y,Ka as vo,Kb as Ae,Nb as $,Oa as bo,Ob as En,Pb as Fe,Qb as Sn,Rb as B,Sb as se,Ta as G,V as Vt,Wa as St,ma as de,na as cn,pa as Gt,qa as yo,qb as Wt,tb as L,ua as J,wa as Et,ya as ve}from"./chunk-N5PQPIBF.js";import{s as Jt}from"./chunk-YTNDFQJT.js";import{d as x,f as C,g as ne,i as go,j as Ze,k as sn,q as an}from"./chunk-IU2ZQ6TE.js";import{a as we,c as ce,e as Q,g as l}from"./chunk-VPRTJUIN.js";var Ls=ce((Mw,Ns)=>{l();Ns.exports=Fc;function Fc(e){var t=e._readableState;return t?t.objectMode||typeof e._duplexState=="number"?e.read():e.read(jc(t)):null}function jc(e){if(e.buffer.length){var t=e.bufferIndex||0;if(e.buffer.head)return e.buffer.head.data.length;if(e.buffer.length-t>0&&e.buffer[t])return e.buffer[t].length}return e.length}});var Vo=ce((Uw,Bs)=>{l();var Wr=$n(),Ms=bn(),Nc=xn(),Lc=Ls(),Hs=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),Bo=function(e,t){e._corked?e.once("uncork",t):t()},Mc=function(e,t){e._autoDestroy&&e.destroy(t)},Us=function(e,t){return function(r){r?Mc(e,r.message==="premature close"?null:r):t&&!e._ended&&e.end()}},Hc=function(e,t){if(!e||e._writableState&&e._writableState.finished)return t();if(e._writableState)return e.end(t);e.end(),t()},Uc=function(e){return new Wr.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},K=function(e,t,r){if(!(this instanceof K))return new K(e,t,r);Wr.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||r.autoDestroy!==!1,this._forwardDestroy=!r||r.destroy!==!1,this._forwardEnd=!r||r.end!==!1,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};Nc(K,Wr.Duplex);K.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new K(e,t,r)};K.prototype.cork=function(){++this._corked===1&&this.emit("cork")};K.prototype.uncork=function(){this._corked&&--this._corked===0&&this.emit("uncork")};K.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.end();return}var t=this,r=Ms(e,{writable:!0,readable:!1},Us(this,this._forwardEnd)),o=function(){var i=t._ondrain;t._ondrain=null,i&&i()},n=function(){t._writable.removeListener("drain",o),r()};this._unwrite&&process.nextTick(o),this._writable=e,this._writable.on("drain",o),this._unwrite=n,this.uncork()};K.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed){e&&e.destroy&&e.destroy();return}if(e===null||e===!1){this.push(null),this.resume();return}var t=this,r=Ms(e,{writable:!1,readable:!0},Us(this)),o=function(){t._forward()},n=function(){t.push(null)},i=function(){t._readable2.removeListener("readable",o),t._readable2.removeListener("end",n),r()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:Uc(e),this._readable2.on("readable",o),this._readable2.on("end",n),this._unread=i,this._forward()};K.prototype._read=function(){this._drained=!0,this._forward()};K.prototype._forward=function(){if(!(this._forwarding||!this._readable2||!this._drained)){this._forwarding=!0;for(var e;this._drained&&(e=Lc(this._readable2))!==null;)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}};K.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;process.nextTick(function(){t._destroy(e)})}};K.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")};K.prototype._write=function(e,t,r){if(this.destroyed)return r();if(this._corked)return Bo(this,this._write.bind(this,e,t,r));if(e===Hs)return this._finish(r);if(!this._writable)return r();this._writable.write(e)===!1?this._ondrain=r:r()};K.prototype._finish=function(e){var t=this;this.emit("preend"),Bo(this,function(){Hc(t._forwardEnd&&t._writable,function(){t._writableState.prefinished===!1&&(t._writableState.prefinished=!0),t.emit("prefinish"),Bo(t,e)})})};K.prototype.end=function(e,t,r){return typeof e=="function"?this.end(null,null,e):typeof t=="function"?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(Hs),Wr.Writable.prototype.end.call(this,r))};Bs.exports=K});var Gs=ce((Vw,Vs)=>{l();Vs.exports=Vc;var Bc=Object.prototype.hasOwnProperty;function Vc(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var o in r)Bc.call(r,o)&&(e[o]=r[o])}return e}});var qo=ce((qw,Yr)=>{l();var qs=$n().Transform,Ws=we("util").inherits,Ys=Gs();function ht(e){qs.call(this,e),this._destroyed=!1}Ws(ht,qs);ht.prototype.destroy=function(e){if(!this._destroyed){this._destroyed=!0;var t=this;process.nextTick(function(){e&&t.emit("error",e),t.emit("close")})}};function Gc(e,t,r){r(null,e)}function Go(e){return function(t,r,o){return typeof t=="function"&&(o=r,r=t,t={}),typeof r!="function"&&(r=Gc),typeof o!="function"&&(o=null),e(t,r,o)}}Yr.exports=Go(function(e,t,r){var o=new ht(e);return o._transform=t,r&&(o._flush=r),o});Yr.exports.ctor=Go(function(e,t,r){function o(n){if(!(this instanceof o))return new o(n);this.options=Ys(e,n),ht.call(this,this.options)}return Ws(o,ht),o.prototype._transform=t,r&&(o.prototype._flush=r),o});Yr.exports.obj=Go(function(e,t,r){var o=new ht(Ys({objectMode:!0,highWaterMark:16},e));return o._transform=t,r&&(o._flush=r),o})});var Qs=ce((Yw,Js)=>{l();var qc=Vo(),Wc=qo(),Yc=Xa(),zc=function(e){return!Buffer.isBuffer(e)&&typeof e!="string"},zs=function(e,t){if(typeof e=="number"&&(e={maxBuffer:e}),typeof e=="function")return zs(null,e);e||(e={});var r=typeof e.maxBuffer=="number"?e.maxBuffer:65535,o=e.strict,n=e.newline!==!1,i=[],s=0,a=qc.obj(),c=Wc.obj({highWaterMark:1},function(m,f,p){if(zc(m))return d(m,null,p);if(Buffer.isBuffer(m)||(m=Yc(m)),n){var g=Array.prototype.indexOf.call(m,10);if(g>0&&m[g-1]===13&&g--,g>-1)return i.push(m.slice(0,g)),d(Buffer.concat(i),m.slice(g),p)}if(i.push(m),s+=m.length,s<r)return p();if(o)return p(new Error("No newline found"));d(Buffer.concat(i),null,p)}),u=function(){if(o)return a.destroy(new Error("No newline found"));a.cork(),d(Buffer.concat(i),null,function(m){if(m)return a.destroy(m);a.uncork()})},d=function(m,f,p){a.removeListener("preend",u),t(m,function(g,w){if(g)return p(g);a.setWritable(w),a.setReadable(w),m&&w.write(m),f&&w.write(f),f=i=c=null,p()})};return a.on("preend",u),a.setWritable(c),a};Js.exports=zs});var Zs=ce((Jw,Xs)=>{l();var Jc=Za(),Qc=bn(),Wo=we("fs"),Mt=function(){},Kc=/^v?\.0/.test(process.version),zr=function(e){return typeof e=="function"},Xc=function(e){return!Kc||!Wo?!1:(e instanceof(Wo.ReadStream||Mt)||e instanceof(Wo.WriteStream||Mt))&&zr(e.close)},Zc=function(e){return e.setHeader&&zr(e.abort)},ed=function(e,t,r,o){o=Jc(o);var n=!1;e.on("close",function(){n=!0}),Qc(e,{readable:t,writable:r},function(s){if(s)return o(s);n=!0,o()});var i=!1;return function(s){if(!n&&!i){if(i=!0,Xc(e))return e.close(Mt);if(Zc(e))return e.abort();if(zr(e.destroy))return e.destroy();o(s||new Error("stream was destroyed"))}}},Ks=function(e){e()},td=function(e,t){return e.pipe(t)},rd=function(){var e=Array.prototype.slice.call(arguments),t=zr(e[e.length-1]||Mt)&&e.pop()||Mt;if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new Error("pump requires two streams per minimum");var r,o=e.map(function(n,i){var s=i<e.length-1,a=i>0;return ed(n,s,a,function(c){r||(r=c),c&&o.forEach(Ks),!s&&(o.forEach(Ks),t(r))})});e.reduce(td)};Xs.exports=rd});var ra=ce((Kw,Jr)=>{l();var od=Zs(),nd=xn(),ea=Vo(),ta=function(e){return e.length?Array.isArray(e[0])?e[0]:Array.prototype.slice.call(e):[]},Yo=function(e){var t=function(){var r=ta(arguments);if(!(this instanceof t))return new t(r);ea.call(this,null,null,e),r.length&&this.setPipeline(r)};return nd(t,ea),t.prototype.setPipeline=function(){var r=ta(arguments),o=this,n=!1,i=r[0],s=r[r.length-1];s=s.readable?s:null,i=i.writable?i:null;var a=function(){r[0].emit("error",new Error("stream was destroyed"))};if(this.on("close",a),this.on("prefinish",function(){n||o.cork()}),od(r,function(c){if(o.removeListener("close",a),c)return o.destroy(c.message==="premature close"?null:c);n=!0,o._autoDestroy===!1&&(o._autoDestroy=!0),o.uncork()}),this.destroyed)return a();this.setWritable(i),this.setReadable(s)},t};Jr.exports=Yo({autoDestroy:!1,destroy:!1});Jr.exports.obj=Yo({autoDestroy:!1,destroy:!1,objectMode:!0,highWaterMark:16});Jr.exports.ctor=Yo});var na=ce((Zw,oa)=>{"use strict";l();oa.exports=function(e){return!e||e.length<3?!1:e[0]===31&&e[1]===139&&e[2]===8}});var sa=ce((tv,ia)=>{"use strict";l();ia.exports=function(e){return!e||e.length<2?!1:e[0]===120&&(e[1]===1||e[1]===156||e[1]===218)}});var da=ce((ov,ca)=>{l();var aa=we("zlib"),id=Qs(),sd=qo(),la=ra(),ad=na(),ld=sa(),cd=function(e){return ad(e)?1:ld(e)?2:0},zo=function(e){return e===void 0&&(e=3),id({newline:!1,maxBuffer:10},function(t,r){if(e<0)return r(new Error("Maximum recursion reached"));switch(cd(t)){case 1:r(null,la(aa.createGunzip(),zo(e-1)));break;case 2:r(null,la(aa.createInflate(),zo(e-1)));break;default:r(null,sd())}})};ca.exports=zo});var ya=ce((iv,ga)=>{"use strict";l();var ge=we("fs"),Ke=we("path"),dd=ge.lchown?"lchown":"chown",ud=ge.lchownSync?"lchownSync":"chownSync",fa=ge.lchown&&!process.version.match(/v1[1-9]+\./)&&!process.version.match(/v10\.[6-9]/),ua=(e,t,r)=>{try{return ge[ud](e,t,r)}catch(o){if(o.code!=="ENOENT")throw o}},fd=(e,t,r)=>{try{return ge.chownSync(e,t,r)}catch(o){if(o.code!=="ENOENT")throw o}},md=fa?(e,t,r,o)=>n=>{!n||n.code!=="EISDIR"?o(n):ge.chown(e,t,r,o)}:(e,t,r,o)=>o,Jo=fa?(e,t,r)=>{try{return ua(e,t,r)}catch(o){if(o.code!=="EISDIR")throw o;fd(e,t,r)}}:(e,t,r)=>ua(e,t,r),pd=process.version,ma=(e,t,r)=>ge.readdir(e,t,r),hd=(e,t)=>ge.readdirSync(e,t);/^v4\./.test(pd)&&(ma=(e,t,r)=>ge.readdir(e,r));var Qr=(e,t,r,o)=>{ge[dd](e,t,r,md(e,t,r,n=>{o(n&&n.code!=="ENOENT"?n:null)}))},pa=(e,t,r,o,n)=>{if(typeof t=="string")return ge.lstat(Ke.resolve(e,t),(i,s)=>{if(i)return n(i.code!=="ENOENT"?i:null);s.name=t,pa(e,s,r,o,n)});if(t.isDirectory())Qo(Ke.resolve(e,t.name),r,o,i=>{if(i)return n(i);let s=Ke.resolve(e,t.name);Qr(s,r,o,n)});else{let i=Ke.resolve(e,t.name);Qr(i,r,o,n)}},Qo=(e,t,r,o)=>{ma(e,{withFileTypes:!0},(n,i)=>{if(n){if(n.code==="ENOENT")return o();if(n.code!=="ENOTDIR"&&n.code!=="ENOTSUP")return o(n)}if(n||!i.length)return Qr(e,t,r,o);let s=i.length,a=null,c=u=>{if(!a){if(u)return o(a=u);if(--s===0)return Qr(e,t,r,o)}};i.forEach(u=>pa(e,u,t,r,c))})},gd=(e,t,r,o)=>{if(typeof t=="string")try{let n=ge.lstatSync(Ke.resolve(e,t));n.name=t,t=n}catch(n){if(n.code==="ENOENT")return;throw n}t.isDirectory()&&ha(Ke.resolve(e,t.name),r,o),Jo(Ke.resolve(e,t.name),r,o)},ha=(e,t,r)=>{let o;try{o=hd(e,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return;if(n.code==="ENOTDIR"||n.code==="ENOTSUP")return Jo(e,t,r);throw n}return o&&o.length&&o.forEach(n=>gd(e,n,t,r)),Jo(e,t,r)};ga.exports=Qo;Qo.sync=ha});var ka=ce((av,ba)=>{l();var Kr=we("path"),wa=we("fs"),va=parseInt("0777",8);ba.exports=gt.mkdirp=gt.mkdirP=gt;function gt(e,t,r,o){typeof t=="function"?(r=t,t={}):(!t||typeof t!="object")&&(t={mode:t});var n=t.mode,i=t.fs||wa;n===void 0&&(n=va&~process.umask()),o||(o=null);var s=r||function(){};e=Kr.resolve(e),i.mkdir(e,n,function(a){if(!a)return o=o||e,s(null,o);a.code==="ENOENT"?gt(Kr.dirname(e),t,function(c,u){c?s(c,u):gt(e,t,s,u)}):i.stat(e,function(c,u){c||!u.isDirectory()?s(a,o):s(null,o)})})}gt.sync=function e(t,r,o){(!r||typeof r!="object")&&(r={mode:r});var n=r.mode,i=r.fs||wa;n===void 0&&(n=va&~process.umask()),o||(o=null),t=Kr.resolve(t);try{i.mkdirSync(t,n),o=o||t}catch(a){switch(a.code){case"ENOENT":o=e(Kr.dirname(t),r,o),e(t,r,o);break;default:var s;try{s=i.statSync(t)}catch{throw a}if(!s.isDirectory())throw a;break}}return o}});var Oa=ce(Zo=>{l();var yd=ya(),xa=ol(),Pa=el(),wd=ka(),Ca=we("fs"),X=we("path"),vd=we("os"),Ht=vd.platform()==="win32",Ut=function(){},Xo=function(e){return e},Ko=Ht?function(e){return e.replace(/\\/g,"/").replace(/[:?<>|]/g,"_")}:Xo,bd=function(e,t,r,o,n,i){var s=n||["."];return function(c){if(!s.length)return c();var u=s.shift(),d=X.join(r,u);t.call(e,d,function(m,f){if(m)return c(m);if(!f.isDirectory())return c(null,u,f);e.readdir(d,function(p,g){if(p)return c(p);i&&g.sort();for(var w=0;w<g.length;w++)o(X.join(r,u,g[w]))||s.push(X.join(u,g[w]));c(null,u,f)})})}},Ta=function(e,t){return function(r){r.name=r.name.split("/").slice(t).join("/");var o=r.linkname;return o&&(r.type==="link"||X.isAbsolute(o))&&(r.linkname=o.split("/").slice(t).join("/")),e(r)}};Zo.pack=function(e,t){e||(e="."),t||(t={});var r=t.fs||Ca,o=t.ignore||t.filter||Ut,n=t.map||Ut,i=t.mapStream||Xo,s=bd(r,t.dereference?r.stat:r.lstat,e,o,t.entries,t.sort),a=t.strict!==!1,c=typeof t.umask=="number"?~t.umask:~Ia(),u=typeof t.dmode=="number"?t.dmode:0,d=typeof t.fmode=="number"?t.fmode:0,m=t.pack||xa.pack(),f=t.finish||Ut;t.strip&&(n=Ta(n,t.strip)),t.readable&&(u|=parseInt(555,8),d|=parseInt(444,8)),t.writable&&(u|=parseInt(333,8),d|=parseInt(222,8));var p=function(k,y){r.readlink(X.join(e,k),function(v,h){if(v)return m.destroy(v);y.linkname=Ko(h),m.entry(y,w)})},g=function(k,y,v){if(k)return m.destroy(k);if(!y)return t.finalize!==!1&&m.finalize(),f(m);if(v.isSocket())return w();var h={name:Ko(y),mode:(v.mode|(v.isDirectory()?u:d))&c,mtime:v.mtime,size:v.size,type:"file",uid:v.uid,gid:v.gid};if(v.isDirectory())return h.size=0,h.type="directory",h=n(h)||h,m.entry(h,w);if(v.isSymbolicLink())return h.size=0,h.type="symlink",h=n(h)||h,p(y,h);if(h=n(h)||h,!v.isFile())return a?m.destroy(new Error("unsupported type for "+y)):w();var S=m.entry(h,w);if(S){var P=i(r.createReadStream(X.join(e,y),{start:0,end:h.size>0?h.size-1:h.size}),h);P.on("error",function(_){S.destroy(_)}),Pa(P,S)}},w=function(k){if(k)return m.destroy(k);s(g)};return w(),m};var kd=function(e){return e.length?e[e.length-1]:null},Ed=function(){return process.getuid?process.getuid():-1},Ia=function(){return process.umask?process.umask():0};Zo.extract=function(e,t){e||(e="."),t||(t={});var r=t.fs||Ca,o=t.ignore||t.filter||Ut,n=t.map||Ut,i=t.mapStream||Xo,s=t.chown!==!1&&!Ht&&Ed()===0,a=t.extract||xa.extract(),c=[],u=new Date,d=typeof t.umask=="number"?~t.umask:~Ia(),m=typeof t.dmode=="number"?t.dmode:0,f=typeof t.fmode=="number"?t.fmode:0,p=t.strict!==!1;t.strip&&(n=Ta(n,t.strip)),t.readable&&(m|=parseInt(555,8),f|=parseInt(444,8)),t.writable&&(m|=parseInt(333,8),f|=parseInt(222,8));var g=function(y,v){for(var h;(h=kd(c))&&y.slice(0,h[0].length)!==h[0];)c.pop();if(!h)return v();r.utimes(h[0],u,h[1],v)},w=function(y,v,h){if(t.utimes===!1)return h();if(v.type==="directory")return r.utimes(y,u,v.mtime,h);if(v.type==="symlink")return g(y,h);r.utimes(y,u,v.mtime,function(S){if(S)return h(S);g(y,h)})},k=function(y,v,h){var S=v.type==="symlink",P=S?r.lchmod:r.chmod,_=S?r.lchown:r.chown;if(!P)return h();var I=(v.mode|(v.type==="directory"?m:f))&d;_&&s?_.call(r,y,v.uid,v.gid,F):F(null);function F(R){if(R)return h(R);if(!P)return h();P.call(r,y,I,h)}};return a.on("entry",function(y,v,h){y=n(y)||y,y.name=Ko(y.name);var S=X.join(e,X.join("/",y.name));if(o(S,y))return v.resume(),h();var P=function(T){if(T)return h(T);w(S,y,function(j){if(j)return h(j);if(Ht)return h();k(S,y,h)})},_=function(){if(Ht)return h();r.unlink(S,function(){var T=X.resolve(X.dirname(S),y.linkname);if(!Sa(T,e))return h(new Error(S+" is not a valid symlink"));r.symlink(y.linkname,S,P)})},I=function(){if(Ht)return h();r.unlink(S,function(){var T=X.join(e,X.join("/",y.linkname));r.realpath(T,function(j,H){if(j||!Sa(H,e))return h(new Error(S+" is not a valid hardlink"));r.link(H,S,function(A){if(A&&A.code==="EPERM"&&t.hardlinkAsFilesFallback)return v=r.createReadStream(T),F();P(A)})})})},F=function(){var T=r.createWriteStream(S),j=i(v,y);T.on("error",function(H){j.destroy(H)}),Pa(j,T,function(H){if(H)return h(H);T.on("close",P)})};if(y.type==="directory")return c.push([S,y.mtime]),Ea(S,{fs:r,own:s,uid:y.uid,gid:y.gid},P);var R=X.dirname(S);Da(r,R,X.join(e,"."),function(T,j){if(T)return h(T);if(!j)return h(new Error(R+" is not a valid path"));Ea(R,{fs:r,own:s,uid:y.uid,gid:y.gid},function(H){if(H)return h(H);switch(y.type){case"file":return F();case"link":return I();case"symlink":return _()}if(p)return h(new Error("unsupported type for "+S+" ("+y.type+")"));v.resume(),h()})})}),t.finish&&a.on("finish",t.finish),a};function Da(e,t,r,o){if(t===r)return o(null,!0);e.lstat(t,function(n,i){if(n&&n.code!=="ENOENT")return o(n);if(n||i.isDirectory())return Da(e,X.join(t,".."),r,o);o(null,!1)})}function Ea(e,t,r){wd(e,{fs:t.fs},function(o,n){!o&&n&&t.own?yd(n,t.uid,t.gid,r):r(o)})}function Sa(e,t){return t=X.resolve(t),t===e||e.startsWith(t+X.sep)}});l();l();var xr=Q(me(),1);l();l();var vr=[{name:"npm",lockfile:"package-lock.json",alternativeLockfiles:["npm-shrinkwrap.json"],installCommand:"npm ci"},{name:"yarn",lockfile:"yarn.lock",installCommand:"yarn install --frozen-lockfile"},{name:"pnpm",lockfile:"pnpm-lock.yaml",installCommand:"pnpm install --frozen-lockfile"},{name:"bun",lockfile:"bun.lockb",alternativeLockfiles:["bun.lock"],installCommand:"bun install --frozen-lockfile"}];function il(e){let t="No lockfile found",r="If you don\u2019t commit a lockfile, then your app might install the wrong package versions when deploying. To avoid versioning issues, generate a new lockfile and commit it to your repository.",o=[["Generate a lockfile. Run",{command:"npm|yarn|pnpm install"}],"Commit the new file to your repository"];if(e)throw new E(t,r,o);q({headline:t,body:r,nextSteps:o})}function sl(e,t){let r=e.map(({packageManager:s,foundLockfile:a})=>`${a} (created by ${s.name})`),o="Multiple lockfiles found",n=[`Your project contains more than one lockfile. This can cause version conflicts when installing and deploying your app. The following lockfiles were detected:
`,{list:{items:r}}],i=["Delete any unneeded lockfiles","Commit the change to your repository"];if(t)throw new E(o,n,i);q({headline:o,body:n,nextSteps:i})}function al(e){let t="Lockfile ignored by Git",r="Your project\u2019s lockfile isn\u2019t being tracked by Git. If you don\u2019t commit a lockfile, then your app might install the wrong package versions when deploying.",o=[`In your project\u2019s .gitignore file, delete any references to ${e}`,"Commit the change to your repository"];q({headline:t,body:r,nextSteps:o})}async function ki(e,t=!1){if(De&&!process.env.SHOPIFY_UNIT_TEST)return;let r=[];for(let i of vr){let s=[i.lockfile,...i.alternativeLockfiles||[]];for(let a of s)if(await G(C(e,a))){r.push({packageManager:i,foundLockfile:a});break}}if(r.length===0)return il(t);if(r.length>1)return sl(r,t);let o=r[0].foundLockfile;(await Cn(e,[o]).catch(()=>[])).length>0&&al(o)}l();var ll=["^cdn/","^_t/"];function br(e){let t=new Set;return Object.values(e.routes).filter(r=>ll.some(o=>new RegExp(o).test(r.path??""))).forEach(r=>{r.path&&t.add(r.path)}),[...t]}var cl=["","cart","products/:productHandle","collections","collections/:collectionHandle","sitemap.xml","robots.txt","pages/:pageHandle","policies/:policyHandle","search","account","account/login","account/orders/:orderId","account/authorize"];function kr(e,t=cl){let r=Object.values(e.routes),o=new Set(t);for(let n of t)for(let i of r)if(!n&&!i.path)o.delete(n);else if(n&&i.path){let s={path:i.path,parentId:i.parentId};for(;s.parentId&&s.parentId!=="root";){let u=r.find(d=>d.id===s.parentId);if(!u)break;s.path=u.path==null?s.path:`${u.path}/${s.path}`,s.parentId=u.parentId}let a=":?[^\\/\\?]+\\?",c=`^(${a}\\/)?`+n.replaceAll(".","\\.").replace(/\//g,`\\/(${a}\\/)?`).replace(/:[^/)?]+/g,"(:[^\\/]+|\\*)")+`(\\/${a})?$`;new RegExp(c).test(s.path)&&o.delete(n)}return[...o]}var Le=100;function Ei(e){e.length?q({headline:"Standard Shopify routes missing",body:`Your Hydrogen project is missing ${e.length} standard Shopify route${e.length>1?"s":""}.
Including these routes improves compatibility with Shopify\u2019s platform:
`+e.slice(0,Le-(e.length<=Le?0:1)).map(t=>`\u2022 /${t}`).join(`
`)+(e.length>Le?`
\u2022 ...and ${e.length-Le+1} more`:"")}):N({headline:"All standard Shopify routes present"})}function Er(e){e.length&&q({headline:"Reserved routes present",body:`Your Hydrogen project is using ${e.length} reserved route${e.length>1?"s":""}.
These routes are reserved by Shopify and may cause issues with your storefront:
`+e.slice(0,Le-(e.length<=Le?0:1)).map(t=>`\u2022 /${t}`).join(`
`)+(e.length>Le?`
\u2022 ...and ${e.length-Le+1} more`:"")})}l();l();var Me="metafile.server.json",Oe="server-bundle-analyzer.html";async function Si(){return de(await Ge("bundle","analyzer.html"))}function xi(e,t){return e.replace("globalThis.METAFILE = '';",`globalThis.METAFILE = '${Buffer.from(t,"utf-8").toString("base64")}';`)}async function Pi(e){try{return` \u2502
`+(await(await import("esbuild")).analyzeMetafile(await de(x(e,Me)),{color:!0})).split(`
`).filter(o=>!o.match(/(.*)(node_modules\/|server-assets-manifest:|server-entry-module:)(react-dom|@remix-run|@shopify\/hydrogen|react-router|react-router-dom)\/(.*)/g)).slice(2,12).join(`
`).replace(/dist\/worker\/_assets\/.*$/ms,`
`).replace(/\n/g,`
`).replace(/(\.\.\/)+node_modules\//g,o=>L.dim(o))}catch(t){console.warn("Could not generate bundle analysis summary:",t.message)}}function Ti(e){let t;return{name:"hydrogen:bundle-analyzer",configResolved(r){t=r},async generateBundle(r,o){if(!t.build.ssr)return;let{root:n}=t,i=Object.values(o).find(g=>g.type==="chunk");if(!i||i.type!=="chunk"||!i.facadeModuleId||!r.dir)return;let s=await Si().catch(()=>null);if(!s){console.warn("Bundle analyzer template not found");return}let a=new Set(Object.keys(i.modules)),c=[];for(let g of a){if(_o(g)||$o(g))continue;let w=this.getModuleInfo(g);if(w?.id){c.push(w);for(let k of[...w.importedIds,...w.dynamicallyImportedIds])!_o(k)&&!$o(k)&&a.add(k)}}let u=new Map,d=new Map,m=await Promise.all(c.map(async g=>{let w=ne(n,g.id),k=i.modules[g.id],y=k?.originalLength??g.code?.length??0,v=k?.renderedLength??0;if(e?.minify&&k?.code){let F=await e.minify(k.code,g.id).catch(()=>null);F&&(v=F.length)}d.set(w,v);let h=F=>this.resolve(F,g.id),S=!g.code||/(^\s*export\s+[\w\{]|^\s*import\s+[\w\{'"]|\bimport\()|\bcreateRequire\(/ms.test(g.code)||!/((^|\b)exports\b|\brequire\()/.test(g.code),P=Ci(g.importedIds,"import-statement",n,h,g.code),_=Ci(g.dynamicallyImportedIds,"dynamic-import",n,h,g.code),I=(await Promise.all([...P,..._])).reduce((F,{importedId:R,...T})=>(_o(R)?S=!1:$o(R)||F.push(T),F),[]);u.set(w,{bytes:y,format:S?"esm":"cjs",imports:I})})).then(()=>null).catch(g=>g);if(m){console.warn("Bundle analyzer failed to analyze the bundle:",m);return}let f=Object.fromEntries(u.entries()),p={inputs:f,outputs:{[ne(n,x(r.dir,i.fileName))]:{imports:i.imports,exports:i.exports,entryPoint:ne(n,i.facadeModuleId),bytes:i.code.length??0,inputs:Object.entries(f).reduce((g,[w,k])=>(g[w]={bytesInOutput:d.get(w)??k.bytes??0},g),{})}}};o[Me]={type:"asset",fileName:Me,needsCodeReference:!1,source:JSON.stringify(p,null,2),names:[Me],originalFileNames:[Me],name:Me,originalFileName:Me},o[Oe]={type:"asset",fileName:Oe,needsCodeReference:!1,source:xi(s,JSON.stringify(p)),names:[Oe],originalFileNames:[Oe],name:Oe,originalFileName:Oe}}}}function _o(e){return/(commonjsHelpers\.js$|\?commonjs\-)/.test(e)}function $o(e){return e.endsWith("?transform-only")}async function dl(e,t,r){let o=t.matchAll(/import\s[^'"]*?['"]([^'"]+)['"]/g)??[];for(let[,n]of o)if(n&&(await r(n))?.id===e)return n;return e}function Ci(e,t,r,o,n){return e.map(async i=>({importedId:i,path:ne(r,i),kind:t,original:n?await dl(i,n,o):i}))}l();import{spawn as ul}from"node:child_process";import{fileURLToPath as Di}from"node:url";var fl=process.argv[1],ml=Di(import.meta.url),pl=fl===ml;pl&&Dt({rootDirectory:process.argv[2],appDirectory:process.argv[3],configFilePath:process.argv[4],watch:!0});function Oi(e,t){if(e.includes("AbortError: ")){let s=e.split("AbortError: ")[1]??"",a=s.split(`
`)[0],c=s.match(/tryMessage: '(.*)',$/m)?.[1];if(a)return{message:a,details:c}}let[r="",...o]=e.replaceAll("[FAILED]","").replace(/\s{2,}/g,`
`).replace(/\n,\n/,`
`).trim().split(`
`),n="[Codegen] "+r,i=o.join(`
`);if(t){let s=t.replaceAll("\\","/")+"/";i=i.replaceAll(s,"")}return{message:n,details:i}}function Sr({rootDirectory:e,appDirectory:t,configFilePath:r}){let o,n,i=process.argv.findIndex(a=>a==="hydrogen");i>=1?(o=process.argv[0],n=[...process.argv.slice(1,i+1),"codegen","--watch","--path",e],r&&n.push("--codegen-config-path",r)):(o="node",n=[Di(import.meta.url),e,t??C("app"),r??""]);let s=ul(o,n,{stdio:["inherit","ignore","pipe"]});return s.stderr.on("data",a=>{let c=typeof a=="string"?a:a?.toString?.("utf8")??"";if(!c)return;let{message:u,details:d}=Oi(c,e);/`punycode`/.test(u)||/\.body\[\d\]/.test(u)||/console\.time(End)?\(\)/.test(u)||/─ (warning|info|success) ───/.test(u)||(V({body:""}),q({headline:u,body:d}))}),s.on("close",a=>{a&&a>0&&q({headline:"Codegen process exited with code "+a,body:"There should be more logs above."})}),s}async function Dt(e){return await hl(e),gl(e).catch(t=>{if(t instanceof E)throw t;let{message:r,details:o}=Oi(t.message,e.rootDirectory);throw new E(r,o)})}async function hl(e){let{execSync:t,exec:r}=await import("child_process");try{t("npx react-router --version",{cwd:e.rootDirectory,stdio:"ignore"})}catch{V({body:"React Router not found, skipping typegen"});return}e.watch?r("npx react-router typegen --watch",{cwd:e.rootDirectory}):t("npx react-router typegen",{cwd:e.rootDirectory,stdio:"inherit"})}async function gl({watch:e,configFilePath:t,forceSfapiVersion:r,...o}){let{generate:n,loadCodegenConfig:i,CodegenContext:s}=await qe("@graphql-codegen/cli",o.rootDirectory).catch(()=>{throw new E("Could not load GraphQL Codegen CLI.","Please make sure you have `@graphql-codegen/cli` installed as a dev dependency.")}),{config:a}=await i({configFilePath:t??o.rootDirectory})||await yl(o,r);await wl(a,o);let c=new s({config:{...a,watch:e,silent:!e,cwd:o.rootDirectory},filepath:"not-used-but-must-be-set"});return c.cwd=o.rootDirectory,await n(c,!0),Object.entries(a.generates).reduce((u,[d,m])=>("documents"in m&&(u[d]=(Array.isArray(m.documents)?m.documents:[m.documents]).filter(f=>typeof f=="string")),u),{})}async function yl({rootDirectory:e,appDirectory:t=C(e,"app")},r){let{getSchema:o,preset:n,pluckConfig:i}=await qe("@shopify/hydrogen-codegen",e).catch(()=>{throw new E("Could not load Hydrogen Codegen.","Please make sure you have `@shopify/hydrogen-codegen` installed as a dev dependency.")}),{loadConfig:s}=await qe("graphql-config",e).catch(()=>{throw new E("Could not load GraphQL Config.","Please make sure you have `graphql-config` installed as a dev dependency.")}),a=await s({rootDir:e,throwOnEmpty:!1,throwOnMissing:!1,legacy:!1}).catch(()=>{}),c=o("storefront"),u=Ii(c,a),d=o("customer-account",{throwIfMissing:!1}),m=d?Ii(d,a):void 0,f="*!(*.d).{ts,tsx,js,jsx}",p=ne(e,t),g=k=>{let y=Ze(c),v=d&&Ze(d);return!!(k.endsWith(y)||v&&k.endsWith(v))},w=Object.values(a?.projects??{}).filter(k=>k.hasExtension("codegen")&&(typeof k.schema!="string"||!g(k.schema)));return{filepath:"virtual:codegen",config:{overwrite:!0,pluckConfig:i,generates:{...Ro(u)??{"storefrontapi.generated.d.ts":{preset:n,schema:c,documents:u?.documents??[f,x(p,"**",f)],...!!r&&{presetConfig:{importTypes:!1},schema:{[`https://hydrogen-preview.myshopify.com/api/${r.split(":")[0]}/graphql.json`]:{headers:{"content-type":"application/json","X-Shopify-Storefront-Access-Token":r.split(":")[1]??"3b580e70970c4528da70c98e097c2fa0"}}},config:{defaultScalarType:"string",scalars:{JSON:"unknown"}}}}},...Ro(m)??(m?.documents?{"customer-accountapi.generated.d.ts":{preset:n,schema:d,documents:m.documents}}:{}),...w.reduce((k,y)=>({...k,...Ro(y)}),{})}}}}function Ro(e){if(e?.extensions?.codegen?.generates)return Object.entries(e.extensions.codegen.generates).reduce((t,[r,o])=>(t[r]={...e,...Array.isArray(o)?o[0]:o},t),{})}function Ii(e,t){if(!t)return;let r=Ze(e);return Object.values(t.projects||{}).find(o=>typeof o.schema=="string"&&o.schema.endsWith(r))}async function wl(e,{rootDirectory:t}){let r=Symbol.for("name"),o=Object.values(e.generates).filter(n=>{let i=(Array.isArray(n)?n[0]:n)?.preset;if(typeof i=="object"&&r in i)return i[r]==="hydrogen"||i[r]==="@shopify/graphql-codegen"});for(let n of o){let i=Array.isArray(n)?n[0]:n;if(i){let s=await tt(t);i.hooks={beforeOneFileWrite:(a,c)=>Pt(c,s,a),...i.hooks}}}}l();function Ot(){let{env:e}=process;return e.CI==="false"?!1:!!(e.CI||e.CI_NAME||e.BUILD_NUMBER||e.TF_BUILD)}l();function _t(){let e={state:"pending"};return e.promise=new Promise((t,r)=>{e.resolve=o=>(e.state==="pending"&&(e.state="resolved"),t(o)),e.reject=o=>(e.state==="pending"&&(e.state="rejected"),r(o))}),e}l();function He(e){let t,r=process.exit;process.exit=async o=>{t??=e();let n=setTimeout(()=>r(o),5e3);return await t,clearTimeout(n),r(o)}}var Pr=class e extends D{static descriptionWithMarkdown="Builds a Hydrogen storefront for production. The client and app worker files are compiled to a `/dist` folder in your Hydrogen project directory.";static description="Builds a Hydrogen storefront for production.";static flags={...b.path,...b.entry,...b.sourcemap,...b.lockfileCheck,...b.disableRouteWarning,...b.codegen,watch:xr.Flags.boolean({description:"Watches for changes and rebuilds the project writing output to disk.",env:"SHOPIFY_HYDROGEN_FLAG_WATCH"}),"bundle-stats":xr.Flags.boolean({description:"Show a bundle size summary after building. Defaults to true, use `--no-bundle-stats` to disable.",allowNo:!0}),"force-client-sourcemap":xr.Flags.boolean({description:"Client sourcemapping is avoided by default because it makes backend code visible in the browser. Use this flag to force enabling it.",env:"SHOPIFY_HYDROGEN_FLAG_FORCE_CLIENT_SOURCEMAP"})};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd(),o={...U(t),useCodegen:t.codegen,directory:r};if(!await tr(r))throw new E(xe);let i=await Je(o);o.watch?i?.close&&He(async()=>{await i?.close()}):process.exit(0)}},vl=5;async function Je({entry:e,directory:t,useCodegen:r=!1,codegenConfigPath:o,sourcemap:n=!0,forceClientSourcemap:i,disableRouteWarning:s=!1,lockfileCheck:a=!0,assetPath:c,bundleStats:u=!Ot(),watch:d=!1,onServerBuildStart:m,onServerBuildFinish:f}){process.env.NODE_ENV||(process.env.NODE_ENV="production"),c=c??process.env.HYDROGEN_ASSET_BASE_URL??"/";let p=t??process.cwd();a&&await ki(p,Ot());let[g,{userViteConfig:w,remixConfig:k,clientOutDir:y,serverOutDir:v,serverOutFile:h}]=await Promise.all([er(p),pe(p,e)]),S=g.createLogger(d?"warn":void 0);process.env.SHOPIFY_UNIT_TEST&&(S.info=A=>Ae("info",A),S.warn=A=>Ae("warn",A),S.error=A=>Ae("error",A));let P=w.build?.minify??!0,_={root:p,mode:process.env.NODE_ENV,base:c,customLogger:S},I,F=await g.build({..._,build:{emptyOutDir:!0,copyPublicDir:!0,sourcemap:i??(process.env.NODE_ENV!=="production"&&n),watch:d?{}:null},server:{watch:d?{}:null},plugins:[{name:"hydrogen:cli:client",buildStart(){I?.resolve(),I=_t()},buildEnd(A){A&&I.reject(A)},writeBundle(){I.resolve()},closeWatcher(){this.error(new Error("Process exited before client build finished."))}}]});console.log("");let R,T=await g.build({..._,build:{sourcemap:n,ssr:e??!0,emptyOutDir:!1,copyPublicDir:!1,minify:P,watch:d?{buildDelay:100}:null},server:{watch:d?{}:null},plugins:[{name:"hydrogen:cli:server",async buildStart(){await I.promise,R?.resolve(),R=_t(),await m?.()},async writeBundle(){R?.state!=="rejected"&&await f?.(),R.resolve()},closeWatcher(){this.error(new Error("Process exited before server build finished."))}},...u?[Ti({minify:P?(A,Z)=>g.transformWithEsbuild(A,Z,{minify:!0,minifyWhitespace:!0,minifySyntax:!0,minifyIdentifiers:!0,sourcemap:!1,treeShaking:!1,legalComments:"none",target:"esnext"}).then(Ce=>Ce.code):void 0})]:[]]});d||await Promise.all([ve(x(y,".vite")),ve(x(v,".vite")),ve(x(v,"assets"))]);let j={rootDirectory:p,appDirectory:k.appDirectory,configFilePath:o},H=r?d?Sr(j):await Dt(j).then(()=>{}):void 0;if(!d&&process.env.NODE_ENV!=="development"){if(u){let Z="file://"+x(v,Oe);$(Y`${await Pi(v)||`
`}\n │\n └─── ${ke.link("Complete analysis: "+Z,Z)}\n\n`)}await dn(h)/(1024*1024)>=vl&&B(`\u{1F6A8} Smaller worker bundles are faster to deploy and run.${P?"":"\n Minify your bundle by adding `build.minify: true` to vite.config.js."}
Learn more about optimizing your worker bundle file: https://h2o.fyi/debugging/bundle-size
`)}if(!d&&!s){let A=kr(k);if(A.length){let Z=await be(p),Ce=Z==="npm"?"npx":Z;B(`Heads up: Shopify stores have a number of standard routes that aren\u2019t set up yet.
Some functionality and backlinks might not work as expected until these are created or redirects are set up.
This build is missing ${A.length} route${A.length>1?"s":""}. For more details, run \`${Ce} shopify hydrogen check routes\`.
`)}}return!d&&!s&&Er(br(k)),{async close(){H?.removeAllListeners("close"),H?.kill("SIGINT");let A=[];"close"in F&&A.push(F.close()),"close"in T&&A.push(T.close()),await Promise.allSettled(A),(I?.state==="pending"||R?.state==="pending")&&(I?.promise.catch(()=>{}),I?.reject(),R?.promise.catch(()=>{}),R?.reject(),await new Promise(Z=>setTimeout(Z,500)))}}}l();var _i=Q(me(),1),Cr=class e extends D{static descriptionWithMarkdown="Checks whether your Hydrogen app includes a set of standard Shopify routes.";static description="Returns diagnostic information about a Hydrogen storefront.";static flags={...b.path};static args={resource:_i.Args.string({name:"resource",description:"The resource to check. Currently only 'routes' is supported.",required:!0,options:["routes"]})};async run(){let{flags:t,args:r}=await this.parse(e),o=t.path?C(t.path):process.cwd();if(r.resource==="routes")await bl({directory:o});else throw new Error("Invalid command argument.")}};async function bl({directory:e}){let t=await Ne(e);Ei(kr(t)),Er(br(t))}l();var Tr=Q(me(),1);var Ir=class e extends D{static descriptionWithMarkdown="Automatically generates GraphQL types for your project\u2019s Storefront API queries.";static description="Generate types for the Storefront API queries found in your project.";static flags={...b.path,"codegen-config-path":Tr.Flags.string({description:"Specify a path to a codegen configuration file. Defaults to `<root>/codegen.ts` if it exists.",required:!1}),"force-sfapi-version":Tr.Flags.string({description:"Force generating Storefront API types for a specific version instead of using the one provided in Hydrogen. A token can also be provided with this format: `<version>:<token>`.",hidden:!0}),watch:Tr.Flags.boolean({description:"Watch the project for changes to update types on file save.",required:!1,default:!1})};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd();await kl({...U(t),directory:r})}};async function kl({directory:e,codegenConfigPath:t,forceSfapiVersion:r,watch:o}){let{root:n}=Se(e),i=await Ne(n);console.log("");let s=await Dt({...i,configFilePath:t,forceSfapiVersion:r,watch:o});o||N({headline:"Generated types for GraphQL:",body:{list:{items:Object.entries(s).map(([a,c])=>a+`
`+c.map(u=>L.dim(`- ${u}`)).join(`
`))}}})}l();var Ai=Q(me(),1);l();import{Session as El}from"node:inspector";async function $i(e){let{createMiniOxygen:t}=await qe("@shopify/mini-oxygen/node",e).catch(Io),r=t({script:"export default {}",modules:!0,log:()=>{}});return{async run(o,n){let[i]=await Promise.all([de(o),r.ready()]),s=await Sl();await r.reload({script:i});let a=await s();return xl(a,o+".map",n)},async close(){await r.dispose()}}}function Sl(){let e=new El;return e.connect(),new Promise(t=>{e.post("Profiler.enable",()=>{e.post("Profiler.start",()=>{t(()=>new Promise((r,o)=>{e.post("Profiler.stop",(n,{profile:i})=>{if(e.disconnect(),n)return o(n);r(i)})}))})})})}async function xl(e,t,r){let{SourceMapConsumer:o}=await import("./source-map-3K6Y2OMO.js"),n=JSON.parse(await de(t)),i=await new o(n,"file://"+t),s=new Set,a=0,c=e.endTime-e.startTime,u=e.samples?.length?c/e.samples.length:0;for(let d of e.nodes)(d.callFrame.url==="<script>"||s.has(d.id))&&(s.add(d.id),d.children?.forEach(m=>s.add(m))),s.has(d.id)?(Pl(d,i),d.callFrame.url==="<script>"&&!d.callFrame.functionName&&!d.callFrame.lineNumber&&!d.callFrame.columnNumber&&(d.callFrame.url=r??"",d.callFrame.functionName="(top-level app code)"),a+=Math.round((d.hitCount??0)*u*1e3)/1e3):Cl(d);return i.destroy(),{profile:e,totalTimeMs:c/1e3,totalScriptTimeMs:a/1e3}}function Pl(e,t){let r=t.originalPositionFor({line:e.callFrame.lineNumber+1,column:e.callFrame.columnNumber+1});e.callFrame.url=r.source||e.callFrame.url,e.callFrame.functionName=r.name||e.callFrame.functionName,e.callFrame.lineNumber=r.line?r.line-1:e.callFrame.lineNumber,e.callFrame.columnNumber=r.column??e.callFrame.columnNumber}function Cl(e){Object.assign(e,{children:[],callFrame:{functionName:"(profiler)",scriptId:"0",url:"",lineNumber:-1,columnNumber:-1}})}var Ri="startup.cpuprofile",Dr=class e extends D{static descriptionWithMarkdown="Builds the app and runs the resulting code to profile the server startup time, watching for changes. This command can be used to [debug slow app startup times](https://shopify.dev/docs/custom-storefronts/hydrogen/debugging/cpu-startup) that cause failed deployments in Oxygen.\n\n The profiling results are written to a `.cpuprofile` file that can be viewed with certain tools such as [Flame Chart Visualizer for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-js-profile-flame).";static description="Builds and profiles the server startup time the app.";static flags={...b.path,...b.entry,output:Ai.Flags.string({description:`Specify a path to generate the profile file. Defaults to "${Ri}".`,default:Ri,required:!1})};async run(){let{flags:t}=await this.parse(e),r=t.path?C(t.path):process.cwd(),{close:o}=await Tl({...U(t),directory:r,output:C(r,t.output)});He(async()=>{await o()})}};async function Tl({directory:e,entry:t,output:r}){process.env.NODE_ENV||(process.env.NODE_ENV="production"),it({workerReload:!1});let{buildPath:o,buildPathWorkerFile:n}=Se(e);$(`\u23F3\uFE0F Starting profiler for CPU startup... Profile will be written to:
`+L.dim(r));let i=0,s,a=await $i(e),c={onServerBuildStart(){i>0&&process.stdout.write(Wt.eraseLines(4)),$(`
#${++i} Building and profiling...`)},async onServerBuildFinish(){let{profile:f,totalScriptTimeMs:p}=await a.run(n,s);process.stdout.write(Wt.eraseLines(2)),$(`#${i} Total time: ${p.toLocaleString()} ms
${L.dim(r)}`),await J(r,JSON.stringify(f,null,2)),$(`
Waiting for changes...`)}};if(await rt(e))throw new E(xe);let d=await pe(e).catch(()=>null);n=d?.serverOutFile??x(o,"server","index.js"),s=d?.remixConfig.serverEntryPoint??"";let m=await Je({entry:t,directory:e,watch:!0,sourcemap:!0,disableRouteWarning:!0,lockfileCheck:!1,bundleStats:!1,...c,onServerBuildStart(){return i===0&&process.stdout.write(Wt.eraseLines(1)),c.onServerBuildStart()}});return{async close(){await Promise.allSettled([m.close(),a.close()])}}}l();var ae=Q(me(),1);l();l();import Fi from"fs";import ji,{dirname as Il}from"path";import{fileURLToPath as Dl}from"url";var Or={assetsDirDefault:"dist/client/",buildCommandDefault:"npm build",verificationDurationDefault:180,maxUploadAttempts:3,maxResumabeUploadAttempts:9,workerDirDefault:"dist/worker/"};function Pe(e){if(Ol(e)){if(e.statusCode===401)throw new E("You are not authorized to perform this action. Please check your deployment token.");if(e.statusCode===429)throw new E("You've made too many requests. Please try again later")}if(e instanceof E&&e.message.includes("503"))throw new E("The server is currently unavailable. Please try again later.")}var ue=(e=>(e.OxygenNamespaceHandle="X-Oxygen-Namespace-Handle",e))(ue||{});function Ol(e){return typeof e=="object"&&e!==null&&"statusCode"in e}function $t(e){let t;if(e)t=ji.join(e,"package.json");else{let o=Dl(import.meta.url),n=Il(o);t=ji.join(n,"../../package.json")}if(!Fi.existsSync(t))return{};let r=Fi.readFileSync(t,"utf8");return JSON.parse(r)}function Ao(e){process.stderr.write(`${e}
`)}var ct=375;function Fo(e){try{let t=Buffer.from(e,"base64").toString("utf-8"),r=JSON.parse(t);return Mi(r)}catch{throw new Error("Error processing deployment token. Please check your token and try again.")}}function Ni(e){if(!e)return;let t=Number(e);if(isNaN(t))throw new E("Invalid duration format. Please specify the duration in hours (e.g., '10').");if(t>12||t<1)throw new E("Invalid duration length. Please specify the duration (in hours) between 1 to 12 hours.");return t}async function Li({config:e,performedBuild:t=!1}){let{rootPath:r,workerDir:o,assetsDir:n,skipBuild:i,workerOnly:s}=e,a={root:r};(i||t)&&(a.worker=x(r,o),s||(a.assets=x(r,n)));for(let u of Object.keys(a))await _l(a[u],u);if(!/^https:\/\/(?:[\w-]+\.)*[\w-]+|^https:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/.test(e.deploymentUrl))throw new Error(`Invalid deployment service URL: ${e.deploymentUrl}`)}async function _l(e,t){if(!await G(e))throw t==="assets"&&B('Use the "workerOnly" flag to perform a worker-only deployment.',Ao),new Error(`Path not found: ${e}`)}function Mi(e){return typeof e=="object"?Object.keys(e).reduce((t,r)=>{let o=r.replace(/([-_][a-z])/gi,n=>n.toUpperCase().replace("-","").replace("_",""));if(e[r]===void 0)throw new Error(`Invalid token: ${r} is undefined`);return t[o]=Mi(e[r]),t},{}):e}l();var _r=Q(tl(),1);var Hi;function $l(e){if(e)return;if(_r.default._client)return _r.default;let r={apiKey:"21fd37fe87ead4b9c5a8eed90752b455",autoDetectErrors:!0,appVersion:$t().version,endpoints:{notify:"https://error-analytics-production.shopifysvc.com",sessions:"https://error-analytics-sessions-production.shopifysvc.com"},logger:null};return _r.default.start(r)}function Ui(e){Hi=$l(e)}function dt(){return Hi}function Bi(e,t){if(!t)return e;let r=o=>o.replace(new RegExp(t,"g"),"***");if(e instanceof Error){let o=Object.create(Object.getPrototypeOf(e));return Object.assign(o,e,{message:r(e.message),stack:e.stack?r(e.stack):void 0}),o}return r(e)}l();var re=(e=>(e.BuildTime="build_time",e.NumFilesRequested="num_files_requested",e.NumFilesUploaded="num_files_uploaded",e.TotalSizeUploaded="total_size_uploaded",e.TotalSizeRequested="total_size_requested",e.TotalTime="total_time",e.UploadTime="upload_time",e.DeploymentCompletedTime="deployment_completed_time",e.DeploymentRoutableTime="deployment_routable_time",e))(re||{}),$r=class{metrics={};metricPrefix="oxygen.cli";defaultTags;exportUrl;constructor(t){let{version:r}=$t(),{version:o}=$t(`${t.rootPath}/node_modules/@shopify/hydrogen`);this.defaultTags={ci_provider:t.ciProvider,cli_version:`oxygen-cli@${r||"unknown"}`,hydrogen_version:o||"unknown"},this.exportUrl="https://metrics.myshopify.dev"}add(t,r,o={}){let n={value:r,tags:o};this.metrics[t]?this.metrics[t].push(n):this.metrics[t]=[n]}formatTags(t){return Object.entries(t).map(([r,o])=>`${r}:${o}`)}async export(){let t=Object.entries(this.metrics).map(([r,o])=>{let n=`${this.metricPrefix}.${r}`;return o.map(({value:i,tags:s})=>({name:n,type:"gauge",value:i,tags:this.formatTags({...s,...this.defaultTags})}))}).flat();try{await ie(this.exportUrl,{method:"POST",body:JSON.stringify({events:t})})}catch(r){let o=dt();o&&(r instanceof Error||typeof r=="string")&&o.notify(r)}}};l();l();var Vi=`
mutation BuildInitiate($environment: EnvironmentSelectorInput, $labels: [String!]) {
buildInitiate(environment: $environment, labels: $labels) {
build {
id
assetPath
}
userErrors {
message
}
}
}
`;async function Gi(e){let{config:t,logger:r,environment:o,labels:n=[]}=e,i={environment:o,labels:n};try{let s=await fe({query:Vi,api:"Oxygen",url:`${t.deploymentUrl}/api/v2/admin/graphql`,token:t.deploymentToken.accessToken,variables:i,addedHeaders:{[ue.OxygenNamespaceHandle]:t.deploymentToken.namespace}});if(s.buildInitiate.userErrors.length>=1)throw new E(`Failed to create build. ${s.buildInitiate.userErrors[0]?.message}`);return Fe(`Build initiated successfully with id ${s.buildInitiate.build.id}.`,r),s.buildInitiate}catch(s){throw Pe(s),s}}l();l();var qi=`
mutation BuildCancel($buildId: ID!, $reason: String!) {
buildCancel(id: $buildId, reason: $reason) {
build {
id
}
userErrors {
message
}
}
}
`;async function Wi(e){let{config:t,buildId:r,reason:o,logger:n}=e,i={buildId:r,reason:o};try{let s=await fe({query:qi,api:"Oxygen",url:`${t.deploymentUrl}/api/v2/admin/graphql`,token:t.deploymentToken.accessToken,addedHeaders:{[ue.OxygenNamespaceHandle]:t.deploymentToken.namespace},variables:i});if(s.buildCancel.userErrors.length>=1)throw new E(`Failed to cancel build: ${s.buildCancel.userErrors[0]?.message}`);return $(`Build with id ${r} cancelled.`,n),s.buildCancel}catch(s){throw Pe(s),s}}l();l();var Rr=(e=>(e.Worker="WORKER",e.Asset="ASSET",e))(Rr||{}),ut=class extends Error{},Qe=class extends Error{};async function zi(e,t){let r=x(e.rootPath,e.workerDir),o=await St(`${r}/**`),n=Yi({files:o,basePath:r,type:Rr.Worker,filter:Al});if(!e.workerOnly){let s=x(e.rootPath,e.assetsDir),a=await St(`${s}/**`);n=[...n,...Yi({files:a,basePath:s,type:Rr.Asset,filter:Fl})]}t?.add(re.NumFilesRequested,n.length);let i=n.reduce((s,a)=>s+a.fileSize,0)/1024;return t?.add(re.TotalSizeRequested,i),n}function Rl(e){let t=cn(e);return fn(t)}function Yi(e){let{files:t,basePath:r,type:o,filter:n}=e,i=[];return t.forEach(s=>{let a=ne(r,s);n&&!n(a)||i.push({filePath:a,fileSize:un(s),mimeType:Pn(s),fileType:o,fileHash:Rl(s)})}),i}function Al(e){let t=["oxygen.json"],r=[".js.map",".mjs.map",".map",".js",".mjs"],n=`^(${["index"].join("|")})(${r.join("|")})$`;return new RegExp(n).test(e.toLowerCase())||t.includes(e)}function Fl(e){let r=`(${[".map"].join("|")})$`;return!new RegExp(r).test(e.toLowerCase())}l();l();var Ji=`
mutation DeploymentInitiate($buildId: ID, $environment: EnvironmentSelectorInput, $labels: [String!], $files: [FileInput!]!) {
deploymentInitiate(buildId: $buildId, environment: $environment, labels: $labels, files: $files) {
deployment {
id
}
deploymentTargets {
filePath
fileSize
uploadUrl
fileType
parameters {
name
value
}
}
deploymentConfiguration {
timeoutInSeconds
}
userErrors {
message
}
}
}
`;async function Qi(e){let{config:t,input:r,logger:o}=e,n={buildId:r.buildId,environment:r.environment,files:r.manifest,labels:r.labels};try{let i=await fe({query:Ji,api:"Oxygen",url:`${t.deploymentUrl}/api/v2/admin/graphql`,token:t.deploymentToken.accessToken,variables:n,addedHeaders:{[ue.OxygenNamespaceHandle]:t.deploymentToken.namespace}});if(i.deploymentInitiate.userErrors.length>=1)throw new E(`Failed to create deployment. ${i.deploymentInitiate.userErrors[0]?.message}`);return Fe(`Deployment initiated, ${i.deploymentInitiate.deploymentTargets.length} files to upload.`,o),i.deploymentInitiate}catch(i){throw Pe(i),i}}l();l();var Ki=`
mutation DeploymentComplete($deploymentId: ID!, $generateAuthBypassToken: Boolean, $authBypassTokenDuration: Int, $environmentVariables: [EnvironmentVariableInput!]) {
deploymentComplete(id: $deploymentId, generateAuthBypassToken: $generateAuthBypassToken, authBypassTokenDuration: $authBypassTokenDuration, environmentVariables: $environmentVariables) {
deployment {
id
url
}
authBypassToken
userErrors {
message
}
}
}
`;async function Xi(e,t){let r={deploymentId:t,generateAuthBypassToken:e.generateAuthBypassToken};if(e.generateAuthBypassToken)r.authBypassTokenDuration=Ni(e.authBypassTokenDuration);else if(e.authBypassTokenDuration)throw new E("authBypassTokenDuration is set but generateAuthBypassToken is not enabled");e.overriddenEnvironmentVariables&&(r.environmentVariables=e.overriddenEnvironmentVariables);try{let o=await fe({query:Ki,api:"Oxygen",url:`${e.deploymentUrl}/api/v2/admin/graphql`,token:e.deploymentToken.accessToken,variables:r,addedHeaders:{[ue.OxygenNamespace