giget 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/_chunks/giget.mjs +3 -16
- package/dist/_chunks/libs/@isaacs/fs-minipass.mjs +527 -1
- package/dist/_chunks/libs/chownr.mjs +48 -1
- package/dist/_chunks/libs/citty.mjs +263 -5
- package/dist/_chunks/libs/minizlib.mjs +261 -1
- package/dist/_chunks/libs/nypm.mjs +677 -2
- package/dist/_chunks/libs/tar.mjs +2102 -3
- package/dist/_chunks/rolldown-runtime.mjs +6 -14
- package/dist/cli.mjs +4 -14
- package/dist/index.mjs +1 -2
- package/package.json +21 -21
|
@@ -1,2 +1,677 @@
|
|
|
1
|
-
import{t as __exportAll}from"../rolldown-runtime.mjs";import"node:module";import{readFile}from"node:fs/promises";import{existsSync}from"node:fs";import{PassThrough}from"node:stream";import{spawn}from"node:child_process";import{createRequire}from"module";import{delimiter,dirname,join,normalize,resolve}from"node:path";import{cwd}from"node:process";import c from"node:readline";const _DRIVE_LETTER_START_RE=/^[A-Za-z]:\//;function normalizeWindowsPath(e=``){return e&&e.replace(/\\/g,`/`).replace(_DRIVE_LETTER_START_RE,e=>e.toUpperCase())}const _UNC_REGEX=/^[/\\]{2}/,_IS_ABSOLUTE_RE=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,_DRIVE_LETTER_RE=/^[A-Za-z]:$/,_ROOT_FOLDER_RE=/^\/([A-Za-z]:)?$/,normalize$1=function(e){if(e.length===0)return`.`;e=normalizeWindowsPath(e);let r=e.match(_UNC_REGEX),i=isAbsolute(e),a=e[e.length-1]===`/`;return e=normalizeString(e,!i),e.length===0?i?`/`:a?`./`:`.`:(a&&(e+=`/`),_DRIVE_LETTER_RE.test(e)&&(e+=`/`),r?i?`//${e}`:`//./${e}`:i&&!isAbsolute(e)?`/${e}`:e)},join$1=function(...e){let r=``;for(let i of e)if(i)if(r.length>0){let e=r[r.length-1]===`/`,a=i[0]===`/`;e&&a?r+=i.slice(1):r+=e||a?i:`/${i}`}else r+=i;return normalize$1(r)};function cwd$1(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const resolve$1=function(...e){e=e.map(e=>normalizeWindowsPath(e));let r=``,i=!1;for(let a=e.length-1;a>=-1&&!i;a--){let o=a>=0?e[a]:cwd$1();!o||o.length===0||(r=`${o}/${r}`,i=isAbsolute(o))}return r=normalizeString(r,!i),i&&!isAbsolute(r)?`/${r}`:r.length>0?r:`.`};function normalizeString(e,r){let i=``,a=0,o=-1,s=0,L=null;for(let J=0;J<=e.length;++J){if(J<e.length)L=e[J];else if(L===`/`)break;else L=`/`;if(L===`/`){if(!(o===J-1||s===1))if(s===2){if(i.length<2||a!==2||i[i.length-1]!==`.`||i[i.length-2]!==`.`){if(i.length>2){let e=i.lastIndexOf(`/`);e===-1?(i=``,a=0):(i=i.slice(0,e),a=i.length-1-i.lastIndexOf(`/`)),o=J,s=0;continue}else if(i.length>0){i=``,a=0,o=J,s=0;continue}}r&&(i+=i.length>0?`/..`:`..`,a=2)}else i.length>0?i+=`/${e.slice(o+1,J)}`:i=e.slice(o+1,J),a=J-o-1;o=J,s=0}else L===`.`&&s!==-1?++s:s=-1}return i}const isAbsolute=function(e){return _IS_ABSOLUTE_RE.test(e)},relative=function(e,r){let i=resolve$1(e).replace(_ROOT_FOLDER_RE,`$1`).split(`/`),a=resolve$1(r).replace(_ROOT_FOLDER_RE,`$1`).split(`/`);if(a[0][1]===`:`&&i[0][1]===`:`&&i[0]!==a[0])return a.join(`/`);let o=[...i];for(let e of o){if(a[0]!==e)break;i.shift(),a.shift()}return[...i.map(()=>`..`),...a].join(`/`)},dirname$1=function(e){let r=normalizeWindowsPath(e).replace(/\/$/,``).split(`/`).slice(0,-1);return r.length===1&&_DRIVE_LETTER_RE.test(r[0])&&(r[0]+=`/`),r.join(`/`)||(isAbsolute(e)?`/`:`.`)},basename$1=function(e,r){let i=normalizeWindowsPath(e).split(`/`),a=``;for(let e=i.length-1;e>=0;e--){let r=i[e];if(r){a=r;break}}return r&&a.endsWith(r)?a.slice(0,-r.length):a};var l=Object.create,u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,p=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,h=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),g=(e,r,i,a)=>{if(r&&typeof r==`object`||typeof r==`function`)for(var o=f(r),s=0,L=o.length,J;s<L;s++)J=o[s],!m.call(e,J)&&J!==i&&u(e,J,{get:(e=>r[e]).bind(null,J),enumerable:!(a=d(r,J))||a.enumerable});return e},_=(e,r,i)=>(i=e==null?{}:l(p(e)),g(r||!e||!e.__esModule?u(i,`default`,{value:e,enumerable:!0}):i,e)),v=createRequire(import.meta.url);const y=/^path$/i,b={key:`PATH`,value:``};function x(e){for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r)||!y.test(r))continue;let i=e[r];return i?{key:r,value:i}:b}return b}function S(e,r){let i=r.value.split(delimiter),a=e,o;do i.push(resolve(a,`node_modules`,`.bin`)),o=a,a=dirname(a);while(a!==o);return{key:r.key,value:i.join(delimiter)}}function C(e,r){let i={...process.env,...r},a=S(e,x(i));return i[a.key]=a.value,i}const w=e=>{let r=e.length,i=new PassThrough,o=()=>{--r===0&&i.emit(`end`)};for(let r of e)r.pipe(i,{end:!1}),r.on(`end`,o);return i};var T=h((e,r)=>{r.exports=s,s.sync=L;var i=v(`fs`);function a(e,r){var i=r.pathExt===void 0?process.env.PATHEXT:r.pathExt;if(!i||(i=i.split(`;`),i.indexOf(``)!==-1))return!0;for(var a=0;a<i.length;a++){var o=i[a].toLowerCase();if(o&&e.substr(-o.length).toLowerCase()===o)return!0}return!1}function o(e,r,i){return!e.isSymbolicLink()&&!e.isFile()?!1:a(r,i)}function s(e,r,a){i.stat(e,function(i,s){a(i,i?!1:o(s,e,r))})}function L(e,r){return o(i.statSync(e),e,r)}}),E=h((e,r)=>{r.exports=a,a.sync=o;var i=v(`fs`);function a(e,r,a){i.stat(e,function(e,i){a(e,e?!1:s(i,r))})}function o(e,r){return s(i.statSync(e),r)}function s(e,r){return e.isFile()&&L(e,r)}function L(e,r){var i=e.mode,a=e.uid,o=e.gid,s=r.uid===void 0?process.getuid&&process.getuid():r.uid,L=r.gid===void 0?process.getgid&&process.getgid():r.gid,J=64,Y=8,X=1,Z=J|Y;return i&X||i&Y&&o===L||i&J&&a===s||i&Z&&s===0}}),D=h((e,r)=>{v(`fs`);var i=process.platform===`win32`||global.TESTING_WINDOWS?T():E();r.exports=a,a.sync=o;function a(e,r,o){if(typeof r==`function`&&(o=r,r={}),!o){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(i,o){a(e,r||{},function(e,r){e?o(e):i(r)})})}i(e,r||{},function(e,i){e&&(e.code===`EACCES`||r&&r.ignoreErrors)&&(e=null,i=!1),o(e,i)})}function o(e,r){try{return i.sync(e,r||{})}catch(e){if(r&&r.ignoreErrors||e.code===`EACCES`)return!1;throw e}}}),O=h((e,r)=>{let i=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,a=v(`path`),o=i?`;`:`:`,s=D(),L=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),J=(e,r)=>{let a=r.colon||o,s=e.match(/\//)||i&&e.match(/\\/)?[``]:[...i?[process.cwd()]:[],...(r.path||process.env.PATH||``).split(a)],L=i?r.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,J=i?L.split(a):[``];return i&&e.indexOf(`.`)!==-1&&J[0]!==``&&J.unshift(``),{pathEnv:s,pathExt:J,pathExtExe:L}},Y=(e,r,i)=>{typeof r==`function`&&(i=r,r={}),r||={};let{pathEnv:o,pathExt:Y,pathExtExe:X}=J(e,r),Z=[],Q=i=>new Promise((s,J)=>{if(i===o.length)return r.all&&Z.length?s(Z):J(L(e));let Y=o[i],X=/^".*"$/.test(Y)?Y.slice(1,-1):Y,Q=a.join(X,e);s($(!X&&/^\.[\\\/]/.test(e)?e.slice(0,2)+Q:Q,i,0))}),$=(e,i,a)=>new Promise((o,L)=>{if(a===Y.length)return o(Q(i+1));let J=Y[a];s(e+J,{pathExt:X},(s,L)=>{if(!s&&L)if(r.all)Z.push(e+J);else return o(e+J);return o($(e,i,a+1))})});return i?Q(0).then(e=>i(null,e),i):Q(0)};r.exports=Y,Y.sync=(e,r)=>{r||={};let{pathEnv:i,pathExt:o,pathExtExe:Y}=J(e,r),X=[];for(let L=0;L<i.length;L++){let J=i[L],Z=/^".*"$/.test(J)?J.slice(1,-1):J,Q=a.join(Z,e),$=!Z&&/^\.[\\\/]/.test(e)?e.slice(0,2)+Q:Q;for(let e=0;e<o.length;e++){let i=$+o[e];try{if(s.sync(i,{pathExt:Y}))if(r.all)X.push(i);else return i}catch{}}}if(r.all&&X.length)return X;if(r.nothrow)return null;throw L(e)}}),k=h((e,r)=>{let i=(e={})=>{let r=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(r).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};r.exports=i,r.exports.default=i}),A=h((e,r)=>{let i=v(`path`),a=O(),o=k();function s(e,r){let s=e.options.env||process.env,L=process.cwd(),J=e.options.cwd!=null,Y=J&&process.chdir!==void 0&&!process.chdir.disabled;if(Y)try{process.chdir(e.options.cwd)}catch{}let X;try{X=a.sync(e.command,{path:s[o({env:s})],pathExt:r?i.delimiter:void 0})}catch{}finally{Y&&process.chdir(L)}return X&&=i.resolve(J?e.options.cwd:``,X),X}function L(e){return s(e)||s(e,!0)}r.exports=L}),j=h((e,r)=>{let i=/([()\][%!^"`<>&|;, *?])/g;function a(e){return e=e.replace(i,`^$1`),e}function o(e,r){return e=`${e}`,e=e.replace(/(\\*)"/g,`$1$1\\"`),e=e.replace(/(\\*)$/,`$1$1`),e=`"${e}"`,e=e.replace(i,`^$1`),r&&(e=e.replace(i,`^$1`)),e}r.exports.command=a,r.exports.argument=o}),M=h((e,r)=>{r.exports=/^#!(.*)/}),N=h((e,r)=>{let i=M();r.exports=(e=``)=>{let r=e.match(i);if(!r)return null;let[a,o]=r[0].replace(/#! ?/,``).split(` `),s=a.split(`/`).pop();return s===`env`?o:o?`${s} ${o}`:s}}),P=h((e,r)=>{let i=v(`fs`),a=N();function o(e){let r=Buffer.alloc(150),o;try{o=i.openSync(e,`r`),i.readSync(o,r,0,150,0),i.closeSync(o)}catch{}return a(r.toString())}r.exports=o}),F=h((e,r)=>{let i=v(`path`),a=A(),o=j(),s=P(),L=process.platform===`win32`,J=/\.(?:com|exe)$/i,Y=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function X(e){e.file=a(e);let r=e.file&&s(e.file);return r?(e.args.unshift(e.file),e.command=r,a(e)):e.file}function Z(e){if(!L)return e;let r=X(e),a=!J.test(r);if(e.options.forceShell||a){let a=Y.test(r);e.command=i.normalize(e.command),e.command=o.command(e.command),e.args=e.args.map(e=>o.argument(e,a)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function Q(e,r,i){r&&!Array.isArray(r)&&(i=r,r=null),r=r?r.slice(0):[],i=Object.assign({},i);let a={command:e,args:r,options:i,file:void 0,original:{command:e,args:r}};return i.shell?a:Z(a)}r.exports=Q}),I=h((e,r)=>{let i=process.platform===`win32`;function a(e,r){return Object.assign(Error(`${r} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${r} ${e.command}`,path:e.command,spawnargs:e.args})}function o(e,r){if(!i)return;let a=e.emit;e.emit=function(i,o){if(i===`exit`){let i=s(o,r,`spawn`);if(i)return a.call(e,`error`,i)}return a.apply(e,arguments)}}function s(e,r){return i&&e===1&&!r.file?a(r.original,`spawn`):null}function L(e,r){return i&&e===1&&!r.file?a(r.original,`spawnSync`):null}r.exports={hookChildProcess:o,verifyENOENT:s,verifyENOENTSync:L,notFoundError:a}}),R=_(h((e,r)=>{let i=v(`child_process`),a=F(),o=I();function s(e,r,s){let L=a(e,r,s),J=i.spawn(L.command,L.args,L.options);return o.hookChildProcess(J,L),J}function L(e,r,s){let L=a(e,r,s),J=i.spawnSync(L.command,L.args,L.options);return J.error=J.error||o.verifyENOENTSync(J.status,L),J}r.exports=s,r.exports.spawn=s,r.exports.sync=L,r.exports._parse=a,r.exports._enoent=o})(),1),z=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,r){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=r}};const B={timeout:void 0,persist:!1},V={windowsHide:!0};function H(e,r){return{command:normalize(e),args:r??[]}}function U(e){let r=new AbortController;for(let i of e){if(i.aborted)return r.abort(),i;i.addEventListener(`abort`,()=>{r.abort(i.reason)},{signal:r.signal})}return r.signal}async function W(e){let r=``;for await(let i of e)r+=i.toString();return r}var G=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,r,i){this._options={...B,...i},this._command=e,this._args=r??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,r,i){return q(e,r,{...i,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let r=[];this._streamErr&&r.push(this._streamErr),this._streamOut&&r.push(this._streamOut);let i=w(r),a=c.createInterface({input:i});for await(let e of a)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new z(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[r,i]=await Promise.all([this._streamOut?W(this._streamOut):``,this._streamErr?W(this._streamErr):``]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let a={stderr:i,stdout:r,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new z(this,a);return a}then(e,r){return this._waitForOutput().then(e,r)}_streamOut;_streamErr;spawn(){let e=cwd(),r=this._options,i={...V,...r.nodeOptions},a=[];this._resetState(),r.timeout!==void 0&&a.push(AbortSignal.timeout(r.timeout)),r.signal!==void 0&&a.push(r.signal),r.persist===!0&&(i.detached=!0),a.length>0&&(i.signal=U(a)),i.env=C(e,i.env);let{command:s,args:L}=H(this._command,this._args),J=(0,R._parse)(s,L,i),Y=spawn(J.command,J.args,J.options);if(Y.stderr&&(this._streamErr=Y.stderr),Y.stdout&&(this._streamOut=Y.stdout),this._process=Y,Y.once(`error`,this._onError),Y.once(`close`,this._onClose),r.stdin!==void 0&&Y.stdin&&r.stdin.process){let{stdout:e}=r.stdin.process;e&&e.pipe(Y.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const K=(e,r,i)=>{let a=new G(e,r,i);return a.spawn(),a},q=K;var dist_exports=__exportAll({detectPackageManager:()=>detectPackageManager,installDependencies:()=>installDependencies,packageManagers:()=>packageManagers});async function findup(e,r,i={}){let a=normalize$1(e).split(`/`);for(;a.length>0;){let e=await r(a.join(`/`)||`/`);if(e||!i.includeParentDirs)return e;a.pop()}}function cached(e){let r;return()=>(r===void 0&&(r=e().then(e=>(r=e,r))),r)}const hasCorepack=cached(async()=>{if(globalThis.process?.versions?.webcontainer)return!1;try{let{exitCode:e}=await K(`corepack`,[`--version`]);return e===0}catch{return!1}});async function executeCommand(e,r,i={}){let a=e!==`npm`&&e!==`bun`&&e!==`deno`&&i.corepack!==!1&&await hasCorepack()?[`corepack`,[e,...r]]:[e,r],{exitCode:o,stdout:s,stderr:L}=await K(a[0],a[1],{nodeOptions:{cwd:resolve$1(i.cwd||process.cwd()),env:i.env,stdio:i.silent?`pipe`:`inherit`}});if(o!==0)throw Error(`\`${a.flat().join(` `)}\` failed.${i.silent?[``,s,L].join(`
|
|
2
|
-
|
|
1
|
+
import { t as __exportAll } from "../rolldown-runtime.mjs";
|
|
2
|
+
import "node:module";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { PassThrough } from "node:stream";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
import { delimiter, dirname, join, normalize, resolve } from "node:path";
|
|
9
|
+
import { cwd } from "node:process";
|
|
10
|
+
import c from "node:readline";
|
|
11
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
12
|
+
function normalizeWindowsPath(e = ``) {
|
|
13
|
+
return e && e.replace(/\\/g, `/`).replace(_DRIVE_LETTER_START_RE, (e) => e.toUpperCase());
|
|
14
|
+
}
|
|
15
|
+
const _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/, normalize$1 = function(e) {
|
|
16
|
+
if (e.length === 0) return `.`;
|
|
17
|
+
e = normalizeWindowsPath(e);
|
|
18
|
+
let t = e.match(_UNC_REGEX), n = isAbsolute(e), r = e[e.length - 1] === `/`;
|
|
19
|
+
return e = normalizeString(e, !n), e.length === 0 ? n ? `/` : r ? `./` : `.` : (r && (e += `/`), _DRIVE_LETTER_RE.test(e) && (e += `/`), t ? n ? `//${e}` : `//./${e}` : n && !isAbsolute(e) ? `/${e}` : e);
|
|
20
|
+
}, join$1 = function(...e) {
|
|
21
|
+
let t = ``;
|
|
22
|
+
for (let n of e) if (n) if (t.length > 0) {
|
|
23
|
+
let e = t[t.length - 1] === `/`, r = n[0] === `/`;
|
|
24
|
+
e && r ? t += n.slice(1) : t += e || r ? n : `/${n}`;
|
|
25
|
+
} else t += n;
|
|
26
|
+
return normalize$1(t);
|
|
27
|
+
};
|
|
28
|
+
function cwd$1() {
|
|
29
|
+
return typeof process < `u` && typeof process.cwd == `function` ? process.cwd().replace(/\\/g, `/`) : `/`;
|
|
30
|
+
}
|
|
31
|
+
const resolve$1 = function(...e) {
|
|
32
|
+
e = e.map((e) => normalizeWindowsPath(e));
|
|
33
|
+
let t = ``, n = !1;
|
|
34
|
+
for (let r = e.length - 1; r >= -1 && !n; r--) {
|
|
35
|
+
let i = r >= 0 ? e[r] : cwd$1();
|
|
36
|
+
!i || i.length === 0 || (t = `${i}/${t}`, n = isAbsolute(i));
|
|
37
|
+
}
|
|
38
|
+
return t = normalizeString(t, !n), n && !isAbsolute(t) ? `/${t}` : t.length > 0 ? t : `.`;
|
|
39
|
+
};
|
|
40
|
+
function normalizeString(e, t) {
|
|
41
|
+
let n = ``, r = 0, i = -1, a = 0, o = null;
|
|
42
|
+
for (let s = 0; s <= e.length; ++s) {
|
|
43
|
+
if (s < e.length) o = e[s];
|
|
44
|
+
else if (o === `/`) break;
|
|
45
|
+
else o = `/`;
|
|
46
|
+
if (o === `/`) {
|
|
47
|
+
if (!(i === s - 1 || a === 1)) if (a === 2) {
|
|
48
|
+
if (n.length < 2 || r !== 2 || n[n.length - 1] !== `.` || n[n.length - 2] !== `.`) {
|
|
49
|
+
if (n.length > 2) {
|
|
50
|
+
let e = n.lastIndexOf(`/`);
|
|
51
|
+
e === -1 ? (n = ``, r = 0) : (n = n.slice(0, e), r = n.length - 1 - n.lastIndexOf(`/`)), i = s, a = 0;
|
|
52
|
+
continue;
|
|
53
|
+
} else if (n.length > 0) {
|
|
54
|
+
n = ``, r = 0, i = s, a = 0;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
t && (n += n.length > 0 ? `/..` : `..`, r = 2);
|
|
59
|
+
} else n.length > 0 ? n += `/${e.slice(i + 1, s)}` : n = e.slice(i + 1, s), r = s - i - 1;
|
|
60
|
+
i = s, a = 0;
|
|
61
|
+
} else o === `.` && a !== -1 ? ++a : a = -1;
|
|
62
|
+
}
|
|
63
|
+
return n;
|
|
64
|
+
}
|
|
65
|
+
const isAbsolute = function(e) {
|
|
66
|
+
return _IS_ABSOLUTE_RE.test(e);
|
|
67
|
+
}, relative = function(e, t) {
|
|
68
|
+
let n = resolve$1(e).replace(_ROOT_FOLDER_RE, `$1`).split(`/`), r = resolve$1(t).replace(_ROOT_FOLDER_RE, `$1`).split(`/`);
|
|
69
|
+
if (r[0][1] === `:` && n[0][1] === `:` && n[0] !== r[0]) return r.join(`/`);
|
|
70
|
+
let i = [...n];
|
|
71
|
+
for (let e of i) {
|
|
72
|
+
if (r[0] !== e) break;
|
|
73
|
+
n.shift(), r.shift();
|
|
74
|
+
}
|
|
75
|
+
return [...n.map(() => `..`), ...r].join(`/`);
|
|
76
|
+
}, dirname$1 = function(e) {
|
|
77
|
+
let t = normalizeWindowsPath(e).replace(/\/$/, ``).split(`/`).slice(0, -1);
|
|
78
|
+
return t.length === 1 && _DRIVE_LETTER_RE.test(t[0]) && (t[0] += `/`), t.join(`/`) || (isAbsolute(e) ? `/` : `.`);
|
|
79
|
+
}, basename$1 = function(e, t) {
|
|
80
|
+
let n = normalizeWindowsPath(e).split(`/`), r = ``;
|
|
81
|
+
for (let e = n.length - 1; e >= 0; e--) {
|
|
82
|
+
let t = n[e];
|
|
83
|
+
if (t) {
|
|
84
|
+
r = t;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return t && r.endsWith(t) ? r.slice(0, -t.length) : r;
|
|
89
|
+
};
|
|
90
|
+
var l = Object.create, u = Object.defineProperty, d = Object.getOwnPropertyDescriptor, f = Object.getOwnPropertyNames, p = Object.getPrototypeOf, m = Object.prototype.hasOwnProperty, h = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), g = (e, t, n, r) => {
|
|
91
|
+
if (t && typeof t == `object` || typeof t == `function`) for (var i = f(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !m.call(e, s) && s !== n && u(e, s, {
|
|
92
|
+
get: ((e) => t[e]).bind(null, s),
|
|
93
|
+
enumerable: !(r = d(t, s)) || r.enumerable
|
|
94
|
+
});
|
|
95
|
+
return e;
|
|
96
|
+
}, _ = (e, t, n) => (n = e == null ? {} : l(p(e)), g(t || !e || !e.__esModule ? u(n, `default`, {
|
|
97
|
+
value: e,
|
|
98
|
+
enumerable: !0
|
|
99
|
+
}) : n, e)), v = createRequire(import.meta.url);
|
|
100
|
+
const y = /^path$/i, b = {
|
|
101
|
+
key: `PATH`,
|
|
102
|
+
value: ``
|
|
103
|
+
};
|
|
104
|
+
function x(e) {
|
|
105
|
+
for (let t in e) {
|
|
106
|
+
if (!Object.prototype.hasOwnProperty.call(e, t) || !y.test(t)) continue;
|
|
107
|
+
let n = e[t];
|
|
108
|
+
return n ? {
|
|
109
|
+
key: t,
|
|
110
|
+
value: n
|
|
111
|
+
} : b;
|
|
112
|
+
}
|
|
113
|
+
return b;
|
|
114
|
+
}
|
|
115
|
+
function S(e, t) {
|
|
116
|
+
let n = t.value.split(delimiter), r = e, i;
|
|
117
|
+
do
|
|
118
|
+
n.push(resolve(r, `node_modules`, `.bin`)), i = r, r = dirname(r);
|
|
119
|
+
while (r !== i);
|
|
120
|
+
return {
|
|
121
|
+
key: t.key,
|
|
122
|
+
value: n.join(delimiter)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function C(e, t) {
|
|
126
|
+
let n = {
|
|
127
|
+
...process.env,
|
|
128
|
+
...t
|
|
129
|
+
}, r = S(e, x(n));
|
|
130
|
+
return n[r.key] = r.value, n;
|
|
131
|
+
}
|
|
132
|
+
const w = (e) => {
|
|
133
|
+
let t = e.length, n = new PassThrough(), i = () => {
|
|
134
|
+
--t === 0 && n.emit(`end`);
|
|
135
|
+
};
|
|
136
|
+
for (let t of e) t.pipe(n, { end: !1 }), t.on(`end`, i);
|
|
137
|
+
return n;
|
|
138
|
+
};
|
|
139
|
+
var T = h((e, t) => {
|
|
140
|
+
t.exports = a, a.sync = o;
|
|
141
|
+
var n = v(`fs`);
|
|
142
|
+
function r(e, t) {
|
|
143
|
+
var n = t.pathExt === void 0 ? process.env.PATHEXT : t.pathExt;
|
|
144
|
+
if (!n || (n = n.split(`;`), n.indexOf(``) !== -1)) return !0;
|
|
145
|
+
for (var r = 0; r < n.length; r++) {
|
|
146
|
+
var i = n[r].toLowerCase();
|
|
147
|
+
if (i && e.substr(-i.length).toLowerCase() === i) return !0;
|
|
148
|
+
}
|
|
149
|
+
return !1;
|
|
150
|
+
}
|
|
151
|
+
function i(e, t, n) {
|
|
152
|
+
return !e.isSymbolicLink() && !e.isFile() ? !1 : r(t, n);
|
|
153
|
+
}
|
|
154
|
+
function a(e, t, r) {
|
|
155
|
+
n.stat(e, function(n, a) {
|
|
156
|
+
r(n, n ? !1 : i(a, e, t));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function o(e, t) {
|
|
160
|
+
return i(n.statSync(e), e, t);
|
|
161
|
+
}
|
|
162
|
+
}), E = h((e, t) => {
|
|
163
|
+
t.exports = r, r.sync = i;
|
|
164
|
+
var n = v(`fs`);
|
|
165
|
+
function r(e, t, r) {
|
|
166
|
+
n.stat(e, function(e, n) {
|
|
167
|
+
r(e, e ? !1 : a(n, t));
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function i(e, t) {
|
|
171
|
+
return a(n.statSync(e), t);
|
|
172
|
+
}
|
|
173
|
+
function a(e, t) {
|
|
174
|
+
return e.isFile() && o(e, t);
|
|
175
|
+
}
|
|
176
|
+
function o(e, t) {
|
|
177
|
+
var n = e.mode, r = e.uid, i = e.gid, a = t.uid === void 0 ? process.getuid && process.getuid() : t.uid, o = t.gid === void 0 ? process.getgid && process.getgid() : t.gid, s = 64, L = 8, J = 1, Y = s | L;
|
|
178
|
+
return n & J || n & L && i === o || n & s && r === a || n & Y && a === 0;
|
|
179
|
+
}
|
|
180
|
+
}), D = h((e, t) => {
|
|
181
|
+
v(`fs`);
|
|
182
|
+
var n = process.platform === `win32` || global.TESTING_WINDOWS ? T() : E();
|
|
183
|
+
t.exports = r, r.sync = i;
|
|
184
|
+
function r(e, t, i) {
|
|
185
|
+
if (typeof t == `function` && (i = t, t = {}), !i) {
|
|
186
|
+
if (typeof Promise != `function`) throw TypeError(`callback not provided`);
|
|
187
|
+
return new Promise(function(n, i) {
|
|
188
|
+
r(e, t || {}, function(e, t) {
|
|
189
|
+
e ? i(e) : n(t);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
n(e, t || {}, function(e, n) {
|
|
194
|
+
e && (e.code === `EACCES` || t && t.ignoreErrors) && (e = null, n = !1), i(e, n);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function i(e, t) {
|
|
198
|
+
try {
|
|
199
|
+
return n.sync(e, t || {});
|
|
200
|
+
} catch (e) {
|
|
201
|
+
if (t && t.ignoreErrors || e.code === `EACCES`) return !1;
|
|
202
|
+
throw e;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}), O = h((e, t) => {
|
|
206
|
+
let n = process.platform === `win32` || process.env.OSTYPE === `cygwin` || process.env.OSTYPE === `msys`, r = v(`path`), i = n ? `;` : `:`, a = D(), o = (e) => Object.assign(Error(`not found: ${e}`), { code: `ENOENT` }), s = (e, t) => {
|
|
207
|
+
let r = t.colon || i, a = e.match(/\//) || n && e.match(/\\/) ? [``] : [...n ? [process.cwd()] : [], ...(t.path || process.env.PATH || ``).split(r)], o = n ? t.pathExt || process.env.PATHEXT || `.EXE;.CMD;.BAT;.COM` : ``, s = n ? o.split(r) : [``];
|
|
208
|
+
return n && e.indexOf(`.`) !== -1 && s[0] !== `` && s.unshift(``), {
|
|
209
|
+
pathEnv: a,
|
|
210
|
+
pathExt: s,
|
|
211
|
+
pathExtExe: o
|
|
212
|
+
};
|
|
213
|
+
}, L = (e, t, n) => {
|
|
214
|
+
typeof t == `function` && (n = t, t = {}), t ||= {};
|
|
215
|
+
let { pathEnv: i, pathExt: L, pathExtExe: J } = s(e, t), Y = [], X = (n) => new Promise((a, s) => {
|
|
216
|
+
if (n === i.length) return t.all && Y.length ? a(Y) : s(o(e));
|
|
217
|
+
let L = i[n], J = /^".*"$/.test(L) ? L.slice(1, -1) : L, X = r.join(J, e);
|
|
218
|
+
a(Z(!J && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + X : X, n, 0));
|
|
219
|
+
}), Z = (e, n, r) => new Promise((i, o) => {
|
|
220
|
+
if (r === L.length) return i(X(n + 1));
|
|
221
|
+
let s = L[r];
|
|
222
|
+
a(e + s, { pathExt: J }, (a, o) => {
|
|
223
|
+
if (!a && o) if (t.all) Y.push(e + s);
|
|
224
|
+
else return i(e + s);
|
|
225
|
+
return i(Z(e, n, r + 1));
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
return n ? X(0).then((e) => n(null, e), n) : X(0);
|
|
229
|
+
};
|
|
230
|
+
t.exports = L, L.sync = (e, t) => {
|
|
231
|
+
t ||= {};
|
|
232
|
+
let { pathEnv: n, pathExt: i, pathExtExe: L } = s(e, t), J = [];
|
|
233
|
+
for (let o = 0; o < n.length; o++) {
|
|
234
|
+
let s = n[o], Y = /^".*"$/.test(s) ? s.slice(1, -1) : s, X = r.join(Y, e), Z = !Y && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + X : X;
|
|
235
|
+
for (let e = 0; e < i.length; e++) {
|
|
236
|
+
let n = Z + i[e];
|
|
237
|
+
try {
|
|
238
|
+
if (a.sync(n, { pathExt: L })) if (t.all) J.push(n);
|
|
239
|
+
else return n;
|
|
240
|
+
} catch {}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (t.all && J.length) return J;
|
|
244
|
+
if (t.nothrow) return null;
|
|
245
|
+
throw o(e);
|
|
246
|
+
};
|
|
247
|
+
}), k = h((e, t) => {
|
|
248
|
+
let n = (e = {}) => {
|
|
249
|
+
let t = e.env || process.env;
|
|
250
|
+
return (e.platform || process.platform) === `win32` ? Object.keys(t).reverse().find((e) => e.toUpperCase() === `PATH`) || `Path` : `PATH`;
|
|
251
|
+
};
|
|
252
|
+
t.exports = n, t.exports.default = n;
|
|
253
|
+
}), A = h((e, t) => {
|
|
254
|
+
let n = v(`path`), r = O(), i = k();
|
|
255
|
+
function a(e, t) {
|
|
256
|
+
let a = e.options.env || process.env, o = process.cwd(), s = e.options.cwd != null, L = s && process.chdir !== void 0 && !process.chdir.disabled;
|
|
257
|
+
if (L) try {
|
|
258
|
+
process.chdir(e.options.cwd);
|
|
259
|
+
} catch {}
|
|
260
|
+
let J;
|
|
261
|
+
try {
|
|
262
|
+
J = r.sync(e.command, {
|
|
263
|
+
path: a[i({ env: a })],
|
|
264
|
+
pathExt: t ? n.delimiter : void 0
|
|
265
|
+
});
|
|
266
|
+
} catch {} finally {
|
|
267
|
+
L && process.chdir(o);
|
|
268
|
+
}
|
|
269
|
+
return J &&= n.resolve(s ? e.options.cwd : ``, J), J;
|
|
270
|
+
}
|
|
271
|
+
function o(e) {
|
|
272
|
+
return a(e) || a(e, !0);
|
|
273
|
+
}
|
|
274
|
+
t.exports = o;
|
|
275
|
+
}), j = h((e, t) => {
|
|
276
|
+
let n = /([()\][%!^"`<>&|;, *?])/g;
|
|
277
|
+
function r(e) {
|
|
278
|
+
return e = e.replace(n, `^$1`), e;
|
|
279
|
+
}
|
|
280
|
+
function i(e, t) {
|
|
281
|
+
return e = `${e}`, e = e.replace(/(\\*)"/g, `$1$1\\"`), e = e.replace(/(\\*)$/, `$1$1`), e = `"${e}"`, e = e.replace(n, `^$1`), t && (e = e.replace(n, `^$1`)), e;
|
|
282
|
+
}
|
|
283
|
+
t.exports.command = r, t.exports.argument = i;
|
|
284
|
+
}), M = h((e, t) => {
|
|
285
|
+
t.exports = /^#!(.*)/;
|
|
286
|
+
}), N = h((e, t) => {
|
|
287
|
+
let n = M();
|
|
288
|
+
t.exports = (e = ``) => {
|
|
289
|
+
let t = e.match(n);
|
|
290
|
+
if (!t) return null;
|
|
291
|
+
let [r, i] = t[0].replace(/#! ?/, ``).split(` `), a = r.split(`/`).pop();
|
|
292
|
+
return a === `env` ? i : i ? `${a} ${i}` : a;
|
|
293
|
+
};
|
|
294
|
+
}), P = h((e, t) => {
|
|
295
|
+
let n = v(`fs`), r = N();
|
|
296
|
+
function i(e) {
|
|
297
|
+
let t = Buffer.alloc(150), i;
|
|
298
|
+
try {
|
|
299
|
+
i = n.openSync(e, `r`), n.readSync(i, t, 0, 150, 0), n.closeSync(i);
|
|
300
|
+
} catch {}
|
|
301
|
+
return r(t.toString());
|
|
302
|
+
}
|
|
303
|
+
t.exports = i;
|
|
304
|
+
}), F = h((e, t) => {
|
|
305
|
+
let n = v(`path`), r = A(), i = j(), a = P(), o = process.platform === `win32`, s = /\.(?:com|exe)$/i, L = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
306
|
+
function J(e) {
|
|
307
|
+
e.file = r(e);
|
|
308
|
+
let t = e.file && a(e.file);
|
|
309
|
+
return t ? (e.args.unshift(e.file), e.command = t, r(e)) : e.file;
|
|
310
|
+
}
|
|
311
|
+
function Y(e) {
|
|
312
|
+
if (!o) return e;
|
|
313
|
+
let t = J(e), r = !s.test(t);
|
|
314
|
+
if (e.options.forceShell || r) {
|
|
315
|
+
let r = L.test(t);
|
|
316
|
+
e.command = n.normalize(e.command), e.command = i.command(e.command), e.args = e.args.map((e) => i.argument(e, r)), e.args = [
|
|
317
|
+
`/d`,
|
|
318
|
+
`/s`,
|
|
319
|
+
`/c`,
|
|
320
|
+
`"${[e.command].concat(e.args).join(` `)}"`
|
|
321
|
+
], e.command = process.env.comspec || `cmd.exe`, e.options.windowsVerbatimArguments = !0;
|
|
322
|
+
}
|
|
323
|
+
return e;
|
|
324
|
+
}
|
|
325
|
+
function X(e, t, n) {
|
|
326
|
+
t && !Array.isArray(t) && (n = t, t = null), t = t ? t.slice(0) : [], n = Object.assign({}, n);
|
|
327
|
+
let r = {
|
|
328
|
+
command: e,
|
|
329
|
+
args: t,
|
|
330
|
+
options: n,
|
|
331
|
+
file: void 0,
|
|
332
|
+
original: {
|
|
333
|
+
command: e,
|
|
334
|
+
args: t
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
return n.shell ? r : Y(r);
|
|
338
|
+
}
|
|
339
|
+
t.exports = X;
|
|
340
|
+
}), I = h((e, t) => {
|
|
341
|
+
let n = process.platform === `win32`;
|
|
342
|
+
function r(e, t) {
|
|
343
|
+
return Object.assign(Error(`${t} ${e.command} ENOENT`), {
|
|
344
|
+
code: `ENOENT`,
|
|
345
|
+
errno: `ENOENT`,
|
|
346
|
+
syscall: `${t} ${e.command}`,
|
|
347
|
+
path: e.command,
|
|
348
|
+
spawnargs: e.args
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function i(e, t) {
|
|
352
|
+
if (!n) return;
|
|
353
|
+
let r = e.emit;
|
|
354
|
+
e.emit = function(n, i) {
|
|
355
|
+
if (n === `exit`) {
|
|
356
|
+
let n = a(i, t, `spawn`);
|
|
357
|
+
if (n) return r.call(e, `error`, n);
|
|
358
|
+
}
|
|
359
|
+
return r.apply(e, arguments);
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function a(e, t) {
|
|
363
|
+
return n && e === 1 && !t.file ? r(t.original, `spawn`) : null;
|
|
364
|
+
}
|
|
365
|
+
function o(e, t) {
|
|
366
|
+
return n && e === 1 && !t.file ? r(t.original, `spawnSync`) : null;
|
|
367
|
+
}
|
|
368
|
+
t.exports = {
|
|
369
|
+
hookChildProcess: i,
|
|
370
|
+
verifyENOENT: a,
|
|
371
|
+
verifyENOENTSync: o,
|
|
372
|
+
notFoundError: r
|
|
373
|
+
};
|
|
374
|
+
}), R = _(h((e, t) => {
|
|
375
|
+
let n = v(`child_process`), r = F(), i = I();
|
|
376
|
+
function a(e, t, a) {
|
|
377
|
+
let o = r(e, t, a), s = n.spawn(o.command, o.args, o.options);
|
|
378
|
+
return i.hookChildProcess(s, o), s;
|
|
379
|
+
}
|
|
380
|
+
function o(e, t, a) {
|
|
381
|
+
let o = r(e, t, a), s = n.spawnSync(o.command, o.args, o.options);
|
|
382
|
+
return s.error = s.error || i.verifyENOENTSync(s.status, o), s;
|
|
383
|
+
}
|
|
384
|
+
t.exports = a, t.exports.spawn = a, t.exports.sync = o, t.exports._parse = r, t.exports._enoent = i;
|
|
385
|
+
})(), 1), z = class extends Error {
|
|
386
|
+
result;
|
|
387
|
+
output;
|
|
388
|
+
get exitCode() {
|
|
389
|
+
if (this.result.exitCode !== null) return this.result.exitCode;
|
|
390
|
+
}
|
|
391
|
+
constructor(e, t) {
|
|
392
|
+
super(`Process exited with non-zero status (${e.exitCode})`), this.result = e, this.output = t;
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const B = {
|
|
396
|
+
timeout: void 0,
|
|
397
|
+
persist: !1
|
|
398
|
+
}, V = { windowsHide: !0 };
|
|
399
|
+
function H(e, t) {
|
|
400
|
+
return {
|
|
401
|
+
command: normalize(e),
|
|
402
|
+
args: t ?? []
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function U(e) {
|
|
406
|
+
let t = new AbortController();
|
|
407
|
+
for (let n of e) {
|
|
408
|
+
if (n.aborted) return t.abort(), n;
|
|
409
|
+
n.addEventListener(`abort`, () => {
|
|
410
|
+
t.abort(n.reason);
|
|
411
|
+
}, { signal: t.signal });
|
|
412
|
+
}
|
|
413
|
+
return t.signal;
|
|
414
|
+
}
|
|
415
|
+
async function W(e) {
|
|
416
|
+
let t = ``;
|
|
417
|
+
for await (let n of e) t += n.toString();
|
|
418
|
+
return t;
|
|
419
|
+
}
|
|
420
|
+
var G = class {
|
|
421
|
+
_process;
|
|
422
|
+
_aborted = !1;
|
|
423
|
+
_options;
|
|
424
|
+
_command;
|
|
425
|
+
_args;
|
|
426
|
+
_resolveClose;
|
|
427
|
+
_processClosed;
|
|
428
|
+
_thrownError;
|
|
429
|
+
get process() {
|
|
430
|
+
return this._process;
|
|
431
|
+
}
|
|
432
|
+
get pid() {
|
|
433
|
+
return this._process?.pid;
|
|
434
|
+
}
|
|
435
|
+
get exitCode() {
|
|
436
|
+
if (this._process && this._process.exitCode !== null) return this._process.exitCode;
|
|
437
|
+
}
|
|
438
|
+
constructor(e, t, n) {
|
|
439
|
+
this._options = {
|
|
440
|
+
...B,
|
|
441
|
+
...n
|
|
442
|
+
}, this._command = e, this._args = t ?? [], this._processClosed = new Promise((e) => {
|
|
443
|
+
this._resolveClose = e;
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
kill(e) {
|
|
447
|
+
return this._process?.kill(e) === !0;
|
|
448
|
+
}
|
|
449
|
+
get aborted() {
|
|
450
|
+
return this._aborted;
|
|
451
|
+
}
|
|
452
|
+
get killed() {
|
|
453
|
+
return this._process?.killed === !0;
|
|
454
|
+
}
|
|
455
|
+
pipe(e, t, n) {
|
|
456
|
+
return q(e, t, {
|
|
457
|
+
...n,
|
|
458
|
+
stdin: this
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
async *[Symbol.asyncIterator]() {
|
|
462
|
+
let e = this._process;
|
|
463
|
+
if (!e) return;
|
|
464
|
+
let t = [];
|
|
465
|
+
this._streamErr && t.push(this._streamErr), this._streamOut && t.push(this._streamOut);
|
|
466
|
+
let n = w(t), r = c.createInterface({ input: n });
|
|
467
|
+
for await (let e of r) yield e.toString();
|
|
468
|
+
if (await this._processClosed, e.removeAllListeners(), this._thrownError) throw this._thrownError;
|
|
469
|
+
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this);
|
|
470
|
+
}
|
|
471
|
+
async _waitForOutput() {
|
|
472
|
+
let e = this._process;
|
|
473
|
+
if (!e) throw Error(`No process was started`);
|
|
474
|
+
let [t, n] = await Promise.all([this._streamOut ? W(this._streamOut) : ``, this._streamErr ? W(this._streamErr) : ``]);
|
|
475
|
+
if (await this._processClosed, this._options?.stdin && await this._options.stdin, e.removeAllListeners(), this._thrownError) throw this._thrownError;
|
|
476
|
+
let r = {
|
|
477
|
+
stderr: n,
|
|
478
|
+
stdout: t,
|
|
479
|
+
exitCode: this.exitCode
|
|
480
|
+
};
|
|
481
|
+
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this, r);
|
|
482
|
+
return r;
|
|
483
|
+
}
|
|
484
|
+
then(e, t) {
|
|
485
|
+
return this._waitForOutput().then(e, t);
|
|
486
|
+
}
|
|
487
|
+
_streamOut;
|
|
488
|
+
_streamErr;
|
|
489
|
+
spawn() {
|
|
490
|
+
let e = cwd(), t = this._options, n = {
|
|
491
|
+
...V,
|
|
492
|
+
...t.nodeOptions
|
|
493
|
+
}, r = [];
|
|
494
|
+
this._resetState(), t.timeout !== void 0 && r.push(AbortSignal.timeout(t.timeout)), t.signal !== void 0 && r.push(t.signal), t.persist === !0 && (n.detached = !0), r.length > 0 && (n.signal = U(r)), n.env = C(e, n.env);
|
|
495
|
+
let { command: a, args: o } = H(this._command, this._args), s = (0, R._parse)(a, o, n), L = spawn(s.command, s.args, s.options);
|
|
496
|
+
if (L.stderr && (this._streamErr = L.stderr), L.stdout && (this._streamOut = L.stdout), this._process = L, L.once(`error`, this._onError), L.once(`close`, this._onClose), t.stdin !== void 0 && L.stdin && t.stdin.process) {
|
|
497
|
+
let { stdout: e } = t.stdin.process;
|
|
498
|
+
e && e.pipe(L.stdin);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
_resetState() {
|
|
502
|
+
this._aborted = !1, this._processClosed = new Promise((e) => {
|
|
503
|
+
this._resolveClose = e;
|
|
504
|
+
}), this._thrownError = void 0;
|
|
505
|
+
}
|
|
506
|
+
_onError = (e) => {
|
|
507
|
+
if (e.name === `AbortError` && (!(e.cause instanceof Error) || e.cause.name !== `TimeoutError`)) {
|
|
508
|
+
this._aborted = !0;
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
this._thrownError = e;
|
|
512
|
+
};
|
|
513
|
+
_onClose = () => {
|
|
514
|
+
this._resolveClose && this._resolveClose();
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
const K = (e, t, n) => {
|
|
518
|
+
let r = new G(e, t, n);
|
|
519
|
+
return r.spawn(), r;
|
|
520
|
+
}, q = K;
|
|
521
|
+
var dist_exports = __exportAll({
|
|
522
|
+
detectPackageManager: () => detectPackageManager,
|
|
523
|
+
installDependencies: () => installDependencies,
|
|
524
|
+
packageManagers: () => packageManagers
|
|
525
|
+
});
|
|
526
|
+
async function findup(e, t, n = {}) {
|
|
527
|
+
let r = normalize$1(e).split(`/`);
|
|
528
|
+
for (; r.length > 0;) {
|
|
529
|
+
let e = await t(r.join(`/`) || `/`);
|
|
530
|
+
if (e || !n.includeParentDirs) return e;
|
|
531
|
+
r.pop();
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
function cached(e) {
|
|
535
|
+
let t;
|
|
536
|
+
return () => (t === void 0 && (t = e().then((e) => (t = e, t))), t);
|
|
537
|
+
}
|
|
538
|
+
const hasCorepack = cached(async () => {
|
|
539
|
+
if (globalThis.process?.versions?.webcontainer) return !1;
|
|
540
|
+
try {
|
|
541
|
+
let { exitCode: e } = await K(`corepack`, [`--version`]);
|
|
542
|
+
return e === 0;
|
|
543
|
+
} catch {
|
|
544
|
+
return !1;
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
async function executeCommand(e, t, n = {}) {
|
|
548
|
+
let r = e !== `npm` && e !== `bun` && e !== `deno` && n.corepack !== !1 && await hasCorepack() ? [`corepack`, [e, ...t]] : [e, t], { exitCode: i, stdout: a, stderr: o } = await K(r[0], r[1], { nodeOptions: {
|
|
549
|
+
cwd: resolve$1(n.cwd || process.cwd()),
|
|
550
|
+
env: n.env,
|
|
551
|
+
stdio: n.silent ? `pipe` : `inherit`
|
|
552
|
+
} });
|
|
553
|
+
if (i !== 0) throw Error(`\`${r.flat().join(` `)}\` failed.${n.silent ? [
|
|
554
|
+
``,
|
|
555
|
+
a,
|
|
556
|
+
o
|
|
557
|
+
].join(`
|
|
558
|
+
`) : ``}`);
|
|
559
|
+
}
|
|
560
|
+
async function resolveOperationOptions(e = {}) {
|
|
561
|
+
let t = e.cwd || process.cwd(), n = {
|
|
562
|
+
...process.env,
|
|
563
|
+
...e.env
|
|
564
|
+
}, r = (typeof e.packageManager == `string` ? packageManagers.find((t) => t.name === e.packageManager) : e.packageManager) || await detectPackageManager(e.cwd || process.cwd());
|
|
565
|
+
if (!r) throw Error(`No package manager auto-detected.`);
|
|
566
|
+
return {
|
|
567
|
+
cwd: t,
|
|
568
|
+
env: n,
|
|
569
|
+
silent: e.silent ?? !1,
|
|
570
|
+
packageManager: r,
|
|
571
|
+
dev: e.dev ?? !1,
|
|
572
|
+
workspace: e.workspace,
|
|
573
|
+
global: e.global ?? !1,
|
|
574
|
+
dry: e.dry ?? !1,
|
|
575
|
+
corepack: e.corepack ?? !0
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
function parsePackageManagerField(e) {
|
|
579
|
+
let [t, n] = (e || ``).split(`@`), [r, i] = n?.split(`+`) || [];
|
|
580
|
+
if (t && t !== `-` && /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t)) return {
|
|
581
|
+
name: t,
|
|
582
|
+
version: r,
|
|
583
|
+
buildMeta: i
|
|
584
|
+
};
|
|
585
|
+
let a = (t || ``).replace(/\W+/g, ``);
|
|
586
|
+
return {
|
|
587
|
+
name: a,
|
|
588
|
+
version: r,
|
|
589
|
+
buildMeta: i,
|
|
590
|
+
warnings: [`Abnormal characters found in \`packageManager\` field, sanitizing from \`${t}\` to \`${a}\``]
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
const packageManagers = [
|
|
594
|
+
{
|
|
595
|
+
name: `npm`,
|
|
596
|
+
command: `npm`,
|
|
597
|
+
lockFile: `package-lock.json`
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
name: `pnpm`,
|
|
601
|
+
command: `pnpm`,
|
|
602
|
+
lockFile: `pnpm-lock.yaml`,
|
|
603
|
+
files: [`pnpm-workspace.yaml`]
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
name: `bun`,
|
|
607
|
+
command: `bun`,
|
|
608
|
+
lockFile: [`bun.lockb`, `bun.lock`]
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
name: `yarn`,
|
|
612
|
+
command: `yarn`,
|
|
613
|
+
lockFile: `yarn.lock`,
|
|
614
|
+
files: [`.yarnrc.yml`]
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
name: `deno`,
|
|
618
|
+
command: `deno`,
|
|
619
|
+
lockFile: `deno.lock`,
|
|
620
|
+
files: [`deno.json`]
|
|
621
|
+
}
|
|
622
|
+
];
|
|
623
|
+
async function detectPackageManager(e, r = {}) {
|
|
624
|
+
let i = await findup(resolve$1(e || `.`), async (e) => {
|
|
625
|
+
if (!r.ignorePackageJSON) {
|
|
626
|
+
let r = join$1(e, `package.json`);
|
|
627
|
+
if (existsSync(r)) {
|
|
628
|
+
let e = JSON.parse(await readFile(r, `utf8`));
|
|
629
|
+
if (e?.packageManager) {
|
|
630
|
+
let { name: t, version: n = `0.0.0`, buildMeta: r, warnings: i } = parsePackageManagerField(e.packageManager);
|
|
631
|
+
if (t) {
|
|
632
|
+
let e = n.split(`.`)[0], a = packageManagers.find((n) => n.name === t && n.majorVersion === e) || packageManagers.find((e) => e.name === t);
|
|
633
|
+
return {
|
|
634
|
+
name: t,
|
|
635
|
+
command: t,
|
|
636
|
+
version: n,
|
|
637
|
+
majorVersion: e,
|
|
638
|
+
buildMeta: r,
|
|
639
|
+
warnings: i,
|
|
640
|
+
files: a?.files,
|
|
641
|
+
lockFile: a?.lockFile
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if (existsSync(join$1(e, `deno.json`))) return packageManagers.find((e) => e.name === `deno`);
|
|
647
|
+
}
|
|
648
|
+
if (!r.ignoreLockFile) {
|
|
649
|
+
for (let t of packageManagers) if ([t.lockFile, t.files].flat().filter(Boolean).some((t) => existsSync(resolve$1(e, t)))) return { ...t };
|
|
650
|
+
}
|
|
651
|
+
}, { includeParentDirs: r.includeParentDirs ?? !0 });
|
|
652
|
+
if (!i && !r.ignoreArgv) {
|
|
653
|
+
let e = process.argv[1];
|
|
654
|
+
if (e) {
|
|
655
|
+
for (let t of packageManagers) if (RegExp(`[/\\\\]\\.?${t.command}`).test(e)) return t;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return i;
|
|
659
|
+
}
|
|
660
|
+
async function installDependencies(e = {}) {
|
|
661
|
+
let t = await resolveOperationOptions(e), n = e.frozenLockFile ? {
|
|
662
|
+
npm: [`ci`],
|
|
663
|
+
yarn: [`install`, `--immutable`],
|
|
664
|
+
bun: [`install`, `--frozen-lockfile`],
|
|
665
|
+
pnpm: [`install`, `--frozen-lockfile`],
|
|
666
|
+
deno: [`install`, `--frozen`]
|
|
667
|
+
}[t.packageManager.name] : [`install`];
|
|
668
|
+
return e.ignoreWorkspace && t.packageManager.name === `pnpm` && n.push(`--ignore-workspace`), t.dry || await executeCommand(t.packageManager.command, n, {
|
|
669
|
+
cwd: t.cwd,
|
|
670
|
+
silent: t.silent,
|
|
671
|
+
corepack: t.corepack
|
|
672
|
+
}), { exec: {
|
|
673
|
+
command: t.packageManager.command,
|
|
674
|
+
args: n
|
|
675
|
+
} };
|
|
676
|
+
}
|
|
677
|
+
export { resolve$1 as a, relative as i, basename$1 as n, dirname$1 as r, dist_exports as t };
|