@mcp-s/skills 1.0.2 → 1.3.1
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/README.md +399 -96
- package/ThirdPartyNoticeText.txt +171 -0
- package/bin/cli.mjs +14 -0
- package/dist/_chunks/libs/@clack/core.mjs +767 -0
- package/dist/_chunks/libs/@clack/prompts.mjs +275 -0
- package/dist/_chunks/libs/@kwsites/file-exists.mjs +562 -0
- package/dist/_chunks/libs/@kwsites/promise-deferred.mjs +37 -0
- package/dist/_chunks/libs/bluebird.mjs +4141 -0
- package/dist/_chunks/libs/core-util-is.mjs +65 -0
- package/dist/_chunks/libs/duplexer2.mjs +1726 -0
- package/dist/_chunks/libs/esprima.mjs +5338 -0
- package/dist/_chunks/libs/extend-shallow.mjs +31 -0
- package/dist/_chunks/libs/fs-extra.mjs +1801 -0
- package/dist/_chunks/libs/gray-matter.mjs +2596 -0
- package/dist/_chunks/libs/node-int64.mjs +103 -0
- package/dist/_chunks/libs/simple-git.mjs +3584 -0
- package/dist/_chunks/libs/unzipper.mjs +945 -0
- package/dist/_chunks/libs/xdg-basedir.mjs +14 -0
- package/dist/_chunks/rolldown-runtime.mjs +24 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +4258 -0
- package/package.json +85 -27
- package/dist/agents.js +0 -246
- package/dist/api.js +0 -45
- package/dist/auth.js +0 -98
- package/dist/index.js +0 -482
- package/dist/installer.js +0 -188
- package/dist/types.js +0 -1
|
@@ -0,0 +1,1801 @@
|
|
|
1
|
+
import { n as __require, t as __commonJSMin } from "../rolldown-runtime.mjs";
|
|
2
|
+
var require_universalify = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3
|
+
exports.fromCallback = function(fn) {
|
|
4
|
+
return Object.defineProperty(function(...args) {
|
|
5
|
+
if (typeof args[args.length - 1] === "function") fn.apply(this, args);
|
|
6
|
+
else return new Promise((resolve, reject) => {
|
|
7
|
+
args.push((err, res) => err != null ? reject(err) : resolve(res));
|
|
8
|
+
fn.apply(this, args);
|
|
9
|
+
});
|
|
10
|
+
}, "name", { value: fn.name });
|
|
11
|
+
};
|
|
12
|
+
exports.fromPromise = function(fn) {
|
|
13
|
+
return Object.defineProperty(function(...args) {
|
|
14
|
+
const cb = args[args.length - 1];
|
|
15
|
+
if (typeof cb !== "function") return fn.apply(this, args);
|
|
16
|
+
else {
|
|
17
|
+
args.pop();
|
|
18
|
+
fn.apply(this, args).then((r) => cb(null, r), cb);
|
|
19
|
+
}
|
|
20
|
+
}, "name", { value: fn.name });
|
|
21
|
+
};
|
|
22
|
+
}));
|
|
23
|
+
var require_polyfills = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
24
|
+
var constants = __require("constants");
|
|
25
|
+
var origCwd = process.cwd;
|
|
26
|
+
var cwd = null;
|
|
27
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
28
|
+
process.cwd = function() {
|
|
29
|
+
if (!cwd) cwd = origCwd.call(process);
|
|
30
|
+
return cwd;
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
process.cwd();
|
|
34
|
+
} catch (er) {}
|
|
35
|
+
if (typeof process.chdir === "function") {
|
|
36
|
+
var chdir = process.chdir;
|
|
37
|
+
process.chdir = function(d) {
|
|
38
|
+
cwd = null;
|
|
39
|
+
chdir.call(process, d);
|
|
40
|
+
};
|
|
41
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
42
|
+
}
|
|
43
|
+
module.exports = patch;
|
|
44
|
+
function patch(fs) {
|
|
45
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) patchLchmod(fs);
|
|
46
|
+
if (!fs.lutimes) patchLutimes(fs);
|
|
47
|
+
fs.chown = chownFix(fs.chown);
|
|
48
|
+
fs.fchown = chownFix(fs.fchown);
|
|
49
|
+
fs.lchown = chownFix(fs.lchown);
|
|
50
|
+
fs.chmod = chmodFix(fs.chmod);
|
|
51
|
+
fs.fchmod = chmodFix(fs.fchmod);
|
|
52
|
+
fs.lchmod = chmodFix(fs.lchmod);
|
|
53
|
+
fs.chownSync = chownFixSync(fs.chownSync);
|
|
54
|
+
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
55
|
+
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
56
|
+
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
57
|
+
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
58
|
+
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
59
|
+
fs.stat = statFix(fs.stat);
|
|
60
|
+
fs.fstat = statFix(fs.fstat);
|
|
61
|
+
fs.lstat = statFix(fs.lstat);
|
|
62
|
+
fs.statSync = statFixSync(fs.statSync);
|
|
63
|
+
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
64
|
+
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
65
|
+
if (fs.chmod && !fs.lchmod) {
|
|
66
|
+
fs.lchmod = function(path, mode, cb) {
|
|
67
|
+
if (cb) process.nextTick(cb);
|
|
68
|
+
};
|
|
69
|
+
fs.lchmodSync = function() {};
|
|
70
|
+
}
|
|
71
|
+
if (fs.chown && !fs.lchown) {
|
|
72
|
+
fs.lchown = function(path, uid, gid, cb) {
|
|
73
|
+
if (cb) process.nextTick(cb);
|
|
74
|
+
};
|
|
75
|
+
fs.lchownSync = function() {};
|
|
76
|
+
}
|
|
77
|
+
if (platform === "win32") fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
|
|
78
|
+
function rename(from, to, cb) {
|
|
79
|
+
var start = Date.now();
|
|
80
|
+
var backoff = 0;
|
|
81
|
+
fs$rename(from, to, function CB(er) {
|
|
82
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
83
|
+
setTimeout(function() {
|
|
84
|
+
fs.stat(to, function(stater, st) {
|
|
85
|
+
if (stater && stater.code === "ENOENT") fs$rename(from, to, CB);
|
|
86
|
+
else cb(er);
|
|
87
|
+
});
|
|
88
|
+
}, backoff);
|
|
89
|
+
if (backoff < 100) backoff += 10;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (cb) cb(er);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
96
|
+
return rename;
|
|
97
|
+
})(fs.rename);
|
|
98
|
+
fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
|
|
99
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
100
|
+
var callback;
|
|
101
|
+
if (callback_ && typeof callback_ === "function") {
|
|
102
|
+
var eagCounter = 0;
|
|
103
|
+
callback = function(er, _, __) {
|
|
104
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
105
|
+
eagCounter++;
|
|
106
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
107
|
+
}
|
|
108
|
+
callback_.apply(this, arguments);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
112
|
+
}
|
|
113
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
114
|
+
return read;
|
|
115
|
+
})(fs.read);
|
|
116
|
+
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : (function(fs$readSync) {
|
|
117
|
+
return function(fd, buffer, offset, length, position) {
|
|
118
|
+
var eagCounter = 0;
|
|
119
|
+
while (true) try {
|
|
120
|
+
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
121
|
+
} catch (er) {
|
|
122
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
123
|
+
eagCounter++;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
throw er;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
})(fs.readSync);
|
|
130
|
+
function patchLchmod(fs) {
|
|
131
|
+
fs.lchmod = function(path, mode, callback) {
|
|
132
|
+
fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
|
|
133
|
+
if (err) {
|
|
134
|
+
if (callback) callback(err);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
fs.fchmod(fd, mode, function(err) {
|
|
138
|
+
fs.close(fd, function(err2) {
|
|
139
|
+
if (callback) callback(err || err2);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
fs.lchmodSync = function(path, mode) {
|
|
145
|
+
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
146
|
+
var threw = true;
|
|
147
|
+
var ret;
|
|
148
|
+
try {
|
|
149
|
+
ret = fs.fchmodSync(fd, mode);
|
|
150
|
+
threw = false;
|
|
151
|
+
} finally {
|
|
152
|
+
if (threw) try {
|
|
153
|
+
fs.closeSync(fd);
|
|
154
|
+
} catch (er) {}
|
|
155
|
+
else fs.closeSync(fd);
|
|
156
|
+
}
|
|
157
|
+
return ret;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function patchLutimes(fs) {
|
|
161
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
|
|
162
|
+
fs.lutimes = function(path, at, mt, cb) {
|
|
163
|
+
fs.open(path, constants.O_SYMLINK, function(er, fd) {
|
|
164
|
+
if (er) {
|
|
165
|
+
if (cb) cb(er);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
fs.futimes(fd, at, mt, function(er) {
|
|
169
|
+
fs.close(fd, function(er2) {
|
|
170
|
+
if (cb) cb(er || er2);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
fs.lutimesSync = function(path, at, mt) {
|
|
176
|
+
var fd = fs.openSync(path, constants.O_SYMLINK);
|
|
177
|
+
var ret;
|
|
178
|
+
var threw = true;
|
|
179
|
+
try {
|
|
180
|
+
ret = fs.futimesSync(fd, at, mt);
|
|
181
|
+
threw = false;
|
|
182
|
+
} finally {
|
|
183
|
+
if (threw) try {
|
|
184
|
+
fs.closeSync(fd);
|
|
185
|
+
} catch (er) {}
|
|
186
|
+
else fs.closeSync(fd);
|
|
187
|
+
}
|
|
188
|
+
return ret;
|
|
189
|
+
};
|
|
190
|
+
} else if (fs.futimes) {
|
|
191
|
+
fs.lutimes = function(_a, _b, _c, cb) {
|
|
192
|
+
if (cb) process.nextTick(cb);
|
|
193
|
+
};
|
|
194
|
+
fs.lutimesSync = function() {};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function chmodFix(orig) {
|
|
198
|
+
if (!orig) return orig;
|
|
199
|
+
return function(target, mode, cb) {
|
|
200
|
+
return orig.call(fs, target, mode, function(er) {
|
|
201
|
+
if (chownErOk(er)) er = null;
|
|
202
|
+
if (cb) cb.apply(this, arguments);
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function chmodFixSync(orig) {
|
|
207
|
+
if (!orig) return orig;
|
|
208
|
+
return function(target, mode) {
|
|
209
|
+
try {
|
|
210
|
+
return orig.call(fs, target, mode);
|
|
211
|
+
} catch (er) {
|
|
212
|
+
if (!chownErOk(er)) throw er;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function chownFix(orig) {
|
|
217
|
+
if (!orig) return orig;
|
|
218
|
+
return function(target, uid, gid, cb) {
|
|
219
|
+
return orig.call(fs, target, uid, gid, function(er) {
|
|
220
|
+
if (chownErOk(er)) er = null;
|
|
221
|
+
if (cb) cb.apply(this, arguments);
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function chownFixSync(orig) {
|
|
226
|
+
if (!orig) return orig;
|
|
227
|
+
return function(target, uid, gid) {
|
|
228
|
+
try {
|
|
229
|
+
return orig.call(fs, target, uid, gid);
|
|
230
|
+
} catch (er) {
|
|
231
|
+
if (!chownErOk(er)) throw er;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function statFix(orig) {
|
|
236
|
+
if (!orig) return orig;
|
|
237
|
+
return function(target, options, cb) {
|
|
238
|
+
if (typeof options === "function") {
|
|
239
|
+
cb = options;
|
|
240
|
+
options = null;
|
|
241
|
+
}
|
|
242
|
+
function callback(er, stats) {
|
|
243
|
+
if (stats) {
|
|
244
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
245
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
246
|
+
}
|
|
247
|
+
if (cb) cb.apply(this, arguments);
|
|
248
|
+
}
|
|
249
|
+
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function statFixSync(orig) {
|
|
253
|
+
if (!orig) return orig;
|
|
254
|
+
return function(target, options) {
|
|
255
|
+
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
|
|
256
|
+
if (stats) {
|
|
257
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
258
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
259
|
+
}
|
|
260
|
+
return stats;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function chownErOk(er) {
|
|
264
|
+
if (!er) return true;
|
|
265
|
+
if (er.code === "ENOSYS") return true;
|
|
266
|
+
if (!process.getuid || process.getuid() !== 0) {
|
|
267
|
+
if (er.code === "EINVAL" || er.code === "EPERM") return true;
|
|
268
|
+
}
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}));
|
|
273
|
+
var require_legacy_streams = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
274
|
+
var Stream = __require("stream").Stream;
|
|
275
|
+
module.exports = legacy;
|
|
276
|
+
function legacy(fs) {
|
|
277
|
+
return {
|
|
278
|
+
ReadStream,
|
|
279
|
+
WriteStream
|
|
280
|
+
};
|
|
281
|
+
function ReadStream(path, options) {
|
|
282
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
|
283
|
+
Stream.call(this);
|
|
284
|
+
var self = this;
|
|
285
|
+
this.path = path;
|
|
286
|
+
this.fd = null;
|
|
287
|
+
this.readable = true;
|
|
288
|
+
this.paused = false;
|
|
289
|
+
this.flags = "r";
|
|
290
|
+
this.mode = 438;
|
|
291
|
+
this.bufferSize = 64 * 1024;
|
|
292
|
+
options = options || {};
|
|
293
|
+
var keys = Object.keys(options);
|
|
294
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
295
|
+
var key = keys[index];
|
|
296
|
+
this[key] = options[key];
|
|
297
|
+
}
|
|
298
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
299
|
+
if (this.start !== void 0) {
|
|
300
|
+
if ("number" !== typeof this.start) throw TypeError("start must be a Number");
|
|
301
|
+
if (this.end === void 0) this.end = Infinity;
|
|
302
|
+
else if ("number" !== typeof this.end) throw TypeError("end must be a Number");
|
|
303
|
+
if (this.start > this.end) throw new Error("start must be <= end");
|
|
304
|
+
this.pos = this.start;
|
|
305
|
+
}
|
|
306
|
+
if (this.fd !== null) {
|
|
307
|
+
process.nextTick(function() {
|
|
308
|
+
self._read();
|
|
309
|
+
});
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
313
|
+
if (err) {
|
|
314
|
+
self.emit("error", err);
|
|
315
|
+
self.readable = false;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
self.fd = fd;
|
|
319
|
+
self.emit("open", fd);
|
|
320
|
+
self._read();
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function WriteStream(path, options) {
|
|
324
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
|
325
|
+
Stream.call(this);
|
|
326
|
+
this.path = path;
|
|
327
|
+
this.fd = null;
|
|
328
|
+
this.writable = true;
|
|
329
|
+
this.flags = "w";
|
|
330
|
+
this.encoding = "binary";
|
|
331
|
+
this.mode = 438;
|
|
332
|
+
this.bytesWritten = 0;
|
|
333
|
+
options = options || {};
|
|
334
|
+
var keys = Object.keys(options);
|
|
335
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
336
|
+
var key = keys[index];
|
|
337
|
+
this[key] = options[key];
|
|
338
|
+
}
|
|
339
|
+
if (this.start !== void 0) {
|
|
340
|
+
if ("number" !== typeof this.start) throw TypeError("start must be a Number");
|
|
341
|
+
if (this.start < 0) throw new Error("start must be >= zero");
|
|
342
|
+
this.pos = this.start;
|
|
343
|
+
}
|
|
344
|
+
this.busy = false;
|
|
345
|
+
this._queue = [];
|
|
346
|
+
if (this.fd === null) {
|
|
347
|
+
this._open = fs.open;
|
|
348
|
+
this._queue.push([
|
|
349
|
+
this._open,
|
|
350
|
+
this.path,
|
|
351
|
+
this.flags,
|
|
352
|
+
this.mode,
|
|
353
|
+
void 0
|
|
354
|
+
]);
|
|
355
|
+
this.flush();
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}));
|
|
360
|
+
var require_clone = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
361
|
+
module.exports = clone;
|
|
362
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
363
|
+
return obj.__proto__;
|
|
364
|
+
};
|
|
365
|
+
function clone(obj) {
|
|
366
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
367
|
+
if (obj instanceof Object) var copy = { __proto__: getPrototypeOf(obj) };
|
|
368
|
+
else var copy = Object.create(null);
|
|
369
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
370
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
371
|
+
});
|
|
372
|
+
return copy;
|
|
373
|
+
}
|
|
374
|
+
}));
|
|
375
|
+
var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
376
|
+
var fs = __require("fs");
|
|
377
|
+
var polyfills = require_polyfills();
|
|
378
|
+
var legacy = require_legacy_streams();
|
|
379
|
+
var clone = require_clone();
|
|
380
|
+
var util = __require("util");
|
|
381
|
+
/* istanbul ignore next - node 0.x polyfill */
|
|
382
|
+
var gracefulQueue;
|
|
383
|
+
var previousSymbol;
|
|
384
|
+
/* istanbul ignore else - node 0.x polyfill */
|
|
385
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
386
|
+
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
387
|
+
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
388
|
+
} else {
|
|
389
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
390
|
+
previousSymbol = "___graceful-fs.previous";
|
|
391
|
+
}
|
|
392
|
+
function noop() {}
|
|
393
|
+
function publishQueue(context, queue) {
|
|
394
|
+
Object.defineProperty(context, gracefulQueue, { get: function() {
|
|
395
|
+
return queue;
|
|
396
|
+
} });
|
|
397
|
+
}
|
|
398
|
+
var debug = noop;
|
|
399
|
+
if (util.debuglog) debug = util.debuglog("gfs4");
|
|
400
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) debug = function() {
|
|
401
|
+
var m = util.format.apply(util, arguments);
|
|
402
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
403
|
+
console.error(m);
|
|
404
|
+
};
|
|
405
|
+
if (!fs[gracefulQueue]) {
|
|
406
|
+
publishQueue(fs, global[gracefulQueue] || []);
|
|
407
|
+
fs.close = (function(fs$close) {
|
|
408
|
+
function close(fd, cb) {
|
|
409
|
+
return fs$close.call(fs, fd, function(err) {
|
|
410
|
+
if (!err) resetQueue();
|
|
411
|
+
if (typeof cb === "function") cb.apply(this, arguments);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
Object.defineProperty(close, previousSymbol, { value: fs$close });
|
|
415
|
+
return close;
|
|
416
|
+
})(fs.close);
|
|
417
|
+
fs.closeSync = (function(fs$closeSync) {
|
|
418
|
+
function closeSync(fd) {
|
|
419
|
+
fs$closeSync.apply(fs, arguments);
|
|
420
|
+
resetQueue();
|
|
421
|
+
}
|
|
422
|
+
Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync });
|
|
423
|
+
return closeSync;
|
|
424
|
+
})(fs.closeSync);
|
|
425
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
|
|
426
|
+
debug(fs[gracefulQueue]);
|
|
427
|
+
__require("assert").equal(fs[gracefulQueue].length, 0);
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
if (!global[gracefulQueue]) publishQueue(global, fs[gracefulQueue]);
|
|
431
|
+
module.exports = patch(clone(fs));
|
|
432
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
|
433
|
+
module.exports = patch(fs);
|
|
434
|
+
fs.__patched = true;
|
|
435
|
+
}
|
|
436
|
+
function patch(fs) {
|
|
437
|
+
polyfills(fs);
|
|
438
|
+
fs.gracefulify = patch;
|
|
439
|
+
fs.createReadStream = createReadStream;
|
|
440
|
+
fs.createWriteStream = createWriteStream;
|
|
441
|
+
var fs$readFile = fs.readFile;
|
|
442
|
+
fs.readFile = readFile;
|
|
443
|
+
function readFile(path, options, cb) {
|
|
444
|
+
if (typeof options === "function") cb = options, options = null;
|
|
445
|
+
return go$readFile(path, options, cb);
|
|
446
|
+
function go$readFile(path, options, cb, startTime) {
|
|
447
|
+
return fs$readFile(path, options, function(err) {
|
|
448
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
449
|
+
go$readFile,
|
|
450
|
+
[
|
|
451
|
+
path,
|
|
452
|
+
options,
|
|
453
|
+
cb
|
|
454
|
+
],
|
|
455
|
+
err,
|
|
456
|
+
startTime || Date.now(),
|
|
457
|
+
Date.now()
|
|
458
|
+
]);
|
|
459
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
var fs$writeFile = fs.writeFile;
|
|
464
|
+
fs.writeFile = writeFile;
|
|
465
|
+
function writeFile(path, data, options, cb) {
|
|
466
|
+
if (typeof options === "function") cb = options, options = null;
|
|
467
|
+
return go$writeFile(path, data, options, cb);
|
|
468
|
+
function go$writeFile(path, data, options, cb, startTime) {
|
|
469
|
+
return fs$writeFile(path, data, options, function(err) {
|
|
470
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
471
|
+
go$writeFile,
|
|
472
|
+
[
|
|
473
|
+
path,
|
|
474
|
+
data,
|
|
475
|
+
options,
|
|
476
|
+
cb
|
|
477
|
+
],
|
|
478
|
+
err,
|
|
479
|
+
startTime || Date.now(),
|
|
480
|
+
Date.now()
|
|
481
|
+
]);
|
|
482
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
var fs$appendFile = fs.appendFile;
|
|
487
|
+
if (fs$appendFile) fs.appendFile = appendFile;
|
|
488
|
+
function appendFile(path, data, options, cb) {
|
|
489
|
+
if (typeof options === "function") cb = options, options = null;
|
|
490
|
+
return go$appendFile(path, data, options, cb);
|
|
491
|
+
function go$appendFile(path, data, options, cb, startTime) {
|
|
492
|
+
return fs$appendFile(path, data, options, function(err) {
|
|
493
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
494
|
+
go$appendFile,
|
|
495
|
+
[
|
|
496
|
+
path,
|
|
497
|
+
data,
|
|
498
|
+
options,
|
|
499
|
+
cb
|
|
500
|
+
],
|
|
501
|
+
err,
|
|
502
|
+
startTime || Date.now(),
|
|
503
|
+
Date.now()
|
|
504
|
+
]);
|
|
505
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
var fs$copyFile = fs.copyFile;
|
|
510
|
+
if (fs$copyFile) fs.copyFile = copyFile;
|
|
511
|
+
function copyFile(src, dest, flags, cb) {
|
|
512
|
+
if (typeof flags === "function") {
|
|
513
|
+
cb = flags;
|
|
514
|
+
flags = 0;
|
|
515
|
+
}
|
|
516
|
+
return go$copyFile(src, dest, flags, cb);
|
|
517
|
+
function go$copyFile(src, dest, flags, cb, startTime) {
|
|
518
|
+
return fs$copyFile(src, dest, flags, function(err) {
|
|
519
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
520
|
+
go$copyFile,
|
|
521
|
+
[
|
|
522
|
+
src,
|
|
523
|
+
dest,
|
|
524
|
+
flags,
|
|
525
|
+
cb
|
|
526
|
+
],
|
|
527
|
+
err,
|
|
528
|
+
startTime || Date.now(),
|
|
529
|
+
Date.now()
|
|
530
|
+
]);
|
|
531
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
var fs$readdir = fs.readdir;
|
|
536
|
+
fs.readdir = readdir;
|
|
537
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
538
|
+
function readdir(path, options, cb) {
|
|
539
|
+
if (typeof options === "function") cb = options, options = null;
|
|
540
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path, options, cb, startTime) {
|
|
541
|
+
return fs$readdir(path, fs$readdirCallback(path, options, cb, startTime));
|
|
542
|
+
} : function go$readdir(path, options, cb, startTime) {
|
|
543
|
+
return fs$readdir(path, options, fs$readdirCallback(path, options, cb, startTime));
|
|
544
|
+
};
|
|
545
|
+
return go$readdir(path, options, cb);
|
|
546
|
+
function fs$readdirCallback(path, options, cb, startTime) {
|
|
547
|
+
return function(err, files) {
|
|
548
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
549
|
+
go$readdir,
|
|
550
|
+
[
|
|
551
|
+
path,
|
|
552
|
+
options,
|
|
553
|
+
cb
|
|
554
|
+
],
|
|
555
|
+
err,
|
|
556
|
+
startTime || Date.now(),
|
|
557
|
+
Date.now()
|
|
558
|
+
]);
|
|
559
|
+
else {
|
|
560
|
+
if (files && files.sort) files.sort();
|
|
561
|
+
if (typeof cb === "function") cb.call(this, err, files);
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
567
|
+
var legStreams = legacy(fs);
|
|
568
|
+
ReadStream = legStreams.ReadStream;
|
|
569
|
+
WriteStream = legStreams.WriteStream;
|
|
570
|
+
}
|
|
571
|
+
var fs$ReadStream = fs.ReadStream;
|
|
572
|
+
if (fs$ReadStream) {
|
|
573
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
574
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
575
|
+
}
|
|
576
|
+
var fs$WriteStream = fs.WriteStream;
|
|
577
|
+
if (fs$WriteStream) {
|
|
578
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
579
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
580
|
+
}
|
|
581
|
+
Object.defineProperty(fs, "ReadStream", {
|
|
582
|
+
get: function() {
|
|
583
|
+
return ReadStream;
|
|
584
|
+
},
|
|
585
|
+
set: function(val) {
|
|
586
|
+
ReadStream = val;
|
|
587
|
+
},
|
|
588
|
+
enumerable: true,
|
|
589
|
+
configurable: true
|
|
590
|
+
});
|
|
591
|
+
Object.defineProperty(fs, "WriteStream", {
|
|
592
|
+
get: function() {
|
|
593
|
+
return WriteStream;
|
|
594
|
+
},
|
|
595
|
+
set: function(val) {
|
|
596
|
+
WriteStream = val;
|
|
597
|
+
},
|
|
598
|
+
enumerable: true,
|
|
599
|
+
configurable: true
|
|
600
|
+
});
|
|
601
|
+
var FileReadStream = ReadStream;
|
|
602
|
+
Object.defineProperty(fs, "FileReadStream", {
|
|
603
|
+
get: function() {
|
|
604
|
+
return FileReadStream;
|
|
605
|
+
},
|
|
606
|
+
set: function(val) {
|
|
607
|
+
FileReadStream = val;
|
|
608
|
+
},
|
|
609
|
+
enumerable: true,
|
|
610
|
+
configurable: true
|
|
611
|
+
});
|
|
612
|
+
var FileWriteStream = WriteStream;
|
|
613
|
+
Object.defineProperty(fs, "FileWriteStream", {
|
|
614
|
+
get: function() {
|
|
615
|
+
return FileWriteStream;
|
|
616
|
+
},
|
|
617
|
+
set: function(val) {
|
|
618
|
+
FileWriteStream = val;
|
|
619
|
+
},
|
|
620
|
+
enumerable: true,
|
|
621
|
+
configurable: true
|
|
622
|
+
});
|
|
623
|
+
function ReadStream(path, options) {
|
|
624
|
+
if (this instanceof ReadStream) return fs$ReadStream.apply(this, arguments), this;
|
|
625
|
+
else return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
626
|
+
}
|
|
627
|
+
function ReadStream$open() {
|
|
628
|
+
var that = this;
|
|
629
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
630
|
+
if (err) {
|
|
631
|
+
if (that.autoClose) that.destroy();
|
|
632
|
+
that.emit("error", err);
|
|
633
|
+
} else {
|
|
634
|
+
that.fd = fd;
|
|
635
|
+
that.emit("open", fd);
|
|
636
|
+
that.read();
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
function WriteStream(path, options) {
|
|
641
|
+
if (this instanceof WriteStream) return fs$WriteStream.apply(this, arguments), this;
|
|
642
|
+
else return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
643
|
+
}
|
|
644
|
+
function WriteStream$open() {
|
|
645
|
+
var that = this;
|
|
646
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
647
|
+
if (err) {
|
|
648
|
+
that.destroy();
|
|
649
|
+
that.emit("error", err);
|
|
650
|
+
} else {
|
|
651
|
+
that.fd = fd;
|
|
652
|
+
that.emit("open", fd);
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
function createReadStream(path, options) {
|
|
657
|
+
return new fs.ReadStream(path, options);
|
|
658
|
+
}
|
|
659
|
+
function createWriteStream(path, options) {
|
|
660
|
+
return new fs.WriteStream(path, options);
|
|
661
|
+
}
|
|
662
|
+
var fs$open = fs.open;
|
|
663
|
+
fs.open = open;
|
|
664
|
+
function open(path, flags, mode, cb) {
|
|
665
|
+
if (typeof mode === "function") cb = mode, mode = null;
|
|
666
|
+
return go$open(path, flags, mode, cb);
|
|
667
|
+
function go$open(path, flags, mode, cb, startTime) {
|
|
668
|
+
return fs$open(path, flags, mode, function(err, fd) {
|
|
669
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
670
|
+
go$open,
|
|
671
|
+
[
|
|
672
|
+
path,
|
|
673
|
+
flags,
|
|
674
|
+
mode,
|
|
675
|
+
cb
|
|
676
|
+
],
|
|
677
|
+
err,
|
|
678
|
+
startTime || Date.now(),
|
|
679
|
+
Date.now()
|
|
680
|
+
]);
|
|
681
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
return fs;
|
|
686
|
+
}
|
|
687
|
+
function enqueue(elem) {
|
|
688
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
689
|
+
fs[gracefulQueue].push(elem);
|
|
690
|
+
retry();
|
|
691
|
+
}
|
|
692
|
+
var retryTimer;
|
|
693
|
+
function resetQueue() {
|
|
694
|
+
var now = Date.now();
|
|
695
|
+
for (var i = 0; i < fs[gracefulQueue].length; ++i) if (fs[gracefulQueue][i].length > 2) {
|
|
696
|
+
fs[gracefulQueue][i][3] = now;
|
|
697
|
+
fs[gracefulQueue][i][4] = now;
|
|
698
|
+
}
|
|
699
|
+
retry();
|
|
700
|
+
}
|
|
701
|
+
function retry() {
|
|
702
|
+
clearTimeout(retryTimer);
|
|
703
|
+
retryTimer = void 0;
|
|
704
|
+
if (fs[gracefulQueue].length === 0) return;
|
|
705
|
+
var elem = fs[gracefulQueue].shift();
|
|
706
|
+
var fn = elem[0];
|
|
707
|
+
var args = elem[1];
|
|
708
|
+
var err = elem[2];
|
|
709
|
+
var startTime = elem[3];
|
|
710
|
+
var lastTime = elem[4];
|
|
711
|
+
if (startTime === void 0) {
|
|
712
|
+
debug("RETRY", fn.name, args);
|
|
713
|
+
fn.apply(null, args);
|
|
714
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
715
|
+
debug("TIMEOUT", fn.name, args);
|
|
716
|
+
var cb = args.pop();
|
|
717
|
+
if (typeof cb === "function") cb.call(null, err);
|
|
718
|
+
} else {
|
|
719
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
720
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
721
|
+
if (sinceAttempt >= Math.min(sinceStart * 1.2, 100)) {
|
|
722
|
+
debug("RETRY", fn.name, args);
|
|
723
|
+
fn.apply(null, args.concat([startTime]));
|
|
724
|
+
} else fs[gracefulQueue].push(elem);
|
|
725
|
+
}
|
|
726
|
+
if (retryTimer === void 0) retryTimer = setTimeout(retry, 0);
|
|
727
|
+
}
|
|
728
|
+
}));
|
|
729
|
+
var require_fs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
730
|
+
const u = require_universalify().fromCallback;
|
|
731
|
+
const fs = require_graceful_fs();
|
|
732
|
+
const api = [
|
|
733
|
+
"access",
|
|
734
|
+
"appendFile",
|
|
735
|
+
"chmod",
|
|
736
|
+
"chown",
|
|
737
|
+
"close",
|
|
738
|
+
"copyFile",
|
|
739
|
+
"cp",
|
|
740
|
+
"fchmod",
|
|
741
|
+
"fchown",
|
|
742
|
+
"fdatasync",
|
|
743
|
+
"fstat",
|
|
744
|
+
"fsync",
|
|
745
|
+
"ftruncate",
|
|
746
|
+
"futimes",
|
|
747
|
+
"glob",
|
|
748
|
+
"lchmod",
|
|
749
|
+
"lchown",
|
|
750
|
+
"lutimes",
|
|
751
|
+
"link",
|
|
752
|
+
"lstat",
|
|
753
|
+
"mkdir",
|
|
754
|
+
"mkdtemp",
|
|
755
|
+
"open",
|
|
756
|
+
"opendir",
|
|
757
|
+
"readdir",
|
|
758
|
+
"readFile",
|
|
759
|
+
"readlink",
|
|
760
|
+
"realpath",
|
|
761
|
+
"rename",
|
|
762
|
+
"rm",
|
|
763
|
+
"rmdir",
|
|
764
|
+
"stat",
|
|
765
|
+
"statfs",
|
|
766
|
+
"symlink",
|
|
767
|
+
"truncate",
|
|
768
|
+
"unlink",
|
|
769
|
+
"utimes",
|
|
770
|
+
"writeFile"
|
|
771
|
+
].filter((key) => {
|
|
772
|
+
return typeof fs[key] === "function";
|
|
773
|
+
});
|
|
774
|
+
Object.assign(exports, fs);
|
|
775
|
+
api.forEach((method) => {
|
|
776
|
+
exports[method] = u(fs[method]);
|
|
777
|
+
});
|
|
778
|
+
exports.exists = function(filename, callback) {
|
|
779
|
+
if (typeof callback === "function") return fs.exists(filename, callback);
|
|
780
|
+
return new Promise((resolve) => {
|
|
781
|
+
return fs.exists(filename, resolve);
|
|
782
|
+
});
|
|
783
|
+
};
|
|
784
|
+
exports.read = function(fd, buffer, offset, length, position, callback) {
|
|
785
|
+
if (typeof callback === "function") return fs.read(fd, buffer, offset, length, position, callback);
|
|
786
|
+
return new Promise((resolve, reject) => {
|
|
787
|
+
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
|
|
788
|
+
if (err) return reject(err);
|
|
789
|
+
resolve({
|
|
790
|
+
bytesRead,
|
|
791
|
+
buffer
|
|
792
|
+
});
|
|
793
|
+
});
|
|
794
|
+
});
|
|
795
|
+
};
|
|
796
|
+
exports.write = function(fd, buffer, ...args) {
|
|
797
|
+
if (typeof args[args.length - 1] === "function") return fs.write(fd, buffer, ...args);
|
|
798
|
+
return new Promise((resolve, reject) => {
|
|
799
|
+
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
|
|
800
|
+
if (err) return reject(err);
|
|
801
|
+
resolve({
|
|
802
|
+
bytesWritten,
|
|
803
|
+
buffer
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
});
|
|
807
|
+
};
|
|
808
|
+
exports.readv = function(fd, buffers, ...args) {
|
|
809
|
+
if (typeof args[args.length - 1] === "function") return fs.readv(fd, buffers, ...args);
|
|
810
|
+
return new Promise((resolve, reject) => {
|
|
811
|
+
fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
|
|
812
|
+
if (err) return reject(err);
|
|
813
|
+
resolve({
|
|
814
|
+
bytesRead,
|
|
815
|
+
buffers
|
|
816
|
+
});
|
|
817
|
+
});
|
|
818
|
+
});
|
|
819
|
+
};
|
|
820
|
+
exports.writev = function(fd, buffers, ...args) {
|
|
821
|
+
if (typeof args[args.length - 1] === "function") return fs.writev(fd, buffers, ...args);
|
|
822
|
+
return new Promise((resolve, reject) => {
|
|
823
|
+
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
|
|
824
|
+
if (err) return reject(err);
|
|
825
|
+
resolve({
|
|
826
|
+
bytesWritten,
|
|
827
|
+
buffers
|
|
828
|
+
});
|
|
829
|
+
});
|
|
830
|
+
});
|
|
831
|
+
};
|
|
832
|
+
if (typeof fs.realpath.native === "function") exports.realpath.native = u(fs.realpath.native);
|
|
833
|
+
else process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?", "Warning", "fs-extra-WARN0003");
|
|
834
|
+
}));
|
|
835
|
+
var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
836
|
+
const path$11 = __require("path");
|
|
837
|
+
module.exports.checkPath = function checkPath(pth) {
|
|
838
|
+
if (process.platform === "win32") {
|
|
839
|
+
if (/[<>:"|?*]/.test(pth.replace(path$11.parse(pth).root, ""))) {
|
|
840
|
+
const error = /* @__PURE__ */ new Error(`Path contains invalid characters: ${pth}`);
|
|
841
|
+
error.code = "EINVAL";
|
|
842
|
+
throw error;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
}));
|
|
847
|
+
var require_make_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
848
|
+
const fs = require_fs();
|
|
849
|
+
const { checkPath } = require_utils$1();
|
|
850
|
+
const getMode = (options) => {
|
|
851
|
+
const defaults = { mode: 511 };
|
|
852
|
+
if (typeof options === "number") return options;
|
|
853
|
+
return {
|
|
854
|
+
...defaults,
|
|
855
|
+
...options
|
|
856
|
+
}.mode;
|
|
857
|
+
};
|
|
858
|
+
module.exports.makeDir = async (dir, options) => {
|
|
859
|
+
checkPath(dir);
|
|
860
|
+
return fs.mkdir(dir, {
|
|
861
|
+
mode: getMode(options),
|
|
862
|
+
recursive: true
|
|
863
|
+
});
|
|
864
|
+
};
|
|
865
|
+
module.exports.makeDirSync = (dir, options) => {
|
|
866
|
+
checkPath(dir);
|
|
867
|
+
return fs.mkdirSync(dir, {
|
|
868
|
+
mode: getMode(options),
|
|
869
|
+
recursive: true
|
|
870
|
+
});
|
|
871
|
+
};
|
|
872
|
+
}));
|
|
873
|
+
var require_mkdirs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
874
|
+
const u = require_universalify().fromPromise;
|
|
875
|
+
const { makeDir: _makeDir, makeDirSync } = require_make_dir();
|
|
876
|
+
const makeDir = u(_makeDir);
|
|
877
|
+
module.exports = {
|
|
878
|
+
mkdirs: makeDir,
|
|
879
|
+
mkdirsSync: makeDirSync,
|
|
880
|
+
mkdirp: makeDir,
|
|
881
|
+
mkdirpSync: makeDirSync,
|
|
882
|
+
ensureDir: makeDir,
|
|
883
|
+
ensureDirSync: makeDirSync
|
|
884
|
+
};
|
|
885
|
+
}));
|
|
886
|
+
var require_path_exists = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
887
|
+
const u = require_universalify().fromPromise;
|
|
888
|
+
const fs = require_fs();
|
|
889
|
+
function pathExists(path) {
|
|
890
|
+
return fs.access(path).then(() => true).catch(() => false);
|
|
891
|
+
}
|
|
892
|
+
module.exports = {
|
|
893
|
+
pathExists: u(pathExists),
|
|
894
|
+
pathExistsSync: fs.existsSync
|
|
895
|
+
};
|
|
896
|
+
}));
|
|
897
|
+
var require_utimes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
898
|
+
const fs = require_fs();
|
|
899
|
+
const u = require_universalify().fromPromise;
|
|
900
|
+
async function utimesMillis(path, atime, mtime) {
|
|
901
|
+
const fd = await fs.open(path, "r+");
|
|
902
|
+
let closeErr = null;
|
|
903
|
+
try {
|
|
904
|
+
await fs.futimes(fd, atime, mtime);
|
|
905
|
+
} finally {
|
|
906
|
+
try {
|
|
907
|
+
await fs.close(fd);
|
|
908
|
+
} catch (e) {
|
|
909
|
+
closeErr = e;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
if (closeErr) throw closeErr;
|
|
913
|
+
}
|
|
914
|
+
function utimesMillisSync(path, atime, mtime) {
|
|
915
|
+
const fd = fs.openSync(path, "r+");
|
|
916
|
+
fs.futimesSync(fd, atime, mtime);
|
|
917
|
+
return fs.closeSync(fd);
|
|
918
|
+
}
|
|
919
|
+
module.exports = {
|
|
920
|
+
utimesMillis: u(utimesMillis),
|
|
921
|
+
utimesMillisSync
|
|
922
|
+
};
|
|
923
|
+
}));
|
|
924
|
+
var require_stat = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
925
|
+
const fs = require_fs();
|
|
926
|
+
const path$10 = __require("path");
|
|
927
|
+
const u = require_universalify().fromPromise;
|
|
928
|
+
function getStats(src, dest, opts) {
|
|
929
|
+
const statFunc = opts.dereference ? (file) => fs.stat(file, { bigint: true }) : (file) => fs.lstat(file, { bigint: true });
|
|
930
|
+
return Promise.all([statFunc(src), statFunc(dest).catch((err) => {
|
|
931
|
+
if (err.code === "ENOENT") return null;
|
|
932
|
+
throw err;
|
|
933
|
+
})]).then(([srcStat, destStat]) => ({
|
|
934
|
+
srcStat,
|
|
935
|
+
destStat
|
|
936
|
+
}));
|
|
937
|
+
}
|
|
938
|
+
function getStatsSync(src, dest, opts) {
|
|
939
|
+
let destStat;
|
|
940
|
+
const statFunc = opts.dereference ? (file) => fs.statSync(file, { bigint: true }) : (file) => fs.lstatSync(file, { bigint: true });
|
|
941
|
+
const srcStat = statFunc(src);
|
|
942
|
+
try {
|
|
943
|
+
destStat = statFunc(dest);
|
|
944
|
+
} catch (err) {
|
|
945
|
+
if (err.code === "ENOENT") return {
|
|
946
|
+
srcStat,
|
|
947
|
+
destStat: null
|
|
948
|
+
};
|
|
949
|
+
throw err;
|
|
950
|
+
}
|
|
951
|
+
return {
|
|
952
|
+
srcStat,
|
|
953
|
+
destStat
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
async function checkPaths(src, dest, funcName, opts) {
|
|
957
|
+
const { srcStat, destStat } = await getStats(src, dest, opts);
|
|
958
|
+
if (destStat) {
|
|
959
|
+
if (areIdentical(srcStat, destStat)) {
|
|
960
|
+
const srcBaseName = path$10.basename(src);
|
|
961
|
+
const destBaseName = path$10.basename(dest);
|
|
962
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) return {
|
|
963
|
+
srcStat,
|
|
964
|
+
destStat,
|
|
965
|
+
isChangingCase: true
|
|
966
|
+
};
|
|
967
|
+
throw new Error("Source and destination must not be the same.");
|
|
968
|
+
}
|
|
969
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
970
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
971
|
+
}
|
|
972
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) throw new Error(errMsg(src, dest, funcName));
|
|
973
|
+
return {
|
|
974
|
+
srcStat,
|
|
975
|
+
destStat
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
function checkPathsSync(src, dest, funcName, opts) {
|
|
979
|
+
const { srcStat, destStat } = getStatsSync(src, dest, opts);
|
|
980
|
+
if (destStat) {
|
|
981
|
+
if (areIdentical(srcStat, destStat)) {
|
|
982
|
+
const srcBaseName = path$10.basename(src);
|
|
983
|
+
const destBaseName = path$10.basename(dest);
|
|
984
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) return {
|
|
985
|
+
srcStat,
|
|
986
|
+
destStat,
|
|
987
|
+
isChangingCase: true
|
|
988
|
+
};
|
|
989
|
+
throw new Error("Source and destination must not be the same.");
|
|
990
|
+
}
|
|
991
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
992
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
993
|
+
}
|
|
994
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) throw new Error(errMsg(src, dest, funcName));
|
|
995
|
+
return {
|
|
996
|
+
srcStat,
|
|
997
|
+
destStat
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
async function checkParentPaths(src, srcStat, dest, funcName) {
|
|
1001
|
+
const srcParent = path$10.resolve(path$10.dirname(src));
|
|
1002
|
+
const destParent = path$10.resolve(path$10.dirname(dest));
|
|
1003
|
+
if (destParent === srcParent || destParent === path$10.parse(destParent).root) return;
|
|
1004
|
+
let destStat;
|
|
1005
|
+
try {
|
|
1006
|
+
destStat = await fs.stat(destParent, { bigint: true });
|
|
1007
|
+
} catch (err) {
|
|
1008
|
+
if (err.code === "ENOENT") return;
|
|
1009
|
+
throw err;
|
|
1010
|
+
}
|
|
1011
|
+
if (areIdentical(srcStat, destStat)) throw new Error(errMsg(src, dest, funcName));
|
|
1012
|
+
return checkParentPaths(src, srcStat, destParent, funcName);
|
|
1013
|
+
}
|
|
1014
|
+
function checkParentPathsSync(src, srcStat, dest, funcName) {
|
|
1015
|
+
const srcParent = path$10.resolve(path$10.dirname(src));
|
|
1016
|
+
const destParent = path$10.resolve(path$10.dirname(dest));
|
|
1017
|
+
if (destParent === srcParent || destParent === path$10.parse(destParent).root) return;
|
|
1018
|
+
let destStat;
|
|
1019
|
+
try {
|
|
1020
|
+
destStat = fs.statSync(destParent, { bigint: true });
|
|
1021
|
+
} catch (err) {
|
|
1022
|
+
if (err.code === "ENOENT") return;
|
|
1023
|
+
throw err;
|
|
1024
|
+
}
|
|
1025
|
+
if (areIdentical(srcStat, destStat)) throw new Error(errMsg(src, dest, funcName));
|
|
1026
|
+
return checkParentPathsSync(src, srcStat, destParent, funcName);
|
|
1027
|
+
}
|
|
1028
|
+
function areIdentical(srcStat, destStat) {
|
|
1029
|
+
return destStat.ino !== void 0 && destStat.dev !== void 0 && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
|
|
1030
|
+
}
|
|
1031
|
+
function isSrcSubdir(src, dest) {
|
|
1032
|
+
const srcArr = path$10.resolve(src).split(path$10.sep).filter((i) => i);
|
|
1033
|
+
const destArr = path$10.resolve(dest).split(path$10.sep).filter((i) => i);
|
|
1034
|
+
return srcArr.every((cur, i) => destArr[i] === cur);
|
|
1035
|
+
}
|
|
1036
|
+
function errMsg(src, dest, funcName) {
|
|
1037
|
+
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
|
|
1038
|
+
}
|
|
1039
|
+
module.exports = {
|
|
1040
|
+
checkPaths: u(checkPaths),
|
|
1041
|
+
checkPathsSync,
|
|
1042
|
+
checkParentPaths: u(checkParentPaths),
|
|
1043
|
+
checkParentPathsSync,
|
|
1044
|
+
isSrcSubdir,
|
|
1045
|
+
areIdentical
|
|
1046
|
+
};
|
|
1047
|
+
}));
|
|
1048
|
+
var require_async = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1049
|
+
async function asyncIteratorConcurrentProcess(iterator, fn) {
|
|
1050
|
+
const promises = [];
|
|
1051
|
+
for await (const item of iterator) promises.push(fn(item).then(() => null, (err) => err ?? /* @__PURE__ */ new Error("unknown error")));
|
|
1052
|
+
await Promise.all(promises.map((promise) => promise.then((possibleErr) => {
|
|
1053
|
+
if (possibleErr !== null) throw possibleErr;
|
|
1054
|
+
})));
|
|
1055
|
+
}
|
|
1056
|
+
module.exports = { asyncIteratorConcurrentProcess };
|
|
1057
|
+
}));
|
|
1058
|
+
var require_copy$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1059
|
+
const fs = require_fs();
|
|
1060
|
+
const path$9 = __require("path");
|
|
1061
|
+
const { mkdirs } = require_mkdirs();
|
|
1062
|
+
const { pathExists } = require_path_exists();
|
|
1063
|
+
const { utimesMillis } = require_utimes();
|
|
1064
|
+
const stat = require_stat();
|
|
1065
|
+
const { asyncIteratorConcurrentProcess } = require_async();
|
|
1066
|
+
async function copy(src, dest, opts = {}) {
|
|
1067
|
+
if (typeof opts === "function") opts = { filter: opts };
|
|
1068
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
1069
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
1070
|
+
if (opts.preserveTimestamps && process.arch === "ia32") process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0001");
|
|
1071
|
+
const { srcStat, destStat } = await stat.checkPaths(src, dest, "copy", opts);
|
|
1072
|
+
await stat.checkParentPaths(src, srcStat, dest, "copy");
|
|
1073
|
+
if (!await runFilter(src, dest, opts)) return;
|
|
1074
|
+
const destParent = path$9.dirname(dest);
|
|
1075
|
+
if (!await pathExists(destParent)) await mkdirs(destParent);
|
|
1076
|
+
await getStatsAndPerformCopy(destStat, src, dest, opts);
|
|
1077
|
+
}
|
|
1078
|
+
async function runFilter(src, dest, opts) {
|
|
1079
|
+
if (!opts.filter) return true;
|
|
1080
|
+
return opts.filter(src, dest);
|
|
1081
|
+
}
|
|
1082
|
+
async function getStatsAndPerformCopy(destStat, src, dest, opts) {
|
|
1083
|
+
const srcStat = await (opts.dereference ? fs.stat : fs.lstat)(src);
|
|
1084
|
+
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
|
|
1085
|
+
if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
|
|
1086
|
+
if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
|
|
1087
|
+
if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
|
|
1088
|
+
if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
1089
|
+
throw new Error(`Unknown file: ${src}`);
|
|
1090
|
+
}
|
|
1091
|
+
async function onFile(srcStat, destStat, src, dest, opts) {
|
|
1092
|
+
if (!destStat) return copyFile(srcStat, src, dest, opts);
|
|
1093
|
+
if (opts.overwrite) {
|
|
1094
|
+
await fs.unlink(dest);
|
|
1095
|
+
return copyFile(srcStat, src, dest, opts);
|
|
1096
|
+
}
|
|
1097
|
+
if (opts.errorOnExist) throw new Error(`'${dest}' already exists`);
|
|
1098
|
+
}
|
|
1099
|
+
async function copyFile(srcStat, src, dest, opts) {
|
|
1100
|
+
await fs.copyFile(src, dest);
|
|
1101
|
+
if (opts.preserveTimestamps) {
|
|
1102
|
+
if (fileIsNotWritable(srcStat.mode)) await makeFileWritable(dest, srcStat.mode);
|
|
1103
|
+
const updatedSrcStat = await fs.stat(src);
|
|
1104
|
+
await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
1105
|
+
}
|
|
1106
|
+
return fs.chmod(dest, srcStat.mode);
|
|
1107
|
+
}
|
|
1108
|
+
function fileIsNotWritable(srcMode) {
|
|
1109
|
+
return (srcMode & 128) === 0;
|
|
1110
|
+
}
|
|
1111
|
+
function makeFileWritable(dest, srcMode) {
|
|
1112
|
+
return fs.chmod(dest, srcMode | 128);
|
|
1113
|
+
}
|
|
1114
|
+
async function onDir(srcStat, destStat, src, dest, opts) {
|
|
1115
|
+
if (!destStat) await fs.mkdir(dest);
|
|
1116
|
+
await asyncIteratorConcurrentProcess(await fs.opendir(src), async (item) => {
|
|
1117
|
+
const srcItem = path$9.join(src, item.name);
|
|
1118
|
+
const destItem = path$9.join(dest, item.name);
|
|
1119
|
+
if (await runFilter(srcItem, destItem, opts)) {
|
|
1120
|
+
const { destStat } = await stat.checkPaths(srcItem, destItem, "copy", opts);
|
|
1121
|
+
await getStatsAndPerformCopy(destStat, srcItem, destItem, opts);
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
if (!destStat) await fs.chmod(dest, srcStat.mode);
|
|
1125
|
+
}
|
|
1126
|
+
async function onLink(destStat, src, dest, opts) {
|
|
1127
|
+
let resolvedSrc = await fs.readlink(src);
|
|
1128
|
+
if (opts.dereference) resolvedSrc = path$9.resolve(process.cwd(), resolvedSrc);
|
|
1129
|
+
if (!destStat) return fs.symlink(resolvedSrc, dest);
|
|
1130
|
+
let resolvedDest = null;
|
|
1131
|
+
try {
|
|
1132
|
+
resolvedDest = await fs.readlink(dest);
|
|
1133
|
+
} catch (e) {
|
|
1134
|
+
if (e.code === "EINVAL" || e.code === "UNKNOWN") return fs.symlink(resolvedSrc, dest);
|
|
1135
|
+
throw e;
|
|
1136
|
+
}
|
|
1137
|
+
if (opts.dereference) resolvedDest = path$9.resolve(process.cwd(), resolvedDest);
|
|
1138
|
+
if (resolvedSrc !== resolvedDest) {
|
|
1139
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
1140
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
1141
|
+
}
|
|
1142
|
+
await fs.unlink(dest);
|
|
1143
|
+
return fs.symlink(resolvedSrc, dest);
|
|
1144
|
+
}
|
|
1145
|
+
module.exports = copy;
|
|
1146
|
+
}));
|
|
1147
|
+
var require_copy_sync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1148
|
+
const fs = require_graceful_fs();
|
|
1149
|
+
const path$8 = __require("path");
|
|
1150
|
+
const mkdirsSync = require_mkdirs().mkdirsSync;
|
|
1151
|
+
const utimesMillisSync = require_utimes().utimesMillisSync;
|
|
1152
|
+
const stat = require_stat();
|
|
1153
|
+
function copySync(src, dest, opts) {
|
|
1154
|
+
if (typeof opts === "function") opts = { filter: opts };
|
|
1155
|
+
opts = opts || {};
|
|
1156
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
1157
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
1158
|
+
if (opts.preserveTimestamps && process.arch === "ia32") process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0002");
|
|
1159
|
+
const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
|
|
1160
|
+
stat.checkParentPathsSync(src, srcStat, dest, "copy");
|
|
1161
|
+
if (opts.filter && !opts.filter(src, dest)) return;
|
|
1162
|
+
const destParent = path$8.dirname(dest);
|
|
1163
|
+
if (!fs.existsSync(destParent)) mkdirsSync(destParent);
|
|
1164
|
+
return getStats(destStat, src, dest, opts);
|
|
1165
|
+
}
|
|
1166
|
+
function getStats(destStat, src, dest, opts) {
|
|
1167
|
+
const srcStat = (opts.dereference ? fs.statSync : fs.lstatSync)(src);
|
|
1168
|
+
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
|
|
1169
|
+
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
|
|
1170
|
+
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
|
|
1171
|
+
else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
|
|
1172
|
+
else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
1173
|
+
throw new Error(`Unknown file: ${src}`);
|
|
1174
|
+
}
|
|
1175
|
+
function onFile(srcStat, destStat, src, dest, opts) {
|
|
1176
|
+
if (!destStat) return copyFile(srcStat, src, dest, opts);
|
|
1177
|
+
return mayCopyFile(srcStat, src, dest, opts);
|
|
1178
|
+
}
|
|
1179
|
+
function mayCopyFile(srcStat, src, dest, opts) {
|
|
1180
|
+
if (opts.overwrite) {
|
|
1181
|
+
fs.unlinkSync(dest);
|
|
1182
|
+
return copyFile(srcStat, src, dest, opts);
|
|
1183
|
+
} else if (opts.errorOnExist) throw new Error(`'${dest}' already exists`);
|
|
1184
|
+
}
|
|
1185
|
+
function copyFile(srcStat, src, dest, opts) {
|
|
1186
|
+
fs.copyFileSync(src, dest);
|
|
1187
|
+
if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
|
|
1188
|
+
return setDestMode(dest, srcStat.mode);
|
|
1189
|
+
}
|
|
1190
|
+
function handleTimestamps(srcMode, src, dest) {
|
|
1191
|
+
if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
|
|
1192
|
+
return setDestTimestamps(src, dest);
|
|
1193
|
+
}
|
|
1194
|
+
function fileIsNotWritable(srcMode) {
|
|
1195
|
+
return (srcMode & 128) === 0;
|
|
1196
|
+
}
|
|
1197
|
+
function makeFileWritable(dest, srcMode) {
|
|
1198
|
+
return setDestMode(dest, srcMode | 128);
|
|
1199
|
+
}
|
|
1200
|
+
function setDestMode(dest, srcMode) {
|
|
1201
|
+
return fs.chmodSync(dest, srcMode);
|
|
1202
|
+
}
|
|
1203
|
+
function setDestTimestamps(src, dest) {
|
|
1204
|
+
const updatedSrcStat = fs.statSync(src);
|
|
1205
|
+
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
1206
|
+
}
|
|
1207
|
+
function onDir(srcStat, destStat, src, dest, opts) {
|
|
1208
|
+
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts);
|
|
1209
|
+
return copyDir(src, dest, opts);
|
|
1210
|
+
}
|
|
1211
|
+
function mkDirAndCopy(srcMode, src, dest, opts) {
|
|
1212
|
+
fs.mkdirSync(dest);
|
|
1213
|
+
copyDir(src, dest, opts);
|
|
1214
|
+
return setDestMode(dest, srcMode);
|
|
1215
|
+
}
|
|
1216
|
+
function copyDir(src, dest, opts) {
|
|
1217
|
+
const dir = fs.opendirSync(src);
|
|
1218
|
+
try {
|
|
1219
|
+
let dirent;
|
|
1220
|
+
while ((dirent = dir.readSync()) !== null) copyDirItem(dirent.name, src, dest, opts);
|
|
1221
|
+
} finally {
|
|
1222
|
+
dir.closeSync();
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
function copyDirItem(item, src, dest, opts) {
|
|
1226
|
+
const srcItem = path$8.join(src, item);
|
|
1227
|
+
const destItem = path$8.join(dest, item);
|
|
1228
|
+
if (opts.filter && !opts.filter(srcItem, destItem)) return;
|
|
1229
|
+
const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
|
|
1230
|
+
return getStats(destStat, srcItem, destItem, opts);
|
|
1231
|
+
}
|
|
1232
|
+
function onLink(destStat, src, dest, opts) {
|
|
1233
|
+
let resolvedSrc = fs.readlinkSync(src);
|
|
1234
|
+
if (opts.dereference) resolvedSrc = path$8.resolve(process.cwd(), resolvedSrc);
|
|
1235
|
+
if (!destStat) return fs.symlinkSync(resolvedSrc, dest);
|
|
1236
|
+
else {
|
|
1237
|
+
let resolvedDest;
|
|
1238
|
+
try {
|
|
1239
|
+
resolvedDest = fs.readlinkSync(dest);
|
|
1240
|
+
} catch (err) {
|
|
1241
|
+
if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs.symlinkSync(resolvedSrc, dest);
|
|
1242
|
+
throw err;
|
|
1243
|
+
}
|
|
1244
|
+
if (opts.dereference) resolvedDest = path$8.resolve(process.cwd(), resolvedDest);
|
|
1245
|
+
if (resolvedSrc !== resolvedDest) {
|
|
1246
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
1247
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
1248
|
+
}
|
|
1249
|
+
return copyLink(resolvedSrc, dest);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
function copyLink(resolvedSrc, dest) {
|
|
1253
|
+
fs.unlinkSync(dest);
|
|
1254
|
+
return fs.symlinkSync(resolvedSrc, dest);
|
|
1255
|
+
}
|
|
1256
|
+
module.exports = copySync;
|
|
1257
|
+
}));
|
|
1258
|
+
var require_copy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1259
|
+
const u = require_universalify().fromPromise;
|
|
1260
|
+
module.exports = {
|
|
1261
|
+
copy: u(require_copy$1()),
|
|
1262
|
+
copySync: require_copy_sync()
|
|
1263
|
+
};
|
|
1264
|
+
}));
|
|
1265
|
+
var require_remove = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1266
|
+
const fs = require_graceful_fs();
|
|
1267
|
+
const u = require_universalify().fromCallback;
|
|
1268
|
+
function remove(path, callback) {
|
|
1269
|
+
fs.rm(path, {
|
|
1270
|
+
recursive: true,
|
|
1271
|
+
force: true
|
|
1272
|
+
}, callback);
|
|
1273
|
+
}
|
|
1274
|
+
function removeSync(path) {
|
|
1275
|
+
fs.rmSync(path, {
|
|
1276
|
+
recursive: true,
|
|
1277
|
+
force: true
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
module.exports = {
|
|
1281
|
+
remove: u(remove),
|
|
1282
|
+
removeSync
|
|
1283
|
+
};
|
|
1284
|
+
}));
|
|
1285
|
+
var require_empty = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1286
|
+
const u = require_universalify().fromPromise;
|
|
1287
|
+
const fs = require_fs();
|
|
1288
|
+
const path$7 = __require("path");
|
|
1289
|
+
const mkdir = require_mkdirs();
|
|
1290
|
+
const remove = require_remove();
|
|
1291
|
+
const emptyDir = u(async function emptyDir(dir) {
|
|
1292
|
+
let items;
|
|
1293
|
+
try {
|
|
1294
|
+
items = await fs.readdir(dir);
|
|
1295
|
+
} catch {
|
|
1296
|
+
return mkdir.mkdirs(dir);
|
|
1297
|
+
}
|
|
1298
|
+
return Promise.all(items.map((item) => remove.remove(path$7.join(dir, item))));
|
|
1299
|
+
});
|
|
1300
|
+
function emptyDirSync(dir) {
|
|
1301
|
+
let items;
|
|
1302
|
+
try {
|
|
1303
|
+
items = fs.readdirSync(dir);
|
|
1304
|
+
} catch {
|
|
1305
|
+
return mkdir.mkdirsSync(dir);
|
|
1306
|
+
}
|
|
1307
|
+
items.forEach((item) => {
|
|
1308
|
+
item = path$7.join(dir, item);
|
|
1309
|
+
remove.removeSync(item);
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
module.exports = {
|
|
1313
|
+
emptyDirSync,
|
|
1314
|
+
emptydirSync: emptyDirSync,
|
|
1315
|
+
emptyDir,
|
|
1316
|
+
emptydir: emptyDir
|
|
1317
|
+
};
|
|
1318
|
+
}));
|
|
1319
|
+
var require_file = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1320
|
+
const u = require_universalify().fromPromise;
|
|
1321
|
+
const path$6 = __require("path");
|
|
1322
|
+
const fs = require_fs();
|
|
1323
|
+
const mkdir = require_mkdirs();
|
|
1324
|
+
async function createFile(file) {
|
|
1325
|
+
let stats;
|
|
1326
|
+
try {
|
|
1327
|
+
stats = await fs.stat(file);
|
|
1328
|
+
} catch {}
|
|
1329
|
+
if (stats && stats.isFile()) return;
|
|
1330
|
+
const dir = path$6.dirname(file);
|
|
1331
|
+
let dirStats = null;
|
|
1332
|
+
try {
|
|
1333
|
+
dirStats = await fs.stat(dir);
|
|
1334
|
+
} catch (err) {
|
|
1335
|
+
if (err.code === "ENOENT") {
|
|
1336
|
+
await mkdir.mkdirs(dir);
|
|
1337
|
+
await fs.writeFile(file, "");
|
|
1338
|
+
return;
|
|
1339
|
+
} else throw err;
|
|
1340
|
+
}
|
|
1341
|
+
if (dirStats.isDirectory()) await fs.writeFile(file, "");
|
|
1342
|
+
else await fs.readdir(dir);
|
|
1343
|
+
}
|
|
1344
|
+
function createFileSync(file) {
|
|
1345
|
+
let stats;
|
|
1346
|
+
try {
|
|
1347
|
+
stats = fs.statSync(file);
|
|
1348
|
+
} catch {}
|
|
1349
|
+
if (stats && stats.isFile()) return;
|
|
1350
|
+
const dir = path$6.dirname(file);
|
|
1351
|
+
try {
|
|
1352
|
+
if (!fs.statSync(dir).isDirectory()) fs.readdirSync(dir);
|
|
1353
|
+
} catch (err) {
|
|
1354
|
+
if (err && err.code === "ENOENT") mkdir.mkdirsSync(dir);
|
|
1355
|
+
else throw err;
|
|
1356
|
+
}
|
|
1357
|
+
fs.writeFileSync(file, "");
|
|
1358
|
+
}
|
|
1359
|
+
module.exports = {
|
|
1360
|
+
createFile: u(createFile),
|
|
1361
|
+
createFileSync
|
|
1362
|
+
};
|
|
1363
|
+
}));
|
|
1364
|
+
var require_link = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1365
|
+
const u = require_universalify().fromPromise;
|
|
1366
|
+
const path$5 = __require("path");
|
|
1367
|
+
const fs = require_fs();
|
|
1368
|
+
const mkdir = require_mkdirs();
|
|
1369
|
+
const { pathExists } = require_path_exists();
|
|
1370
|
+
const { areIdentical } = require_stat();
|
|
1371
|
+
async function createLink(srcpath, dstpath) {
|
|
1372
|
+
let dstStat;
|
|
1373
|
+
try {
|
|
1374
|
+
dstStat = await fs.lstat(dstpath);
|
|
1375
|
+
} catch {}
|
|
1376
|
+
let srcStat;
|
|
1377
|
+
try {
|
|
1378
|
+
srcStat = await fs.lstat(srcpath);
|
|
1379
|
+
} catch (err) {
|
|
1380
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
1381
|
+
throw err;
|
|
1382
|
+
}
|
|
1383
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return;
|
|
1384
|
+
const dir = path$5.dirname(dstpath);
|
|
1385
|
+
if (!await pathExists(dir)) await mkdir.mkdirs(dir);
|
|
1386
|
+
await fs.link(srcpath, dstpath);
|
|
1387
|
+
}
|
|
1388
|
+
function createLinkSync(srcpath, dstpath) {
|
|
1389
|
+
let dstStat;
|
|
1390
|
+
try {
|
|
1391
|
+
dstStat = fs.lstatSync(dstpath);
|
|
1392
|
+
} catch {}
|
|
1393
|
+
try {
|
|
1394
|
+
const srcStat = fs.lstatSync(srcpath);
|
|
1395
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return;
|
|
1396
|
+
} catch (err) {
|
|
1397
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
1398
|
+
throw err;
|
|
1399
|
+
}
|
|
1400
|
+
const dir = path$5.dirname(dstpath);
|
|
1401
|
+
if (fs.existsSync(dir)) return fs.linkSync(srcpath, dstpath);
|
|
1402
|
+
mkdir.mkdirsSync(dir);
|
|
1403
|
+
return fs.linkSync(srcpath, dstpath);
|
|
1404
|
+
}
|
|
1405
|
+
module.exports = {
|
|
1406
|
+
createLink: u(createLink),
|
|
1407
|
+
createLinkSync
|
|
1408
|
+
};
|
|
1409
|
+
}));
|
|
1410
|
+
var require_symlink_paths = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1411
|
+
const path$4 = __require("path");
|
|
1412
|
+
const fs = require_fs();
|
|
1413
|
+
const { pathExists } = require_path_exists();
|
|
1414
|
+
const u = require_universalify().fromPromise;
|
|
1415
|
+
async function symlinkPaths(srcpath, dstpath) {
|
|
1416
|
+
if (path$4.isAbsolute(srcpath)) {
|
|
1417
|
+
try {
|
|
1418
|
+
await fs.lstat(srcpath);
|
|
1419
|
+
} catch (err) {
|
|
1420
|
+
err.message = err.message.replace("lstat", "ensureSymlink");
|
|
1421
|
+
throw err;
|
|
1422
|
+
}
|
|
1423
|
+
return {
|
|
1424
|
+
toCwd: srcpath,
|
|
1425
|
+
toDst: srcpath
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
const dstdir = path$4.dirname(dstpath);
|
|
1429
|
+
const relativeToDst = path$4.join(dstdir, srcpath);
|
|
1430
|
+
if (await pathExists(relativeToDst)) return {
|
|
1431
|
+
toCwd: relativeToDst,
|
|
1432
|
+
toDst: srcpath
|
|
1433
|
+
};
|
|
1434
|
+
try {
|
|
1435
|
+
await fs.lstat(srcpath);
|
|
1436
|
+
} catch (err) {
|
|
1437
|
+
err.message = err.message.replace("lstat", "ensureSymlink");
|
|
1438
|
+
throw err;
|
|
1439
|
+
}
|
|
1440
|
+
return {
|
|
1441
|
+
toCwd: srcpath,
|
|
1442
|
+
toDst: path$4.relative(dstdir, srcpath)
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1445
|
+
function symlinkPathsSync(srcpath, dstpath) {
|
|
1446
|
+
if (path$4.isAbsolute(srcpath)) {
|
|
1447
|
+
if (!fs.existsSync(srcpath)) throw new Error("absolute srcpath does not exist");
|
|
1448
|
+
return {
|
|
1449
|
+
toCwd: srcpath,
|
|
1450
|
+
toDst: srcpath
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
const dstdir = path$4.dirname(dstpath);
|
|
1454
|
+
const relativeToDst = path$4.join(dstdir, srcpath);
|
|
1455
|
+
if (fs.existsSync(relativeToDst)) return {
|
|
1456
|
+
toCwd: relativeToDst,
|
|
1457
|
+
toDst: srcpath
|
|
1458
|
+
};
|
|
1459
|
+
if (!fs.existsSync(srcpath)) throw new Error("relative srcpath does not exist");
|
|
1460
|
+
return {
|
|
1461
|
+
toCwd: srcpath,
|
|
1462
|
+
toDst: path$4.relative(dstdir, srcpath)
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
module.exports = {
|
|
1466
|
+
symlinkPaths: u(symlinkPaths),
|
|
1467
|
+
symlinkPathsSync
|
|
1468
|
+
};
|
|
1469
|
+
}));
|
|
1470
|
+
var require_symlink_type = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1471
|
+
const fs = require_fs();
|
|
1472
|
+
const u = require_universalify().fromPromise;
|
|
1473
|
+
async function symlinkType(srcpath, type) {
|
|
1474
|
+
if (type) return type;
|
|
1475
|
+
let stats;
|
|
1476
|
+
try {
|
|
1477
|
+
stats = await fs.lstat(srcpath);
|
|
1478
|
+
} catch {
|
|
1479
|
+
return "file";
|
|
1480
|
+
}
|
|
1481
|
+
return stats && stats.isDirectory() ? "dir" : "file";
|
|
1482
|
+
}
|
|
1483
|
+
function symlinkTypeSync(srcpath, type) {
|
|
1484
|
+
if (type) return type;
|
|
1485
|
+
let stats;
|
|
1486
|
+
try {
|
|
1487
|
+
stats = fs.lstatSync(srcpath);
|
|
1488
|
+
} catch {
|
|
1489
|
+
return "file";
|
|
1490
|
+
}
|
|
1491
|
+
return stats && stats.isDirectory() ? "dir" : "file";
|
|
1492
|
+
}
|
|
1493
|
+
module.exports = {
|
|
1494
|
+
symlinkType: u(symlinkType),
|
|
1495
|
+
symlinkTypeSync
|
|
1496
|
+
};
|
|
1497
|
+
}));
|
|
1498
|
+
var require_symlink = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1499
|
+
const u = require_universalify().fromPromise;
|
|
1500
|
+
const path$3 = __require("path");
|
|
1501
|
+
const fs = require_fs();
|
|
1502
|
+
const { mkdirs, mkdirsSync } = require_mkdirs();
|
|
1503
|
+
const { symlinkPaths, symlinkPathsSync } = require_symlink_paths();
|
|
1504
|
+
const { symlinkType, symlinkTypeSync } = require_symlink_type();
|
|
1505
|
+
const { pathExists } = require_path_exists();
|
|
1506
|
+
const { areIdentical } = require_stat();
|
|
1507
|
+
async function createSymlink(srcpath, dstpath, type) {
|
|
1508
|
+
let stats;
|
|
1509
|
+
try {
|
|
1510
|
+
stats = await fs.lstat(dstpath);
|
|
1511
|
+
} catch {}
|
|
1512
|
+
if (stats && stats.isSymbolicLink()) {
|
|
1513
|
+
const [srcStat, dstStat] = await Promise.all([fs.stat(srcpath), fs.stat(dstpath)]);
|
|
1514
|
+
if (areIdentical(srcStat, dstStat)) return;
|
|
1515
|
+
}
|
|
1516
|
+
const relative = await symlinkPaths(srcpath, dstpath);
|
|
1517
|
+
srcpath = relative.toDst;
|
|
1518
|
+
const toType = await symlinkType(relative.toCwd, type);
|
|
1519
|
+
const dir = path$3.dirname(dstpath);
|
|
1520
|
+
if (!await pathExists(dir)) await mkdirs(dir);
|
|
1521
|
+
return fs.symlink(srcpath, dstpath, toType);
|
|
1522
|
+
}
|
|
1523
|
+
function createSymlinkSync(srcpath, dstpath, type) {
|
|
1524
|
+
let stats;
|
|
1525
|
+
try {
|
|
1526
|
+
stats = fs.lstatSync(dstpath);
|
|
1527
|
+
} catch {}
|
|
1528
|
+
if (stats && stats.isSymbolicLink()) {
|
|
1529
|
+
if (areIdentical(fs.statSync(srcpath), fs.statSync(dstpath))) return;
|
|
1530
|
+
}
|
|
1531
|
+
const relative = symlinkPathsSync(srcpath, dstpath);
|
|
1532
|
+
srcpath = relative.toDst;
|
|
1533
|
+
type = symlinkTypeSync(relative.toCwd, type);
|
|
1534
|
+
const dir = path$3.dirname(dstpath);
|
|
1535
|
+
if (fs.existsSync(dir)) return fs.symlinkSync(srcpath, dstpath, type);
|
|
1536
|
+
mkdirsSync(dir);
|
|
1537
|
+
return fs.symlinkSync(srcpath, dstpath, type);
|
|
1538
|
+
}
|
|
1539
|
+
module.exports = {
|
|
1540
|
+
createSymlink: u(createSymlink),
|
|
1541
|
+
createSymlinkSync
|
|
1542
|
+
};
|
|
1543
|
+
}));
|
|
1544
|
+
var require_ensure = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1545
|
+
const { createFile, createFileSync } = require_file();
|
|
1546
|
+
const { createLink, createLinkSync } = require_link();
|
|
1547
|
+
const { createSymlink, createSymlinkSync } = require_symlink();
|
|
1548
|
+
module.exports = {
|
|
1549
|
+
createFile,
|
|
1550
|
+
createFileSync,
|
|
1551
|
+
ensureFile: createFile,
|
|
1552
|
+
ensureFileSync: createFileSync,
|
|
1553
|
+
createLink,
|
|
1554
|
+
createLinkSync,
|
|
1555
|
+
ensureLink: createLink,
|
|
1556
|
+
ensureLinkSync: createLinkSync,
|
|
1557
|
+
createSymlink,
|
|
1558
|
+
createSymlinkSync,
|
|
1559
|
+
ensureSymlink: createSymlink,
|
|
1560
|
+
ensureSymlinkSync: createSymlinkSync
|
|
1561
|
+
};
|
|
1562
|
+
}));
|
|
1563
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1564
|
+
function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
|
|
1565
|
+
const EOF = finalEOL ? EOL : "";
|
|
1566
|
+
return JSON.stringify(obj, replacer, spaces).replace(/\n/g, EOL) + EOF;
|
|
1567
|
+
}
|
|
1568
|
+
function stripBom(content) {
|
|
1569
|
+
if (Buffer.isBuffer(content)) content = content.toString("utf8");
|
|
1570
|
+
return content.replace(/^\uFEFF/, "");
|
|
1571
|
+
}
|
|
1572
|
+
module.exports = {
|
|
1573
|
+
stringify,
|
|
1574
|
+
stripBom
|
|
1575
|
+
};
|
|
1576
|
+
}));
|
|
1577
|
+
var require_jsonfile$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1578
|
+
let _fs;
|
|
1579
|
+
try {
|
|
1580
|
+
_fs = require_graceful_fs();
|
|
1581
|
+
} catch (_) {
|
|
1582
|
+
_fs = __require("fs");
|
|
1583
|
+
}
|
|
1584
|
+
const universalify = require_universalify();
|
|
1585
|
+
const { stringify, stripBom } = require_utils();
|
|
1586
|
+
async function _readFile(file, options = {}) {
|
|
1587
|
+
if (typeof options === "string") options = { encoding: options };
|
|
1588
|
+
const fs = options.fs || _fs;
|
|
1589
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
1590
|
+
let data = await universalify.fromCallback(fs.readFile)(file, options);
|
|
1591
|
+
data = stripBom(data);
|
|
1592
|
+
let obj;
|
|
1593
|
+
try {
|
|
1594
|
+
obj = JSON.parse(data, options ? options.reviver : null);
|
|
1595
|
+
} catch (err) {
|
|
1596
|
+
if (shouldThrow) {
|
|
1597
|
+
err.message = `${file}: ${err.message}`;
|
|
1598
|
+
throw err;
|
|
1599
|
+
} else return null;
|
|
1600
|
+
}
|
|
1601
|
+
return obj;
|
|
1602
|
+
}
|
|
1603
|
+
const readFile = universalify.fromPromise(_readFile);
|
|
1604
|
+
function readFileSync(file, options = {}) {
|
|
1605
|
+
if (typeof options === "string") options = { encoding: options };
|
|
1606
|
+
const fs = options.fs || _fs;
|
|
1607
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
1608
|
+
try {
|
|
1609
|
+
let content = fs.readFileSync(file, options);
|
|
1610
|
+
content = stripBom(content);
|
|
1611
|
+
return JSON.parse(content, options.reviver);
|
|
1612
|
+
} catch (err) {
|
|
1613
|
+
if (shouldThrow) {
|
|
1614
|
+
err.message = `${file}: ${err.message}`;
|
|
1615
|
+
throw err;
|
|
1616
|
+
} else return null;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
async function _writeFile(file, obj, options = {}) {
|
|
1620
|
+
const fs = options.fs || _fs;
|
|
1621
|
+
const str = stringify(obj, options);
|
|
1622
|
+
await universalify.fromCallback(fs.writeFile)(file, str, options);
|
|
1623
|
+
}
|
|
1624
|
+
const writeFile = universalify.fromPromise(_writeFile);
|
|
1625
|
+
function writeFileSync(file, obj, options = {}) {
|
|
1626
|
+
const fs = options.fs || _fs;
|
|
1627
|
+
const str = stringify(obj, options);
|
|
1628
|
+
return fs.writeFileSync(file, str, options);
|
|
1629
|
+
}
|
|
1630
|
+
module.exports = {
|
|
1631
|
+
readFile,
|
|
1632
|
+
readFileSync,
|
|
1633
|
+
writeFile,
|
|
1634
|
+
writeFileSync
|
|
1635
|
+
};
|
|
1636
|
+
}));
|
|
1637
|
+
var require_jsonfile = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1638
|
+
const jsonFile = require_jsonfile$1();
|
|
1639
|
+
module.exports = {
|
|
1640
|
+
readJson: jsonFile.readFile,
|
|
1641
|
+
readJsonSync: jsonFile.readFileSync,
|
|
1642
|
+
writeJson: jsonFile.writeFile,
|
|
1643
|
+
writeJsonSync: jsonFile.writeFileSync
|
|
1644
|
+
};
|
|
1645
|
+
}));
|
|
1646
|
+
var require_output_file = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1647
|
+
const u = require_universalify().fromPromise;
|
|
1648
|
+
const fs = require_fs();
|
|
1649
|
+
const path$2 = __require("path");
|
|
1650
|
+
const mkdir = require_mkdirs();
|
|
1651
|
+
const pathExists = require_path_exists().pathExists;
|
|
1652
|
+
async function outputFile(file, data, encoding = "utf-8") {
|
|
1653
|
+
const dir = path$2.dirname(file);
|
|
1654
|
+
if (!await pathExists(dir)) await mkdir.mkdirs(dir);
|
|
1655
|
+
return fs.writeFile(file, data, encoding);
|
|
1656
|
+
}
|
|
1657
|
+
function outputFileSync(file, ...args) {
|
|
1658
|
+
const dir = path$2.dirname(file);
|
|
1659
|
+
if (!fs.existsSync(dir)) mkdir.mkdirsSync(dir);
|
|
1660
|
+
fs.writeFileSync(file, ...args);
|
|
1661
|
+
}
|
|
1662
|
+
module.exports = {
|
|
1663
|
+
outputFile: u(outputFile),
|
|
1664
|
+
outputFileSync
|
|
1665
|
+
};
|
|
1666
|
+
}));
|
|
1667
|
+
var require_output_json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1668
|
+
const { stringify } = require_utils();
|
|
1669
|
+
const { outputFile } = require_output_file();
|
|
1670
|
+
async function outputJson(file, data, options = {}) {
|
|
1671
|
+
await outputFile(file, stringify(data, options), options);
|
|
1672
|
+
}
|
|
1673
|
+
module.exports = outputJson;
|
|
1674
|
+
}));
|
|
1675
|
+
var require_output_json_sync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1676
|
+
const { stringify } = require_utils();
|
|
1677
|
+
const { outputFileSync } = require_output_file();
|
|
1678
|
+
function outputJsonSync(file, data, options) {
|
|
1679
|
+
outputFileSync(file, stringify(data, options), options);
|
|
1680
|
+
}
|
|
1681
|
+
module.exports = outputJsonSync;
|
|
1682
|
+
}));
|
|
1683
|
+
var require_json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1684
|
+
const u = require_universalify().fromPromise;
|
|
1685
|
+
const jsonFile = require_jsonfile();
|
|
1686
|
+
jsonFile.outputJson = u(require_output_json());
|
|
1687
|
+
jsonFile.outputJsonSync = require_output_json_sync();
|
|
1688
|
+
jsonFile.outputJSON = jsonFile.outputJson;
|
|
1689
|
+
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
|
|
1690
|
+
jsonFile.writeJSON = jsonFile.writeJson;
|
|
1691
|
+
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
|
|
1692
|
+
jsonFile.readJSON = jsonFile.readJson;
|
|
1693
|
+
jsonFile.readJSONSync = jsonFile.readJsonSync;
|
|
1694
|
+
module.exports = jsonFile;
|
|
1695
|
+
}));
|
|
1696
|
+
var require_move$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1697
|
+
const fs = require_fs();
|
|
1698
|
+
const path$1 = __require("path");
|
|
1699
|
+
const { copy } = require_copy();
|
|
1700
|
+
const { remove } = require_remove();
|
|
1701
|
+
const { mkdirp } = require_mkdirs();
|
|
1702
|
+
const { pathExists } = require_path_exists();
|
|
1703
|
+
const stat = require_stat();
|
|
1704
|
+
async function move(src, dest, opts = {}) {
|
|
1705
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
1706
|
+
const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, "move", opts);
|
|
1707
|
+
await stat.checkParentPaths(src, srcStat, dest, "move");
|
|
1708
|
+
const destParent = path$1.dirname(dest);
|
|
1709
|
+
if (path$1.parse(destParent).root !== destParent) await mkdirp(destParent);
|
|
1710
|
+
return doRename(src, dest, overwrite, isChangingCase);
|
|
1711
|
+
}
|
|
1712
|
+
async function doRename(src, dest, overwrite, isChangingCase) {
|
|
1713
|
+
if (!isChangingCase) {
|
|
1714
|
+
if (overwrite) await remove(dest);
|
|
1715
|
+
else if (await pathExists(dest)) throw new Error("dest already exists.");
|
|
1716
|
+
}
|
|
1717
|
+
try {
|
|
1718
|
+
await fs.rename(src, dest);
|
|
1719
|
+
} catch (err) {
|
|
1720
|
+
if (err.code !== "EXDEV") throw err;
|
|
1721
|
+
await moveAcrossDevice(src, dest, overwrite);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
async function moveAcrossDevice(src, dest, overwrite) {
|
|
1725
|
+
await copy(src, dest, {
|
|
1726
|
+
overwrite,
|
|
1727
|
+
errorOnExist: true,
|
|
1728
|
+
preserveTimestamps: true
|
|
1729
|
+
});
|
|
1730
|
+
return remove(src);
|
|
1731
|
+
}
|
|
1732
|
+
module.exports = move;
|
|
1733
|
+
}));
|
|
1734
|
+
var require_move_sync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1735
|
+
const fs = require_graceful_fs();
|
|
1736
|
+
const path = __require("path");
|
|
1737
|
+
const copySync = require_copy().copySync;
|
|
1738
|
+
const removeSync = require_remove().removeSync;
|
|
1739
|
+
const mkdirpSync = require_mkdirs().mkdirpSync;
|
|
1740
|
+
const stat = require_stat();
|
|
1741
|
+
function moveSync(src, dest, opts) {
|
|
1742
|
+
opts = opts || {};
|
|
1743
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
1744
|
+
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
|
|
1745
|
+
stat.checkParentPathsSync(src, srcStat, dest, "move");
|
|
1746
|
+
if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest));
|
|
1747
|
+
return doRename(src, dest, overwrite, isChangingCase);
|
|
1748
|
+
}
|
|
1749
|
+
function isParentRoot(dest) {
|
|
1750
|
+
const parent = path.dirname(dest);
|
|
1751
|
+
return path.parse(parent).root === parent;
|
|
1752
|
+
}
|
|
1753
|
+
function doRename(src, dest, overwrite, isChangingCase) {
|
|
1754
|
+
if (isChangingCase) return rename(src, dest, overwrite);
|
|
1755
|
+
if (overwrite) {
|
|
1756
|
+
removeSync(dest);
|
|
1757
|
+
return rename(src, dest, overwrite);
|
|
1758
|
+
}
|
|
1759
|
+
if (fs.existsSync(dest)) throw new Error("dest already exists.");
|
|
1760
|
+
return rename(src, dest, overwrite);
|
|
1761
|
+
}
|
|
1762
|
+
function rename(src, dest, overwrite) {
|
|
1763
|
+
try {
|
|
1764
|
+
fs.renameSync(src, dest);
|
|
1765
|
+
} catch (err) {
|
|
1766
|
+
if (err.code !== "EXDEV") throw err;
|
|
1767
|
+
return moveAcrossDevice(src, dest, overwrite);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
function moveAcrossDevice(src, dest, overwrite) {
|
|
1771
|
+
copySync(src, dest, {
|
|
1772
|
+
overwrite,
|
|
1773
|
+
errorOnExist: true,
|
|
1774
|
+
preserveTimestamps: true
|
|
1775
|
+
});
|
|
1776
|
+
return removeSync(src);
|
|
1777
|
+
}
|
|
1778
|
+
module.exports = moveSync;
|
|
1779
|
+
}));
|
|
1780
|
+
var require_move = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1781
|
+
const u = require_universalify().fromPromise;
|
|
1782
|
+
module.exports = {
|
|
1783
|
+
move: u(require_move$1()),
|
|
1784
|
+
moveSync: require_move_sync()
|
|
1785
|
+
};
|
|
1786
|
+
}));
|
|
1787
|
+
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1788
|
+
module.exports = {
|
|
1789
|
+
...require_fs(),
|
|
1790
|
+
...require_copy(),
|
|
1791
|
+
...require_empty(),
|
|
1792
|
+
...require_ensure(),
|
|
1793
|
+
...require_json(),
|
|
1794
|
+
...require_mkdirs(),
|
|
1795
|
+
...require_move(),
|
|
1796
|
+
...require_output_file(),
|
|
1797
|
+
...require_path_exists(),
|
|
1798
|
+
...require_remove()
|
|
1799
|
+
};
|
|
1800
|
+
}));
|
|
1801
|
+
export { require_graceful_fs as n, require_lib as t };
|