main.cjs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. "use strict";
  2. var It = Object.create;
  3. var v = Object.defineProperty;
  4. var Lt = Object.getOwnPropertyDescriptor;
  5. var jt = Object.getOwnPropertyNames;
  6. var Ft = Object.getPrototypeOf, zt = Object.prototype.hasOwnProperty;
  7. var l = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports), Ht = (t, e) => {
  8. for (var n in e)
  9. v(t, n, { get: e[n], enumerable: !0 });
  10. }, N = (t, e, n, r) => {
  11. if (e && typeof e == "object" || typeof e == "function")
  12. for (let s of jt(e))
  13. !zt.call(t, s) && s !== n && v(t, s, { get: () => e[s], enumerable: !(r = Lt(e, s)) || r.enumerable });
  14. return t;
  15. };
  16. var q = (t, e, n) => (n = t != null ? It(Ft(t)) : {}, N(
  17. // If the importer is in node compatibility mode or this is not an ESM
  18. // file that has been converted to a CommonJS file using a Babel-
  19. // compatible transform (i.e. "__esModule" has not been set), then set
  20. // "default" to the CommonJS "module.exports" for node compatibility.
  21. e || !t || !t.__esModule ? v(n, "default", { value: t, enumerable: !0 }) : n,
  22. t
  23. )), Wt = (t) => N(v({}, "__esModule", { value: !0 }), t);
  24. // node_modules/isexe/windows.js
  25. var K = l((Pe, D) => {
  26. "use strict";
  27. D.exports = W;
  28. W.sync = Xt;
  29. var z = require("fs");
  30. function Bt(t, e) {
  31. var n = e.pathExt !== void 0 ? e.pathExt : process.env.PATHEXT;
  32. if (!n || (n = n.split(";"), n.indexOf("") !== -1))
  33. return !0;
  34. for (var r = 0; r < n.length; r++) {
  35. var s = n[r].toLowerCase();
  36. if (s && t.substr(-s.length).toLowerCase() === s)
  37. return !0;
  38. }
  39. return !1;
  40. }
  41. function H(t, e, n) {
  42. return !t.isSymbolicLink() && !t.isFile() ? !1 : Bt(e, n);
  43. }
  44. function W(t, e, n) {
  45. z.stat(t, function(r, s) {
  46. n(r, r ? !1 : H(s, t, e));
  47. });
  48. }
  49. function Xt(t, e) {
  50. return H(z.statSync(t), t, e);
  51. }
  52. });
  53. // node_modules/isexe/mode.js
  54. var U = l((Oe, G) => {
  55. "use strict";
  56. G.exports = B;
  57. B.sync = Gt;
  58. var M = require("fs");
  59. function B(t, e, n) {
  60. M.stat(t, function(r, s) {
  61. n(r, r ? !1 : X(s, e));
  62. });
  63. }
  64. function Gt(t, e) {
  65. return X(M.statSync(t), e);
  66. }
  67. function X(t, e) {
  68. return t.isFile() && Ut(t, e);
  69. }
  70. function Ut(t, e) {
  71. var n = t.mode, r = t.uid, s = t.gid, o = e.uid !== void 0 ? e.uid : process.getuid && process.getuid(), i = e.gid !== void 0 ? e.gid : process.getgid && process.getgid(), a = parseInt("100", 8), c = parseInt("010", 8), u = parseInt("001", 8), f = a | c, p = n & u || n & c && s === i || n & a && r === o || n & f && o === 0;
  72. return p;
  73. }
  74. });
  75. // node_modules/isexe/index.js
  76. var V = l((ke, Y) => {
  77. "use strict";
  78. var Se = require("fs"), b;
  79. process.platform === "win32" || global.TESTING_WINDOWS ? b = K() : b = U();
  80. Y.exports = C;
  81. C.sync = Yt;
  82. function C(t, e, n) {
  83. if (typeof e == "function" && (n = e, e = {}), !n) {
  84. if (typeof Promise != "function")
  85. throw new TypeError("callback not provided");
  86. return new Promise(function(r, s) {
  87. C(t, e || {}, function(o, i) {
  88. o ? s(o) : r(i);
  89. });
  90. });
  91. }
  92. b(t, e || {}, function(r, s) {
  93. r && (r.code === "EACCES" || e && e.ignoreErrors) && (r = null, s = !1), n(r, s);
  94. });
  95. }
  96. function Yt(t, e) {
  97. try {
  98. return b.sync(t, e || {});
  99. } catch (n) {
  100. if (e && e.ignoreErrors || n.code === "EACCES")
  101. return !1;
  102. throw n;
  103. }
  104. }
  105. });
  106. // node_modules/which/which.js
  107. var rt = l((Te, nt) => {
  108. "use strict";
  109. var g = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", J = require("path"), Vt = g ? ";" : ":", Q = V(), Z = (t) => Object.assign(new Error(`not found: ${t}`), { code: "ENOENT" }), tt = (t, e) => {
  110. let n = e.colon || Vt, r = t.match(/\//) || g && t.match(/\\/) ? [""] : [
  111. // windows always checks the cwd first
  112. ...g ? [process.cwd()] : [],
  113. ...(e.path || process.env.PATH || /* istanbul ignore next: very unusual */
  114. "").split(n)
  115. ], s = g ? e.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "", o = g ? s.split(n) : [""];
  116. return g && t.indexOf(".") !== -1 && o[0] !== "" && o.unshift(""), {
  117. pathEnv: r,
  118. pathExt: o,
  119. pathExtExe: s
  120. };
  121. }, et = (t, e, n) => {
  122. typeof e == "function" && (n = e, e = {}), e || (e = {});
  123. let { pathEnv: r, pathExt: s, pathExtExe: o } = tt(t, e), i = [], a = (u) => new Promise((f, p) => {
  124. if (u === r.length)
  125. return e.all && i.length ? f(i) : p(Z(t));
  126. let d = r[u], x = /^".*"$/.test(d) ? d.slice(1, -1) : d, m = J.join(x, t), _ = !x && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + m : m;
  127. f(c(_, u, 0));
  128. }), c = (u, f, p) => new Promise((d, x) => {
  129. if (p === s.length)
  130. return d(a(f + 1));
  131. let m = s[p];
  132. Q(u + m, { pathExt: o }, (_, qt) => {
  133. if (!_ && qt)
  134. if (e.all)
  135. i.push(u + m);
  136. else
  137. return d(u + m);
  138. return d(c(u, f, p + 1));
  139. });
  140. });
  141. return n ? a(0).then((u) => n(null, u), n) : a(0);
  142. }, Jt = (t, e) => {
  143. e = e || {};
  144. let { pathEnv: n, pathExt: r, pathExtExe: s } = tt(t, e), o = [];
  145. for (let i = 0; i < n.length; i++) {
  146. let a = n[i], c = /^".*"$/.test(a) ? a.slice(1, -1) : a, u = J.join(c, t), f = !c && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + u : u;
  147. for (let p = 0; p < r.length; p++) {
  148. let d = f + r[p];
  149. try {
  150. if (Q.sync(d, { pathExt: s }))
  151. if (e.all)
  152. o.push(d);
  153. else
  154. return d;
  155. } catch {
  156. }
  157. }
  158. }
  159. if (e.all && o.length)
  160. return o;
  161. if (e.nothrow)
  162. return null;
  163. throw Z(t);
  164. };
  165. nt.exports = et;
  166. et.sync = Jt;
  167. });
  168. // node_modules/path-key/index.js
  169. var ot = l((Ae, P) => {
  170. "use strict";
  171. var st = (t = {}) => {
  172. let e = t.env || process.env;
  173. return (t.platform || process.platform) !== "win32" ? "PATH" : Object.keys(e).reverse().find((r) => r.toUpperCase() === "PATH") || "Path";
  174. };
  175. P.exports = st;
  176. P.exports.default = st;
  177. });
  178. // node_modules/cross-spawn/lib/util/resolveCommand.js
  179. var at = l((Re, ut) => {
  180. "use strict";
  181. var it = require("path"), Qt = rt(), Zt = ot();
  182. function ct(t, e) {
  183. let n = t.options.env || process.env, r = process.cwd(), s = t.options.cwd != null, o = s && process.chdir !== void 0 && !process.chdir.disabled;
  184. if (o)
  185. try {
  186. process.chdir(t.options.cwd);
  187. } catch {
  188. }
  189. let i;
  190. try {
  191. i = Qt.sync(t.command, {
  192. path: n[Zt({ env: n })],
  193. pathExt: e ? it.delimiter : void 0
  194. });
  195. } catch {
  196. } finally {
  197. o && process.chdir(r);
  198. }
  199. return i && (i = it.resolve(s ? t.options.cwd : "", i)), i;
  200. }
  201. function te(t) {
  202. return ct(t) || ct(t, !0);
  203. }
  204. ut.exports = te;
  205. });
  206. // node_modules/cross-spawn/lib/util/escape.js
  207. var lt = l(($e, S) => {
  208. "use strict";
  209. var O = /([()\][%!^"`<>&|;, *?])/g;
  210. function ee(t) {
  211. return t = t.replace(O, "^$1"), t;
  212. }
  213. function ne(t, e) {
  214. return t = `${t}`, t = t.replace(/(\\*)"/g, '$1$1\\"'), t = t.replace(/(\\*)$/, "$1$1"), t = `"${t}"`, t = t.replace(O, "^$1"), e && (t = t.replace(O, "^$1")), t;
  215. }
  216. S.exports.command = ee;
  217. S.exports.argument = ne;
  218. });
  219. // node_modules/shebang-regex/index.js
  220. var dt = l((Ne, pt) => {
  221. "use strict";
  222. pt.exports = /^#!(.*)/;
  223. });
  224. // node_modules/shebang-command/index.js
  225. var ht = l((qe, ft) => {
  226. "use strict";
  227. var re = dt();
  228. ft.exports = (t = "") => {
  229. let e = t.match(re);
  230. if (!e)
  231. return null;
  232. let [n, r] = e[0].replace(/#! ?/, "").split(" "), s = n.split("/").pop();
  233. return s === "env" ? r : r ? `${s} ${r}` : s;
  234. };
  235. });
  236. // node_modules/cross-spawn/lib/util/readShebang.js
  237. var gt = l((Ie, mt) => {
  238. "use strict";
  239. var k = require("fs"), se = ht();
  240. function oe(t) {
  241. let n = Buffer.alloc(150), r;
  242. try {
  243. r = k.openSync(t, "r"), k.readSync(r, n, 0, 150, 0), k.closeSync(r);
  244. } catch {
  245. }
  246. return se(n.toString());
  247. }
  248. mt.exports = oe;
  249. });
  250. // node_modules/cross-spawn/lib/parse.js
  251. var vt = l((Le, xt) => {
  252. "use strict";
  253. var ie = require("path"), Et = at(), wt = lt(), ce = gt(), ue = process.platform === "win32", ae = /\.(?:com|exe)$/i, le = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
  254. function pe(t) {
  255. t.file = Et(t);
  256. let e = t.file && ce(t.file);
  257. return e ? (t.args.unshift(t.file), t.command = e, Et(t)) : t.file;
  258. }
  259. function de(t) {
  260. if (!ue)
  261. return t;
  262. let e = pe(t), n = !ae.test(e);
  263. if (t.options.forceShell || n) {
  264. let r = le.test(e);
  265. t.command = ie.normalize(t.command), t.command = wt.command(t.command), t.args = t.args.map((o) => wt.argument(o, r));
  266. let s = [t.command].concat(t.args).join(" ");
  267. t.args = ["/d", "/s", "/c", `"${s}"`], t.command = process.env.comspec || "cmd.exe", t.options.windowsVerbatimArguments = !0;
  268. }
  269. return t;
  270. }
  271. function fe(t, e, n) {
  272. e && !Array.isArray(e) && (n = e, e = null), e = e ? e.slice(0) : [], n = Object.assign({}, n);
  273. let r = {
  274. command: t,
  275. args: e,
  276. options: n,
  277. file: void 0,
  278. original: {
  279. command: t,
  280. args: e
  281. }
  282. };
  283. return n.shell ? r : de(r);
  284. }
  285. xt.exports = fe;
  286. });
  287. // node_modules/cross-spawn/lib/enoent.js
  288. var _t = l((je, yt) => {
  289. "use strict";
  290. var T = process.platform === "win32";
  291. function A(t, e) {
  292. return Object.assign(new Error(`${e} ${t.command} ENOENT`), {
  293. code: "ENOENT",
  294. errno: "ENOENT",
  295. syscall: `${e} ${t.command}`,
  296. path: t.command,
  297. spawnargs: t.args
  298. });
  299. }
  300. function he(t, e) {
  301. if (!T)
  302. return;
  303. let n = t.emit;
  304. t.emit = function(r, s) {
  305. if (r === "exit") {
  306. let o = bt(s, e, "spawn");
  307. if (o)
  308. return n.call(t, "error", o);
  309. }
  310. return n.apply(t, arguments);
  311. };
  312. }
  313. function bt(t, e) {
  314. return T && t === 1 && !e.file ? A(e.original, "spawn") : null;
  315. }
  316. function me(t, e) {
  317. return T && t === 1 && !e.file ? A(e.original, "spawnSync") : null;
  318. }
  319. yt.exports = {
  320. hookChildProcess: he,
  321. verifyENOENT: bt,
  322. verifyENOENTSync: me,
  323. notFoundError: A
  324. };
  325. });
  326. // node_modules/cross-spawn/index.js
  327. var Ot = l((Fe, E) => {
  328. "use strict";
  329. var Ct = require("child_process"), R = vt(), $ = _t();
  330. function Pt(t, e, n) {
  331. let r = R(t, e, n), s = Ct.spawn(r.command, r.args, r.options);
  332. return $.hookChildProcess(s, r), s;
  333. }
  334. function ge(t, e, n) {
  335. let r = R(t, e, n), s = Ct.spawnSync(r.command, r.args, r.options);
  336. return s.error = s.error || $.verifyENOENTSync(s.status, r), s;
  337. }
  338. E.exports = Pt;
  339. E.exports.spawn = Pt;
  340. E.exports.sync = ge;
  341. E.exports._parse = R;
  342. E.exports._enoent = $;
  343. });
  344. // src/main.ts
  345. var be = {};
  346. Ht(be, {
  347. ExecProcess: () => y,
  348. NonZeroExitError: () => w,
  349. exec: () => Nt,
  350. x: () => $t
  351. });
  352. module.exports = Wt(be);
  353. var St = require("child_process"), kt = require("path"), Tt = require("process");
  354. // src/env.ts
  355. var h = require("path"), Dt = /^path$/i, I = { key: "PATH", value: "" };
  356. function Kt(t) {
  357. for (let e in t) {
  358. if (!Object.prototype.hasOwnProperty.call(t, e) || !Dt.test(e))
  359. continue;
  360. let n = t[e];
  361. return n ? { key: e, value: n } : I;
  362. }
  363. return I;
  364. }
  365. function Mt(t, e) {
  366. let n = e.value.split(h.delimiter), r = t, s;
  367. do
  368. n.push((0, h.resolve)(r, "node_modules", ".bin")), s = r, r = (0, h.dirname)(r);
  369. while (r !== s);
  370. return { key: e.key, value: n.join(h.delimiter) };
  371. }
  372. function L(t, e) {
  373. let n = {
  374. ...process.env,
  375. ...e
  376. }, r = Mt(t, Kt(n));
  377. return n[r.key] = r.value, n;
  378. }
  379. // src/stream.ts
  380. var j = require("stream");
  381. var F = (t) => {
  382. let e = t.length, n = new j.PassThrough(), r = () => {
  383. --e === 0 && n.emit("end");
  384. };
  385. for (let s of t)
  386. s.pipe(n, { end: !1 }), s.on("end", r);
  387. return n;
  388. };
  389. // src/main.ts
  390. var At = q(require("readline"), 1), Rt = q(Ot(), 1);
  391. // src/non-zero-exit-error.ts
  392. var w = class extends Error {
  393. result;
  394. output;
  395. get exitCode() {
  396. if (this.result.exitCode !== null)
  397. return this.result.exitCode;
  398. }
  399. constructor(e, n) {
  400. super(`Process exited with non-zero status (${e.exitCode})`), this.result = e, this.output = n;
  401. }
  402. };
  403. // src/main.ts
  404. var Ee = {
  405. timeout: void 0,
  406. persist: !1
  407. }, we = {
  408. windowsHide: !0
  409. };
  410. function xe(t, e) {
  411. return {
  412. command: (0, kt.normalize)(t),
  413. args: e ?? []
  414. };
  415. }
  416. function ve(t) {
  417. let e = new AbortController();
  418. for (let n of t) {
  419. if (n.aborted)
  420. return e.abort(), n;
  421. let r = () => {
  422. e.abort(n.reason);
  423. };
  424. n.addEventListener("abort", r, {
  425. signal: e.signal
  426. });
  427. }
  428. return e.signal;
  429. }
  430. var y = class {
  431. _process;
  432. _aborted = !1;
  433. _options;
  434. _command;
  435. _args;
  436. _resolveClose;
  437. _processClosed;
  438. _thrownError;
  439. get process() {
  440. return this._process;
  441. }
  442. get pid() {
  443. return this._process?.pid;
  444. }
  445. get exitCode() {
  446. if (this._process && this._process.exitCode !== null)
  447. return this._process.exitCode;
  448. }
  449. constructor(e, n, r) {
  450. this._options = {
  451. ...Ee,
  452. ...r
  453. }, this._command = e, this._args = n ?? [], this._processClosed = new Promise((s) => {
  454. this._resolveClose = s;
  455. });
  456. }
  457. kill(e) {
  458. return this._process?.kill(e) === !0;
  459. }
  460. get aborted() {
  461. return this._aborted;
  462. }
  463. get killed() {
  464. return this._process?.killed === !0;
  465. }
  466. pipe(e, n, r) {
  467. return Nt(e, n, {
  468. ...r,
  469. stdin: this
  470. });
  471. }
  472. async *[Symbol.asyncIterator]() {
  473. let e = this._process;
  474. if (!e)
  475. return;
  476. let n = [];
  477. this._streamErr && n.push(this._streamErr), this._streamOut && n.push(this._streamOut);
  478. let r = F(n), s = At.default.createInterface({
  479. input: r
  480. });
  481. for await (let o of s)
  482. yield o.toString();
  483. if (await this._processClosed, e.removeAllListeners(), this._thrownError)
  484. throw this._thrownError;
  485. if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0)
  486. throw new w(this);
  487. }
  488. async _waitForOutput() {
  489. let e = this._process;
  490. if (!e)
  491. throw new Error("No process was started");
  492. let n = "", r = "";
  493. if (this._streamOut)
  494. for await (let o of this._streamOut)
  495. r += o.toString();
  496. if (this._streamErr)
  497. for await (let o of this._streamErr)
  498. n += o.toString();
  499. if (await this._processClosed, this._options?.stdin && await this._options.stdin, e.removeAllListeners(), this._thrownError)
  500. throw this._thrownError;
  501. let s = {
  502. stderr: n,
  503. stdout: r,
  504. exitCode: this.exitCode
  505. };
  506. if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0)
  507. throw new w(this, s);
  508. return s;
  509. }
  510. then(e, n) {
  511. return this._waitForOutput().then(e, n);
  512. }
  513. _streamOut;
  514. _streamErr;
  515. spawn() {
  516. let e = (0, Tt.cwd)(), n = this._options, r = {
  517. ...we,
  518. ...n.nodeOptions
  519. }, s = [];
  520. this._resetState(), n.timeout !== void 0 && s.push(AbortSignal.timeout(n.timeout)), n.signal !== void 0 && s.push(n.signal), n.persist === !0 && (r.detached = !0), s.length > 0 && (r.signal = ve(s)), r.env = L(e, r.env);
  521. let { command: o, args: i } = xe(this._command, this._args), a = (0, Rt._parse)(o, i, r), c = (0, St.spawn)(
  522. a.command,
  523. a.args,
  524. a.options
  525. );
  526. if (c.stderr && (this._streamErr = c.stderr), c.stdout && (this._streamOut = c.stdout), this._process = c, c.once("error", this._onError), c.once("close", this._onClose), n.stdin !== void 0 && c.stdin && n.stdin.process) {
  527. let { stdout: u } = n.stdin.process;
  528. u && u.pipe(c.stdin);
  529. }
  530. }
  531. _resetState() {
  532. this._aborted = !1, this._processClosed = new Promise((e) => {
  533. this._resolveClose = e;
  534. }), this._thrownError = void 0;
  535. }
  536. _onError = (e) => {
  537. if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
  538. this._aborted = !0;
  539. return;
  540. }
  541. this._thrownError = e;
  542. };
  543. _onClose = () => {
  544. this._resolveClose && this._resolveClose();
  545. };
  546. }, $t = (t, e, n) => {
  547. let r = new y(t, e, n);
  548. return r.spawn(), r;
  549. }, Nt = $t;
  550. // Annotate the CommonJS export names for ESM import in node:
  551. 0 && (module.exports = {
  552. ExecProcess,
  553. NonZeroExitError,
  554. exec,
  555. x
  556. });