@lousy-agents/mcp 5.8.0 → 5.8.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/dist/316.js +2961 -0
- package/dist/316.js.map +1 -0
- package/dist/511.js +1260 -0
- package/dist/511.js.map +1 -0
- package/dist/mcp-server.js +588 -707
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
- package/dist/433.js +0 -1740
- package/dist/433.js.map +0 -1
- package/dist/696.js +0 -13
- package/dist/696.js.map +0 -1
package/dist/511.js
ADDED
|
@@ -0,0 +1,1260 @@
|
|
|
1
|
+
export const __rspack_esm_id = "511";
|
|
2
|
+
export const __rspack_esm_ids = ["511"];
|
|
3
|
+
export const __webpack_modules__ = {
|
|
4
|
+
292(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
6
|
+
a: () => (y),
|
|
7
|
+
n: () => (ne),
|
|
8
|
+
r: () => (C),
|
|
9
|
+
t: () => (oe)
|
|
10
|
+
});
|
|
11
|
+
/* import */ var _rolldown_runtime_mjs__rspack_import_8 = __webpack_require__(421);
|
|
12
|
+
/* import */ var node_module__rspack_import_0 = __webpack_require__(8995);
|
|
13
|
+
/* import */ var node_fs__rspack_import_1 = __webpack_require__(3024);
|
|
14
|
+
/* import */ var node_fs_promises__rspack_import_2 = __webpack_require__(1455);
|
|
15
|
+
/* import */ var node_stream__rspack_import_3 = __webpack_require__(7075);
|
|
16
|
+
/* import */ var node_child_process__rspack_import_4 = __webpack_require__(1421);
|
|
17
|
+
/* import */ var node_path__rspack_import_5 = __webpack_require__(6760);
|
|
18
|
+
/* import */ var node_process__rspack_import_6 = __webpack_require__(1708);
|
|
19
|
+
/* import */ var node_readline__rspack_import_7 = __webpack_require__(481);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const f = /^[A-Za-z]:\//;
|
|
30
|
+
function p(e = ``) {
|
|
31
|
+
return e && e.replace(/\\/g, `/`).replace(f, (e) => e.toUpperCase());
|
|
32
|
+
}
|
|
33
|
+
const ee = /^[/\\]{2}/, te = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, m = /^[A-Za-z]:$/, h = /^\/([A-Za-z]:)?$/, g = function(e) {
|
|
34
|
+
if (e.length === 0) return `.`;
|
|
35
|
+
e = p(e);
|
|
36
|
+
let t = e.match(ee), n = x(e), r = e[e.length - 1] === `/`;
|
|
37
|
+
return e = b(e, !n), e.length === 0 ? n ? `/` : r ? `./` : `.` : (r && (e += `/`), m.test(e) && (e += `/`), t ? n ? `//${e}` : `//./${e}` : n && !x(e) ? `/${e}` : e);
|
|
38
|
+
}, _ = function(...e) {
|
|
39
|
+
let t = ``;
|
|
40
|
+
for (let n of e) if (n) if (t.length > 0) {
|
|
41
|
+
let e = t[t.length - 1] === `/`, r = n[0] === `/`;
|
|
42
|
+
e && r ? t += n.slice(1) : t += e || r ? n : `/${n}`;
|
|
43
|
+
} else t += n;
|
|
44
|
+
return g(t);
|
|
45
|
+
};
|
|
46
|
+
function v() {
|
|
47
|
+
return typeof process < `u` && typeof process.cwd == `function` ? process.cwd().replace(/\\/g, `/`) : `/`;
|
|
48
|
+
}
|
|
49
|
+
const y = function(...e) {
|
|
50
|
+
e = e.map((e) => p(e));
|
|
51
|
+
let t = ``, n = !1;
|
|
52
|
+
for (let r = e.length - 1; r >= -1 && !n; r--) {
|
|
53
|
+
let i = r >= 0 ? e[r] : v();
|
|
54
|
+
!i || i.length === 0 || (t = `${i}/${t}`, n = x(i));
|
|
55
|
+
}
|
|
56
|
+
return t = b(t, !n), n && !x(t) ? `/${t}` : t.length > 0 ? t : `.`;
|
|
57
|
+
};
|
|
58
|
+
function b(e, t) {
|
|
59
|
+
let n = ``, r = 0, i = -1, a = 0, o = null;
|
|
60
|
+
for (let s = 0; s <= e.length; ++s) {
|
|
61
|
+
if (s < e.length) o = e[s];
|
|
62
|
+
else if (o === `/`) break;
|
|
63
|
+
else o = `/`;
|
|
64
|
+
if (o === `/`) {
|
|
65
|
+
if (!(i === s - 1 || a === 1)) if (a === 2) {
|
|
66
|
+
if (n.length < 2 || r !== 2 || n[n.length - 1] !== `.` || n[n.length - 2] !== `.`) {
|
|
67
|
+
if (n.length > 2) {
|
|
68
|
+
let e = n.lastIndexOf(`/`);
|
|
69
|
+
e === -1 ? (n = ``, r = 0) : (n = n.slice(0, e), r = n.length - 1 - n.lastIndexOf(`/`)), i = s, a = 0;
|
|
70
|
+
continue;
|
|
71
|
+
} else if (n.length > 0) {
|
|
72
|
+
n = ``, r = 0, i = s, a = 0;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
t && (n += n.length > 0 ? `/..` : `..`, r = 2);
|
|
77
|
+
} else n.length > 0 ? n += `/${e.slice(i + 1, s)}` : n = e.slice(i + 1, s), r = s - i - 1;
|
|
78
|
+
i = s, a = 0;
|
|
79
|
+
} else o === `.` && a !== -1 ? ++a : a = -1;
|
|
80
|
+
}
|
|
81
|
+
return n;
|
|
82
|
+
}
|
|
83
|
+
const x = function(e) {
|
|
84
|
+
return te.test(e);
|
|
85
|
+
}, S = function(e, t) {
|
|
86
|
+
let n = y(e).replace(h, `$1`).split(`/`), r = y(t).replace(h, `$1`).split(`/`);
|
|
87
|
+
if (r[0][1] === `:` && n[0][1] === `:` && n[0] !== r[0]) return r.join(`/`);
|
|
88
|
+
let i = [...n];
|
|
89
|
+
for (let e of i) {
|
|
90
|
+
if (r[0] !== e) break;
|
|
91
|
+
n.shift(), r.shift();
|
|
92
|
+
}
|
|
93
|
+
return [...n.map(() => `..`), ...r].join(`/`);
|
|
94
|
+
}, C = function(e) {
|
|
95
|
+
let t = p(e).replace(/\/$/, ``).split(`/`).slice(0, -1);
|
|
96
|
+
return t.length === 1 && m.test(t[0]) && (t[0] += `/`), t.join(`/`) || (x(e) ? `/` : `.`);
|
|
97
|
+
}, ne = function(e, t) {
|
|
98
|
+
let n = p(e).split(`/`), r = ``;
|
|
99
|
+
for (let e = n.length - 1; e >= 0; e--) {
|
|
100
|
+
let t = n[e];
|
|
101
|
+
if (t) {
|
|
102
|
+
r = t;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return t && r.endsWith(t) ? r.slice(0, -t.length) : r;
|
|
107
|
+
};
|
|
108
|
+
globalThis.process?.platform;
|
|
109
|
+
var w = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), T = (0,node_module__rspack_import_0.createRequire)(import.meta.url);
|
|
110
|
+
const re = /^path$/i, E = {
|
|
111
|
+
key: `PATH`,
|
|
112
|
+
value: ``
|
|
113
|
+
};
|
|
114
|
+
function D(e) {
|
|
115
|
+
for (let t in e) {
|
|
116
|
+
if (!Object.prototype.hasOwnProperty.call(e, t) || !re.test(t)) continue;
|
|
117
|
+
let n = e[t];
|
|
118
|
+
return n ? {
|
|
119
|
+
key: t,
|
|
120
|
+
value: n
|
|
121
|
+
} : E;
|
|
122
|
+
}
|
|
123
|
+
return E;
|
|
124
|
+
}
|
|
125
|
+
function O(e, t) {
|
|
126
|
+
let n = t.value.split(node_path__rspack_import_5.delimiter), r = [], i = e, a;
|
|
127
|
+
do
|
|
128
|
+
r.push((0,node_path__rspack_import_5.resolve)(i, `node_modules`, `.bin`)), a = i, i = (0,node_path__rspack_import_5.dirname)(i);
|
|
129
|
+
while (i !== a);
|
|
130
|
+
let c = r.concat(n).join(node_path__rspack_import_5.delimiter);
|
|
131
|
+
return {
|
|
132
|
+
key: t.key,
|
|
133
|
+
value: c
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function k(e, t) {
|
|
137
|
+
let n = {
|
|
138
|
+
...process.env,
|
|
139
|
+
...t
|
|
140
|
+
}, r = O(e, D(n));
|
|
141
|
+
return n[r.key] = r.value, n;
|
|
142
|
+
}
|
|
143
|
+
const A = (e) => {
|
|
144
|
+
let t = e.length, n = new node_stream__rspack_import_3.PassThrough(), r = () => {
|
|
145
|
+
--t === 0 && n.emit(`end`);
|
|
146
|
+
};
|
|
147
|
+
for (let t of e) t.pipe(n, { end: !1 }), t.on(`end`, r);
|
|
148
|
+
return n;
|
|
149
|
+
};
|
|
150
|
+
var j = w(((e, t) => {
|
|
151
|
+
t.exports = a, a.sync = o;
|
|
152
|
+
var n = T(`fs`);
|
|
153
|
+
function r(e, t) {
|
|
154
|
+
var n = t.pathExt === void 0 ? process.env.PATHEXT : t.pathExt;
|
|
155
|
+
if (!n || (n = n.split(`;`), n.indexOf(``) !== -1)) return !0;
|
|
156
|
+
for (var r = 0; r < n.length; r++) {
|
|
157
|
+
var i = n[r].toLowerCase();
|
|
158
|
+
if (i && e.substr(-i.length).toLowerCase() === i) return !0;
|
|
159
|
+
}
|
|
160
|
+
return !1;
|
|
161
|
+
}
|
|
162
|
+
function i(e, t, n) {
|
|
163
|
+
return !e.isSymbolicLink() && !e.isFile() ? !1 : r(t, n);
|
|
164
|
+
}
|
|
165
|
+
function a(e, t, r) {
|
|
166
|
+
n.stat(e, function(n, a) {
|
|
167
|
+
r(n, n ? !1 : i(a, e, t));
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function o(e, t) {
|
|
171
|
+
return i(n.statSync(e), e, t);
|
|
172
|
+
}
|
|
173
|
+
})), M = w(((e, t) => {
|
|
174
|
+
t.exports = r, r.sync = i;
|
|
175
|
+
var n = T(`fs`);
|
|
176
|
+
function r(e, t, r) {
|
|
177
|
+
n.stat(e, function(e, n) {
|
|
178
|
+
r(e, e ? !1 : a(n, t));
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
function i(e, t) {
|
|
182
|
+
return a(n.statSync(e), t);
|
|
183
|
+
}
|
|
184
|
+
function a(e, t) {
|
|
185
|
+
return e.isFile() && o(e, t);
|
|
186
|
+
}
|
|
187
|
+
function o(e, t) {
|
|
188
|
+
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, c = 8, l = 1, u = s | c;
|
|
189
|
+
return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
|
|
190
|
+
}
|
|
191
|
+
})), N = w(((e, t) => {
|
|
192
|
+
T(`fs`);
|
|
193
|
+
var n = process.platform === `win32` || global.TESTING_WINDOWS ? j() : M();
|
|
194
|
+
t.exports = r, r.sync = i;
|
|
195
|
+
function r(e, t, i) {
|
|
196
|
+
if (typeof t == `function` && (i = t, t = {}), !i) {
|
|
197
|
+
if (typeof Promise != `function`) throw TypeError(`callback not provided`);
|
|
198
|
+
return new Promise(function(n, i) {
|
|
199
|
+
r(e, t || {}, function(e, t) {
|
|
200
|
+
e ? i(e) : n(t);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
n(e, t || {}, function(e, n) {
|
|
205
|
+
e && (e.code === `EACCES` || t && t.ignoreErrors) && (e = null, n = !1), i(e, n);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function i(e, t) {
|
|
209
|
+
try {
|
|
210
|
+
return n.sync(e, t || {});
|
|
211
|
+
} catch (e) {
|
|
212
|
+
if (t && t.ignoreErrors || e.code === `EACCES`) return !1;
|
|
213
|
+
throw e;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
})), P = w(((e, t) => {
|
|
217
|
+
let n = process.platform === `win32` || process.env.OSTYPE === `cygwin` || process.env.OSTYPE === `msys`, r = T(`path`), i = n ? `;` : `:`, a = N(), o = (e) => Object.assign(Error(`not found: ${e}`), { code: `ENOENT` }), s = (e, t) => {
|
|
218
|
+
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) : [``];
|
|
219
|
+
return n && e.indexOf(`.`) !== -1 && s[0] !== `` && s.unshift(``), {
|
|
220
|
+
pathEnv: a,
|
|
221
|
+
pathExt: s,
|
|
222
|
+
pathExtExe: o
|
|
223
|
+
};
|
|
224
|
+
}, c = (e, t, n) => {
|
|
225
|
+
typeof t == `function` && (n = t, t = {}), t ||= {};
|
|
226
|
+
let { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t), u = [], d = (n) => new Promise((a, s) => {
|
|
227
|
+
if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
|
|
228
|
+
let c = i[n], l = /^".*"$/.test(c) ? c.slice(1, -1) : c, d = r.join(l, e);
|
|
229
|
+
a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
|
|
230
|
+
}), f = (e, n, r) => new Promise((i, o) => {
|
|
231
|
+
if (r === c.length) return i(d(n + 1));
|
|
232
|
+
let s = c[r];
|
|
233
|
+
a(e + s, { pathExt: l }, (a, o) => {
|
|
234
|
+
if (!a && o) if (t.all) u.push(e + s);
|
|
235
|
+
else return i(e + s);
|
|
236
|
+
return i(f(e, n, r + 1));
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
return n ? d(0).then((e) => n(null, e), n) : d(0);
|
|
240
|
+
};
|
|
241
|
+
t.exports = c, c.sync = (e, t) => {
|
|
242
|
+
t ||= {};
|
|
243
|
+
let { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t), l = [];
|
|
244
|
+
for (let o = 0; o < n.length; o++) {
|
|
245
|
+
let s = n[o], u = /^".*"$/.test(s) ? s.slice(1, -1) : s, d = r.join(u, e), f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
|
|
246
|
+
for (let e = 0; e < i.length; e++) {
|
|
247
|
+
let n = f + i[e];
|
|
248
|
+
try {
|
|
249
|
+
if (a.sync(n, { pathExt: c })) if (t.all) l.push(n);
|
|
250
|
+
else return n;
|
|
251
|
+
} catch {}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (t.all && l.length) return l;
|
|
255
|
+
if (t.nothrow) return null;
|
|
256
|
+
throw o(e);
|
|
257
|
+
};
|
|
258
|
+
})), F = w(((e, t) => {
|
|
259
|
+
let n = (e = {}) => {
|
|
260
|
+
let t = e.env || process.env;
|
|
261
|
+
return (e.platform || process.platform) === `win32` ? Object.keys(t).reverse().find((e) => e.toUpperCase() === `PATH`) || `Path` : `PATH`;
|
|
262
|
+
};
|
|
263
|
+
t.exports = n, t.exports.default = n;
|
|
264
|
+
})), I = w(((e, t) => {
|
|
265
|
+
let n = T(`path`), r = P(), i = F();
|
|
266
|
+
function a(e, t) {
|
|
267
|
+
let a = e.options.env || process.env, o = process.cwd(), s = e.options.cwd != null, c = s && process.chdir !== void 0 && !process.chdir.disabled;
|
|
268
|
+
if (c) try {
|
|
269
|
+
process.chdir(e.options.cwd);
|
|
270
|
+
} catch {}
|
|
271
|
+
let l;
|
|
272
|
+
try {
|
|
273
|
+
l = r.sync(e.command, {
|
|
274
|
+
path: a[i({ env: a })],
|
|
275
|
+
pathExt: t ? n.delimiter : void 0
|
|
276
|
+
});
|
|
277
|
+
} catch {} finally {
|
|
278
|
+
c && process.chdir(o);
|
|
279
|
+
}
|
|
280
|
+
return l &&= n.resolve(s ? e.options.cwd : ``, l), l;
|
|
281
|
+
}
|
|
282
|
+
function o(e) {
|
|
283
|
+
return a(e) || a(e, !0);
|
|
284
|
+
}
|
|
285
|
+
t.exports = o;
|
|
286
|
+
})), L = w(((e, t) => {
|
|
287
|
+
let n = /([()\][%!^"`<>&|;, *?])/g;
|
|
288
|
+
function r(e) {
|
|
289
|
+
return e = e.replace(n, `^$1`), e;
|
|
290
|
+
}
|
|
291
|
+
function i(e, t) {
|
|
292
|
+
return e = `${e}`, e = e.replace(/(?=(\\+?)?)\1"/g, `$1$1\\"`), e = e.replace(/(?=(\\+?)?)\1$/, `$1$1`), e = `"${e}"`, e = e.replace(n, `^$1`), t && (e = e.replace(n, `^$1`)), e;
|
|
293
|
+
}
|
|
294
|
+
t.exports.command = r, t.exports.argument = i;
|
|
295
|
+
})), R = w(((e, t) => {
|
|
296
|
+
t.exports = /^#!(.*)/;
|
|
297
|
+
})), z = w(((e, t) => {
|
|
298
|
+
let n = R();
|
|
299
|
+
t.exports = (e = ``) => {
|
|
300
|
+
let t = e.match(n);
|
|
301
|
+
if (!t) return null;
|
|
302
|
+
let [r, i] = t[0].replace(/#! ?/, ``).split(` `), a = r.split(`/`).pop();
|
|
303
|
+
return a === `env` ? i : i ? `${a} ${i}` : a;
|
|
304
|
+
};
|
|
305
|
+
})), B = w(((e, t) => {
|
|
306
|
+
let n = T(`fs`), r = z();
|
|
307
|
+
function i(e) {
|
|
308
|
+
let t = Buffer.alloc(150), i;
|
|
309
|
+
try {
|
|
310
|
+
i = n.openSync(e, `r`), n.readSync(i, t, 0, 150, 0), n.closeSync(i);
|
|
311
|
+
} catch {}
|
|
312
|
+
return r(t.toString());
|
|
313
|
+
}
|
|
314
|
+
t.exports = i;
|
|
315
|
+
})), V = w(((e, t) => {
|
|
316
|
+
let n = T(`path`), r = I(), i = L(), a = B(), o = process.platform === `win32`, s = /\.(?:com|exe)$/i, c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
317
|
+
function l(e) {
|
|
318
|
+
e.file = r(e);
|
|
319
|
+
let t = e.file && a(e.file);
|
|
320
|
+
return t ? (e.args.unshift(e.file), e.command = t, r(e)) : e.file;
|
|
321
|
+
}
|
|
322
|
+
function u(e) {
|
|
323
|
+
if (!o) return e;
|
|
324
|
+
let t = l(e), r = !s.test(t);
|
|
325
|
+
if (e.options.forceShell || r) {
|
|
326
|
+
let r = c.test(t);
|
|
327
|
+
e.command = n.normalize(e.command), e.command = i.command(e.command), e.args = e.args.map((e) => i.argument(e, r)), e.args = [
|
|
328
|
+
`/d`,
|
|
329
|
+
`/s`,
|
|
330
|
+
`/c`,
|
|
331
|
+
`"${[e.command].concat(e.args).join(` `)}"`
|
|
332
|
+
], e.command = process.env.comspec || `cmd.exe`, e.options.windowsVerbatimArguments = !0;
|
|
333
|
+
}
|
|
334
|
+
return e;
|
|
335
|
+
}
|
|
336
|
+
function d(e, t, n) {
|
|
337
|
+
t && !Array.isArray(t) && (n = t, t = null), t = t ? t.slice(0) : [], n = Object.assign({}, n);
|
|
338
|
+
let r = {
|
|
339
|
+
command: e,
|
|
340
|
+
args: t,
|
|
341
|
+
options: n,
|
|
342
|
+
file: void 0,
|
|
343
|
+
original: {
|
|
344
|
+
command: e,
|
|
345
|
+
args: t
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
return n.shell ? r : u(r);
|
|
349
|
+
}
|
|
350
|
+
t.exports = d;
|
|
351
|
+
})), ie = w(((e, t) => {
|
|
352
|
+
let n = process.platform === `win32`;
|
|
353
|
+
function r(e, t) {
|
|
354
|
+
return Object.assign(Error(`${t} ${e.command} ENOENT`), {
|
|
355
|
+
code: `ENOENT`,
|
|
356
|
+
errno: `ENOENT`,
|
|
357
|
+
syscall: `${t} ${e.command}`,
|
|
358
|
+
path: e.command,
|
|
359
|
+
spawnargs: e.args
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function i(e, t) {
|
|
363
|
+
if (!n) return;
|
|
364
|
+
let r = e.emit;
|
|
365
|
+
e.emit = function(n, i) {
|
|
366
|
+
if (n === `exit`) {
|
|
367
|
+
let n = a(i, t);
|
|
368
|
+
if (n) return r.call(e, `error`, n);
|
|
369
|
+
}
|
|
370
|
+
return r.apply(e, arguments);
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
function a(e, t) {
|
|
374
|
+
return n && e === 1 && !t.file ? r(t.original, `spawn`) : null;
|
|
375
|
+
}
|
|
376
|
+
function o(e, t) {
|
|
377
|
+
return n && e === 1 && !t.file ? r(t.original, `spawnSync`) : null;
|
|
378
|
+
}
|
|
379
|
+
t.exports = {
|
|
380
|
+
hookChildProcess: i,
|
|
381
|
+
verifyENOENT: a,
|
|
382
|
+
verifyENOENTSync: o,
|
|
383
|
+
notFoundError: r
|
|
384
|
+
};
|
|
385
|
+
})), H = w(((e, t) => {
|
|
386
|
+
let n = T(`child_process`), r = V(), i = ie();
|
|
387
|
+
function a(e, t, a) {
|
|
388
|
+
let o = r(e, t, a), s = n.spawn(o.command, o.args, o.options);
|
|
389
|
+
return i.hookChildProcess(s, o), s;
|
|
390
|
+
}
|
|
391
|
+
function o(e, t, a) {
|
|
392
|
+
let o = r(e, t, a), s = n.spawnSync(o.command, o.args, o.options);
|
|
393
|
+
return s.error = s.error || i.verifyENOENTSync(s.status, o), s;
|
|
394
|
+
}
|
|
395
|
+
t.exports = a, t.exports.spawn = a, t.exports.sync = o, t.exports._parse = r, t.exports._enoent = i;
|
|
396
|
+
}))(), U = class extends Error {
|
|
397
|
+
result;
|
|
398
|
+
output;
|
|
399
|
+
get exitCode() {
|
|
400
|
+
if (this.result.exitCode !== null) return this.result.exitCode;
|
|
401
|
+
}
|
|
402
|
+
constructor(e, t) {
|
|
403
|
+
super(`Process exited with non-zero status (${e.exitCode})`), this.result = e, this.output = t;
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
const W = {
|
|
407
|
+
timeout: void 0,
|
|
408
|
+
persist: !1
|
|
409
|
+
}, G = { windowsHide: !0 };
|
|
410
|
+
function K(e, t) {
|
|
411
|
+
return {
|
|
412
|
+
command: (0,node_path__rspack_import_5.normalize)(e),
|
|
413
|
+
args: t ?? []
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function q(e) {
|
|
417
|
+
let t = new AbortController();
|
|
418
|
+
for (let n of e) {
|
|
419
|
+
if (n.aborted) return t.abort(), n;
|
|
420
|
+
n.addEventListener(`abort`, () => {
|
|
421
|
+
t.abort(n.reason);
|
|
422
|
+
}, { signal: t.signal });
|
|
423
|
+
}
|
|
424
|
+
return t.signal;
|
|
425
|
+
}
|
|
426
|
+
async function J(e) {
|
|
427
|
+
let t = ``;
|
|
428
|
+
for await (let n of e) t += n.toString();
|
|
429
|
+
return t;
|
|
430
|
+
}
|
|
431
|
+
var Y = class {
|
|
432
|
+
_process;
|
|
433
|
+
_aborted = !1;
|
|
434
|
+
_options;
|
|
435
|
+
_command;
|
|
436
|
+
_args;
|
|
437
|
+
_resolveClose;
|
|
438
|
+
_processClosed;
|
|
439
|
+
_thrownError;
|
|
440
|
+
get process() {
|
|
441
|
+
return this._process;
|
|
442
|
+
}
|
|
443
|
+
get pid() {
|
|
444
|
+
return this._process?.pid;
|
|
445
|
+
}
|
|
446
|
+
get exitCode() {
|
|
447
|
+
if (this._process && this._process.exitCode !== null) return this._process.exitCode;
|
|
448
|
+
}
|
|
449
|
+
constructor(e, t, n) {
|
|
450
|
+
this._options = {
|
|
451
|
+
...W,
|
|
452
|
+
...n
|
|
453
|
+
}, this._command = e, this._args = t ?? [], this._processClosed = new Promise((e) => {
|
|
454
|
+
this._resolveClose = e;
|
|
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, t, n) {
|
|
467
|
+
return ae(e, t, {
|
|
468
|
+
...n,
|
|
469
|
+
stdin: this
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
async *[Symbol.asyncIterator]() {
|
|
473
|
+
let e = this._process;
|
|
474
|
+
if (!e) return;
|
|
475
|
+
let t = [];
|
|
476
|
+
this._streamErr && t.push(this._streamErr), this._streamOut && t.push(this._streamOut);
|
|
477
|
+
let n = A(t), r = node_readline__rspack_import_7.createInterface({ input: n });
|
|
478
|
+
for await (let e of r) yield e.toString();
|
|
479
|
+
if (await this._processClosed, e.removeAllListeners(), this._thrownError) throw this._thrownError;
|
|
480
|
+
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new U(this);
|
|
481
|
+
}
|
|
482
|
+
async _waitForOutput() {
|
|
483
|
+
let e = this._process;
|
|
484
|
+
if (!e) throw Error(`No process was started`);
|
|
485
|
+
let [t, n] = await Promise.all([this._streamOut ? J(this._streamOut) : ``, this._streamErr ? J(this._streamErr) : ``]);
|
|
486
|
+
if (await this._processClosed, this._options?.stdin && await this._options.stdin, e.removeAllListeners(), this._thrownError) throw this._thrownError;
|
|
487
|
+
let r = {
|
|
488
|
+
stderr: n,
|
|
489
|
+
stdout: t,
|
|
490
|
+
exitCode: this.exitCode
|
|
491
|
+
};
|
|
492
|
+
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new U(this, r);
|
|
493
|
+
return r;
|
|
494
|
+
}
|
|
495
|
+
then(e, t) {
|
|
496
|
+
return this._waitForOutput().then(e, t);
|
|
497
|
+
}
|
|
498
|
+
_streamOut;
|
|
499
|
+
_streamErr;
|
|
500
|
+
spawn() {
|
|
501
|
+
let e = (0,node_process__rspack_import_6.cwd)(), t = this._options, n = {
|
|
502
|
+
...G,
|
|
503
|
+
...t.nodeOptions
|
|
504
|
+
}, r = [];
|
|
505
|
+
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 = q(r)), n.env = k(e, n.env);
|
|
506
|
+
let { command: i, args: o } = K(this._command, this._args), s = (0, H._parse)(i, o, n), c = (0,node_child_process__rspack_import_4.spawn)(s.command, s.args, s.options);
|
|
507
|
+
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), t.stdin !== void 0 && c.stdin && t.stdin.process) {
|
|
508
|
+
let { stdout: e } = t.stdin.process;
|
|
509
|
+
e && e.pipe(c.stdin);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
_resetState() {
|
|
513
|
+
this._aborted = !1, this._processClosed = new Promise((e) => {
|
|
514
|
+
this._resolveClose = e;
|
|
515
|
+
}), this._thrownError = void 0;
|
|
516
|
+
}
|
|
517
|
+
_onError = (e) => {
|
|
518
|
+
if (e.name === `AbortError` && (!(e.cause instanceof Error) || e.cause.name !== `TimeoutError`)) {
|
|
519
|
+
this._aborted = !0;
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
this._thrownError = e;
|
|
523
|
+
};
|
|
524
|
+
_onClose = () => {
|
|
525
|
+
this._resolveClose && this._resolveClose();
|
|
526
|
+
};
|
|
527
|
+
};
|
|
528
|
+
const X = (e, t, n) => {
|
|
529
|
+
let r = new Y(e, t, n);
|
|
530
|
+
return r.spawn(), r;
|
|
531
|
+
}, ae = X;
|
|
532
|
+
var oe = (0,_rolldown_runtime_mjs__rspack_import_8.t)({
|
|
533
|
+
detectPackageManager: () => $,
|
|
534
|
+
installDependencies: () => fe,
|
|
535
|
+
packageManagers: () => Q
|
|
536
|
+
});
|
|
537
|
+
async function se(e, t, n = {}) {
|
|
538
|
+
let r = g(e).split(`/`);
|
|
539
|
+
for (; r.length > 0;) {
|
|
540
|
+
let e = await t(r.join(`/`) || `/`);
|
|
541
|
+
if (e || !n.includeParentDirs) return e;
|
|
542
|
+
r.pop();
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function ce(e) {
|
|
546
|
+
let t;
|
|
547
|
+
return () => (t === void 0 && (t = e().then((e) => (t = e, t))), t);
|
|
548
|
+
}
|
|
549
|
+
const Z = ce(async () => {
|
|
550
|
+
if (globalThis.process?.versions?.webcontainer) return !1;
|
|
551
|
+
try {
|
|
552
|
+
let { exitCode: e } = await X(`corepack`, [`--version`]);
|
|
553
|
+
return e === 0;
|
|
554
|
+
} catch {
|
|
555
|
+
return !1;
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
async function le(e, t, n = {}) {
|
|
559
|
+
let r = e !== `npm` && e !== `bun` && e !== `deno` && n.corepack !== !1 && await Z() ? [`corepack`, [e, ...t]] : [e, t], { exitCode: i, stdout: a, stderr: o } = await X(r[0], r[1], { nodeOptions: {
|
|
560
|
+
cwd: y(n.cwd || process.cwd()),
|
|
561
|
+
env: n.env,
|
|
562
|
+
stdio: n.silent ? `pipe` : `inherit`
|
|
563
|
+
} });
|
|
564
|
+
if (i !== 0) throw Error(`\`${r.flat().join(` `)}\` failed.${n.silent ? [
|
|
565
|
+
``,
|
|
566
|
+
a,
|
|
567
|
+
o
|
|
568
|
+
].join(`
|
|
569
|
+
`) : ``}`);
|
|
570
|
+
}
|
|
571
|
+
async function ue(e = {}) {
|
|
572
|
+
let t = e.cwd || process.cwd(), n = {
|
|
573
|
+
...process.env,
|
|
574
|
+
...e.env
|
|
575
|
+
}, r = (typeof e.packageManager == `string` ? Q.find((t) => t.name === e.packageManager) : e.packageManager) || await $(e.cwd || process.cwd());
|
|
576
|
+
if (!r) throw Error(`No package manager auto-detected.`);
|
|
577
|
+
return {
|
|
578
|
+
cwd: t,
|
|
579
|
+
env: n,
|
|
580
|
+
silent: e.silent ?? !1,
|
|
581
|
+
packageManager: r,
|
|
582
|
+
dev: e.dev ?? !1,
|
|
583
|
+
workspace: e.workspace,
|
|
584
|
+
global: e.global ?? !1,
|
|
585
|
+
dry: e.dry ?? !1,
|
|
586
|
+
corepack: e.corepack ?? !0
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function de(e) {
|
|
590
|
+
let [t, n] = (e || ``).split(`@`), [r, i] = n?.split(`+`) || [];
|
|
591
|
+
if (t && t !== `-` && /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t)) return {
|
|
592
|
+
name: t,
|
|
593
|
+
version: r,
|
|
594
|
+
buildMeta: i
|
|
595
|
+
};
|
|
596
|
+
let a = (t || ``).replace(/\W+/g, ``);
|
|
597
|
+
return {
|
|
598
|
+
name: a,
|
|
599
|
+
version: r,
|
|
600
|
+
buildMeta: i,
|
|
601
|
+
warnings: [`Abnormal characters found in \`packageManager\` field, sanitizing from \`${t}\` to \`${a}\``]
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
const Q = [
|
|
605
|
+
{
|
|
606
|
+
name: `npm`,
|
|
607
|
+
command: `npm`,
|
|
608
|
+
lockFile: `package-lock.json`
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
name: `pnpm`,
|
|
612
|
+
command: `pnpm`,
|
|
613
|
+
lockFile: `pnpm-lock.yaml`,
|
|
614
|
+
files: [`pnpm-workspace.yaml`]
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
name: `bun`,
|
|
618
|
+
command: `bun`,
|
|
619
|
+
lockFile: [`bun.lockb`, `bun.lock`]
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
name: `yarn`,
|
|
623
|
+
command: `yarn`,
|
|
624
|
+
lockFile: `yarn.lock`,
|
|
625
|
+
files: [`.yarnrc.yml`]
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
name: `deno`,
|
|
629
|
+
command: `deno`,
|
|
630
|
+
lockFile: `deno.lock`,
|
|
631
|
+
files: [`deno.json`]
|
|
632
|
+
}
|
|
633
|
+
];
|
|
634
|
+
async function $(e, t = {}) {
|
|
635
|
+
let i = await se(y(e || `.`), async (e) => {
|
|
636
|
+
if (!t.ignorePackageJSON) {
|
|
637
|
+
let t = _(e, `package.json`);
|
|
638
|
+
if ((0,node_fs__rspack_import_1.existsSync)(t)) {
|
|
639
|
+
let e = JSON.parse(await (0,node_fs_promises__rspack_import_2.readFile)(t, `utf8`));
|
|
640
|
+
if (e?.packageManager) {
|
|
641
|
+
let { name: t, version: n = `0.0.0`, buildMeta: r, warnings: i } = de(e.packageManager);
|
|
642
|
+
if (t) {
|
|
643
|
+
let e = n.split(`.`)[0], a = Q.find((n) => n.name === t && n.majorVersion === e) || Q.find((e) => e.name === t);
|
|
644
|
+
return {
|
|
645
|
+
name: t,
|
|
646
|
+
command: t,
|
|
647
|
+
version: n,
|
|
648
|
+
majorVersion: e,
|
|
649
|
+
buildMeta: r,
|
|
650
|
+
warnings: i,
|
|
651
|
+
files: a?.files,
|
|
652
|
+
lockFile: a?.lockFile
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if ((0,node_fs__rspack_import_1.existsSync)(_(e, `deno.json`))) return Q.find((e) => e.name === `deno`);
|
|
658
|
+
}
|
|
659
|
+
if (!t.ignoreLockFile) {
|
|
660
|
+
for (let t of Q) if ([t.lockFile, t.files].flat().filter(Boolean).some((t) => (0,node_fs__rspack_import_1.existsSync)(y(e, t)))) return { ...t };
|
|
661
|
+
}
|
|
662
|
+
}, { includeParentDirs: t.includeParentDirs ?? !0 });
|
|
663
|
+
if (!i && !t.ignoreArgv) {
|
|
664
|
+
let e = process.argv[1];
|
|
665
|
+
if (e) {
|
|
666
|
+
for (let t of Q) if (RegExp(`[/\\\\]\\.?${t.command}`).test(e)) return t;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
return i;
|
|
670
|
+
}
|
|
671
|
+
async function fe(e = {}) {
|
|
672
|
+
let t = await ue(e), n = e.frozenLockFile ? {
|
|
673
|
+
npm: [`ci`],
|
|
674
|
+
yarn: [`install`, `--immutable`],
|
|
675
|
+
bun: [`install`, `--frozen-lockfile`],
|
|
676
|
+
pnpm: [`install`, `--frozen-lockfile`],
|
|
677
|
+
deno: [`install`, `--frozen`]
|
|
678
|
+
}[t.packageManager.name] : [`install`];
|
|
679
|
+
return e.ignoreWorkspace && t.packageManager.name === `pnpm` && n.push(`--ignore-workspace`), t.dry || await le(t.packageManager.command, n, {
|
|
680
|
+
cwd: t.cwd,
|
|
681
|
+
silent: t.silent,
|
|
682
|
+
corepack: t.corepack
|
|
683
|
+
}), { exec: {
|
|
684
|
+
command: t.packageManager.command,
|
|
685
|
+
args: n
|
|
686
|
+
} };
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
},
|
|
692
|
+
421(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
693
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
694
|
+
t: () => (__exportAll)
|
|
695
|
+
});
|
|
696
|
+
/* import */ var node_module__rspack_import_0 = __webpack_require__(8995);
|
|
697
|
+
|
|
698
|
+
//#region \0rolldown/runtime.js
|
|
699
|
+
var __defProp = Object.defineProperty;
|
|
700
|
+
var __exportAll = (all, no_symbols) => {
|
|
701
|
+
let target = {};
|
|
702
|
+
for (var name in all) __defProp(target, name, {
|
|
703
|
+
get: all[name],
|
|
704
|
+
enumerable: true
|
|
705
|
+
});
|
|
706
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
707
|
+
return target;
|
|
708
|
+
};
|
|
709
|
+
//#endregion
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
},
|
|
714
|
+
7170(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
715
|
+
|
|
716
|
+
// EXPORTS
|
|
717
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
718
|
+
downloadTemplate: () => (/* reexport */ downloadTemplate)
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
// UNUSED EXPORTS: startShell, registryProvider
|
|
722
|
+
|
|
723
|
+
// EXTERNAL MODULE: ../../node_modules/giget/dist/_chunks/libs/nypm.mjs
|
|
724
|
+
var nypm = __webpack_require__(292);
|
|
725
|
+
// EXTERNAL MODULE: external "node:fs"
|
|
726
|
+
var external_node_fs_ = __webpack_require__(3024);
|
|
727
|
+
// EXTERNAL MODULE: external "node:fs/promises"
|
|
728
|
+
var promises_ = __webpack_require__(1455);
|
|
729
|
+
// EXTERNAL MODULE: external "node:stream"
|
|
730
|
+
var external_node_stream_ = __webpack_require__(7075);
|
|
731
|
+
// EXTERNAL MODULE: external "node:stream/promises"
|
|
732
|
+
var external_node_stream_promises_ = __webpack_require__(6466);
|
|
733
|
+
// EXTERNAL MODULE: external "node:child_process"
|
|
734
|
+
var external_node_child_process_ = __webpack_require__(1421);
|
|
735
|
+
// EXTERNAL MODULE: external "node:os"
|
|
736
|
+
var external_node_os_ = __webpack_require__(8161);
|
|
737
|
+
// EXTERNAL MODULE: external "node:util"
|
|
738
|
+
var external_node_util_ = __webpack_require__(7975);
|
|
739
|
+
// EXTERNAL MODULE: external "node:path"
|
|
740
|
+
var external_node_path_ = __webpack_require__(6760);
|
|
741
|
+
;// CONCATENATED MODULE: ../../node_modules/giget/dist/_chunks/giget.mjs
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
//#region src/_utils.ts
|
|
752
|
+
async function download(url, filePath, options = {}) {
|
|
753
|
+
const infoPath = filePath + ".json";
|
|
754
|
+
const info = JSON.parse(await (0,promises_.readFile)(infoPath, "utf8").catch(() => "{}"));
|
|
755
|
+
const etag = (await sendFetch(url, {
|
|
756
|
+
method: "HEAD",
|
|
757
|
+
headers: options.headers
|
|
758
|
+
}).catch(() => void 0))?.headers.get("etag");
|
|
759
|
+
if (info.etag === etag && (0,external_node_fs_.existsSync)(filePath)) return;
|
|
760
|
+
if (typeof etag === "string") info.etag = etag;
|
|
761
|
+
const response = await sendFetch(url, { headers: options.headers });
|
|
762
|
+
if (response.status >= 400) throw new Error(`Failed to download ${url}: ${response.status} ${response.statusText}`);
|
|
763
|
+
const stream = (0,external_node_fs_.createWriteStream)(filePath);
|
|
764
|
+
await (0,external_node_util_.promisify)(external_node_stream_.pipeline)(response.body, stream);
|
|
765
|
+
await (0,promises_.writeFile)(infoPath, JSON.stringify(info), "utf8");
|
|
766
|
+
}
|
|
767
|
+
const inputRegex = /^(?<repo>[-\w.]+\/[-\w.]+)(?<subdir>[^#]+)?(?<ref>#[-\w./@]+)?/;
|
|
768
|
+
const expandedInputRegex = /^(?<repo>[-\w.]+(?:\/[-\w.]+)+?)(?:::(?<subdir>[^#]*))?(?<ref>#[-\w./@]+)?$/;
|
|
769
|
+
function parseGitURI(input, options) {
|
|
770
|
+
const useExpanded = options?.expandRepo || input.includes("::");
|
|
771
|
+
const m = input.match(useExpanded ? expandedInputRegex : inputRegex)?.groups || {};
|
|
772
|
+
const subdir = useExpanded ? m.subdir ? "/" + m.subdir : "/" : m.subdir || "/";
|
|
773
|
+
return {
|
|
774
|
+
repo: m.repo || "",
|
|
775
|
+
subdir,
|
|
776
|
+
ref: m.ref ? m.ref.slice(1) : "main"
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function debug(...args) {
|
|
780
|
+
if (process.env.DEBUG) console.debug("[giget]", ...args);
|
|
781
|
+
}
|
|
782
|
+
async function sendFetch(url, options = {}) {
|
|
783
|
+
if (options.headers?.["sec-fetch-mode"]) options.mode = options.headers["sec-fetch-mode"];
|
|
784
|
+
const res = await fetch(url, {
|
|
785
|
+
...options,
|
|
786
|
+
headers: normalizeHeaders(options.headers)
|
|
787
|
+
}).catch((error) => {
|
|
788
|
+
throw new Error(`Failed to download ${url}: ${error}`, { cause: error });
|
|
789
|
+
});
|
|
790
|
+
if (options.validateStatus && res.status >= 400) throw new Error(`Failed to fetch ${url}: ${res.status} ${res.statusText}`);
|
|
791
|
+
return res;
|
|
792
|
+
}
|
|
793
|
+
function cacheDirectory() {
|
|
794
|
+
const cacheDir = process.env.XDG_CACHE_HOME ? (0,nypm.a)(process.env.XDG_CACHE_HOME, "giget") : (0,nypm.a)((0,external_node_os_.homedir)(), ".cache/giget");
|
|
795
|
+
if (process.platform === "win32") {
|
|
796
|
+
const windowsCacheDir = (0,nypm.a)((0,external_node_os_.tmpdir)(), "giget");
|
|
797
|
+
if (!(0,external_node_fs_.existsSync)(windowsCacheDir) && (0,external_node_fs_.existsSync)(cacheDir)) try {
|
|
798
|
+
(0,external_node_fs_.renameSync)(cacheDir, windowsCacheDir);
|
|
799
|
+
} catch {}
|
|
800
|
+
return windowsCacheDir;
|
|
801
|
+
}
|
|
802
|
+
return cacheDir;
|
|
803
|
+
}
|
|
804
|
+
function normalizeHeaders(headers = {}) {
|
|
805
|
+
const normalized = {};
|
|
806
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
807
|
+
if (!value) continue;
|
|
808
|
+
normalized[key.toLowerCase()] = value;
|
|
809
|
+
}
|
|
810
|
+
return normalized;
|
|
811
|
+
}
|
|
812
|
+
function currentShell() {
|
|
813
|
+
if (process.env.SHELL) return process.env.SHELL;
|
|
814
|
+
if (process.platform === "win32") return "cmd.exe";
|
|
815
|
+
return "/bin/bash";
|
|
816
|
+
}
|
|
817
|
+
function startShell(cwd) {
|
|
818
|
+
cwd = resolve$1(cwd);
|
|
819
|
+
const shell = currentShell();
|
|
820
|
+
console.info(`(experimental) Opening shell in ${relative(process.cwd(), cwd)}...`);
|
|
821
|
+
spawnSync(shell, [], {
|
|
822
|
+
cwd,
|
|
823
|
+
shell: true,
|
|
824
|
+
stdio: "inherit"
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region src/git.ts
|
|
829
|
+
const git = (input, options) => {
|
|
830
|
+
const parsed = parseGitCloneURI(input);
|
|
831
|
+
return {
|
|
832
|
+
name: parsed.name,
|
|
833
|
+
version: parsed.subdir ? `${parsed.version || "default"}-${parsed.subdir.replaceAll("/", "-")}` : parsed.version,
|
|
834
|
+
tar: ({ auth } = {}) => _cloneAndTar(parsed, auth ?? options.auth)
|
|
835
|
+
};
|
|
836
|
+
};
|
|
837
|
+
function parseGitCloneURI(input, opts = {}) {
|
|
838
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
839
|
+
let uri = input.replace(/#.*$/, "");
|
|
840
|
+
let pathSubdir;
|
|
841
|
+
if (/^[./]/.test(input)) uri = (0,nypm.a)(cwd, uri);
|
|
842
|
+
else if (/^https?:\/\//.test(uri)) {
|
|
843
|
+
const httpMatch = /^(https?:\/\/[^/]+)\/([\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(uri);
|
|
844
|
+
if (httpMatch) {
|
|
845
|
+
const [, origin, repo, rest] = httpMatch;
|
|
846
|
+
uri = `${origin}/${repo}`;
|
|
847
|
+
if (rest) pathSubdir = rest;
|
|
848
|
+
}
|
|
849
|
+
} else if (uri.includes("@")) {
|
|
850
|
+
const sshMatch = /^(.*?:[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(uri);
|
|
851
|
+
if (sshMatch) {
|
|
852
|
+
const [, repoUri, rest] = sshMatch;
|
|
853
|
+
uri = repoUri;
|
|
854
|
+
if (rest) pathSubdir = rest;
|
|
855
|
+
}
|
|
856
|
+
} else {
|
|
857
|
+
const hostMap = {
|
|
858
|
+
"github:": "https://github.com/",
|
|
859
|
+
"gh:": "https://github.com/",
|
|
860
|
+
"gitlab:": "https://gitlab.com/",
|
|
861
|
+
"bitbucket:": "https://bitbucket.org/",
|
|
862
|
+
"sourcehut:": "https://git.sr.ht/~"
|
|
863
|
+
};
|
|
864
|
+
const host = /^(.+?:)/.exec(uri)?.at(1);
|
|
865
|
+
if (host && hostMap[host]) uri = uri.replace(host, hostMap[host]);
|
|
866
|
+
else if (!host) uri = `${(process.env.GIGET_GIT_HOST || "https://github.com/").replace(/\/$/, "")}/${uri}`;
|
|
867
|
+
const httpMatch = /^(https?:\/\/[^/]+\/~?[\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/(.+))?$/.exec(uri);
|
|
868
|
+
if (httpMatch) {
|
|
869
|
+
const [, repoUri, rest] = httpMatch;
|
|
870
|
+
uri = repoUri;
|
|
871
|
+
if (rest) pathSubdir = rest;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
const name = uri.replace(/^https?:\/\//, "").replace(/^.+@/, "").replace(/(\.git)?(#.*)?$/, "").replace(/^\W+/, "").replaceAll(/[:/]/g, "-");
|
|
875
|
+
const [version, hashSubdir] = /#(.+)$/.exec(input)?.at(1)?.split(":") ?? [];
|
|
876
|
+
const resolvedVersion = version || void 0;
|
|
877
|
+
const subdir = hashSubdir || pathSubdir;
|
|
878
|
+
return {
|
|
879
|
+
uri,
|
|
880
|
+
name,
|
|
881
|
+
...resolvedVersion && { version: resolvedVersion },
|
|
882
|
+
...subdir && { subdir }
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
async function _cloneAndTar(parsed, token) {
|
|
886
|
+
const tmpDir = await (0,promises_.mkdtemp)((0,external_node_path_.join)((0,external_node_os_.tmpdir)(), "giget-git-"));
|
|
887
|
+
if (token && /[\r\n]/.test(token)) throw new Error("Auth token must not contain newline characters");
|
|
888
|
+
const execEnv = {
|
|
889
|
+
...process.env,
|
|
890
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
891
|
+
};
|
|
892
|
+
if (token) {
|
|
893
|
+
execEnv.GIT_CONFIG_COUNT = "1";
|
|
894
|
+
execEnv.GIT_CONFIG_KEY_0 = "http.extraHeader";
|
|
895
|
+
execEnv.GIT_CONFIG_VALUE_0 = `Authorization: Bearer ${token}`;
|
|
896
|
+
}
|
|
897
|
+
const execOpts = {
|
|
898
|
+
env: execEnv,
|
|
899
|
+
timeout: 6e4
|
|
900
|
+
};
|
|
901
|
+
const status = _createStatus();
|
|
902
|
+
const gitExec = (args) => _gitSpawn(args, execOpts, status);
|
|
903
|
+
const gitExecIn = (args) => _gitSpawn(args, {
|
|
904
|
+
...execOpts,
|
|
905
|
+
cwd: tmpDir
|
|
906
|
+
}, status);
|
|
907
|
+
try {
|
|
908
|
+
const cloneArgs = [
|
|
909
|
+
"clone",
|
|
910
|
+
"--progress",
|
|
911
|
+
"--depth",
|
|
912
|
+
"1"
|
|
913
|
+
];
|
|
914
|
+
if (parsed.subdir) cloneArgs.push("--filter=blob:none", "--sparse", "--no-checkout");
|
|
915
|
+
if (parsed.version) cloneArgs.push("--branch", parsed.version);
|
|
916
|
+
cloneArgs.push("--", parsed.uri, tmpDir);
|
|
917
|
+
try {
|
|
918
|
+
status.update("Cloning...");
|
|
919
|
+
await gitExec(cloneArgs);
|
|
920
|
+
status.update("Cloned.");
|
|
921
|
+
} catch (cloneError) {
|
|
922
|
+
if (!parsed.version) throw cloneError;
|
|
923
|
+
debug("Shallow clone failed, falling back to full clone:", cloneError);
|
|
924
|
+
status.update("Shallow clone failed, cloning...");
|
|
925
|
+
await (0,promises_.rm)(tmpDir, {
|
|
926
|
+
recursive: true,
|
|
927
|
+
force: true
|
|
928
|
+
});
|
|
929
|
+
await (0,promises_.mkdir)(tmpDir, { recursive: true });
|
|
930
|
+
await gitExecIn(["init"]);
|
|
931
|
+
await gitExecIn([
|
|
932
|
+
"remote",
|
|
933
|
+
"add",
|
|
934
|
+
"origin",
|
|
935
|
+
parsed.uri
|
|
936
|
+
]);
|
|
937
|
+
await gitExecIn(["fetch", "origin"]);
|
|
938
|
+
await gitExecIn(["checkout", parsed.version]);
|
|
939
|
+
status.update("Fetched.");
|
|
940
|
+
}
|
|
941
|
+
if (parsed.subdir) {
|
|
942
|
+
status.update(`Sparse checkout ${parsed.subdir}...`);
|
|
943
|
+
await gitExecIn([
|
|
944
|
+
"sparse-checkout",
|
|
945
|
+
"set",
|
|
946
|
+
parsed.subdir
|
|
947
|
+
]);
|
|
948
|
+
await gitExecIn(["checkout"]);
|
|
949
|
+
}
|
|
950
|
+
status.update("Packing...");
|
|
951
|
+
const tarDir = parsed.subdir ? (0,external_node_path_.join)(tmpDir, parsed.subdir) : tmpDir;
|
|
952
|
+
const { create } = await __webpack_require__.e(/* import() */ "316").then(__webpack_require__.bind(__webpack_require__, 5375)).then((n) => n.t);
|
|
953
|
+
status.done();
|
|
954
|
+
const stream = create({
|
|
955
|
+
gzip: true,
|
|
956
|
+
cwd: tarDir,
|
|
957
|
+
filter: (path) => !path.startsWith(".git/") && path !== ".git" && !path.startsWith("./.git/") && path !== "./.git"
|
|
958
|
+
}, ["."]).pipe(new external_node_stream_.PassThrough());
|
|
959
|
+
let cleaned = false;
|
|
960
|
+
const cleanup = () => {
|
|
961
|
+
if (cleaned) return;
|
|
962
|
+
cleaned = true;
|
|
963
|
+
(0,promises_.rm)(tmpDir, {
|
|
964
|
+
recursive: true,
|
|
965
|
+
force: true
|
|
966
|
+
});
|
|
967
|
+
};
|
|
968
|
+
stream.on("end", cleanup);
|
|
969
|
+
stream.on("error", cleanup);
|
|
970
|
+
stream.on("close", cleanup);
|
|
971
|
+
return stream;
|
|
972
|
+
} catch (error) {
|
|
973
|
+
status.done();
|
|
974
|
+
await (0,promises_.rm)(tmpDir, {
|
|
975
|
+
recursive: true,
|
|
976
|
+
force: true
|
|
977
|
+
});
|
|
978
|
+
throw error;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
const _spinnerFrames = [
|
|
982
|
+
"⠋",
|
|
983
|
+
"⠙",
|
|
984
|
+
"⠹",
|
|
985
|
+
"⠸",
|
|
986
|
+
"⠼",
|
|
987
|
+
"⠴",
|
|
988
|
+
"⠦",
|
|
989
|
+
"⠧",
|
|
990
|
+
"⠇",
|
|
991
|
+
"⠏"
|
|
992
|
+
];
|
|
993
|
+
function _gitSpawn(args, opts, status) {
|
|
994
|
+
return new Promise((resolve, reject) => {
|
|
995
|
+
const proc = (0,external_node_child_process_.spawn)("git", args, {
|
|
996
|
+
...opts,
|
|
997
|
+
stdio: [
|
|
998
|
+
"ignore",
|
|
999
|
+
"pipe",
|
|
1000
|
+
"pipe"
|
|
1001
|
+
]
|
|
1002
|
+
});
|
|
1003
|
+
proc.stdout.resume();
|
|
1004
|
+
let lastLine = "";
|
|
1005
|
+
proc.stderr?.on("data", (chunk) => {
|
|
1006
|
+
const str = chunk.toString();
|
|
1007
|
+
for (const line of str.split(/[\r\n]/)) {
|
|
1008
|
+
const clean = line.trim();
|
|
1009
|
+
if (clean) lastLine = clean;
|
|
1010
|
+
}
|
|
1011
|
+
if (status) status.update(lastLine);
|
|
1012
|
+
});
|
|
1013
|
+
proc.on("close", (code) => {
|
|
1014
|
+
if (code === 0) resolve(lastLine);
|
|
1015
|
+
else reject(/* @__PURE__ */ new Error(`git ${args[0]} exited with code ${code}. Is git installed?`));
|
|
1016
|
+
});
|
|
1017
|
+
proc.on("error", (err) => {
|
|
1018
|
+
if (err.code === "ENOENT") reject(/* @__PURE__ */ new Error("git is not installed or not found in PATH"));
|
|
1019
|
+
else reject(err);
|
|
1020
|
+
});
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
function _createStatus() {
|
|
1024
|
+
if (!process.stderr.isTTY) return {
|
|
1025
|
+
update(_text) {},
|
|
1026
|
+
done() {}
|
|
1027
|
+
};
|
|
1028
|
+
let msg = "";
|
|
1029
|
+
let frame = 0;
|
|
1030
|
+
const render = () => {
|
|
1031
|
+
const spinner = _spinnerFrames[frame % _spinnerFrames.length];
|
|
1032
|
+
frame++;
|
|
1033
|
+
process.stderr.write(`\x1B[2K\r\x1B[2m${spinner} ${msg}\x1B[0m`);
|
|
1034
|
+
};
|
|
1035
|
+
const interval = setInterval(render, 80);
|
|
1036
|
+
return {
|
|
1037
|
+
update(text) {
|
|
1038
|
+
msg = text;
|
|
1039
|
+
render();
|
|
1040
|
+
},
|
|
1041
|
+
done() {
|
|
1042
|
+
clearInterval(interval);
|
|
1043
|
+
process.stderr.write("\x1B[2K\r");
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
//#endregion
|
|
1048
|
+
//#region src/providers.ts
|
|
1049
|
+
const http = async (input, options) => {
|
|
1050
|
+
if (input.endsWith(".json")) return await _httpJSON(input, options);
|
|
1051
|
+
const url = new URL(input);
|
|
1052
|
+
let name = (0,nypm.n)(url.pathname);
|
|
1053
|
+
try {
|
|
1054
|
+
const head = await sendFetch(url.href, {
|
|
1055
|
+
method: "HEAD",
|
|
1056
|
+
validateStatus: true,
|
|
1057
|
+
headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 }
|
|
1058
|
+
});
|
|
1059
|
+
if ((head.headers.get("content-type") || "").includes("application/json")) return await _httpJSON(input, options);
|
|
1060
|
+
const filename = head.headers.get("content-disposition")?.match(/filename="?(.+)"?/)?.[1];
|
|
1061
|
+
if (filename) name = filename.split(".")[0];
|
|
1062
|
+
} catch (error) {
|
|
1063
|
+
debug(`Failed to fetch HEAD for ${url.href}:`, error);
|
|
1064
|
+
}
|
|
1065
|
+
return {
|
|
1066
|
+
name: `${name}-${url.href.slice(0, 8)}`,
|
|
1067
|
+
version: "",
|
|
1068
|
+
subdir: "",
|
|
1069
|
+
tar: url.href,
|
|
1070
|
+
defaultDir: name,
|
|
1071
|
+
headers: { Authorization: options.auth ? `Bearer ${options.auth}` : void 0 }
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1074
|
+
const _httpJSON = async (input, options) => {
|
|
1075
|
+
const info = await (await sendFetch(input, {
|
|
1076
|
+
validateStatus: true,
|
|
1077
|
+
headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 }
|
|
1078
|
+
})).json();
|
|
1079
|
+
if (!info.tar || !info.name) throw new Error(`Invalid template info from ${input}. name or tar fields are missing!`);
|
|
1080
|
+
return info;
|
|
1081
|
+
};
|
|
1082
|
+
const github = (input, options) => {
|
|
1083
|
+
const parsed = parseGitURI(input);
|
|
1084
|
+
const githubAPIURL = process.env.GIGET_GITHUB_URL || "https://api.github.com";
|
|
1085
|
+
return {
|
|
1086
|
+
name: parsed.repo.replace("/", "-"),
|
|
1087
|
+
version: parsed.ref,
|
|
1088
|
+
subdir: parsed.subdir,
|
|
1089
|
+
headers: {
|
|
1090
|
+
Authorization: options.auth ? `Bearer ${options.auth}` : void 0,
|
|
1091
|
+
Accept: "application/vnd.github+json",
|
|
1092
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
1093
|
+
},
|
|
1094
|
+
url: `${githubAPIURL.replace("api.github.com", "github.com")}/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
|
|
1095
|
+
tar: `${githubAPIURL}/repos/${parsed.repo}/tarball/${parsed.ref}`
|
|
1096
|
+
};
|
|
1097
|
+
};
|
|
1098
|
+
const giget_gitlab = (input, options) => {
|
|
1099
|
+
const parsed = parseGitURI(input, { expandRepo: true });
|
|
1100
|
+
const gitlab = process.env.GIGET_GITLAB_URL || "https://gitlab.com";
|
|
1101
|
+
return {
|
|
1102
|
+
name: parsed.repo.replace("/", "-"),
|
|
1103
|
+
version: parsed.ref,
|
|
1104
|
+
subdir: parsed.subdir,
|
|
1105
|
+
headers: {
|
|
1106
|
+
authorization: options.auth ? `Bearer ${options.auth}` : void 0,
|
|
1107
|
+
"sec-fetch-mode": "same-origin"
|
|
1108
|
+
},
|
|
1109
|
+
url: `${gitlab}/${parsed.repo}/tree/${parsed.ref}${parsed.subdir}`,
|
|
1110
|
+
tar: `${gitlab}/${parsed.repo}/-/archive/${parsed.ref}.tar.gz`
|
|
1111
|
+
};
|
|
1112
|
+
};
|
|
1113
|
+
const bitbucket = (input, options) => {
|
|
1114
|
+
const parsed = parseGitURI(input);
|
|
1115
|
+
return {
|
|
1116
|
+
name: parsed.repo.replace("/", "-"),
|
|
1117
|
+
version: parsed.ref,
|
|
1118
|
+
subdir: parsed.subdir,
|
|
1119
|
+
headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 },
|
|
1120
|
+
url: `https://bitbucket.com/${parsed.repo}/src/${parsed.ref}${parsed.subdir}`,
|
|
1121
|
+
tar: `https://bitbucket.org/${parsed.repo}/get/${parsed.ref}.tar.gz`
|
|
1122
|
+
};
|
|
1123
|
+
};
|
|
1124
|
+
const sourcehut = (input, options) => {
|
|
1125
|
+
const parsed = parseGitURI(input);
|
|
1126
|
+
return {
|
|
1127
|
+
name: parsed.repo.replace("/", "-"),
|
|
1128
|
+
version: parsed.ref,
|
|
1129
|
+
subdir: parsed.subdir,
|
|
1130
|
+
headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 },
|
|
1131
|
+
url: `https://git.sr.ht/~${parsed.repo}/tree/${parsed.ref}/item${parsed.subdir}`,
|
|
1132
|
+
tar: `https://git.sr.ht/~${parsed.repo}/archive/${parsed.ref}.tar.gz`
|
|
1133
|
+
};
|
|
1134
|
+
};
|
|
1135
|
+
const providers = {
|
|
1136
|
+
http,
|
|
1137
|
+
https: http,
|
|
1138
|
+
git,
|
|
1139
|
+
github,
|
|
1140
|
+
gh: github,
|
|
1141
|
+
gitlab: giget_gitlab,
|
|
1142
|
+
bitbucket,
|
|
1143
|
+
sourcehut
|
|
1144
|
+
};
|
|
1145
|
+
//#endregion
|
|
1146
|
+
//#region src/registry.ts
|
|
1147
|
+
const DEFAULT_REGISTRY = "https://raw.githubusercontent.com/unjs/giget/main/templates";
|
|
1148
|
+
const registryProvider = (registryEndpoint = DEFAULT_REGISTRY, options = {}) => {
|
|
1149
|
+
return (async (input) => {
|
|
1150
|
+
const start = Date.now();
|
|
1151
|
+
const registryURL = `${registryEndpoint}/${input}.json`;
|
|
1152
|
+
const result = await sendFetch(registryURL, { headers: { authorization: options.auth ? `Bearer ${options.auth}` : void 0 } });
|
|
1153
|
+
if (result.status >= 400) throw new Error(`Failed to download ${input} template info from ${registryURL}: ${result.status} ${result.statusText}`);
|
|
1154
|
+
const info = await result.json();
|
|
1155
|
+
if (!info.tar || !info.name) throw new Error(`Invalid template info from ${registryURL}. name or tar fields are missing!`);
|
|
1156
|
+
debug(`Fetched ${input} template info from ${registryURL} in ${Date.now() - start}ms`);
|
|
1157
|
+
return info;
|
|
1158
|
+
});
|
|
1159
|
+
};
|
|
1160
|
+
//#endregion
|
|
1161
|
+
//#region src/giget.ts
|
|
1162
|
+
const sourceProtoRe = /^([\w+-.]+):/;
|
|
1163
|
+
async function downloadTemplate(input, options = {}) {
|
|
1164
|
+
options.registry = process.env.GIGET_REGISTRY ?? options.registry;
|
|
1165
|
+
options.auth = process.env.GIGET_AUTH ?? options.auth;
|
|
1166
|
+
const registry = options.registry === false ? void 0 : registryProvider(options.registry, { auth: options.auth });
|
|
1167
|
+
let providerName = options.provider || (registry ? "registry" : "github");
|
|
1168
|
+
let source = input;
|
|
1169
|
+
const sourceProviderMatch = input.match(sourceProtoRe);
|
|
1170
|
+
if (sourceProviderMatch) {
|
|
1171
|
+
providerName = sourceProviderMatch[1];
|
|
1172
|
+
source = input.slice(sourceProviderMatch[0].length);
|
|
1173
|
+
if (providerName === "http" || providerName === "https") source = input;
|
|
1174
|
+
}
|
|
1175
|
+
if (providerName.endsWith("+git")) {
|
|
1176
|
+
source = `${providerName.slice(0, -4)}:${source}`;
|
|
1177
|
+
providerName = "git";
|
|
1178
|
+
}
|
|
1179
|
+
const provider = options.providers?.[providerName] || providers[providerName] || registry;
|
|
1180
|
+
if (!provider) throw new Error(`Unsupported provider: ${providerName}`);
|
|
1181
|
+
const template = await Promise.resolve().then(() => provider(source, { auth: options.auth })).catch((error) => {
|
|
1182
|
+
throw new Error(`Failed to download template from ${providerName}: ${error.message}`);
|
|
1183
|
+
});
|
|
1184
|
+
if (!template) throw new Error(`Failed to resolve template from ${providerName}`);
|
|
1185
|
+
template.name = (template.name || "template").replace(/[^\da-z-]/gi, "-");
|
|
1186
|
+
template.defaultDir = (template.defaultDir || template.name).replace(/[^\da-z-]/gi, "-");
|
|
1187
|
+
const tarPath = (0,nypm.a)((0,nypm.a)(cacheDirectory(), providerName, template.name), (template.version || template.name) + ".tar.gz");
|
|
1188
|
+
if (options.preferOffline && (0,external_node_fs_.existsSync)(tarPath)) options.offline = true;
|
|
1189
|
+
if (!options.offline) {
|
|
1190
|
+
await (0,promises_.mkdir)((0,nypm.r)(tarPath), { recursive: true });
|
|
1191
|
+
const s = Date.now();
|
|
1192
|
+
if (typeof template.tar === "function") {
|
|
1193
|
+
const tarFn = template.tar;
|
|
1194
|
+
await (async () => {
|
|
1195
|
+
const stream = await tarFn({ auth: options.auth });
|
|
1196
|
+
await (0,external_node_stream_promises_.pipeline)(stream instanceof external_node_stream_.Readable ? stream : external_node_stream_.Readable.fromWeb(stream), (0,external_node_fs_.createWriteStream)(tarPath));
|
|
1197
|
+
})().catch((error) => {
|
|
1198
|
+
if (!(0,external_node_fs_.existsSync)(tarPath)) throw error;
|
|
1199
|
+
debug("Download error. Using cached version:", error);
|
|
1200
|
+
options.offline = true;
|
|
1201
|
+
});
|
|
1202
|
+
} else await download(template.tar, tarPath, { headers: {
|
|
1203
|
+
Authorization: options.auth ? `Bearer ${options.auth}` : void 0,
|
|
1204
|
+
...normalizeHeaders(template.headers)
|
|
1205
|
+
} }).catch((error) => {
|
|
1206
|
+
if (!(0,external_node_fs_.existsSync)(tarPath)) throw error;
|
|
1207
|
+
debug("Download error. Using cached version:", error);
|
|
1208
|
+
options.offline = true;
|
|
1209
|
+
});
|
|
1210
|
+
debug(`Downloaded to ${tarPath} in ${Date.now() - s}ms`);
|
|
1211
|
+
}
|
|
1212
|
+
if (!(0,external_node_fs_.existsSync)(tarPath)) throw new Error(`Tarball not found: ${tarPath} (offline: ${options.offline})`);
|
|
1213
|
+
const extractPath = (0,nypm.a)((0,nypm.a)(options.cwd || "."), options.dir || template.defaultDir);
|
|
1214
|
+
if (options.forceClean) await (0,promises_.rm)(extractPath, {
|
|
1215
|
+
recursive: true,
|
|
1216
|
+
force: true
|
|
1217
|
+
});
|
|
1218
|
+
if (!options.force && (0,external_node_fs_.existsSync)(extractPath) && (0,external_node_fs_.readdirSync)(extractPath).length > 0) throw new Error(`Destination ${extractPath} already exists.`);
|
|
1219
|
+
await (0,promises_.mkdir)(extractPath, { recursive: true });
|
|
1220
|
+
const s = Date.now();
|
|
1221
|
+
const subdir = template.subdir?.replace(/^\//, "") || "";
|
|
1222
|
+
const { extract } = await __webpack_require__.e(/* import() */ "316").then(__webpack_require__.bind(__webpack_require__, 5375)).then((n) => n.t);
|
|
1223
|
+
await extract({
|
|
1224
|
+
file: tarPath,
|
|
1225
|
+
cwd: extractPath,
|
|
1226
|
+
onReadEntry(entry) {
|
|
1227
|
+
entry.path = entry.path.split("/").splice(1).join("/");
|
|
1228
|
+
if (subdir) if (entry.path.startsWith(subdir + "/")) entry.path = entry.path.slice(subdir.length);
|
|
1229
|
+
else entry.path = "";
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
debug(`Extracted to ${extractPath} in ${Date.now() - s}ms`);
|
|
1233
|
+
if (options.install) {
|
|
1234
|
+
debug("Installing dependencies...");
|
|
1235
|
+
const { installDependencies } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 292)).then((n) => n.t);
|
|
1236
|
+
await installDependencies({
|
|
1237
|
+
cwd: extractPath,
|
|
1238
|
+
silent: options.silent,
|
|
1239
|
+
...typeof options.install === "object" ? options.install : {}
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
return {
|
|
1243
|
+
...template,
|
|
1244
|
+
source,
|
|
1245
|
+
dir: extractPath
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
//#endregion
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
;// CONCATENATED MODULE: ../../node_modules/giget/dist/index.mjs
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
},
|
|
1257
|
+
|
|
1258
|
+
};
|
|
1259
|
+
|
|
1260
|
+
//# sourceMappingURL=511.js.map
|