@shopify/cli
Version:
A CLI tool to build for the Shopify platform
3 lines (2 loc) • 3.59 kB
JavaScript
import{g as c}from"./chunk-VPRTJUIN.js";c();c();c();var j=/^[A-Za-z]:\//;function f(e=""){return e&&e.replace(/\\/g,"/").replace(j,n=>n.toUpperCase())}var z=/^[/\\]{2}/,A=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,E=/^[A-Za-z]:$/,v=/^\/([A-Za-z]:)?$/,$="/",R=":",m=function(e){if(e.length===0)return".";e=f(e);let n=e.match(z),t=l(e),s=e[e.length-1]==="/";return e=P(e,!t),e.length===0?t?"/":s?"./":".":(s&&(e+="/"),E.test(e)&&(e+="/"),n?t?`//${e}`:`//./${e}`:t&&!l(e)?`/${e}`:e)},x=function(...e){if(e.length===0)return".";let n;for(let t of e)t&&t.length>0&&(n===void 0?n=t:n+=`/${t}`);return n===void 0?".":m(n.replace(/\/\/+/g,"/"))};function S(){return typeof process<"u"&&typeof process.cwd=="function"?process.cwd().replace(/\\/g,"/"):"/"}var u=function(...e){e=e.map(s=>f(s));let n="",t=!1;for(let s=e.length-1;s>=-1&&!t;s--){let r=s>=0?e[s]:S();!r||r.length===0||(n=`${r}/${n}`,t=l(r))}return n=P(n,!t),t&&!l(n)?`/${n}`:n.length>0?n:"."};function P(e,n){let t="",s=0,r=-1,o=0,a=null;for(let i=0;i<=e.length;++i){if(i<e.length)a=e[i];else{if(a==="/")break;a="/"}if(a==="/"){if(!(r===i-1||o===1))if(o===2){if(t.length<2||s!==2||t[t.length-1]!=="."||t[t.length-2]!=="."){if(t.length>2){let b=t.lastIndexOf("/");b===-1?(t="",s=0):(t=t.slice(0,b),s=t.length-1-t.lastIndexOf("/")),r=i,o=0;continue}else if(t.length>0){t="",s=0,r=i,o=0;continue}}n&&(t+=t.length>0?"/..":"..",s=2)}else t.length>0?t+=`/${e.slice(r+1,i)}`:t=e.slice(r+1,i),s=i-r-1;r=i,o=0}else a==="."&&o!==-1?++o:o=-1}return t}var l=function(e){return A.test(e)};var T=/.(\.[^./]+)$/,h=function(e){let n=T.exec(f(e));return n&&n[1]||""},p=function(e,n){let t=u(e).replace(v,"$1").split("/"),s=u(n).replace(v,"$1").split("/");if(s[0][1]===":"&&t[0][1]===":"&&t[0]!==s[0])return s.join("/");let r=[...t];for(let o of r){if(s[0]!==o)break;t.shift(),s.shift()}return[...t.map(()=>".."),...s].join("/")},d=function(e){let n=f(e).replace(/\/$/,"").split("/").slice(0,-1);return n.length===1&&E.test(n[0])&&(n[0]+="/"),n.join("/")||(l(e)?"/":".")};var g=function(e,n){let t=f(e).split("/").pop();return n&&t.endsWith(n)?t.slice(0,-n.length):t},_=function(e){let n=f(e).split("/").shift()||"/",t=g(e),s=h(t);return{root:n,dir:d(e),base:t,ext:s,name:t.slice(0,t.length-s.length)}};import{fileURLToPath as I}from"url";function X(...e){return x(...e)}function G(e){return m(e)}function J(...e){return u(...e)}function M(e,n){return p(e,n)}function w(e){return l(e)}function D(e){return d(e)}function q(e,n){return g(e,n)}function H(e){return h(e)}function K(e){return _(e)}function N(e,n){let t=e.split(/\/+|\\+/),s=n.split(/\/+|\\+/),r=0;for(;r<t.length&&r<s.length&&t[r]===s[r];)r++;return r>1?t.slice(0,r).join("/"):"/"}function Q(e,n=O()){let t=N(e,n),s=p(n,e),r=s.split("/").filter(o=>o==="..").length;return t==="/"||s===""||r>2?e:s}function Y(e,n){let t=p(e,n);return!t.startsWith("..")&&!w(t)}function ee(e){return D(I(e))}function O(){return m(process.env.INIT_CWD||process.cwd())}function te(e=process.argv){let n=e.indexOf("--path");if(n===-1)return e.find(r=>r.startsWith("--path="))?.split("=")[1];let t=e[n+1];if(!(!t||t.startsWith("-")))return t}function ne(e=process.argv){return e.includes("--json")||e.includes("-j")}function se(e,n){let t=e.replace(/\\/g,"/").split("/"),s=[],r=!1;for(let a of t)a===".."?(r=!0,s.pop()):a!=="."&&s.push(a);let o=s.join("/");return r&&n(`Warning: path '${e}' contains '..' traversal \u2014 sanitized to '${o||"."}'
`),o}export{$ as a,R as b,x as c,X as d,G as e,J as f,M as g,w as h,D as i,q as j,H as k,K as l,N as m,Q as n,Y as o,ee as p,O as q,te as r,ne as s,se as t};