@wzyjs/cli 0.2.12 → 0.2.37
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/bin/mi.js +2 -2
- package/dist/index.js +3392 -16
- package/package.json +9 -32
- package/dist/commands/build/index.d.ts +0 -3
- package/dist/commands/build/index.js +0 -71
- package/dist/commands/dev/index.d.ts +0 -3
- package/dist/commands/dev/index.js +0 -24
- package/dist/commands/merge/index.d.ts +0 -3
- package/dist/commands/merge/index.js +0 -13
- package/dist/commands/merge/script.d.ts +0 -6
- package/dist/commands/merge/script.js +0 -58
- package/dist/commands/start/index.d.ts +0 -3
- package/dist/commands/start/index.js +0 -56
- package/dist/index.d.ts +0 -1
- package/dist/plugins/maxAlias.d.ts +0 -3
- package/dist/plugins/maxAlias.js +0 -11
- package/dist/plugins/maxAppData.d.ts +0 -3
- package/dist/plugins/maxAppData.js +0 -10
- package/dist/plugins/maxChecker.d.ts +0 -3
- package/dist/plugins/maxChecker.js +0 -10
- package/dist/plugins/preset.d.ts +0 -4
- package/dist/plugins/preset.js +0 -24
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.js +0 -131
package/dist/index.js
CHANGED
|
@@ -1,18 +1,3394 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
+
|
|
20
|
+
// ../../node_modules/universalify/index.js
|
|
21
|
+
var require_universalify = __commonJS((exports) => {
|
|
22
|
+
exports.fromCallback = function(fn) {
|
|
23
|
+
return Object.defineProperty(function(...args) {
|
|
24
|
+
if (typeof args[args.length - 1] === "function")
|
|
25
|
+
fn.apply(this, args);
|
|
26
|
+
else {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
args.push((err, res) => err != null ? reject(err) : resolve(res));
|
|
29
|
+
fn.apply(this, args);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, "name", { value: fn.name });
|
|
33
|
+
};
|
|
34
|
+
exports.fromPromise = function(fn) {
|
|
35
|
+
return Object.defineProperty(function(...args) {
|
|
36
|
+
const cb = args[args.length - 1];
|
|
37
|
+
if (typeof cb !== "function")
|
|
38
|
+
return fn.apply(this, args);
|
|
39
|
+
else {
|
|
40
|
+
args.pop();
|
|
41
|
+
fn.apply(this, args).then((r) => cb(null, r), cb);
|
|
42
|
+
}
|
|
43
|
+
}, "name", { value: fn.name });
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// ../../node_modules/graceful-fs/polyfills.js
|
|
48
|
+
var require_polyfills = __commonJS((exports, module) => {
|
|
49
|
+
function patch(fs) {
|
|
50
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
51
|
+
patchLchmod(fs);
|
|
52
|
+
}
|
|
53
|
+
if (!fs.lutimes) {
|
|
54
|
+
patchLutimes(fs);
|
|
55
|
+
}
|
|
56
|
+
fs.chown = chownFix(fs.chown);
|
|
57
|
+
fs.fchown = chownFix(fs.fchown);
|
|
58
|
+
fs.lchown = chownFix(fs.lchown);
|
|
59
|
+
fs.chmod = chmodFix(fs.chmod);
|
|
60
|
+
fs.fchmod = chmodFix(fs.fchmod);
|
|
61
|
+
fs.lchmod = chmodFix(fs.lchmod);
|
|
62
|
+
fs.chownSync = chownFixSync(fs.chownSync);
|
|
63
|
+
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
64
|
+
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
65
|
+
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
66
|
+
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
67
|
+
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
68
|
+
fs.stat = statFix(fs.stat);
|
|
69
|
+
fs.fstat = statFix(fs.fstat);
|
|
70
|
+
fs.lstat = statFix(fs.lstat);
|
|
71
|
+
fs.statSync = statFixSync(fs.statSync);
|
|
72
|
+
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
73
|
+
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
74
|
+
if (fs.chmod && !fs.lchmod) {
|
|
75
|
+
fs.lchmod = function(path, mode, cb) {
|
|
76
|
+
if (cb)
|
|
77
|
+
process.nextTick(cb);
|
|
78
|
+
};
|
|
79
|
+
fs.lchmodSync = function() {
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (fs.chown && !fs.lchown) {
|
|
83
|
+
fs.lchown = function(path, uid, gid, cb) {
|
|
84
|
+
if (cb)
|
|
85
|
+
process.nextTick(cb);
|
|
86
|
+
};
|
|
87
|
+
fs.lchownSync = function() {
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (platform === "win32") {
|
|
91
|
+
fs.rename = typeof fs.rename !== "function" ? fs.rename : function(fs$rename) {
|
|
92
|
+
function rename(from, to, cb) {
|
|
93
|
+
var start = Date.now();
|
|
94
|
+
var backoff = 0;
|
|
95
|
+
fs$rename(from, to, function CB(er) {
|
|
96
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 60000) {
|
|
97
|
+
setTimeout(function() {
|
|
98
|
+
fs.stat(to, function(stater, st) {
|
|
99
|
+
if (stater && stater.code === "ENOENT")
|
|
100
|
+
fs$rename(from, to, CB);
|
|
101
|
+
else
|
|
102
|
+
cb(er);
|
|
103
|
+
});
|
|
104
|
+
}, backoff);
|
|
105
|
+
if (backoff < 100)
|
|
106
|
+
backoff += 10;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (cb)
|
|
110
|
+
cb(er);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (Object.setPrototypeOf)
|
|
114
|
+
Object.setPrototypeOf(rename, fs$rename);
|
|
115
|
+
return rename;
|
|
116
|
+
}(fs.rename);
|
|
117
|
+
}
|
|
118
|
+
fs.read = typeof fs.read !== "function" ? fs.read : function(fs$read) {
|
|
119
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
120
|
+
var callback;
|
|
121
|
+
if (callback_ && typeof callback_ === "function") {
|
|
122
|
+
var eagCounter = 0;
|
|
123
|
+
callback = function(er, _, __) {
|
|
124
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
125
|
+
eagCounter++;
|
|
126
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
127
|
+
}
|
|
128
|
+
callback_.apply(this, arguments);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
132
|
+
}
|
|
133
|
+
if (Object.setPrototypeOf)
|
|
134
|
+
Object.setPrototypeOf(read, fs$read);
|
|
135
|
+
return read;
|
|
136
|
+
}(fs.read);
|
|
137
|
+
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : function(fs$readSync) {
|
|
138
|
+
return function(fd, buffer, offset, length, position) {
|
|
139
|
+
var eagCounter = 0;
|
|
140
|
+
while (true) {
|
|
141
|
+
try {
|
|
142
|
+
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
143
|
+
} catch (er) {
|
|
144
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
145
|
+
eagCounter++;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
throw er;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}(fs.readSync);
|
|
153
|
+
function patchLchmod(fs2) {
|
|
154
|
+
fs2.lchmod = function(path, mode, callback) {
|
|
155
|
+
fs2.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
|
|
156
|
+
if (err) {
|
|
157
|
+
if (callback)
|
|
158
|
+
callback(err);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
fs2.fchmod(fd, mode, function(err2) {
|
|
162
|
+
fs2.close(fd, function(err22) {
|
|
163
|
+
if (callback)
|
|
164
|
+
callback(err2 || err22);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
fs2.lchmodSync = function(path, mode) {
|
|
170
|
+
var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
171
|
+
var threw = true;
|
|
172
|
+
var ret;
|
|
173
|
+
try {
|
|
174
|
+
ret = fs2.fchmodSync(fd, mode);
|
|
175
|
+
threw = false;
|
|
176
|
+
} finally {
|
|
177
|
+
if (threw) {
|
|
178
|
+
try {
|
|
179
|
+
fs2.closeSync(fd);
|
|
180
|
+
} catch (er) {
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
fs2.closeSync(fd);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return ret;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function patchLutimes(fs2) {
|
|
190
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
|
|
191
|
+
fs2.lutimes = function(path, at, mt, cb) {
|
|
192
|
+
fs2.open(path, constants.O_SYMLINK, function(er, fd) {
|
|
193
|
+
if (er) {
|
|
194
|
+
if (cb)
|
|
195
|
+
cb(er);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
fs2.futimes(fd, at, mt, function(er2) {
|
|
199
|
+
fs2.close(fd, function(er22) {
|
|
200
|
+
if (cb)
|
|
201
|
+
cb(er2 || er22);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
fs2.lutimesSync = function(path, at, mt) {
|
|
207
|
+
var fd = fs2.openSync(path, constants.O_SYMLINK);
|
|
208
|
+
var ret;
|
|
209
|
+
var threw = true;
|
|
210
|
+
try {
|
|
211
|
+
ret = fs2.futimesSync(fd, at, mt);
|
|
212
|
+
threw = false;
|
|
213
|
+
} finally {
|
|
214
|
+
if (threw) {
|
|
215
|
+
try {
|
|
216
|
+
fs2.closeSync(fd);
|
|
217
|
+
} catch (er) {
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
fs2.closeSync(fd);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return ret;
|
|
224
|
+
};
|
|
225
|
+
} else if (fs2.futimes) {
|
|
226
|
+
fs2.lutimes = function(_a, _b, _c, cb) {
|
|
227
|
+
if (cb)
|
|
228
|
+
process.nextTick(cb);
|
|
229
|
+
};
|
|
230
|
+
fs2.lutimesSync = function() {
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function chmodFix(orig) {
|
|
235
|
+
if (!orig)
|
|
236
|
+
return orig;
|
|
237
|
+
return function(target, mode, cb) {
|
|
238
|
+
return orig.call(fs, target, mode, function(er) {
|
|
239
|
+
if (chownErOk(er))
|
|
240
|
+
er = null;
|
|
241
|
+
if (cb)
|
|
242
|
+
cb.apply(this, arguments);
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function chmodFixSync(orig) {
|
|
247
|
+
if (!orig)
|
|
248
|
+
return orig;
|
|
249
|
+
return function(target, mode) {
|
|
250
|
+
try {
|
|
251
|
+
return orig.call(fs, target, mode);
|
|
252
|
+
} catch (er) {
|
|
253
|
+
if (!chownErOk(er))
|
|
254
|
+
throw er;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function chownFix(orig) {
|
|
259
|
+
if (!orig)
|
|
260
|
+
return orig;
|
|
261
|
+
return function(target, uid, gid, cb) {
|
|
262
|
+
return orig.call(fs, target, uid, gid, function(er) {
|
|
263
|
+
if (chownErOk(er))
|
|
264
|
+
er = null;
|
|
265
|
+
if (cb)
|
|
266
|
+
cb.apply(this, arguments);
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function chownFixSync(orig) {
|
|
271
|
+
if (!orig)
|
|
272
|
+
return orig;
|
|
273
|
+
return function(target, uid, gid) {
|
|
274
|
+
try {
|
|
275
|
+
return orig.call(fs, target, uid, gid);
|
|
276
|
+
} catch (er) {
|
|
277
|
+
if (!chownErOk(er))
|
|
278
|
+
throw er;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function statFix(orig) {
|
|
283
|
+
if (!orig)
|
|
284
|
+
return orig;
|
|
285
|
+
return function(target, options, cb) {
|
|
286
|
+
if (typeof options === "function") {
|
|
287
|
+
cb = options;
|
|
288
|
+
options = null;
|
|
289
|
+
}
|
|
290
|
+
function callback(er, stats) {
|
|
291
|
+
if (stats) {
|
|
292
|
+
if (stats.uid < 0)
|
|
293
|
+
stats.uid += 4294967296;
|
|
294
|
+
if (stats.gid < 0)
|
|
295
|
+
stats.gid += 4294967296;
|
|
296
|
+
}
|
|
297
|
+
if (cb)
|
|
298
|
+
cb.apply(this, arguments);
|
|
299
|
+
}
|
|
300
|
+
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function statFixSync(orig) {
|
|
304
|
+
if (!orig)
|
|
305
|
+
return orig;
|
|
306
|
+
return function(target, options) {
|
|
307
|
+
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
|
|
308
|
+
if (stats) {
|
|
309
|
+
if (stats.uid < 0)
|
|
310
|
+
stats.uid += 4294967296;
|
|
311
|
+
if (stats.gid < 0)
|
|
312
|
+
stats.gid += 4294967296;
|
|
313
|
+
}
|
|
314
|
+
return stats;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function chownErOk(er) {
|
|
318
|
+
if (!er)
|
|
319
|
+
return true;
|
|
320
|
+
if (er.code === "ENOSYS")
|
|
321
|
+
return true;
|
|
322
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
323
|
+
if (nonroot) {
|
|
324
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
var constants = import.meta.require("constants");
|
|
331
|
+
var origCwd = process.cwd;
|
|
332
|
+
var cwd = null;
|
|
333
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
334
|
+
process.cwd = function() {
|
|
335
|
+
if (!cwd)
|
|
336
|
+
cwd = origCwd.call(process);
|
|
337
|
+
return cwd;
|
|
338
|
+
};
|
|
339
|
+
try {
|
|
340
|
+
process.cwd();
|
|
341
|
+
} catch (er) {
|
|
342
|
+
}
|
|
343
|
+
if (typeof process.chdir === "function") {
|
|
344
|
+
chdir = process.chdir;
|
|
345
|
+
process.chdir = function(d) {
|
|
346
|
+
cwd = null;
|
|
347
|
+
chdir.call(process, d);
|
|
348
|
+
};
|
|
349
|
+
if (Object.setPrototypeOf)
|
|
350
|
+
Object.setPrototypeOf(process.chdir, chdir);
|
|
351
|
+
}
|
|
352
|
+
var chdir;
|
|
353
|
+
module.exports = patch;
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// ../../node_modules/graceful-fs/legacy-streams.js
|
|
357
|
+
var require_legacy_streams = __commonJS((exports, module) => {
|
|
358
|
+
function legacy(fs) {
|
|
359
|
+
return {
|
|
360
|
+
ReadStream,
|
|
361
|
+
WriteStream
|
|
362
|
+
};
|
|
363
|
+
function ReadStream(path, options) {
|
|
364
|
+
if (!(this instanceof ReadStream))
|
|
365
|
+
return new ReadStream(path, options);
|
|
366
|
+
Stream.call(this);
|
|
367
|
+
var self = this;
|
|
368
|
+
this.path = path;
|
|
369
|
+
this.fd = null;
|
|
370
|
+
this.readable = true;
|
|
371
|
+
this.paused = false;
|
|
372
|
+
this.flags = "r";
|
|
373
|
+
this.mode = 438;
|
|
374
|
+
this.bufferSize = 64 * 1024;
|
|
375
|
+
options = options || {};
|
|
376
|
+
var keys = Object.keys(options);
|
|
377
|
+
for (var index = 0, length = keys.length;index < length; index++) {
|
|
378
|
+
var key = keys[index];
|
|
379
|
+
this[key] = options[key];
|
|
380
|
+
}
|
|
381
|
+
if (this.encoding)
|
|
382
|
+
this.setEncoding(this.encoding);
|
|
383
|
+
if (this.start !== undefined) {
|
|
384
|
+
if (typeof this.start !== "number") {
|
|
385
|
+
throw TypeError("start must be a Number");
|
|
386
|
+
}
|
|
387
|
+
if (this.end === undefined) {
|
|
388
|
+
this.end = Infinity;
|
|
389
|
+
} else if (typeof this.end !== "number") {
|
|
390
|
+
throw TypeError("end must be a Number");
|
|
391
|
+
}
|
|
392
|
+
if (this.start > this.end) {
|
|
393
|
+
throw new Error("start must be <= end");
|
|
394
|
+
}
|
|
395
|
+
this.pos = this.start;
|
|
396
|
+
}
|
|
397
|
+
if (this.fd !== null) {
|
|
398
|
+
process.nextTick(function() {
|
|
399
|
+
self._read();
|
|
400
|
+
});
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
404
|
+
if (err) {
|
|
405
|
+
self.emit("error", err);
|
|
406
|
+
self.readable = false;
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
self.fd = fd;
|
|
410
|
+
self.emit("open", fd);
|
|
411
|
+
self._read();
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function WriteStream(path, options) {
|
|
415
|
+
if (!(this instanceof WriteStream))
|
|
416
|
+
return new WriteStream(path, options);
|
|
417
|
+
Stream.call(this);
|
|
418
|
+
this.path = path;
|
|
419
|
+
this.fd = null;
|
|
420
|
+
this.writable = true;
|
|
421
|
+
this.flags = "w";
|
|
422
|
+
this.encoding = "binary";
|
|
423
|
+
this.mode = 438;
|
|
424
|
+
this.bytesWritten = 0;
|
|
425
|
+
options = options || {};
|
|
426
|
+
var keys = Object.keys(options);
|
|
427
|
+
for (var index = 0, length = keys.length;index < length; index++) {
|
|
428
|
+
var key = keys[index];
|
|
429
|
+
this[key] = options[key];
|
|
430
|
+
}
|
|
431
|
+
if (this.start !== undefined) {
|
|
432
|
+
if (typeof this.start !== "number") {
|
|
433
|
+
throw TypeError("start must be a Number");
|
|
434
|
+
}
|
|
435
|
+
if (this.start < 0) {
|
|
436
|
+
throw new Error("start must be >= zero");
|
|
437
|
+
}
|
|
438
|
+
this.pos = this.start;
|
|
439
|
+
}
|
|
440
|
+
this.busy = false;
|
|
441
|
+
this._queue = [];
|
|
442
|
+
if (this.fd === null) {
|
|
443
|
+
this._open = fs.open;
|
|
444
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
|
|
445
|
+
this.flush();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
var Stream = import.meta.require("stream").Stream;
|
|
450
|
+
module.exports = legacy;
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// ../../node_modules/graceful-fs/clone.js
|
|
454
|
+
var require_clone = __commonJS((exports, module) => {
|
|
455
|
+
function clone(obj) {
|
|
456
|
+
if (obj === null || typeof obj !== "object")
|
|
457
|
+
return obj;
|
|
458
|
+
if (obj instanceof Object)
|
|
459
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
460
|
+
else
|
|
461
|
+
var copy = Object.create(null);
|
|
462
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
463
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
464
|
+
});
|
|
465
|
+
return copy;
|
|
466
|
+
}
|
|
467
|
+
module.exports = clone;
|
|
468
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
469
|
+
return obj.__proto__;
|
|
470
|
+
};
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
// ../../node_modules/graceful-fs/graceful-fs.js
|
|
474
|
+
var require_graceful_fs = __commonJS((exports, module) => {
|
|
475
|
+
function noop() {
|
|
476
|
+
}
|
|
477
|
+
function publishQueue(context, queue2) {
|
|
478
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
479
|
+
get: function() {
|
|
480
|
+
return queue2;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
function patch(fs2) {
|
|
485
|
+
polyfills(fs2);
|
|
486
|
+
fs2.gracefulify = patch;
|
|
487
|
+
fs2.createReadStream = createReadStream;
|
|
488
|
+
fs2.createWriteStream = createWriteStream;
|
|
489
|
+
var fs$readFile = fs2.readFile;
|
|
490
|
+
fs2.readFile = readFile;
|
|
491
|
+
function readFile(path, options, cb) {
|
|
492
|
+
if (typeof options === "function")
|
|
493
|
+
cb = options, options = null;
|
|
494
|
+
return go$readFile(path, options, cb);
|
|
495
|
+
function go$readFile(path2, options2, cb2, startTime) {
|
|
496
|
+
return fs$readFile(path2, options2, function(err) {
|
|
497
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
498
|
+
enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
499
|
+
else {
|
|
500
|
+
if (typeof cb2 === "function")
|
|
501
|
+
cb2.apply(this, arguments);
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
var fs$writeFile = fs2.writeFile;
|
|
507
|
+
fs2.writeFile = writeFile;
|
|
508
|
+
function writeFile(path, data, options, cb) {
|
|
509
|
+
if (typeof options === "function")
|
|
510
|
+
cb = options, options = null;
|
|
511
|
+
return go$writeFile(path, data, options, cb);
|
|
512
|
+
function go$writeFile(path2, data2, options2, cb2, startTime) {
|
|
513
|
+
return fs$writeFile(path2, data2, options2, function(err) {
|
|
514
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
515
|
+
enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
516
|
+
else {
|
|
517
|
+
if (typeof cb2 === "function")
|
|
518
|
+
cb2.apply(this, arguments);
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
var fs$appendFile = fs2.appendFile;
|
|
524
|
+
if (fs$appendFile)
|
|
525
|
+
fs2.appendFile = appendFile;
|
|
526
|
+
function appendFile(path, data, options, cb) {
|
|
527
|
+
if (typeof options === "function")
|
|
528
|
+
cb = options, options = null;
|
|
529
|
+
return go$appendFile(path, data, options, cb);
|
|
530
|
+
function go$appendFile(path2, data2, options2, cb2, startTime) {
|
|
531
|
+
return fs$appendFile(path2, data2, options2, function(err) {
|
|
532
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
533
|
+
enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
534
|
+
else {
|
|
535
|
+
if (typeof cb2 === "function")
|
|
536
|
+
cb2.apply(this, arguments);
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
var fs$copyFile = fs2.copyFile;
|
|
542
|
+
if (fs$copyFile)
|
|
543
|
+
fs2.copyFile = copyFile;
|
|
544
|
+
function copyFile(src, dest, flags, cb) {
|
|
545
|
+
if (typeof flags === "function") {
|
|
546
|
+
cb = flags;
|
|
547
|
+
flags = 0;
|
|
548
|
+
}
|
|
549
|
+
return go$copyFile(src, dest, flags, cb);
|
|
550
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
551
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
552
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
553
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
554
|
+
else {
|
|
555
|
+
if (typeof cb2 === "function")
|
|
556
|
+
cb2.apply(this, arguments);
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
var fs$readdir = fs2.readdir;
|
|
562
|
+
fs2.readdir = readdir;
|
|
563
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
564
|
+
function readdir(path, options, cb) {
|
|
565
|
+
if (typeof options === "function")
|
|
566
|
+
cb = options, options = null;
|
|
567
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path2, options2, cb2, startTime) {
|
|
568
|
+
return fs$readdir(path2, fs$readdirCallback(path2, options2, cb2, startTime));
|
|
569
|
+
} : function go$readdir(path2, options2, cb2, startTime) {
|
|
570
|
+
return fs$readdir(path2, options2, fs$readdirCallback(path2, options2, cb2, startTime));
|
|
571
|
+
};
|
|
572
|
+
return go$readdir(path, options, cb);
|
|
573
|
+
function fs$readdirCallback(path2, options2, cb2, startTime) {
|
|
574
|
+
return function(err, files) {
|
|
575
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
576
|
+
enqueue([
|
|
577
|
+
go$readdir,
|
|
578
|
+
[path2, options2, cb2],
|
|
579
|
+
err,
|
|
580
|
+
startTime || Date.now(),
|
|
581
|
+
Date.now()
|
|
582
|
+
]);
|
|
583
|
+
else {
|
|
584
|
+
if (files && files.sort)
|
|
585
|
+
files.sort();
|
|
586
|
+
if (typeof cb2 === "function")
|
|
587
|
+
cb2.call(this, err, files);
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
593
|
+
var legStreams = legacy(fs2);
|
|
594
|
+
ReadStream = legStreams.ReadStream;
|
|
595
|
+
WriteStream = legStreams.WriteStream;
|
|
596
|
+
}
|
|
597
|
+
var fs$ReadStream = fs2.ReadStream;
|
|
598
|
+
if (fs$ReadStream) {
|
|
599
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
600
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
601
|
+
}
|
|
602
|
+
var fs$WriteStream = fs2.WriteStream;
|
|
603
|
+
if (fs$WriteStream) {
|
|
604
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
605
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
606
|
+
}
|
|
607
|
+
Object.defineProperty(fs2, "ReadStream", {
|
|
608
|
+
get: function() {
|
|
609
|
+
return ReadStream;
|
|
610
|
+
},
|
|
611
|
+
set: function(val) {
|
|
612
|
+
ReadStream = val;
|
|
613
|
+
},
|
|
614
|
+
enumerable: true,
|
|
615
|
+
configurable: true
|
|
616
|
+
});
|
|
617
|
+
Object.defineProperty(fs2, "WriteStream", {
|
|
618
|
+
get: function() {
|
|
619
|
+
return WriteStream;
|
|
620
|
+
},
|
|
621
|
+
set: function(val) {
|
|
622
|
+
WriteStream = val;
|
|
623
|
+
},
|
|
624
|
+
enumerable: true,
|
|
625
|
+
configurable: true
|
|
626
|
+
});
|
|
627
|
+
var FileReadStream = ReadStream;
|
|
628
|
+
Object.defineProperty(fs2, "FileReadStream", {
|
|
629
|
+
get: function() {
|
|
630
|
+
return FileReadStream;
|
|
631
|
+
},
|
|
632
|
+
set: function(val) {
|
|
633
|
+
FileReadStream = val;
|
|
634
|
+
},
|
|
635
|
+
enumerable: true,
|
|
636
|
+
configurable: true
|
|
637
|
+
});
|
|
638
|
+
var FileWriteStream = WriteStream;
|
|
639
|
+
Object.defineProperty(fs2, "FileWriteStream", {
|
|
640
|
+
get: function() {
|
|
641
|
+
return FileWriteStream;
|
|
642
|
+
},
|
|
643
|
+
set: function(val) {
|
|
644
|
+
FileWriteStream = val;
|
|
645
|
+
},
|
|
646
|
+
enumerable: true,
|
|
647
|
+
configurable: true
|
|
648
|
+
});
|
|
649
|
+
function ReadStream(path, options) {
|
|
650
|
+
if (this instanceof ReadStream)
|
|
651
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
652
|
+
else
|
|
653
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
654
|
+
}
|
|
655
|
+
function ReadStream$open() {
|
|
656
|
+
var that = this;
|
|
657
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
658
|
+
if (err) {
|
|
659
|
+
if (that.autoClose)
|
|
660
|
+
that.destroy();
|
|
661
|
+
that.emit("error", err);
|
|
662
|
+
} else {
|
|
663
|
+
that.fd = fd;
|
|
664
|
+
that.emit("open", fd);
|
|
665
|
+
that.read();
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
function WriteStream(path, options) {
|
|
670
|
+
if (this instanceof WriteStream)
|
|
671
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
672
|
+
else
|
|
673
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
674
|
+
}
|
|
675
|
+
function WriteStream$open() {
|
|
676
|
+
var that = this;
|
|
677
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
678
|
+
if (err) {
|
|
679
|
+
that.destroy();
|
|
680
|
+
that.emit("error", err);
|
|
681
|
+
} else {
|
|
682
|
+
that.fd = fd;
|
|
683
|
+
that.emit("open", fd);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
function createReadStream(path, options) {
|
|
688
|
+
return new fs2.ReadStream(path, options);
|
|
689
|
+
}
|
|
690
|
+
function createWriteStream(path, options) {
|
|
691
|
+
return new fs2.WriteStream(path, options);
|
|
692
|
+
}
|
|
693
|
+
var fs$open = fs2.open;
|
|
694
|
+
fs2.open = open;
|
|
695
|
+
function open(path, flags, mode, cb) {
|
|
696
|
+
if (typeof mode === "function")
|
|
697
|
+
cb = mode, mode = null;
|
|
698
|
+
return go$open(path, flags, mode, cb);
|
|
699
|
+
function go$open(path2, flags2, mode2, cb2, startTime) {
|
|
700
|
+
return fs$open(path2, flags2, mode2, function(err, fd) {
|
|
701
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
702
|
+
enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
703
|
+
else {
|
|
704
|
+
if (typeof cb2 === "function")
|
|
705
|
+
cb2.apply(this, arguments);
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return fs2;
|
|
711
|
+
}
|
|
712
|
+
function enqueue(elem) {
|
|
713
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
714
|
+
fs[gracefulQueue].push(elem);
|
|
715
|
+
retry();
|
|
716
|
+
}
|
|
717
|
+
function resetQueue() {
|
|
718
|
+
var now = Date.now();
|
|
719
|
+
for (var i = 0;i < fs[gracefulQueue].length; ++i) {
|
|
720
|
+
if (fs[gracefulQueue][i].length > 2) {
|
|
721
|
+
fs[gracefulQueue][i][3] = now;
|
|
722
|
+
fs[gracefulQueue][i][4] = now;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
retry();
|
|
726
|
+
}
|
|
727
|
+
function retry() {
|
|
728
|
+
clearTimeout(retryTimer);
|
|
729
|
+
retryTimer = undefined;
|
|
730
|
+
if (fs[gracefulQueue].length === 0)
|
|
731
|
+
return;
|
|
732
|
+
var elem = fs[gracefulQueue].shift();
|
|
733
|
+
var fn = elem[0];
|
|
734
|
+
var args = elem[1];
|
|
735
|
+
var err = elem[2];
|
|
736
|
+
var startTime = elem[3];
|
|
737
|
+
var lastTime = elem[4];
|
|
738
|
+
if (startTime === undefined) {
|
|
739
|
+
debug("RETRY", fn.name, args);
|
|
740
|
+
fn.apply(null, args);
|
|
741
|
+
} else if (Date.now() - startTime >= 60000) {
|
|
742
|
+
debug("TIMEOUT", fn.name, args);
|
|
743
|
+
var cb = args.pop();
|
|
744
|
+
if (typeof cb === "function")
|
|
745
|
+
cb.call(null, err);
|
|
746
|
+
} else {
|
|
747
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
748
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
749
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
750
|
+
if (sinceAttempt >= desiredDelay) {
|
|
751
|
+
debug("RETRY", fn.name, args);
|
|
752
|
+
fn.apply(null, args.concat([startTime]));
|
|
753
|
+
} else {
|
|
754
|
+
fs[gracefulQueue].push(elem);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if (retryTimer === undefined) {
|
|
758
|
+
retryTimer = setTimeout(retry, 0);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
var fs = import.meta.require("fs");
|
|
762
|
+
var polyfills = require_polyfills();
|
|
763
|
+
var legacy = require_legacy_streams();
|
|
764
|
+
var clone = require_clone();
|
|
765
|
+
var util = import.meta.require("util");
|
|
766
|
+
var gracefulQueue;
|
|
767
|
+
var previousSymbol;
|
|
768
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
769
|
+
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
770
|
+
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
771
|
+
} else {
|
|
772
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
773
|
+
previousSymbol = "___graceful-fs.previous";
|
|
774
|
+
}
|
|
775
|
+
var debug = noop;
|
|
776
|
+
if (util.debuglog)
|
|
777
|
+
debug = util.debuglog("gfs4");
|
|
778
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
779
|
+
debug = function() {
|
|
780
|
+
var m = util.format.apply(util, arguments);
|
|
781
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
782
|
+
console.error(m);
|
|
783
|
+
};
|
|
784
|
+
if (!fs[gracefulQueue]) {
|
|
785
|
+
queue = global[gracefulQueue] || [];
|
|
786
|
+
publishQueue(fs, queue);
|
|
787
|
+
fs.close = function(fs$close) {
|
|
788
|
+
function close(fd, cb) {
|
|
789
|
+
return fs$close.call(fs, fd, function(err) {
|
|
790
|
+
if (!err) {
|
|
791
|
+
resetQueue();
|
|
792
|
+
}
|
|
793
|
+
if (typeof cb === "function")
|
|
794
|
+
cb.apply(this, arguments);
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
Object.defineProperty(close, previousSymbol, {
|
|
798
|
+
value: fs$close
|
|
799
|
+
});
|
|
800
|
+
return close;
|
|
801
|
+
}(fs.close);
|
|
802
|
+
fs.closeSync = function(fs$closeSync) {
|
|
803
|
+
function closeSync(fd) {
|
|
804
|
+
fs$closeSync.apply(fs, arguments);
|
|
805
|
+
resetQueue();
|
|
806
|
+
}
|
|
807
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
808
|
+
value: fs$closeSync
|
|
809
|
+
});
|
|
810
|
+
return closeSync;
|
|
811
|
+
}(fs.closeSync);
|
|
812
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
813
|
+
process.on("exit", function() {
|
|
814
|
+
debug(fs[gracefulQueue]);
|
|
815
|
+
import.meta.require("assert").equal(fs[gracefulQueue].length, 0);
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
var queue;
|
|
820
|
+
if (!global[gracefulQueue]) {
|
|
821
|
+
publishQueue(global, fs[gracefulQueue]);
|
|
822
|
+
}
|
|
823
|
+
module.exports = patch(clone(fs));
|
|
824
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
|
825
|
+
module.exports = patch(fs);
|
|
826
|
+
fs.__patched = true;
|
|
827
|
+
}
|
|
828
|
+
var retryTimer;
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
// ../../node_modules/fs-extra/lib/fs/index.js
|
|
832
|
+
var require_fs = __commonJS((exports) => {
|
|
833
|
+
var u = require_universalify().fromCallback;
|
|
834
|
+
var fs = require_graceful_fs();
|
|
835
|
+
var api = [
|
|
836
|
+
"access",
|
|
837
|
+
"appendFile",
|
|
838
|
+
"chmod",
|
|
839
|
+
"chown",
|
|
840
|
+
"close",
|
|
841
|
+
"copyFile",
|
|
842
|
+
"fchmod",
|
|
843
|
+
"fchown",
|
|
844
|
+
"fdatasync",
|
|
845
|
+
"fstat",
|
|
846
|
+
"fsync",
|
|
847
|
+
"ftruncate",
|
|
848
|
+
"futimes",
|
|
849
|
+
"lchmod",
|
|
850
|
+
"lchown",
|
|
851
|
+
"link",
|
|
852
|
+
"lstat",
|
|
853
|
+
"mkdir",
|
|
854
|
+
"mkdtemp",
|
|
855
|
+
"open",
|
|
856
|
+
"opendir",
|
|
857
|
+
"readdir",
|
|
858
|
+
"readFile",
|
|
859
|
+
"readlink",
|
|
860
|
+
"realpath",
|
|
861
|
+
"rename",
|
|
862
|
+
"rm",
|
|
863
|
+
"rmdir",
|
|
864
|
+
"stat",
|
|
865
|
+
"symlink",
|
|
866
|
+
"truncate",
|
|
867
|
+
"unlink",
|
|
868
|
+
"utimes",
|
|
869
|
+
"writeFile"
|
|
870
|
+
].filter((key) => {
|
|
871
|
+
return typeof fs[key] === "function";
|
|
872
|
+
});
|
|
873
|
+
Object.assign(exports, fs);
|
|
874
|
+
api.forEach((method) => {
|
|
875
|
+
exports[method] = u(fs[method]);
|
|
876
|
+
});
|
|
877
|
+
exports.exists = function(filename, callback) {
|
|
878
|
+
if (typeof callback === "function") {
|
|
879
|
+
return fs.exists(filename, callback);
|
|
880
|
+
}
|
|
881
|
+
return new Promise((resolve) => {
|
|
882
|
+
return fs.exists(filename, resolve);
|
|
883
|
+
});
|
|
884
|
+
};
|
|
885
|
+
exports.read = function(fd, buffer, offset, length, position, callback) {
|
|
886
|
+
if (typeof callback === "function") {
|
|
887
|
+
return fs.read(fd, buffer, offset, length, position, callback);
|
|
888
|
+
}
|
|
889
|
+
return new Promise((resolve, reject) => {
|
|
890
|
+
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
|
|
891
|
+
if (err)
|
|
892
|
+
return reject(err);
|
|
893
|
+
resolve({ bytesRead, buffer: buffer2 });
|
|
894
|
+
});
|
|
895
|
+
});
|
|
896
|
+
};
|
|
897
|
+
exports.write = function(fd, buffer, ...args) {
|
|
898
|
+
if (typeof args[args.length - 1] === "function") {
|
|
899
|
+
return fs.write(fd, buffer, ...args);
|
|
900
|
+
}
|
|
901
|
+
return new Promise((resolve, reject) => {
|
|
902
|
+
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
|
|
903
|
+
if (err)
|
|
904
|
+
return reject(err);
|
|
905
|
+
resolve({ bytesWritten, buffer: buffer2 });
|
|
906
|
+
});
|
|
907
|
+
});
|
|
908
|
+
};
|
|
909
|
+
if (typeof fs.writev === "function") {
|
|
910
|
+
exports.writev = function(fd, buffers, ...args) {
|
|
911
|
+
if (typeof args[args.length - 1] === "function") {
|
|
912
|
+
return fs.writev(fd, buffers, ...args);
|
|
913
|
+
}
|
|
914
|
+
return new Promise((resolve, reject) => {
|
|
915
|
+
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
|
|
916
|
+
if (err)
|
|
917
|
+
return reject(err);
|
|
918
|
+
resolve({ bytesWritten, buffers: buffers2 });
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
if (typeof fs.realpath.native === "function") {
|
|
924
|
+
exports.realpath.native = u(fs.realpath.native);
|
|
925
|
+
} else {
|
|
926
|
+
process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?", "Warning", "fs-extra-WARN0003");
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
// ../../node_modules/fs-extra/lib/mkdirs/utils.js
|
|
931
|
+
var require_utils = __commonJS((exports, module) => {
|
|
932
|
+
var path = import.meta.require("path");
|
|
933
|
+
exports.checkPath = function checkPath(pth) {
|
|
934
|
+
if (process.platform === "win32") {
|
|
935
|
+
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ""));
|
|
936
|
+
if (pathHasInvalidWinCharacters) {
|
|
937
|
+
const error = new Error(`Path contains invalid characters: ${pth}`);
|
|
938
|
+
error.code = "EINVAL";
|
|
939
|
+
throw error;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
// ../../node_modules/fs-extra/lib/mkdirs/make-dir.js
|
|
946
|
+
var require_make_dir = __commonJS((exports, module) => {
|
|
947
|
+
var fs = require_fs();
|
|
948
|
+
var { checkPath } = require_utils();
|
|
949
|
+
var getMode = (options) => {
|
|
950
|
+
const defaults = { mode: 511 };
|
|
951
|
+
if (typeof options === "number")
|
|
952
|
+
return options;
|
|
953
|
+
return { ...defaults, ...options }.mode;
|
|
954
|
+
};
|
|
955
|
+
exports.makeDir = async (dir, options) => {
|
|
956
|
+
checkPath(dir);
|
|
957
|
+
return fs.mkdir(dir, {
|
|
958
|
+
mode: getMode(options),
|
|
959
|
+
recursive: true
|
|
960
|
+
});
|
|
961
|
+
};
|
|
962
|
+
exports.makeDirSync = (dir, options) => {
|
|
963
|
+
checkPath(dir);
|
|
964
|
+
return fs.mkdirSync(dir, {
|
|
965
|
+
mode: getMode(options),
|
|
966
|
+
recursive: true
|
|
967
|
+
});
|
|
968
|
+
};
|
|
969
|
+
});
|
|
970
|
+
|
|
971
|
+
// ../../node_modules/fs-extra/lib/mkdirs/index.js
|
|
972
|
+
var require_mkdirs = __commonJS((exports, module) => {
|
|
973
|
+
var u = require_universalify().fromPromise;
|
|
974
|
+
var { makeDir: _makeDir, makeDirSync } = require_make_dir();
|
|
975
|
+
var makeDir = u(_makeDir);
|
|
976
|
+
module.exports = {
|
|
977
|
+
mkdirs: makeDir,
|
|
978
|
+
mkdirsSync: makeDirSync,
|
|
979
|
+
mkdirp: makeDir,
|
|
980
|
+
mkdirpSync: makeDirSync,
|
|
981
|
+
ensureDir: makeDir,
|
|
982
|
+
ensureDirSync: makeDirSync
|
|
983
|
+
};
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
// ../../node_modules/fs-extra/lib/path-exists/index.js
|
|
987
|
+
var require_path_exists = __commonJS((exports, module) => {
|
|
988
|
+
function pathExists(path) {
|
|
989
|
+
return fs.access(path).then(() => true).catch(() => false);
|
|
990
|
+
}
|
|
991
|
+
var u = require_universalify().fromPromise;
|
|
992
|
+
var fs = require_fs();
|
|
993
|
+
module.exports = {
|
|
994
|
+
pathExists: u(pathExists),
|
|
995
|
+
pathExistsSync: fs.existsSync
|
|
996
|
+
};
|
|
997
|
+
});
|
|
998
|
+
|
|
999
|
+
// ../../node_modules/fs-extra/lib/util/utimes.js
|
|
1000
|
+
var require_utimes = __commonJS((exports, module) => {
|
|
1001
|
+
function utimesMillis(path, atime, mtime, callback) {
|
|
1002
|
+
fs.open(path, "r+", (err, fd) => {
|
|
1003
|
+
if (err)
|
|
1004
|
+
return callback(err);
|
|
1005
|
+
fs.futimes(fd, atime, mtime, (futimesErr) => {
|
|
1006
|
+
fs.close(fd, (closeErr) => {
|
|
1007
|
+
if (callback)
|
|
1008
|
+
callback(futimesErr || closeErr);
|
|
1009
|
+
});
|
|
1010
|
+
});
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
function utimesMillisSync(path, atime, mtime) {
|
|
1014
|
+
const fd = fs.openSync(path, "r+");
|
|
1015
|
+
fs.futimesSync(fd, atime, mtime);
|
|
1016
|
+
return fs.closeSync(fd);
|
|
1017
|
+
}
|
|
1018
|
+
var fs = require_graceful_fs();
|
|
1019
|
+
module.exports = {
|
|
1020
|
+
utimesMillis,
|
|
1021
|
+
utimesMillisSync
|
|
1022
|
+
};
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
// ../../node_modules/fs-extra/lib/util/stat.js
|
|
1026
|
+
var require_stat = __commonJS((exports, module) => {
|
|
1027
|
+
function getStats(src, dest, opts) {
|
|
1028
|
+
const statFunc = opts.dereference ? (file) => fs.stat(file, { bigint: true }) : (file) => fs.lstat(file, { bigint: true });
|
|
1029
|
+
return Promise.all([
|
|
1030
|
+
statFunc(src),
|
|
1031
|
+
statFunc(dest).catch((err) => {
|
|
1032
|
+
if (err.code === "ENOENT")
|
|
1033
|
+
return null;
|
|
1034
|
+
throw err;
|
|
1035
|
+
})
|
|
1036
|
+
]).then(([srcStat, destStat]) => ({ srcStat, destStat }));
|
|
1037
|
+
}
|
|
1038
|
+
function getStatsSync(src, dest, opts) {
|
|
1039
|
+
let destStat;
|
|
1040
|
+
const statFunc = opts.dereference ? (file) => fs.statSync(file, { bigint: true }) : (file) => fs.lstatSync(file, { bigint: true });
|
|
1041
|
+
const srcStat = statFunc(src);
|
|
1042
|
+
try {
|
|
1043
|
+
destStat = statFunc(dest);
|
|
1044
|
+
} catch (err) {
|
|
1045
|
+
if (err.code === "ENOENT")
|
|
1046
|
+
return { srcStat, destStat: null };
|
|
1047
|
+
throw err;
|
|
1048
|
+
}
|
|
1049
|
+
return { srcStat, destStat };
|
|
1050
|
+
}
|
|
1051
|
+
function checkPaths(src, dest, funcName, opts, cb) {
|
|
1052
|
+
util.callbackify(getStats)(src, dest, opts, (err, stats) => {
|
|
1053
|
+
if (err)
|
|
1054
|
+
return cb(err);
|
|
1055
|
+
const { srcStat, destStat } = stats;
|
|
1056
|
+
if (destStat) {
|
|
1057
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1058
|
+
const srcBaseName = path.basename(src);
|
|
1059
|
+
const destBaseName = path.basename(dest);
|
|
1060
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
1061
|
+
return cb(null, { srcStat, destStat, isChangingCase: true });
|
|
1062
|
+
}
|
|
1063
|
+
return cb(new Error("Source and destination must not be the same."));
|
|
1064
|
+
}
|
|
1065
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
1066
|
+
return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`));
|
|
1067
|
+
}
|
|
1068
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
1069
|
+
return cb(new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`));
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
1073
|
+
return cb(new Error(errMsg(src, dest, funcName)));
|
|
1074
|
+
}
|
|
1075
|
+
return cb(null, { srcStat, destStat });
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
function checkPathsSync(src, dest, funcName, opts) {
|
|
1079
|
+
const { srcStat, destStat } = getStatsSync(src, dest, opts);
|
|
1080
|
+
if (destStat) {
|
|
1081
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1082
|
+
const srcBaseName = path.basename(src);
|
|
1083
|
+
const destBaseName = path.basename(dest);
|
|
1084
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
1085
|
+
return { srcStat, destStat, isChangingCase: true };
|
|
1086
|
+
}
|
|
1087
|
+
throw new Error("Source and destination must not be the same.");
|
|
1088
|
+
}
|
|
1089
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
1090
|
+
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
1091
|
+
}
|
|
1092
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
1093
|
+
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
1097
|
+
throw new Error(errMsg(src, dest, funcName));
|
|
1098
|
+
}
|
|
1099
|
+
return { srcStat, destStat };
|
|
1100
|
+
}
|
|
1101
|
+
function checkParentPaths(src, srcStat, dest, funcName, cb) {
|
|
1102
|
+
const srcParent = path.resolve(path.dirname(src));
|
|
1103
|
+
const destParent = path.resolve(path.dirname(dest));
|
|
1104
|
+
if (destParent === srcParent || destParent === path.parse(destParent).root)
|
|
1105
|
+
return cb();
|
|
1106
|
+
fs.stat(destParent, { bigint: true }, (err, destStat) => {
|
|
1107
|
+
if (err) {
|
|
1108
|
+
if (err.code === "ENOENT")
|
|
1109
|
+
return cb();
|
|
1110
|
+
return cb(err);
|
|
1111
|
+
}
|
|
1112
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1113
|
+
return cb(new Error(errMsg(src, dest, funcName)));
|
|
1114
|
+
}
|
|
1115
|
+
return checkParentPaths(src, srcStat, destParent, funcName, cb);
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
function checkParentPathsSync(src, srcStat, dest, funcName) {
|
|
1119
|
+
const srcParent = path.resolve(path.dirname(src));
|
|
1120
|
+
const destParent = path.resolve(path.dirname(dest));
|
|
1121
|
+
if (destParent === srcParent || destParent === path.parse(destParent).root)
|
|
1122
|
+
return;
|
|
1123
|
+
let destStat;
|
|
1124
|
+
try {
|
|
1125
|
+
destStat = fs.statSync(destParent, { bigint: true });
|
|
1126
|
+
} catch (err) {
|
|
1127
|
+
if (err.code === "ENOENT")
|
|
1128
|
+
return;
|
|
1129
|
+
throw err;
|
|
1130
|
+
}
|
|
1131
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1132
|
+
throw new Error(errMsg(src, dest, funcName));
|
|
1133
|
+
}
|
|
1134
|
+
return checkParentPathsSync(src, srcStat, destParent, funcName);
|
|
1135
|
+
}
|
|
1136
|
+
function areIdentical(srcStat, destStat) {
|
|
1137
|
+
return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
|
|
1138
|
+
}
|
|
1139
|
+
function isSrcSubdir(src, dest) {
|
|
1140
|
+
const srcArr = path.resolve(src).split(path.sep).filter((i) => i);
|
|
1141
|
+
const destArr = path.resolve(dest).split(path.sep).filter((i) => i);
|
|
1142
|
+
return srcArr.reduce((acc, cur, i) => acc && destArr[i] === cur, true);
|
|
1143
|
+
}
|
|
1144
|
+
function errMsg(src, dest, funcName) {
|
|
1145
|
+
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
|
|
1146
|
+
}
|
|
1147
|
+
var fs = require_fs();
|
|
1148
|
+
var path = import.meta.require("path");
|
|
1149
|
+
var util = import.meta.require("util");
|
|
1150
|
+
module.exports = {
|
|
1151
|
+
checkPaths,
|
|
1152
|
+
checkPathsSync,
|
|
1153
|
+
checkParentPaths,
|
|
1154
|
+
checkParentPathsSync,
|
|
1155
|
+
isSrcSubdir,
|
|
1156
|
+
areIdentical
|
|
1157
|
+
};
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
// ../../node_modules/fs-extra/lib/copy/copy.js
|
|
1161
|
+
var require_copy = __commonJS((exports, module) => {
|
|
1162
|
+
function copy(src, dest, opts, cb) {
|
|
1163
|
+
if (typeof opts === "function" && !cb) {
|
|
1164
|
+
cb = opts;
|
|
1165
|
+
opts = {};
|
|
1166
|
+
} else if (typeof opts === "function") {
|
|
1167
|
+
opts = { filter: opts };
|
|
1168
|
+
}
|
|
1169
|
+
cb = cb || function() {
|
|
1170
|
+
};
|
|
1171
|
+
opts = opts || {};
|
|
1172
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
1173
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
1174
|
+
if (opts.preserveTimestamps && process.arch === "ia32") {
|
|
1175
|
+
process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n" + "\tsee https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0001");
|
|
1176
|
+
}
|
|
1177
|
+
stat.checkPaths(src, dest, "copy", opts, (err, stats) => {
|
|
1178
|
+
if (err)
|
|
1179
|
+
return cb(err);
|
|
1180
|
+
const { srcStat, destStat } = stats;
|
|
1181
|
+
stat.checkParentPaths(src, srcStat, dest, "copy", (err2) => {
|
|
1182
|
+
if (err2)
|
|
1183
|
+
return cb(err2);
|
|
1184
|
+
if (opts.filter)
|
|
1185
|
+
return handleFilter(checkParentDir, destStat, src, dest, opts, cb);
|
|
1186
|
+
return checkParentDir(destStat, src, dest, opts, cb);
|
|
1187
|
+
});
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
function checkParentDir(destStat, src, dest, opts, cb) {
|
|
1191
|
+
const destParent = path.dirname(dest);
|
|
1192
|
+
pathExists(destParent, (err, dirExists) => {
|
|
1193
|
+
if (err)
|
|
1194
|
+
return cb(err);
|
|
1195
|
+
if (dirExists)
|
|
1196
|
+
return getStats(destStat, src, dest, opts, cb);
|
|
1197
|
+
mkdirs(destParent, (err2) => {
|
|
1198
|
+
if (err2)
|
|
1199
|
+
return cb(err2);
|
|
1200
|
+
return getStats(destStat, src, dest, opts, cb);
|
|
1201
|
+
});
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
function handleFilter(onInclude, destStat, src, dest, opts, cb) {
|
|
1205
|
+
Promise.resolve(opts.filter(src, dest)).then((include) => {
|
|
1206
|
+
if (include)
|
|
1207
|
+
return onInclude(destStat, src, dest, opts, cb);
|
|
1208
|
+
return cb();
|
|
1209
|
+
}, (error) => cb(error));
|
|
1210
|
+
}
|
|
1211
|
+
function startCopy(destStat, src, dest, opts, cb) {
|
|
1212
|
+
if (opts.filter)
|
|
1213
|
+
return handleFilter(getStats, destStat, src, dest, opts, cb);
|
|
1214
|
+
return getStats(destStat, src, dest, opts, cb);
|
|
1215
|
+
}
|
|
1216
|
+
function getStats(destStat, src, dest, opts, cb) {
|
|
1217
|
+
const stat2 = opts.dereference ? fs.stat : fs.lstat;
|
|
1218
|
+
stat2(src, (err, srcStat) => {
|
|
1219
|
+
if (err)
|
|
1220
|
+
return cb(err);
|
|
1221
|
+
if (srcStat.isDirectory())
|
|
1222
|
+
return onDir(srcStat, destStat, src, dest, opts, cb);
|
|
1223
|
+
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
|
|
1224
|
+
return onFile(srcStat, destStat, src, dest, opts, cb);
|
|
1225
|
+
else if (srcStat.isSymbolicLink())
|
|
1226
|
+
return onLink(destStat, src, dest, opts, cb);
|
|
1227
|
+
else if (srcStat.isSocket())
|
|
1228
|
+
return cb(new Error(`Cannot copy a socket file: ${src}`));
|
|
1229
|
+
else if (srcStat.isFIFO())
|
|
1230
|
+
return cb(new Error(`Cannot copy a FIFO pipe: ${src}`));
|
|
1231
|
+
return cb(new Error(`Unknown file: ${src}`));
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
function onFile(srcStat, destStat, src, dest, opts, cb) {
|
|
1235
|
+
if (!destStat)
|
|
1236
|
+
return copyFile(srcStat, src, dest, opts, cb);
|
|
1237
|
+
return mayCopyFile(srcStat, src, dest, opts, cb);
|
|
1238
|
+
}
|
|
1239
|
+
function mayCopyFile(srcStat, src, dest, opts, cb) {
|
|
1240
|
+
if (opts.overwrite) {
|
|
1241
|
+
fs.unlink(dest, (err) => {
|
|
1242
|
+
if (err)
|
|
1243
|
+
return cb(err);
|
|
1244
|
+
return copyFile(srcStat, src, dest, opts, cb);
|
|
1245
|
+
});
|
|
1246
|
+
} else if (opts.errorOnExist) {
|
|
1247
|
+
return cb(new Error(`'${dest}' already exists`));
|
|
1248
|
+
} else
|
|
1249
|
+
return cb();
|
|
1250
|
+
}
|
|
1251
|
+
function copyFile(srcStat, src, dest, opts, cb) {
|
|
1252
|
+
fs.copyFile(src, dest, (err) => {
|
|
1253
|
+
if (err)
|
|
1254
|
+
return cb(err);
|
|
1255
|
+
if (opts.preserveTimestamps)
|
|
1256
|
+
return handleTimestampsAndMode(srcStat.mode, src, dest, cb);
|
|
1257
|
+
return setDestMode(dest, srcStat.mode, cb);
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
function handleTimestampsAndMode(srcMode, src, dest, cb) {
|
|
1261
|
+
if (fileIsNotWritable(srcMode)) {
|
|
1262
|
+
return makeFileWritable(dest, srcMode, (err) => {
|
|
1263
|
+
if (err)
|
|
1264
|
+
return cb(err);
|
|
1265
|
+
return setDestTimestampsAndMode(srcMode, src, dest, cb);
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
return setDestTimestampsAndMode(srcMode, src, dest, cb);
|
|
1269
|
+
}
|
|
1270
|
+
function fileIsNotWritable(srcMode) {
|
|
1271
|
+
return (srcMode & 128) === 0;
|
|
1272
|
+
}
|
|
1273
|
+
function makeFileWritable(dest, srcMode, cb) {
|
|
1274
|
+
return setDestMode(dest, srcMode | 128, cb);
|
|
1275
|
+
}
|
|
1276
|
+
function setDestTimestampsAndMode(srcMode, src, dest, cb) {
|
|
1277
|
+
setDestTimestamps(src, dest, (err) => {
|
|
1278
|
+
if (err)
|
|
1279
|
+
return cb(err);
|
|
1280
|
+
return setDestMode(dest, srcMode, cb);
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
function setDestMode(dest, srcMode, cb) {
|
|
1284
|
+
return fs.chmod(dest, srcMode, cb);
|
|
1285
|
+
}
|
|
1286
|
+
function setDestTimestamps(src, dest, cb) {
|
|
1287
|
+
fs.stat(src, (err, updatedSrcStat) => {
|
|
1288
|
+
if (err)
|
|
1289
|
+
return cb(err);
|
|
1290
|
+
return utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime, cb);
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
function onDir(srcStat, destStat, src, dest, opts, cb) {
|
|
1294
|
+
if (!destStat)
|
|
1295
|
+
return mkDirAndCopy(srcStat.mode, src, dest, opts, cb);
|
|
1296
|
+
return copyDir(src, dest, opts, cb);
|
|
1297
|
+
}
|
|
1298
|
+
function mkDirAndCopy(srcMode, src, dest, opts, cb) {
|
|
1299
|
+
fs.mkdir(dest, (err) => {
|
|
1300
|
+
if (err)
|
|
1301
|
+
return cb(err);
|
|
1302
|
+
copyDir(src, dest, opts, (err2) => {
|
|
1303
|
+
if (err2)
|
|
1304
|
+
return cb(err2);
|
|
1305
|
+
return setDestMode(dest, srcMode, cb);
|
|
1306
|
+
});
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
function copyDir(src, dest, opts, cb) {
|
|
1310
|
+
fs.readdir(src, (err, items) => {
|
|
1311
|
+
if (err)
|
|
1312
|
+
return cb(err);
|
|
1313
|
+
return copyDirItems(items, src, dest, opts, cb);
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
function copyDirItems(items, src, dest, opts, cb) {
|
|
1317
|
+
const item = items.pop();
|
|
1318
|
+
if (!item)
|
|
1319
|
+
return cb();
|
|
1320
|
+
return copyDirItem(items, item, src, dest, opts, cb);
|
|
1321
|
+
}
|
|
1322
|
+
function copyDirItem(items, item, src, dest, opts, cb) {
|
|
1323
|
+
const srcItem = path.join(src, item);
|
|
1324
|
+
const destItem = path.join(dest, item);
|
|
1325
|
+
stat.checkPaths(srcItem, destItem, "copy", opts, (err, stats) => {
|
|
1326
|
+
if (err)
|
|
1327
|
+
return cb(err);
|
|
1328
|
+
const { destStat } = stats;
|
|
1329
|
+
startCopy(destStat, srcItem, destItem, opts, (err2) => {
|
|
1330
|
+
if (err2)
|
|
1331
|
+
return cb(err2);
|
|
1332
|
+
return copyDirItems(items, src, dest, opts, cb);
|
|
1333
|
+
});
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
function onLink(destStat, src, dest, opts, cb) {
|
|
1337
|
+
fs.readlink(src, (err, resolvedSrc) => {
|
|
1338
|
+
if (err)
|
|
1339
|
+
return cb(err);
|
|
1340
|
+
if (opts.dereference) {
|
|
1341
|
+
resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
|
|
1342
|
+
}
|
|
1343
|
+
if (!destStat) {
|
|
1344
|
+
return fs.symlink(resolvedSrc, dest, cb);
|
|
1345
|
+
} else {
|
|
1346
|
+
fs.readlink(dest, (err2, resolvedDest) => {
|
|
1347
|
+
if (err2) {
|
|
1348
|
+
if (err2.code === "EINVAL" || err2.code === "UNKNOWN")
|
|
1349
|
+
return fs.symlink(resolvedSrc, dest, cb);
|
|
1350
|
+
return cb(err2);
|
|
1351
|
+
}
|
|
1352
|
+
if (opts.dereference) {
|
|
1353
|
+
resolvedDest = path.resolve(process.cwd(), resolvedDest);
|
|
1354
|
+
}
|
|
1355
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
1356
|
+
return cb(new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`));
|
|
1357
|
+
}
|
|
1358
|
+
if (destStat.isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
1359
|
+
return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`));
|
|
1360
|
+
}
|
|
1361
|
+
return copyLink(resolvedSrc, dest, cb);
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
function copyLink(resolvedSrc, dest, cb) {
|
|
1367
|
+
fs.unlink(dest, (err) => {
|
|
1368
|
+
if (err)
|
|
1369
|
+
return cb(err);
|
|
1370
|
+
return fs.symlink(resolvedSrc, dest, cb);
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
var fs = require_graceful_fs();
|
|
1374
|
+
var path = import.meta.require("path");
|
|
1375
|
+
var mkdirs = require_mkdirs().mkdirs;
|
|
1376
|
+
var pathExists = require_path_exists().pathExists;
|
|
1377
|
+
var utimesMillis = require_utimes().utimesMillis;
|
|
1378
|
+
var stat = require_stat();
|
|
1379
|
+
module.exports = copy;
|
|
1380
|
+
});
|
|
1381
|
+
|
|
1382
|
+
// ../../node_modules/fs-extra/lib/copy/copy-sync.js
|
|
1383
|
+
var require_copy_sync = __commonJS((exports, module) => {
|
|
1384
|
+
function copySync(src, dest, opts) {
|
|
1385
|
+
if (typeof opts === "function") {
|
|
1386
|
+
opts = { filter: opts };
|
|
1387
|
+
}
|
|
1388
|
+
opts = opts || {};
|
|
1389
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
1390
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
1391
|
+
if (opts.preserveTimestamps && process.arch === "ia32") {
|
|
1392
|
+
process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n" + "\tsee https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0002");
|
|
1393
|
+
}
|
|
1394
|
+
const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
|
|
1395
|
+
stat.checkParentPathsSync(src, srcStat, dest, "copy");
|
|
1396
|
+
return handleFilterAndCopy(destStat, src, dest, opts);
|
|
1397
|
+
}
|
|
1398
|
+
function handleFilterAndCopy(destStat, src, dest, opts) {
|
|
1399
|
+
if (opts.filter && !opts.filter(src, dest))
|
|
1400
|
+
return;
|
|
1401
|
+
const destParent = path.dirname(dest);
|
|
1402
|
+
if (!fs.existsSync(destParent))
|
|
1403
|
+
mkdirsSync(destParent);
|
|
1404
|
+
return getStats(destStat, src, dest, opts);
|
|
1405
|
+
}
|
|
1406
|
+
function startCopy(destStat, src, dest, opts) {
|
|
1407
|
+
if (opts.filter && !opts.filter(src, dest))
|
|
1408
|
+
return;
|
|
1409
|
+
return getStats(destStat, src, dest, opts);
|
|
1410
|
+
}
|
|
1411
|
+
function getStats(destStat, src, dest, opts) {
|
|
1412
|
+
const statSync = opts.dereference ? fs.statSync : fs.lstatSync;
|
|
1413
|
+
const srcStat = statSync(src);
|
|
1414
|
+
if (srcStat.isDirectory())
|
|
1415
|
+
return onDir(srcStat, destStat, src, dest, opts);
|
|
1416
|
+
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
|
|
1417
|
+
return onFile(srcStat, destStat, src, dest, opts);
|
|
1418
|
+
else if (srcStat.isSymbolicLink())
|
|
1419
|
+
return onLink(destStat, src, dest, opts);
|
|
1420
|
+
else if (srcStat.isSocket())
|
|
1421
|
+
throw new Error(`Cannot copy a socket file: ${src}`);
|
|
1422
|
+
else if (srcStat.isFIFO())
|
|
1423
|
+
throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
1424
|
+
throw new Error(`Unknown file: ${src}`);
|
|
1425
|
+
}
|
|
1426
|
+
function onFile(srcStat, destStat, src, dest, opts) {
|
|
1427
|
+
if (!destStat)
|
|
1428
|
+
return copyFile(srcStat, src, dest, opts);
|
|
1429
|
+
return mayCopyFile(srcStat, src, dest, opts);
|
|
1430
|
+
}
|
|
1431
|
+
function mayCopyFile(srcStat, src, dest, opts) {
|
|
1432
|
+
if (opts.overwrite) {
|
|
1433
|
+
fs.unlinkSync(dest);
|
|
1434
|
+
return copyFile(srcStat, src, dest, opts);
|
|
1435
|
+
} else if (opts.errorOnExist) {
|
|
1436
|
+
throw new Error(`'${dest}' already exists`);
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
function copyFile(srcStat, src, dest, opts) {
|
|
1440
|
+
fs.copyFileSync(src, dest);
|
|
1441
|
+
if (opts.preserveTimestamps)
|
|
1442
|
+
handleTimestamps(srcStat.mode, src, dest);
|
|
1443
|
+
return setDestMode(dest, srcStat.mode);
|
|
1444
|
+
}
|
|
1445
|
+
function handleTimestamps(srcMode, src, dest) {
|
|
1446
|
+
if (fileIsNotWritable(srcMode))
|
|
1447
|
+
makeFileWritable(dest, srcMode);
|
|
1448
|
+
return setDestTimestamps(src, dest);
|
|
1449
|
+
}
|
|
1450
|
+
function fileIsNotWritable(srcMode) {
|
|
1451
|
+
return (srcMode & 128) === 0;
|
|
1452
|
+
}
|
|
1453
|
+
function makeFileWritable(dest, srcMode) {
|
|
1454
|
+
return setDestMode(dest, srcMode | 128);
|
|
1455
|
+
}
|
|
1456
|
+
function setDestMode(dest, srcMode) {
|
|
1457
|
+
return fs.chmodSync(dest, srcMode);
|
|
1458
|
+
}
|
|
1459
|
+
function setDestTimestamps(src, dest) {
|
|
1460
|
+
const updatedSrcStat = fs.statSync(src);
|
|
1461
|
+
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
1462
|
+
}
|
|
1463
|
+
function onDir(srcStat, destStat, src, dest, opts) {
|
|
1464
|
+
if (!destStat)
|
|
1465
|
+
return mkDirAndCopy(srcStat.mode, src, dest, opts);
|
|
1466
|
+
return copyDir(src, dest, opts);
|
|
1467
|
+
}
|
|
1468
|
+
function mkDirAndCopy(srcMode, src, dest, opts) {
|
|
1469
|
+
fs.mkdirSync(dest);
|
|
1470
|
+
copyDir(src, dest, opts);
|
|
1471
|
+
return setDestMode(dest, srcMode);
|
|
1472
|
+
}
|
|
1473
|
+
function copyDir(src, dest, opts) {
|
|
1474
|
+
fs.readdirSync(src).forEach((item) => copyDirItem(item, src, dest, opts));
|
|
1475
|
+
}
|
|
1476
|
+
function copyDirItem(item, src, dest, opts) {
|
|
1477
|
+
const srcItem = path.join(src, item);
|
|
1478
|
+
const destItem = path.join(dest, item);
|
|
1479
|
+
const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
|
|
1480
|
+
return startCopy(destStat, srcItem, destItem, opts);
|
|
1481
|
+
}
|
|
1482
|
+
function onLink(destStat, src, dest, opts) {
|
|
1483
|
+
let resolvedSrc = fs.readlinkSync(src);
|
|
1484
|
+
if (opts.dereference) {
|
|
1485
|
+
resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
|
|
1486
|
+
}
|
|
1487
|
+
if (!destStat) {
|
|
1488
|
+
return fs.symlinkSync(resolvedSrc, dest);
|
|
1489
|
+
} else {
|
|
1490
|
+
let resolvedDest;
|
|
1491
|
+
try {
|
|
1492
|
+
resolvedDest = fs.readlinkSync(dest);
|
|
1493
|
+
} catch (err) {
|
|
1494
|
+
if (err.code === "EINVAL" || err.code === "UNKNOWN")
|
|
1495
|
+
return fs.symlinkSync(resolvedSrc, dest);
|
|
1496
|
+
throw err;
|
|
1497
|
+
}
|
|
1498
|
+
if (opts.dereference) {
|
|
1499
|
+
resolvedDest = path.resolve(process.cwd(), resolvedDest);
|
|
1500
|
+
}
|
|
1501
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
1502
|
+
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
1503
|
+
}
|
|
1504
|
+
if (fs.statSync(dest).isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
1505
|
+
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
1506
|
+
}
|
|
1507
|
+
return copyLink(resolvedSrc, dest);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
function copyLink(resolvedSrc, dest) {
|
|
1511
|
+
fs.unlinkSync(dest);
|
|
1512
|
+
return fs.symlinkSync(resolvedSrc, dest);
|
|
1513
|
+
}
|
|
1514
|
+
var fs = require_graceful_fs();
|
|
1515
|
+
var path = import.meta.require("path");
|
|
1516
|
+
var mkdirsSync = require_mkdirs().mkdirsSync;
|
|
1517
|
+
var utimesMillisSync = require_utimes().utimesMillisSync;
|
|
1518
|
+
var stat = require_stat();
|
|
1519
|
+
module.exports = copySync;
|
|
1520
|
+
});
|
|
1521
|
+
|
|
1522
|
+
// ../../node_modules/fs-extra/lib/copy/index.js
|
|
1523
|
+
var require_copy2 = __commonJS((exports, module) => {
|
|
1524
|
+
var u = require_universalify().fromCallback;
|
|
1525
|
+
module.exports = {
|
|
1526
|
+
copy: u(require_copy()),
|
|
1527
|
+
copySync: require_copy_sync()
|
|
1528
|
+
};
|
|
1529
|
+
});
|
|
1530
|
+
|
|
1531
|
+
// ../../node_modules/fs-extra/lib/remove/rimraf.js
|
|
1532
|
+
var require_rimraf = __commonJS((exports, module) => {
|
|
1533
|
+
function defaults(options) {
|
|
1534
|
+
const methods = [
|
|
1535
|
+
"unlink",
|
|
1536
|
+
"chmod",
|
|
1537
|
+
"stat",
|
|
1538
|
+
"lstat",
|
|
1539
|
+
"rmdir",
|
|
1540
|
+
"readdir"
|
|
1541
|
+
];
|
|
1542
|
+
methods.forEach((m) => {
|
|
1543
|
+
options[m] = options[m] || fs[m];
|
|
1544
|
+
m = m + "Sync";
|
|
1545
|
+
options[m] = options[m] || fs[m];
|
|
1546
|
+
});
|
|
1547
|
+
options.maxBusyTries = options.maxBusyTries || 3;
|
|
1548
|
+
}
|
|
1549
|
+
function rimraf(p, options, cb) {
|
|
1550
|
+
let busyTries = 0;
|
|
1551
|
+
if (typeof options === "function") {
|
|
1552
|
+
cb = options;
|
|
1553
|
+
options = {};
|
|
1554
|
+
}
|
|
1555
|
+
assert(p, "rimraf: missing path");
|
|
1556
|
+
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
|
|
1557
|
+
assert.strictEqual(typeof cb, "function", "rimraf: callback function required");
|
|
1558
|
+
assert(options, "rimraf: invalid options argument provided");
|
|
1559
|
+
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
|
|
1560
|
+
defaults(options);
|
|
1561
|
+
rimraf_(p, options, function CB(er) {
|
|
1562
|
+
if (er) {
|
|
1563
|
+
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && busyTries < options.maxBusyTries) {
|
|
1564
|
+
busyTries++;
|
|
1565
|
+
const time = busyTries * 100;
|
|
1566
|
+
return setTimeout(() => rimraf_(p, options, CB), time);
|
|
1567
|
+
}
|
|
1568
|
+
if (er.code === "ENOENT")
|
|
1569
|
+
er = null;
|
|
1570
|
+
}
|
|
1571
|
+
cb(er);
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
function rimraf_(p, options, cb) {
|
|
1575
|
+
assert(p);
|
|
1576
|
+
assert(options);
|
|
1577
|
+
assert(typeof cb === "function");
|
|
1578
|
+
options.lstat(p, (er, st) => {
|
|
1579
|
+
if (er && er.code === "ENOENT") {
|
|
1580
|
+
return cb(null);
|
|
1581
|
+
}
|
|
1582
|
+
if (er && er.code === "EPERM" && isWindows) {
|
|
1583
|
+
return fixWinEPERM(p, options, er, cb);
|
|
1584
|
+
}
|
|
1585
|
+
if (st && st.isDirectory()) {
|
|
1586
|
+
return rmdir(p, options, er, cb);
|
|
1587
|
+
}
|
|
1588
|
+
options.unlink(p, (er2) => {
|
|
1589
|
+
if (er2) {
|
|
1590
|
+
if (er2.code === "ENOENT") {
|
|
1591
|
+
return cb(null);
|
|
1592
|
+
}
|
|
1593
|
+
if (er2.code === "EPERM") {
|
|
1594
|
+
return isWindows ? fixWinEPERM(p, options, er2, cb) : rmdir(p, options, er2, cb);
|
|
1595
|
+
}
|
|
1596
|
+
if (er2.code === "EISDIR") {
|
|
1597
|
+
return rmdir(p, options, er2, cb);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
return cb(er2);
|
|
1601
|
+
});
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
function fixWinEPERM(p, options, er, cb) {
|
|
1605
|
+
assert(p);
|
|
1606
|
+
assert(options);
|
|
1607
|
+
assert(typeof cb === "function");
|
|
1608
|
+
options.chmod(p, 438, (er2) => {
|
|
1609
|
+
if (er2) {
|
|
1610
|
+
cb(er2.code === "ENOENT" ? null : er);
|
|
1611
|
+
} else {
|
|
1612
|
+
options.stat(p, (er3, stats) => {
|
|
1613
|
+
if (er3) {
|
|
1614
|
+
cb(er3.code === "ENOENT" ? null : er);
|
|
1615
|
+
} else if (stats.isDirectory()) {
|
|
1616
|
+
rmdir(p, options, er, cb);
|
|
1617
|
+
} else {
|
|
1618
|
+
options.unlink(p, cb);
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
function fixWinEPERMSync(p, options, er) {
|
|
1625
|
+
let stats;
|
|
1626
|
+
assert(p);
|
|
1627
|
+
assert(options);
|
|
1628
|
+
try {
|
|
1629
|
+
options.chmodSync(p, 438);
|
|
1630
|
+
} catch (er2) {
|
|
1631
|
+
if (er2.code === "ENOENT") {
|
|
1632
|
+
return;
|
|
1633
|
+
} else {
|
|
1634
|
+
throw er;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
try {
|
|
1638
|
+
stats = options.statSync(p);
|
|
1639
|
+
} catch (er3) {
|
|
1640
|
+
if (er3.code === "ENOENT") {
|
|
1641
|
+
return;
|
|
1642
|
+
} else {
|
|
1643
|
+
throw er;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
if (stats.isDirectory()) {
|
|
1647
|
+
rmdirSync(p, options, er);
|
|
1648
|
+
} else {
|
|
1649
|
+
options.unlinkSync(p);
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
function rmdir(p, options, originalEr, cb) {
|
|
1653
|
+
assert(p);
|
|
1654
|
+
assert(options);
|
|
1655
|
+
assert(typeof cb === "function");
|
|
1656
|
+
options.rmdir(p, (er) => {
|
|
1657
|
+
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) {
|
|
1658
|
+
rmkids(p, options, cb);
|
|
1659
|
+
} else if (er && er.code === "ENOTDIR") {
|
|
1660
|
+
cb(originalEr);
|
|
1661
|
+
} else {
|
|
1662
|
+
cb(er);
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
function rmkids(p, options, cb) {
|
|
1667
|
+
assert(p);
|
|
1668
|
+
assert(options);
|
|
1669
|
+
assert(typeof cb === "function");
|
|
1670
|
+
options.readdir(p, (er, files) => {
|
|
1671
|
+
if (er)
|
|
1672
|
+
return cb(er);
|
|
1673
|
+
let n = files.length;
|
|
1674
|
+
let errState;
|
|
1675
|
+
if (n === 0)
|
|
1676
|
+
return options.rmdir(p, cb);
|
|
1677
|
+
files.forEach((f) => {
|
|
1678
|
+
rimraf(path.join(p, f), options, (er2) => {
|
|
1679
|
+
if (errState) {
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
if (er2)
|
|
1683
|
+
return cb(errState = er2);
|
|
1684
|
+
if (--n === 0) {
|
|
1685
|
+
options.rmdir(p, cb);
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
});
|
|
1689
|
+
});
|
|
1690
|
+
}
|
|
1691
|
+
function rimrafSync(p, options) {
|
|
1692
|
+
let st;
|
|
1693
|
+
options = options || {};
|
|
1694
|
+
defaults(options);
|
|
1695
|
+
assert(p, "rimraf: missing path");
|
|
1696
|
+
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
|
|
1697
|
+
assert(options, "rimraf: missing options");
|
|
1698
|
+
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
|
|
1699
|
+
try {
|
|
1700
|
+
st = options.lstatSync(p);
|
|
1701
|
+
} catch (er) {
|
|
1702
|
+
if (er.code === "ENOENT") {
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
if (er.code === "EPERM" && isWindows) {
|
|
1706
|
+
fixWinEPERMSync(p, options, er);
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
try {
|
|
1710
|
+
if (st && st.isDirectory()) {
|
|
1711
|
+
rmdirSync(p, options, null);
|
|
1712
|
+
} else {
|
|
1713
|
+
options.unlinkSync(p);
|
|
1714
|
+
}
|
|
1715
|
+
} catch (er) {
|
|
1716
|
+
if (er.code === "ENOENT") {
|
|
1717
|
+
return;
|
|
1718
|
+
} else if (er.code === "EPERM") {
|
|
1719
|
+
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er);
|
|
1720
|
+
} else if (er.code !== "EISDIR") {
|
|
1721
|
+
throw er;
|
|
1722
|
+
}
|
|
1723
|
+
rmdirSync(p, options, er);
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
function rmdirSync(p, options, originalEr) {
|
|
1727
|
+
assert(p);
|
|
1728
|
+
assert(options);
|
|
1729
|
+
try {
|
|
1730
|
+
options.rmdirSync(p);
|
|
1731
|
+
} catch (er) {
|
|
1732
|
+
if (er.code === "ENOTDIR") {
|
|
1733
|
+
throw originalEr;
|
|
1734
|
+
} else if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") {
|
|
1735
|
+
rmkidsSync(p, options);
|
|
1736
|
+
} else if (er.code !== "ENOENT") {
|
|
1737
|
+
throw er;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
function rmkidsSync(p, options) {
|
|
1742
|
+
assert(p);
|
|
1743
|
+
assert(options);
|
|
1744
|
+
options.readdirSync(p).forEach((f) => rimrafSync(path.join(p, f), options));
|
|
1745
|
+
if (isWindows) {
|
|
1746
|
+
const startTime = Date.now();
|
|
1747
|
+
do {
|
|
1748
|
+
try {
|
|
1749
|
+
const ret = options.rmdirSync(p, options);
|
|
1750
|
+
return ret;
|
|
1751
|
+
} catch {
|
|
1752
|
+
}
|
|
1753
|
+
} while (Date.now() - startTime < 500);
|
|
1754
|
+
} else {
|
|
1755
|
+
const ret = options.rmdirSync(p, options);
|
|
1756
|
+
return ret;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
var fs = require_graceful_fs();
|
|
1760
|
+
var path = import.meta.require("path");
|
|
1761
|
+
var assert = import.meta.require("assert");
|
|
1762
|
+
var isWindows = process.platform === "win32";
|
|
1763
|
+
module.exports = rimraf;
|
|
1764
|
+
rimraf.sync = rimrafSync;
|
|
1765
|
+
});
|
|
1766
|
+
|
|
1767
|
+
// ../../node_modules/fs-extra/lib/remove/index.js
|
|
1768
|
+
var require_remove = __commonJS((exports, module) => {
|
|
1769
|
+
function remove(path, callback) {
|
|
1770
|
+
if (fs.rm)
|
|
1771
|
+
return fs.rm(path, { recursive: true, force: true }, callback);
|
|
1772
|
+
rimraf(path, callback);
|
|
1773
|
+
}
|
|
1774
|
+
function removeSync(path) {
|
|
1775
|
+
if (fs.rmSync)
|
|
1776
|
+
return fs.rmSync(path, { recursive: true, force: true });
|
|
1777
|
+
rimraf.sync(path);
|
|
1778
|
+
}
|
|
1779
|
+
var fs = require_graceful_fs();
|
|
1780
|
+
var u = require_universalify().fromCallback;
|
|
1781
|
+
var rimraf = require_rimraf();
|
|
1782
|
+
module.exports = {
|
|
1783
|
+
remove: u(remove),
|
|
1784
|
+
removeSync
|
|
1785
|
+
};
|
|
1786
|
+
});
|
|
1787
|
+
|
|
1788
|
+
// ../../node_modules/fs-extra/lib/empty/index.js
|
|
1789
|
+
var require_empty = __commonJS((exports, module) => {
|
|
1790
|
+
function emptyDirSync(dir) {
|
|
1791
|
+
let items;
|
|
1792
|
+
try {
|
|
1793
|
+
items = fs.readdirSync(dir);
|
|
1794
|
+
} catch {
|
|
1795
|
+
return mkdir.mkdirsSync(dir);
|
|
1796
|
+
}
|
|
1797
|
+
items.forEach((item) => {
|
|
1798
|
+
item = path.join(dir, item);
|
|
1799
|
+
remove.removeSync(item);
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
var u = require_universalify().fromPromise;
|
|
1803
|
+
var fs = require_fs();
|
|
1804
|
+
var path = import.meta.require("path");
|
|
1805
|
+
var mkdir = require_mkdirs();
|
|
1806
|
+
var remove = require_remove();
|
|
1807
|
+
var emptyDir = u(async function emptyDir(dir) {
|
|
1808
|
+
let items;
|
|
1809
|
+
try {
|
|
1810
|
+
items = await fs.readdir(dir);
|
|
1811
|
+
} catch {
|
|
1812
|
+
return mkdir.mkdirs(dir);
|
|
1813
|
+
}
|
|
1814
|
+
return Promise.all(items.map((item) => remove.remove(path.join(dir, item))));
|
|
1815
|
+
});
|
|
1816
|
+
module.exports = {
|
|
1817
|
+
emptyDirSync,
|
|
1818
|
+
emptydirSync: emptyDirSync,
|
|
1819
|
+
emptyDir,
|
|
1820
|
+
emptydir: emptyDir
|
|
1821
|
+
};
|
|
1822
|
+
});
|
|
1823
|
+
|
|
1824
|
+
// ../../node_modules/fs-extra/lib/ensure/file.js
|
|
1825
|
+
var require_file = __commonJS((exports, module) => {
|
|
1826
|
+
function createFile(file, callback) {
|
|
1827
|
+
function makeFile() {
|
|
1828
|
+
fs.writeFile(file, "", (err) => {
|
|
1829
|
+
if (err)
|
|
1830
|
+
return callback(err);
|
|
1831
|
+
callback();
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
fs.stat(file, (err, stats) => {
|
|
1835
|
+
if (!err && stats.isFile())
|
|
1836
|
+
return callback();
|
|
1837
|
+
const dir = path.dirname(file);
|
|
1838
|
+
fs.stat(dir, (err2, stats2) => {
|
|
1839
|
+
if (err2) {
|
|
1840
|
+
if (err2.code === "ENOENT") {
|
|
1841
|
+
return mkdir.mkdirs(dir, (err3) => {
|
|
1842
|
+
if (err3)
|
|
1843
|
+
return callback(err3);
|
|
1844
|
+
makeFile();
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1847
|
+
return callback(err2);
|
|
1848
|
+
}
|
|
1849
|
+
if (stats2.isDirectory())
|
|
1850
|
+
makeFile();
|
|
1851
|
+
else {
|
|
1852
|
+
fs.readdir(dir, (err3) => {
|
|
1853
|
+
if (err3)
|
|
1854
|
+
return callback(err3);
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
});
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1860
|
+
function createFileSync(file) {
|
|
1861
|
+
let stats;
|
|
1862
|
+
try {
|
|
1863
|
+
stats = fs.statSync(file);
|
|
1864
|
+
} catch {
|
|
1865
|
+
}
|
|
1866
|
+
if (stats && stats.isFile())
|
|
1867
|
+
return;
|
|
1868
|
+
const dir = path.dirname(file);
|
|
1869
|
+
try {
|
|
1870
|
+
if (!fs.statSync(dir).isDirectory()) {
|
|
1871
|
+
fs.readdirSync(dir);
|
|
1872
|
+
}
|
|
1873
|
+
} catch (err) {
|
|
1874
|
+
if (err && err.code === "ENOENT")
|
|
1875
|
+
mkdir.mkdirsSync(dir);
|
|
1876
|
+
else
|
|
1877
|
+
throw err;
|
|
1878
|
+
}
|
|
1879
|
+
fs.writeFileSync(file, "");
|
|
1880
|
+
}
|
|
1881
|
+
var u = require_universalify().fromCallback;
|
|
1882
|
+
var path = import.meta.require("path");
|
|
1883
|
+
var fs = require_graceful_fs();
|
|
1884
|
+
var mkdir = require_mkdirs();
|
|
1885
|
+
module.exports = {
|
|
1886
|
+
createFile: u(createFile),
|
|
1887
|
+
createFileSync
|
|
1888
|
+
};
|
|
1889
|
+
});
|
|
1890
|
+
|
|
1891
|
+
// ../../node_modules/fs-extra/lib/ensure/link.js
|
|
1892
|
+
var require_link = __commonJS((exports, module) => {
|
|
1893
|
+
function createLink(srcpath, dstpath, callback) {
|
|
1894
|
+
function makeLink(srcpath2, dstpath2) {
|
|
1895
|
+
fs.link(srcpath2, dstpath2, (err) => {
|
|
1896
|
+
if (err)
|
|
1897
|
+
return callback(err);
|
|
1898
|
+
callback(null);
|
|
1899
|
+
});
|
|
1900
|
+
}
|
|
1901
|
+
fs.lstat(dstpath, (_, dstStat) => {
|
|
1902
|
+
fs.lstat(srcpath, (err, srcStat) => {
|
|
1903
|
+
if (err) {
|
|
1904
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
1905
|
+
return callback(err);
|
|
1906
|
+
}
|
|
1907
|
+
if (dstStat && areIdentical(srcStat, dstStat))
|
|
1908
|
+
return callback(null);
|
|
1909
|
+
const dir = path.dirname(dstpath);
|
|
1910
|
+
pathExists(dir, (err2, dirExists) => {
|
|
1911
|
+
if (err2)
|
|
1912
|
+
return callback(err2);
|
|
1913
|
+
if (dirExists)
|
|
1914
|
+
return makeLink(srcpath, dstpath);
|
|
1915
|
+
mkdir.mkdirs(dir, (err3) => {
|
|
1916
|
+
if (err3)
|
|
1917
|
+
return callback(err3);
|
|
1918
|
+
makeLink(srcpath, dstpath);
|
|
1919
|
+
});
|
|
1920
|
+
});
|
|
1921
|
+
});
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
function createLinkSync(srcpath, dstpath) {
|
|
1925
|
+
let dstStat;
|
|
1926
|
+
try {
|
|
1927
|
+
dstStat = fs.lstatSync(dstpath);
|
|
1928
|
+
} catch {
|
|
1929
|
+
}
|
|
1930
|
+
try {
|
|
1931
|
+
const srcStat = fs.lstatSync(srcpath);
|
|
1932
|
+
if (dstStat && areIdentical(srcStat, dstStat))
|
|
1933
|
+
return;
|
|
1934
|
+
} catch (err) {
|
|
1935
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
1936
|
+
throw err;
|
|
1937
|
+
}
|
|
1938
|
+
const dir = path.dirname(dstpath);
|
|
1939
|
+
const dirExists = fs.existsSync(dir);
|
|
1940
|
+
if (dirExists)
|
|
1941
|
+
return fs.linkSync(srcpath, dstpath);
|
|
1942
|
+
mkdir.mkdirsSync(dir);
|
|
1943
|
+
return fs.linkSync(srcpath, dstpath);
|
|
1944
|
+
}
|
|
1945
|
+
var u = require_universalify().fromCallback;
|
|
1946
|
+
var path = import.meta.require("path");
|
|
1947
|
+
var fs = require_graceful_fs();
|
|
1948
|
+
var mkdir = require_mkdirs();
|
|
1949
|
+
var pathExists = require_path_exists().pathExists;
|
|
1950
|
+
var { areIdentical } = require_stat();
|
|
1951
|
+
module.exports = {
|
|
1952
|
+
createLink: u(createLink),
|
|
1953
|
+
createLinkSync
|
|
1954
|
+
};
|
|
1955
|
+
});
|
|
1956
|
+
|
|
1957
|
+
// ../../node_modules/fs-extra/lib/ensure/symlink-paths.js
|
|
1958
|
+
var require_symlink_paths = __commonJS((exports, module) => {
|
|
1959
|
+
function symlinkPaths(srcpath, dstpath, callback) {
|
|
1960
|
+
if (path.isAbsolute(srcpath)) {
|
|
1961
|
+
return fs.lstat(srcpath, (err) => {
|
|
1962
|
+
if (err) {
|
|
1963
|
+
err.message = err.message.replace("lstat", "ensureSymlink");
|
|
1964
|
+
return callback(err);
|
|
1965
|
+
}
|
|
1966
|
+
return callback(null, {
|
|
1967
|
+
toCwd: srcpath,
|
|
1968
|
+
toDst: srcpath
|
|
1969
|
+
});
|
|
1970
|
+
});
|
|
1971
|
+
} else {
|
|
1972
|
+
const dstdir = path.dirname(dstpath);
|
|
1973
|
+
const relativeToDst = path.join(dstdir, srcpath);
|
|
1974
|
+
return pathExists(relativeToDst, (err, exists) => {
|
|
1975
|
+
if (err)
|
|
1976
|
+
return callback(err);
|
|
1977
|
+
if (exists) {
|
|
1978
|
+
return callback(null, {
|
|
1979
|
+
toCwd: relativeToDst,
|
|
1980
|
+
toDst: srcpath
|
|
1981
|
+
});
|
|
1982
|
+
} else {
|
|
1983
|
+
return fs.lstat(srcpath, (err2) => {
|
|
1984
|
+
if (err2) {
|
|
1985
|
+
err2.message = err2.message.replace("lstat", "ensureSymlink");
|
|
1986
|
+
return callback(err2);
|
|
1987
|
+
}
|
|
1988
|
+
return callback(null, {
|
|
1989
|
+
toCwd: srcpath,
|
|
1990
|
+
toDst: path.relative(dstdir, srcpath)
|
|
1991
|
+
});
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
function symlinkPathsSync(srcpath, dstpath) {
|
|
1998
|
+
let exists;
|
|
1999
|
+
if (path.isAbsolute(srcpath)) {
|
|
2000
|
+
exists = fs.existsSync(srcpath);
|
|
2001
|
+
if (!exists)
|
|
2002
|
+
throw new Error("absolute srcpath does not exist");
|
|
2003
|
+
return {
|
|
2004
|
+
toCwd: srcpath,
|
|
2005
|
+
toDst: srcpath
|
|
2006
|
+
};
|
|
2007
|
+
} else {
|
|
2008
|
+
const dstdir = path.dirname(dstpath);
|
|
2009
|
+
const relativeToDst = path.join(dstdir, srcpath);
|
|
2010
|
+
exists = fs.existsSync(relativeToDst);
|
|
2011
|
+
if (exists) {
|
|
2012
|
+
return {
|
|
2013
|
+
toCwd: relativeToDst,
|
|
2014
|
+
toDst: srcpath
|
|
2015
|
+
};
|
|
2016
|
+
} else {
|
|
2017
|
+
exists = fs.existsSync(srcpath);
|
|
2018
|
+
if (!exists)
|
|
2019
|
+
throw new Error("relative srcpath does not exist");
|
|
2020
|
+
return {
|
|
2021
|
+
toCwd: srcpath,
|
|
2022
|
+
toDst: path.relative(dstdir, srcpath)
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
var path = import.meta.require("path");
|
|
2028
|
+
var fs = require_graceful_fs();
|
|
2029
|
+
var pathExists = require_path_exists().pathExists;
|
|
2030
|
+
module.exports = {
|
|
2031
|
+
symlinkPaths,
|
|
2032
|
+
symlinkPathsSync
|
|
2033
|
+
};
|
|
2034
|
+
});
|
|
2035
|
+
|
|
2036
|
+
// ../../node_modules/fs-extra/lib/ensure/symlink-type.js
|
|
2037
|
+
var require_symlink_type = __commonJS((exports, module) => {
|
|
2038
|
+
function symlinkType(srcpath, type, callback) {
|
|
2039
|
+
callback = typeof type === "function" ? type : callback;
|
|
2040
|
+
type = typeof type === "function" ? false : type;
|
|
2041
|
+
if (type)
|
|
2042
|
+
return callback(null, type);
|
|
2043
|
+
fs.lstat(srcpath, (err, stats) => {
|
|
2044
|
+
if (err)
|
|
2045
|
+
return callback(null, "file");
|
|
2046
|
+
type = stats && stats.isDirectory() ? "dir" : "file";
|
|
2047
|
+
callback(null, type);
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
function symlinkTypeSync(srcpath, type) {
|
|
2051
|
+
let stats;
|
|
2052
|
+
if (type)
|
|
2053
|
+
return type;
|
|
2054
|
+
try {
|
|
2055
|
+
stats = fs.lstatSync(srcpath);
|
|
2056
|
+
} catch {
|
|
2057
|
+
return "file";
|
|
2058
|
+
}
|
|
2059
|
+
return stats && stats.isDirectory() ? "dir" : "file";
|
|
2060
|
+
}
|
|
2061
|
+
var fs = require_graceful_fs();
|
|
2062
|
+
module.exports = {
|
|
2063
|
+
symlinkType,
|
|
2064
|
+
symlinkTypeSync
|
|
2065
|
+
};
|
|
2066
|
+
});
|
|
2067
|
+
|
|
2068
|
+
// ../../node_modules/fs-extra/lib/ensure/symlink.js
|
|
2069
|
+
var require_symlink = __commonJS((exports, module) => {
|
|
2070
|
+
function createSymlink(srcpath, dstpath, type, callback) {
|
|
2071
|
+
callback = typeof type === "function" ? type : callback;
|
|
2072
|
+
type = typeof type === "function" ? false : type;
|
|
2073
|
+
fs.lstat(dstpath, (err, stats) => {
|
|
2074
|
+
if (!err && stats.isSymbolicLink()) {
|
|
2075
|
+
Promise.all([
|
|
2076
|
+
fs.stat(srcpath),
|
|
2077
|
+
fs.stat(dstpath)
|
|
2078
|
+
]).then(([srcStat, dstStat]) => {
|
|
2079
|
+
if (areIdentical(srcStat, dstStat))
|
|
2080
|
+
return callback(null);
|
|
2081
|
+
_createSymlink(srcpath, dstpath, type, callback);
|
|
2082
|
+
});
|
|
2083
|
+
} else
|
|
2084
|
+
_createSymlink(srcpath, dstpath, type, callback);
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
function _createSymlink(srcpath, dstpath, type, callback) {
|
|
2088
|
+
symlinkPaths(srcpath, dstpath, (err, relative) => {
|
|
2089
|
+
if (err)
|
|
2090
|
+
return callback(err);
|
|
2091
|
+
srcpath = relative.toDst;
|
|
2092
|
+
symlinkType(relative.toCwd, type, (err2, type2) => {
|
|
2093
|
+
if (err2)
|
|
2094
|
+
return callback(err2);
|
|
2095
|
+
const dir = path.dirname(dstpath);
|
|
2096
|
+
pathExists(dir, (err3, dirExists) => {
|
|
2097
|
+
if (err3)
|
|
2098
|
+
return callback(err3);
|
|
2099
|
+
if (dirExists)
|
|
2100
|
+
return fs.symlink(srcpath, dstpath, type2, callback);
|
|
2101
|
+
mkdirs(dir, (err4) => {
|
|
2102
|
+
if (err4)
|
|
2103
|
+
return callback(err4);
|
|
2104
|
+
fs.symlink(srcpath, dstpath, type2, callback);
|
|
2105
|
+
});
|
|
2106
|
+
});
|
|
2107
|
+
});
|
|
2108
|
+
});
|
|
2109
|
+
}
|
|
2110
|
+
function createSymlinkSync(srcpath, dstpath, type) {
|
|
2111
|
+
let stats;
|
|
2112
|
+
try {
|
|
2113
|
+
stats = fs.lstatSync(dstpath);
|
|
2114
|
+
} catch {
|
|
2115
|
+
}
|
|
2116
|
+
if (stats && stats.isSymbolicLink()) {
|
|
2117
|
+
const srcStat = fs.statSync(srcpath);
|
|
2118
|
+
const dstStat = fs.statSync(dstpath);
|
|
2119
|
+
if (areIdentical(srcStat, dstStat))
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
const relative = symlinkPathsSync(srcpath, dstpath);
|
|
2123
|
+
srcpath = relative.toDst;
|
|
2124
|
+
type = symlinkTypeSync(relative.toCwd, type);
|
|
2125
|
+
const dir = path.dirname(dstpath);
|
|
2126
|
+
const exists = fs.existsSync(dir);
|
|
2127
|
+
if (exists)
|
|
2128
|
+
return fs.symlinkSync(srcpath, dstpath, type);
|
|
2129
|
+
mkdirsSync(dir);
|
|
2130
|
+
return fs.symlinkSync(srcpath, dstpath, type);
|
|
2131
|
+
}
|
|
2132
|
+
var u = require_universalify().fromCallback;
|
|
2133
|
+
var path = import.meta.require("path");
|
|
2134
|
+
var fs = require_fs();
|
|
2135
|
+
var _mkdirs = require_mkdirs();
|
|
2136
|
+
var mkdirs = _mkdirs.mkdirs;
|
|
2137
|
+
var mkdirsSync = _mkdirs.mkdirsSync;
|
|
2138
|
+
var _symlinkPaths = require_symlink_paths();
|
|
2139
|
+
var symlinkPaths = _symlinkPaths.symlinkPaths;
|
|
2140
|
+
var symlinkPathsSync = _symlinkPaths.symlinkPathsSync;
|
|
2141
|
+
var _symlinkType = require_symlink_type();
|
|
2142
|
+
var symlinkType = _symlinkType.symlinkType;
|
|
2143
|
+
var symlinkTypeSync = _symlinkType.symlinkTypeSync;
|
|
2144
|
+
var pathExists = require_path_exists().pathExists;
|
|
2145
|
+
var { areIdentical } = require_stat();
|
|
2146
|
+
module.exports = {
|
|
2147
|
+
createSymlink: u(createSymlink),
|
|
2148
|
+
createSymlinkSync
|
|
2149
|
+
};
|
|
2150
|
+
});
|
|
2151
|
+
|
|
2152
|
+
// ../../node_modules/fs-extra/lib/ensure/index.js
|
|
2153
|
+
var require_ensure = __commonJS((exports, module) => {
|
|
2154
|
+
var { createFile, createFileSync } = require_file();
|
|
2155
|
+
var { createLink, createLinkSync } = require_link();
|
|
2156
|
+
var { createSymlink, createSymlinkSync } = require_symlink();
|
|
2157
|
+
module.exports = {
|
|
2158
|
+
createFile,
|
|
2159
|
+
createFileSync,
|
|
2160
|
+
ensureFile: createFile,
|
|
2161
|
+
ensureFileSync: createFileSync,
|
|
2162
|
+
createLink,
|
|
2163
|
+
createLinkSync,
|
|
2164
|
+
ensureLink: createLink,
|
|
2165
|
+
ensureLinkSync: createLinkSync,
|
|
2166
|
+
createSymlink,
|
|
2167
|
+
createSymlinkSync,
|
|
2168
|
+
ensureSymlink: createSymlink,
|
|
2169
|
+
ensureSymlinkSync: createSymlinkSync
|
|
2170
|
+
};
|
|
2171
|
+
});
|
|
2172
|
+
|
|
2173
|
+
// ../../node_modules/jsonfile/utils.js
|
|
2174
|
+
var require_utils2 = __commonJS((exports, module) => {
|
|
2175
|
+
function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
|
|
2176
|
+
const EOF = finalEOL ? EOL : "";
|
|
2177
|
+
const str = JSON.stringify(obj, replacer, spaces);
|
|
2178
|
+
return str.replace(/\n/g, EOL) + EOF;
|
|
2179
|
+
}
|
|
2180
|
+
function stripBom(content) {
|
|
2181
|
+
if (Buffer.isBuffer(content))
|
|
2182
|
+
content = content.toString("utf8");
|
|
2183
|
+
return content.replace(/^\uFEFF/, "");
|
|
2184
|
+
}
|
|
2185
|
+
module.exports = { stringify, stripBom };
|
|
2186
|
+
});
|
|
2187
|
+
|
|
2188
|
+
// ../../node_modules/jsonfile/index.js
|
|
2189
|
+
var require_jsonfile = __commonJS((exports, module) => {
|
|
2190
|
+
async function _readFile(file, options = {}) {
|
|
2191
|
+
if (typeof options === "string") {
|
|
2192
|
+
options = { encoding: options };
|
|
2193
|
+
}
|
|
2194
|
+
const fs = options.fs || _fs;
|
|
2195
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
2196
|
+
let data = await universalify.fromCallback(fs.readFile)(file, options);
|
|
2197
|
+
data = stripBom(data);
|
|
2198
|
+
let obj;
|
|
2199
|
+
try {
|
|
2200
|
+
obj = JSON.parse(data, options ? options.reviver : null);
|
|
2201
|
+
} catch (err) {
|
|
2202
|
+
if (shouldThrow) {
|
|
2203
|
+
err.message = `${file}: ${err.message}`;
|
|
2204
|
+
throw err;
|
|
2205
|
+
} else {
|
|
2206
|
+
return null;
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
return obj;
|
|
2210
|
+
}
|
|
2211
|
+
function readFileSync(file, options = {}) {
|
|
2212
|
+
if (typeof options === "string") {
|
|
2213
|
+
options = { encoding: options };
|
|
2214
|
+
}
|
|
2215
|
+
const fs = options.fs || _fs;
|
|
2216
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
2217
|
+
try {
|
|
2218
|
+
let content = fs.readFileSync(file, options);
|
|
2219
|
+
content = stripBom(content);
|
|
2220
|
+
return JSON.parse(content, options.reviver);
|
|
2221
|
+
} catch (err) {
|
|
2222
|
+
if (shouldThrow) {
|
|
2223
|
+
err.message = `${file}: ${err.message}`;
|
|
2224
|
+
throw err;
|
|
2225
|
+
} else {
|
|
2226
|
+
return null;
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
async function _writeFile(file, obj, options = {}) {
|
|
2231
|
+
const fs = options.fs || _fs;
|
|
2232
|
+
const str = stringify(obj, options);
|
|
2233
|
+
await universalify.fromCallback(fs.writeFile)(file, str, options);
|
|
2234
|
+
}
|
|
2235
|
+
function writeFileSync(file, obj, options = {}) {
|
|
2236
|
+
const fs = options.fs || _fs;
|
|
2237
|
+
const str = stringify(obj, options);
|
|
2238
|
+
return fs.writeFileSync(file, str, options);
|
|
2239
|
+
}
|
|
2240
|
+
var _fs;
|
|
2241
|
+
try {
|
|
2242
|
+
_fs = require_graceful_fs();
|
|
2243
|
+
} catch (_) {
|
|
2244
|
+
_fs = import.meta.require("fs");
|
|
2245
|
+
}
|
|
2246
|
+
var universalify = require_universalify();
|
|
2247
|
+
var { stringify, stripBom } = require_utils2();
|
|
2248
|
+
var readFile = universalify.fromPromise(_readFile);
|
|
2249
|
+
var writeFile = universalify.fromPromise(_writeFile);
|
|
2250
|
+
var jsonfile = {
|
|
2251
|
+
readFile,
|
|
2252
|
+
readFileSync,
|
|
2253
|
+
writeFile,
|
|
2254
|
+
writeFileSync
|
|
2255
|
+
};
|
|
2256
|
+
module.exports = jsonfile;
|
|
2257
|
+
});
|
|
2258
|
+
|
|
2259
|
+
// ../../node_modules/fs-extra/lib/json/jsonfile.js
|
|
2260
|
+
var require_jsonfile2 = __commonJS((exports, module) => {
|
|
2261
|
+
var jsonFile = require_jsonfile();
|
|
2262
|
+
module.exports = {
|
|
2263
|
+
readJson: jsonFile.readFile,
|
|
2264
|
+
readJsonSync: jsonFile.readFileSync,
|
|
2265
|
+
writeJson: jsonFile.writeFile,
|
|
2266
|
+
writeJsonSync: jsonFile.writeFileSync
|
|
2267
|
+
};
|
|
2268
|
+
});
|
|
2269
|
+
|
|
2270
|
+
// ../../node_modules/fs-extra/lib/output-file/index.js
|
|
2271
|
+
var require_output_file = __commonJS((exports, module) => {
|
|
2272
|
+
function outputFile(file, data, encoding, callback) {
|
|
2273
|
+
if (typeof encoding === "function") {
|
|
2274
|
+
callback = encoding;
|
|
2275
|
+
encoding = "utf8";
|
|
2276
|
+
}
|
|
2277
|
+
const dir = path.dirname(file);
|
|
2278
|
+
pathExists(dir, (err, itDoes) => {
|
|
2279
|
+
if (err)
|
|
2280
|
+
return callback(err);
|
|
2281
|
+
if (itDoes)
|
|
2282
|
+
return fs.writeFile(file, data, encoding, callback);
|
|
2283
|
+
mkdir.mkdirs(dir, (err2) => {
|
|
2284
|
+
if (err2)
|
|
2285
|
+
return callback(err2);
|
|
2286
|
+
fs.writeFile(file, data, encoding, callback);
|
|
2287
|
+
});
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
function outputFileSync(file, ...args) {
|
|
2291
|
+
const dir = path.dirname(file);
|
|
2292
|
+
if (fs.existsSync(dir)) {
|
|
2293
|
+
return fs.writeFileSync(file, ...args);
|
|
2294
|
+
}
|
|
2295
|
+
mkdir.mkdirsSync(dir);
|
|
2296
|
+
fs.writeFileSync(file, ...args);
|
|
2297
|
+
}
|
|
2298
|
+
var u = require_universalify().fromCallback;
|
|
2299
|
+
var fs = require_graceful_fs();
|
|
2300
|
+
var path = import.meta.require("path");
|
|
2301
|
+
var mkdir = require_mkdirs();
|
|
2302
|
+
var pathExists = require_path_exists().pathExists;
|
|
2303
|
+
module.exports = {
|
|
2304
|
+
outputFile: u(outputFile),
|
|
2305
|
+
outputFileSync
|
|
2306
|
+
};
|
|
2307
|
+
});
|
|
2308
|
+
|
|
2309
|
+
// ../../node_modules/fs-extra/lib/json/output-json.js
|
|
2310
|
+
var require_output_json = __commonJS((exports, module) => {
|
|
2311
|
+
async function outputJson(file, data, options = {}) {
|
|
2312
|
+
const str = stringify(data, options);
|
|
2313
|
+
await outputFile(file, str, options);
|
|
2314
|
+
}
|
|
2315
|
+
var { stringify } = require_utils2();
|
|
2316
|
+
var { outputFile } = require_output_file();
|
|
2317
|
+
module.exports = outputJson;
|
|
2318
|
+
});
|
|
2319
|
+
|
|
2320
|
+
// ../../node_modules/fs-extra/lib/json/output-json-sync.js
|
|
2321
|
+
var require_output_json_sync = __commonJS((exports, module) => {
|
|
2322
|
+
function outputJsonSync(file, data, options) {
|
|
2323
|
+
const str = stringify(data, options);
|
|
2324
|
+
outputFileSync(file, str, options);
|
|
2325
|
+
}
|
|
2326
|
+
var { stringify } = require_utils2();
|
|
2327
|
+
var { outputFileSync } = require_output_file();
|
|
2328
|
+
module.exports = outputJsonSync;
|
|
2329
|
+
});
|
|
2330
|
+
|
|
2331
|
+
// ../../node_modules/fs-extra/lib/json/index.js
|
|
2332
|
+
var require_json = __commonJS((exports, module) => {
|
|
2333
|
+
var u = require_universalify().fromPromise;
|
|
2334
|
+
var jsonFile = require_jsonfile2();
|
|
2335
|
+
jsonFile.outputJson = u(require_output_json());
|
|
2336
|
+
jsonFile.outputJsonSync = require_output_json_sync();
|
|
2337
|
+
jsonFile.outputJSON = jsonFile.outputJson;
|
|
2338
|
+
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
|
|
2339
|
+
jsonFile.writeJSON = jsonFile.writeJson;
|
|
2340
|
+
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
|
|
2341
|
+
jsonFile.readJSON = jsonFile.readJson;
|
|
2342
|
+
jsonFile.readJSONSync = jsonFile.readJsonSync;
|
|
2343
|
+
module.exports = jsonFile;
|
|
2344
|
+
});
|
|
2345
|
+
|
|
2346
|
+
// ../../node_modules/fs-extra/lib/move/move.js
|
|
2347
|
+
var require_move = __commonJS((exports, module) => {
|
|
2348
|
+
function move(src, dest, opts, cb) {
|
|
2349
|
+
if (typeof opts === "function") {
|
|
2350
|
+
cb = opts;
|
|
2351
|
+
opts = {};
|
|
2352
|
+
}
|
|
2353
|
+
opts = opts || {};
|
|
2354
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
2355
|
+
stat.checkPaths(src, dest, "move", opts, (err, stats) => {
|
|
2356
|
+
if (err)
|
|
2357
|
+
return cb(err);
|
|
2358
|
+
const { srcStat, isChangingCase = false } = stats;
|
|
2359
|
+
stat.checkParentPaths(src, srcStat, dest, "move", (err2) => {
|
|
2360
|
+
if (err2)
|
|
2361
|
+
return cb(err2);
|
|
2362
|
+
if (isParentRoot(dest))
|
|
2363
|
+
return doRename(src, dest, overwrite, isChangingCase, cb);
|
|
2364
|
+
mkdirp(path.dirname(dest), (err3) => {
|
|
2365
|
+
if (err3)
|
|
2366
|
+
return cb(err3);
|
|
2367
|
+
return doRename(src, dest, overwrite, isChangingCase, cb);
|
|
2368
|
+
});
|
|
2369
|
+
});
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
function isParentRoot(dest) {
|
|
2373
|
+
const parent = path.dirname(dest);
|
|
2374
|
+
const parsedPath = path.parse(parent);
|
|
2375
|
+
return parsedPath.root === parent;
|
|
2376
|
+
}
|
|
2377
|
+
function doRename(src, dest, overwrite, isChangingCase, cb) {
|
|
2378
|
+
if (isChangingCase)
|
|
2379
|
+
return rename(src, dest, overwrite, cb);
|
|
2380
|
+
if (overwrite) {
|
|
2381
|
+
return remove(dest, (err) => {
|
|
2382
|
+
if (err)
|
|
2383
|
+
return cb(err);
|
|
2384
|
+
return rename(src, dest, overwrite, cb);
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
pathExists(dest, (err, destExists) => {
|
|
2388
|
+
if (err)
|
|
2389
|
+
return cb(err);
|
|
2390
|
+
if (destExists)
|
|
2391
|
+
return cb(new Error("dest already exists."));
|
|
2392
|
+
return rename(src, dest, overwrite, cb);
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
function rename(src, dest, overwrite, cb) {
|
|
2396
|
+
fs.rename(src, dest, (err) => {
|
|
2397
|
+
if (!err)
|
|
2398
|
+
return cb();
|
|
2399
|
+
if (err.code !== "EXDEV")
|
|
2400
|
+
return cb(err);
|
|
2401
|
+
return moveAcrossDevice(src, dest, overwrite, cb);
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
function moveAcrossDevice(src, dest, overwrite, cb) {
|
|
2405
|
+
const opts = {
|
|
2406
|
+
overwrite,
|
|
2407
|
+
errorOnExist: true
|
|
2408
|
+
};
|
|
2409
|
+
copy(src, dest, opts, (err) => {
|
|
2410
|
+
if (err)
|
|
2411
|
+
return cb(err);
|
|
2412
|
+
return remove(src, cb);
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
var fs = require_graceful_fs();
|
|
2416
|
+
var path = import.meta.require("path");
|
|
2417
|
+
var copy = require_copy2().copy;
|
|
2418
|
+
var remove = require_remove().remove;
|
|
2419
|
+
var mkdirp = require_mkdirs().mkdirp;
|
|
2420
|
+
var pathExists = require_path_exists().pathExists;
|
|
2421
|
+
var stat = require_stat();
|
|
2422
|
+
module.exports = move;
|
|
2423
|
+
});
|
|
2424
|
+
|
|
2425
|
+
// ../../node_modules/fs-extra/lib/move/move-sync.js
|
|
2426
|
+
var require_move_sync = __commonJS((exports, module) => {
|
|
2427
|
+
function moveSync(src, dest, opts) {
|
|
2428
|
+
opts = opts || {};
|
|
2429
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
2430
|
+
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
|
|
2431
|
+
stat.checkParentPathsSync(src, srcStat, dest, "move");
|
|
2432
|
+
if (!isParentRoot(dest))
|
|
2433
|
+
mkdirpSync(path.dirname(dest));
|
|
2434
|
+
return doRename(src, dest, overwrite, isChangingCase);
|
|
2435
|
+
}
|
|
2436
|
+
function isParentRoot(dest) {
|
|
2437
|
+
const parent = path.dirname(dest);
|
|
2438
|
+
const parsedPath = path.parse(parent);
|
|
2439
|
+
return parsedPath.root === parent;
|
|
2440
|
+
}
|
|
2441
|
+
function doRename(src, dest, overwrite, isChangingCase) {
|
|
2442
|
+
if (isChangingCase)
|
|
2443
|
+
return rename(src, dest, overwrite);
|
|
2444
|
+
if (overwrite) {
|
|
2445
|
+
removeSync(dest);
|
|
2446
|
+
return rename(src, dest, overwrite);
|
|
2447
|
+
}
|
|
2448
|
+
if (fs.existsSync(dest))
|
|
2449
|
+
throw new Error("dest already exists.");
|
|
2450
|
+
return rename(src, dest, overwrite);
|
|
2451
|
+
}
|
|
2452
|
+
function rename(src, dest, overwrite) {
|
|
2453
|
+
try {
|
|
2454
|
+
fs.renameSync(src, dest);
|
|
2455
|
+
} catch (err) {
|
|
2456
|
+
if (err.code !== "EXDEV")
|
|
2457
|
+
throw err;
|
|
2458
|
+
return moveAcrossDevice(src, dest, overwrite);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
function moveAcrossDevice(src, dest, overwrite) {
|
|
2462
|
+
const opts = {
|
|
2463
|
+
overwrite,
|
|
2464
|
+
errorOnExist: true
|
|
2465
|
+
};
|
|
2466
|
+
copySync(src, dest, opts);
|
|
2467
|
+
return removeSync(src);
|
|
2468
|
+
}
|
|
2469
|
+
var fs = require_graceful_fs();
|
|
2470
|
+
var path = import.meta.require("path");
|
|
2471
|
+
var copySync = require_copy2().copySync;
|
|
2472
|
+
var removeSync = require_remove().removeSync;
|
|
2473
|
+
var mkdirpSync = require_mkdirs().mkdirpSync;
|
|
2474
|
+
var stat = require_stat();
|
|
2475
|
+
module.exports = moveSync;
|
|
2476
|
+
});
|
|
2477
|
+
|
|
2478
|
+
// ../../node_modules/fs-extra/lib/move/index.js
|
|
2479
|
+
var require_move2 = __commonJS((exports, module) => {
|
|
2480
|
+
var u = require_universalify().fromCallback;
|
|
2481
|
+
module.exports = {
|
|
2482
|
+
move: u(require_move()),
|
|
2483
|
+
moveSync: require_move_sync()
|
|
2484
|
+
};
|
|
2485
|
+
});
|
|
2486
|
+
|
|
2487
|
+
// ../../node_modules/fs-extra/lib/index.js
|
|
2488
|
+
var require_lib = __commonJS((exports, module) => {
|
|
2489
|
+
module.exports = {
|
|
2490
|
+
...require_fs(),
|
|
2491
|
+
...require_copy2(),
|
|
2492
|
+
...require_empty(),
|
|
2493
|
+
...require_ensure(),
|
|
2494
|
+
...require_json(),
|
|
2495
|
+
...require_mkdirs(),
|
|
2496
|
+
...require_move2(),
|
|
2497
|
+
...require_output_file(),
|
|
2498
|
+
...require_path_exists(),
|
|
2499
|
+
...require_remove()
|
|
2500
|
+
};
|
|
2501
|
+
});
|
|
2502
|
+
|
|
2503
|
+
// ../../node_modules/cac/dist/index.mjs
|
|
2504
|
+
import { EventEmitter } from "events";
|
|
2505
|
+
function toArr(any) {
|
|
2506
|
+
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
2507
|
+
}
|
|
2508
|
+
function toVal(out, key, val, opts) {
|
|
2509
|
+
var x, old = out[key], nxt = ~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
2510
|
+
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
2511
|
+
}
|
|
2512
|
+
function mri2(args, opts) {
|
|
2513
|
+
args = args || [];
|
|
2514
|
+
opts = opts || {};
|
|
2515
|
+
var k, arr, arg, name, val, out = { _: [] };
|
|
2516
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
2517
|
+
const alibi = opts.alias !== undefined;
|
|
2518
|
+
const strict = opts.unknown !== undefined;
|
|
2519
|
+
const defaults = opts.default !== undefined;
|
|
2520
|
+
opts.alias = opts.alias || {};
|
|
2521
|
+
opts.string = toArr(opts.string);
|
|
2522
|
+
opts.boolean = toArr(opts.boolean);
|
|
2523
|
+
if (alibi) {
|
|
2524
|
+
for (k in opts.alias) {
|
|
2525
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
2526
|
+
for (i = 0;i < arr.length; i++) {
|
|
2527
|
+
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
for (i = opts.boolean.length;i-- > 0; ) {
|
|
2532
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
2533
|
+
for (j = arr.length;j-- > 0; )
|
|
2534
|
+
opts.boolean.push(arr[j]);
|
|
2535
|
+
}
|
|
2536
|
+
for (i = opts.string.length;i-- > 0; ) {
|
|
2537
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
2538
|
+
for (j = arr.length;j-- > 0; )
|
|
2539
|
+
opts.string.push(arr[j]);
|
|
2540
|
+
}
|
|
2541
|
+
if (defaults) {
|
|
2542
|
+
for (k in opts.default) {
|
|
2543
|
+
name = typeof opts.default[k];
|
|
2544
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
2545
|
+
if (opts[name] !== undefined) {
|
|
2546
|
+
opts[name].push(k);
|
|
2547
|
+
for (i = 0;i < arr.length; i++) {
|
|
2548
|
+
opts[name].push(arr[i]);
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
2554
|
+
for (i = 0;i < len; i++) {
|
|
2555
|
+
arg = args[i];
|
|
2556
|
+
if (arg === "--") {
|
|
2557
|
+
out._ = out._.concat(args.slice(++i));
|
|
2558
|
+
break;
|
|
2559
|
+
}
|
|
2560
|
+
for (j = 0;j < arg.length; j++) {
|
|
2561
|
+
if (arg.charCodeAt(j) !== 45)
|
|
2562
|
+
break;
|
|
2563
|
+
}
|
|
2564
|
+
if (j === 0) {
|
|
2565
|
+
out._.push(arg);
|
|
2566
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
2567
|
+
name = arg.substring(j + 3);
|
|
2568
|
+
if (strict && !~keys.indexOf(name)) {
|
|
2569
|
+
return opts.unknown(arg);
|
|
2570
|
+
}
|
|
2571
|
+
out[name] = false;
|
|
2572
|
+
} else {
|
|
2573
|
+
for (idx = j + 1;idx < arg.length; idx++) {
|
|
2574
|
+
if (arg.charCodeAt(idx) === 61)
|
|
2575
|
+
break;
|
|
2576
|
+
}
|
|
2577
|
+
name = arg.substring(j, idx);
|
|
2578
|
+
val = arg.substring(++idx) || (i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i]);
|
|
2579
|
+
arr = j === 2 ? [name] : name;
|
|
2580
|
+
for (idx = 0;idx < arr.length; idx++) {
|
|
2581
|
+
name = arr[idx];
|
|
2582
|
+
if (strict && !~keys.indexOf(name))
|
|
2583
|
+
return opts.unknown("-".repeat(j) + name);
|
|
2584
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
if (defaults) {
|
|
2589
|
+
for (k in opts.default) {
|
|
2590
|
+
if (out[k] === undefined) {
|
|
2591
|
+
out[k] = opts.default[k];
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
if (alibi) {
|
|
2596
|
+
for (k in out) {
|
|
2597
|
+
arr = opts.alias[k] || [];
|
|
2598
|
+
while (arr.length > 0) {
|
|
2599
|
+
out[arr.shift()] = out[k];
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
return out;
|
|
2604
|
+
}
|
|
2605
|
+
var removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
2606
|
+
var findAllBrackets = (v) => {
|
|
2607
|
+
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
2608
|
+
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
2609
|
+
const res = [];
|
|
2610
|
+
const parse = (match) => {
|
|
2611
|
+
let variadic = false;
|
|
2612
|
+
let value = match[1];
|
|
2613
|
+
if (value.startsWith("...")) {
|
|
2614
|
+
value = value.slice(3);
|
|
2615
|
+
variadic = true;
|
|
2616
|
+
}
|
|
2617
|
+
return {
|
|
2618
|
+
required: match[0].startsWith("<"),
|
|
2619
|
+
value,
|
|
2620
|
+
variadic
|
|
2621
|
+
};
|
|
2622
|
+
};
|
|
2623
|
+
let angledMatch;
|
|
2624
|
+
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
|
|
2625
|
+
res.push(parse(angledMatch));
|
|
2626
|
+
}
|
|
2627
|
+
let squareMatch;
|
|
2628
|
+
while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
|
|
2629
|
+
res.push(parse(squareMatch));
|
|
2630
|
+
}
|
|
2631
|
+
return res;
|
|
2632
|
+
};
|
|
2633
|
+
var getMriOptions = (options) => {
|
|
2634
|
+
const result = { alias: {}, boolean: [] };
|
|
2635
|
+
for (const [index, option] of options.entries()) {
|
|
2636
|
+
if (option.names.length > 1) {
|
|
2637
|
+
result.alias[option.names[0]] = option.names.slice(1);
|
|
2638
|
+
}
|
|
2639
|
+
if (option.isBoolean) {
|
|
2640
|
+
if (option.negated) {
|
|
2641
|
+
const hasStringTypeOption = options.some((o, i) => {
|
|
2642
|
+
return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
|
|
2643
|
+
});
|
|
2644
|
+
if (!hasStringTypeOption) {
|
|
2645
|
+
result.boolean.push(option.names[0]);
|
|
2646
|
+
}
|
|
2647
|
+
} else {
|
|
2648
|
+
result.boolean.push(option.names[0]);
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
return result;
|
|
2653
|
+
};
|
|
2654
|
+
var findLongest = (arr) => {
|
|
2655
|
+
return arr.sort((a, b) => {
|
|
2656
|
+
return a.length > b.length ? -1 : 1;
|
|
2657
|
+
})[0];
|
|
2658
|
+
};
|
|
2659
|
+
var padRight = (str, length) => {
|
|
2660
|
+
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
2661
|
+
};
|
|
2662
|
+
var camelcase = (input) => {
|
|
2663
|
+
return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
2664
|
+
return p1 + p2.toUpperCase();
|
|
2665
|
+
});
|
|
2666
|
+
};
|
|
2667
|
+
var setDotProp = (obj, keys, val) => {
|
|
2668
|
+
let i = 0;
|
|
2669
|
+
let length = keys.length;
|
|
2670
|
+
let t = obj;
|
|
2671
|
+
let x;
|
|
2672
|
+
for (;i < length; ++i) {
|
|
2673
|
+
x = t[keys[i]];
|
|
2674
|
+
t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
|
|
2675
|
+
}
|
|
2676
|
+
};
|
|
2677
|
+
var setByType = (obj, transforms) => {
|
|
2678
|
+
for (const key of Object.keys(transforms)) {
|
|
2679
|
+
const transform = transforms[key];
|
|
2680
|
+
if (transform.shouldTransform) {
|
|
2681
|
+
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
2682
|
+
if (typeof transform.transformFunction === "function") {
|
|
2683
|
+
obj[key] = obj[key].map(transform.transformFunction);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
};
|
|
2688
|
+
var getFileName = (input) => {
|
|
2689
|
+
const m = /([^\\\/]+)$/.exec(input);
|
|
2690
|
+
return m ? m[1] : "";
|
|
2691
|
+
};
|
|
2692
|
+
var camelcaseOptionName = (name) => {
|
|
2693
|
+
return name.split(".").map((v, i) => {
|
|
2694
|
+
return i === 0 ? camelcase(v) : v;
|
|
2695
|
+
}).join(".");
|
|
2696
|
+
};
|
|
2697
|
+
|
|
2698
|
+
class CACError extends Error {
|
|
2699
|
+
constructor(message) {
|
|
2700
|
+
super(message);
|
|
2701
|
+
this.name = this.constructor.name;
|
|
2702
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
2703
|
+
Error.captureStackTrace(this, this.constructor);
|
|
2704
|
+
} else {
|
|
2705
|
+
this.stack = new Error(message).stack;
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
class Option {
|
|
2711
|
+
constructor(rawName, description, config) {
|
|
2712
|
+
this.rawName = rawName;
|
|
2713
|
+
this.description = description;
|
|
2714
|
+
this.config = Object.assign({}, config);
|
|
2715
|
+
rawName = rawName.replace(/\.\*/g, "");
|
|
2716
|
+
this.negated = false;
|
|
2717
|
+
this.names = removeBrackets(rawName).split(",").map((v) => {
|
|
2718
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
2719
|
+
if (name.startsWith("no-")) {
|
|
2720
|
+
this.negated = true;
|
|
2721
|
+
name = name.replace(/^no-/, "");
|
|
2722
|
+
}
|
|
2723
|
+
return camelcaseOptionName(name);
|
|
2724
|
+
}).sort((a, b) => a.length > b.length ? 1 : -1);
|
|
2725
|
+
this.name = this.names[this.names.length - 1];
|
|
2726
|
+
if (this.negated && this.config.default == null) {
|
|
2727
|
+
this.config.default = true;
|
|
2728
|
+
}
|
|
2729
|
+
if (rawName.includes("<")) {
|
|
2730
|
+
this.required = true;
|
|
2731
|
+
} else if (rawName.includes("[")) {
|
|
2732
|
+
this.required = false;
|
|
2733
|
+
} else {
|
|
2734
|
+
this.isBoolean = true;
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
var processArgs = process.argv;
|
|
2739
|
+
var platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
2740
|
+
|
|
2741
|
+
class Command {
|
|
2742
|
+
constructor(rawName, description, config = {}, cli) {
|
|
2743
|
+
this.rawName = rawName;
|
|
2744
|
+
this.description = description;
|
|
2745
|
+
this.config = config;
|
|
2746
|
+
this.cli = cli;
|
|
2747
|
+
this.options = [];
|
|
2748
|
+
this.aliasNames = [];
|
|
2749
|
+
this.name = removeBrackets(rawName);
|
|
2750
|
+
this.args = findAllBrackets(rawName);
|
|
2751
|
+
this.examples = [];
|
|
2752
|
+
}
|
|
2753
|
+
usage(text) {
|
|
2754
|
+
this.usageText = text;
|
|
2755
|
+
return this;
|
|
2756
|
+
}
|
|
2757
|
+
allowUnknownOptions() {
|
|
2758
|
+
this.config.allowUnknownOptions = true;
|
|
2759
|
+
return this;
|
|
2760
|
+
}
|
|
2761
|
+
ignoreOptionDefaultValue() {
|
|
2762
|
+
this.config.ignoreOptionDefaultValue = true;
|
|
2763
|
+
return this;
|
|
2764
|
+
}
|
|
2765
|
+
version(version, customFlags = "-v, --version") {
|
|
2766
|
+
this.versionNumber = version;
|
|
2767
|
+
this.option(customFlags, "Display version number");
|
|
2768
|
+
return this;
|
|
2769
|
+
}
|
|
2770
|
+
example(example) {
|
|
2771
|
+
this.examples.push(example);
|
|
2772
|
+
return this;
|
|
2773
|
+
}
|
|
2774
|
+
option(rawName, description, config) {
|
|
2775
|
+
const option = new Option(rawName, description, config);
|
|
2776
|
+
this.options.push(option);
|
|
2777
|
+
return this;
|
|
2778
|
+
}
|
|
2779
|
+
alias(name) {
|
|
2780
|
+
this.aliasNames.push(name);
|
|
2781
|
+
return this;
|
|
2782
|
+
}
|
|
2783
|
+
action(callback) {
|
|
2784
|
+
this.commandAction = callback;
|
|
2785
|
+
return this;
|
|
2786
|
+
}
|
|
2787
|
+
isMatched(name) {
|
|
2788
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
2789
|
+
}
|
|
2790
|
+
get isDefaultCommand() {
|
|
2791
|
+
return this.name === "" || this.aliasNames.includes("!");
|
|
2792
|
+
}
|
|
2793
|
+
get isGlobalCommand() {
|
|
2794
|
+
return this instanceof GlobalCommand;
|
|
2795
|
+
}
|
|
2796
|
+
hasOption(name) {
|
|
2797
|
+
name = name.split(".")[0];
|
|
2798
|
+
return this.options.find((option) => {
|
|
2799
|
+
return option.names.includes(name);
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
outputHelp() {
|
|
2803
|
+
const { name, commands } = this.cli;
|
|
2804
|
+
const {
|
|
2805
|
+
versionNumber,
|
|
2806
|
+
options: globalOptions,
|
|
2807
|
+
helpCallback
|
|
2808
|
+
} = this.cli.globalCommand;
|
|
2809
|
+
let sections = [
|
|
2810
|
+
{
|
|
2811
|
+
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
2812
|
+
}
|
|
2813
|
+
];
|
|
2814
|
+
sections.push({
|
|
2815
|
+
title: "Usage",
|
|
2816
|
+
body: ` \$ ${name} ${this.usageText || this.rawName}`
|
|
2817
|
+
});
|
|
2818
|
+
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
2819
|
+
if (showCommands) {
|
|
2820
|
+
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
2821
|
+
sections.push({
|
|
2822
|
+
title: "Commands",
|
|
2823
|
+
body: commands.map((command) => {
|
|
2824
|
+
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
2825
|
+
}).join("\n")
|
|
2826
|
+
});
|
|
2827
|
+
sections.push({
|
|
2828
|
+
title: `For more info, run any command with the \`--help\` flag`,
|
|
2829
|
+
body: commands.map((command) => ` \$ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
|
|
2833
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) {
|
|
2834
|
+
options = options.filter((option) => option.name !== "version");
|
|
2835
|
+
}
|
|
2836
|
+
if (options.length > 0) {
|
|
2837
|
+
const longestOptionName = findLongest(options.map((option) => option.rawName));
|
|
2838
|
+
sections.push({
|
|
2839
|
+
title: "Options",
|
|
2840
|
+
body: options.map((option) => {
|
|
2841
|
+
return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === undefined ? "" : `(default: ${option.config.default})`}`;
|
|
2842
|
+
}).join("\n")
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
if (this.examples.length > 0) {
|
|
2846
|
+
sections.push({
|
|
2847
|
+
title: "Examples",
|
|
2848
|
+
body: this.examples.map((example) => {
|
|
2849
|
+
if (typeof example === "function") {
|
|
2850
|
+
return example(name);
|
|
2851
|
+
}
|
|
2852
|
+
return example;
|
|
2853
|
+
}).join("\n")
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
if (helpCallback) {
|
|
2857
|
+
sections = helpCallback(sections) || sections;
|
|
2858
|
+
}
|
|
2859
|
+
console.log(sections.map((section) => {
|
|
2860
|
+
return section.title ? `${section.title}:
|
|
2861
|
+
${section.body}` : section.body;
|
|
2862
|
+
}).join("\n\n"));
|
|
2863
|
+
}
|
|
2864
|
+
outputVersion() {
|
|
2865
|
+
const { name } = this.cli;
|
|
2866
|
+
const { versionNumber } = this.cli.globalCommand;
|
|
2867
|
+
if (versionNumber) {
|
|
2868
|
+
console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
checkRequiredArgs() {
|
|
2872
|
+
const minimalArgsCount = this.args.filter((arg) => arg.required).length;
|
|
2873
|
+
if (this.cli.args.length < minimalArgsCount) {
|
|
2874
|
+
throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
checkUnknownOptions() {
|
|
2878
|
+
const { options, globalCommand } = this.cli;
|
|
2879
|
+
if (!this.config.allowUnknownOptions) {
|
|
2880
|
+
for (const name of Object.keys(options)) {
|
|
2881
|
+
if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
|
|
2882
|
+
throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
checkOptionValue() {
|
|
2888
|
+
const { options: parsedOptions, globalCommand } = this.cli;
|
|
2889
|
+
const options = [...globalCommand.options, ...this.options];
|
|
2890
|
+
for (const option of options) {
|
|
2891
|
+
const value = parsedOptions[option.name.split(".")[0]];
|
|
2892
|
+
if (option.required) {
|
|
2893
|
+
const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
|
|
2894
|
+
if (value === true || value === false && !hasNegated) {
|
|
2895
|
+
throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
class GlobalCommand extends Command {
|
|
2903
|
+
constructor(cli) {
|
|
2904
|
+
super("@@global@@", "", {}, cli);
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
var __assign = Object.assign;
|
|
2908
|
+
|
|
2909
|
+
class CAC extends EventEmitter {
|
|
2910
|
+
constructor(name = "") {
|
|
2911
|
+
super();
|
|
2912
|
+
this.name = name;
|
|
2913
|
+
this.commands = [];
|
|
2914
|
+
this.rawArgs = [];
|
|
2915
|
+
this.args = [];
|
|
2916
|
+
this.options = {};
|
|
2917
|
+
this.globalCommand = new GlobalCommand(this);
|
|
2918
|
+
this.globalCommand.usage("<command> [options]");
|
|
2919
|
+
}
|
|
2920
|
+
usage(text) {
|
|
2921
|
+
this.globalCommand.usage(text);
|
|
2922
|
+
return this;
|
|
2923
|
+
}
|
|
2924
|
+
command(rawName, description, config) {
|
|
2925
|
+
const command = new Command(rawName, description || "", config, this);
|
|
2926
|
+
command.globalCommand = this.globalCommand;
|
|
2927
|
+
this.commands.push(command);
|
|
2928
|
+
return command;
|
|
2929
|
+
}
|
|
2930
|
+
option(rawName, description, config) {
|
|
2931
|
+
this.globalCommand.option(rawName, description, config);
|
|
2932
|
+
return this;
|
|
2933
|
+
}
|
|
2934
|
+
help(callback) {
|
|
2935
|
+
this.globalCommand.option("-h, --help", "Display this message");
|
|
2936
|
+
this.globalCommand.helpCallback = callback;
|
|
2937
|
+
this.showHelpOnExit = true;
|
|
2938
|
+
return this;
|
|
2939
|
+
}
|
|
2940
|
+
version(version, customFlags = "-v, --version") {
|
|
2941
|
+
this.globalCommand.version(version, customFlags);
|
|
2942
|
+
this.showVersionOnExit = true;
|
|
2943
|
+
return this;
|
|
2944
|
+
}
|
|
2945
|
+
example(example) {
|
|
2946
|
+
this.globalCommand.example(example);
|
|
2947
|
+
return this;
|
|
2948
|
+
}
|
|
2949
|
+
outputHelp() {
|
|
2950
|
+
if (this.matchedCommand) {
|
|
2951
|
+
this.matchedCommand.outputHelp();
|
|
2952
|
+
} else {
|
|
2953
|
+
this.globalCommand.outputHelp();
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
outputVersion() {
|
|
2957
|
+
this.globalCommand.outputVersion();
|
|
2958
|
+
}
|
|
2959
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
2960
|
+
this.args = args;
|
|
2961
|
+
this.options = options;
|
|
2962
|
+
if (matchedCommand) {
|
|
2963
|
+
this.matchedCommand = matchedCommand;
|
|
2964
|
+
}
|
|
2965
|
+
if (matchedCommandName) {
|
|
2966
|
+
this.matchedCommandName = matchedCommandName;
|
|
2967
|
+
}
|
|
2968
|
+
return this;
|
|
2969
|
+
}
|
|
2970
|
+
unsetMatchedCommand() {
|
|
2971
|
+
this.matchedCommand = undefined;
|
|
2972
|
+
this.matchedCommandName = undefined;
|
|
2973
|
+
}
|
|
2974
|
+
parse(argv = processArgs, {
|
|
2975
|
+
run = true
|
|
2976
|
+
} = {}) {
|
|
2977
|
+
this.rawArgs = argv;
|
|
2978
|
+
if (!this.name) {
|
|
2979
|
+
this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
2980
|
+
}
|
|
2981
|
+
let shouldParse = true;
|
|
2982
|
+
for (const command of this.commands) {
|
|
2983
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
2984
|
+
const commandName = parsed.args[0];
|
|
2985
|
+
if (command.isMatched(commandName)) {
|
|
2986
|
+
shouldParse = false;
|
|
2987
|
+
const parsedInfo = __assign(__assign({}, parsed), {
|
|
2988
|
+
args: parsed.args.slice(1)
|
|
2989
|
+
});
|
|
2990
|
+
this.setParsedInfo(parsedInfo, command, commandName);
|
|
2991
|
+
this.emit(`command:${commandName}`, command);
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
if (shouldParse) {
|
|
2995
|
+
for (const command of this.commands) {
|
|
2996
|
+
if (command.name === "") {
|
|
2997
|
+
shouldParse = false;
|
|
2998
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
2999
|
+
this.setParsedInfo(parsed, command);
|
|
3000
|
+
this.emit(`command:!`, command);
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
if (shouldParse) {
|
|
3005
|
+
const parsed = this.mri(argv.slice(2));
|
|
3006
|
+
this.setParsedInfo(parsed);
|
|
3007
|
+
}
|
|
3008
|
+
if (this.options.help && this.showHelpOnExit) {
|
|
3009
|
+
this.outputHelp();
|
|
3010
|
+
run = false;
|
|
3011
|
+
this.unsetMatchedCommand();
|
|
3012
|
+
}
|
|
3013
|
+
if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
|
|
3014
|
+
this.outputVersion();
|
|
3015
|
+
run = false;
|
|
3016
|
+
this.unsetMatchedCommand();
|
|
3017
|
+
}
|
|
3018
|
+
const parsedArgv = { args: this.args, options: this.options };
|
|
3019
|
+
if (run) {
|
|
3020
|
+
this.runMatchedCommand();
|
|
3021
|
+
}
|
|
3022
|
+
if (!this.matchedCommand && this.args[0]) {
|
|
3023
|
+
this.emit("command:*");
|
|
3024
|
+
}
|
|
3025
|
+
return parsedArgv;
|
|
3026
|
+
}
|
|
3027
|
+
mri(argv, command) {
|
|
3028
|
+
const cliOptions = [
|
|
3029
|
+
...this.globalCommand.options,
|
|
3030
|
+
...command ? command.options : []
|
|
3031
|
+
];
|
|
3032
|
+
const mriOptions = getMriOptions(cliOptions);
|
|
3033
|
+
let argsAfterDoubleDashes = [];
|
|
3034
|
+
const doubleDashesIndex = argv.indexOf("--");
|
|
3035
|
+
if (doubleDashesIndex > -1) {
|
|
3036
|
+
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
3037
|
+
argv = argv.slice(0, doubleDashesIndex);
|
|
3038
|
+
}
|
|
3039
|
+
let parsed = mri2(argv, mriOptions);
|
|
3040
|
+
parsed = Object.keys(parsed).reduce((res, name) => {
|
|
3041
|
+
return __assign(__assign({}, res), {
|
|
3042
|
+
[camelcaseOptionName(name)]: parsed[name]
|
|
3043
|
+
});
|
|
3044
|
+
}, { _: [] });
|
|
3045
|
+
const args = parsed._;
|
|
3046
|
+
const options = {
|
|
3047
|
+
"--": argsAfterDoubleDashes
|
|
3048
|
+
};
|
|
3049
|
+
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
3050
|
+
let transforms = Object.create(null);
|
|
3051
|
+
for (const cliOption of cliOptions) {
|
|
3052
|
+
if (!ignoreDefault && cliOption.config.default !== undefined) {
|
|
3053
|
+
for (const name of cliOption.names) {
|
|
3054
|
+
options[name] = cliOption.config.default;
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
if (Array.isArray(cliOption.config.type)) {
|
|
3058
|
+
if (transforms[cliOption.name] === undefined) {
|
|
3059
|
+
transforms[cliOption.name] = Object.create(null);
|
|
3060
|
+
transforms[cliOption.name]["shouldTransform"] = true;
|
|
3061
|
+
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
for (const key of Object.keys(parsed)) {
|
|
3066
|
+
if (key !== "_") {
|
|
3067
|
+
const keys = key.split(".");
|
|
3068
|
+
setDotProp(options, keys, parsed[key]);
|
|
3069
|
+
setByType(options, transforms);
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
return {
|
|
3073
|
+
args,
|
|
3074
|
+
options
|
|
3075
|
+
};
|
|
3076
|
+
}
|
|
3077
|
+
runMatchedCommand() {
|
|
3078
|
+
const { args, options, matchedCommand: command } = this;
|
|
3079
|
+
if (!command || !command.commandAction)
|
|
3080
|
+
return;
|
|
3081
|
+
command.checkUnknownOptions();
|
|
3082
|
+
command.checkOptionValue();
|
|
3083
|
+
command.checkRequiredArgs();
|
|
3084
|
+
const actionArgs = [];
|
|
3085
|
+
command.args.forEach((arg, index) => {
|
|
3086
|
+
if (arg.variadic) {
|
|
3087
|
+
actionArgs.push(args.slice(index));
|
|
3088
|
+
} else {
|
|
3089
|
+
actionArgs.push(args[index]);
|
|
3090
|
+
}
|
|
3091
|
+
});
|
|
3092
|
+
actionArgs.push(options);
|
|
3093
|
+
return command.commandAction.apply(this, actionArgs);
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
var cac = (name = "") => new CAC(name);
|
|
3097
|
+
var dist_default = cac;
|
|
3098
|
+
|
|
3099
|
+
// src/commands/gen/index.ts
|
|
3100
|
+
var import_fs_extra2 = __toESM(require_lib(), 1);
|
|
3101
|
+
|
|
3102
|
+
// src/commands/gen/utils.ts
|
|
3103
|
+
var import_fs_extra = __toESM(require_lib(), 1);
|
|
3104
|
+
import path from "path";
|
|
3105
|
+
var splitPath = (path2) => {
|
|
3106
|
+
return path2.split("/").filter(Boolean);
|
|
3107
|
+
};
|
|
3108
|
+
var capitalizeFirstLetter = (str) => {
|
|
3109
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3110
|
+
};
|
|
3111
|
+
var replaceAndCopyFile = async (sourceFilePath, targetFilePath, replacements) => {
|
|
3112
|
+
try {
|
|
3113
|
+
let result = await import_fs_extra.default.readFile(sourceFilePath, "utf8");
|
|
3114
|
+
for (const [searchValue, newValue] of replacements) {
|
|
3115
|
+
result = result.replace(searchValue, newValue);
|
|
3116
|
+
}
|
|
3117
|
+
const filePathToWrite = targetFilePath || sourceFilePath;
|
|
3118
|
+
const dirPath = path.dirname(filePathToWrite);
|
|
3119
|
+
await import_fs_extra.default.ensureDir(dirPath);
|
|
3120
|
+
await import_fs_extra.default.writeFile(filePathToWrite, result, "utf8");
|
|
3121
|
+
} catch (err) {
|
|
3122
|
+
console.error("\u64CD\u4F5C\u6587\u4EF6\u5931\u8D25:", err);
|
|
3123
|
+
}
|
|
3124
|
+
};
|
|
3125
|
+
var addRoute = async (routesFilePath, newName, newPath, newComponent) => {
|
|
3126
|
+
try {
|
|
3127
|
+
const routesContent = await import_fs_extra.default.readFile(routesFilePath, "utf-8");
|
|
3128
|
+
const routes = new Function(routesContent.replace("export default", "return"))();
|
|
3129
|
+
const newPage = {
|
|
3130
|
+
name: newName,
|
|
3131
|
+
path: newPath,
|
|
3132
|
+
component: newComponent,
|
|
3133
|
+
wrappers: ["@/wrappers/login"]
|
|
3134
|
+
};
|
|
3135
|
+
routes.splice(routes.length - 1, 0, newPage);
|
|
3136
|
+
const updatedRoutesContent = `export default ${JSON.stringify(routes, null, 1)}\n`;
|
|
3137
|
+
await import_fs_extra.default.writeFile(routesFilePath, updatedRoutesContent, "utf-8");
|
|
3138
|
+
} catch (error) {
|
|
3139
|
+
console.error("\u6DFB\u52A0\u9875\u9762\u5931\u8D25\uFF1A", error);
|
|
3140
|
+
}
|
|
3141
|
+
};
|
|
3142
|
+
var getTsType = (type) => {
|
|
3143
|
+
const tsTypeMap = new Map;
|
|
3144
|
+
tsTypeMap.set(["int", "tinyint", "smallint", "mediumint", "bigint", "float", "double", "decimal"], "number");
|
|
3145
|
+
tsTypeMap.set(["char", "varchar", "binary", "varbinary", "tinyblob", "blob", "mediumblob", "longblob", "tinytext", "text", "mediumtext", "longtext", "enum", "set"], "string");
|
|
3146
|
+
tsTypeMap.set(["boolean"], "boolean");
|
|
3147
|
+
tsTypeMap.set(["date", "datetime", "timestamp", "time", "year"], "Date");
|
|
3148
|
+
for (const [keys, value] of tsTypeMap.entries()) {
|
|
3149
|
+
if (keys.includes(type)) {
|
|
3150
|
+
return value;
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
throw new Error(`\u9519\u8BEF\u7684\u6570\u636E\u5E93\u5B57\u6BB5\u7C7B\u578B: ${type}`);
|
|
3154
|
+
};
|
|
3155
|
+
var parseColumns = (input) => {
|
|
3156
|
+
return input.split(",").map((column) => {
|
|
3157
|
+
const [nameAndType, defaultValue] = column.split("=");
|
|
3158
|
+
const [name, type] = nameAndType.split(":");
|
|
3159
|
+
return {
|
|
3160
|
+
name,
|
|
3161
|
+
type,
|
|
3162
|
+
tsType: getTsType(type),
|
|
3163
|
+
...defaultValue ? { default: defaultValue } : { nullable: true }
|
|
3164
|
+
};
|
|
3165
|
+
});
|
|
3166
|
+
};
|
|
3167
|
+
var generateEntityClass = (columns) => {
|
|
3168
|
+
return columns.map((column) => {
|
|
3169
|
+
const nullable = column.nullable ? ", nullable: true" : "";
|
|
3170
|
+
const defaultVal = column.default !== undefined ? `, default: ${column.default}` : "";
|
|
3171
|
+
return ` @Column({ type: '${column.type}'${nullable}${defaultVal} })
|
|
3172
|
+
${column.name}${column.nullable ? "?" : "!"}: ${column.tsType}`;
|
|
3173
|
+
}).join("\n\n").trimStart();
|
|
3174
|
+
};
|
|
3175
|
+
var generateFormConfig = (columns) => {
|
|
3176
|
+
return columns.map((column) => {
|
|
3177
|
+
const title = column.name.charAt(0).toUpperCase() + column.name.slice(1);
|
|
3178
|
+
const validator = column.nullable ? "[]" : `['require']`;
|
|
3179
|
+
const hideInSearch = column.tsType === "boolean" ? "true" : "false";
|
|
3180
|
+
return `{
|
|
3181
|
+
title: '${title}',
|
|
3182
|
+
dataIndex: '${column.name}',
|
|
3183
|
+
ellipsis: true,
|
|
3184
|
+
${validator.length ? `validator: ${validator},` : ""}
|
|
3185
|
+
hideInSearch: ${hideInSearch}
|
|
3186
|
+
}`;
|
|
3187
|
+
}).join(",\n");
|
|
3188
|
+
};
|
|
3189
|
+
|
|
3190
|
+
// src/commands/gen/index.ts
|
|
3191
|
+
var __dirname = "/Users/wangzhenyu/Code/newWork/libs/cli/src/commands/gen";
|
|
3192
|
+
var gen_default = (cli) => {
|
|
3193
|
+
cli.command("g <type> <p> <cnName> <column>", "\u751F\u6210\u4EE3\u7801\u6587\u4EF6\uFF0C\u4F7F\u7528\u65B9\u5F0F\uFF1Ami g 3 /user User name:varchar,age:tinyint,isMan:boolean=1").action(async (type, p, cnName, column) => {
|
|
3194
|
+
const paths = splitPath(p);
|
|
3195
|
+
const columns = parseColumns(column);
|
|
3196
|
+
const name = paths[paths.length - 1];
|
|
3197
|
+
const modelName = capitalizeFirstLetter(name);
|
|
3198
|
+
const pathModelName = paths.slice(0, -1).join("/") + (paths.slice(0, -1) ? "/" : "") + modelName;
|
|
3199
|
+
const projectPath = process.cwd();
|
|
3200
|
+
const templatesPath = `${__dirname}/templates`;
|
|
3201
|
+
if (parseInt(type) >= 1) {
|
|
3202
|
+
const modelPath = `${projectPath}/src/apis/entities/${pathModelName}.ts`;
|
|
3203
|
+
if (!import_fs_extra2.existsSync(modelPath)) {
|
|
3204
|
+
const modelTempPath = templatesPath + "/model.temp";
|
|
3205
|
+
const modelIndexPath = `${projectPath}/src/apis/entities/index.ts`;
|
|
3206
|
+
const content = generateEntityClass(columns);
|
|
3207
|
+
await replaceAndCopyFile(modelTempPath, modelPath, [
|
|
3208
|
+
[/\[modelName]/g, modelName],
|
|
3209
|
+
[/\[content]/, content]
|
|
3210
|
+
]);
|
|
3211
|
+
await replaceAndCopyFile(modelIndexPath, null, [
|
|
3212
|
+
[/(?:\r?\n)+$/, `\r\nexport * from './${pathModelName}'\r\n`]
|
|
3213
|
+
]);
|
|
3214
|
+
console.log(`${modelName}: Model \u521B\u5EFA\u6210\u529F`);
|
|
3215
|
+
} else {
|
|
3216
|
+
console.log(`${modelName} Model \u5B58\u5728\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
if (parseInt(type) >= 2) {
|
|
3220
|
+
const apiPath = `${projectPath}/src/apis/routes/${paths.join("/")}/index.ts`;
|
|
3221
|
+
if (!import_fs_extra2.existsSync(apiPath)) {
|
|
3222
|
+
const apiTempPath = templatesPath + "/api.temp";
|
|
3223
|
+
const apiIndexPath = `${projectPath}/src/apis/index.ts`;
|
|
3224
|
+
await replaceAndCopyFile(apiTempPath, apiPath, [
|
|
3225
|
+
[/\[cnName]/g, cnName],
|
|
3226
|
+
[/\[modelName]/g, modelName],
|
|
3227
|
+
[/\[pathModelName]/g, pathModelName]
|
|
3228
|
+
]);
|
|
3229
|
+
await replaceAndCopyFile(apiIndexPath, null, [
|
|
3230
|
+
[/(?:\r?\n)+$/, `\r\nexport * as ${name} from './routes/${paths.join("/")}'\r\n`]
|
|
3231
|
+
]);
|
|
3232
|
+
console.log(`${modelName}: Api \u521B\u5EFA\u6210\u529F`);
|
|
3233
|
+
} else {
|
|
3234
|
+
console.log(`${modelName} Api \u5B58\u5728\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
if (parseInt(type) >= 3) {
|
|
3238
|
+
const pagePath = `${projectPath}/src/pages/${pathModelName}/index.tsx`;
|
|
3239
|
+
if (!import_fs_extra2.existsSync(pagePath)) {
|
|
3240
|
+
const pageTempPath = templatesPath + "/page.temp";
|
|
3241
|
+
const pageRoutesPath = `${projectPath}/config/routes.ts`;
|
|
3242
|
+
const content = generateFormConfig(columns);
|
|
3243
|
+
await replaceAndCopyFile(pageTempPath, pagePath, [
|
|
3244
|
+
[/\[name]/g, name],
|
|
3245
|
+
[/\[content]/, content]
|
|
3246
|
+
]);
|
|
3247
|
+
await addRoute(pageRoutesPath, cnName, `/${paths.join("/")}`, `./${pathModelName}`);
|
|
3248
|
+
console.log(`${modelName}: Page \u521B\u5EFA\u6210\u529F`);
|
|
3249
|
+
} else {
|
|
3250
|
+
console.log(`${modelName} Page \u5B58\u5728\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
});
|
|
3254
|
+
};
|
|
3255
|
+
|
|
3256
|
+
// src/commands/merge/script.ts
|
|
3257
|
+
import { exec } from "child_process";
|
|
3258
|
+
async function getLatestCommitMsg() {
|
|
3259
|
+
return execGitCommand(`git log -1 --pretty=%B`);
|
|
3260
|
+
}
|
|
3261
|
+
function getContinuousCommitCount() {
|
|
3262
|
+
return new Promise((resolve, reject) => {
|
|
3263
|
+
exec(`git log --oneline --format=%s`, (err, stdout) => {
|
|
3264
|
+
if (err) {
|
|
3265
|
+
reject(err);
|
|
3266
|
+
return;
|
|
3267
|
+
}
|
|
3268
|
+
const messages = stdout.split("\n");
|
|
3269
|
+
const msg = messages[0];
|
|
3270
|
+
let count = 0;
|
|
3271
|
+
for (const item of messages) {
|
|
3272
|
+
if (item !== msg) {
|
|
3273
|
+
break;
|
|
3274
|
+
}
|
|
3275
|
+
count++;
|
|
3276
|
+
}
|
|
3277
|
+
resolve(count);
|
|
3278
|
+
});
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
function execGitCommand(command) {
|
|
3282
|
+
return new Promise((resolve, reject) => {
|
|
3283
|
+
exec(command, (err, stdout) => {
|
|
3284
|
+
if (err) {
|
|
3285
|
+
reject(err);
|
|
3286
|
+
return;
|
|
3287
|
+
}
|
|
3288
|
+
resolve(stdout);
|
|
3289
|
+
});
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
var script_default = async (options) => {
|
|
3293
|
+
const hasChange = await execGitCommand("git status -s");
|
|
3294
|
+
if (hasChange) {
|
|
3295
|
+
if (options?.commit) {
|
|
3296
|
+
console.log("commit success", await execGitCommand(`git commit -a -m "${(await getLatestCommitMsg()).trim()}"`));
|
|
3297
|
+
} else {
|
|
3298
|
+
console.log("stash success", await execGitCommand("git stash"));
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
const count = options?.count || await getContinuousCommitCount();
|
|
3302
|
+
const command = `GIT_EDITOR=true GIT_SEQUENCE_EDITOR="sed -i -e '2,\\\$s/^pick/squash/'" git rebase -i HEAD~${count}`;
|
|
3303
|
+
console.log("rebase success", await execGitCommand(command));
|
|
3304
|
+
if (options?.push) {
|
|
3305
|
+
console.log("push success", await execGitCommand("git push origin HEAD --force"));
|
|
3306
|
+
}
|
|
3307
|
+
if (hasChange && !options?.commit) {
|
|
3308
|
+
await execGitCommand("git stash pop");
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
|
|
3312
|
+
// src/commands/merge/index.ts
|
|
3313
|
+
var merge_default = (cli) => {
|
|
3314
|
+
cli.command("m", "\u5408\u5E76 commit").option("--count [number]", "\u5408\u5E76\u51E0\u4E2Acommit\uFF0C\u4E0D\u586B\u4F1A\u81EA\u52A8\u8BA1\u7B97\u4E0E\u6700\u65B0commit\u76F8\u540C\u540D\u79F0\u7684\u6570\u91CF").option("--commit [boolean]", "\u662F\u5426\u5728\u5408\u5E76\u524D\u63D0\u4EA4\u4EE3\u7801").option("--push [boolean]", "\u662F\u5426\u5728\u5408\u5E76\u540E\u63A8\u9001\u4EE3\u7801").action(script_default);
|
|
3315
|
+
};
|
|
3316
|
+
|
|
3317
|
+
// src/commands/summary/script.ts
|
|
3318
|
+
import fs from "fs";
|
|
3319
|
+
import path2 from "path";
|
|
3320
|
+
var __filename = "/Users/wangzhenyu/Code/newWork/libs/cli/src/commands/summary/script.ts";
|
|
3321
|
+
var defaultConfig = {
|
|
3322
|
+
ignoreDirs: ["node_modules", ".git"],
|
|
3323
|
+
ignoreFiles: [],
|
|
3324
|
+
allowedExtensions: [".ts", ".js"],
|
|
3325
|
+
includeHiddenDirs: false
|
|
3326
|
+
};
|
|
3327
|
+
var getAllFiles = (dirPath, config = defaultConfig, filesArray = []) => {
|
|
3328
|
+
const files = fs.readdirSync(dirPath);
|
|
3329
|
+
files.forEach((file) => {
|
|
3330
|
+
const filePath = path2.join(dirPath, file);
|
|
3331
|
+
const stat = fs.statSync(filePath);
|
|
3332
|
+
if (stat.isDirectory()) {
|
|
3333
|
+
const isHidden = path2.basename(filePath).startsWith(".");
|
|
3334
|
+
if (!isHidden || config.includeHiddenDirs) {
|
|
3335
|
+
if (!config.ignoreDirs?.some((dir) => filePath.includes(dir))) {
|
|
3336
|
+
getAllFiles(filePath, config, filesArray);
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
} else if (config.allowedExtensions?.includes(path2.extname(file)) && !config.ignoreFiles?.some((ignoreFile) => filePath.includes(ignoreFile))) {
|
|
3340
|
+
filesArray.push(filePath);
|
|
3341
|
+
}
|
|
3342
|
+
});
|
|
3343
|
+
return filesArray;
|
|
3344
|
+
};
|
|
3345
|
+
var mergeCodeFiles = (dirPath, config = defaultConfig, maxSize) => {
|
|
3346
|
+
let mergedContent = "";
|
|
3347
|
+
const files = getAllFiles(dirPath, config);
|
|
3348
|
+
files.forEach((filePath) => {
|
|
3349
|
+
try {
|
|
3350
|
+
const fileContent = fs.readFileSync(filePath, "utf-8");
|
|
3351
|
+
if (fileContent.length <= maxSize) {
|
|
3352
|
+
mergedContent += `### ${filePath.replace(dirPath, "")}\n\`\`\`${path2.extname(filePath).slice(1)}\n${fileContent}\n\`\`\`\n\n`;
|
|
3353
|
+
}
|
|
3354
|
+
} catch (error) {
|
|
3355
|
+
console.error(`Error reading file ${filePath}:`, error);
|
|
3356
|
+
}
|
|
3357
|
+
});
|
|
3358
|
+
return mergedContent;
|
|
3359
|
+
};
|
|
3360
|
+
var saveAsMarkdown = (content, outputFile) => {
|
|
3361
|
+
try {
|
|
3362
|
+
fs.writeFileSync(outputFile, content, "utf-8");
|
|
3363
|
+
console.log(`Merged code saved as: ${outputFile}`);
|
|
3364
|
+
} catch (error) {
|
|
3365
|
+
console.error(`Error writing file ${outputFile}:`, error);
|
|
3366
|
+
}
|
|
3367
|
+
};
|
|
3368
|
+
var script_default2 = async () => {
|
|
3369
|
+
const projectDir = process.cwd();
|
|
3370
|
+
const outputMarkdownFile = path2.resolve("./summary.md");
|
|
3371
|
+
const currentScriptPath = path2.resolve(__filename);
|
|
3372
|
+
const customConfig = {
|
|
3373
|
+
ignoreDirs: ["node_modules", "dist", "linshi", "helper", "projects", "shells"],
|
|
3374
|
+
ignoreFiles: [currentScriptPath],
|
|
3375
|
+
allowedExtensions: [".ts", ".js", ".json"],
|
|
3376
|
+
includeHiddenDirs: false
|
|
3377
|
+
};
|
|
3378
|
+
const mergedContent = mergeCodeFiles(projectDir, customConfig, 3000);
|
|
3379
|
+
saveAsMarkdown(mergedContent, outputMarkdownFile);
|
|
3380
|
+
};
|
|
3381
|
+
|
|
3382
|
+
// src/commands/summary/index.ts
|
|
3383
|
+
var summary_default = (cli) => {
|
|
3384
|
+
cli.command("s", "\u751F\u6210\u9879\u76EE\u7684\u4EE3\u7801\u6458\u8981").action(script_default2);
|
|
3385
|
+
};
|
|
3386
|
+
|
|
3387
|
+
// src/index.ts
|
|
3388
|
+
var cli = dist_default();
|
|
3389
|
+
merge_default(cli);
|
|
3390
|
+
gen_default(cli);
|
|
3391
|
+
summary_default(cli);
|
|
16
3392
|
cli.help();
|
|
17
|
-
cli.version(
|
|
3393
|
+
cli.version("0.0.5");
|
|
18
3394
|
cli.parse();
|