@visulima/package 3.5.10 → 3.5.11
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/CHANGELOG.md +11 -0
- package/dist/error.cjs +1 -9
- package/dist/error.mjs +1 -1
- package/dist/index.cjs +1 -33
- package/dist/index.mjs +1 -5
- package/dist/monorepo.cjs +1 -103
- package/dist/monorepo.mjs +1 -98
- package/dist/package-json.cjs +3 -1287
- package/dist/package-json.mjs +3 -1265
- package/dist/package-manager.cjs +9 -176
- package/dist/package-manager.mjs +9 -166
- package/dist/package.cjs +1 -67
- package/dist/package.mjs +1 -62
- package/dist/packem_shared/PackageNotFoundError-CEETCi0X.mjs +1 -0
- package/dist/packem_shared/PackageNotFoundError-CY57YCot.cjs +1 -0
- package/package.json +2 -2
- package/dist/packem_shared/PackageNotFoundError-Ck8Sk4z9.mjs +0 -51
- package/dist/packem_shared/PackageNotFoundError-g9G2-W3s.cjs +0 -53
package/dist/package-json.cjs
CHANGED
|
@@ -1,1287 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const node_fs = require('node:fs');
|
|
6
|
-
const process$1 = require('node:process');
|
|
7
|
-
const fs = require('node:fs/promises');
|
|
8
|
-
const path = require('node:path');
|
|
9
|
-
const node_module = require('node:module');
|
|
10
|
-
const child_process = require('child_process');
|
|
11
|
-
const path$1 = require('path');
|
|
12
|
-
const process$2 = require('process');
|
|
13
|
-
const stream = require('stream');
|
|
14
|
-
const me = require('readline');
|
|
15
|
-
const confirm = require('@inquirer/confirm');
|
|
16
|
-
const fs$1 = require('@visulima/fs');
|
|
17
|
-
const error = require('@visulima/fs/error');
|
|
18
|
-
const utils = require('@visulima/fs/utils');
|
|
19
|
-
const path$2 = require('@visulima/path');
|
|
20
|
-
const normalizeData = require('normalize-package-data');
|
|
21
|
-
|
|
22
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
23
|
-
const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
|
|
24
|
-
|
|
25
|
-
const process__default = /*#__PURE__*/_interopDefaultCompat(process$1);
|
|
26
|
-
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
27
|
-
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
28
|
-
const me__default = /*#__PURE__*/_interopDefaultCompat(me);
|
|
29
|
-
const confirm__default = /*#__PURE__*/_interopDefaultCompat(confirm);
|
|
30
|
-
const normalizeData__default = /*#__PURE__*/_interopDefaultCompat(normalizeData);
|
|
31
|
-
|
|
32
|
-
const AGENTS = [
|
|
33
|
-
"npm",
|
|
34
|
-
"yarn",
|
|
35
|
-
"yarn@berry",
|
|
36
|
-
"pnpm",
|
|
37
|
-
"pnpm@6",
|
|
38
|
-
"bun",
|
|
39
|
-
"deno"
|
|
40
|
-
];
|
|
41
|
-
const LOCKS = {
|
|
42
|
-
"bun.lock": "bun",
|
|
43
|
-
"bun.lockb": "bun",
|
|
44
|
-
"deno.lock": "deno",
|
|
45
|
-
"pnpm-lock.yaml": "pnpm",
|
|
46
|
-
"pnpm-workspace.yaml": "pnpm",
|
|
47
|
-
"yarn.lock": "yarn",
|
|
48
|
-
"package-lock.json": "npm",
|
|
49
|
-
"npm-shrinkwrap.json": "npm"
|
|
50
|
-
};
|
|
51
|
-
const INSTALL_METADATA = {
|
|
52
|
-
"node_modules/.deno/": "deno",
|
|
53
|
-
"node_modules/.pnpm/": "pnpm",
|
|
54
|
-
"node_modules/.yarn-state.yml": "yarn",
|
|
55
|
-
// yarn v2+ (node-modules)
|
|
56
|
-
"node_modules/.yarn_integrity": "yarn",
|
|
57
|
-
// yarn v1
|
|
58
|
-
"node_modules/.package-lock.json": "npm",
|
|
59
|
-
".pnp.cjs": "yarn",
|
|
60
|
-
// yarn v3+ (pnp)
|
|
61
|
-
".pnp.js": "yarn",
|
|
62
|
-
// yarn v2 (pnp)
|
|
63
|
-
"bun.lock": "bun",
|
|
64
|
-
"bun.lockb": "bun"
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
var __defProp$4 = Object.defineProperty;
|
|
68
|
-
var __name$4 = (target, value) => __defProp$4(target, "name", { value, configurable: true });
|
|
69
|
-
async function pathExists(path2, type) {
|
|
70
|
-
try {
|
|
71
|
-
const stat = await fs__default.stat(path2);
|
|
72
|
-
return type === "file" ? stat.isFile() : stat.isDirectory();
|
|
73
|
-
} catch {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
__name$4(pathExists, "pathExists");
|
|
78
|
-
function getUserAgent() {
|
|
79
|
-
const userAgent = process__default.env.npm_config_user_agent;
|
|
80
|
-
if (!userAgent) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const name = userAgent.split("/")[0];
|
|
84
|
-
return AGENTS.includes(name) ? name : null;
|
|
85
|
-
}
|
|
86
|
-
__name$4(getUserAgent, "getUserAgent");
|
|
87
|
-
function* lookup(cwd = process__default.cwd()) {
|
|
88
|
-
let directory = path__default.resolve(cwd);
|
|
89
|
-
const { root } = path__default.parse(directory);
|
|
90
|
-
while (directory && directory !== root) {
|
|
91
|
-
yield directory;
|
|
92
|
-
directory = path__default.dirname(directory);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
__name$4(lookup, "lookup");
|
|
96
|
-
async function parsePackageJson$1(filepath, onUnknown) {
|
|
97
|
-
return !filepath || !pathExists(filepath, "file") ? null : await handlePackageManager(filepath, onUnknown);
|
|
98
|
-
}
|
|
99
|
-
__name$4(parsePackageJson$1, "parsePackageJson");
|
|
100
|
-
async function detect(options = {}) {
|
|
101
|
-
const {
|
|
102
|
-
cwd,
|
|
103
|
-
strategies = ["lockfile", "packageManager-field", "devEngines-field"],
|
|
104
|
-
onUnknown
|
|
105
|
-
} = options;
|
|
106
|
-
let stopDir;
|
|
107
|
-
if (typeof options.stopDir === "string") {
|
|
108
|
-
const resolved = path__default.resolve(options.stopDir);
|
|
109
|
-
stopDir = /* @__PURE__ */ __name$4((dir) => dir === resolved, "stopDir");
|
|
110
|
-
} else {
|
|
111
|
-
stopDir = options.stopDir;
|
|
112
|
-
}
|
|
113
|
-
for (const directory of lookup(cwd)) {
|
|
114
|
-
for (const strategy of strategies) {
|
|
115
|
-
switch (strategy) {
|
|
116
|
-
case "lockfile": {
|
|
117
|
-
for (const lock of Object.keys(LOCKS)) {
|
|
118
|
-
if (await pathExists(path__default.join(directory, lock), "file")) {
|
|
119
|
-
const name = LOCKS[lock];
|
|
120
|
-
const result = await parsePackageJson$1(path__default.join(directory, "package.json"), onUnknown);
|
|
121
|
-
if (result)
|
|
122
|
-
return result;
|
|
123
|
-
else
|
|
124
|
-
return { name, agent: name };
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
case "packageManager-field":
|
|
130
|
-
case "devEngines-field": {
|
|
131
|
-
const result = await parsePackageJson$1(path__default.join(directory, "package.json"), onUnknown);
|
|
132
|
-
if (result)
|
|
133
|
-
return result;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
case "install-metadata": {
|
|
137
|
-
for (const metadata of Object.keys(INSTALL_METADATA)) {
|
|
138
|
-
const fileOrDir = metadata.endsWith("/") ? "dir" : "file";
|
|
139
|
-
if (await pathExists(path__default.join(directory, metadata), fileOrDir)) {
|
|
140
|
-
const name = INSTALL_METADATA[metadata];
|
|
141
|
-
const agent = name === "yarn" ? isMetadataYarnClassic(metadata) ? "yarn" : "yarn@berry" : name;
|
|
142
|
-
return { name, agent };
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (stopDir?.(directory))
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
__name$4(detect, "detect");
|
|
155
|
-
function getNameAndVer(pkg) {
|
|
156
|
-
const handelVer = /* @__PURE__ */ __name$4((version) => version?.match(/\d+(\.\d+){0,2}/)?.[0] ?? version, "handelVer");
|
|
157
|
-
if (typeof pkg.packageManager === "string") {
|
|
158
|
-
const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
|
|
159
|
-
return { name, ver: handelVer(ver) };
|
|
160
|
-
}
|
|
161
|
-
if (typeof pkg.devEngines?.packageManager?.name === "string") {
|
|
162
|
-
return {
|
|
163
|
-
name: pkg.devEngines.packageManager.name,
|
|
164
|
-
ver: handelVer(pkg.devEngines.packageManager.version)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
return void 0;
|
|
168
|
-
}
|
|
169
|
-
__name$4(getNameAndVer, "getNameAndVer");
|
|
170
|
-
async function handlePackageManager(filepath, onUnknown) {
|
|
171
|
-
try {
|
|
172
|
-
const pkg = JSON.parse(await fs__default.readFile(filepath, "utf8"));
|
|
173
|
-
let agent;
|
|
174
|
-
const nameAndVer = getNameAndVer(pkg);
|
|
175
|
-
if (nameAndVer) {
|
|
176
|
-
const name = nameAndVer.name;
|
|
177
|
-
const ver = nameAndVer.ver;
|
|
178
|
-
let version = ver;
|
|
179
|
-
if (name === "yarn" && ver && Number.parseInt(ver) > 1) {
|
|
180
|
-
agent = "yarn@berry";
|
|
181
|
-
version = "berry";
|
|
182
|
-
return { name, agent, version };
|
|
183
|
-
} else if (name === "pnpm" && ver && Number.parseInt(ver) < 7) {
|
|
184
|
-
agent = "pnpm@6";
|
|
185
|
-
return { name, agent, version };
|
|
186
|
-
} else if (AGENTS.includes(name)) {
|
|
187
|
-
agent = name;
|
|
188
|
-
return { name, agent, version };
|
|
189
|
-
} else {
|
|
190
|
-
return onUnknown?.(pkg.packageManager) ?? null;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
} catch {
|
|
194
|
-
}
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
__name$4(handlePackageManager, "handlePackageManager");
|
|
198
|
-
function isMetadataYarnClassic(metadataPath) {
|
|
199
|
-
return metadataPath.endsWith(".yarn_integrity");
|
|
200
|
-
}
|
|
201
|
-
__name$4(isMetadataYarnClassic, "isMetadataYarnClassic");
|
|
202
|
-
|
|
203
|
-
var __defProp$3 = Object.defineProperty;
|
|
204
|
-
var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
|
|
205
|
-
const require2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('package-json.cjs', document.baseURI).href)));
|
|
206
|
-
var St = Object.create;
|
|
207
|
-
var $ = Object.defineProperty;
|
|
208
|
-
var kt = Object.getOwnPropertyDescriptor;
|
|
209
|
-
var Tt = Object.getOwnPropertyNames;
|
|
210
|
-
var At = Object.getPrototypeOf;
|
|
211
|
-
var Rt = Object.prototype.hasOwnProperty;
|
|
212
|
-
var h = /* @__PURE__ */ ((t) => typeof require2 < "u" ? require2 : typeof Proxy < "u" ? new Proxy(t, {
|
|
213
|
-
get: /* @__PURE__ */ __name$3((e, n) => (typeof require2 < "u" ? require2 : e)[n], "get")
|
|
214
|
-
}) : t)(function(t) {
|
|
215
|
-
if (typeof require2 < "u") return require2.apply(this, arguments);
|
|
216
|
-
throw Error('Dynamic require of "' + t + '" is not supported');
|
|
217
|
-
});
|
|
218
|
-
var l = /* @__PURE__ */ __name$3((t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports), "l");
|
|
219
|
-
var $t = /* @__PURE__ */ __name$3((t, e, n, r) => {
|
|
220
|
-
if (e && typeof e == "object" || typeof e == "function")
|
|
221
|
-
for (let s of Tt(e))
|
|
222
|
-
!Rt.call(t, s) && s !== n && $(t, s, { get: /* @__PURE__ */ __name$3(() => e[s], "get"), enumerable: !(r = kt(e, s)) || r.enumerable });
|
|
223
|
-
return t;
|
|
224
|
-
}, "$t");
|
|
225
|
-
var Nt = /* @__PURE__ */ __name$3((t, e, n) => (n = t != null ? St(At(t)) : {}, $t(
|
|
226
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
227
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
228
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
229
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
230
|
-
e || !t || !t.__esModule ? $(n, "default", { value: t, enumerable: true }) : n,
|
|
231
|
-
t
|
|
232
|
-
)), "Nt");
|
|
233
|
-
var W = l((Se, H) => {
|
|
234
|
-
H.exports = z;
|
|
235
|
-
z.sync = Wt;
|
|
236
|
-
var j = h("fs");
|
|
237
|
-
function Ht(t, e) {
|
|
238
|
-
var n = e.pathExt !== void 0 ? e.pathExt : process.env.PATHEXT;
|
|
239
|
-
if (!n || (n = n.split(";"), n.indexOf("") !== -1))
|
|
240
|
-
return true;
|
|
241
|
-
for (var r = 0; r < n.length; r++) {
|
|
242
|
-
var s = n[r].toLowerCase();
|
|
243
|
-
if (s && t.substr(-s.length).toLowerCase() === s)
|
|
244
|
-
return true;
|
|
245
|
-
}
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
__name$3(Ht, "Ht");
|
|
249
|
-
function F(t, e, n) {
|
|
250
|
-
return !t.isSymbolicLink() && !t.isFile() ? false : Ht(e, n);
|
|
251
|
-
}
|
|
252
|
-
__name$3(F, "F");
|
|
253
|
-
function z(t, e, n) {
|
|
254
|
-
j.stat(t, function(r, s) {
|
|
255
|
-
n(r, r ? false : F(s, t, e));
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
__name$3(z, "z");
|
|
259
|
-
function Wt(t, e) {
|
|
260
|
-
return F(j.statSync(t), t, e);
|
|
261
|
-
}
|
|
262
|
-
__name$3(Wt, "Wt");
|
|
263
|
-
});
|
|
264
|
-
var X = l((ke, B) => {
|
|
265
|
-
B.exports = K;
|
|
266
|
-
K.sync = Dt;
|
|
267
|
-
var D = h("fs");
|
|
268
|
-
function K(t, e, n) {
|
|
269
|
-
D.stat(t, function(r, s) {
|
|
270
|
-
n(r, r ? false : M(s, e));
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
__name$3(K, "K");
|
|
274
|
-
function Dt(t, e) {
|
|
275
|
-
return M(D.statSync(t), e);
|
|
276
|
-
}
|
|
277
|
-
__name$3(Dt, "Dt");
|
|
278
|
-
function M(t, e) {
|
|
279
|
-
return t.isFile() && Kt(t, e);
|
|
280
|
-
}
|
|
281
|
-
__name$3(M, "M");
|
|
282
|
-
function Kt(t, e) {
|
|
283
|
-
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;
|
|
284
|
-
return p;
|
|
285
|
-
}
|
|
286
|
-
__name$3(Kt, "Kt");
|
|
287
|
-
});
|
|
288
|
-
var U = l((Ae, G) => {
|
|
289
|
-
h("fs"); var v;
|
|
290
|
-
process.platform === "win32" || global.TESTING_WINDOWS ? v = W() : v = X();
|
|
291
|
-
G.exports = y;
|
|
292
|
-
y.sync = Mt;
|
|
293
|
-
function y(t, e, n) {
|
|
294
|
-
if (typeof e == "function" && (n = e, e = {}), !n) {
|
|
295
|
-
if (typeof Promise != "function")
|
|
296
|
-
throw new TypeError("callback not provided");
|
|
297
|
-
return new Promise(function(r, s) {
|
|
298
|
-
y(t, e || {}, function(o, i) {
|
|
299
|
-
o ? s(o) : r(i);
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
v(t, e || {}, function(r, s) {
|
|
304
|
-
r && (r.code === "EACCES" || e && e.ignoreErrors) && (r = null, s = false), n(r, s);
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
__name$3(y, "y");
|
|
308
|
-
function Mt(t, e) {
|
|
309
|
-
try {
|
|
310
|
-
return v.sync(t, e || {});
|
|
311
|
-
} catch (n) {
|
|
312
|
-
if (e && e.ignoreErrors || n.code === "EACCES")
|
|
313
|
-
return false;
|
|
314
|
-
throw n;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
__name$3(Mt, "Mt");
|
|
318
|
-
});
|
|
319
|
-
var et = l((Re, tt) => {
|
|
320
|
-
var g = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", Y = h("path"), Bt = g ? ";" : ":", V = U(), J = /* @__PURE__ */ __name$3((t) => Object.assign(new Error(`not found: ${t}`), { code: "ENOENT" }), "J"), Q = /* @__PURE__ */ __name$3((t, e) => {
|
|
321
|
-
let n = e.colon || Bt, r = t.match(/\//) || g && t.match(/\\/) ? [""] : [
|
|
322
|
-
// windows always checks the cwd first
|
|
323
|
-
...g ? [process.cwd()] : [],
|
|
324
|
-
...(e.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
325
|
-
"").split(n)
|
|
326
|
-
], s = g ? e.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "", o = g ? s.split(n) : [""];
|
|
327
|
-
return g && t.indexOf(".") !== -1 && o[0] !== "" && o.unshift(""), {
|
|
328
|
-
pathEnv: r,
|
|
329
|
-
pathExt: o,
|
|
330
|
-
pathExtExe: s
|
|
331
|
-
};
|
|
332
|
-
}, "Q"), Z = /* @__PURE__ */ __name$3((t, e, n) => {
|
|
333
|
-
typeof e == "function" && (n = e, e = {}), e || (e = {});
|
|
334
|
-
let { pathEnv: r, pathExt: s, pathExtExe: o } = Q(t, e), i = [], a = /* @__PURE__ */ __name$3((u) => new Promise((f, p) => {
|
|
335
|
-
if (u === r.length)
|
|
336
|
-
return e.all && i.length ? f(i) : p(J(t));
|
|
337
|
-
let d = r[u], w = /^".*"$/.test(d) ? d.slice(1, -1) : d, m = Y.join(w, t), b = !w && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + m : m;
|
|
338
|
-
f(c(b, u, 0));
|
|
339
|
-
}), "a"), c = /* @__PURE__ */ __name$3((u, f, p) => new Promise((d, w) => {
|
|
340
|
-
if (p === s.length)
|
|
341
|
-
return d(a(f + 1));
|
|
342
|
-
let m = s[p];
|
|
343
|
-
V(u + m, { pathExt: o }, (b, Ot) => {
|
|
344
|
-
if (!b && Ot)
|
|
345
|
-
if (e.all)
|
|
346
|
-
i.push(u + m);
|
|
347
|
-
else
|
|
348
|
-
return d(u + m);
|
|
349
|
-
return d(c(u, f, p + 1));
|
|
350
|
-
});
|
|
351
|
-
}), "c");
|
|
352
|
-
return n ? a(0).then((u) => n(null, u), n) : a(0);
|
|
353
|
-
}, "Z"), Xt = /* @__PURE__ */ __name$3((t, e) => {
|
|
354
|
-
e = e || {};
|
|
355
|
-
let { pathEnv: n, pathExt: r, pathExtExe: s } = Q(t, e), o = [];
|
|
356
|
-
for (let i = 0; i < n.length; i++) {
|
|
357
|
-
let a = n[i], c = /^".*"$/.test(a) ? a.slice(1, -1) : a, u = Y.join(c, t), f = !c && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + u : u;
|
|
358
|
-
for (let p = 0; p < r.length; p++) {
|
|
359
|
-
let d = f + r[p];
|
|
360
|
-
try {
|
|
361
|
-
if (V.sync(d, { pathExt: s }))
|
|
362
|
-
if (e.all)
|
|
363
|
-
o.push(d);
|
|
364
|
-
else
|
|
365
|
-
return d;
|
|
366
|
-
} catch {
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
if (e.all && o.length)
|
|
371
|
-
return o;
|
|
372
|
-
if (e.nothrow)
|
|
373
|
-
return null;
|
|
374
|
-
throw J(t);
|
|
375
|
-
}, "Xt");
|
|
376
|
-
tt.exports = Z;
|
|
377
|
-
Z.sync = Xt;
|
|
378
|
-
});
|
|
379
|
-
var rt = l(($e, _) => {
|
|
380
|
-
var nt = /* @__PURE__ */ __name$3((t = {}) => {
|
|
381
|
-
let e = t.env || process.env;
|
|
382
|
-
return (t.platform || process.platform) !== "win32" ? "PATH" : Object.keys(e).reverse().find((r) => r.toUpperCase() === "PATH") || "Path";
|
|
383
|
-
}, "nt");
|
|
384
|
-
_.exports = nt;
|
|
385
|
-
_.exports.default = nt;
|
|
386
|
-
});
|
|
387
|
-
var ct = l((Ne, it) => {
|
|
388
|
-
var st = h("path"), Gt = et(), Ut = rt();
|
|
389
|
-
function ot(t, e) {
|
|
390
|
-
let n = t.options.env || process.env, r = process.cwd(), s = t.options.cwd != null, o = s && process.chdir !== void 0 && !process.chdir.disabled;
|
|
391
|
-
if (o)
|
|
392
|
-
try {
|
|
393
|
-
process.chdir(t.options.cwd);
|
|
394
|
-
} catch {
|
|
395
|
-
}
|
|
396
|
-
let i;
|
|
397
|
-
try {
|
|
398
|
-
i = Gt.sync(t.command, {
|
|
399
|
-
path: n[Ut({ env: n })],
|
|
400
|
-
pathExt: e ? st.delimiter : void 0
|
|
401
|
-
});
|
|
402
|
-
} catch {
|
|
403
|
-
} finally {
|
|
404
|
-
o && process.chdir(r);
|
|
405
|
-
}
|
|
406
|
-
return i && (i = st.resolve(s ? t.options.cwd : "", i)), i;
|
|
407
|
-
}
|
|
408
|
-
__name$3(ot, "ot");
|
|
409
|
-
function Yt(t) {
|
|
410
|
-
return ot(t) || ot(t, true);
|
|
411
|
-
}
|
|
412
|
-
__name$3(Yt, "Yt");
|
|
413
|
-
it.exports = Yt;
|
|
414
|
-
});
|
|
415
|
-
var ut = l((qe, P) => {
|
|
416
|
-
var C = /([()\][%!^"`<>&|;, *?])/g;
|
|
417
|
-
function Vt(t) {
|
|
418
|
-
return t = t.replace(C, "^$1"), t;
|
|
419
|
-
}
|
|
420
|
-
__name$3(Vt, "Vt");
|
|
421
|
-
function Jt(t, e) {
|
|
422
|
-
return t = `${t}`, t = t.replace(/(\\*)"/g, '$1$1\\"'), t = t.replace(/(\\*)$/, "$1$1"), t = `"${t}"`, t = t.replace(C, "^$1"), e && (t = t.replace(C, "^$1")), t;
|
|
423
|
-
}
|
|
424
|
-
__name$3(Jt, "Jt");
|
|
425
|
-
P.exports.command = Vt;
|
|
426
|
-
P.exports.argument = Jt;
|
|
427
|
-
});
|
|
428
|
-
var lt = l((Ie, at) => {
|
|
429
|
-
at.exports = /^#!(.*)/;
|
|
430
|
-
});
|
|
431
|
-
var dt = l((Le, pt) => {
|
|
432
|
-
var Qt = lt();
|
|
433
|
-
pt.exports = (t = "") => {
|
|
434
|
-
let e = t.match(Qt);
|
|
435
|
-
if (!e)
|
|
436
|
-
return null;
|
|
437
|
-
let [n, r] = e[0].replace(/#! ?/, "").split(" "), s = n.split("/").pop();
|
|
438
|
-
return s === "env" ? r : r ? `${s} ${r}` : s;
|
|
439
|
-
};
|
|
440
|
-
});
|
|
441
|
-
var ht = l((je, ft) => {
|
|
442
|
-
var O = h("fs"), Zt = dt();
|
|
443
|
-
function te(t) {
|
|
444
|
-
let n = Buffer.alloc(150), r;
|
|
445
|
-
try {
|
|
446
|
-
r = O.openSync(t, "r"), O.readSync(r, n, 0, 150, 0), O.closeSync(r);
|
|
447
|
-
} catch {
|
|
448
|
-
}
|
|
449
|
-
return Zt(n.toString());
|
|
450
|
-
}
|
|
451
|
-
__name$3(te, "te");
|
|
452
|
-
ft.exports = te;
|
|
453
|
-
});
|
|
454
|
-
var wt = l((Fe, Et) => {
|
|
455
|
-
var ee = h("path"), mt = ct(), gt = ut(), ne = ht(), re = process.platform === "win32", se = /\.(?:com|exe)$/i, oe = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
456
|
-
function ie(t) {
|
|
457
|
-
t.file = mt(t);
|
|
458
|
-
let e = t.file && ne(t.file);
|
|
459
|
-
return e ? (t.args.unshift(t.file), t.command = e, mt(t)) : t.file;
|
|
460
|
-
}
|
|
461
|
-
__name$3(ie, "ie");
|
|
462
|
-
function ce(t) {
|
|
463
|
-
if (!re)
|
|
464
|
-
return t;
|
|
465
|
-
let e = ie(t), n = !se.test(e);
|
|
466
|
-
if (t.options.forceShell || n) {
|
|
467
|
-
let r = oe.test(e);
|
|
468
|
-
t.command = ee.normalize(t.command), t.command = gt.command(t.command), t.args = t.args.map((o) => gt.argument(o, r));
|
|
469
|
-
let s = [t.command].concat(t.args).join(" ");
|
|
470
|
-
t.args = ["/d", "/s", "/c", `"${s}"`], t.command = process.env.comspec || "cmd.exe", t.options.windowsVerbatimArguments = true;
|
|
471
|
-
}
|
|
472
|
-
return t;
|
|
473
|
-
}
|
|
474
|
-
__name$3(ce, "ce");
|
|
475
|
-
function ue(t, e, n) {
|
|
476
|
-
e && !Array.isArray(e) && (n = e, e = null), e = e ? e.slice(0) : [], n = Object.assign({}, n);
|
|
477
|
-
let r = {
|
|
478
|
-
command: t,
|
|
479
|
-
args: e,
|
|
480
|
-
options: n,
|
|
481
|
-
file: void 0,
|
|
482
|
-
original: {
|
|
483
|
-
command: t,
|
|
484
|
-
args: e
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
return n.shell ? r : ce(r);
|
|
488
|
-
}
|
|
489
|
-
__name$3(ue, "ue");
|
|
490
|
-
Et.exports = ue;
|
|
491
|
-
});
|
|
492
|
-
var bt = l((ze, vt) => {
|
|
493
|
-
var S = process.platform === "win32";
|
|
494
|
-
function k(t, e) {
|
|
495
|
-
return Object.assign(new Error(`${e} ${t.command} ENOENT`), {
|
|
496
|
-
code: "ENOENT",
|
|
497
|
-
errno: "ENOENT",
|
|
498
|
-
syscall: `${e} ${t.command}`,
|
|
499
|
-
path: t.command,
|
|
500
|
-
spawnargs: t.args
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
__name$3(k, "k");
|
|
504
|
-
function ae(t, e) {
|
|
505
|
-
if (!S)
|
|
506
|
-
return;
|
|
507
|
-
let n = t.emit;
|
|
508
|
-
t.emit = function(r, s) {
|
|
509
|
-
if (r === "exit") {
|
|
510
|
-
let o = xt(s, e);
|
|
511
|
-
if (o)
|
|
512
|
-
return n.call(t, "error", o);
|
|
513
|
-
}
|
|
514
|
-
return n.apply(t, arguments);
|
|
515
|
-
};
|
|
516
|
-
}
|
|
517
|
-
__name$3(ae, "ae");
|
|
518
|
-
function xt(t, e) {
|
|
519
|
-
return S && t === 1 && !e.file ? k(e.original, "spawn") : null;
|
|
520
|
-
}
|
|
521
|
-
__name$3(xt, "xt");
|
|
522
|
-
function le(t, e) {
|
|
523
|
-
return S && t === 1 && !e.file ? k(e.original, "spawnSync") : null;
|
|
524
|
-
}
|
|
525
|
-
__name$3(le, "le");
|
|
526
|
-
vt.exports = {
|
|
527
|
-
hookChildProcess: ae,
|
|
528
|
-
verifyENOENT: xt,
|
|
529
|
-
verifyENOENTSync: le,
|
|
530
|
-
notFoundError: k
|
|
531
|
-
};
|
|
532
|
-
});
|
|
533
|
-
var Ct = l((He, E) => {
|
|
534
|
-
var yt = h("child_process"), T = wt(), A = bt();
|
|
535
|
-
function _t(t, e, n) {
|
|
536
|
-
let r = T(t, e, n), s = yt.spawn(r.command, r.args, r.options);
|
|
537
|
-
return A.hookChildProcess(s, r), s;
|
|
538
|
-
}
|
|
539
|
-
__name$3(_t, "_t");
|
|
540
|
-
function pe(t, e, n) {
|
|
541
|
-
let r = T(t, e, n), s = yt.spawnSync(r.command, r.args, r.options);
|
|
542
|
-
return s.error = s.error || A.verifyENOENTSync(s.status, r), s;
|
|
543
|
-
}
|
|
544
|
-
__name$3(pe, "pe");
|
|
545
|
-
E.exports = _t;
|
|
546
|
-
E.exports.spawn = _t;
|
|
547
|
-
E.exports.sync = pe;
|
|
548
|
-
E.exports._parse = T;
|
|
549
|
-
E.exports._enoent = A;
|
|
550
|
-
});
|
|
551
|
-
var Lt = /^path$/i;
|
|
552
|
-
var q = { key: "PATH", value: "" };
|
|
553
|
-
function jt(t) {
|
|
554
|
-
for (let e in t) {
|
|
555
|
-
if (!Object.prototype.hasOwnProperty.call(t, e) || !Lt.test(e))
|
|
556
|
-
continue;
|
|
557
|
-
let n = t[e];
|
|
558
|
-
return n ? { key: e, value: n } : q;
|
|
559
|
-
}
|
|
560
|
-
return q;
|
|
561
|
-
}
|
|
562
|
-
__name$3(jt, "jt");
|
|
563
|
-
function Ft(t, e) {
|
|
564
|
-
let n = e.value.split(path$1.delimiter), r = t, s;
|
|
565
|
-
do
|
|
566
|
-
n.push(path$1.resolve(r, "node_modules", ".bin")), s = r, r = path$1.dirname(r);
|
|
567
|
-
while (r !== s);
|
|
568
|
-
return { key: e.key, value: n.join(path$1.delimiter) };
|
|
569
|
-
}
|
|
570
|
-
__name$3(Ft, "Ft");
|
|
571
|
-
function I(t, e) {
|
|
572
|
-
let n = {
|
|
573
|
-
...process.env,
|
|
574
|
-
...e
|
|
575
|
-
}, r = Ft(t, jt(n));
|
|
576
|
-
return n[r.key] = r.value, n;
|
|
577
|
-
}
|
|
578
|
-
__name$3(I, "I");
|
|
579
|
-
var L = /* @__PURE__ */ __name$3((t) => {
|
|
580
|
-
let e = t.length, n = new stream.PassThrough(), r = /* @__PURE__ */ __name$3(() => {
|
|
581
|
-
--e === 0 && n.emit("end");
|
|
582
|
-
}, "r");
|
|
583
|
-
for (let s of t)
|
|
584
|
-
s.pipe(n, { end: false }), s.on("end", r);
|
|
585
|
-
return n;
|
|
586
|
-
}, "L");
|
|
587
|
-
var Pt = Nt(Ct(), 1);
|
|
588
|
-
var x = class extends Error {
|
|
589
|
-
static {
|
|
590
|
-
__name$3(this, "x");
|
|
591
|
-
}
|
|
592
|
-
result;
|
|
593
|
-
output;
|
|
594
|
-
get exitCode() {
|
|
595
|
-
if (this.result.exitCode !== null)
|
|
596
|
-
return this.result.exitCode;
|
|
597
|
-
}
|
|
598
|
-
constructor(e, n) {
|
|
599
|
-
super(`Process exited with non-zero status (${e.exitCode})`), this.result = e, this.output = n;
|
|
600
|
-
}
|
|
601
|
-
};
|
|
602
|
-
var ge = {
|
|
603
|
-
timeout: void 0,
|
|
604
|
-
persist: false
|
|
605
|
-
};
|
|
606
|
-
var Ee = {
|
|
607
|
-
windowsHide: true
|
|
608
|
-
};
|
|
609
|
-
function we(t, e) {
|
|
610
|
-
return {
|
|
611
|
-
command: path$1.normalize(t),
|
|
612
|
-
args: e ?? []
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
__name$3(we, "we");
|
|
616
|
-
function xe(t) {
|
|
617
|
-
let e = new AbortController();
|
|
618
|
-
for (let n of t) {
|
|
619
|
-
if (n.aborted)
|
|
620
|
-
return e.abort(), n;
|
|
621
|
-
let r = /* @__PURE__ */ __name$3(() => {
|
|
622
|
-
e.abort(n.reason);
|
|
623
|
-
}, "r");
|
|
624
|
-
n.addEventListener("abort", r, {
|
|
625
|
-
signal: e.signal
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
return e.signal;
|
|
629
|
-
}
|
|
630
|
-
__name$3(xe, "xe");
|
|
631
|
-
var R = class {
|
|
632
|
-
static {
|
|
633
|
-
__name$3(this, "R");
|
|
634
|
-
}
|
|
635
|
-
_process;
|
|
636
|
-
_aborted = false;
|
|
637
|
-
_options;
|
|
638
|
-
_command;
|
|
639
|
-
_args;
|
|
640
|
-
_resolveClose;
|
|
641
|
-
_processClosed;
|
|
642
|
-
_thrownError;
|
|
643
|
-
get process() {
|
|
644
|
-
return this._process;
|
|
645
|
-
}
|
|
646
|
-
get pid() {
|
|
647
|
-
return this._process?.pid;
|
|
648
|
-
}
|
|
649
|
-
get exitCode() {
|
|
650
|
-
if (this._process && this._process.exitCode !== null)
|
|
651
|
-
return this._process.exitCode;
|
|
652
|
-
}
|
|
653
|
-
constructor(e, n, r) {
|
|
654
|
-
this._options = {
|
|
655
|
-
...ge,
|
|
656
|
-
...r
|
|
657
|
-
}, this._command = e, this._args = n ?? [], this._processClosed = new Promise((s) => {
|
|
658
|
-
this._resolveClose = s;
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
kill(e) {
|
|
662
|
-
return this._process?.kill(e) === true;
|
|
663
|
-
}
|
|
664
|
-
get aborted() {
|
|
665
|
-
return this._aborted;
|
|
666
|
-
}
|
|
667
|
-
get killed() {
|
|
668
|
-
return this._process?.killed === true;
|
|
669
|
-
}
|
|
670
|
-
pipe(e, n, r) {
|
|
671
|
-
return be(e, n, {
|
|
672
|
-
...r,
|
|
673
|
-
stdin: this
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
async *[Symbol.asyncIterator]() {
|
|
677
|
-
let e = this._process;
|
|
678
|
-
if (!e)
|
|
679
|
-
return;
|
|
680
|
-
let n = [];
|
|
681
|
-
this._streamErr && n.push(this._streamErr), this._streamOut && n.push(this._streamOut);
|
|
682
|
-
let r = L(n), s = me__default.createInterface({
|
|
683
|
-
input: r
|
|
684
|
-
});
|
|
685
|
-
for await (let o of s)
|
|
686
|
-
yield o.toString();
|
|
687
|
-
if (await this._processClosed, e.removeAllListeners(), this._thrownError)
|
|
688
|
-
throw this._thrownError;
|
|
689
|
-
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0)
|
|
690
|
-
throw new x(this);
|
|
691
|
-
}
|
|
692
|
-
async _waitForOutput() {
|
|
693
|
-
let e = this._process;
|
|
694
|
-
if (!e)
|
|
695
|
-
throw new Error("No process was started");
|
|
696
|
-
let n = "", r = "";
|
|
697
|
-
if (this._streamOut)
|
|
698
|
-
for await (let o of this._streamOut)
|
|
699
|
-
r += o.toString();
|
|
700
|
-
if (this._streamErr)
|
|
701
|
-
for await (let o of this._streamErr)
|
|
702
|
-
n += o.toString();
|
|
703
|
-
if (await this._processClosed, this._options?.stdin && await this._options.stdin, e.removeAllListeners(), this._thrownError)
|
|
704
|
-
throw this._thrownError;
|
|
705
|
-
let s = {
|
|
706
|
-
stderr: n,
|
|
707
|
-
stdout: r,
|
|
708
|
-
exitCode: this.exitCode
|
|
709
|
-
};
|
|
710
|
-
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0)
|
|
711
|
-
throw new x(this, s);
|
|
712
|
-
return s;
|
|
713
|
-
}
|
|
714
|
-
then(e, n) {
|
|
715
|
-
return this._waitForOutput().then(e, n);
|
|
716
|
-
}
|
|
717
|
-
_streamOut;
|
|
718
|
-
_streamErr;
|
|
719
|
-
spawn() {
|
|
720
|
-
let e = process$2.cwd(), n = this._options, r = {
|
|
721
|
-
...Ee,
|
|
722
|
-
...n.nodeOptions
|
|
723
|
-
}, s = [];
|
|
724
|
-
this._resetState(), n.timeout !== void 0 && s.push(AbortSignal.timeout(n.timeout)), n.signal !== void 0 && s.push(n.signal), n.persist === true && (r.detached = true), s.length > 0 && (r.signal = xe(s)), r.env = I(e, r.env);
|
|
725
|
-
let { command: o, args: i } = we(this._command, this._args), a = (0, Pt._parse)(o, i, r), c = child_process.spawn(
|
|
726
|
-
a.command,
|
|
727
|
-
a.args,
|
|
728
|
-
a.options
|
|
729
|
-
);
|
|
730
|
-
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) {
|
|
731
|
-
let { stdout: u } = n.stdin.process;
|
|
732
|
-
u && u.pipe(c.stdin);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
_resetState() {
|
|
736
|
-
this._aborted = false, this._processClosed = new Promise((e) => {
|
|
737
|
-
this._resolveClose = e;
|
|
738
|
-
}), this._thrownError = void 0;
|
|
739
|
-
}
|
|
740
|
-
_onError = /* @__PURE__ */ __name$3((e) => {
|
|
741
|
-
if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
|
|
742
|
-
this._aborted = true;
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
|
-
this._thrownError = e;
|
|
746
|
-
}, "_onError");
|
|
747
|
-
_onClose = /* @__PURE__ */ __name$3(() => {
|
|
748
|
-
this._resolveClose && this._resolveClose();
|
|
749
|
-
}, "_onClose");
|
|
750
|
-
};
|
|
751
|
-
var ve = /* @__PURE__ */ __name$3((t, e, n) => {
|
|
752
|
-
let r = new R(t, e, n);
|
|
753
|
-
return r.spawn(), r;
|
|
754
|
-
}, "ve");
|
|
755
|
-
var be = ve;
|
|
756
|
-
|
|
757
|
-
var __defProp$2 = Object.defineProperty;
|
|
758
|
-
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
759
|
-
async function detectPackageManager(cwd = process__default.cwd()) {
|
|
760
|
-
const result = await detect({
|
|
761
|
-
cwd,
|
|
762
|
-
onUnknown(packageManager) {
|
|
763
|
-
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
|
764
|
-
return void 0;
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
return result?.agent || null;
|
|
768
|
-
}
|
|
769
|
-
__name$2(detectPackageManager, "detectPackageManager");
|
|
770
|
-
async function installPackage(names, options = {}) {
|
|
771
|
-
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
|
772
|
-
const [agent] = detectedAgent.split("@");
|
|
773
|
-
if (!Array.isArray(names))
|
|
774
|
-
names = [names];
|
|
775
|
-
const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
|
|
776
|
-
if (options.preferOffline) {
|
|
777
|
-
if (detectedAgent === "yarn@berry")
|
|
778
|
-
args.unshift("--cached");
|
|
779
|
-
else
|
|
780
|
-
args.unshift("--prefer-offline");
|
|
781
|
-
}
|
|
782
|
-
if (agent === "pnpm") {
|
|
783
|
-
args.unshift(
|
|
784
|
-
/**
|
|
785
|
-
* Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
|
|
786
|
-
* @see https://pnpm.io/cli/install#--prod--p
|
|
787
|
-
*/
|
|
788
|
-
"--prod=false"
|
|
789
|
-
);
|
|
790
|
-
if (node_fs.existsSync(path.resolve(options.cwd ?? process__default.cwd(), "pnpm-workspace.yaml"))) {
|
|
791
|
-
args.unshift("-w");
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
return ve(
|
|
795
|
-
agent,
|
|
796
|
-
[
|
|
797
|
-
agent === "yarn" ? "add" : "install",
|
|
798
|
-
options.dev ? "-D" : "",
|
|
799
|
-
...args,
|
|
800
|
-
...names
|
|
801
|
-
].filter(Boolean),
|
|
802
|
-
{
|
|
803
|
-
nodeOptions: {
|
|
804
|
-
stdio: options.silent ? "ignore" : "inherit",
|
|
805
|
-
cwd: options.cwd
|
|
806
|
-
},
|
|
807
|
-
throwOnError: true
|
|
808
|
-
}
|
|
809
|
-
);
|
|
810
|
-
}
|
|
811
|
-
__name$2(installPackage, "installPackage");
|
|
812
|
-
async function uninstallPackage(names, options = {}) {
|
|
813
|
-
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
|
814
|
-
const [agent] = detectedAgent.split("@");
|
|
815
|
-
if (!Array.isArray(names))
|
|
816
|
-
names = [names];
|
|
817
|
-
const args = options.additionalArgs || [];
|
|
818
|
-
if (agent === "pnpm" && node_fs.existsSync(path.resolve(options.cwd ?? process__default.cwd(), "pnpm-workspace.yaml")))
|
|
819
|
-
args.unshift("-w");
|
|
820
|
-
return ve(
|
|
821
|
-
agent,
|
|
822
|
-
[
|
|
823
|
-
agent === "yarn" ? "remove" : "uninstall",
|
|
824
|
-
options.dev ? "-D" : "",
|
|
825
|
-
...args,
|
|
826
|
-
...names
|
|
827
|
-
].filter(Boolean),
|
|
828
|
-
{
|
|
829
|
-
nodeOptions: {
|
|
830
|
-
stdio: options.silent ? "ignore" : "inherit",
|
|
831
|
-
cwd: options.cwd
|
|
832
|
-
},
|
|
833
|
-
throwOnError: true
|
|
834
|
-
}
|
|
835
|
-
);
|
|
836
|
-
}
|
|
837
|
-
__name$2(uninstallPackage, "uninstallPackage");
|
|
838
|
-
|
|
839
|
-
var __defProp$1 = Object.defineProperty;
|
|
840
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
841
|
-
const isObject = /* @__PURE__ */ __name$1((value) => {
|
|
842
|
-
const type = typeof value;
|
|
843
|
-
return value !== null && (type === "object" || type === "function");
|
|
844
|
-
}, "isObject");
|
|
845
|
-
const isEmptyObject = /* @__PURE__ */ __name$1((value) => isObject(value) && Object.keys(value).length === 0, "isEmptyObject");
|
|
846
|
-
const disallowedKeys = /* @__PURE__ */ new Set([
|
|
847
|
-
"__proto__",
|
|
848
|
-
"prototype",
|
|
849
|
-
"constructor"
|
|
850
|
-
]);
|
|
851
|
-
const digits = new Set("0123456789");
|
|
852
|
-
function getPathSegments(path) {
|
|
853
|
-
const parts = [];
|
|
854
|
-
let currentSegment = "";
|
|
855
|
-
let currentPart = "start";
|
|
856
|
-
let isIgnoring = false;
|
|
857
|
-
for (const character of path) {
|
|
858
|
-
switch (character) {
|
|
859
|
-
case "\\": {
|
|
860
|
-
if (currentPart === "index") {
|
|
861
|
-
throw new Error("Invalid character in an index");
|
|
862
|
-
}
|
|
863
|
-
if (currentPart === "indexEnd") {
|
|
864
|
-
throw new Error("Invalid character after an index");
|
|
865
|
-
}
|
|
866
|
-
if (isIgnoring) {
|
|
867
|
-
currentSegment += character;
|
|
868
|
-
}
|
|
869
|
-
currentPart = "property";
|
|
870
|
-
isIgnoring = !isIgnoring;
|
|
871
|
-
break;
|
|
872
|
-
}
|
|
873
|
-
case ".": {
|
|
874
|
-
if (currentPart === "index") {
|
|
875
|
-
throw new Error("Invalid character in an index");
|
|
876
|
-
}
|
|
877
|
-
if (currentPart === "indexEnd") {
|
|
878
|
-
currentPart = "property";
|
|
879
|
-
break;
|
|
880
|
-
}
|
|
881
|
-
if (isIgnoring) {
|
|
882
|
-
isIgnoring = false;
|
|
883
|
-
currentSegment += character;
|
|
884
|
-
break;
|
|
885
|
-
}
|
|
886
|
-
if (disallowedKeys.has(currentSegment)) {
|
|
887
|
-
return [];
|
|
888
|
-
}
|
|
889
|
-
parts.push(currentSegment);
|
|
890
|
-
currentSegment = "";
|
|
891
|
-
currentPart = "property";
|
|
892
|
-
break;
|
|
893
|
-
}
|
|
894
|
-
case "[": {
|
|
895
|
-
if (currentPart === "index") {
|
|
896
|
-
throw new Error("Invalid character in an index");
|
|
897
|
-
}
|
|
898
|
-
if (currentPart === "indexEnd") {
|
|
899
|
-
currentPart = "index";
|
|
900
|
-
break;
|
|
901
|
-
}
|
|
902
|
-
if (isIgnoring) {
|
|
903
|
-
isIgnoring = false;
|
|
904
|
-
currentSegment += character;
|
|
905
|
-
break;
|
|
906
|
-
}
|
|
907
|
-
if (currentPart === "property") {
|
|
908
|
-
if (disallowedKeys.has(currentSegment)) {
|
|
909
|
-
return [];
|
|
910
|
-
}
|
|
911
|
-
parts.push(currentSegment);
|
|
912
|
-
currentSegment = "";
|
|
913
|
-
}
|
|
914
|
-
currentPart = "index";
|
|
915
|
-
break;
|
|
916
|
-
}
|
|
917
|
-
case "]": {
|
|
918
|
-
if (currentPart === "index") {
|
|
919
|
-
parts.push(Number.parseInt(currentSegment, 10));
|
|
920
|
-
currentSegment = "";
|
|
921
|
-
currentPart = "indexEnd";
|
|
922
|
-
break;
|
|
923
|
-
}
|
|
924
|
-
if (currentPart === "indexEnd") {
|
|
925
|
-
throw new Error("Invalid character after an index");
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
default: {
|
|
929
|
-
if (currentPart === "index" && !digits.has(character)) {
|
|
930
|
-
throw new Error("Invalid character in an index");
|
|
931
|
-
}
|
|
932
|
-
if (currentPart === "indexEnd") {
|
|
933
|
-
throw new Error("Invalid character after an index");
|
|
934
|
-
}
|
|
935
|
-
if (currentPart === "start") {
|
|
936
|
-
currentPart = "property";
|
|
937
|
-
}
|
|
938
|
-
if (isIgnoring) {
|
|
939
|
-
isIgnoring = false;
|
|
940
|
-
currentSegment += "\\";
|
|
941
|
-
}
|
|
942
|
-
currentSegment += character;
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
if (isIgnoring) {
|
|
947
|
-
currentSegment += "\\";
|
|
948
|
-
}
|
|
949
|
-
switch (currentPart) {
|
|
950
|
-
case "property": {
|
|
951
|
-
if (disallowedKeys.has(currentSegment)) {
|
|
952
|
-
return [];
|
|
953
|
-
}
|
|
954
|
-
parts.push(currentSegment);
|
|
955
|
-
break;
|
|
956
|
-
}
|
|
957
|
-
case "index": {
|
|
958
|
-
throw new Error("Index was not closed");
|
|
959
|
-
}
|
|
960
|
-
case "start": {
|
|
961
|
-
parts.push("");
|
|
962
|
-
break;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
return parts;
|
|
966
|
-
}
|
|
967
|
-
__name$1(getPathSegments, "getPathSegments");
|
|
968
|
-
function isStringIndex(object, key) {
|
|
969
|
-
if (typeof key !== "number" && Array.isArray(object)) {
|
|
970
|
-
const index = Number.parseInt(key, 10);
|
|
971
|
-
return Number.isInteger(index) && object[index] === object[key];
|
|
972
|
-
}
|
|
973
|
-
return false;
|
|
974
|
-
}
|
|
975
|
-
__name$1(isStringIndex, "isStringIndex");
|
|
976
|
-
function assertNotStringIndex(object, key) {
|
|
977
|
-
if (isStringIndex(object, key)) {
|
|
978
|
-
throw new Error("Cannot use string index");
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
__name$1(assertNotStringIndex, "assertNotStringIndex");
|
|
982
|
-
function getProperty(object, path, value) {
|
|
983
|
-
if (!isObject(object) || typeof path !== "string") {
|
|
984
|
-
return value === void 0 ? object : value;
|
|
985
|
-
}
|
|
986
|
-
const pathArray = getPathSegments(path);
|
|
987
|
-
if (pathArray.length === 0) {
|
|
988
|
-
return value;
|
|
989
|
-
}
|
|
990
|
-
for (let index = 0; index < pathArray.length; index++) {
|
|
991
|
-
const key = pathArray[index];
|
|
992
|
-
if (isStringIndex(object, key)) {
|
|
993
|
-
object = index === pathArray.length - 1 ? void 0 : null;
|
|
994
|
-
} else {
|
|
995
|
-
object = object[key];
|
|
996
|
-
}
|
|
997
|
-
if (object === void 0 || object === null) {
|
|
998
|
-
if (index !== pathArray.length - 1) {
|
|
999
|
-
return value;
|
|
1000
|
-
}
|
|
1001
|
-
break;
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
return object === void 0 ? value : object;
|
|
1005
|
-
}
|
|
1006
|
-
__name$1(getProperty, "getProperty");
|
|
1007
|
-
function setProperty(object, path, value) {
|
|
1008
|
-
if (!isObject(object) || typeof path !== "string") {
|
|
1009
|
-
return object;
|
|
1010
|
-
}
|
|
1011
|
-
const root = object;
|
|
1012
|
-
const pathArray = getPathSegments(path);
|
|
1013
|
-
for (let index = 0; index < pathArray.length; index++) {
|
|
1014
|
-
const key = pathArray[index];
|
|
1015
|
-
assertNotStringIndex(object, key);
|
|
1016
|
-
if (index === pathArray.length - 1) {
|
|
1017
|
-
object[key] = value;
|
|
1018
|
-
} else if (!isObject(object[key])) {
|
|
1019
|
-
object[key] = typeof pathArray[index + 1] === "number" ? [] : {};
|
|
1020
|
-
}
|
|
1021
|
-
object = object[key];
|
|
1022
|
-
}
|
|
1023
|
-
return root;
|
|
1024
|
-
}
|
|
1025
|
-
__name$1(setProperty, "setProperty");
|
|
1026
|
-
function deleteProperty(object, path) {
|
|
1027
|
-
if (!isObject(object) || typeof path !== "string") {
|
|
1028
|
-
return false;
|
|
1029
|
-
}
|
|
1030
|
-
const pathArray = getPathSegments(path);
|
|
1031
|
-
for (let index = 0; index < pathArray.length; index++) {
|
|
1032
|
-
const key = pathArray[index];
|
|
1033
|
-
assertNotStringIndex(object, key);
|
|
1034
|
-
if (index === pathArray.length - 1) {
|
|
1035
|
-
delete object[key];
|
|
1036
|
-
return true;
|
|
1037
|
-
}
|
|
1038
|
-
object = object[key];
|
|
1039
|
-
if (!isObject(object)) {
|
|
1040
|
-
return false;
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
__name$1(deleteProperty, "deleteProperty");
|
|
1045
|
-
function hasProperty(object, path) {
|
|
1046
|
-
if (!isObject(object) || typeof path !== "string") {
|
|
1047
|
-
return false;
|
|
1048
|
-
}
|
|
1049
|
-
const pathArray = getPathSegments(path);
|
|
1050
|
-
if (pathArray.length === 0) {
|
|
1051
|
-
return false;
|
|
1052
|
-
}
|
|
1053
|
-
for (const key of pathArray) {
|
|
1054
|
-
if (!isObject(object) || !(key in object) || isStringIndex(object, key)) {
|
|
1055
|
-
return false;
|
|
1056
|
-
}
|
|
1057
|
-
object = object[key];
|
|
1058
|
-
}
|
|
1059
|
-
return true;
|
|
1060
|
-
}
|
|
1061
|
-
__name$1(hasProperty, "hasProperty");
|
|
1062
|
-
function escapePath(path) {
|
|
1063
|
-
if (typeof path !== "string") {
|
|
1064
|
-
throw new TypeError("Expected a string");
|
|
1065
|
-
}
|
|
1066
|
-
return path.replaceAll(/[\\.[]/g, "\\$&");
|
|
1067
|
-
}
|
|
1068
|
-
__name$1(escapePath, "escapePath");
|
|
1069
|
-
function entries(value) {
|
|
1070
|
-
const result = Object.entries(value);
|
|
1071
|
-
if (Array.isArray(value)) {
|
|
1072
|
-
return result.map(([key, value2]) => [Number(key), value2]);
|
|
1073
|
-
}
|
|
1074
|
-
return result;
|
|
1075
|
-
}
|
|
1076
|
-
__name$1(entries, "entries");
|
|
1077
|
-
function stringifyPath(pathSegments) {
|
|
1078
|
-
let result = "";
|
|
1079
|
-
for (let [index, segment] of entries(pathSegments)) {
|
|
1080
|
-
if (typeof segment === "number") {
|
|
1081
|
-
result += `[${segment}]`;
|
|
1082
|
-
} else {
|
|
1083
|
-
segment = escapePath(segment);
|
|
1084
|
-
result += index === 0 ? segment : `.${segment}`;
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
return result;
|
|
1088
|
-
}
|
|
1089
|
-
__name$1(stringifyPath, "stringifyPath");
|
|
1090
|
-
function* deepKeysIterator(object, currentPath = []) {
|
|
1091
|
-
if (!isObject(object) || isEmptyObject(object)) {
|
|
1092
|
-
if (currentPath.length > 0) {
|
|
1093
|
-
yield stringifyPath(currentPath);
|
|
1094
|
-
}
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
for (const [key, value] of entries(object)) {
|
|
1098
|
-
yield* deepKeysIterator(value, [...currentPath, key]);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
__name$1(deepKeysIterator, "deepKeysIterator");
|
|
1102
|
-
function deepKeys(object) {
|
|
1103
|
-
return [...deepKeysIterator(object)];
|
|
1104
|
-
}
|
|
1105
|
-
__name$1(deepKeys, "deepKeys");
|
|
1106
|
-
|
|
1107
|
-
const isNode = typeof process.stdout < "u" && !process.versions.deno && !globalThis.window;
|
|
1108
|
-
|
|
1109
|
-
var __defProp = Object.defineProperty;
|
|
1110
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1111
|
-
const PackageJsonFileCache = /* @__PURE__ */ new Map();
|
|
1112
|
-
class PackageJsonValidationError extends Error {
|
|
1113
|
-
static {
|
|
1114
|
-
__name(this, "PackageJsonValidationError");
|
|
1115
|
-
}
|
|
1116
|
-
constructor(warnings) {
|
|
1117
|
-
super(`The following warnings were encountered while normalizing package data:
|
|
1118
|
-
- ${warnings.join("\n- ")}`);
|
|
1119
|
-
this.name = "PackageJsonValidationError";
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
const normalizeInput = /* @__PURE__ */ __name((input, strict, ignoreWarnings = []) => {
|
|
1123
|
-
const warnings = [];
|
|
1124
|
-
normalizeData__default(
|
|
1125
|
-
input,
|
|
1126
|
-
(message) => {
|
|
1127
|
-
warnings.push(message);
|
|
1128
|
-
},
|
|
1129
|
-
strict
|
|
1130
|
-
);
|
|
1131
|
-
if (strict && warnings.length > 0) {
|
|
1132
|
-
const filteredWarnings = warnings.filter(
|
|
1133
|
-
(warning) => !ignoreWarnings.some((pattern) => {
|
|
1134
|
-
if (pattern instanceof RegExp) {
|
|
1135
|
-
return pattern.test(warning);
|
|
1136
|
-
}
|
|
1137
|
-
return pattern === warning;
|
|
1138
|
-
})
|
|
1139
|
-
);
|
|
1140
|
-
if (filteredWarnings.length > 0) {
|
|
1141
|
-
throw new PackageJsonValidationError(filteredWarnings);
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
return input;
|
|
1145
|
-
}, "normalizeInput");
|
|
1146
|
-
const findPackageJson = /* @__PURE__ */ __name(async (cwd, options = {}) => {
|
|
1147
|
-
const findUpConfig = {
|
|
1148
|
-
type: "file"
|
|
1149
|
-
};
|
|
1150
|
-
if (cwd) {
|
|
1151
|
-
findUpConfig.cwd = cwd;
|
|
1152
|
-
}
|
|
1153
|
-
const filePath = await fs$1.findUp("package.json", findUpConfig);
|
|
1154
|
-
if (!filePath) {
|
|
1155
|
-
throw new error.NotFoundError("No such file or directory, for package.json found.");
|
|
1156
|
-
}
|
|
1157
|
-
const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
|
|
1158
|
-
if (options.cache && cache.has(filePath)) {
|
|
1159
|
-
return cache.get(filePath);
|
|
1160
|
-
}
|
|
1161
|
-
const packageJson = await fs$1.readJson(filePath);
|
|
1162
|
-
normalizeInput(packageJson, options.strict ?? false, options.ignoreWarnings);
|
|
1163
|
-
const output = {
|
|
1164
|
-
packageJson,
|
|
1165
|
-
path: filePath
|
|
1166
|
-
};
|
|
1167
|
-
cache.set(filePath, output);
|
|
1168
|
-
return output;
|
|
1169
|
-
}, "findPackageJson");
|
|
1170
|
-
const findPackageJsonSync = /* @__PURE__ */ __name((cwd, options = {}) => {
|
|
1171
|
-
const findUpConfig = {
|
|
1172
|
-
type: "file"
|
|
1173
|
-
};
|
|
1174
|
-
if (cwd) {
|
|
1175
|
-
findUpConfig.cwd = cwd;
|
|
1176
|
-
}
|
|
1177
|
-
const filePath = fs$1.findUpSync("package.json", findUpConfig);
|
|
1178
|
-
if (!filePath) {
|
|
1179
|
-
throw new error.NotFoundError("No such file or directory, for package.json found.");
|
|
1180
|
-
}
|
|
1181
|
-
const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
|
|
1182
|
-
if (options.cache && cache.has(filePath)) {
|
|
1183
|
-
return cache.get(filePath);
|
|
1184
|
-
}
|
|
1185
|
-
const packageJson = fs$1.readJsonSync(filePath);
|
|
1186
|
-
normalizeInput(packageJson, options.strict ?? false, options.ignoreWarnings);
|
|
1187
|
-
const output = {
|
|
1188
|
-
packageJson,
|
|
1189
|
-
path: filePath
|
|
1190
|
-
};
|
|
1191
|
-
cache.set(filePath, output);
|
|
1192
|
-
return output;
|
|
1193
|
-
}, "findPackageJsonSync");
|
|
1194
|
-
const writePackageJson = /* @__PURE__ */ __name(async (data, options = {}) => {
|
|
1195
|
-
const { cwd, ...writeOptions } = options;
|
|
1196
|
-
const directory = utils.toPath(options.cwd ?? process.cwd());
|
|
1197
|
-
await fs$1.writeJson(path$2.join(directory, "package.json"), data, writeOptions);
|
|
1198
|
-
}, "writePackageJson");
|
|
1199
|
-
const writePackageJsonSync = /* @__PURE__ */ __name((data, options = {}) => {
|
|
1200
|
-
const { cwd, ...writeOptions } = options;
|
|
1201
|
-
const directory = utils.toPath(options.cwd ?? process.cwd());
|
|
1202
|
-
fs$1.writeJsonSync(path$2.join(directory, "package.json"), data, writeOptions);
|
|
1203
|
-
}, "writePackageJsonSync");
|
|
1204
|
-
const parsePackageJson = /* @__PURE__ */ __name((packageFile, options) => {
|
|
1205
|
-
const isObject = packageFile !== null && typeof packageFile === "object" && !Array.isArray(packageFile);
|
|
1206
|
-
const isString = typeof packageFile === "string";
|
|
1207
|
-
if (!isObject && !isString) {
|
|
1208
|
-
throw new TypeError("`packageFile` should be either an `object` or a `string`.");
|
|
1209
|
-
}
|
|
1210
|
-
const json = isObject ? structuredClone(packageFile) : (
|
|
1211
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
1212
|
-
node_fs.existsSync(packageFile) ? fs$1.readJsonSync(packageFile) : utils.parseJson(packageFile)
|
|
1213
|
-
);
|
|
1214
|
-
normalizeInput(json, options?.strict ?? false, options?.ignoreWarnings);
|
|
1215
|
-
return json;
|
|
1216
|
-
}, "parsePackageJson");
|
|
1217
|
-
const getPackageJsonProperty = /* @__PURE__ */ __name((packageJson, property, defaultValue) => getProperty(packageJson, property, defaultValue), "getPackageJsonProperty");
|
|
1218
|
-
const hasPackageJsonProperty = /* @__PURE__ */ __name((packageJson, property) => hasProperty(packageJson, property), "hasPackageJsonProperty");
|
|
1219
|
-
const hasPackageJsonAnyDependency = /* @__PURE__ */ __name((packageJson, arguments_, options) => {
|
|
1220
|
-
const dependencies = getProperty(packageJson, "dependencies", {});
|
|
1221
|
-
const devDependencies = getProperty(packageJson, "devDependencies", {});
|
|
1222
|
-
const peerDependencies = getProperty(packageJson, "peerDependencies", {});
|
|
1223
|
-
const allDependencies = { ...dependencies, ...devDependencies, ...options?.peerDeps === false ? {} : peerDependencies };
|
|
1224
|
-
for (const argument of arguments_) {
|
|
1225
|
-
if (hasProperty(allDependencies, argument)) {
|
|
1226
|
-
return true;
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
return false;
|
|
1230
|
-
}, "hasPackageJsonAnyDependency");
|
|
1231
|
-
const ensurePackages = /* @__PURE__ */ __name(async (packageJson, packages, installKey = "dependencies", options = {}) => {
|
|
1232
|
-
if (process.env.CI || isNode && !process.stdout?.isTTY) {
|
|
1233
|
-
console.warn("Skipping package installation because the process is not interactive.");
|
|
1234
|
-
return;
|
|
1235
|
-
}
|
|
1236
|
-
const dependencies = getProperty(packageJson, "dependencies", {});
|
|
1237
|
-
const devDependencies = getProperty(packageJson, "devDependencies", {});
|
|
1238
|
-
const peerDependencies = getProperty(packageJson, "peerDependencies", {});
|
|
1239
|
-
const nonExistingPackages = [];
|
|
1240
|
-
const config = {
|
|
1241
|
-
deps: true,
|
|
1242
|
-
devDeps: true,
|
|
1243
|
-
peerDeps: false,
|
|
1244
|
-
...options
|
|
1245
|
-
};
|
|
1246
|
-
for (const packageName of packages) {
|
|
1247
|
-
if (config.deps && hasProperty(dependencies, packageName) || config.devDeps && hasProperty(devDependencies, packageName) || config.peerDeps && hasProperty(peerDependencies, packageName)) {
|
|
1248
|
-
continue;
|
|
1249
|
-
}
|
|
1250
|
-
nonExistingPackages.push(packageName);
|
|
1251
|
-
}
|
|
1252
|
-
if (nonExistingPackages.length === 0) {
|
|
1253
|
-
return;
|
|
1254
|
-
}
|
|
1255
|
-
if (typeof config.confirm?.message === "function") {
|
|
1256
|
-
config.confirm.message = config.confirm.message(nonExistingPackages);
|
|
1257
|
-
}
|
|
1258
|
-
if (config.confirm?.message === void 0) {
|
|
1259
|
-
const message = `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`;
|
|
1260
|
-
if (config.confirm === void 0) {
|
|
1261
|
-
config.confirm = {
|
|
1262
|
-
message
|
|
1263
|
-
};
|
|
1264
|
-
} else {
|
|
1265
|
-
config.confirm.message = message;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
const answer = await confirm__default(config.confirm);
|
|
1269
|
-
if (!answer) {
|
|
1270
|
-
return;
|
|
1271
|
-
}
|
|
1272
|
-
await installPackage(nonExistingPackages, {
|
|
1273
|
-
...config.installPackage,
|
|
1274
|
-
cwd: config.cwd ? utils.toPath(config.cwd) : void 0,
|
|
1275
|
-
dev: installKey === "devDependencies"
|
|
1276
|
-
});
|
|
1277
|
-
}, "ensurePackages");
|
|
1278
|
-
|
|
1279
|
-
exports.ensurePackages = ensurePackages;
|
|
1280
|
-
exports.findPackageJson = findPackageJson;
|
|
1281
|
-
exports.findPackageJsonSync = findPackageJsonSync;
|
|
1282
|
-
exports.getPackageJsonProperty = getPackageJsonProperty;
|
|
1283
|
-
exports.hasPackageJsonAnyDependency = hasPackageJsonAnyDependency;
|
|
1284
|
-
exports.hasPackageJsonProperty = hasPackageJsonProperty;
|
|
1285
|
-
exports.parsePackageJson = parsePackageJson;
|
|
1286
|
-
exports.writePackageJson = writePackageJson;
|
|
1287
|
-
exports.writePackageJsonSync = writePackageJsonSync;
|
|
1
|
+
"use strict";var Oe=Object.defineProperty;var l=(e,t)=>Oe(e,"name",{value:t,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const B=require("node:fs"),Se=require("node:process"),Ce=require("node:fs/promises"),X=require("node:path"),Je=require("node:module"),Ae=require("child_process"),q=require("path"),Ne=require("process"),Te=require("stream"),De=require("readline"),Ie=require("@inquirer/confirm"),N=require("@visulima/fs"),ce=require("@visulima/fs/error"),H=require("@visulima/fs/utils"),le=require("@visulima/path"),Me=require("normalize-package-data");var z=typeof document<"u"?document.currentScript:null;const M=l(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),F=M(Se),ue=M(Ce),O=M(X),qe=M(De),Fe=M(Ie),Ue=M(Me),pe=["npm","yarn","yarn@berry","pnpm","pnpm@6","bun","deno"],oe={"bun.lock":"bun","bun.lockb":"bun","deno.lock":"deno","pnpm-lock.yaml":"pnpm","pnpm-workspace.yaml":"pnpm","yarn.lock":"yarn","package-lock.json":"npm","npm-shrinkwrap.json":"npm"},se={"node_modules/.deno/":"deno","node_modules/.pnpm/":"pnpm","node_modules/.yarn-state.yml":"yarn","node_modules/.yarn_integrity":"yarn","node_modules/.package-lock.json":"npm",".pnp.cjs":"yarn",".pnp.js":"yarn","bun.lock":"bun","bun.lockb":"bun"};var Le=Object.defineProperty,P=l((e,t)=>Le(e,"name",{value:t,configurable:!0}),"i$1");async function L(e,t){try{const n=await ue.stat(e);return t==="file"?n.isFile():n.isDirectory()}catch{return!1}}l(L,"g$2");P(L,"pathExists");function He(){const e=F.env.npm_config_user_agent;if(!e)return null;const t=e.split("/")[0];return pe.includes(t)?t:null}l(He,"M$1");P(He,"getUserAgent");function*fe(e=F.cwd()){let t=O.resolve(e);const{root:n}=O.parse(t);for(;t&&t!==n;)yield t,t=O.dirname(t)}l(fe,"h$2");P(fe,"lookup");async function Y(e,t){return!e||!L(e,"file")?null:await ge(e,t)}l(Y,"m");P(Y,"parsePackageJson");async function de(e={}){const{cwd:t,strategies:n=["lockfile","packageManager-field","devEngines-field"],onUnknown:r}=e;let o;if(typeof e.stopDir=="string"){const a=O.resolve(e.stopDir);o=P(i=>i===a,"stopDir")}else o=e.stopDir;for(const a of fe(t)){for(const i of n)switch(i){case"lockfile":{for(const s of Object.keys(oe))if(await L(O.join(a,s),"file")){const c=oe[s];return await Y(O.join(a,"package.json"),r)||{name:c,agent:c}}break}case"packageManager-field":case"devEngines-field":{const s=await Y(O.join(a,"package.json"),r);if(s)return s;break}case"install-metadata":{for(const s of Object.keys(se)){const c=s.endsWith("/")?"dir":"file";if(await L(O.join(a,s),c)){const p=se[s],u=p==="yarn"?ye(s)?"yarn":"yarn@berry":p;return{name:p,agent:u}}}break}}if(o?.(a))break}return null}l(de,"A");P(de,"detect");function he(e){const t=P(n=>n?.match(/\d+(\.\d+){0,2}/)?.[0]??n,"handelVer");if(typeof e.packageManager=="string"){const[n,r]=e.packageManager.replace(/^\^/,"").split("@");return{name:n,ver:t(r)}}if(typeof e.devEngines?.packageManager?.name=="string")return{name:e.devEngines.packageManager.name,ver:t(e.devEngines.packageManager.version)}}l(he,"j$1");P(he,"getNameAndVer");async function ge(e,t){try{const n=JSON.parse(await ue.readFile(e,"utf8"));let r;const o=he(n);if(o){const a=o.name,i=o.ver;let s=i;return a==="yarn"&&i&&Number.parseInt(i)>1?(r="yarn@berry",s="berry",{name:a,agent:r,version:s}):a==="pnpm"&&i&&Number.parseInt(i)<7?(r="pnpm@6",{name:a,agent:r,version:s}):pe.includes(a)?(r=a,{name:a,agent:r,version:s}):t?.(n.packageManager)??null}}catch{}return null}l(ge,"E$1");P(ge,"handlePackageManager");function ye(e){return e.endsWith(".yarn_integrity")}l(ye,"D$1");P(ye,"isMetadataYarnClassic");var We=Object.defineProperty,f=l((e,t)=>We(e,"name",{value:t,configurable:!0}),"l$2");const D=Je.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:z&&z.tagName.toUpperCase()==="SCRIPT"&&z.src||new URL("package-json.cjs",document.baseURI).href);var Re=Object.create,me=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,ze=Object.getOwnPropertyNames,Ke=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty,C=(e=>typeof D<"u"?D:typeof Proxy<"u"?new Proxy(e,{get:f((t,n)=>(typeof D<"u"?D:t)[n],"get")}):e)(function(e){if(typeof D<"u")return D.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),k=f((e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),"l"),Be=f((e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ze(t))!Ye.call(e,o)&&o!==n&&me(e,o,{get:f(()=>t[o],"get"),enumerable:!(r=Ve(t,o))||r.enumerable});return e},"$t"),Xe=f((e,t,n)=>(n=e!=null?Re(Ke(e)):{},Be(t||!e||!e.__esModule?me(n,"default",{value:e,enumerable:!0}):n,e)),"Nt"),Ge=k((e,t)=>{t.exports=a,a.sync=i;var n=C("fs");function r(s,c){var p=c.pathExt!==void 0?c.pathExt:process.env.PATHEXT;if(!p||(p=p.split(";"),p.indexOf("")!==-1))return!0;for(var u=0;u<p.length;u++){var h=p[u].toLowerCase();if(h&&s.substr(-h.length).toLowerCase()===h)return!0}return!1}l(r,"o"),f(r,"Ht");function o(s,c,p){return!s.isSymbolicLink()&&!s.isFile()?!1:r(c,p)}l(o,"i"),f(o,"F");function a(s,c,p){n.stat(s,function(u,h){p(u,u?!1:o(h,s,c))})}l(a,"u"),f(a,"z");function i(s,c){return o(n.statSync(s),s,c)}l(i,"d"),f(i,"Wt")}),Qe=k((e,t)=>{t.exports=r,r.sync=o;var n=C("fs");function r(s,c,p){n.stat(s,function(u,h){p(u,u?!1:a(h,c))})}l(r,"o"),f(r,"K");function o(s,c){return a(n.statSync(s),c)}l(o,"i"),f(o,"Dt");function a(s,c){return s.isFile()&&i(s,c)}l(a,"u"),f(a,"M");function i(s,c){var p=s.mode,u=s.uid,h=s.gid,d=c.uid!==void 0?c.uid:process.getuid&&process.getuid(),g=c.gid!==void 0?c.gid:process.getgid&&process.getgid(),y=parseInt("100",8),m=parseInt("010",8),_=parseInt("001",8),E=y|m,J=p&_||p&m&&h===g||p&y&&u===d||p&E&&d===0;return J}l(i,"d"),f(i,"Kt")}),Ze=k((e,t)=>{C("fs");var n;process.platform==="win32"||global.TESTING_WINDOWS?n=Ge():n=Qe(),t.exports=r,r.sync=o;function r(a,i,s){if(typeof i=="function"&&(s=i,i={}),!s){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(c,p){r(a,i||{},function(u,h){u?p(u):c(h)})})}n(a,i||{},function(c,p){c&&(c.code==="EACCES"||i&&i.ignoreErrors)&&(c=null,p=!1),s(c,p)})}l(r,"i"),f(r,"y");function o(a,i){try{return n.sync(a,i||{})}catch(s){if(i&&i.ignoreErrors||s.code==="EACCES")return!1;throw s}}l(o,"u"),f(o,"Mt")}),et=k((e,t)=>{var n=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",r=C("path"),o=n?";":":",a=Ze(),i=f(u=>Object.assign(new Error(`not found: ${u}`),{code:"ENOENT"}),"J"),s=f((u,h)=>{let d=h.colon||o,g=u.match(/\//)||n&&u.match(/\\/)?[""]:[...n?[process.cwd()]:[],...(h.path||process.env.PATH||"").split(d)],y=n?h.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",m=n?y.split(d):[""];return n&&u.indexOf(".")!==-1&&m[0]!==""&&m.unshift(""),{pathEnv:g,pathExt:m,pathExtExe:y}},"Q"),c=f((u,h,d)=>{typeof h=="function"&&(d=h,h={}),h||(h={});let{pathEnv:g,pathExt:y,pathExtExe:m}=s(u,h),_=[],E=f(v=>new Promise((A,$)=>{if(v===g.length)return h.all&&_.length?A(_):$(i(u));let b=g[v],R=/^".*"$/.test(b)?b.slice(1,-1):b,T=r.join(R,u),V=!R&&/^\.[\\\/]/.test(u)?u.slice(0,2)+T:T;A(J(V,v,0))}),"a"),J=f((v,A,$)=>new Promise((b,R)=>{if($===y.length)return b(E(A+1));let T=y[$];a(v+T,{pathExt:m},(V,je)=>{if(!V&&je)if(h.all)_.push(v+T);else return b(v+T);return b(J(v,A,$+1))})}),"c");return d?E(0).then(v=>d(null,v),d):E(0)},"Z"),p=f((u,h)=>{h=h||{};let{pathEnv:d,pathExt:g,pathExtExe:y}=s(u,h),m=[];for(let _=0;_<d.length;_++){let E=d[_],J=/^".*"$/.test(E)?E.slice(1,-1):E,v=r.join(J,u),A=!J&&/^\.[\\\/]/.test(u)?u.slice(0,2)+v:v;for(let $=0;$<g.length;$++){let b=A+g[$];try{if(a.sync(b,{pathExt:y}))if(h.all)m.push(b);else return b}catch{}}}if(h.all&&m.length)return m;if(h.nothrow)return null;throw i(u)},"Xt");t.exports=c,c.sync=p}),tt=k((e,t)=>{var n=f((r={})=>{let o=r.env||process.env;return(r.platform||process.platform)!=="win32"?"PATH":Object.keys(o).reverse().find(a=>a.toUpperCase()==="PATH")||"Path"},"nt");t.exports=n,t.exports.default=n}),rt=k((e,t)=>{var n=C("path"),r=et(),o=tt();function a(s,c){let p=s.options.env||process.env,u=process.cwd(),h=s.options.cwd!=null,d=h&&process.chdir!==void 0&&!process.chdir.disabled;if(d)try{process.chdir(s.options.cwd)}catch{}let g;try{g=r.sync(s.command,{path:p[o({env:p})],pathExt:c?n.delimiter:void 0})}catch{}finally{d&&process.chdir(u)}return g&&(g=n.resolve(h?s.options.cwd:"",g)),g}l(a,"u"),f(a,"ot");function i(s){return a(s)||a(s,!0)}l(i,"d"),f(i,"Yt"),t.exports=i}),nt=k((e,t)=>{var n=/([()\][%!^"`<>&|;, *?])/g;function r(a){return a=a.replace(n,"^$1"),a}l(r,"o"),f(r,"Vt");function o(a,i){return a=`${a}`,a=a.replace(/(\\*)"/g,'$1$1\\"'),a=a.replace(/(\\*)$/,"$1$1"),a=`"${a}"`,a=a.replace(n,"^$1"),i&&(a=a.replace(n,"^$1")),a}l(o,"i"),f(o,"Jt"),t.exports.command=r,t.exports.argument=o}),ot=k((e,t)=>{t.exports=/^#!(.*)/}),st=k((e,t)=>{var n=ot();t.exports=(r="")=>{let o=r.match(n);if(!o)return null;let[a,i]=o[0].replace(/#! ?/,"").split(" "),s=a.split("/").pop();return s==="env"?i:i?`${s} ${i}`:s}}),at=k((e,t)=>{var n=C("fs"),r=st();function o(a){let i=Buffer.alloc(150),s;try{s=n.openSync(a,"r"),n.readSync(s,i,0,150,0),n.closeSync(s)}catch{}return r(i.toString())}l(o,"i"),f(o,"te"),t.exports=o}),it=k((e,t)=>{var n=C("path"),r=rt(),o=nt(),a=at(),i=process.platform==="win32",s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function p(d){d.file=r(d);let g=d.file&&a(d.file);return g?(d.args.unshift(d.file),d.command=g,r(d)):d.file}l(p,"h"),f(p,"ie");function u(d){if(!i)return d;let g=p(d),y=!s.test(g);if(d.options.forceShell||y){let m=c.test(g);d.command=n.normalize(d.command),d.command=o.command(d.command),d.args=d.args.map(E=>o.argument(E,m));let _=[d.command].concat(d.args).join(" ");d.args=["/d","/s","/c",`"${_}"`],d.command=process.env.comspec||"cmd.exe",d.options.windowsVerbatimArguments=!0}return d}l(u,"a"),f(u,"ce");function h(d,g,y){g&&!Array.isArray(g)&&(y=g,g=null),g=g?g.slice(0):[],y=Object.assign({},y);let m={command:d,args:g,options:y,file:void 0,original:{command:d,args:g}};return y.shell?m:u(m)}l(h,"p"),f(h,"ue"),t.exports=h}),ct=k((e,t)=>{var n=process.platform==="win32";function r(s,c){return Object.assign(new Error(`${c} ${s.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${c} ${s.command}`,path:s.command,spawnargs:s.args})}l(r,"o"),f(r,"k");function o(s,c){if(!n)return;let p=s.emit;s.emit=function(u,h){if(u==="exit"){let d=a(h,c);if(d)return p.call(s,"error",d)}return p.apply(s,arguments)}}l(o,"i"),f(o,"ae");function a(s,c){return n&&s===1&&!c.file?r(c.original,"spawn"):null}l(a,"u"),f(a,"xt");function i(s,c){return n&&s===1&&!c.file?r(c.original,"spawnSync"):null}l(i,"d"),f(i,"le"),t.exports={hookChildProcess:o,verifyENOENT:a,verifyENOENTSync:i,notFoundError:r}}),lt=k((e,t)=>{var n=C("child_process"),r=it(),o=ct();function a(s,c,p){let u=r(s,c,p),h=n.spawn(u.command,u.args,u.options);return o.hookChildProcess(h,u),h}l(a,"u"),f(a,"_t");function i(s,c,p){let u=r(s,c,p),h=n.spawnSync(u.command,u.args,u.options);return h.error=h.error||o.verifyENOENTSync(h.status,u),h}l(i,"d"),f(i,"pe"),t.exports=a,t.exports.spawn=a,t.exports.sync=i,t.exports._parse=r,t.exports._enoent=o}),ut=/^path$/i,ae={key:"PATH",value:""};function we(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!ut.test(t))continue;let n=e[t];return n?{key:t,value:n}:ae}return ae}l(we,"hr");f(we,"jt");function ve(e,t){let n=t.value.split(q.delimiter),r=e,o;do n.push(q.resolve(r,"node_modules",".bin")),o=r,r=q.dirname(r);while(r!==o);return{key:t.key,value:n.join(q.delimiter)}}l(ve,"dr");f(ve,"Ft");function ke(e,t){let n={...process.env,...t},r=ve(e,we(n));return n[r.key]=r.value,n}l(ke,"fr");f(ke,"I");var pt=f(e=>{let t=e.length,n=new Te.PassThrough,r=f(()=>{--t===0&&n.emit("end")},"r");for(let o of e)o.pipe(n,{end:!1}),o.on("end",r);return n},"L"),ft=Xe(lt(),1),ie=class extends Error{static{l(this,"N")}static{f(this,"x")}result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}},dt={timeout:void 0,persist:!1},ht={windowsHide:!0};function _e(e,t){return{command:q.normalize(e),args:t??[]}}l(_e,"yr");f(_e,"we");function Ee(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;let r=f(()=>{t.abort(n.reason)},"r");n.addEventListener("abort",r,{signal:t.signal})}return t.signal}l(Ee,"xr");f(Ee,"xe");var gt=class{static{l(this,"I")}static{f(this,"R")}_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,t,n){this._options={...dt,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(r=>{this._resolveClose=r})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return yt(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=pt(t),r=qe.createInterface({input:n});for await(let o of r)yield o.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 ie(this)}async _waitForOutput(){let e=this._process;if(!e)throw new Error("No process was started");let t="",n="";if(this._streamOut)for await(let o of this._streamOut)n+=o.toString();if(this._streamErr)for await(let o of this._streamErr)t+=o.toString();if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let r={stderr:t,stdout:n,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new ie(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=Ne.cwd(),t=this._options,n={...ht,...t.nodeOptions},r=[];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=Ee(r)),n.env=ke(e,n.env);let{command:o,args:a}=_e(this._command,this._args),i=(0,ft._parse)(o,a,n),s=Ae.spawn(i.command,i.args,i.options);if(s.stderr&&(this._streamErr=s.stderr),s.stdout&&(this._streamOut=s.stdout),this._process=s,s.once("error",this._onError),s.once("close",this._onClose),t.stdin!==void 0&&s.stdin&&t.stdin.process){let{stdout:c}=t.stdin.process;c&&c.pipe(s.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=f(e=>{if(e.name==="AbortError"&&(!(e.cause instanceof Error)||e.cause.name!=="TimeoutError")){this._aborted=!0;return}this._thrownError=e},"_onError");_onClose=f(()=>{this._resolveClose&&this._resolveClose()},"_onClose")},G=f((e,t,n)=>{let r=new gt(e,t,n);return r.spawn(),r},"ve"),yt=G,mt=Object.defineProperty,Q=l((e,t)=>mt(e,"name",{value:t,configurable:!0}),"i");async function Z(e=F.cwd()){return(await de({cwd:e,onUnknown(t){console.warn("[@antfu/install-pkg] Unknown packageManager:",t)}}))?.agent||null}l(Z,"c$2");Q(Z,"detectPackageManager");async function be(e,t={}){const n=t.packageManager||await Z(t.cwd)||"npm",[r]=n.split("@");Array.isArray(e)||(e=[e]);const o=(typeof t.additionalArgs=="function"?t.additionalArgs(r,n):t.additionalArgs)||[];return t.preferOffline&&(n==="yarn@berry"?o.unshift("--cached"):o.unshift("--prefer-offline")),r==="pnpm"&&(o.unshift("--prod=false"),B.existsSync(X.resolve(t.cwd??F.cwd(),"pnpm-workspace.yaml"))&&o.unshift("-w")),G(r,[r==="yarn"?"add":"install",t.dev?"-D":"",...o,...e].filter(Boolean),{nodeOptions:{stdio:t.silent?"ignore":"inherit",cwd:t.cwd},throwOnError:!0})}l(be,"p$1");Q(be,"installPackage");async function wt(e,t={}){const n=t.packageManager||await Z(t.cwd)||"npm",[r]=n.split("@");Array.isArray(e)||(e=[e]);const o=t.additionalArgs||[];return r==="pnpm"&&B.existsSync(X.resolve(t.cwd??F.cwd(),"pnpm-workspace.yaml"))&&o.unshift("-w"),G(r,[r==="yarn"?"remove":"uninstall",t.dev?"-D":"",...o,...e].filter(Boolean),{nodeOptions:{stdio:t.silent?"ignore":"inherit",cwd:t.cwd},throwOnError:!0})}l(wt,"h$1");Q(wt,"uninstallPackage");var vt=Object.defineProperty,w=l((e,t)=>vt(e,"name",{value:t,configurable:!0}),"s");const j=w(e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},"isObject"),kt=w(e=>j(e)&&Object.keys(e).length===0,"isEmptyObject"),K=new Set(["__proto__","prototype","constructor"]),_t=new Set("0123456789");function U(e){const t=[];let n="",r="start",o=!1;for(const a of e)switch(a){case"\\":{if(r==="index")throw new Error("Invalid character in an index");if(r==="indexEnd")throw new Error("Invalid character after an index");o&&(n+=a),r="property",o=!o;break}case".":{if(r==="index")throw new Error("Invalid character in an index");if(r==="indexEnd"){r="property";break}if(o){o=!1,n+=a;break}if(K.has(n))return[];t.push(n),n="",r="property";break}case"[":{if(r==="index")throw new Error("Invalid character in an index");if(r==="indexEnd"){r="index";break}if(o){o=!1,n+=a;break}if(r==="property"){if(K.has(n))return[];t.push(n),n=""}r="index";break}case"]":{if(r==="index"){t.push(Number.parseInt(n,10)),n="",r="indexEnd";break}if(r==="indexEnd")throw new Error("Invalid character after an index")}default:{if(r==="index"&&!_t.has(a))throw new Error("Invalid character in an index");if(r==="indexEnd")throw new Error("Invalid character after an index");r==="start"&&(r="property"),o&&(o=!1,n+="\\"),n+=a}}switch(o&&(n+="\\"),r){case"property":{if(K.has(n))return[];t.push(n);break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}l(U,"d");w(U,"getPathSegments");function W(e,t){if(typeof t!="number"&&Array.isArray(e)){const n=Number.parseInt(t,10);return Number.isInteger(n)&&e[n]===e[t]}return!1}l(W,"l$1");w(W,"isStringIndex");function ee(e,t){if(W(e,t))throw new Error("Cannot use string index")}l(ee,"p");w(ee,"assertNotStringIndex");function S(e,t,n){if(!j(e)||typeof t!="string")return n===void 0?e:n;const r=U(t);if(r.length===0)return n;for(let o=0;o<r.length;o++){const a=r[o];if(W(e,a)?e=o===r.length-1?void 0:null:e=e[a],e==null){if(o!==r.length-1)return n;break}}return e===void 0?n:e}l(S,"getProperty");w(S,"getProperty");function Et(e,t,n){if(!j(e)||typeof t!="string")return e;const r=e,o=U(t);for(let a=0;a<o.length;a++){const i=o[a];ee(e,i),a===o.length-1?e[i]=n:j(e[i])||(e[i]=typeof o[a+1]=="number"?[]:{}),e=e[i]}return r}l(Et,"setProperty");w(Et,"setProperty");function bt(e,t){if(!j(e)||typeof t!="string")return!1;const n=U(t);for(let r=0;r<n.length;r++){const o=n[r];if(ee(e,o),r===n.length-1)return delete e[o],!0;if(e=e[o],!j(e))return!1}}l(bt,"deleteProperty");w(bt,"deleteProperty");function I(e,t){if(!j(e)||typeof t!="string")return!1;const n=U(t);if(n.length===0)return!1;for(const r of n){if(!j(e)||!(r in e)||W(e,r))return!1;e=e[r]}return!0}l(I,"hasProperty");w(I,"hasProperty");function xe(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replaceAll(/[\\.[]/g,"\\$&")}l(xe,"escapePath");w(xe,"escapePath");function te(e){const t=Object.entries(e);return Array.isArray(e)?t.map(([n,r])=>[Number(n),r]):t}l(te,"h");w(te,"entries");function Pe(e){let t="";for(let[n,r]of te(e))typeof r=="number"?t+=`[${r}]`:(r=xe(r),t+=n===0?r:`.${r}`);return t}l(Pe,"w");w(Pe,"stringifyPath");function*re(e,t=[]){if(!j(e)||kt(e)){t.length>0&&(yield Pe(t));return}for(const[n,r]of te(e))yield*re(r,[...t,n])}l(re,"y");w(re,"deepKeysIterator");function xt(e){return[...re(e)]}l(xt,"deepKeys");w(xt,"deepKeys");const Pt=typeof process.stdout<"u"&&!process.versions.deno&&!globalThis.window;var $t=Object.defineProperty,x=l((e,t)=>$t(e,"name",{value:t,configurable:!0}),"c");const $e=new Map;class jt extends Error{static{l(this,"E")}static{x(this,"PackageJsonValidationError")}constructor(t){super(`The following warnings were encountered while normalizing package data:
|
|
2
|
+
- ${t.join(`
|
|
3
|
+
- `)}`),this.name="PackageJsonValidationError"}}const ne=x((e,t,n=[])=>{const r=[];if(Ue(e,o=>{r.push(o)},t),t&&r.length>0){const o=r.filter(a=>!n.some(i=>i instanceof RegExp?i.test(a):i===a));if(o.length>0)throw new jt(o)}return e},"normalizeInput"),Ot=x(async(e,t={})=>{const n={type:"file"};e&&(n.cwd=e);const r=await N.findUp("package.json",n);if(!r)throw new ce.NotFoundError("No such file or directory, for package.json found.");const o=t.cache&&typeof t.cache!="boolean"?t.cache:$e;if(t.cache&&o.has(r))return o.get(r);const a=await N.readJson(r);ne(a,t.strict??!1,t.ignoreWarnings);const i={packageJson:a,path:r};return o.set(r,i),i},"findPackageJson"),St=x((e,t={})=>{const n={type:"file"};e&&(n.cwd=e);const r=N.findUpSync("package.json",n);if(!r)throw new ce.NotFoundError("No such file or directory, for package.json found.");const o=t.cache&&typeof t.cache!="boolean"?t.cache:$e;if(t.cache&&o.has(r))return o.get(r);const a=N.readJsonSync(r);ne(a,t.strict??!1,t.ignoreWarnings);const i={packageJson:a,path:r};return o.set(r,i),i},"findPackageJsonSync"),Ct=x(async(e,t={})=>{const{cwd:n,...r}=t,o=H.toPath(t.cwd??process.cwd());await N.writeJson(le.join(o,"package.json"),e,r)},"writePackageJson"),Jt=x((e,t={})=>{const{cwd:n,...r}=t,o=H.toPath(t.cwd??process.cwd());N.writeJsonSync(le.join(o,"package.json"),e,r)},"writePackageJsonSync"),At=x((e,t)=>{const n=e!==null&&typeof e=="object"&&!Array.isArray(e);if(!n&&typeof e!="string")throw new TypeError("`packageFile` should be either an `object` or a `string`.");const r=n?structuredClone(e):B.existsSync(e)?N.readJsonSync(e):H.parseJson(e);return ne(r,t?.strict??!1,t?.ignoreWarnings),r},"parsePackageJson"),Nt=x((e,t,n)=>S(e,t,n),"getPackageJsonProperty"),Tt=x((e,t)=>I(e,t),"hasPackageJsonProperty"),Dt=x((e,t,n)=>{const r=S(e,"dependencies",{}),o=S(e,"devDependencies",{}),a=S(e,"peerDependencies",{}),i={...r,...o,...n?.peerDeps===!1?{}:a};for(const s of t)if(I(i,s))return!0;return!1},"hasPackageJsonAnyDependency"),It=x(async(e,t,n="dependencies",r={})=>{if(process.env.CI||Pt&&!process.stdout?.isTTY){console.warn("Skipping package installation because the process is not interactive.");return}const o=S(e,"dependencies",{}),a=S(e,"devDependencies",{}),i=S(e,"peerDependencies",{}),s=[],c={deps:!0,devDeps:!0,peerDeps:!1,...r};for(const p of t)c.deps&&I(o,p)||c.devDeps&&I(a,p)||c.peerDeps&&I(i,p)||s.push(p);if(s.length!==0){if(typeof c.confirm?.message=="function"&&(c.confirm.message=c.confirm.message(s)),c.confirm?.message===void 0){const p=`${s.length===1?"Package is":"Packages are"} required for this config: ${s.join(", ")}. Do you want to install them?`;c.confirm===void 0?c.confirm={message:p}:c.confirm.message=p}await Fe(c.confirm)&&await be(s,{...c.installPackage,cwd:c.cwd?H.toPath(c.cwd):void 0,dev:n==="devDependencies"})}},"ensurePackages");exports.ensurePackages=It;exports.findPackageJson=Ot;exports.findPackageJsonSync=St;exports.getPackageJsonProperty=Nt;exports.hasPackageJsonAnyDependency=Dt;exports.hasPackageJsonProperty=Tt;exports.parsePackageJson=At;exports.writePackageJson=Ct;exports.writePackageJsonSync=Jt;
|