@visulima/package 3.5.4 → 3.5.6
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 +29 -0
- package/LICENSE.md +116 -0
- package/dist/index.d.cts +1 -2
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/package-json.cjs +834 -11
- package/dist/package-json.d.cts +1 -2
- package/dist/package-json.d.mts +1 -2
- package/dist/package-json.d.ts +1 -2
- package/dist/package-json.mjs +819 -1
- package/dist/packem_shared/{package-json-DvaC9k-3.d.cts → package-json-BCAHuiQ6.d.cts} +545 -58
- package/dist/packem_shared/{package-json-DvaC9k-3.d.mts → package-json-BCAHuiQ6.d.mts} +545 -58
- package/dist/packem_shared/{package-json-DvaC9k-3.d.ts → package-json-BCAHuiQ6.d.ts} +545 -58
- package/package.json +4 -5
package/dist/package-json.cjs
CHANGED
|
@@ -3,19 +3,839 @@
|
|
|
3
3
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
4
|
|
|
5
5
|
const node_fs = require('node:fs');
|
|
6
|
-
const
|
|
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');
|
|
7
15
|
const confirm = require('@inquirer/confirm');
|
|
8
|
-
const fs = require('@visulima/fs');
|
|
16
|
+
const fs$1 = require('@visulima/fs');
|
|
9
17
|
const error = require('@visulima/fs/error');
|
|
10
18
|
const utils = require('@visulima/fs/utils');
|
|
11
|
-
const path = require('@visulima/path');
|
|
19
|
+
const path$2 = require('@visulima/path');
|
|
12
20
|
const normalizeData = require('normalize-package-data');
|
|
13
21
|
|
|
22
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
14
23
|
const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
|
|
15
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);
|
|
16
29
|
const confirm__default = /*#__PURE__*/_interopDefaultCompat(confirm);
|
|
17
30
|
const normalizeData__default = /*#__PURE__*/_interopDefaultCompat(normalizeData);
|
|
18
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
|
+
|
|
19
839
|
var __defProp$1 = Object.defineProperty;
|
|
20
840
|
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
21
841
|
const isObject = /* @__PURE__ */ __name$1((value) => {
|
|
@@ -330,7 +1150,7 @@ const findPackageJson = /* @__PURE__ */ __name(async (cwd, options = {}) => {
|
|
|
330
1150
|
if (cwd) {
|
|
331
1151
|
findUpConfig.cwd = cwd;
|
|
332
1152
|
}
|
|
333
|
-
const filePath = await fs.findUp("package.json", findUpConfig);
|
|
1153
|
+
const filePath = await fs$1.findUp("package.json", findUpConfig);
|
|
334
1154
|
if (!filePath) {
|
|
335
1155
|
throw new error.NotFoundError("No such file or directory, for package.json found.");
|
|
336
1156
|
}
|
|
@@ -338,7 +1158,7 @@ const findPackageJson = /* @__PURE__ */ __name(async (cwd, options = {}) => {
|
|
|
338
1158
|
if (options.cache && cache.has(filePath)) {
|
|
339
1159
|
return cache.get(filePath);
|
|
340
1160
|
}
|
|
341
|
-
const packageJson = await fs.readJson(filePath);
|
|
1161
|
+
const packageJson = await fs$1.readJson(filePath);
|
|
342
1162
|
normalizeInput(packageJson, options.strict ?? false, options.ignoreWarnings);
|
|
343
1163
|
const output = {
|
|
344
1164
|
packageJson,
|
|
@@ -354,7 +1174,7 @@ const findPackageJsonSync = /* @__PURE__ */ __name((cwd, options = {}) => {
|
|
|
354
1174
|
if (cwd) {
|
|
355
1175
|
findUpConfig.cwd = cwd;
|
|
356
1176
|
}
|
|
357
|
-
const filePath = fs.findUpSync("package.json", findUpConfig);
|
|
1177
|
+
const filePath = fs$1.findUpSync("package.json", findUpConfig);
|
|
358
1178
|
if (!filePath) {
|
|
359
1179
|
throw new error.NotFoundError("No such file or directory, for package.json found.");
|
|
360
1180
|
}
|
|
@@ -362,7 +1182,7 @@ const findPackageJsonSync = /* @__PURE__ */ __name((cwd, options = {}) => {
|
|
|
362
1182
|
if (options.cache && cache.has(filePath)) {
|
|
363
1183
|
return cache.get(filePath);
|
|
364
1184
|
}
|
|
365
|
-
const packageJson = fs.readJsonSync(filePath);
|
|
1185
|
+
const packageJson = fs$1.readJsonSync(filePath);
|
|
366
1186
|
normalizeInput(packageJson, options.strict ?? false, options.ignoreWarnings);
|
|
367
1187
|
const output = {
|
|
368
1188
|
packageJson,
|
|
@@ -374,12 +1194,12 @@ const findPackageJsonSync = /* @__PURE__ */ __name((cwd, options = {}) => {
|
|
|
374
1194
|
const writePackageJson = /* @__PURE__ */ __name(async (data, options = {}) => {
|
|
375
1195
|
const { cwd, ...writeOptions } = options;
|
|
376
1196
|
const directory = utils.toPath(options.cwd ?? process.cwd());
|
|
377
|
-
await fs.writeJson(path.join(directory, "package.json"), data, writeOptions);
|
|
1197
|
+
await fs$1.writeJson(path$2.join(directory, "package.json"), data, writeOptions);
|
|
378
1198
|
}, "writePackageJson");
|
|
379
1199
|
const writePackageJsonSync = /* @__PURE__ */ __name((data, options = {}) => {
|
|
380
1200
|
const { cwd, ...writeOptions } = options;
|
|
381
1201
|
const directory = utils.toPath(options.cwd ?? process.cwd());
|
|
382
|
-
fs.writeJsonSync(path.join(directory, "package.json"), data, writeOptions);
|
|
1202
|
+
fs$1.writeJsonSync(path$2.join(directory, "package.json"), data, writeOptions);
|
|
383
1203
|
}, "writePackageJsonSync");
|
|
384
1204
|
const parsePackageJson = /* @__PURE__ */ __name((packageFile, options) => {
|
|
385
1205
|
const isObject = packageFile !== null && typeof packageFile === "object" && !Array.isArray(packageFile);
|
|
@@ -389,7 +1209,7 @@ const parsePackageJson = /* @__PURE__ */ __name((packageFile, options) => {
|
|
|
389
1209
|
}
|
|
390
1210
|
const json = isObject ? structuredClone(packageFile) : (
|
|
391
1211
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
392
|
-
node_fs.existsSync(packageFile) ? fs.readJsonSync(packageFile) : utils.parseJson(packageFile)
|
|
1212
|
+
node_fs.existsSync(packageFile) ? fs$1.readJsonSync(packageFile) : utils.parseJson(packageFile)
|
|
393
1213
|
);
|
|
394
1214
|
normalizeInput(json, options?.strict ?? false, options?.ignoreWarnings);
|
|
395
1215
|
return json;
|
|
@@ -429,6 +1249,9 @@ const ensurePackages = /* @__PURE__ */ __name(async (packageJson, packages, inst
|
|
|
429
1249
|
}
|
|
430
1250
|
nonExistingPackages.push(packageName);
|
|
431
1251
|
}
|
|
1252
|
+
if (nonExistingPackages.length === 0) {
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
432
1255
|
if (typeof config.confirm?.message === "function") {
|
|
433
1256
|
config.confirm.message = config.confirm.message(nonExistingPackages);
|
|
434
1257
|
}
|
|
@@ -446,7 +1269,7 @@ const ensurePackages = /* @__PURE__ */ __name(async (packageJson, packages, inst
|
|
|
446
1269
|
if (!answer) {
|
|
447
1270
|
return;
|
|
448
1271
|
}
|
|
449
|
-
await
|
|
1272
|
+
await installPackage(nonExistingPackages, {
|
|
450
1273
|
...config.installPackage,
|
|
451
1274
|
cwd: config.cwd ? utils.toPath(config.cwd) : void 0,
|
|
452
1275
|
dev: installKey === "devDependencies"
|