@shopify/cli
Version:
A CLI tool to build for the Shopify platform
2 lines (1 loc) • 3.84 kB
JavaScript
import{a as _,b as M}from"./chunk-EENHXSWU.js";import{a as h,c as A,g as l}from"./chunk-VPRTJUIN.js";var F=A((G,E)=>{"use strict";l();E.exports=(e,r,t)=>{let o=n=>Object.defineProperty(e,r,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){let n=t();return o(n),n},set(n){o(n)}}),e}});var I=A((N,$)=>{l();var W=h("path"),q=h("child_process"),{promises:d,constants:v}=h("fs"),p=M(),T=_(),x=F(),O=W.join(__dirname,"xdg-open"),{platform:c,arch:C}=process,z=()=>{try{return d.statSync("/run/.containerenv"),!0}catch{return!1}},w;function B(){return w===void 0&&(w=z()||T()),w}var X=(()=>{let e="/mnt/",r;return async function(){if(r)return r;let t="/etc/wsl.conf",o=!1;try{await d.access(t,v.F_OK),o=!0}catch{}if(!o)return e;let n=await d.readFile(t,{encoding:"utf8"}),a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(n);return a?(r=a.groups.mountPoint.trim(),r=r.endsWith("/")?r:`${r}/`,r):e}})(),S=async(e,r)=>{let t;for(let o of e)try{return await r(o)}catch(n){t=n}throw t},g=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return S(e.app,i=>g({...e,app:i}));let{name:r,arguments:t=[]}=e.app||{};if(t=[...t],Array.isArray(r))return S(r,i=>g({...e,app:{name:i,arguments:t}}));let o,n=[],a={};if(c==="darwin")o="open",e.wait&&n.push("--wait-apps"),e.background&&n.push("--background"),e.newInstance&&n.push("--new"),r&&n.push("-a",r);else if(c==="win32"||p&&!B()&&!r){let i=await X();o=p?`${i}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`:`${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`,n.push("-NoProfile","-NonInteractive","\u2013ExecutionPolicy","Bypass","-EncodedCommand"),p||(a.windowsVerbatimArguments=!0);let s=["Start"];e.wait&&s.push("-Wait"),r?(s.push(`"\`"${r}\`""`,"-ArgumentList"),e.target&&t.unshift(e.target)):e.target&&s.push(`"${e.target}"`),t.length>0&&(t=t.map(f=>`"\`"${f}\`""`),s.push(t.join(","))),e.target=Buffer.from(s.join(" "),"utf16le").toString("base64")}else{if(r)o=r;else{let i=!__dirname||__dirname==="/",s=!1;try{await d.access(O,v.X_OK),s=!0}catch{}o=process.versions.electron||c==="android"||i||!s?"xdg-open":O}t.length>0&&n.push(...t),e.wait||(a.stdio="ignore",a.detached=!0)}e.target&&n.push(e.target),c==="darwin"&&t.length>0&&n.push("--args",...t);let u=q.spawn(o,n,a);return e.wait?new Promise((i,s)=>{u.once("error",s),u.once("close",f=>{if(!e.allowNonzeroExitCode&&f>0){s(new Error(`Exited with code ${f}`));return}i(u)})}):(u.unref(),u)},y=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return g({...r,target:e})},k=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a `name`");let{arguments:t=[]}=r||{};if(t!=null&&!Array.isArray(t))throw new TypeError("Expected `appArguments` as Array type");return g({...r,app:{name:e,arguments:t}})};function b(e){if(typeof e=="string"||Array.isArray(e))return e;let{[C]:r}=e;if(!r)throw new Error(`${C} is not supported`);return r}function P({[c]:e},{wsl:r}){if(r&&p)return b(r);if(!e)throw new Error(`${c} is not supported`);return b(e)}var m={};x(m,"chrome",()=>P({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));x(m,"firefox",()=>P({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));x(m,"edge",()=>P({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));y.apps=m;y.openApp=k;$.exports=y});export default I();