@visulima/package 3.4.2 → 3.4.4

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.
@@ -1 +1,430 @@
1
- "use strict";var A=Object.defineProperty;var s=(e,n)=>A(e,"name",{value:n,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("node:fs"),q=require("@antfu/install-pkg"),$=require("@inquirer/confirm"),h=require("@visulima/fs"),E=require("@visulima/fs/error"),k=require("@visulima/fs/utils"),j=require("@visulima/path"),O=require("normalize-package-data"),S=s(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),T=S($),J=S(O);var C=Object.defineProperty,f=s((e,n)=>C(e,"name",{value:n,configurable:!0}),"s");const p=f(e=>{const n=typeof e;return e!==null&&(n==="object"||n==="function")},"isObject"),F=f(e=>p(e)&&Object.keys(e).length===0,"isEmptyObject"),b=new Set(["__proto__","prototype","constructor"]),K=new Set("0123456789");function w(e){const n=[];let r="",t="start",o=!1;for(const a of e)switch(a){case"\\":{if(t==="index")throw new Error("Invalid character in an index");if(t==="indexEnd")throw new Error("Invalid character after an index");o&&(r+=a),t="property",o=!o;break}case".":{if(t==="index")throw new Error("Invalid character in an index");if(t==="indexEnd"){t="property";break}if(o){o=!1,r+=a;break}if(b.has(r))return[];n.push(r),r="",t="property";break}case"[":{if(t==="index")throw new Error("Invalid character in an index");if(t==="indexEnd"){t="index";break}if(o){o=!1,r+=a;break}if(t==="property"){if(b.has(r))return[];n.push(r),r=""}t="index";break}case"]":{if(t==="index"){n.push(Number.parseInt(r,10)),r="",t="indexEnd";break}if(t==="indexEnd")throw new Error("Invalid character after an index")}default:{if(t==="index"&&!K.has(a))throw new Error("Invalid character in an index");if(t==="indexEnd")throw new Error("Invalid character after an index");t==="start"&&(t="property"),o&&(o=!1,r+="\\"),r+=a}}switch(o&&(r+="\\"),t){case"property":{if(b.has(r))return[];n.push(r);break}case"index":throw new Error("Index was not closed");case"start":{n.push("");break}}return n}s(w,"d");f(w,"getPathSegments");function P(e,n){if(typeof n!="number"&&Array.isArray(e)){const r=Number.parseInt(n,10);return Number.isInteger(r)&&e[r]===e[n]}return!1}s(P,"l");f(P,"isStringIndex");function m(e,n){if(P(e,n))throw new Error("Cannot use string index")}s(m,"p");f(m,"assertNotStringIndex");function u(e,n,r){if(!p(e)||typeof n!="string")return r===void 0?e:r;const t=w(n);if(t.length===0)return r;for(let o=0;o<t.length;o++){const a=t[o];if(P(e,a)?e=o===t.length-1?void 0:null:e=e[a],e==null){if(o!==t.length-1)return r;break}}return e===void 0?r:e}s(u,"getProperty");f(u,"getProperty");function M(e,n,r){if(!p(e)||typeof n!="string")return e;const t=e,o=w(n);for(let a=0;a<o.length;a++){const c=o[a];m(e,c),a===o.length-1?e[c]=r:p(e[c])||(e[c]=typeof o[a+1]=="number"?[]:{}),e=e[c]}return t}s(M,"setProperty");f(M,"setProperty");function U(e,n){if(!p(e)||typeof n!="string")return!1;const r=w(n);for(let t=0;t<r.length;t++){const o=r[t];if(m(e,o),t===r.length-1)return delete e[o],!0;if(e=e[o],!p(e))return!1}}s(U,"deleteProperty");f(U,"deleteProperty");function l(e,n){if(!p(e)||typeof n!="string")return!1;const r=w(n);if(r.length===0)return!1;for(const t of r){if(!p(e)||!(t in e)||P(e,t))return!1;e=e[t]}return!0}s(l,"hasProperty");f(l,"hasProperty");function D(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replaceAll(/[\\.[]/g,"\\$&")}s(D,"escapePath");f(D,"escapePath");function v(e){const n=Object.entries(e);return Array.isArray(e)?n.map(([r,t])=>[Number(r),t]):n}s(v,"h");f(v,"entries");function I(e){let n="";for(let[r,t]of v(e))typeof t=="number"?n+=`[${t}]`:(t=D(t),n+=r===0?t:`.${t}`);return n}s(I,"w");f(I,"stringifyPath");function*x(e,n=[]){if(!p(e)||F(e)){n.length>0&&(yield I(n));return}for(const[r,t]of v(e))yield*x(t,[...n,r])}s(x,"y$1");f(x,"deepKeysIterator");function Y(e){return[...x(e)]}s(Y,"deepKeys");f(Y,"deepKeys");const z=typeof process.stdout<"u"&&!process.versions?.deno&&!globalThis.window;var B=Object.defineProperty,d=s((e,n)=>B(e,"name",{value:n,configurable:!0}),"r");const N=new Map,G=d(async(e,n={})=>{const r={type:"file"};e&&(r.cwd=e);const t=await h.findUp("package.json",r);if(!t)throw new E.NotFoundError("No such file or directory, for package.json found.");const o=n.cache&&typeof n.cache!="boolean"?n.cache:N;if(n.cache&&o.has(t))return o.get(t);const a=await h.readJson(t);J(a);const c={packageJson:a,path:t};return o.set(t,c),c},"findPackageJson"),H=d((e,n={})=>{const r={type:"file"};e&&(r.cwd=e);const t=h.findUpSync("package.json",r);if(!t)throw new E.NotFoundError("No such file or directory, for package.json found.");const o=n.cache&&typeof n.cache!="boolean"?n.cache:N;if(n.cache&&o.has(t))return o.get(t);const a=h.readJsonSync(t);J(a);const c={packageJson:a,path:t};return o.set(t,c),c},"findPackageJsonSync"),L=d(async(e,n={})=>{const{cwd:r,...t}=n,o=k.toPath(n.cwd??process.cwd());await h.writeJson(j.join(o,"package.json"),e,t)},"writePackageJson"),Q=d((e,n={})=>{const{cwd:r,...t}=n,o=k.toPath(n.cwd??process.cwd());h.writeJsonSync(j.join(o,"package.json"),e,t)},"writePackageJsonSync"),R=d(e=>{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):_.existsSync(e)?h.readJsonSync(e):k.parseJson(e);return J(r),r},"parsePackageJson"),V=d((e,n,r)=>u(e,n,r),"getPackageJsonProperty"),W=d((e,n)=>l(e,n),"hasPackageJsonProperty"),X=d((e,n,r)=>{const t=u(e,"dependencies",{}),o=u(e,"devDependencies",{}),a=u(e,"peerDependencies",{}),c={...t,...o,...r?.peerDeps===!1?{}:a};for(const g of n)if(l(c,g))return!0;return!1},"hasPackageJsonAnyDependency"),Z=d(async(e,n,r="dependencies",t={})=>{if(process.env.CI||z&&!process.stdout?.isTTY){console.warn("Skipping package installation because the process is not interactive.");return}const o=u(e,"dependencies",{}),a=u(e,"devDependencies",{}),c=u(e,"peerDependencies",{}),g=[],i={deps:!0,devDeps:!0,peerDeps:!1,...t};for(const y of n)i.deps&&l(o,y)||i.devDeps&&l(a,y)||i.peerDeps&&l(c,y)||g.push(y);if(typeof i.confirm?.message=="function"&&(i.confirm.message=i.confirm.message(g)),i.confirm?.message===void 0){const y=`${g.length===1?"Package is":"Packages are"} required for this config: ${g.join(", ")}. Do you want to install them?`;i.confirm===void 0?i.confirm={message:y}:i.confirm.message=y}await T(i.confirm)&&await q.installPackage(g,{...i.installPackage,cwd:i.cwd?k.toPath(i.cwd):void 0,dev:r==="devDependencies"})},"ensurePackages");exports.ensurePackages=Z;exports.findPackageJson=G;exports.findPackageJsonSync=H;exports.getPackageJsonProperty=V;exports.hasPackageJsonAnyDependency=X;exports.hasPackageJsonProperty=W;exports.parsePackageJson=R;exports.writePackageJson=L;exports.writePackageJsonSync=Q;
1
+ 'use strict';
2
+
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
+
5
+ const node_fs = require('node:fs');
6
+ const installPkg = require('@antfu/install-pkg');
7
+ const confirm = require('@inquirer/confirm');
8
+ const fs = require('@visulima/fs');
9
+ const error = require('@visulima/fs/error');
10
+ const utils = require('@visulima/fs/utils');
11
+ const path = require('@visulima/path');
12
+ const normalizeData = require('normalize-package-data');
13
+
14
+ const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
15
+
16
+ const confirm__default = /*#__PURE__*/_interopDefaultCompat(confirm);
17
+ const normalizeData__default = /*#__PURE__*/_interopDefaultCompat(normalizeData);
18
+
19
+ var __defProp$1 = Object.defineProperty;
20
+ var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
21
+ const isObject = /* @__PURE__ */ __name$1((value) => {
22
+ const type = typeof value;
23
+ return value !== null && (type === "object" || type === "function");
24
+ }, "isObject");
25
+ const isEmptyObject = /* @__PURE__ */ __name$1((value) => isObject(value) && Object.keys(value).length === 0, "isEmptyObject");
26
+ const disallowedKeys = /* @__PURE__ */ new Set([
27
+ "__proto__",
28
+ "prototype",
29
+ "constructor"
30
+ ]);
31
+ const digits = new Set("0123456789");
32
+ function getPathSegments(path) {
33
+ const parts = [];
34
+ let currentSegment = "";
35
+ let currentPart = "start";
36
+ let isIgnoring = false;
37
+ for (const character of path) {
38
+ switch (character) {
39
+ case "\\": {
40
+ if (currentPart === "index") {
41
+ throw new Error("Invalid character in an index");
42
+ }
43
+ if (currentPart === "indexEnd") {
44
+ throw new Error("Invalid character after an index");
45
+ }
46
+ if (isIgnoring) {
47
+ currentSegment += character;
48
+ }
49
+ currentPart = "property";
50
+ isIgnoring = !isIgnoring;
51
+ break;
52
+ }
53
+ case ".": {
54
+ if (currentPart === "index") {
55
+ throw new Error("Invalid character in an index");
56
+ }
57
+ if (currentPart === "indexEnd") {
58
+ currentPart = "property";
59
+ break;
60
+ }
61
+ if (isIgnoring) {
62
+ isIgnoring = false;
63
+ currentSegment += character;
64
+ break;
65
+ }
66
+ if (disallowedKeys.has(currentSegment)) {
67
+ return [];
68
+ }
69
+ parts.push(currentSegment);
70
+ currentSegment = "";
71
+ currentPart = "property";
72
+ break;
73
+ }
74
+ case "[": {
75
+ if (currentPart === "index") {
76
+ throw new Error("Invalid character in an index");
77
+ }
78
+ if (currentPart === "indexEnd") {
79
+ currentPart = "index";
80
+ break;
81
+ }
82
+ if (isIgnoring) {
83
+ isIgnoring = false;
84
+ currentSegment += character;
85
+ break;
86
+ }
87
+ if (currentPart === "property") {
88
+ if (disallowedKeys.has(currentSegment)) {
89
+ return [];
90
+ }
91
+ parts.push(currentSegment);
92
+ currentSegment = "";
93
+ }
94
+ currentPart = "index";
95
+ break;
96
+ }
97
+ case "]": {
98
+ if (currentPart === "index") {
99
+ parts.push(Number.parseInt(currentSegment, 10));
100
+ currentSegment = "";
101
+ currentPart = "indexEnd";
102
+ break;
103
+ }
104
+ if (currentPart === "indexEnd") {
105
+ throw new Error("Invalid character after an index");
106
+ }
107
+ }
108
+ default: {
109
+ if (currentPart === "index" && !digits.has(character)) {
110
+ throw new Error("Invalid character in an index");
111
+ }
112
+ if (currentPart === "indexEnd") {
113
+ throw new Error("Invalid character after an index");
114
+ }
115
+ if (currentPart === "start") {
116
+ currentPart = "property";
117
+ }
118
+ if (isIgnoring) {
119
+ isIgnoring = false;
120
+ currentSegment += "\\";
121
+ }
122
+ currentSegment += character;
123
+ }
124
+ }
125
+ }
126
+ if (isIgnoring) {
127
+ currentSegment += "\\";
128
+ }
129
+ switch (currentPart) {
130
+ case "property": {
131
+ if (disallowedKeys.has(currentSegment)) {
132
+ return [];
133
+ }
134
+ parts.push(currentSegment);
135
+ break;
136
+ }
137
+ case "index": {
138
+ throw new Error("Index was not closed");
139
+ }
140
+ case "start": {
141
+ parts.push("");
142
+ break;
143
+ }
144
+ }
145
+ return parts;
146
+ }
147
+ __name$1(getPathSegments, "getPathSegments");
148
+ function isStringIndex(object, key) {
149
+ if (typeof key !== "number" && Array.isArray(object)) {
150
+ const index = Number.parseInt(key, 10);
151
+ return Number.isInteger(index) && object[index] === object[key];
152
+ }
153
+ return false;
154
+ }
155
+ __name$1(isStringIndex, "isStringIndex");
156
+ function assertNotStringIndex(object, key) {
157
+ if (isStringIndex(object, key)) {
158
+ throw new Error("Cannot use string index");
159
+ }
160
+ }
161
+ __name$1(assertNotStringIndex, "assertNotStringIndex");
162
+ function getProperty(object, path, value) {
163
+ if (!isObject(object) || typeof path !== "string") {
164
+ return value === undefined ? object : value;
165
+ }
166
+ const pathArray = getPathSegments(path);
167
+ if (pathArray.length === 0) {
168
+ return value;
169
+ }
170
+ for (let index = 0; index < pathArray.length; index++) {
171
+ const key = pathArray[index];
172
+ if (isStringIndex(object, key)) {
173
+ object = index === pathArray.length - 1 ? undefined : null;
174
+ } else {
175
+ object = object[key];
176
+ }
177
+ if (object === undefined || object === null) {
178
+ if (index !== pathArray.length - 1) {
179
+ return value;
180
+ }
181
+ break;
182
+ }
183
+ }
184
+ return object === undefined ? value : object;
185
+ }
186
+ __name$1(getProperty, "getProperty");
187
+ function setProperty(object, path, value) {
188
+ if (!isObject(object) || typeof path !== "string") {
189
+ return object;
190
+ }
191
+ const root = object;
192
+ const pathArray = getPathSegments(path);
193
+ for (let index = 0; index < pathArray.length; index++) {
194
+ const key = pathArray[index];
195
+ assertNotStringIndex(object, key);
196
+ if (index === pathArray.length - 1) {
197
+ object[key] = value;
198
+ } else if (!isObject(object[key])) {
199
+ object[key] = typeof pathArray[index + 1] === "number" ? [] : {};
200
+ }
201
+ object = object[key];
202
+ }
203
+ return root;
204
+ }
205
+ __name$1(setProperty, "setProperty");
206
+ function deleteProperty(object, path) {
207
+ if (!isObject(object) || typeof path !== "string") {
208
+ return false;
209
+ }
210
+ const pathArray = getPathSegments(path);
211
+ for (let index = 0; index < pathArray.length; index++) {
212
+ const key = pathArray[index];
213
+ assertNotStringIndex(object, key);
214
+ if (index === pathArray.length - 1) {
215
+ delete object[key];
216
+ return true;
217
+ }
218
+ object = object[key];
219
+ if (!isObject(object)) {
220
+ return false;
221
+ }
222
+ }
223
+ }
224
+ __name$1(deleteProperty, "deleteProperty");
225
+ function hasProperty(object, path) {
226
+ if (!isObject(object) || typeof path !== "string") {
227
+ return false;
228
+ }
229
+ const pathArray = getPathSegments(path);
230
+ if (pathArray.length === 0) {
231
+ return false;
232
+ }
233
+ for (const key of pathArray) {
234
+ if (!isObject(object) || !(key in object) || isStringIndex(object, key)) {
235
+ return false;
236
+ }
237
+ object = object[key];
238
+ }
239
+ return true;
240
+ }
241
+ __name$1(hasProperty, "hasProperty");
242
+ function escapePath(path) {
243
+ if (typeof path !== "string") {
244
+ throw new TypeError("Expected a string");
245
+ }
246
+ return path.replaceAll(/[\\.[]/g, "\\$&");
247
+ }
248
+ __name$1(escapePath, "escapePath");
249
+ function entries(value) {
250
+ const result = Object.entries(value);
251
+ if (Array.isArray(value)) {
252
+ return result.map(([key, value2]) => [Number(key), value2]);
253
+ }
254
+ return result;
255
+ }
256
+ __name$1(entries, "entries");
257
+ function stringifyPath(pathSegments) {
258
+ let result = "";
259
+ for (let [index, segment] of entries(pathSegments)) {
260
+ if (typeof segment === "number") {
261
+ result += `[${segment}]`;
262
+ } else {
263
+ segment = escapePath(segment);
264
+ result += index === 0 ? segment : `.${segment}`;
265
+ }
266
+ }
267
+ return result;
268
+ }
269
+ __name$1(stringifyPath, "stringifyPath");
270
+ function* deepKeysIterator(object, currentPath = []) {
271
+ if (!isObject(object) || isEmptyObject(object)) {
272
+ if (currentPath.length > 0) {
273
+ yield stringifyPath(currentPath);
274
+ }
275
+ return;
276
+ }
277
+ for (const [key, value] of entries(object)) {
278
+ yield* deepKeysIterator(value, [...currentPath, key]);
279
+ }
280
+ }
281
+ __name$1(deepKeysIterator, "deepKeysIterator");
282
+ function deepKeys(object) {
283
+ return [...deepKeysIterator(object)];
284
+ }
285
+ __name$1(deepKeys, "deepKeys");
286
+
287
+ const isNode = typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
288
+
289
+ var __defProp = Object.defineProperty;
290
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
291
+ const PackageJsonFileCache = /* @__PURE__ */ new Map();
292
+ const findPackageJson = /* @__PURE__ */ __name(async (cwd, options = {}) => {
293
+ const findUpConfig = {
294
+ type: "file"
295
+ };
296
+ if (cwd) {
297
+ findUpConfig.cwd = cwd;
298
+ }
299
+ const filePath = await fs.findUp("package.json", findUpConfig);
300
+ if (!filePath) {
301
+ throw new error.NotFoundError("No such file or directory, for package.json found.");
302
+ }
303
+ const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
304
+ if (options.cache && cache.has(filePath)) {
305
+ return cache.get(filePath);
306
+ }
307
+ const packageJson = await fs.readJson(filePath);
308
+ normalizeData__default(packageJson);
309
+ const output = {
310
+ packageJson,
311
+ path: filePath
312
+ };
313
+ cache.set(filePath, output);
314
+ return output;
315
+ }, "findPackageJson");
316
+ const findPackageJsonSync = /* @__PURE__ */ __name((cwd, options = {}) => {
317
+ const findUpConfig = {
318
+ type: "file"
319
+ };
320
+ if (cwd) {
321
+ findUpConfig.cwd = cwd;
322
+ }
323
+ const filePath = fs.findUpSync("package.json", findUpConfig);
324
+ if (!filePath) {
325
+ throw new error.NotFoundError("No such file or directory, for package.json found.");
326
+ }
327
+ const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : PackageJsonFileCache;
328
+ if (options.cache && cache.has(filePath)) {
329
+ return cache.get(filePath);
330
+ }
331
+ const packageJson = fs.readJsonSync(filePath);
332
+ normalizeData__default(packageJson);
333
+ const output = {
334
+ packageJson,
335
+ path: filePath
336
+ };
337
+ cache.set(filePath, output);
338
+ return output;
339
+ }, "findPackageJsonSync");
340
+ const writePackageJson = /* @__PURE__ */ __name(async (data, options = {}) => {
341
+ const { cwd, ...writeOptions } = options;
342
+ const directory = utils.toPath(options.cwd ?? process.cwd());
343
+ await fs.writeJson(path.join(directory, "package.json"), data, writeOptions);
344
+ }, "writePackageJson");
345
+ const writePackageJsonSync = /* @__PURE__ */ __name((data, options = {}) => {
346
+ const { cwd, ...writeOptions } = options;
347
+ const directory = utils.toPath(options.cwd ?? process.cwd());
348
+ fs.writeJsonSync(path.join(directory, "package.json"), data, writeOptions);
349
+ }, "writePackageJsonSync");
350
+ const parsePackageJson = /* @__PURE__ */ __name((packageFile) => {
351
+ const isObject = packageFile !== null && typeof packageFile === "object" && !Array.isArray(packageFile);
352
+ const isString = typeof packageFile === "string";
353
+ if (!isObject && !isString) {
354
+ throw new TypeError("`packageFile` should be either an `object` or a `string`.");
355
+ }
356
+ const json = isObject ? structuredClone(packageFile) : (
357
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
358
+ node_fs.existsSync(packageFile) ? fs.readJsonSync(packageFile) : utils.parseJson(packageFile)
359
+ );
360
+ normalizeData__default(json);
361
+ return json;
362
+ }, "parsePackageJson");
363
+ const getPackageJsonProperty = /* @__PURE__ */ __name((packageJson, property, defaultValue) => getProperty(packageJson, property, defaultValue), "getPackageJsonProperty");
364
+ const hasPackageJsonProperty = /* @__PURE__ */ __name((packageJson, property) => hasProperty(packageJson, property), "hasPackageJsonProperty");
365
+ const hasPackageJsonAnyDependency = /* @__PURE__ */ __name((packageJson, arguments_, options) => {
366
+ const dependencies = getProperty(packageJson, "dependencies", {});
367
+ const devDependencies = getProperty(packageJson, "devDependencies", {});
368
+ const peerDependencies = getProperty(packageJson, "peerDependencies", {});
369
+ const allDependencies = { ...dependencies, ...devDependencies, ...options?.peerDeps === false ? {} : peerDependencies };
370
+ for (const argument of arguments_) {
371
+ if (hasProperty(allDependencies, argument)) {
372
+ return true;
373
+ }
374
+ }
375
+ return false;
376
+ }, "hasPackageJsonAnyDependency");
377
+ const ensurePackages = /* @__PURE__ */ __name(async (packageJson, packages, installKey = "dependencies", options = {}) => {
378
+ if (process.env.CI || isNode && !process.stdout?.isTTY) {
379
+ console.warn("Skipping package installation because the process is not interactive.");
380
+ return;
381
+ }
382
+ const dependencies = getProperty(packageJson, "dependencies", {});
383
+ const devDependencies = getProperty(packageJson, "devDependencies", {});
384
+ const peerDependencies = getProperty(packageJson, "peerDependencies", {});
385
+ const nonExistingPackages = [];
386
+ const config = {
387
+ deps: true,
388
+ devDeps: true,
389
+ peerDeps: false,
390
+ ...options
391
+ };
392
+ for (const packageName of packages) {
393
+ if (config.deps && hasProperty(dependencies, packageName) || config.devDeps && hasProperty(devDependencies, packageName) || config.peerDeps && hasProperty(peerDependencies, packageName)) {
394
+ continue;
395
+ }
396
+ nonExistingPackages.push(packageName);
397
+ }
398
+ if (typeof config.confirm?.message === "function") {
399
+ config.confirm.message = config.confirm.message(nonExistingPackages);
400
+ }
401
+ if (config.confirm?.message === undefined) {
402
+ const message = `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`;
403
+ if (config.confirm === undefined) {
404
+ config.confirm = {
405
+ message
406
+ };
407
+ } else {
408
+ config.confirm.message = message;
409
+ }
410
+ }
411
+ const answer = await confirm__default(config.confirm);
412
+ if (!answer) {
413
+ return;
414
+ }
415
+ await installPkg.installPackage(nonExistingPackages, {
416
+ ...config.installPackage,
417
+ cwd: config.cwd ? utils.toPath(config.cwd) : undefined,
418
+ dev: installKey === "devDependencies"
419
+ });
420
+ }, "ensurePackages");
421
+
422
+ exports.ensurePackages = ensurePackages;
423
+ exports.findPackageJson = findPackageJson;
424
+ exports.findPackageJsonSync = findPackageJsonSync;
425
+ exports.getPackageJsonProperty = getPackageJsonProperty;
426
+ exports.hasPackageJsonAnyDependency = hasPackageJsonAnyDependency;
427
+ exports.hasPackageJsonProperty = hasPackageJsonProperty;
428
+ exports.parsePackageJson = parsePackageJson;
429
+ exports.writePackageJson = writePackageJson;
430
+ exports.writePackageJsonSync = writePackageJsonSync;