create-react-router 0.0.0-experimental-16086cbff
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/LICENSE.md +23 -0
- package/README.md +7 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +4563 -0
- package/package.json +74 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,4563 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* create-react-router v0.0.0-experimental-16086cbff
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Remix Software Inc.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
* @license MIT
|
|
11
|
+
*/
|
|
12
|
+
"use strict";
|
|
13
|
+
var __create = Object.create;
|
|
14
|
+
var __defProp = Object.defineProperty;
|
|
15
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
16
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
17
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
18
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
19
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
20
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
+
mod
|
|
37
|
+
));
|
|
38
|
+
|
|
39
|
+
// ../../node_modules/.pnpm/universalify@2.0.0/node_modules/universalify/index.js
|
|
40
|
+
var require_universalify = __commonJS({
|
|
41
|
+
"../../node_modules/.pnpm/universalify@2.0.0/node_modules/universalify/index.js"(exports2) {
|
|
42
|
+
"use strict";
|
|
43
|
+
exports2.fromCallback = function(fn) {
|
|
44
|
+
return Object.defineProperty(function(...args) {
|
|
45
|
+
if (typeof args[args.length - 1] === "function") fn.apply(this, args);
|
|
46
|
+
else {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
fn.call(
|
|
49
|
+
this,
|
|
50
|
+
...args,
|
|
51
|
+
(err, res) => err != null ? reject(err) : resolve(res)
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, "name", { value: fn.name });
|
|
56
|
+
};
|
|
57
|
+
exports2.fromPromise = function(fn) {
|
|
58
|
+
return Object.defineProperty(function(...args) {
|
|
59
|
+
const cb = args[args.length - 1];
|
|
60
|
+
if (typeof cb !== "function") return fn.apply(this, args);
|
|
61
|
+
else fn.apply(this, args.slice(0, -1)).then((r) => cb(null, r), cb);
|
|
62
|
+
}, "name", { value: fn.name });
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
|
|
68
|
+
var require_polyfills = __commonJS({
|
|
69
|
+
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js"(exports2, module2) {
|
|
70
|
+
"use strict";
|
|
71
|
+
var constants = require("constants");
|
|
72
|
+
var origCwd = process.cwd;
|
|
73
|
+
var cwd = null;
|
|
74
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
75
|
+
process.cwd = function() {
|
|
76
|
+
if (!cwd)
|
|
77
|
+
cwd = origCwd.call(process);
|
|
78
|
+
return cwd;
|
|
79
|
+
};
|
|
80
|
+
try {
|
|
81
|
+
process.cwd();
|
|
82
|
+
} catch (er) {
|
|
83
|
+
}
|
|
84
|
+
if (typeof process.chdir === "function") {
|
|
85
|
+
chdir = process.chdir;
|
|
86
|
+
process.chdir = function(d) {
|
|
87
|
+
cwd = null;
|
|
88
|
+
chdir.call(process, d);
|
|
89
|
+
};
|
|
90
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
91
|
+
}
|
|
92
|
+
var chdir;
|
|
93
|
+
module2.exports = patch;
|
|
94
|
+
function patch(fs4) {
|
|
95
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
96
|
+
patchLchmod(fs4);
|
|
97
|
+
}
|
|
98
|
+
if (!fs4.lutimes) {
|
|
99
|
+
patchLutimes(fs4);
|
|
100
|
+
}
|
|
101
|
+
fs4.chown = chownFix(fs4.chown);
|
|
102
|
+
fs4.fchown = chownFix(fs4.fchown);
|
|
103
|
+
fs4.lchown = chownFix(fs4.lchown);
|
|
104
|
+
fs4.chmod = chmodFix(fs4.chmod);
|
|
105
|
+
fs4.fchmod = chmodFix(fs4.fchmod);
|
|
106
|
+
fs4.lchmod = chmodFix(fs4.lchmod);
|
|
107
|
+
fs4.chownSync = chownFixSync(fs4.chownSync);
|
|
108
|
+
fs4.fchownSync = chownFixSync(fs4.fchownSync);
|
|
109
|
+
fs4.lchownSync = chownFixSync(fs4.lchownSync);
|
|
110
|
+
fs4.chmodSync = chmodFixSync(fs4.chmodSync);
|
|
111
|
+
fs4.fchmodSync = chmodFixSync(fs4.fchmodSync);
|
|
112
|
+
fs4.lchmodSync = chmodFixSync(fs4.lchmodSync);
|
|
113
|
+
fs4.stat = statFix(fs4.stat);
|
|
114
|
+
fs4.fstat = statFix(fs4.fstat);
|
|
115
|
+
fs4.lstat = statFix(fs4.lstat);
|
|
116
|
+
fs4.statSync = statFixSync(fs4.statSync);
|
|
117
|
+
fs4.fstatSync = statFixSync(fs4.fstatSync);
|
|
118
|
+
fs4.lstatSync = statFixSync(fs4.lstatSync);
|
|
119
|
+
if (fs4.chmod && !fs4.lchmod) {
|
|
120
|
+
fs4.lchmod = function(path4, mode, cb) {
|
|
121
|
+
if (cb) process.nextTick(cb);
|
|
122
|
+
};
|
|
123
|
+
fs4.lchmodSync = function() {
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (fs4.chown && !fs4.lchown) {
|
|
127
|
+
fs4.lchown = function(path4, uid, gid, cb) {
|
|
128
|
+
if (cb) process.nextTick(cb);
|
|
129
|
+
};
|
|
130
|
+
fs4.lchownSync = function() {
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (platform === "win32") {
|
|
134
|
+
fs4.rename = typeof fs4.rename !== "function" ? fs4.rename : function(fs$rename) {
|
|
135
|
+
function rename(from, to, cb) {
|
|
136
|
+
var start = Date.now();
|
|
137
|
+
var backoff = 0;
|
|
138
|
+
fs$rename(from, to, function CB(er) {
|
|
139
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
140
|
+
setTimeout(function() {
|
|
141
|
+
fs4.stat(to, function(stater, st) {
|
|
142
|
+
if (stater && stater.code === "ENOENT")
|
|
143
|
+
fs$rename(from, to, CB);
|
|
144
|
+
else
|
|
145
|
+
cb(er);
|
|
146
|
+
});
|
|
147
|
+
}, backoff);
|
|
148
|
+
if (backoff < 100)
|
|
149
|
+
backoff += 10;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (cb) cb(er);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
156
|
+
return rename;
|
|
157
|
+
}(fs4.rename);
|
|
158
|
+
}
|
|
159
|
+
fs4.read = typeof fs4.read !== "function" ? fs4.read : function(fs$read) {
|
|
160
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
161
|
+
var callback;
|
|
162
|
+
if (callback_ && typeof callback_ === "function") {
|
|
163
|
+
var eagCounter = 0;
|
|
164
|
+
callback = function(er, _, __) {
|
|
165
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
166
|
+
eagCounter++;
|
|
167
|
+
return fs$read.call(fs4, fd, buffer, offset, length, position, callback);
|
|
168
|
+
}
|
|
169
|
+
callback_.apply(this, arguments);
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return fs$read.call(fs4, fd, buffer, offset, length, position, callback);
|
|
173
|
+
}
|
|
174
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
175
|
+
return read;
|
|
176
|
+
}(fs4.read);
|
|
177
|
+
fs4.readSync = typeof fs4.readSync !== "function" ? fs4.readSync : /* @__PURE__ */ function(fs$readSync) {
|
|
178
|
+
return function(fd, buffer, offset, length, position) {
|
|
179
|
+
var eagCounter = 0;
|
|
180
|
+
while (true) {
|
|
181
|
+
try {
|
|
182
|
+
return fs$readSync.call(fs4, fd, buffer, offset, length, position);
|
|
183
|
+
} catch (er) {
|
|
184
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
185
|
+
eagCounter++;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
throw er;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}(fs4.readSync);
|
|
193
|
+
function patchLchmod(fs5) {
|
|
194
|
+
fs5.lchmod = function(path4, mode, callback) {
|
|
195
|
+
fs5.open(
|
|
196
|
+
path4,
|
|
197
|
+
constants.O_WRONLY | constants.O_SYMLINK,
|
|
198
|
+
mode,
|
|
199
|
+
function(err, fd) {
|
|
200
|
+
if (err) {
|
|
201
|
+
if (callback) callback(err);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
fs5.fchmod(fd, mode, function(err2) {
|
|
205
|
+
fs5.close(fd, function(err22) {
|
|
206
|
+
if (callback) callback(err2 || err22);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
fs5.lchmodSync = function(path4, mode) {
|
|
213
|
+
var fd = fs5.openSync(path4, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
214
|
+
var threw = true;
|
|
215
|
+
var ret;
|
|
216
|
+
try {
|
|
217
|
+
ret = fs5.fchmodSync(fd, mode);
|
|
218
|
+
threw = false;
|
|
219
|
+
} finally {
|
|
220
|
+
if (threw) {
|
|
221
|
+
try {
|
|
222
|
+
fs5.closeSync(fd);
|
|
223
|
+
} catch (er) {
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
fs5.closeSync(fd);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return ret;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function patchLutimes(fs5) {
|
|
233
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs5.futimes) {
|
|
234
|
+
fs5.lutimes = function(path4, at, mt, cb) {
|
|
235
|
+
fs5.open(path4, constants.O_SYMLINK, function(er, fd) {
|
|
236
|
+
if (er) {
|
|
237
|
+
if (cb) cb(er);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
fs5.futimes(fd, at, mt, function(er2) {
|
|
241
|
+
fs5.close(fd, function(er22) {
|
|
242
|
+
if (cb) cb(er2 || er22);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
fs5.lutimesSync = function(path4, at, mt) {
|
|
248
|
+
var fd = fs5.openSync(path4, constants.O_SYMLINK);
|
|
249
|
+
var ret;
|
|
250
|
+
var threw = true;
|
|
251
|
+
try {
|
|
252
|
+
ret = fs5.futimesSync(fd, at, mt);
|
|
253
|
+
threw = false;
|
|
254
|
+
} finally {
|
|
255
|
+
if (threw) {
|
|
256
|
+
try {
|
|
257
|
+
fs5.closeSync(fd);
|
|
258
|
+
} catch (er) {
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
fs5.closeSync(fd);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return ret;
|
|
265
|
+
};
|
|
266
|
+
} else if (fs5.futimes) {
|
|
267
|
+
fs5.lutimes = function(_a, _b, _c, cb) {
|
|
268
|
+
if (cb) process.nextTick(cb);
|
|
269
|
+
};
|
|
270
|
+
fs5.lutimesSync = function() {
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function chmodFix(orig) {
|
|
275
|
+
if (!orig) return orig;
|
|
276
|
+
return function(target, mode, cb) {
|
|
277
|
+
return orig.call(fs4, target, mode, function(er) {
|
|
278
|
+
if (chownErOk(er)) er = null;
|
|
279
|
+
if (cb) cb.apply(this, arguments);
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function chmodFixSync(orig) {
|
|
284
|
+
if (!orig) return orig;
|
|
285
|
+
return function(target, mode) {
|
|
286
|
+
try {
|
|
287
|
+
return orig.call(fs4, target, mode);
|
|
288
|
+
} catch (er) {
|
|
289
|
+
if (!chownErOk(er)) throw er;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function chownFix(orig) {
|
|
294
|
+
if (!orig) return orig;
|
|
295
|
+
return function(target, uid, gid, cb) {
|
|
296
|
+
return orig.call(fs4, target, uid, gid, function(er) {
|
|
297
|
+
if (chownErOk(er)) er = null;
|
|
298
|
+
if (cb) cb.apply(this, arguments);
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function chownFixSync(orig) {
|
|
303
|
+
if (!orig) return orig;
|
|
304
|
+
return function(target, uid, gid) {
|
|
305
|
+
try {
|
|
306
|
+
return orig.call(fs4, target, uid, gid);
|
|
307
|
+
} catch (er) {
|
|
308
|
+
if (!chownErOk(er)) throw er;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function statFix(orig) {
|
|
313
|
+
if (!orig) return orig;
|
|
314
|
+
return function(target, options, cb) {
|
|
315
|
+
if (typeof options === "function") {
|
|
316
|
+
cb = options;
|
|
317
|
+
options = null;
|
|
318
|
+
}
|
|
319
|
+
function callback(er, stats) {
|
|
320
|
+
if (stats) {
|
|
321
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
322
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
323
|
+
}
|
|
324
|
+
if (cb) cb.apply(this, arguments);
|
|
325
|
+
}
|
|
326
|
+
return options ? orig.call(fs4, target, options, callback) : orig.call(fs4, target, callback);
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function statFixSync(orig) {
|
|
330
|
+
if (!orig) return orig;
|
|
331
|
+
return function(target, options) {
|
|
332
|
+
var stats = options ? orig.call(fs4, target, options) : orig.call(fs4, target);
|
|
333
|
+
if (stats) {
|
|
334
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
335
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
336
|
+
}
|
|
337
|
+
return stats;
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function chownErOk(er) {
|
|
341
|
+
if (!er)
|
|
342
|
+
return true;
|
|
343
|
+
if (er.code === "ENOSYS")
|
|
344
|
+
return true;
|
|
345
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
346
|
+
if (nonroot) {
|
|
347
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js
|
|
357
|
+
var require_legacy_streams = __commonJS({
|
|
358
|
+
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
|
|
359
|
+
"use strict";
|
|
360
|
+
var Stream = require("stream").Stream;
|
|
361
|
+
module2.exports = legacy;
|
|
362
|
+
function legacy(fs4) {
|
|
363
|
+
return {
|
|
364
|
+
ReadStream,
|
|
365
|
+
WriteStream
|
|
366
|
+
};
|
|
367
|
+
function ReadStream(path4, options) {
|
|
368
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path4, options);
|
|
369
|
+
Stream.call(this);
|
|
370
|
+
var self = this;
|
|
371
|
+
this.path = path4;
|
|
372
|
+
this.fd = null;
|
|
373
|
+
this.readable = true;
|
|
374
|
+
this.paused = false;
|
|
375
|
+
this.flags = "r";
|
|
376
|
+
this.mode = 438;
|
|
377
|
+
this.bufferSize = 64 * 1024;
|
|
378
|
+
options = options || {};
|
|
379
|
+
var keys = Object.keys(options);
|
|
380
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
381
|
+
var key = keys[index];
|
|
382
|
+
this[key] = options[key];
|
|
383
|
+
}
|
|
384
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
385
|
+
if (this.start !== void 0) {
|
|
386
|
+
if ("number" !== typeof this.start) {
|
|
387
|
+
throw TypeError("start must be a Number");
|
|
388
|
+
}
|
|
389
|
+
if (this.end === void 0) {
|
|
390
|
+
this.end = Infinity;
|
|
391
|
+
} else if ("number" !== typeof this.end) {
|
|
392
|
+
throw TypeError("end must be a Number");
|
|
393
|
+
}
|
|
394
|
+
if (this.start > this.end) {
|
|
395
|
+
throw new Error("start must be <= end");
|
|
396
|
+
}
|
|
397
|
+
this.pos = this.start;
|
|
398
|
+
}
|
|
399
|
+
if (this.fd !== null) {
|
|
400
|
+
process.nextTick(function() {
|
|
401
|
+
self._read();
|
|
402
|
+
});
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
fs4.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
406
|
+
if (err) {
|
|
407
|
+
self.emit("error", err);
|
|
408
|
+
self.readable = false;
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
self.fd = fd;
|
|
412
|
+
self.emit("open", fd);
|
|
413
|
+
self._read();
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function WriteStream(path4, options) {
|
|
417
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path4, options);
|
|
418
|
+
Stream.call(this);
|
|
419
|
+
this.path = path4;
|
|
420
|
+
this.fd = null;
|
|
421
|
+
this.writable = true;
|
|
422
|
+
this.flags = "w";
|
|
423
|
+
this.encoding = "binary";
|
|
424
|
+
this.mode = 438;
|
|
425
|
+
this.bytesWritten = 0;
|
|
426
|
+
options = options || {};
|
|
427
|
+
var keys = Object.keys(options);
|
|
428
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
429
|
+
var key = keys[index];
|
|
430
|
+
this[key] = options[key];
|
|
431
|
+
}
|
|
432
|
+
if (this.start !== void 0) {
|
|
433
|
+
if ("number" !== typeof this.start) {
|
|
434
|
+
throw TypeError("start must be a Number");
|
|
435
|
+
}
|
|
436
|
+
if (this.start < 0) {
|
|
437
|
+
throw new Error("start must be >= zero");
|
|
438
|
+
}
|
|
439
|
+
this.pos = this.start;
|
|
440
|
+
}
|
|
441
|
+
this.busy = false;
|
|
442
|
+
this._queue = [];
|
|
443
|
+
if (this.fd === null) {
|
|
444
|
+
this._open = fs4.open;
|
|
445
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
446
|
+
this.flush();
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js
|
|
454
|
+
var require_clone = __commonJS({
|
|
455
|
+
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js"(exports2, module2) {
|
|
456
|
+
"use strict";
|
|
457
|
+
module2.exports = clone;
|
|
458
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
459
|
+
return obj.__proto__;
|
|
460
|
+
};
|
|
461
|
+
function clone(obj) {
|
|
462
|
+
if (obj === null || typeof obj !== "object")
|
|
463
|
+
return obj;
|
|
464
|
+
if (obj instanceof Object)
|
|
465
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
466
|
+
else
|
|
467
|
+
var copy = /* @__PURE__ */ Object.create(null);
|
|
468
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
469
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
470
|
+
});
|
|
471
|
+
return copy;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
|
|
477
|
+
var require_graceful_fs = __commonJS({
|
|
478
|
+
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
|
|
479
|
+
"use strict";
|
|
480
|
+
var fs4 = require("fs");
|
|
481
|
+
var polyfills = require_polyfills();
|
|
482
|
+
var legacy = require_legacy_streams();
|
|
483
|
+
var clone = require_clone();
|
|
484
|
+
var util = require("util");
|
|
485
|
+
var gracefulQueue;
|
|
486
|
+
var previousSymbol;
|
|
487
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
488
|
+
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
489
|
+
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
490
|
+
} else {
|
|
491
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
492
|
+
previousSymbol = "___graceful-fs.previous";
|
|
493
|
+
}
|
|
494
|
+
function noop() {
|
|
495
|
+
}
|
|
496
|
+
function publishQueue(context, queue2) {
|
|
497
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
498
|
+
get: function() {
|
|
499
|
+
return queue2;
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
var debug2 = noop;
|
|
504
|
+
if (util.debuglog)
|
|
505
|
+
debug2 = util.debuglog("gfs4");
|
|
506
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
507
|
+
debug2 = function() {
|
|
508
|
+
var m = util.format.apply(util, arguments);
|
|
509
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
510
|
+
console.error(m);
|
|
511
|
+
};
|
|
512
|
+
if (!fs4[gracefulQueue]) {
|
|
513
|
+
queue = global[gracefulQueue] || [];
|
|
514
|
+
publishQueue(fs4, queue);
|
|
515
|
+
fs4.close = function(fs$close) {
|
|
516
|
+
function close(fd, cb) {
|
|
517
|
+
return fs$close.call(fs4, fd, function(err) {
|
|
518
|
+
if (!err) {
|
|
519
|
+
resetQueue();
|
|
520
|
+
}
|
|
521
|
+
if (typeof cb === "function")
|
|
522
|
+
cb.apply(this, arguments);
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
Object.defineProperty(close, previousSymbol, {
|
|
526
|
+
value: fs$close
|
|
527
|
+
});
|
|
528
|
+
return close;
|
|
529
|
+
}(fs4.close);
|
|
530
|
+
fs4.closeSync = function(fs$closeSync) {
|
|
531
|
+
function closeSync(fd) {
|
|
532
|
+
fs$closeSync.apply(fs4, arguments);
|
|
533
|
+
resetQueue();
|
|
534
|
+
}
|
|
535
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
536
|
+
value: fs$closeSync
|
|
537
|
+
});
|
|
538
|
+
return closeSync;
|
|
539
|
+
}(fs4.closeSync);
|
|
540
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
541
|
+
process.on("exit", function() {
|
|
542
|
+
debug2(fs4[gracefulQueue]);
|
|
543
|
+
require("assert").equal(fs4[gracefulQueue].length, 0);
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
var queue;
|
|
548
|
+
if (!global[gracefulQueue]) {
|
|
549
|
+
publishQueue(global, fs4[gracefulQueue]);
|
|
550
|
+
}
|
|
551
|
+
module2.exports = patch(clone(fs4));
|
|
552
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs4.__patched) {
|
|
553
|
+
module2.exports = patch(fs4);
|
|
554
|
+
fs4.__patched = true;
|
|
555
|
+
}
|
|
556
|
+
function patch(fs5) {
|
|
557
|
+
polyfills(fs5);
|
|
558
|
+
fs5.gracefulify = patch;
|
|
559
|
+
fs5.createReadStream = createReadStream;
|
|
560
|
+
fs5.createWriteStream = createWriteStream;
|
|
561
|
+
var fs$readFile = fs5.readFile;
|
|
562
|
+
fs5.readFile = readFile;
|
|
563
|
+
function readFile(path4, options, cb) {
|
|
564
|
+
if (typeof options === "function")
|
|
565
|
+
cb = options, options = null;
|
|
566
|
+
return go$readFile(path4, options, cb);
|
|
567
|
+
function go$readFile(path5, options2, cb2, startTime) {
|
|
568
|
+
return fs$readFile(path5, options2, function(err) {
|
|
569
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
570
|
+
enqueue([go$readFile, [path5, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
571
|
+
else {
|
|
572
|
+
if (typeof cb2 === "function")
|
|
573
|
+
cb2.apply(this, arguments);
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
var fs$writeFile = fs5.writeFile;
|
|
579
|
+
fs5.writeFile = writeFile;
|
|
580
|
+
function writeFile(path4, data, options, cb) {
|
|
581
|
+
if (typeof options === "function")
|
|
582
|
+
cb = options, options = null;
|
|
583
|
+
return go$writeFile(path4, data, options, cb);
|
|
584
|
+
function go$writeFile(path5, data2, options2, cb2, startTime) {
|
|
585
|
+
return fs$writeFile(path5, data2, options2, function(err) {
|
|
586
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
587
|
+
enqueue([go$writeFile, [path5, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
588
|
+
else {
|
|
589
|
+
if (typeof cb2 === "function")
|
|
590
|
+
cb2.apply(this, arguments);
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
var fs$appendFile = fs5.appendFile;
|
|
596
|
+
if (fs$appendFile)
|
|
597
|
+
fs5.appendFile = appendFile;
|
|
598
|
+
function appendFile(path4, data, options, cb) {
|
|
599
|
+
if (typeof options === "function")
|
|
600
|
+
cb = options, options = null;
|
|
601
|
+
return go$appendFile(path4, data, options, cb);
|
|
602
|
+
function go$appendFile(path5, data2, options2, cb2, startTime) {
|
|
603
|
+
return fs$appendFile(path5, data2, options2, function(err) {
|
|
604
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
605
|
+
enqueue([go$appendFile, [path5, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
606
|
+
else {
|
|
607
|
+
if (typeof cb2 === "function")
|
|
608
|
+
cb2.apply(this, arguments);
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
var fs$copyFile = fs5.copyFile;
|
|
614
|
+
if (fs$copyFile)
|
|
615
|
+
fs5.copyFile = copyFile;
|
|
616
|
+
function copyFile(src, dest, flags, cb) {
|
|
617
|
+
if (typeof flags === "function") {
|
|
618
|
+
cb = flags;
|
|
619
|
+
flags = 0;
|
|
620
|
+
}
|
|
621
|
+
return go$copyFile(src, dest, flags, cb);
|
|
622
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
623
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
624
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
625
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
626
|
+
else {
|
|
627
|
+
if (typeof cb2 === "function")
|
|
628
|
+
cb2.apply(this, arguments);
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
var fs$readdir = fs5.readdir;
|
|
634
|
+
fs5.readdir = readdir;
|
|
635
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
636
|
+
function readdir(path4, options, cb) {
|
|
637
|
+
if (typeof options === "function")
|
|
638
|
+
cb = options, options = null;
|
|
639
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path5, options2, cb2, startTime) {
|
|
640
|
+
return fs$readdir(path5, fs$readdirCallback(
|
|
641
|
+
path5,
|
|
642
|
+
options2,
|
|
643
|
+
cb2,
|
|
644
|
+
startTime
|
|
645
|
+
));
|
|
646
|
+
} : function go$readdir2(path5, options2, cb2, startTime) {
|
|
647
|
+
return fs$readdir(path5, options2, fs$readdirCallback(
|
|
648
|
+
path5,
|
|
649
|
+
options2,
|
|
650
|
+
cb2,
|
|
651
|
+
startTime
|
|
652
|
+
));
|
|
653
|
+
};
|
|
654
|
+
return go$readdir(path4, options, cb);
|
|
655
|
+
function fs$readdirCallback(path5, options2, cb2, startTime) {
|
|
656
|
+
return function(err, files) {
|
|
657
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
658
|
+
enqueue([
|
|
659
|
+
go$readdir,
|
|
660
|
+
[path5, options2, cb2],
|
|
661
|
+
err,
|
|
662
|
+
startTime || Date.now(),
|
|
663
|
+
Date.now()
|
|
664
|
+
]);
|
|
665
|
+
else {
|
|
666
|
+
if (files && files.sort)
|
|
667
|
+
files.sort();
|
|
668
|
+
if (typeof cb2 === "function")
|
|
669
|
+
cb2.call(this, err, files);
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
675
|
+
var legStreams = legacy(fs5);
|
|
676
|
+
ReadStream = legStreams.ReadStream;
|
|
677
|
+
WriteStream = legStreams.WriteStream;
|
|
678
|
+
}
|
|
679
|
+
var fs$ReadStream = fs5.ReadStream;
|
|
680
|
+
if (fs$ReadStream) {
|
|
681
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
682
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
683
|
+
}
|
|
684
|
+
var fs$WriteStream = fs5.WriteStream;
|
|
685
|
+
if (fs$WriteStream) {
|
|
686
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
687
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
688
|
+
}
|
|
689
|
+
Object.defineProperty(fs5, "ReadStream", {
|
|
690
|
+
get: function() {
|
|
691
|
+
return ReadStream;
|
|
692
|
+
},
|
|
693
|
+
set: function(val) {
|
|
694
|
+
ReadStream = val;
|
|
695
|
+
},
|
|
696
|
+
enumerable: true,
|
|
697
|
+
configurable: true
|
|
698
|
+
});
|
|
699
|
+
Object.defineProperty(fs5, "WriteStream", {
|
|
700
|
+
get: function() {
|
|
701
|
+
return WriteStream;
|
|
702
|
+
},
|
|
703
|
+
set: function(val) {
|
|
704
|
+
WriteStream = val;
|
|
705
|
+
},
|
|
706
|
+
enumerable: true,
|
|
707
|
+
configurable: true
|
|
708
|
+
});
|
|
709
|
+
var FileReadStream = ReadStream;
|
|
710
|
+
Object.defineProperty(fs5, "FileReadStream", {
|
|
711
|
+
get: function() {
|
|
712
|
+
return FileReadStream;
|
|
713
|
+
},
|
|
714
|
+
set: function(val) {
|
|
715
|
+
FileReadStream = val;
|
|
716
|
+
},
|
|
717
|
+
enumerable: true,
|
|
718
|
+
configurable: true
|
|
719
|
+
});
|
|
720
|
+
var FileWriteStream = WriteStream;
|
|
721
|
+
Object.defineProperty(fs5, "FileWriteStream", {
|
|
722
|
+
get: function() {
|
|
723
|
+
return FileWriteStream;
|
|
724
|
+
},
|
|
725
|
+
set: function(val) {
|
|
726
|
+
FileWriteStream = val;
|
|
727
|
+
},
|
|
728
|
+
enumerable: true,
|
|
729
|
+
configurable: true
|
|
730
|
+
});
|
|
731
|
+
function ReadStream(path4, options) {
|
|
732
|
+
if (this instanceof ReadStream)
|
|
733
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
734
|
+
else
|
|
735
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
736
|
+
}
|
|
737
|
+
function ReadStream$open() {
|
|
738
|
+
var that = this;
|
|
739
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
740
|
+
if (err) {
|
|
741
|
+
if (that.autoClose)
|
|
742
|
+
that.destroy();
|
|
743
|
+
that.emit("error", err);
|
|
744
|
+
} else {
|
|
745
|
+
that.fd = fd;
|
|
746
|
+
that.emit("open", fd);
|
|
747
|
+
that.read();
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
function WriteStream(path4, options) {
|
|
752
|
+
if (this instanceof WriteStream)
|
|
753
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
754
|
+
else
|
|
755
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
756
|
+
}
|
|
757
|
+
function WriteStream$open() {
|
|
758
|
+
var that = this;
|
|
759
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
760
|
+
if (err) {
|
|
761
|
+
that.destroy();
|
|
762
|
+
that.emit("error", err);
|
|
763
|
+
} else {
|
|
764
|
+
that.fd = fd;
|
|
765
|
+
that.emit("open", fd);
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
function createReadStream(path4, options) {
|
|
770
|
+
return new fs5.ReadStream(path4, options);
|
|
771
|
+
}
|
|
772
|
+
function createWriteStream(path4, options) {
|
|
773
|
+
return new fs5.WriteStream(path4, options);
|
|
774
|
+
}
|
|
775
|
+
var fs$open = fs5.open;
|
|
776
|
+
fs5.open = open;
|
|
777
|
+
function open(path4, flags, mode, cb) {
|
|
778
|
+
if (typeof mode === "function")
|
|
779
|
+
cb = mode, mode = null;
|
|
780
|
+
return go$open(path4, flags, mode, cb);
|
|
781
|
+
function go$open(path5, flags2, mode2, cb2, startTime) {
|
|
782
|
+
return fs$open(path5, flags2, mode2, function(err, fd) {
|
|
783
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
784
|
+
enqueue([go$open, [path5, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
785
|
+
else {
|
|
786
|
+
if (typeof cb2 === "function")
|
|
787
|
+
cb2.apply(this, arguments);
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return fs5;
|
|
793
|
+
}
|
|
794
|
+
function enqueue(elem) {
|
|
795
|
+
debug2("ENQUEUE", elem[0].name, elem[1]);
|
|
796
|
+
fs4[gracefulQueue].push(elem);
|
|
797
|
+
retry();
|
|
798
|
+
}
|
|
799
|
+
var retryTimer;
|
|
800
|
+
function resetQueue() {
|
|
801
|
+
var now = Date.now();
|
|
802
|
+
for (var i = 0; i < fs4[gracefulQueue].length; ++i) {
|
|
803
|
+
if (fs4[gracefulQueue][i].length > 2) {
|
|
804
|
+
fs4[gracefulQueue][i][3] = now;
|
|
805
|
+
fs4[gracefulQueue][i][4] = now;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
retry();
|
|
809
|
+
}
|
|
810
|
+
function retry() {
|
|
811
|
+
clearTimeout(retryTimer);
|
|
812
|
+
retryTimer = void 0;
|
|
813
|
+
if (fs4[gracefulQueue].length === 0)
|
|
814
|
+
return;
|
|
815
|
+
var elem = fs4[gracefulQueue].shift();
|
|
816
|
+
var fn = elem[0];
|
|
817
|
+
var args = elem[1];
|
|
818
|
+
var err = elem[2];
|
|
819
|
+
var startTime = elem[3];
|
|
820
|
+
var lastTime = elem[4];
|
|
821
|
+
if (startTime === void 0) {
|
|
822
|
+
debug2("RETRY", fn.name, args);
|
|
823
|
+
fn.apply(null, args);
|
|
824
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
825
|
+
debug2("TIMEOUT", fn.name, args);
|
|
826
|
+
var cb = args.pop();
|
|
827
|
+
if (typeof cb === "function")
|
|
828
|
+
cb.call(null, err);
|
|
829
|
+
} else {
|
|
830
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
831
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
832
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
833
|
+
if (sinceAttempt >= desiredDelay) {
|
|
834
|
+
debug2("RETRY", fn.name, args);
|
|
835
|
+
fn.apply(null, args.concat([startTime]));
|
|
836
|
+
} else {
|
|
837
|
+
fs4[gracefulQueue].push(elem);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
if (retryTimer === void 0) {
|
|
841
|
+
retryTimer = setTimeout(retry, 0);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/fs/index.js
|
|
848
|
+
var require_fs = __commonJS({
|
|
849
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/fs/index.js"(exports2) {
|
|
850
|
+
"use strict";
|
|
851
|
+
var u = require_universalify().fromCallback;
|
|
852
|
+
var fs4 = require_graceful_fs();
|
|
853
|
+
var api = [
|
|
854
|
+
"access",
|
|
855
|
+
"appendFile",
|
|
856
|
+
"chmod",
|
|
857
|
+
"chown",
|
|
858
|
+
"close",
|
|
859
|
+
"copyFile",
|
|
860
|
+
"fchmod",
|
|
861
|
+
"fchown",
|
|
862
|
+
"fdatasync",
|
|
863
|
+
"fstat",
|
|
864
|
+
"fsync",
|
|
865
|
+
"ftruncate",
|
|
866
|
+
"futimes",
|
|
867
|
+
"lchmod",
|
|
868
|
+
"lchown",
|
|
869
|
+
"link",
|
|
870
|
+
"lstat",
|
|
871
|
+
"mkdir",
|
|
872
|
+
"mkdtemp",
|
|
873
|
+
"open",
|
|
874
|
+
"opendir",
|
|
875
|
+
"readdir",
|
|
876
|
+
"readFile",
|
|
877
|
+
"readlink",
|
|
878
|
+
"realpath",
|
|
879
|
+
"rename",
|
|
880
|
+
"rm",
|
|
881
|
+
"rmdir",
|
|
882
|
+
"stat",
|
|
883
|
+
"symlink",
|
|
884
|
+
"truncate",
|
|
885
|
+
"unlink",
|
|
886
|
+
"utimes",
|
|
887
|
+
"writeFile"
|
|
888
|
+
].filter((key) => {
|
|
889
|
+
return typeof fs4[key] === "function";
|
|
890
|
+
});
|
|
891
|
+
Object.assign(exports2, fs4);
|
|
892
|
+
api.forEach((method) => {
|
|
893
|
+
exports2[method] = u(fs4[method]);
|
|
894
|
+
});
|
|
895
|
+
exports2.exists = function(filename, callback) {
|
|
896
|
+
if (typeof callback === "function") {
|
|
897
|
+
return fs4.exists(filename, callback);
|
|
898
|
+
}
|
|
899
|
+
return new Promise((resolve) => {
|
|
900
|
+
return fs4.exists(filename, resolve);
|
|
901
|
+
});
|
|
902
|
+
};
|
|
903
|
+
exports2.read = function(fd, buffer, offset, length, position, callback) {
|
|
904
|
+
if (typeof callback === "function") {
|
|
905
|
+
return fs4.read(fd, buffer, offset, length, position, callback);
|
|
906
|
+
}
|
|
907
|
+
return new Promise((resolve, reject) => {
|
|
908
|
+
fs4.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
|
|
909
|
+
if (err) return reject(err);
|
|
910
|
+
resolve({ bytesRead, buffer: buffer2 });
|
|
911
|
+
});
|
|
912
|
+
});
|
|
913
|
+
};
|
|
914
|
+
exports2.write = function(fd, buffer, ...args) {
|
|
915
|
+
if (typeof args[args.length - 1] === "function") {
|
|
916
|
+
return fs4.write(fd, buffer, ...args);
|
|
917
|
+
}
|
|
918
|
+
return new Promise((resolve, reject) => {
|
|
919
|
+
fs4.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
|
|
920
|
+
if (err) return reject(err);
|
|
921
|
+
resolve({ bytesWritten, buffer: buffer2 });
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
};
|
|
925
|
+
if (typeof fs4.writev === "function") {
|
|
926
|
+
exports2.writev = function(fd, buffers, ...args) {
|
|
927
|
+
if (typeof args[args.length - 1] === "function") {
|
|
928
|
+
return fs4.writev(fd, buffers, ...args);
|
|
929
|
+
}
|
|
930
|
+
return new Promise((resolve, reject) => {
|
|
931
|
+
fs4.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
|
|
932
|
+
if (err) return reject(err);
|
|
933
|
+
resolve({ bytesWritten, buffers: buffers2 });
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
if (typeof fs4.realpath.native === "function") {
|
|
939
|
+
exports2.realpath.native = u(fs4.realpath.native);
|
|
940
|
+
} else {
|
|
941
|
+
process.emitWarning(
|
|
942
|
+
"fs.realpath.native is not a function. Is fs being monkey-patched?",
|
|
943
|
+
"Warning",
|
|
944
|
+
"fs-extra-WARN0003"
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
|
|
950
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/mkdirs/utils.js
|
|
951
|
+
var require_utils = __commonJS({
|
|
952
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/mkdirs/utils.js"(exports2, module2) {
|
|
953
|
+
"use strict";
|
|
954
|
+
var path4 = require("path");
|
|
955
|
+
module2.exports.checkPath = function checkPath(pth) {
|
|
956
|
+
if (process.platform === "win32") {
|
|
957
|
+
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path4.parse(pth).root, ""));
|
|
958
|
+
if (pathHasInvalidWinCharacters) {
|
|
959
|
+
const error2 = new Error(`Path contains invalid characters: ${pth}`);
|
|
960
|
+
error2.code = "EINVAL";
|
|
961
|
+
throw error2;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
|
|
968
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/mkdirs/make-dir.js
|
|
969
|
+
var require_make_dir = __commonJS({
|
|
970
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/mkdirs/make-dir.js"(exports2, module2) {
|
|
971
|
+
"use strict";
|
|
972
|
+
var fs4 = require_fs();
|
|
973
|
+
var { checkPath } = require_utils();
|
|
974
|
+
var getMode = (options) => {
|
|
975
|
+
const defaults = { mode: 511 };
|
|
976
|
+
if (typeof options === "number") return options;
|
|
977
|
+
return { ...defaults, ...options }.mode;
|
|
978
|
+
};
|
|
979
|
+
module2.exports.makeDir = async (dir, options) => {
|
|
980
|
+
checkPath(dir);
|
|
981
|
+
return fs4.mkdir(dir, {
|
|
982
|
+
mode: getMode(options),
|
|
983
|
+
recursive: true
|
|
984
|
+
});
|
|
985
|
+
};
|
|
986
|
+
module2.exports.makeDirSync = (dir, options) => {
|
|
987
|
+
checkPath(dir);
|
|
988
|
+
return fs4.mkdirSync(dir, {
|
|
989
|
+
mode: getMode(options),
|
|
990
|
+
recursive: true
|
|
991
|
+
});
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/mkdirs/index.js
|
|
997
|
+
var require_mkdirs = __commonJS({
|
|
998
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/mkdirs/index.js"(exports2, module2) {
|
|
999
|
+
"use strict";
|
|
1000
|
+
var u = require_universalify().fromPromise;
|
|
1001
|
+
var { makeDir: _makeDir, makeDirSync } = require_make_dir();
|
|
1002
|
+
var makeDir = u(_makeDir);
|
|
1003
|
+
module2.exports = {
|
|
1004
|
+
mkdirs: makeDir,
|
|
1005
|
+
mkdirsSync: makeDirSync,
|
|
1006
|
+
// alias
|
|
1007
|
+
mkdirp: makeDir,
|
|
1008
|
+
mkdirpSync: makeDirSync,
|
|
1009
|
+
ensureDir: makeDir,
|
|
1010
|
+
ensureDirSync: makeDirSync
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/path-exists/index.js
|
|
1016
|
+
var require_path_exists = __commonJS({
|
|
1017
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/path-exists/index.js"(exports2, module2) {
|
|
1018
|
+
"use strict";
|
|
1019
|
+
var u = require_universalify().fromPromise;
|
|
1020
|
+
var fs4 = require_fs();
|
|
1021
|
+
function pathExists(path4) {
|
|
1022
|
+
return fs4.access(path4).then(() => true).catch(() => false);
|
|
1023
|
+
}
|
|
1024
|
+
module2.exports = {
|
|
1025
|
+
pathExists: u(pathExists),
|
|
1026
|
+
pathExistsSync: fs4.existsSync
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
|
|
1031
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/util/utimes.js
|
|
1032
|
+
var require_utimes = __commonJS({
|
|
1033
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/util/utimes.js"(exports2, module2) {
|
|
1034
|
+
"use strict";
|
|
1035
|
+
var fs4 = require_graceful_fs();
|
|
1036
|
+
function utimesMillis(path4, atime, mtime, callback) {
|
|
1037
|
+
fs4.open(path4, "r+", (err, fd) => {
|
|
1038
|
+
if (err) return callback(err);
|
|
1039
|
+
fs4.futimes(fd, atime, mtime, (futimesErr) => {
|
|
1040
|
+
fs4.close(fd, (closeErr) => {
|
|
1041
|
+
if (callback) callback(futimesErr || closeErr);
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
function utimesMillisSync(path4, atime, mtime) {
|
|
1047
|
+
const fd = fs4.openSync(path4, "r+");
|
|
1048
|
+
fs4.futimesSync(fd, atime, mtime);
|
|
1049
|
+
return fs4.closeSync(fd);
|
|
1050
|
+
}
|
|
1051
|
+
module2.exports = {
|
|
1052
|
+
utimesMillis,
|
|
1053
|
+
utimesMillisSync
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
|
|
1058
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/util/stat.js
|
|
1059
|
+
var require_stat = __commonJS({
|
|
1060
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/util/stat.js"(exports2, module2) {
|
|
1061
|
+
"use strict";
|
|
1062
|
+
var fs4 = require_fs();
|
|
1063
|
+
var path4 = require("path");
|
|
1064
|
+
var util = require("util");
|
|
1065
|
+
function getStats(src, dest, opts) {
|
|
1066
|
+
const statFunc = opts.dereference ? (file) => fs4.stat(file, { bigint: true }) : (file) => fs4.lstat(file, { bigint: true });
|
|
1067
|
+
return Promise.all([
|
|
1068
|
+
statFunc(src),
|
|
1069
|
+
statFunc(dest).catch((err) => {
|
|
1070
|
+
if (err.code === "ENOENT") return null;
|
|
1071
|
+
throw err;
|
|
1072
|
+
})
|
|
1073
|
+
]).then(([srcStat, destStat]) => ({ srcStat, destStat }));
|
|
1074
|
+
}
|
|
1075
|
+
function getStatsSync(src, dest, opts) {
|
|
1076
|
+
let destStat;
|
|
1077
|
+
const statFunc = opts.dereference ? (file) => fs4.statSync(file, { bigint: true }) : (file) => fs4.lstatSync(file, { bigint: true });
|
|
1078
|
+
const srcStat = statFunc(src);
|
|
1079
|
+
try {
|
|
1080
|
+
destStat = statFunc(dest);
|
|
1081
|
+
} catch (err) {
|
|
1082
|
+
if (err.code === "ENOENT") return { srcStat, destStat: null };
|
|
1083
|
+
throw err;
|
|
1084
|
+
}
|
|
1085
|
+
return { srcStat, destStat };
|
|
1086
|
+
}
|
|
1087
|
+
function checkPaths(src, dest, funcName, opts, cb) {
|
|
1088
|
+
util.callbackify(getStats)(src, dest, opts, (err, stats) => {
|
|
1089
|
+
if (err) return cb(err);
|
|
1090
|
+
const { srcStat, destStat } = stats;
|
|
1091
|
+
if (destStat) {
|
|
1092
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1093
|
+
const srcBaseName = path4.basename(src);
|
|
1094
|
+
const destBaseName = path4.basename(dest);
|
|
1095
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
1096
|
+
return cb(null, { srcStat, destStat, isChangingCase: true });
|
|
1097
|
+
}
|
|
1098
|
+
return cb(new Error("Source and destination must not be the same."));
|
|
1099
|
+
}
|
|
1100
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
1101
|
+
return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`));
|
|
1102
|
+
}
|
|
1103
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
1104
|
+
return cb(new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`));
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
1108
|
+
return cb(new Error(errMsg(src, dest, funcName)));
|
|
1109
|
+
}
|
|
1110
|
+
return cb(null, { srcStat, destStat });
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
function checkPathsSync(src, dest, funcName, opts) {
|
|
1114
|
+
const { srcStat, destStat } = getStatsSync(src, dest, opts);
|
|
1115
|
+
if (destStat) {
|
|
1116
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1117
|
+
const srcBaseName = path4.basename(src);
|
|
1118
|
+
const destBaseName = path4.basename(dest);
|
|
1119
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
|
1120
|
+
return { srcStat, destStat, isChangingCase: true };
|
|
1121
|
+
}
|
|
1122
|
+
throw new Error("Source and destination must not be the same.");
|
|
1123
|
+
}
|
|
1124
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
|
1125
|
+
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
1126
|
+
}
|
|
1127
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
|
1128
|
+
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
1132
|
+
throw new Error(errMsg(src, dest, funcName));
|
|
1133
|
+
}
|
|
1134
|
+
return { srcStat, destStat };
|
|
1135
|
+
}
|
|
1136
|
+
function checkParentPaths(src, srcStat, dest, funcName, cb) {
|
|
1137
|
+
const srcParent = path4.resolve(path4.dirname(src));
|
|
1138
|
+
const destParent = path4.resolve(path4.dirname(dest));
|
|
1139
|
+
if (destParent === srcParent || destParent === path4.parse(destParent).root) return cb();
|
|
1140
|
+
fs4.stat(destParent, { bigint: true }, (err, destStat) => {
|
|
1141
|
+
if (err) {
|
|
1142
|
+
if (err.code === "ENOENT") return cb();
|
|
1143
|
+
return cb(err);
|
|
1144
|
+
}
|
|
1145
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1146
|
+
return cb(new Error(errMsg(src, dest, funcName)));
|
|
1147
|
+
}
|
|
1148
|
+
return checkParentPaths(src, srcStat, destParent, funcName, cb);
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
function checkParentPathsSync(src, srcStat, dest, funcName) {
|
|
1152
|
+
const srcParent = path4.resolve(path4.dirname(src));
|
|
1153
|
+
const destParent = path4.resolve(path4.dirname(dest));
|
|
1154
|
+
if (destParent === srcParent || destParent === path4.parse(destParent).root) return;
|
|
1155
|
+
let destStat;
|
|
1156
|
+
try {
|
|
1157
|
+
destStat = fs4.statSync(destParent, { bigint: true });
|
|
1158
|
+
} catch (err) {
|
|
1159
|
+
if (err.code === "ENOENT") return;
|
|
1160
|
+
throw err;
|
|
1161
|
+
}
|
|
1162
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1163
|
+
throw new Error(errMsg(src, dest, funcName));
|
|
1164
|
+
}
|
|
1165
|
+
return checkParentPathsSync(src, srcStat, destParent, funcName);
|
|
1166
|
+
}
|
|
1167
|
+
function areIdentical(srcStat, destStat) {
|
|
1168
|
+
return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
|
|
1169
|
+
}
|
|
1170
|
+
function isSrcSubdir(src, dest) {
|
|
1171
|
+
const srcArr = path4.resolve(src).split(path4.sep).filter((i) => i);
|
|
1172
|
+
const destArr = path4.resolve(dest).split(path4.sep).filter((i) => i);
|
|
1173
|
+
return srcArr.reduce((acc, cur, i) => acc && destArr[i] === cur, true);
|
|
1174
|
+
}
|
|
1175
|
+
function errMsg(src, dest, funcName) {
|
|
1176
|
+
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
|
|
1177
|
+
}
|
|
1178
|
+
module2.exports = {
|
|
1179
|
+
checkPaths,
|
|
1180
|
+
checkPathsSync,
|
|
1181
|
+
checkParentPaths,
|
|
1182
|
+
checkParentPathsSync,
|
|
1183
|
+
isSrcSubdir,
|
|
1184
|
+
areIdentical
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
|
|
1189
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/copy/copy.js
|
|
1190
|
+
var require_copy = __commonJS({
|
|
1191
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/copy/copy.js"(exports2, module2) {
|
|
1192
|
+
"use strict";
|
|
1193
|
+
var fs4 = require_graceful_fs();
|
|
1194
|
+
var path4 = require("path");
|
|
1195
|
+
var mkdirs = require_mkdirs().mkdirs;
|
|
1196
|
+
var pathExists = require_path_exists().pathExists;
|
|
1197
|
+
var utimesMillis = require_utimes().utimesMillis;
|
|
1198
|
+
var stat = require_stat();
|
|
1199
|
+
function copy(src, dest, opts, cb) {
|
|
1200
|
+
if (typeof opts === "function" && !cb) {
|
|
1201
|
+
cb = opts;
|
|
1202
|
+
opts = {};
|
|
1203
|
+
} else if (typeof opts === "function") {
|
|
1204
|
+
opts = { filter: opts };
|
|
1205
|
+
}
|
|
1206
|
+
cb = cb || function() {
|
|
1207
|
+
};
|
|
1208
|
+
opts = opts || {};
|
|
1209
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
1210
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
1211
|
+
if (opts.preserveTimestamps && process.arch === "ia32") {
|
|
1212
|
+
process.emitWarning(
|
|
1213
|
+
"Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
|
|
1214
|
+
"Warning",
|
|
1215
|
+
"fs-extra-WARN0001"
|
|
1216
|
+
);
|
|
1217
|
+
}
|
|
1218
|
+
stat.checkPaths(src, dest, "copy", opts, (err, stats) => {
|
|
1219
|
+
if (err) return cb(err);
|
|
1220
|
+
const { srcStat, destStat } = stats;
|
|
1221
|
+
stat.checkParentPaths(src, srcStat, dest, "copy", (err2) => {
|
|
1222
|
+
if (err2) return cb(err2);
|
|
1223
|
+
if (opts.filter) return handleFilter(checkParentDir, destStat, src, dest, opts, cb);
|
|
1224
|
+
return checkParentDir(destStat, src, dest, opts, cb);
|
|
1225
|
+
});
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
function checkParentDir(destStat, src, dest, opts, cb) {
|
|
1229
|
+
const destParent = path4.dirname(dest);
|
|
1230
|
+
pathExists(destParent, (err, dirExists) => {
|
|
1231
|
+
if (err) return cb(err);
|
|
1232
|
+
if (dirExists) return getStats(destStat, src, dest, opts, cb);
|
|
1233
|
+
mkdirs(destParent, (err2) => {
|
|
1234
|
+
if (err2) return cb(err2);
|
|
1235
|
+
return getStats(destStat, src, dest, opts, cb);
|
|
1236
|
+
});
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
function handleFilter(onInclude, destStat, src, dest, opts, cb) {
|
|
1240
|
+
Promise.resolve(opts.filter(src, dest)).then((include) => {
|
|
1241
|
+
if (include) return onInclude(destStat, src, dest, opts, cb);
|
|
1242
|
+
return cb();
|
|
1243
|
+
}, (error2) => cb(error2));
|
|
1244
|
+
}
|
|
1245
|
+
function startCopy(destStat, src, dest, opts, cb) {
|
|
1246
|
+
if (opts.filter) return handleFilter(getStats, destStat, src, dest, opts, cb);
|
|
1247
|
+
return getStats(destStat, src, dest, opts, cb);
|
|
1248
|
+
}
|
|
1249
|
+
function getStats(destStat, src, dest, opts, cb) {
|
|
1250
|
+
const stat2 = opts.dereference ? fs4.stat : fs4.lstat;
|
|
1251
|
+
stat2(src, (err, srcStat) => {
|
|
1252
|
+
if (err) return cb(err);
|
|
1253
|
+
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts, cb);
|
|
1254
|
+
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts, cb);
|
|
1255
|
+
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts, cb);
|
|
1256
|
+
else if (srcStat.isSocket()) return cb(new Error(`Cannot copy a socket file: ${src}`));
|
|
1257
|
+
else if (srcStat.isFIFO()) return cb(new Error(`Cannot copy a FIFO pipe: ${src}`));
|
|
1258
|
+
return cb(new Error(`Unknown file: ${src}`));
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
function onFile(srcStat, destStat, src, dest, opts, cb) {
|
|
1262
|
+
if (!destStat) return copyFile(srcStat, src, dest, opts, cb);
|
|
1263
|
+
return mayCopyFile(srcStat, src, dest, opts, cb);
|
|
1264
|
+
}
|
|
1265
|
+
function mayCopyFile(srcStat, src, dest, opts, cb) {
|
|
1266
|
+
if (opts.overwrite) {
|
|
1267
|
+
fs4.unlink(dest, (err) => {
|
|
1268
|
+
if (err) return cb(err);
|
|
1269
|
+
return copyFile(srcStat, src, dest, opts, cb);
|
|
1270
|
+
});
|
|
1271
|
+
} else if (opts.errorOnExist) {
|
|
1272
|
+
return cb(new Error(`'${dest}' already exists`));
|
|
1273
|
+
} else return cb();
|
|
1274
|
+
}
|
|
1275
|
+
function copyFile(srcStat, src, dest, opts, cb) {
|
|
1276
|
+
fs4.copyFile(src, dest, (err) => {
|
|
1277
|
+
if (err) return cb(err);
|
|
1278
|
+
if (opts.preserveTimestamps) return handleTimestampsAndMode(srcStat.mode, src, dest, cb);
|
|
1279
|
+
return setDestMode(dest, srcStat.mode, cb);
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
function handleTimestampsAndMode(srcMode, src, dest, cb) {
|
|
1283
|
+
if (fileIsNotWritable(srcMode)) {
|
|
1284
|
+
return makeFileWritable(dest, srcMode, (err) => {
|
|
1285
|
+
if (err) return cb(err);
|
|
1286
|
+
return setDestTimestampsAndMode(srcMode, src, dest, cb);
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
return setDestTimestampsAndMode(srcMode, src, dest, cb);
|
|
1290
|
+
}
|
|
1291
|
+
function fileIsNotWritable(srcMode) {
|
|
1292
|
+
return (srcMode & 128) === 0;
|
|
1293
|
+
}
|
|
1294
|
+
function makeFileWritable(dest, srcMode, cb) {
|
|
1295
|
+
return setDestMode(dest, srcMode | 128, cb);
|
|
1296
|
+
}
|
|
1297
|
+
function setDestTimestampsAndMode(srcMode, src, dest, cb) {
|
|
1298
|
+
setDestTimestamps(src, dest, (err) => {
|
|
1299
|
+
if (err) return cb(err);
|
|
1300
|
+
return setDestMode(dest, srcMode, cb);
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
function setDestMode(dest, srcMode, cb) {
|
|
1304
|
+
return fs4.chmod(dest, srcMode, cb);
|
|
1305
|
+
}
|
|
1306
|
+
function setDestTimestamps(src, dest, cb) {
|
|
1307
|
+
fs4.stat(src, (err, updatedSrcStat) => {
|
|
1308
|
+
if (err) return cb(err);
|
|
1309
|
+
return utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime, cb);
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
function onDir(srcStat, destStat, src, dest, opts, cb) {
|
|
1313
|
+
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts, cb);
|
|
1314
|
+
return copyDir(src, dest, opts, cb);
|
|
1315
|
+
}
|
|
1316
|
+
function mkDirAndCopy(srcMode, src, dest, opts, cb) {
|
|
1317
|
+
fs4.mkdir(dest, (err) => {
|
|
1318
|
+
if (err) return cb(err);
|
|
1319
|
+
copyDir(src, dest, opts, (err2) => {
|
|
1320
|
+
if (err2) return cb(err2);
|
|
1321
|
+
return setDestMode(dest, srcMode, cb);
|
|
1322
|
+
});
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
function copyDir(src, dest, opts, cb) {
|
|
1326
|
+
fs4.readdir(src, (err, items) => {
|
|
1327
|
+
if (err) return cb(err);
|
|
1328
|
+
return copyDirItems(items, src, dest, opts, cb);
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
function copyDirItems(items, src, dest, opts, cb) {
|
|
1332
|
+
const item = items.pop();
|
|
1333
|
+
if (!item) return cb();
|
|
1334
|
+
return copyDirItem(items, item, src, dest, opts, cb);
|
|
1335
|
+
}
|
|
1336
|
+
function copyDirItem(items, item, src, dest, opts, cb) {
|
|
1337
|
+
const srcItem = path4.join(src, item);
|
|
1338
|
+
const destItem = path4.join(dest, item);
|
|
1339
|
+
stat.checkPaths(srcItem, destItem, "copy", opts, (err, stats) => {
|
|
1340
|
+
if (err) return cb(err);
|
|
1341
|
+
const { destStat } = stats;
|
|
1342
|
+
startCopy(destStat, srcItem, destItem, opts, (err2) => {
|
|
1343
|
+
if (err2) return cb(err2);
|
|
1344
|
+
return copyDirItems(items, src, dest, opts, cb);
|
|
1345
|
+
});
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
function onLink(destStat, src, dest, opts, cb) {
|
|
1349
|
+
fs4.readlink(src, (err, resolvedSrc) => {
|
|
1350
|
+
if (err) return cb(err);
|
|
1351
|
+
if (opts.dereference) {
|
|
1352
|
+
resolvedSrc = path4.resolve(process.cwd(), resolvedSrc);
|
|
1353
|
+
}
|
|
1354
|
+
if (!destStat) {
|
|
1355
|
+
return fs4.symlink(resolvedSrc, dest, cb);
|
|
1356
|
+
} else {
|
|
1357
|
+
fs4.readlink(dest, (err2, resolvedDest) => {
|
|
1358
|
+
if (err2) {
|
|
1359
|
+
if (err2.code === "EINVAL" || err2.code === "UNKNOWN") return fs4.symlink(resolvedSrc, dest, cb);
|
|
1360
|
+
return cb(err2);
|
|
1361
|
+
}
|
|
1362
|
+
if (opts.dereference) {
|
|
1363
|
+
resolvedDest = path4.resolve(process.cwd(), resolvedDest);
|
|
1364
|
+
}
|
|
1365
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
1366
|
+
return cb(new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`));
|
|
1367
|
+
}
|
|
1368
|
+
if (destStat.isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
1369
|
+
return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`));
|
|
1370
|
+
}
|
|
1371
|
+
return copyLink(resolvedSrc, dest, cb);
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
function copyLink(resolvedSrc, dest, cb) {
|
|
1377
|
+
fs4.unlink(dest, (err) => {
|
|
1378
|
+
if (err) return cb(err);
|
|
1379
|
+
return fs4.symlink(resolvedSrc, dest, cb);
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
module2.exports = copy;
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1386
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/copy/copy-sync.js
|
|
1387
|
+
var require_copy_sync = __commonJS({
|
|
1388
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/copy/copy-sync.js"(exports2, module2) {
|
|
1389
|
+
"use strict";
|
|
1390
|
+
var fs4 = require_graceful_fs();
|
|
1391
|
+
var path4 = require("path");
|
|
1392
|
+
var mkdirsSync = require_mkdirs().mkdirsSync;
|
|
1393
|
+
var utimesMillisSync = require_utimes().utimesMillisSync;
|
|
1394
|
+
var stat = require_stat();
|
|
1395
|
+
function copySync(src, dest, opts) {
|
|
1396
|
+
if (typeof opts === "function") {
|
|
1397
|
+
opts = { filter: opts };
|
|
1398
|
+
}
|
|
1399
|
+
opts = opts || {};
|
|
1400
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
1401
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
1402
|
+
if (opts.preserveTimestamps && process.arch === "ia32") {
|
|
1403
|
+
process.emitWarning(
|
|
1404
|
+
"Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
|
|
1405
|
+
"Warning",
|
|
1406
|
+
"fs-extra-WARN0002"
|
|
1407
|
+
);
|
|
1408
|
+
}
|
|
1409
|
+
const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
|
|
1410
|
+
stat.checkParentPathsSync(src, srcStat, dest, "copy");
|
|
1411
|
+
return handleFilterAndCopy(destStat, src, dest, opts);
|
|
1412
|
+
}
|
|
1413
|
+
function handleFilterAndCopy(destStat, src, dest, opts) {
|
|
1414
|
+
if (opts.filter && !opts.filter(src, dest)) return;
|
|
1415
|
+
const destParent = path4.dirname(dest);
|
|
1416
|
+
if (!fs4.existsSync(destParent)) mkdirsSync(destParent);
|
|
1417
|
+
return getStats(destStat, src, dest, opts);
|
|
1418
|
+
}
|
|
1419
|
+
function startCopy(destStat, src, dest, opts) {
|
|
1420
|
+
if (opts.filter && !opts.filter(src, dest)) return;
|
|
1421
|
+
return getStats(destStat, src, dest, opts);
|
|
1422
|
+
}
|
|
1423
|
+
function getStats(destStat, src, dest, opts) {
|
|
1424
|
+
const statSync = opts.dereference ? fs4.statSync : fs4.lstatSync;
|
|
1425
|
+
const srcStat = statSync(src);
|
|
1426
|
+
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
|
|
1427
|
+
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
|
|
1428
|
+
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
|
|
1429
|
+
else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
|
|
1430
|
+
else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
1431
|
+
throw new Error(`Unknown file: ${src}`);
|
|
1432
|
+
}
|
|
1433
|
+
function onFile(srcStat, destStat, src, dest, opts) {
|
|
1434
|
+
if (!destStat) return copyFile(srcStat, src, dest, opts);
|
|
1435
|
+
return mayCopyFile(srcStat, src, dest, opts);
|
|
1436
|
+
}
|
|
1437
|
+
function mayCopyFile(srcStat, src, dest, opts) {
|
|
1438
|
+
if (opts.overwrite) {
|
|
1439
|
+
fs4.unlinkSync(dest);
|
|
1440
|
+
return copyFile(srcStat, src, dest, opts);
|
|
1441
|
+
} else if (opts.errorOnExist) {
|
|
1442
|
+
throw new Error(`'${dest}' already exists`);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
function copyFile(srcStat, src, dest, opts) {
|
|
1446
|
+
fs4.copyFileSync(src, dest);
|
|
1447
|
+
if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
|
|
1448
|
+
return setDestMode(dest, srcStat.mode);
|
|
1449
|
+
}
|
|
1450
|
+
function handleTimestamps(srcMode, src, dest) {
|
|
1451
|
+
if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
|
|
1452
|
+
return setDestTimestamps(src, dest);
|
|
1453
|
+
}
|
|
1454
|
+
function fileIsNotWritable(srcMode) {
|
|
1455
|
+
return (srcMode & 128) === 0;
|
|
1456
|
+
}
|
|
1457
|
+
function makeFileWritable(dest, srcMode) {
|
|
1458
|
+
return setDestMode(dest, srcMode | 128);
|
|
1459
|
+
}
|
|
1460
|
+
function setDestMode(dest, srcMode) {
|
|
1461
|
+
return fs4.chmodSync(dest, srcMode);
|
|
1462
|
+
}
|
|
1463
|
+
function setDestTimestamps(src, dest) {
|
|
1464
|
+
const updatedSrcStat = fs4.statSync(src);
|
|
1465
|
+
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
1466
|
+
}
|
|
1467
|
+
function onDir(srcStat, destStat, src, dest, opts) {
|
|
1468
|
+
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts);
|
|
1469
|
+
return copyDir(src, dest, opts);
|
|
1470
|
+
}
|
|
1471
|
+
function mkDirAndCopy(srcMode, src, dest, opts) {
|
|
1472
|
+
fs4.mkdirSync(dest);
|
|
1473
|
+
copyDir(src, dest, opts);
|
|
1474
|
+
return setDestMode(dest, srcMode);
|
|
1475
|
+
}
|
|
1476
|
+
function copyDir(src, dest, opts) {
|
|
1477
|
+
fs4.readdirSync(src).forEach((item) => copyDirItem(item, src, dest, opts));
|
|
1478
|
+
}
|
|
1479
|
+
function copyDirItem(item, src, dest, opts) {
|
|
1480
|
+
const srcItem = path4.join(src, item);
|
|
1481
|
+
const destItem = path4.join(dest, item);
|
|
1482
|
+
const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
|
|
1483
|
+
return startCopy(destStat, srcItem, destItem, opts);
|
|
1484
|
+
}
|
|
1485
|
+
function onLink(destStat, src, dest, opts) {
|
|
1486
|
+
let resolvedSrc = fs4.readlinkSync(src);
|
|
1487
|
+
if (opts.dereference) {
|
|
1488
|
+
resolvedSrc = path4.resolve(process.cwd(), resolvedSrc);
|
|
1489
|
+
}
|
|
1490
|
+
if (!destStat) {
|
|
1491
|
+
return fs4.symlinkSync(resolvedSrc, dest);
|
|
1492
|
+
} else {
|
|
1493
|
+
let resolvedDest;
|
|
1494
|
+
try {
|
|
1495
|
+
resolvedDest = fs4.readlinkSync(dest);
|
|
1496
|
+
} catch (err) {
|
|
1497
|
+
if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs4.symlinkSync(resolvedSrc, dest);
|
|
1498
|
+
throw err;
|
|
1499
|
+
}
|
|
1500
|
+
if (opts.dereference) {
|
|
1501
|
+
resolvedDest = path4.resolve(process.cwd(), resolvedDest);
|
|
1502
|
+
}
|
|
1503
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
1504
|
+
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
1505
|
+
}
|
|
1506
|
+
if (fs4.statSync(dest).isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
1507
|
+
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
1508
|
+
}
|
|
1509
|
+
return copyLink(resolvedSrc, dest);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
function copyLink(resolvedSrc, dest) {
|
|
1513
|
+
fs4.unlinkSync(dest);
|
|
1514
|
+
return fs4.symlinkSync(resolvedSrc, dest);
|
|
1515
|
+
}
|
|
1516
|
+
module2.exports = copySync;
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
|
|
1520
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/copy/index.js
|
|
1521
|
+
var require_copy2 = __commonJS({
|
|
1522
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/copy/index.js"(exports2, module2) {
|
|
1523
|
+
"use strict";
|
|
1524
|
+
var u = require_universalify().fromCallback;
|
|
1525
|
+
module2.exports = {
|
|
1526
|
+
copy: u(require_copy()),
|
|
1527
|
+
copySync: require_copy_sync()
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
|
|
1532
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/remove/rimraf.js
|
|
1533
|
+
var require_rimraf = __commonJS({
|
|
1534
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/remove/rimraf.js"(exports2, module2) {
|
|
1535
|
+
"use strict";
|
|
1536
|
+
var fs4 = require_graceful_fs();
|
|
1537
|
+
var path4 = require("path");
|
|
1538
|
+
var assert = require("assert");
|
|
1539
|
+
var isWindows = process.platform === "win32";
|
|
1540
|
+
function defaults(options) {
|
|
1541
|
+
const methods = [
|
|
1542
|
+
"unlink",
|
|
1543
|
+
"chmod",
|
|
1544
|
+
"stat",
|
|
1545
|
+
"lstat",
|
|
1546
|
+
"rmdir",
|
|
1547
|
+
"readdir"
|
|
1548
|
+
];
|
|
1549
|
+
methods.forEach((m) => {
|
|
1550
|
+
options[m] = options[m] || fs4[m];
|
|
1551
|
+
m = m + "Sync";
|
|
1552
|
+
options[m] = options[m] || fs4[m];
|
|
1553
|
+
});
|
|
1554
|
+
options.maxBusyTries = options.maxBusyTries || 3;
|
|
1555
|
+
}
|
|
1556
|
+
function rimraf(p, options, cb) {
|
|
1557
|
+
let busyTries = 0;
|
|
1558
|
+
if (typeof options === "function") {
|
|
1559
|
+
cb = options;
|
|
1560
|
+
options = {};
|
|
1561
|
+
}
|
|
1562
|
+
assert(p, "rimraf: missing path");
|
|
1563
|
+
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
|
|
1564
|
+
assert.strictEqual(typeof cb, "function", "rimraf: callback function required");
|
|
1565
|
+
assert(options, "rimraf: invalid options argument provided");
|
|
1566
|
+
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
|
|
1567
|
+
defaults(options);
|
|
1568
|
+
rimraf_(p, options, function CB(er) {
|
|
1569
|
+
if (er) {
|
|
1570
|
+
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && busyTries < options.maxBusyTries) {
|
|
1571
|
+
busyTries++;
|
|
1572
|
+
const time = busyTries * 100;
|
|
1573
|
+
return setTimeout(() => rimraf_(p, options, CB), time);
|
|
1574
|
+
}
|
|
1575
|
+
if (er.code === "ENOENT") er = null;
|
|
1576
|
+
}
|
|
1577
|
+
cb(er);
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
function rimraf_(p, options, cb) {
|
|
1581
|
+
assert(p);
|
|
1582
|
+
assert(options);
|
|
1583
|
+
assert(typeof cb === "function");
|
|
1584
|
+
options.lstat(p, (er, st) => {
|
|
1585
|
+
if (er && er.code === "ENOENT") {
|
|
1586
|
+
return cb(null);
|
|
1587
|
+
}
|
|
1588
|
+
if (er && er.code === "EPERM" && isWindows) {
|
|
1589
|
+
return fixWinEPERM(p, options, er, cb);
|
|
1590
|
+
}
|
|
1591
|
+
if (st && st.isDirectory()) {
|
|
1592
|
+
return rmdir(p, options, er, cb);
|
|
1593
|
+
}
|
|
1594
|
+
options.unlink(p, (er2) => {
|
|
1595
|
+
if (er2) {
|
|
1596
|
+
if (er2.code === "ENOENT") {
|
|
1597
|
+
return cb(null);
|
|
1598
|
+
}
|
|
1599
|
+
if (er2.code === "EPERM") {
|
|
1600
|
+
return isWindows ? fixWinEPERM(p, options, er2, cb) : rmdir(p, options, er2, cb);
|
|
1601
|
+
}
|
|
1602
|
+
if (er2.code === "EISDIR") {
|
|
1603
|
+
return rmdir(p, options, er2, cb);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
return cb(er2);
|
|
1607
|
+
});
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
function fixWinEPERM(p, options, er, cb) {
|
|
1611
|
+
assert(p);
|
|
1612
|
+
assert(options);
|
|
1613
|
+
assert(typeof cb === "function");
|
|
1614
|
+
options.chmod(p, 438, (er2) => {
|
|
1615
|
+
if (er2) {
|
|
1616
|
+
cb(er2.code === "ENOENT" ? null : er);
|
|
1617
|
+
} else {
|
|
1618
|
+
options.stat(p, (er3, stats) => {
|
|
1619
|
+
if (er3) {
|
|
1620
|
+
cb(er3.code === "ENOENT" ? null : er);
|
|
1621
|
+
} else if (stats.isDirectory()) {
|
|
1622
|
+
rmdir(p, options, er, cb);
|
|
1623
|
+
} else {
|
|
1624
|
+
options.unlink(p, cb);
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
function fixWinEPERMSync(p, options, er) {
|
|
1631
|
+
let stats;
|
|
1632
|
+
assert(p);
|
|
1633
|
+
assert(options);
|
|
1634
|
+
try {
|
|
1635
|
+
options.chmodSync(p, 438);
|
|
1636
|
+
} catch (er2) {
|
|
1637
|
+
if (er2.code === "ENOENT") {
|
|
1638
|
+
return;
|
|
1639
|
+
} else {
|
|
1640
|
+
throw er;
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
try {
|
|
1644
|
+
stats = options.statSync(p);
|
|
1645
|
+
} catch (er3) {
|
|
1646
|
+
if (er3.code === "ENOENT") {
|
|
1647
|
+
return;
|
|
1648
|
+
} else {
|
|
1649
|
+
throw er;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
if (stats.isDirectory()) {
|
|
1653
|
+
rmdirSync(p, options, er);
|
|
1654
|
+
} else {
|
|
1655
|
+
options.unlinkSync(p);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
function rmdir(p, options, originalEr, cb) {
|
|
1659
|
+
assert(p);
|
|
1660
|
+
assert(options);
|
|
1661
|
+
assert(typeof cb === "function");
|
|
1662
|
+
options.rmdir(p, (er) => {
|
|
1663
|
+
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) {
|
|
1664
|
+
rmkids(p, options, cb);
|
|
1665
|
+
} else if (er && er.code === "ENOTDIR") {
|
|
1666
|
+
cb(originalEr);
|
|
1667
|
+
} else {
|
|
1668
|
+
cb(er);
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
function rmkids(p, options, cb) {
|
|
1673
|
+
assert(p);
|
|
1674
|
+
assert(options);
|
|
1675
|
+
assert(typeof cb === "function");
|
|
1676
|
+
options.readdir(p, (er, files) => {
|
|
1677
|
+
if (er) return cb(er);
|
|
1678
|
+
let n = files.length;
|
|
1679
|
+
let errState;
|
|
1680
|
+
if (n === 0) return options.rmdir(p, cb);
|
|
1681
|
+
files.forEach((f) => {
|
|
1682
|
+
rimraf(path4.join(p, f), options, (er2) => {
|
|
1683
|
+
if (errState) {
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
if (er2) return cb(errState = er2);
|
|
1687
|
+
if (--n === 0) {
|
|
1688
|
+
options.rmdir(p, cb);
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
});
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
function rimrafSync(p, options) {
|
|
1695
|
+
let st;
|
|
1696
|
+
options = options || {};
|
|
1697
|
+
defaults(options);
|
|
1698
|
+
assert(p, "rimraf: missing path");
|
|
1699
|
+
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
|
|
1700
|
+
assert(options, "rimraf: missing options");
|
|
1701
|
+
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
|
|
1702
|
+
try {
|
|
1703
|
+
st = options.lstatSync(p);
|
|
1704
|
+
} catch (er) {
|
|
1705
|
+
if (er.code === "ENOENT") {
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
if (er.code === "EPERM" && isWindows) {
|
|
1709
|
+
fixWinEPERMSync(p, options, er);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
try {
|
|
1713
|
+
if (st && st.isDirectory()) {
|
|
1714
|
+
rmdirSync(p, options, null);
|
|
1715
|
+
} else {
|
|
1716
|
+
options.unlinkSync(p);
|
|
1717
|
+
}
|
|
1718
|
+
} catch (er) {
|
|
1719
|
+
if (er.code === "ENOENT") {
|
|
1720
|
+
return;
|
|
1721
|
+
} else if (er.code === "EPERM") {
|
|
1722
|
+
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er);
|
|
1723
|
+
} else if (er.code !== "EISDIR") {
|
|
1724
|
+
throw er;
|
|
1725
|
+
}
|
|
1726
|
+
rmdirSync(p, options, er);
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
function rmdirSync(p, options, originalEr) {
|
|
1730
|
+
assert(p);
|
|
1731
|
+
assert(options);
|
|
1732
|
+
try {
|
|
1733
|
+
options.rmdirSync(p);
|
|
1734
|
+
} catch (er) {
|
|
1735
|
+
if (er.code === "ENOTDIR") {
|
|
1736
|
+
throw originalEr;
|
|
1737
|
+
} else if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") {
|
|
1738
|
+
rmkidsSync(p, options);
|
|
1739
|
+
} else if (er.code !== "ENOENT") {
|
|
1740
|
+
throw er;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
function rmkidsSync(p, options) {
|
|
1745
|
+
assert(p);
|
|
1746
|
+
assert(options);
|
|
1747
|
+
options.readdirSync(p).forEach((f) => rimrafSync(path4.join(p, f), options));
|
|
1748
|
+
if (isWindows) {
|
|
1749
|
+
const startTime = Date.now();
|
|
1750
|
+
do {
|
|
1751
|
+
try {
|
|
1752
|
+
const ret = options.rmdirSync(p, options);
|
|
1753
|
+
return ret;
|
|
1754
|
+
} catch {
|
|
1755
|
+
}
|
|
1756
|
+
} while (Date.now() - startTime < 500);
|
|
1757
|
+
} else {
|
|
1758
|
+
const ret = options.rmdirSync(p, options);
|
|
1759
|
+
return ret;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
module2.exports = rimraf;
|
|
1763
|
+
rimraf.sync = rimrafSync;
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
|
|
1767
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/remove/index.js
|
|
1768
|
+
var require_remove = __commonJS({
|
|
1769
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/remove/index.js"(exports2, module2) {
|
|
1770
|
+
"use strict";
|
|
1771
|
+
var fs4 = require_graceful_fs();
|
|
1772
|
+
var u = require_universalify().fromCallback;
|
|
1773
|
+
var rimraf = require_rimraf();
|
|
1774
|
+
function remove(path4, callback) {
|
|
1775
|
+
if (fs4.rm) return fs4.rm(path4, { recursive: true, force: true }, callback);
|
|
1776
|
+
rimraf(path4, callback);
|
|
1777
|
+
}
|
|
1778
|
+
function removeSync(path4) {
|
|
1779
|
+
if (fs4.rmSync) return fs4.rmSync(path4, { recursive: true, force: true });
|
|
1780
|
+
rimraf.sync(path4);
|
|
1781
|
+
}
|
|
1782
|
+
module2.exports = {
|
|
1783
|
+
remove: u(remove),
|
|
1784
|
+
removeSync
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
});
|
|
1788
|
+
|
|
1789
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/empty/index.js
|
|
1790
|
+
var require_empty = __commonJS({
|
|
1791
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/empty/index.js"(exports2, module2) {
|
|
1792
|
+
"use strict";
|
|
1793
|
+
var u = require_universalify().fromPromise;
|
|
1794
|
+
var fs4 = require_fs();
|
|
1795
|
+
var path4 = require("path");
|
|
1796
|
+
var mkdir = require_mkdirs();
|
|
1797
|
+
var remove = require_remove();
|
|
1798
|
+
var emptyDir = u(async function emptyDir2(dir) {
|
|
1799
|
+
let items;
|
|
1800
|
+
try {
|
|
1801
|
+
items = await fs4.readdir(dir);
|
|
1802
|
+
} catch {
|
|
1803
|
+
return mkdir.mkdirs(dir);
|
|
1804
|
+
}
|
|
1805
|
+
return Promise.all(items.map((item) => remove.remove(path4.join(dir, item))));
|
|
1806
|
+
});
|
|
1807
|
+
function emptyDirSync(dir) {
|
|
1808
|
+
let items;
|
|
1809
|
+
try {
|
|
1810
|
+
items = fs4.readdirSync(dir);
|
|
1811
|
+
} catch {
|
|
1812
|
+
return mkdir.mkdirsSync(dir);
|
|
1813
|
+
}
|
|
1814
|
+
items.forEach((item) => {
|
|
1815
|
+
item = path4.join(dir, item);
|
|
1816
|
+
remove.removeSync(item);
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
module2.exports = {
|
|
1820
|
+
emptyDirSync,
|
|
1821
|
+
emptydirSync: emptyDirSync,
|
|
1822
|
+
emptyDir,
|
|
1823
|
+
emptydir: emptyDir
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
1827
|
+
|
|
1828
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/file.js
|
|
1829
|
+
var require_file = __commonJS({
|
|
1830
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/file.js"(exports2, module2) {
|
|
1831
|
+
"use strict";
|
|
1832
|
+
var u = require_universalify().fromCallback;
|
|
1833
|
+
var path4 = require("path");
|
|
1834
|
+
var fs4 = require_graceful_fs();
|
|
1835
|
+
var mkdir = require_mkdirs();
|
|
1836
|
+
function createFile(file, callback) {
|
|
1837
|
+
function makeFile() {
|
|
1838
|
+
fs4.writeFile(file, "", (err) => {
|
|
1839
|
+
if (err) return callback(err);
|
|
1840
|
+
callback();
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
fs4.stat(file, (err, stats) => {
|
|
1844
|
+
if (!err && stats.isFile()) return callback();
|
|
1845
|
+
const dir = path4.dirname(file);
|
|
1846
|
+
fs4.stat(dir, (err2, stats2) => {
|
|
1847
|
+
if (err2) {
|
|
1848
|
+
if (err2.code === "ENOENT") {
|
|
1849
|
+
return mkdir.mkdirs(dir, (err3) => {
|
|
1850
|
+
if (err3) return callback(err3);
|
|
1851
|
+
makeFile();
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
return callback(err2);
|
|
1855
|
+
}
|
|
1856
|
+
if (stats2.isDirectory()) makeFile();
|
|
1857
|
+
else {
|
|
1858
|
+
fs4.readdir(dir, (err3) => {
|
|
1859
|
+
if (err3) return callback(err3);
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
});
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
function createFileSync(file) {
|
|
1866
|
+
let stats;
|
|
1867
|
+
try {
|
|
1868
|
+
stats = fs4.statSync(file);
|
|
1869
|
+
} catch {
|
|
1870
|
+
}
|
|
1871
|
+
if (stats && stats.isFile()) return;
|
|
1872
|
+
const dir = path4.dirname(file);
|
|
1873
|
+
try {
|
|
1874
|
+
if (!fs4.statSync(dir).isDirectory()) {
|
|
1875
|
+
fs4.readdirSync(dir);
|
|
1876
|
+
}
|
|
1877
|
+
} catch (err) {
|
|
1878
|
+
if (err && err.code === "ENOENT") mkdir.mkdirsSync(dir);
|
|
1879
|
+
else throw err;
|
|
1880
|
+
}
|
|
1881
|
+
fs4.writeFileSync(file, "");
|
|
1882
|
+
}
|
|
1883
|
+
module2.exports = {
|
|
1884
|
+
createFile: u(createFile),
|
|
1885
|
+
createFileSync
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
});
|
|
1889
|
+
|
|
1890
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/link.js
|
|
1891
|
+
var require_link = __commonJS({
|
|
1892
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/link.js"(exports2, module2) {
|
|
1893
|
+
"use strict";
|
|
1894
|
+
var u = require_universalify().fromCallback;
|
|
1895
|
+
var path4 = require("path");
|
|
1896
|
+
var fs4 = require_graceful_fs();
|
|
1897
|
+
var mkdir = require_mkdirs();
|
|
1898
|
+
var pathExists = require_path_exists().pathExists;
|
|
1899
|
+
var { areIdentical } = require_stat();
|
|
1900
|
+
function createLink(srcpath, dstpath, callback) {
|
|
1901
|
+
function makeLink(srcpath2, dstpath2) {
|
|
1902
|
+
fs4.link(srcpath2, dstpath2, (err) => {
|
|
1903
|
+
if (err) return callback(err);
|
|
1904
|
+
callback(null);
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
fs4.lstat(dstpath, (_, dstStat) => {
|
|
1908
|
+
fs4.lstat(srcpath, (err, srcStat) => {
|
|
1909
|
+
if (err) {
|
|
1910
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
1911
|
+
return callback(err);
|
|
1912
|
+
}
|
|
1913
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return callback(null);
|
|
1914
|
+
const dir = path4.dirname(dstpath);
|
|
1915
|
+
pathExists(dir, (err2, dirExists) => {
|
|
1916
|
+
if (err2) return callback(err2);
|
|
1917
|
+
if (dirExists) return makeLink(srcpath, dstpath);
|
|
1918
|
+
mkdir.mkdirs(dir, (err3) => {
|
|
1919
|
+
if (err3) return callback(err3);
|
|
1920
|
+
makeLink(srcpath, dstpath);
|
|
1921
|
+
});
|
|
1922
|
+
});
|
|
1923
|
+
});
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
function createLinkSync(srcpath, dstpath) {
|
|
1927
|
+
let dstStat;
|
|
1928
|
+
try {
|
|
1929
|
+
dstStat = fs4.lstatSync(dstpath);
|
|
1930
|
+
} catch {
|
|
1931
|
+
}
|
|
1932
|
+
try {
|
|
1933
|
+
const srcStat = fs4.lstatSync(srcpath);
|
|
1934
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return;
|
|
1935
|
+
} catch (err) {
|
|
1936
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
1937
|
+
throw err;
|
|
1938
|
+
}
|
|
1939
|
+
const dir = path4.dirname(dstpath);
|
|
1940
|
+
const dirExists = fs4.existsSync(dir);
|
|
1941
|
+
if (dirExists) return fs4.linkSync(srcpath, dstpath);
|
|
1942
|
+
mkdir.mkdirsSync(dir);
|
|
1943
|
+
return fs4.linkSync(srcpath, dstpath);
|
|
1944
|
+
}
|
|
1945
|
+
module2.exports = {
|
|
1946
|
+
createLink: u(createLink),
|
|
1947
|
+
createLinkSync
|
|
1948
|
+
};
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
|
|
1952
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/symlink-paths.js
|
|
1953
|
+
var require_symlink_paths = __commonJS({
|
|
1954
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/symlink-paths.js"(exports2, module2) {
|
|
1955
|
+
"use strict";
|
|
1956
|
+
var path4 = require("path");
|
|
1957
|
+
var fs4 = require_graceful_fs();
|
|
1958
|
+
var pathExists = require_path_exists().pathExists;
|
|
1959
|
+
function symlinkPaths(srcpath, dstpath, callback) {
|
|
1960
|
+
if (path4.isAbsolute(srcpath)) {
|
|
1961
|
+
return fs4.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 = path4.dirname(dstpath);
|
|
1973
|
+
const relativeToDst = path4.join(dstdir, srcpath);
|
|
1974
|
+
return pathExists(relativeToDst, (err, exists) => {
|
|
1975
|
+
if (err) return callback(err);
|
|
1976
|
+
if (exists) {
|
|
1977
|
+
return callback(null, {
|
|
1978
|
+
toCwd: relativeToDst,
|
|
1979
|
+
toDst: srcpath
|
|
1980
|
+
});
|
|
1981
|
+
} else {
|
|
1982
|
+
return fs4.lstat(srcpath, (err2) => {
|
|
1983
|
+
if (err2) {
|
|
1984
|
+
err2.message = err2.message.replace("lstat", "ensureSymlink");
|
|
1985
|
+
return callback(err2);
|
|
1986
|
+
}
|
|
1987
|
+
return callback(null, {
|
|
1988
|
+
toCwd: srcpath,
|
|
1989
|
+
toDst: path4.relative(dstdir, srcpath)
|
|
1990
|
+
});
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
function symlinkPathsSync(srcpath, dstpath) {
|
|
1997
|
+
let exists;
|
|
1998
|
+
if (path4.isAbsolute(srcpath)) {
|
|
1999
|
+
exists = fs4.existsSync(srcpath);
|
|
2000
|
+
if (!exists) throw new Error("absolute srcpath does not exist");
|
|
2001
|
+
return {
|
|
2002
|
+
toCwd: srcpath,
|
|
2003
|
+
toDst: srcpath
|
|
2004
|
+
};
|
|
2005
|
+
} else {
|
|
2006
|
+
const dstdir = path4.dirname(dstpath);
|
|
2007
|
+
const relativeToDst = path4.join(dstdir, srcpath);
|
|
2008
|
+
exists = fs4.existsSync(relativeToDst);
|
|
2009
|
+
if (exists) {
|
|
2010
|
+
return {
|
|
2011
|
+
toCwd: relativeToDst,
|
|
2012
|
+
toDst: srcpath
|
|
2013
|
+
};
|
|
2014
|
+
} else {
|
|
2015
|
+
exists = fs4.existsSync(srcpath);
|
|
2016
|
+
if (!exists) throw new Error("relative srcpath does not exist");
|
|
2017
|
+
return {
|
|
2018
|
+
toCwd: srcpath,
|
|
2019
|
+
toDst: path4.relative(dstdir, srcpath)
|
|
2020
|
+
};
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
module2.exports = {
|
|
2025
|
+
symlinkPaths,
|
|
2026
|
+
symlinkPathsSync
|
|
2027
|
+
};
|
|
2028
|
+
}
|
|
2029
|
+
});
|
|
2030
|
+
|
|
2031
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/symlink-type.js
|
|
2032
|
+
var require_symlink_type = __commonJS({
|
|
2033
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/symlink-type.js"(exports2, module2) {
|
|
2034
|
+
"use strict";
|
|
2035
|
+
var fs4 = require_graceful_fs();
|
|
2036
|
+
function symlinkType(srcpath, type, callback) {
|
|
2037
|
+
callback = typeof type === "function" ? type : callback;
|
|
2038
|
+
type = typeof type === "function" ? false : type;
|
|
2039
|
+
if (type) return callback(null, type);
|
|
2040
|
+
fs4.lstat(srcpath, (err, stats) => {
|
|
2041
|
+
if (err) return callback(null, "file");
|
|
2042
|
+
type = stats && stats.isDirectory() ? "dir" : "file";
|
|
2043
|
+
callback(null, type);
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
function symlinkTypeSync(srcpath, type) {
|
|
2047
|
+
let stats;
|
|
2048
|
+
if (type) return type;
|
|
2049
|
+
try {
|
|
2050
|
+
stats = fs4.lstatSync(srcpath);
|
|
2051
|
+
} catch {
|
|
2052
|
+
return "file";
|
|
2053
|
+
}
|
|
2054
|
+
return stats && stats.isDirectory() ? "dir" : "file";
|
|
2055
|
+
}
|
|
2056
|
+
module2.exports = {
|
|
2057
|
+
symlinkType,
|
|
2058
|
+
symlinkTypeSync
|
|
2059
|
+
};
|
|
2060
|
+
}
|
|
2061
|
+
});
|
|
2062
|
+
|
|
2063
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/symlink.js
|
|
2064
|
+
var require_symlink = __commonJS({
|
|
2065
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/symlink.js"(exports2, module2) {
|
|
2066
|
+
"use strict";
|
|
2067
|
+
var u = require_universalify().fromCallback;
|
|
2068
|
+
var path4 = require("path");
|
|
2069
|
+
var fs4 = require_fs();
|
|
2070
|
+
var _mkdirs = require_mkdirs();
|
|
2071
|
+
var mkdirs = _mkdirs.mkdirs;
|
|
2072
|
+
var mkdirsSync = _mkdirs.mkdirsSync;
|
|
2073
|
+
var _symlinkPaths = require_symlink_paths();
|
|
2074
|
+
var symlinkPaths = _symlinkPaths.symlinkPaths;
|
|
2075
|
+
var symlinkPathsSync = _symlinkPaths.symlinkPathsSync;
|
|
2076
|
+
var _symlinkType = require_symlink_type();
|
|
2077
|
+
var symlinkType = _symlinkType.symlinkType;
|
|
2078
|
+
var symlinkTypeSync = _symlinkType.symlinkTypeSync;
|
|
2079
|
+
var pathExists = require_path_exists().pathExists;
|
|
2080
|
+
var { areIdentical } = require_stat();
|
|
2081
|
+
function createSymlink(srcpath, dstpath, type, callback) {
|
|
2082
|
+
callback = typeof type === "function" ? type : callback;
|
|
2083
|
+
type = typeof type === "function" ? false : type;
|
|
2084
|
+
fs4.lstat(dstpath, (err, stats) => {
|
|
2085
|
+
if (!err && stats.isSymbolicLink()) {
|
|
2086
|
+
Promise.all([
|
|
2087
|
+
fs4.stat(srcpath),
|
|
2088
|
+
fs4.stat(dstpath)
|
|
2089
|
+
]).then(([srcStat, dstStat]) => {
|
|
2090
|
+
if (areIdentical(srcStat, dstStat)) return callback(null);
|
|
2091
|
+
_createSymlink(srcpath, dstpath, type, callback);
|
|
2092
|
+
});
|
|
2093
|
+
} else _createSymlink(srcpath, dstpath, type, callback);
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
function _createSymlink(srcpath, dstpath, type, callback) {
|
|
2097
|
+
symlinkPaths(srcpath, dstpath, (err, relative) => {
|
|
2098
|
+
if (err) return callback(err);
|
|
2099
|
+
srcpath = relative.toDst;
|
|
2100
|
+
symlinkType(relative.toCwd, type, (err2, type2) => {
|
|
2101
|
+
if (err2) return callback(err2);
|
|
2102
|
+
const dir = path4.dirname(dstpath);
|
|
2103
|
+
pathExists(dir, (err3, dirExists) => {
|
|
2104
|
+
if (err3) return callback(err3);
|
|
2105
|
+
if (dirExists) return fs4.symlink(srcpath, dstpath, type2, callback);
|
|
2106
|
+
mkdirs(dir, (err4) => {
|
|
2107
|
+
if (err4) return callback(err4);
|
|
2108
|
+
fs4.symlink(srcpath, dstpath, type2, callback);
|
|
2109
|
+
});
|
|
2110
|
+
});
|
|
2111
|
+
});
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
function createSymlinkSync(srcpath, dstpath, type) {
|
|
2115
|
+
let stats;
|
|
2116
|
+
try {
|
|
2117
|
+
stats = fs4.lstatSync(dstpath);
|
|
2118
|
+
} catch {
|
|
2119
|
+
}
|
|
2120
|
+
if (stats && stats.isSymbolicLink()) {
|
|
2121
|
+
const srcStat = fs4.statSync(srcpath);
|
|
2122
|
+
const dstStat = fs4.statSync(dstpath);
|
|
2123
|
+
if (areIdentical(srcStat, dstStat)) return;
|
|
2124
|
+
}
|
|
2125
|
+
const relative = symlinkPathsSync(srcpath, dstpath);
|
|
2126
|
+
srcpath = relative.toDst;
|
|
2127
|
+
type = symlinkTypeSync(relative.toCwd, type);
|
|
2128
|
+
const dir = path4.dirname(dstpath);
|
|
2129
|
+
const exists = fs4.existsSync(dir);
|
|
2130
|
+
if (exists) return fs4.symlinkSync(srcpath, dstpath, type);
|
|
2131
|
+
mkdirsSync(dir);
|
|
2132
|
+
return fs4.symlinkSync(srcpath, dstpath, type);
|
|
2133
|
+
}
|
|
2134
|
+
module2.exports = {
|
|
2135
|
+
createSymlink: u(createSymlink),
|
|
2136
|
+
createSymlinkSync
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
|
|
2141
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/index.js
|
|
2142
|
+
var require_ensure = __commonJS({
|
|
2143
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/ensure/index.js"(exports2, module2) {
|
|
2144
|
+
"use strict";
|
|
2145
|
+
var { createFile, createFileSync } = require_file();
|
|
2146
|
+
var { createLink, createLinkSync } = require_link();
|
|
2147
|
+
var { createSymlink, createSymlinkSync } = require_symlink();
|
|
2148
|
+
module2.exports = {
|
|
2149
|
+
// file
|
|
2150
|
+
createFile,
|
|
2151
|
+
createFileSync,
|
|
2152
|
+
ensureFile: createFile,
|
|
2153
|
+
ensureFileSync: createFileSync,
|
|
2154
|
+
// link
|
|
2155
|
+
createLink,
|
|
2156
|
+
createLinkSync,
|
|
2157
|
+
ensureLink: createLink,
|
|
2158
|
+
ensureLinkSync: createLinkSync,
|
|
2159
|
+
// symlink
|
|
2160
|
+
createSymlink,
|
|
2161
|
+
createSymlinkSync,
|
|
2162
|
+
ensureSymlink: createSymlink,
|
|
2163
|
+
ensureSymlinkSync: createSymlinkSync
|
|
2164
|
+
};
|
|
2165
|
+
}
|
|
2166
|
+
});
|
|
2167
|
+
|
|
2168
|
+
// ../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/utils.js
|
|
2169
|
+
var require_utils2 = __commonJS({
|
|
2170
|
+
"../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/utils.js"(exports2, module2) {
|
|
2171
|
+
"use strict";
|
|
2172
|
+
function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
|
|
2173
|
+
const EOF = finalEOL ? EOL : "";
|
|
2174
|
+
const str = JSON.stringify(obj, replacer, spaces);
|
|
2175
|
+
return str.replace(/\n/g, EOL) + EOF;
|
|
2176
|
+
}
|
|
2177
|
+
function stripBom(content) {
|
|
2178
|
+
if (Buffer.isBuffer(content)) content = content.toString("utf8");
|
|
2179
|
+
return content.replace(/^\uFEFF/, "");
|
|
2180
|
+
}
|
|
2181
|
+
module2.exports = { stringify, stripBom };
|
|
2182
|
+
}
|
|
2183
|
+
});
|
|
2184
|
+
|
|
2185
|
+
// ../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/index.js
|
|
2186
|
+
var require_jsonfile = __commonJS({
|
|
2187
|
+
"../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/index.js"(exports2, module2) {
|
|
2188
|
+
"use strict";
|
|
2189
|
+
var _fs;
|
|
2190
|
+
try {
|
|
2191
|
+
_fs = require_graceful_fs();
|
|
2192
|
+
} catch (_) {
|
|
2193
|
+
_fs = require("fs");
|
|
2194
|
+
}
|
|
2195
|
+
var universalify = require_universalify();
|
|
2196
|
+
var { stringify, stripBom } = require_utils2();
|
|
2197
|
+
async function _readFile(file, options = {}) {
|
|
2198
|
+
if (typeof options === "string") {
|
|
2199
|
+
options = { encoding: options };
|
|
2200
|
+
}
|
|
2201
|
+
const fs4 = options.fs || _fs;
|
|
2202
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
2203
|
+
let data = await universalify.fromCallback(fs4.readFile)(file, options);
|
|
2204
|
+
data = stripBom(data);
|
|
2205
|
+
let obj;
|
|
2206
|
+
try {
|
|
2207
|
+
obj = JSON.parse(data, options ? options.reviver : null);
|
|
2208
|
+
} catch (err) {
|
|
2209
|
+
if (shouldThrow) {
|
|
2210
|
+
err.message = `${file}: ${err.message}`;
|
|
2211
|
+
throw err;
|
|
2212
|
+
} else {
|
|
2213
|
+
return null;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
return obj;
|
|
2217
|
+
}
|
|
2218
|
+
var readFile = universalify.fromPromise(_readFile);
|
|
2219
|
+
function readFileSync(file, options = {}) {
|
|
2220
|
+
if (typeof options === "string") {
|
|
2221
|
+
options = { encoding: options };
|
|
2222
|
+
}
|
|
2223
|
+
const fs4 = options.fs || _fs;
|
|
2224
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
2225
|
+
try {
|
|
2226
|
+
let content = fs4.readFileSync(file, options);
|
|
2227
|
+
content = stripBom(content);
|
|
2228
|
+
return JSON.parse(content, options.reviver);
|
|
2229
|
+
} catch (err) {
|
|
2230
|
+
if (shouldThrow) {
|
|
2231
|
+
err.message = `${file}: ${err.message}`;
|
|
2232
|
+
throw err;
|
|
2233
|
+
} else {
|
|
2234
|
+
return null;
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
async function _writeFile(file, obj, options = {}) {
|
|
2239
|
+
const fs4 = options.fs || _fs;
|
|
2240
|
+
const str = stringify(obj, options);
|
|
2241
|
+
await universalify.fromCallback(fs4.writeFile)(file, str, options);
|
|
2242
|
+
}
|
|
2243
|
+
var writeFile = universalify.fromPromise(_writeFile);
|
|
2244
|
+
function writeFileSync(file, obj, options = {}) {
|
|
2245
|
+
const fs4 = options.fs || _fs;
|
|
2246
|
+
const str = stringify(obj, options);
|
|
2247
|
+
return fs4.writeFileSync(file, str, options);
|
|
2248
|
+
}
|
|
2249
|
+
var jsonfile = {
|
|
2250
|
+
readFile,
|
|
2251
|
+
readFileSync,
|
|
2252
|
+
writeFile,
|
|
2253
|
+
writeFileSync
|
|
2254
|
+
};
|
|
2255
|
+
module2.exports = jsonfile;
|
|
2256
|
+
}
|
|
2257
|
+
});
|
|
2258
|
+
|
|
2259
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/json/jsonfile.js
|
|
2260
|
+
var require_jsonfile2 = __commonJS({
|
|
2261
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/json/jsonfile.js"(exports2, module2) {
|
|
2262
|
+
"use strict";
|
|
2263
|
+
var jsonFile = require_jsonfile();
|
|
2264
|
+
module2.exports = {
|
|
2265
|
+
// jsonfile exports
|
|
2266
|
+
readJson: jsonFile.readFile,
|
|
2267
|
+
readJsonSync: jsonFile.readFileSync,
|
|
2268
|
+
writeJson: jsonFile.writeFile,
|
|
2269
|
+
writeJsonSync: jsonFile.writeFileSync
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2272
|
+
});
|
|
2273
|
+
|
|
2274
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/output-file/index.js
|
|
2275
|
+
var require_output_file = __commonJS({
|
|
2276
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/output-file/index.js"(exports2, module2) {
|
|
2277
|
+
"use strict";
|
|
2278
|
+
var u = require_universalify().fromCallback;
|
|
2279
|
+
var fs4 = require_graceful_fs();
|
|
2280
|
+
var path4 = require("path");
|
|
2281
|
+
var mkdir = require_mkdirs();
|
|
2282
|
+
var pathExists = require_path_exists().pathExists;
|
|
2283
|
+
function outputFile(file, data, encoding, callback) {
|
|
2284
|
+
if (typeof encoding === "function") {
|
|
2285
|
+
callback = encoding;
|
|
2286
|
+
encoding = "utf8";
|
|
2287
|
+
}
|
|
2288
|
+
const dir = path4.dirname(file);
|
|
2289
|
+
pathExists(dir, (err, itDoes) => {
|
|
2290
|
+
if (err) return callback(err);
|
|
2291
|
+
if (itDoes) return fs4.writeFile(file, data, encoding, callback);
|
|
2292
|
+
mkdir.mkdirs(dir, (err2) => {
|
|
2293
|
+
if (err2) return callback(err2);
|
|
2294
|
+
fs4.writeFile(file, data, encoding, callback);
|
|
2295
|
+
});
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
function outputFileSync(file, ...args) {
|
|
2299
|
+
const dir = path4.dirname(file);
|
|
2300
|
+
if (fs4.existsSync(dir)) {
|
|
2301
|
+
return fs4.writeFileSync(file, ...args);
|
|
2302
|
+
}
|
|
2303
|
+
mkdir.mkdirsSync(dir);
|
|
2304
|
+
fs4.writeFileSync(file, ...args);
|
|
2305
|
+
}
|
|
2306
|
+
module2.exports = {
|
|
2307
|
+
outputFile: u(outputFile),
|
|
2308
|
+
outputFileSync
|
|
2309
|
+
};
|
|
2310
|
+
}
|
|
2311
|
+
});
|
|
2312
|
+
|
|
2313
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/json/output-json.js
|
|
2314
|
+
var require_output_json = __commonJS({
|
|
2315
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/json/output-json.js"(exports2, module2) {
|
|
2316
|
+
"use strict";
|
|
2317
|
+
var { stringify } = require_utils2();
|
|
2318
|
+
var { outputFile } = require_output_file();
|
|
2319
|
+
async function outputJson(file, data, options = {}) {
|
|
2320
|
+
const str = stringify(data, options);
|
|
2321
|
+
await outputFile(file, str, options);
|
|
2322
|
+
}
|
|
2323
|
+
module2.exports = outputJson;
|
|
2324
|
+
}
|
|
2325
|
+
});
|
|
2326
|
+
|
|
2327
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/json/output-json-sync.js
|
|
2328
|
+
var require_output_json_sync = __commonJS({
|
|
2329
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/json/output-json-sync.js"(exports2, module2) {
|
|
2330
|
+
"use strict";
|
|
2331
|
+
var { stringify } = require_utils2();
|
|
2332
|
+
var { outputFileSync } = require_output_file();
|
|
2333
|
+
function outputJsonSync(file, data, options) {
|
|
2334
|
+
const str = stringify(data, options);
|
|
2335
|
+
outputFileSync(file, str, options);
|
|
2336
|
+
}
|
|
2337
|
+
module2.exports = outputJsonSync;
|
|
2338
|
+
}
|
|
2339
|
+
});
|
|
2340
|
+
|
|
2341
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/json/index.js
|
|
2342
|
+
var require_json = __commonJS({
|
|
2343
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/json/index.js"(exports2, module2) {
|
|
2344
|
+
"use strict";
|
|
2345
|
+
var u = require_universalify().fromPromise;
|
|
2346
|
+
var jsonFile = require_jsonfile2();
|
|
2347
|
+
jsonFile.outputJson = u(require_output_json());
|
|
2348
|
+
jsonFile.outputJsonSync = require_output_json_sync();
|
|
2349
|
+
jsonFile.outputJSON = jsonFile.outputJson;
|
|
2350
|
+
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
|
|
2351
|
+
jsonFile.writeJSON = jsonFile.writeJson;
|
|
2352
|
+
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
|
|
2353
|
+
jsonFile.readJSON = jsonFile.readJson;
|
|
2354
|
+
jsonFile.readJSONSync = jsonFile.readJsonSync;
|
|
2355
|
+
module2.exports = jsonFile;
|
|
2356
|
+
}
|
|
2357
|
+
});
|
|
2358
|
+
|
|
2359
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/move/move.js
|
|
2360
|
+
var require_move = __commonJS({
|
|
2361
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/move/move.js"(exports2, module2) {
|
|
2362
|
+
"use strict";
|
|
2363
|
+
var fs4 = require_graceful_fs();
|
|
2364
|
+
var path4 = require("path");
|
|
2365
|
+
var copy = require_copy2().copy;
|
|
2366
|
+
var remove = require_remove().remove;
|
|
2367
|
+
var mkdirp = require_mkdirs().mkdirp;
|
|
2368
|
+
var pathExists = require_path_exists().pathExists;
|
|
2369
|
+
var stat = require_stat();
|
|
2370
|
+
function move(src, dest, opts, cb) {
|
|
2371
|
+
if (typeof opts === "function") {
|
|
2372
|
+
cb = opts;
|
|
2373
|
+
opts = {};
|
|
2374
|
+
}
|
|
2375
|
+
opts = opts || {};
|
|
2376
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
2377
|
+
stat.checkPaths(src, dest, "move", opts, (err, stats) => {
|
|
2378
|
+
if (err) return cb(err);
|
|
2379
|
+
const { srcStat, isChangingCase = false } = stats;
|
|
2380
|
+
stat.checkParentPaths(src, srcStat, dest, "move", (err2) => {
|
|
2381
|
+
if (err2) return cb(err2);
|
|
2382
|
+
if (isParentRoot(dest)) return doRename(src, dest, overwrite, isChangingCase, cb);
|
|
2383
|
+
mkdirp(path4.dirname(dest), (err3) => {
|
|
2384
|
+
if (err3) return cb(err3);
|
|
2385
|
+
return doRename(src, dest, overwrite, isChangingCase, cb);
|
|
2386
|
+
});
|
|
2387
|
+
});
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
function isParentRoot(dest) {
|
|
2391
|
+
const parent = path4.dirname(dest);
|
|
2392
|
+
const parsedPath = path4.parse(parent);
|
|
2393
|
+
return parsedPath.root === parent;
|
|
2394
|
+
}
|
|
2395
|
+
function doRename(src, dest, overwrite, isChangingCase, cb) {
|
|
2396
|
+
if (isChangingCase) return rename(src, dest, overwrite, cb);
|
|
2397
|
+
if (overwrite) {
|
|
2398
|
+
return remove(dest, (err) => {
|
|
2399
|
+
if (err) return cb(err);
|
|
2400
|
+
return rename(src, dest, overwrite, cb);
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2403
|
+
pathExists(dest, (err, destExists) => {
|
|
2404
|
+
if (err) return cb(err);
|
|
2405
|
+
if (destExists) return cb(new Error("dest already exists."));
|
|
2406
|
+
return rename(src, dest, overwrite, cb);
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
function rename(src, dest, overwrite, cb) {
|
|
2410
|
+
fs4.rename(src, dest, (err) => {
|
|
2411
|
+
if (!err) return cb();
|
|
2412
|
+
if (err.code !== "EXDEV") return cb(err);
|
|
2413
|
+
return moveAcrossDevice(src, dest, overwrite, cb);
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
function moveAcrossDevice(src, dest, overwrite, cb) {
|
|
2417
|
+
const opts = {
|
|
2418
|
+
overwrite,
|
|
2419
|
+
errorOnExist: true
|
|
2420
|
+
};
|
|
2421
|
+
copy(src, dest, opts, (err) => {
|
|
2422
|
+
if (err) return cb(err);
|
|
2423
|
+
return remove(src, cb);
|
|
2424
|
+
});
|
|
2425
|
+
}
|
|
2426
|
+
module2.exports = move;
|
|
2427
|
+
}
|
|
2428
|
+
});
|
|
2429
|
+
|
|
2430
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/move/move-sync.js
|
|
2431
|
+
var require_move_sync = __commonJS({
|
|
2432
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/move/move-sync.js"(exports2, module2) {
|
|
2433
|
+
"use strict";
|
|
2434
|
+
var fs4 = require_graceful_fs();
|
|
2435
|
+
var path4 = require("path");
|
|
2436
|
+
var copySync = require_copy2().copySync;
|
|
2437
|
+
var removeSync = require_remove().removeSync;
|
|
2438
|
+
var mkdirpSync = require_mkdirs().mkdirpSync;
|
|
2439
|
+
var stat = require_stat();
|
|
2440
|
+
function moveSync(src, dest, opts) {
|
|
2441
|
+
opts = opts || {};
|
|
2442
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
2443
|
+
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
|
|
2444
|
+
stat.checkParentPathsSync(src, srcStat, dest, "move");
|
|
2445
|
+
if (!isParentRoot(dest)) mkdirpSync(path4.dirname(dest));
|
|
2446
|
+
return doRename(src, dest, overwrite, isChangingCase);
|
|
2447
|
+
}
|
|
2448
|
+
function isParentRoot(dest) {
|
|
2449
|
+
const parent = path4.dirname(dest);
|
|
2450
|
+
const parsedPath = path4.parse(parent);
|
|
2451
|
+
return parsedPath.root === parent;
|
|
2452
|
+
}
|
|
2453
|
+
function doRename(src, dest, overwrite, isChangingCase) {
|
|
2454
|
+
if (isChangingCase) return rename(src, dest, overwrite);
|
|
2455
|
+
if (overwrite) {
|
|
2456
|
+
removeSync(dest);
|
|
2457
|
+
return rename(src, dest, overwrite);
|
|
2458
|
+
}
|
|
2459
|
+
if (fs4.existsSync(dest)) throw new Error("dest already exists.");
|
|
2460
|
+
return rename(src, dest, overwrite);
|
|
2461
|
+
}
|
|
2462
|
+
function rename(src, dest, overwrite) {
|
|
2463
|
+
try {
|
|
2464
|
+
fs4.renameSync(src, dest);
|
|
2465
|
+
} catch (err) {
|
|
2466
|
+
if (err.code !== "EXDEV") throw err;
|
|
2467
|
+
return moveAcrossDevice(src, dest, overwrite);
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
function moveAcrossDevice(src, dest, overwrite) {
|
|
2471
|
+
const opts = {
|
|
2472
|
+
overwrite,
|
|
2473
|
+
errorOnExist: true
|
|
2474
|
+
};
|
|
2475
|
+
copySync(src, dest, opts);
|
|
2476
|
+
return removeSync(src);
|
|
2477
|
+
}
|
|
2478
|
+
module2.exports = moveSync;
|
|
2479
|
+
}
|
|
2480
|
+
});
|
|
2481
|
+
|
|
2482
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/move/index.js
|
|
2483
|
+
var require_move2 = __commonJS({
|
|
2484
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/move/index.js"(exports2, module2) {
|
|
2485
|
+
"use strict";
|
|
2486
|
+
var u = require_universalify().fromCallback;
|
|
2487
|
+
module2.exports = {
|
|
2488
|
+
move: u(require_move()),
|
|
2489
|
+
moveSync: require_move_sync()
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
});
|
|
2493
|
+
|
|
2494
|
+
// ../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/index.js
|
|
2495
|
+
var require_lib = __commonJS({
|
|
2496
|
+
"../../node_modules/.pnpm/fs-extra@10.1.0/node_modules/fs-extra/lib/index.js"(exports2, module2) {
|
|
2497
|
+
"use strict";
|
|
2498
|
+
module2.exports = {
|
|
2499
|
+
// Export promiseified graceful-fs:
|
|
2500
|
+
...require_fs(),
|
|
2501
|
+
// Export extra methods:
|
|
2502
|
+
...require_copy2(),
|
|
2503
|
+
...require_empty(),
|
|
2504
|
+
...require_ensure(),
|
|
2505
|
+
...require_json(),
|
|
2506
|
+
...require_mkdirs(),
|
|
2507
|
+
...require_move2(),
|
|
2508
|
+
...require_output_file(),
|
|
2509
|
+
...require_path_exists(),
|
|
2510
|
+
...require_remove()
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
});
|
|
2514
|
+
|
|
2515
|
+
// cli.ts
|
|
2516
|
+
var import_node_process7 = __toESM(require("process"));
|
|
2517
|
+
|
|
2518
|
+
// index.ts
|
|
2519
|
+
var import_node_process6 = __toESM(require("process"));
|
|
2520
|
+
var import_node_fs3 = __toESM(require("fs"));
|
|
2521
|
+
var import_node_os2 = __toESM(require("os"));
|
|
2522
|
+
var import_node_path3 = __toESM(require("path"));
|
|
2523
|
+
var import_fs_extra = __toESM(require_lib());
|
|
2524
|
+
var import_strip_ansi = __toESM(require("strip-ansi"));
|
|
2525
|
+
var import_execa = __toESM(require("execa"));
|
|
2526
|
+
var import_arg = __toESM(require("arg"));
|
|
2527
|
+
var semver = __toESM(require("semver"));
|
|
2528
|
+
var import_sort_package_json = __toESM(require("sort-package-json"));
|
|
2529
|
+
|
|
2530
|
+
// package.json
|
|
2531
|
+
var version = "0.0.0-experimental-16086cbff";
|
|
2532
|
+
|
|
2533
|
+
// prompt.ts
|
|
2534
|
+
var import_node_process3 = __toESM(require("process"));
|
|
2535
|
+
|
|
2536
|
+
// prompts-confirm.ts
|
|
2537
|
+
var import_sisteransi3 = require("sisteransi");
|
|
2538
|
+
|
|
2539
|
+
// prompts-prompt-base.ts
|
|
2540
|
+
var import_node_process2 = __toESM(require("process"));
|
|
2541
|
+
var import_node_events = __toESM(require("events"));
|
|
2542
|
+
var import_node_readline = __toESM(require("readline"));
|
|
2543
|
+
var import_sisteransi2 = require("sisteransi");
|
|
2544
|
+
|
|
2545
|
+
// utils.ts
|
|
2546
|
+
var import_node_path = __toESM(require("path"));
|
|
2547
|
+
var import_node_process = __toESM(require("process"));
|
|
2548
|
+
var import_node_os = __toESM(require("os"));
|
|
2549
|
+
var import_node_fs = __toESM(require("fs"));
|
|
2550
|
+
var import_sisteransi = require("sisteransi");
|
|
2551
|
+
var import_chalk = __toESM(require("chalk"));
|
|
2552
|
+
var import_recursive_readdir = __toESM(require("recursive-readdir"));
|
|
2553
|
+
var SUPPORTS_COLOR = import_chalk.default.supportsColor && !import_node_process.default.env.NO_COLOR;
|
|
2554
|
+
var color = {
|
|
2555
|
+
supportsColor: SUPPORTS_COLOR,
|
|
2556
|
+
heading: safeColor(import_chalk.default.bold),
|
|
2557
|
+
arg: safeColor(import_chalk.default.yellowBright),
|
|
2558
|
+
error: safeColor(import_chalk.default.red),
|
|
2559
|
+
warning: safeColor(import_chalk.default.yellow),
|
|
2560
|
+
hint: safeColor(import_chalk.default.blue),
|
|
2561
|
+
bold: safeColor(import_chalk.default.bold),
|
|
2562
|
+
black: safeColor(import_chalk.default.black),
|
|
2563
|
+
white: safeColor(import_chalk.default.white),
|
|
2564
|
+
blue: safeColor(import_chalk.default.blue),
|
|
2565
|
+
cyan: safeColor(import_chalk.default.cyan),
|
|
2566
|
+
red: safeColor(import_chalk.default.red),
|
|
2567
|
+
yellow: safeColor(import_chalk.default.yellow),
|
|
2568
|
+
green: safeColor(import_chalk.default.green),
|
|
2569
|
+
blackBright: safeColor(import_chalk.default.blackBright),
|
|
2570
|
+
whiteBright: safeColor(import_chalk.default.whiteBright),
|
|
2571
|
+
blueBright: safeColor(import_chalk.default.blueBright),
|
|
2572
|
+
cyanBright: safeColor(import_chalk.default.cyanBright),
|
|
2573
|
+
redBright: safeColor(import_chalk.default.redBright),
|
|
2574
|
+
yellowBright: safeColor(import_chalk.default.yellowBright),
|
|
2575
|
+
greenBright: safeColor(import_chalk.default.greenBright),
|
|
2576
|
+
bgBlack: safeColor(import_chalk.default.bgBlack),
|
|
2577
|
+
bgWhite: safeColor(import_chalk.default.bgWhite),
|
|
2578
|
+
bgBlue: safeColor(import_chalk.default.bgBlue),
|
|
2579
|
+
bgCyan: safeColor(import_chalk.default.bgCyan),
|
|
2580
|
+
bgRed: safeColor(import_chalk.default.bgRed),
|
|
2581
|
+
bgYellow: safeColor(import_chalk.default.bgYellow),
|
|
2582
|
+
bgGreen: safeColor(import_chalk.default.bgGreen),
|
|
2583
|
+
bgBlackBright: safeColor(import_chalk.default.bgBlackBright),
|
|
2584
|
+
bgWhiteBright: safeColor(import_chalk.default.bgWhiteBright),
|
|
2585
|
+
bgBlueBright: safeColor(import_chalk.default.bgBlueBright),
|
|
2586
|
+
bgCyanBright: safeColor(import_chalk.default.bgCyanBright),
|
|
2587
|
+
bgRedBright: safeColor(import_chalk.default.bgRedBright),
|
|
2588
|
+
bgYellowBright: safeColor(import_chalk.default.bgYellowBright),
|
|
2589
|
+
bgGreenBright: safeColor(import_chalk.default.bgGreenBright),
|
|
2590
|
+
gray: safeColor(import_chalk.default.gray),
|
|
2591
|
+
dim: safeColor(import_chalk.default.dim),
|
|
2592
|
+
reset: safeColor(import_chalk.default.reset),
|
|
2593
|
+
inverse: safeColor(import_chalk.default.inverse),
|
|
2594
|
+
hex: (color2) => safeColor(import_chalk.default.hex(color2)),
|
|
2595
|
+
underline: import_chalk.default.underline
|
|
2596
|
+
};
|
|
2597
|
+
function safeColor(style) {
|
|
2598
|
+
return SUPPORTS_COLOR ? style : identity;
|
|
2599
|
+
}
|
|
2600
|
+
var unicode = { enabled: import_node_os.default.platform() !== "win32" };
|
|
2601
|
+
var shouldUseAscii = () => !unicode.enabled;
|
|
2602
|
+
function isInteractive() {
|
|
2603
|
+
if ("CREATE_REACT_ROUTER_FORCE_INTERACTIVE" in import_node_process.default.env) {
|
|
2604
|
+
return true;
|
|
2605
|
+
}
|
|
2606
|
+
return Boolean(
|
|
2607
|
+
import_node_process.default.stdout.isTTY && import_node_process.default.env.TERM !== "dumb" && !("CI" in import_node_process.default.env)
|
|
2608
|
+
);
|
|
2609
|
+
}
|
|
2610
|
+
function log(message) {
|
|
2611
|
+
return import_node_process.default.stdout.write(message + "\n");
|
|
2612
|
+
}
|
|
2613
|
+
var stderr = import_node_process.default.stderr;
|
|
2614
|
+
function logError(message) {
|
|
2615
|
+
return stderr.write(message + "\n");
|
|
2616
|
+
}
|
|
2617
|
+
function logBullet(logger, colorizePrefix, colorizeText, symbol, prefix, text) {
|
|
2618
|
+
let textParts = Array.isArray(text) ? text : [text || ""].filter(Boolean);
|
|
2619
|
+
let formattedText = textParts.map((textPart) => colorizeText(textPart)).join("");
|
|
2620
|
+
if (import_node_process.default.stdout.columns < 80) {
|
|
2621
|
+
logger(
|
|
2622
|
+
`${" ".repeat(5)} ${colorizePrefix(symbol)} ${colorizePrefix(prefix)}`
|
|
2623
|
+
);
|
|
2624
|
+
logger(`${" ".repeat(9)}${formattedText}`);
|
|
2625
|
+
} else {
|
|
2626
|
+
logger(
|
|
2627
|
+
`${" ".repeat(5)} ${colorizePrefix(symbol)} ${colorizePrefix(
|
|
2628
|
+
prefix
|
|
2629
|
+
)} ${formattedText}`
|
|
2630
|
+
);
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
function debug(prefix, text) {
|
|
2634
|
+
logBullet(log, color.yellow, color.dim, "\u25CF", prefix, text);
|
|
2635
|
+
}
|
|
2636
|
+
function info(prefix, text) {
|
|
2637
|
+
logBullet(log, color.cyan, color.dim, "\u25FC", prefix, text);
|
|
2638
|
+
}
|
|
2639
|
+
function error(prefix, text) {
|
|
2640
|
+
log("");
|
|
2641
|
+
logBullet(logError, color.red, color.error, "\u25B2", prefix, text);
|
|
2642
|
+
}
|
|
2643
|
+
function sleep(ms) {
|
|
2644
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2645
|
+
}
|
|
2646
|
+
function toValidProjectName(projectName) {
|
|
2647
|
+
if (isValidProjectName(projectName)) {
|
|
2648
|
+
return projectName;
|
|
2649
|
+
}
|
|
2650
|
+
return projectName.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z\d\-~]+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
2651
|
+
}
|
|
2652
|
+
function isValidProjectName(projectName) {
|
|
2653
|
+
return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(
|
|
2654
|
+
projectName
|
|
2655
|
+
);
|
|
2656
|
+
}
|
|
2657
|
+
function identity(v) {
|
|
2658
|
+
return v;
|
|
2659
|
+
}
|
|
2660
|
+
function strip(str) {
|
|
2661
|
+
let pattern = [
|
|
2662
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
2663
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
|
2664
|
+
].join("|");
|
|
2665
|
+
let RGX = new RegExp(pattern, "g");
|
|
2666
|
+
return typeof str === "string" ? str.replace(RGX, "") : str;
|
|
2667
|
+
}
|
|
2668
|
+
function reverse(arr) {
|
|
2669
|
+
return [...arr].reverse();
|
|
2670
|
+
}
|
|
2671
|
+
function isValidJsonObject(obj) {
|
|
2672
|
+
return !!(obj && typeof obj === "object" && !Array.isArray(obj));
|
|
2673
|
+
}
|
|
2674
|
+
async function directoryExists(p) {
|
|
2675
|
+
try {
|
|
2676
|
+
let stat = await import_node_fs.default.promises.stat(p);
|
|
2677
|
+
return stat.isDirectory();
|
|
2678
|
+
} catch {
|
|
2679
|
+
return false;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
async function ensureDirectory(dir) {
|
|
2683
|
+
if (!await directoryExists(dir)) {
|
|
2684
|
+
await import_node_fs.default.promises.mkdir(dir, { recursive: true });
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
function isUrl(value) {
|
|
2688
|
+
try {
|
|
2689
|
+
new URL(value);
|
|
2690
|
+
return true;
|
|
2691
|
+
} catch (_) {
|
|
2692
|
+
return false;
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
function clear(prompt2, perLine) {
|
|
2696
|
+
if (!perLine) return import_sisteransi.erase.line + import_sisteransi.cursor.to(0);
|
|
2697
|
+
let rows = 0;
|
|
2698
|
+
let lines2 = prompt2.split(/\r?\n/);
|
|
2699
|
+
for (let line of lines2) {
|
|
2700
|
+
rows += 1 + Math.floor(Math.max(strip(line).length - 1, 0) / perLine);
|
|
2701
|
+
}
|
|
2702
|
+
return import_sisteransi.erase.lines(rows);
|
|
2703
|
+
}
|
|
2704
|
+
function lines(msg, perLine) {
|
|
2705
|
+
let lines2 = String(strip(msg) || "").split(/\r?\n/);
|
|
2706
|
+
if (!perLine) return lines2.length;
|
|
2707
|
+
return lines2.map((l) => Math.ceil(l.length / perLine)).reduce((a, b) => a + b);
|
|
2708
|
+
}
|
|
2709
|
+
function action(key, isSelect) {
|
|
2710
|
+
if (key.meta && key.name !== "escape") return;
|
|
2711
|
+
if (key.ctrl) {
|
|
2712
|
+
if (key.name === "a") return "first";
|
|
2713
|
+
if (key.name === "c") return "abort";
|
|
2714
|
+
if (key.name === "d") return "abort";
|
|
2715
|
+
if (key.name === "e") return "last";
|
|
2716
|
+
if (key.name === "g") return "reset";
|
|
2717
|
+
}
|
|
2718
|
+
if (isSelect) {
|
|
2719
|
+
if (key.name === "j") return "down";
|
|
2720
|
+
if (key.name === "k") return "up";
|
|
2721
|
+
}
|
|
2722
|
+
if (key.name === "return") return "submit";
|
|
2723
|
+
if (key.name === "enter") return "submit";
|
|
2724
|
+
if (key.name === "backspace") return "delete";
|
|
2725
|
+
if (key.name === "delete") return "deleteForward";
|
|
2726
|
+
if (key.name === "abort") return "abort";
|
|
2727
|
+
if (key.name === "escape") return "exit";
|
|
2728
|
+
if (key.name === "tab") return "next";
|
|
2729
|
+
if (key.name === "pagedown") return "nextPage";
|
|
2730
|
+
if (key.name === "pageup") return "prevPage";
|
|
2731
|
+
if (key.name === "home") return "home";
|
|
2732
|
+
if (key.name === "end") return "end";
|
|
2733
|
+
if (key.name === "up") return "up";
|
|
2734
|
+
if (key.name === "down") return "down";
|
|
2735
|
+
if (key.name === "right") return "right";
|
|
2736
|
+
if (key.name === "left") return "left";
|
|
2737
|
+
return false;
|
|
2738
|
+
}
|
|
2739
|
+
function stripDirectoryFromPath(dir, filePath) {
|
|
2740
|
+
let stripped = filePath;
|
|
2741
|
+
if (dir.endsWith(import_node_path.default.sep) && filePath.startsWith(dir) || !dir.endsWith(import_node_path.default.sep) && filePath.startsWith(dir + import_node_path.default.sep)) {
|
|
2742
|
+
stripped = filePath.slice(dir.length);
|
|
2743
|
+
if (stripped.startsWith(import_node_path.default.sep)) {
|
|
2744
|
+
stripped = stripped.slice(1);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
return stripped;
|
|
2748
|
+
}
|
|
2749
|
+
var IGNORED_TEMPLATE_DIRECTORIES = [".git", "node_modules"];
|
|
2750
|
+
async function getDirectoryFilesRecursive(dir) {
|
|
2751
|
+
let files = await (0, import_recursive_readdir.default)(dir, [
|
|
2752
|
+
(file) => {
|
|
2753
|
+
let strippedFile = stripDirectoryFromPath(dir, file);
|
|
2754
|
+
let parts = strippedFile.split(import_node_path.default.sep);
|
|
2755
|
+
return parts.length > 1 && IGNORED_TEMPLATE_DIRECTORIES.includes(parts[0]);
|
|
2756
|
+
}
|
|
2757
|
+
]);
|
|
2758
|
+
return files.map((f) => stripDirectoryFromPath(dir, f));
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
// prompts-prompt-base.ts
|
|
2762
|
+
var Prompt = class extends import_node_events.default {
|
|
2763
|
+
firstRender;
|
|
2764
|
+
in;
|
|
2765
|
+
out;
|
|
2766
|
+
onRender;
|
|
2767
|
+
close;
|
|
2768
|
+
aborted;
|
|
2769
|
+
exited;
|
|
2770
|
+
closed;
|
|
2771
|
+
name = "Prompt";
|
|
2772
|
+
constructor(opts = {}) {
|
|
2773
|
+
super();
|
|
2774
|
+
this.firstRender = true;
|
|
2775
|
+
this.in = opts.stdin || import_node_process2.default.stdin;
|
|
2776
|
+
this.out = opts.stdout || import_node_process2.default.stdout;
|
|
2777
|
+
this.onRender = (opts.onRender || (() => void 0)).bind(this);
|
|
2778
|
+
let rl = import_node_readline.default.createInterface({
|
|
2779
|
+
input: this.in,
|
|
2780
|
+
escapeCodeTimeout: 50
|
|
2781
|
+
});
|
|
2782
|
+
import_node_readline.default.emitKeypressEvents(this.in, rl);
|
|
2783
|
+
if (this.in.isTTY) this.in.setRawMode(true);
|
|
2784
|
+
let isSelect = ["SelectPrompt", "MultiSelectPrompt"].indexOf(this.constructor.name) > -1;
|
|
2785
|
+
let keypress = (str, key) => {
|
|
2786
|
+
if (this.in.isTTY) this.in.setRawMode(true);
|
|
2787
|
+
let a = action(key, isSelect);
|
|
2788
|
+
if (a === false) {
|
|
2789
|
+
try {
|
|
2790
|
+
this._(str, key);
|
|
2791
|
+
} catch (_) {
|
|
2792
|
+
}
|
|
2793
|
+
} else if (typeof this[a] === "function") {
|
|
2794
|
+
this[a](key);
|
|
2795
|
+
}
|
|
2796
|
+
};
|
|
2797
|
+
this.close = () => {
|
|
2798
|
+
this.out.write(import_sisteransi2.cursor.show);
|
|
2799
|
+
this.in.removeListener("keypress", keypress);
|
|
2800
|
+
if (this.in.isTTY) this.in.setRawMode(false);
|
|
2801
|
+
rl.close();
|
|
2802
|
+
this.emit(
|
|
2803
|
+
this.aborted ? "abort" : this.exited ? "exit" : "submit",
|
|
2804
|
+
// @ts-expect-error
|
|
2805
|
+
this.value
|
|
2806
|
+
);
|
|
2807
|
+
this.closed = true;
|
|
2808
|
+
};
|
|
2809
|
+
this.in.on("keypress", keypress);
|
|
2810
|
+
}
|
|
2811
|
+
get type() {
|
|
2812
|
+
throw new Error("Method type not implemented.");
|
|
2813
|
+
}
|
|
2814
|
+
bell() {
|
|
2815
|
+
this.out.write(import_sisteransi2.beep);
|
|
2816
|
+
}
|
|
2817
|
+
fire() {
|
|
2818
|
+
this.emit("state", {
|
|
2819
|
+
// @ts-expect-error
|
|
2820
|
+
value: this.value,
|
|
2821
|
+
aborted: !!this.aborted,
|
|
2822
|
+
exited: !!this.exited
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
render() {
|
|
2826
|
+
this.onRender(color);
|
|
2827
|
+
if (this.firstRender) this.firstRender = false;
|
|
2828
|
+
}
|
|
2829
|
+
_(c, key) {
|
|
2830
|
+
throw new Error("Method _ not implemented.");
|
|
2831
|
+
}
|
|
2832
|
+
};
|
|
2833
|
+
|
|
2834
|
+
// prompts-confirm.ts
|
|
2835
|
+
var ConfirmPrompt = class extends Prompt {
|
|
2836
|
+
label;
|
|
2837
|
+
msg;
|
|
2838
|
+
value;
|
|
2839
|
+
initialValue;
|
|
2840
|
+
hint;
|
|
2841
|
+
choices;
|
|
2842
|
+
cursor;
|
|
2843
|
+
done;
|
|
2844
|
+
name = "ConfirmPrompt";
|
|
2845
|
+
// set by render which is called in constructor
|
|
2846
|
+
outputText;
|
|
2847
|
+
constructor(opts) {
|
|
2848
|
+
super(opts);
|
|
2849
|
+
this.label = opts.label;
|
|
2850
|
+
this.hint = opts.hint;
|
|
2851
|
+
this.msg = opts.message;
|
|
2852
|
+
this.value = opts.initial;
|
|
2853
|
+
this.initialValue = !!opts.initial;
|
|
2854
|
+
this.choices = [
|
|
2855
|
+
{ value: true, label: "Yes" },
|
|
2856
|
+
{ value: false, label: "No" }
|
|
2857
|
+
];
|
|
2858
|
+
this.cursor = this.choices.findIndex((c) => c.value === this.initialValue);
|
|
2859
|
+
this.render();
|
|
2860
|
+
}
|
|
2861
|
+
get type() {
|
|
2862
|
+
return "confirm";
|
|
2863
|
+
}
|
|
2864
|
+
exit() {
|
|
2865
|
+
this.abort();
|
|
2866
|
+
}
|
|
2867
|
+
abort() {
|
|
2868
|
+
this.done = this.aborted = true;
|
|
2869
|
+
this.fire();
|
|
2870
|
+
this.render();
|
|
2871
|
+
this.out.write("\n");
|
|
2872
|
+
this.close();
|
|
2873
|
+
}
|
|
2874
|
+
submit() {
|
|
2875
|
+
this.value = this.value || false;
|
|
2876
|
+
this.cursor = this.choices.findIndex((c) => c.value === this.value);
|
|
2877
|
+
this.done = true;
|
|
2878
|
+
this.aborted = false;
|
|
2879
|
+
this.fire();
|
|
2880
|
+
this.render();
|
|
2881
|
+
this.out.write("\n");
|
|
2882
|
+
this.close();
|
|
2883
|
+
}
|
|
2884
|
+
moveCursor(n) {
|
|
2885
|
+
this.cursor = n;
|
|
2886
|
+
this.value = this.choices[n].value;
|
|
2887
|
+
this.fire();
|
|
2888
|
+
}
|
|
2889
|
+
reset() {
|
|
2890
|
+
this.moveCursor(0);
|
|
2891
|
+
this.fire();
|
|
2892
|
+
this.render();
|
|
2893
|
+
}
|
|
2894
|
+
first() {
|
|
2895
|
+
this.moveCursor(0);
|
|
2896
|
+
this.render();
|
|
2897
|
+
}
|
|
2898
|
+
last() {
|
|
2899
|
+
this.moveCursor(this.choices.length - 1);
|
|
2900
|
+
this.render();
|
|
2901
|
+
}
|
|
2902
|
+
left() {
|
|
2903
|
+
if (this.cursor === 0) {
|
|
2904
|
+
this.moveCursor(this.choices.length - 1);
|
|
2905
|
+
} else {
|
|
2906
|
+
this.moveCursor(this.cursor - 1);
|
|
2907
|
+
}
|
|
2908
|
+
this.render();
|
|
2909
|
+
}
|
|
2910
|
+
right() {
|
|
2911
|
+
if (this.cursor === this.choices.length - 1) {
|
|
2912
|
+
this.moveCursor(0);
|
|
2913
|
+
} else {
|
|
2914
|
+
this.moveCursor(this.cursor + 1);
|
|
2915
|
+
}
|
|
2916
|
+
this.render();
|
|
2917
|
+
}
|
|
2918
|
+
_(c, key) {
|
|
2919
|
+
if (!Number.isNaN(Number.parseInt(c))) {
|
|
2920
|
+
let n = Number.parseInt(c) - 1;
|
|
2921
|
+
this.moveCursor(n);
|
|
2922
|
+
this.render();
|
|
2923
|
+
return this.submit();
|
|
2924
|
+
}
|
|
2925
|
+
if (c.toLowerCase() === "y") {
|
|
2926
|
+
this.value = true;
|
|
2927
|
+
return this.submit();
|
|
2928
|
+
}
|
|
2929
|
+
if (c.toLowerCase() === "n") {
|
|
2930
|
+
this.value = false;
|
|
2931
|
+
return this.submit();
|
|
2932
|
+
}
|
|
2933
|
+
return;
|
|
2934
|
+
}
|
|
2935
|
+
render() {
|
|
2936
|
+
if (this.closed) {
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2939
|
+
if (this.firstRender) {
|
|
2940
|
+
this.out.write(import_sisteransi3.cursor.hide);
|
|
2941
|
+
} else {
|
|
2942
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
2943
|
+
}
|
|
2944
|
+
super.render();
|
|
2945
|
+
let outputText = [
|
|
2946
|
+
"\n",
|
|
2947
|
+
this.label,
|
|
2948
|
+
" ",
|
|
2949
|
+
this.msg,
|
|
2950
|
+
this.done ? "" : this.hint ? color.dim(` (${this.hint})`) : "",
|
|
2951
|
+
"\n"
|
|
2952
|
+
];
|
|
2953
|
+
outputText.push(" ".repeat(strip(this.label).length));
|
|
2954
|
+
if (this.done) {
|
|
2955
|
+
outputText.push(" ", color.dim(`${this.choices[this.cursor].label}`));
|
|
2956
|
+
} else {
|
|
2957
|
+
outputText.push(
|
|
2958
|
+
" ",
|
|
2959
|
+
this.choices.map(
|
|
2960
|
+
(choice, i) => i === this.cursor ? `${color.green("\u25CF")} ${choice.label} ` : color.dim(`\u25CB ${choice.label} `)
|
|
2961
|
+
).join(color.dim(" "))
|
|
2962
|
+
);
|
|
2963
|
+
}
|
|
2964
|
+
this.outputText = outputText.join("");
|
|
2965
|
+
this.out.write(import_sisteransi3.erase.line + import_sisteransi3.cursor.to(0) + this.outputText);
|
|
2966
|
+
}
|
|
2967
|
+
};
|
|
2968
|
+
|
|
2969
|
+
// prompts-select.ts
|
|
2970
|
+
var import_sisteransi4 = require("sisteransi");
|
|
2971
|
+
var SelectPrompt = class extends Prompt {
|
|
2972
|
+
choices;
|
|
2973
|
+
label;
|
|
2974
|
+
msg;
|
|
2975
|
+
hint;
|
|
2976
|
+
value;
|
|
2977
|
+
initialValue;
|
|
2978
|
+
search;
|
|
2979
|
+
done;
|
|
2980
|
+
cursor;
|
|
2981
|
+
name = "SelectPrompt";
|
|
2982
|
+
_timeout;
|
|
2983
|
+
// set by render which is called in constructor
|
|
2984
|
+
outputText;
|
|
2985
|
+
constructor(opts) {
|
|
2986
|
+
if (!opts.choices || !Array.isArray(opts.choices) || opts.choices.length < 1) {
|
|
2987
|
+
throw new Error("SelectPrompt must contain choices");
|
|
2988
|
+
}
|
|
2989
|
+
super(opts);
|
|
2990
|
+
this.label = opts.label;
|
|
2991
|
+
this.hint = opts.hint;
|
|
2992
|
+
this.msg = opts.message;
|
|
2993
|
+
this.value = opts.initial;
|
|
2994
|
+
this.choices = opts.choices;
|
|
2995
|
+
this.initialValue = opts.initial || this.choices[0].value;
|
|
2996
|
+
this.cursor = this.choices.findIndex((c) => c.value === this.initialValue);
|
|
2997
|
+
this.search = null;
|
|
2998
|
+
this.render();
|
|
2999
|
+
}
|
|
3000
|
+
get type() {
|
|
3001
|
+
return "select";
|
|
3002
|
+
}
|
|
3003
|
+
exit() {
|
|
3004
|
+
this.abort();
|
|
3005
|
+
}
|
|
3006
|
+
abort() {
|
|
3007
|
+
this.done = this.aborted = true;
|
|
3008
|
+
this.cursor = this.choices.findIndex((c) => c.value === this.initialValue);
|
|
3009
|
+
this.fire();
|
|
3010
|
+
this.render();
|
|
3011
|
+
this.out.write("\n");
|
|
3012
|
+
this.close();
|
|
3013
|
+
}
|
|
3014
|
+
submit() {
|
|
3015
|
+
this.value = this.value || void 0;
|
|
3016
|
+
this.cursor = this.choices.findIndex((c) => c.value === this.value);
|
|
3017
|
+
this.done = true;
|
|
3018
|
+
this.aborted = false;
|
|
3019
|
+
this.fire();
|
|
3020
|
+
this.render();
|
|
3021
|
+
this.out.write("\n");
|
|
3022
|
+
this.close();
|
|
3023
|
+
}
|
|
3024
|
+
delete() {
|
|
3025
|
+
this.search = null;
|
|
3026
|
+
this.render();
|
|
3027
|
+
}
|
|
3028
|
+
_(c, key) {
|
|
3029
|
+
if (this._timeout) clearTimeout(this._timeout);
|
|
3030
|
+
if (!Number.isNaN(Number.parseInt(c))) {
|
|
3031
|
+
let n2 = Number.parseInt(c) - 1;
|
|
3032
|
+
this.moveCursor(n2);
|
|
3033
|
+
this.render();
|
|
3034
|
+
return this.submit();
|
|
3035
|
+
}
|
|
3036
|
+
this.search = this.search || "";
|
|
3037
|
+
this.search += c.toLowerCase();
|
|
3038
|
+
let choices = !this.search ? this.choices.slice(this.cursor) : this.choices;
|
|
3039
|
+
let n = choices.findIndex(
|
|
3040
|
+
(c2) => c2.label.toLowerCase().includes(this.search)
|
|
3041
|
+
);
|
|
3042
|
+
if (n > -1) {
|
|
3043
|
+
this.moveCursor(n);
|
|
3044
|
+
this.render();
|
|
3045
|
+
}
|
|
3046
|
+
this._timeout = setTimeout(() => {
|
|
3047
|
+
this.search = null;
|
|
3048
|
+
}, 500);
|
|
3049
|
+
}
|
|
3050
|
+
moveCursor(n) {
|
|
3051
|
+
this.cursor = n;
|
|
3052
|
+
this.value = this.choices[n].value;
|
|
3053
|
+
this.fire();
|
|
3054
|
+
}
|
|
3055
|
+
reset() {
|
|
3056
|
+
this.moveCursor(0);
|
|
3057
|
+
this.fire();
|
|
3058
|
+
this.render();
|
|
3059
|
+
}
|
|
3060
|
+
first() {
|
|
3061
|
+
this.moveCursor(0);
|
|
3062
|
+
this.render();
|
|
3063
|
+
}
|
|
3064
|
+
last() {
|
|
3065
|
+
this.moveCursor(this.choices.length - 1);
|
|
3066
|
+
this.render();
|
|
3067
|
+
}
|
|
3068
|
+
up() {
|
|
3069
|
+
if (this.cursor === 0) {
|
|
3070
|
+
this.moveCursor(this.choices.length - 1);
|
|
3071
|
+
} else {
|
|
3072
|
+
this.moveCursor(this.cursor - 1);
|
|
3073
|
+
}
|
|
3074
|
+
this.render();
|
|
3075
|
+
}
|
|
3076
|
+
down() {
|
|
3077
|
+
if (this.cursor === this.choices.length - 1) {
|
|
3078
|
+
this.moveCursor(0);
|
|
3079
|
+
} else {
|
|
3080
|
+
this.moveCursor(this.cursor + 1);
|
|
3081
|
+
}
|
|
3082
|
+
this.render();
|
|
3083
|
+
}
|
|
3084
|
+
highlight(label) {
|
|
3085
|
+
if (!this.search) return label;
|
|
3086
|
+
let n = label.toLowerCase().indexOf(this.search.toLowerCase());
|
|
3087
|
+
if (n === -1) return label;
|
|
3088
|
+
return [
|
|
3089
|
+
label.slice(0, n),
|
|
3090
|
+
color.underline(label.slice(n, n + this.search.length)),
|
|
3091
|
+
label.slice(n + this.search.length)
|
|
3092
|
+
].join("");
|
|
3093
|
+
}
|
|
3094
|
+
render() {
|
|
3095
|
+
if (this.closed) return;
|
|
3096
|
+
if (this.firstRender) this.out.write(import_sisteransi4.cursor.hide);
|
|
3097
|
+
else this.out.write(clear(this.outputText, this.out.columns));
|
|
3098
|
+
super.render();
|
|
3099
|
+
let outputText = [
|
|
3100
|
+
"\n",
|
|
3101
|
+
this.label,
|
|
3102
|
+
" ",
|
|
3103
|
+
this.msg,
|
|
3104
|
+
this.done ? "" : this.hint ? (this.out.columns < 80 ? "\n" + " ".repeat(8) : "") + color.dim(` (${this.hint})`) : "",
|
|
3105
|
+
"\n"
|
|
3106
|
+
];
|
|
3107
|
+
let prefix = " ".repeat(strip(this.label).length);
|
|
3108
|
+
if (this.done) {
|
|
3109
|
+
outputText.push(
|
|
3110
|
+
`${prefix} `,
|
|
3111
|
+
color.dim(`${this.choices[this.cursor]?.label}`)
|
|
3112
|
+
);
|
|
3113
|
+
} else {
|
|
3114
|
+
outputText.push(
|
|
3115
|
+
this.choices.map(
|
|
3116
|
+
(choice, i) => i === this.cursor ? `${prefix} ${color.green(
|
|
3117
|
+
shouldUseAscii() ? ">" : "\u25CF"
|
|
3118
|
+
)} ${this.highlight(choice.label)} ${choice.hint ? color.dim(choice.hint) : ""}` : color.dim(
|
|
3119
|
+
`${prefix} ${shouldUseAscii() ? "\u2014" : "\u25CB"} ${choice.label} `
|
|
3120
|
+
)
|
|
3121
|
+
).join("\n")
|
|
3122
|
+
);
|
|
3123
|
+
}
|
|
3124
|
+
this.outputText = outputText.join("");
|
|
3125
|
+
this.out.write(import_sisteransi4.erase.line + import_sisteransi4.cursor.to(0) + this.outputText);
|
|
3126
|
+
}
|
|
3127
|
+
};
|
|
3128
|
+
|
|
3129
|
+
// prompts-multi-select.ts
|
|
3130
|
+
var import_sisteransi5 = require("sisteransi");
|
|
3131
|
+
var MultiSelectPrompt = class extends Prompt {
|
|
3132
|
+
choices;
|
|
3133
|
+
label;
|
|
3134
|
+
msg;
|
|
3135
|
+
hint;
|
|
3136
|
+
value;
|
|
3137
|
+
initialValue;
|
|
3138
|
+
done;
|
|
3139
|
+
cursor;
|
|
3140
|
+
name = "MultiSelectPrompt";
|
|
3141
|
+
// set by render which is called in constructor
|
|
3142
|
+
outputText;
|
|
3143
|
+
constructor(opts) {
|
|
3144
|
+
if (!opts.choices || !Array.isArray(opts.choices) || opts.choices.length < 1) {
|
|
3145
|
+
throw new Error("MultiSelectPrompt must contain choices");
|
|
3146
|
+
}
|
|
3147
|
+
super(opts);
|
|
3148
|
+
this.label = opts.label;
|
|
3149
|
+
this.msg = opts.message;
|
|
3150
|
+
this.hint = opts.hint;
|
|
3151
|
+
this.value = [];
|
|
3152
|
+
this.choices = opts.choices.map((choice) => ({ ...choice, selected: false })) || [];
|
|
3153
|
+
this.initialValue = opts.initial || this.choices[0].value;
|
|
3154
|
+
this.cursor = this.choices.findIndex((c) => c.value === this.initialValue);
|
|
3155
|
+
this.render();
|
|
3156
|
+
}
|
|
3157
|
+
get type() {
|
|
3158
|
+
return "multiselect";
|
|
3159
|
+
}
|
|
3160
|
+
exit() {
|
|
3161
|
+
this.abort();
|
|
3162
|
+
}
|
|
3163
|
+
abort() {
|
|
3164
|
+
this.done = this.aborted = true;
|
|
3165
|
+
this.cursor = this.choices.findIndex((c) => c.value === this.initialValue);
|
|
3166
|
+
this.fire();
|
|
3167
|
+
this.render();
|
|
3168
|
+
this.out.write("\n");
|
|
3169
|
+
this.close();
|
|
3170
|
+
}
|
|
3171
|
+
submit() {
|
|
3172
|
+
return this.toggle();
|
|
3173
|
+
}
|
|
3174
|
+
finish() {
|
|
3175
|
+
this.value = this.value;
|
|
3176
|
+
this.done = true;
|
|
3177
|
+
this.aborted = false;
|
|
3178
|
+
this.fire();
|
|
3179
|
+
this.render();
|
|
3180
|
+
this.out.write("\n");
|
|
3181
|
+
this.close();
|
|
3182
|
+
}
|
|
3183
|
+
moveCursor(n) {
|
|
3184
|
+
this.cursor = n;
|
|
3185
|
+
this.fire();
|
|
3186
|
+
}
|
|
3187
|
+
toggle() {
|
|
3188
|
+
let choice = this.choices[this.cursor];
|
|
3189
|
+
if (!choice) return;
|
|
3190
|
+
choice.selected = !choice.selected;
|
|
3191
|
+
this.render();
|
|
3192
|
+
}
|
|
3193
|
+
_(c, key) {
|
|
3194
|
+
if (c === " ") {
|
|
3195
|
+
return this.toggle();
|
|
3196
|
+
}
|
|
3197
|
+
if (c.toLowerCase() === "c") {
|
|
3198
|
+
return this.finish();
|
|
3199
|
+
}
|
|
3200
|
+
return;
|
|
3201
|
+
}
|
|
3202
|
+
reset() {
|
|
3203
|
+
this.moveCursor(0);
|
|
3204
|
+
this.fire();
|
|
3205
|
+
this.render();
|
|
3206
|
+
}
|
|
3207
|
+
first() {
|
|
3208
|
+
this.moveCursor(0);
|
|
3209
|
+
this.render();
|
|
3210
|
+
}
|
|
3211
|
+
last() {
|
|
3212
|
+
this.moveCursor(this.choices.length - 1);
|
|
3213
|
+
this.render();
|
|
3214
|
+
}
|
|
3215
|
+
up() {
|
|
3216
|
+
if (this.cursor === 0) {
|
|
3217
|
+
this.moveCursor(this.choices.length - 1);
|
|
3218
|
+
} else {
|
|
3219
|
+
this.moveCursor(this.cursor - 1);
|
|
3220
|
+
}
|
|
3221
|
+
this.render();
|
|
3222
|
+
}
|
|
3223
|
+
down() {
|
|
3224
|
+
if (this.cursor === this.choices.length - 1) {
|
|
3225
|
+
this.moveCursor(0);
|
|
3226
|
+
} else {
|
|
3227
|
+
this.moveCursor(this.cursor + 1);
|
|
3228
|
+
}
|
|
3229
|
+
this.render();
|
|
3230
|
+
}
|
|
3231
|
+
render() {
|
|
3232
|
+
if (this.closed) return;
|
|
3233
|
+
if (this.firstRender) {
|
|
3234
|
+
this.out.write(import_sisteransi5.cursor.hide);
|
|
3235
|
+
} else {
|
|
3236
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
3237
|
+
}
|
|
3238
|
+
super.render();
|
|
3239
|
+
let outputText = ["\n", this.label, " ", this.msg, "\n"];
|
|
3240
|
+
let prefix = " ".repeat(strip(this.label).length);
|
|
3241
|
+
if (this.done) {
|
|
3242
|
+
outputText.push(
|
|
3243
|
+
this.choices.map(
|
|
3244
|
+
(choice) => choice.selected ? `${prefix} ${color.dim(`${choice.label}`)}
|
|
3245
|
+
` : ""
|
|
3246
|
+
).join("").trimEnd()
|
|
3247
|
+
);
|
|
3248
|
+
} else {
|
|
3249
|
+
outputText.push(
|
|
3250
|
+
this.choices.map(
|
|
3251
|
+
(choice, i) => i === this.cursor ? `${prefix.slice(0, -2)}${color.cyanBright("\u25B6")} ${choice.selected ? color.green("\u25A0") : color.whiteBright("\u25A1")} ${color.underline(choice.label)} ${choice.hint ? color.dim(choice.hint) : ""}` : color[choice.selected ? "reset" : "dim"](
|
|
3252
|
+
`${prefix} ${choice.selected ? color.green("\u25A0") : "\u25A1"} ${choice.label} `
|
|
3253
|
+
)
|
|
3254
|
+
).join("\n")
|
|
3255
|
+
);
|
|
3256
|
+
outputText.push(
|
|
3257
|
+
`
|
|
3258
|
+
|
|
3259
|
+
${prefix} Press ${color.inverse(" C ")} to continue`
|
|
3260
|
+
);
|
|
3261
|
+
}
|
|
3262
|
+
this.outputText = outputText.join("");
|
|
3263
|
+
this.out.write(import_sisteransi5.erase.line + import_sisteransi5.cursor.to(0) + this.outputText);
|
|
3264
|
+
}
|
|
3265
|
+
};
|
|
3266
|
+
|
|
3267
|
+
// prompts-text.ts
|
|
3268
|
+
var import_sisteransi6 = require("sisteransi");
|
|
3269
|
+
var TextPrompt = class extends Prompt {
|
|
3270
|
+
transform;
|
|
3271
|
+
label;
|
|
3272
|
+
scale;
|
|
3273
|
+
msg;
|
|
3274
|
+
initial;
|
|
3275
|
+
hint;
|
|
3276
|
+
validator;
|
|
3277
|
+
errorMsg;
|
|
3278
|
+
cursor;
|
|
3279
|
+
cursorOffset;
|
|
3280
|
+
clear;
|
|
3281
|
+
done;
|
|
3282
|
+
error;
|
|
3283
|
+
red;
|
|
3284
|
+
outputError;
|
|
3285
|
+
name = "TextPrompt";
|
|
3286
|
+
// set by value setter, value is set in constructor
|
|
3287
|
+
_value;
|
|
3288
|
+
placeholder;
|
|
3289
|
+
rendered;
|
|
3290
|
+
// set by render which is called in constructor
|
|
3291
|
+
outputText;
|
|
3292
|
+
constructor(opts) {
|
|
3293
|
+
super(opts);
|
|
3294
|
+
this.transform = { render: (v) => v, scale: 1 };
|
|
3295
|
+
this.label = opts.label;
|
|
3296
|
+
this.scale = this.transform.scale;
|
|
3297
|
+
this.msg = opts.message;
|
|
3298
|
+
this.hint = opts.hint;
|
|
3299
|
+
this.initial = opts.initial || "";
|
|
3300
|
+
this.validator = opts.validate || (() => true);
|
|
3301
|
+
this.value = "";
|
|
3302
|
+
this.errorMsg = opts.error || "Please enter a valid value";
|
|
3303
|
+
this.cursor = Number(!!this.initial);
|
|
3304
|
+
this.cursorOffset = 0;
|
|
3305
|
+
this.clear = clear(``, this.out.columns);
|
|
3306
|
+
this.render();
|
|
3307
|
+
}
|
|
3308
|
+
get type() {
|
|
3309
|
+
return "text";
|
|
3310
|
+
}
|
|
3311
|
+
set value(v) {
|
|
3312
|
+
if (!v && this.initial) {
|
|
3313
|
+
this.placeholder = true;
|
|
3314
|
+
this.rendered = color.dim(this.initial);
|
|
3315
|
+
} else {
|
|
3316
|
+
this.placeholder = false;
|
|
3317
|
+
this.rendered = this.transform.render(v);
|
|
3318
|
+
}
|
|
3319
|
+
this._value = v;
|
|
3320
|
+
this.fire();
|
|
3321
|
+
}
|
|
3322
|
+
get value() {
|
|
3323
|
+
return this._value;
|
|
3324
|
+
}
|
|
3325
|
+
reset() {
|
|
3326
|
+
this.value = "";
|
|
3327
|
+
this.cursor = Number(!!this.initial);
|
|
3328
|
+
this.cursorOffset = 0;
|
|
3329
|
+
this.fire();
|
|
3330
|
+
this.render();
|
|
3331
|
+
}
|
|
3332
|
+
exit() {
|
|
3333
|
+
this.abort();
|
|
3334
|
+
}
|
|
3335
|
+
abort() {
|
|
3336
|
+
this.value = this.value || this.initial;
|
|
3337
|
+
this.done = this.aborted = true;
|
|
3338
|
+
this.error = false;
|
|
3339
|
+
this.red = false;
|
|
3340
|
+
this.fire();
|
|
3341
|
+
this.render();
|
|
3342
|
+
this.out.write("\n");
|
|
3343
|
+
this.close();
|
|
3344
|
+
}
|
|
3345
|
+
async validate() {
|
|
3346
|
+
let valid2 = await this.validator(this.value);
|
|
3347
|
+
if (typeof valid2 === `string`) {
|
|
3348
|
+
this.errorMsg = valid2;
|
|
3349
|
+
valid2 = false;
|
|
3350
|
+
}
|
|
3351
|
+
this.error = !valid2;
|
|
3352
|
+
}
|
|
3353
|
+
async submit() {
|
|
3354
|
+
this.value = this.value || this.initial;
|
|
3355
|
+
this.cursorOffset = 0;
|
|
3356
|
+
this.cursor = this.rendered.length;
|
|
3357
|
+
await this.validate();
|
|
3358
|
+
if (this.error) {
|
|
3359
|
+
this.red = true;
|
|
3360
|
+
this.fire();
|
|
3361
|
+
this.render();
|
|
3362
|
+
return;
|
|
3363
|
+
}
|
|
3364
|
+
this.done = true;
|
|
3365
|
+
this.aborted = false;
|
|
3366
|
+
this.fire();
|
|
3367
|
+
this.render();
|
|
3368
|
+
this.out.write("\n");
|
|
3369
|
+
this.close();
|
|
3370
|
+
}
|
|
3371
|
+
next() {
|
|
3372
|
+
if (!this.placeholder) return this.bell();
|
|
3373
|
+
this.value = this.initial;
|
|
3374
|
+
this.cursor = this.rendered.length;
|
|
3375
|
+
this.fire();
|
|
3376
|
+
this.render();
|
|
3377
|
+
}
|
|
3378
|
+
moveCursor(n) {
|
|
3379
|
+
if (this.placeholder) return;
|
|
3380
|
+
this.cursor = this.cursor + n;
|
|
3381
|
+
this.cursorOffset += n;
|
|
3382
|
+
}
|
|
3383
|
+
_(c, key) {
|
|
3384
|
+
let s1 = this.value.slice(0, this.cursor);
|
|
3385
|
+
let s2 = this.value.slice(this.cursor);
|
|
3386
|
+
this.value = `${s1}${c}${s2}`;
|
|
3387
|
+
this.red = false;
|
|
3388
|
+
this.cursor = this.placeholder ? 0 : s1.length + 1;
|
|
3389
|
+
this.render();
|
|
3390
|
+
}
|
|
3391
|
+
delete() {
|
|
3392
|
+
if (this.isCursorAtStart()) return this.bell();
|
|
3393
|
+
let s1 = this.value.slice(0, this.cursor - 1);
|
|
3394
|
+
let s2 = this.value.slice(this.cursor);
|
|
3395
|
+
this.value = `${s1}${s2}`;
|
|
3396
|
+
this.red = false;
|
|
3397
|
+
this.outputError = "";
|
|
3398
|
+
this.error = false;
|
|
3399
|
+
if (this.isCursorAtStart()) {
|
|
3400
|
+
this.cursorOffset = 0;
|
|
3401
|
+
} else {
|
|
3402
|
+
this.cursorOffset++;
|
|
3403
|
+
this.moveCursor(-1);
|
|
3404
|
+
}
|
|
3405
|
+
this.render();
|
|
3406
|
+
}
|
|
3407
|
+
deleteForward() {
|
|
3408
|
+
if (this.cursor * this.scale >= this.rendered.length || this.placeholder)
|
|
3409
|
+
return this.bell();
|
|
3410
|
+
let s1 = this.value.slice(0, this.cursor);
|
|
3411
|
+
let s2 = this.value.slice(this.cursor + 1);
|
|
3412
|
+
this.value = `${s1}${s2}`;
|
|
3413
|
+
this.red = false;
|
|
3414
|
+
this.outputError = "";
|
|
3415
|
+
this.error = false;
|
|
3416
|
+
if (this.isCursorAtEnd()) {
|
|
3417
|
+
this.cursorOffset = 0;
|
|
3418
|
+
} else {
|
|
3419
|
+
this.cursorOffset++;
|
|
3420
|
+
}
|
|
3421
|
+
this.render();
|
|
3422
|
+
}
|
|
3423
|
+
first() {
|
|
3424
|
+
this.cursor = 0;
|
|
3425
|
+
this.render();
|
|
3426
|
+
}
|
|
3427
|
+
last() {
|
|
3428
|
+
this.cursor = this.value.length;
|
|
3429
|
+
this.render();
|
|
3430
|
+
}
|
|
3431
|
+
left() {
|
|
3432
|
+
if (this.cursor <= 0 || this.placeholder) return this.bell();
|
|
3433
|
+
this.moveCursor(-1);
|
|
3434
|
+
this.render();
|
|
3435
|
+
}
|
|
3436
|
+
right() {
|
|
3437
|
+
if (this.cursor * this.scale >= this.rendered.length || this.placeholder)
|
|
3438
|
+
return this.bell();
|
|
3439
|
+
this.moveCursor(1);
|
|
3440
|
+
this.render();
|
|
3441
|
+
}
|
|
3442
|
+
isCursorAtStart() {
|
|
3443
|
+
return this.cursor === 0 || this.placeholder && this.cursor === 1;
|
|
3444
|
+
}
|
|
3445
|
+
isCursorAtEnd() {
|
|
3446
|
+
return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1;
|
|
3447
|
+
}
|
|
3448
|
+
render() {
|
|
3449
|
+
if (this.closed) return;
|
|
3450
|
+
if (!this.firstRender) {
|
|
3451
|
+
if (this.outputError)
|
|
3452
|
+
this.out.write(
|
|
3453
|
+
import_sisteransi6.cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns)
|
|
3454
|
+
);
|
|
3455
|
+
this.out.write(clear(this.outputText, this.out.columns));
|
|
3456
|
+
}
|
|
3457
|
+
super.render();
|
|
3458
|
+
this.outputError = "";
|
|
3459
|
+
let prefix = " ".repeat(strip(this.label).length);
|
|
3460
|
+
this.outputText = [
|
|
3461
|
+
"\n",
|
|
3462
|
+
this.label,
|
|
3463
|
+
" ",
|
|
3464
|
+
this.msg,
|
|
3465
|
+
this.done ? "" : this.hint ? (this.out.columns < 80 ? "\n" + " ".repeat(8) : "") + color.dim(` (${this.hint})`) : "",
|
|
3466
|
+
"\n" + prefix,
|
|
3467
|
+
" ",
|
|
3468
|
+
this.done ? color.dim(this.rendered) : this.rendered
|
|
3469
|
+
].join("");
|
|
3470
|
+
if (this.error) {
|
|
3471
|
+
this.outputError += ` ${color.redBright(
|
|
3472
|
+
(shouldUseAscii() ? "> " : "\u25B6 ") + this.errorMsg
|
|
3473
|
+
)}`;
|
|
3474
|
+
}
|
|
3475
|
+
this.out.write(
|
|
3476
|
+
import_sisteransi6.erase.line + import_sisteransi6.cursor.to(0) + this.outputText + import_sisteransi6.cursor.save + this.outputError + import_sisteransi6.cursor.restore + import_sisteransi6.cursor.move(
|
|
3477
|
+
this.placeholder ? (this.rendered.length - 9) * -1 : this.cursorOffset,
|
|
3478
|
+
0
|
|
3479
|
+
)
|
|
3480
|
+
);
|
|
3481
|
+
}
|
|
3482
|
+
};
|
|
3483
|
+
|
|
3484
|
+
// prompt.ts
|
|
3485
|
+
var prompts = {
|
|
3486
|
+
text: (args) => toPrompt(TextPrompt, args),
|
|
3487
|
+
confirm: (args) => toPrompt(ConfirmPrompt, args),
|
|
3488
|
+
select: (args) => toPrompt(SelectPrompt, args),
|
|
3489
|
+
multiselect: (args) => toPrompt(MultiSelectPrompt, args)
|
|
3490
|
+
};
|
|
3491
|
+
async function prompt(questions, opts = {}) {
|
|
3492
|
+
let {
|
|
3493
|
+
onSubmit = identity,
|
|
3494
|
+
onCancel = () => import_node_process3.default.exit(0),
|
|
3495
|
+
stdin = import_node_process3.default.stdin,
|
|
3496
|
+
stdout = import_node_process3.default.stdout
|
|
3497
|
+
} = opts;
|
|
3498
|
+
let answers = {};
|
|
3499
|
+
let questionsArray = Array.isArray(questions) ? questions : [questions];
|
|
3500
|
+
let answer;
|
|
3501
|
+
let quit;
|
|
3502
|
+
let name;
|
|
3503
|
+
let type;
|
|
3504
|
+
for (let question of questionsArray) {
|
|
3505
|
+
({ name, type } = question);
|
|
3506
|
+
try {
|
|
3507
|
+
answer = await prompts[type](Object.assign({ stdin, stdout }, question));
|
|
3508
|
+
answers[name] = answer;
|
|
3509
|
+
quit = await onSubmit(question, answer, answers);
|
|
3510
|
+
} catch (err) {
|
|
3511
|
+
quit = !await onCancel(question, answers);
|
|
3512
|
+
}
|
|
3513
|
+
if (quit) {
|
|
3514
|
+
return answers;
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
return answers;
|
|
3518
|
+
}
|
|
3519
|
+
function toPrompt(el, args, opts = {}) {
|
|
3520
|
+
if (el !== TextPrompt && el !== ConfirmPrompt && el !== SelectPrompt && el !== MultiSelectPrompt) {
|
|
3521
|
+
throw new Error(`Invalid prompt type: ${el.name}`);
|
|
3522
|
+
}
|
|
3523
|
+
return new Promise((res, rej) => {
|
|
3524
|
+
let p = new el(
|
|
3525
|
+
args,
|
|
3526
|
+
// @ts-expect-error
|
|
3527
|
+
opts
|
|
3528
|
+
);
|
|
3529
|
+
let onAbort = args.onAbort || opts.onAbort || identity;
|
|
3530
|
+
let onSubmit = args.onSubmit || opts.onSubmit || identity;
|
|
3531
|
+
let onExit = args.onExit || opts.onExit || identity;
|
|
3532
|
+
p.on("state", args.onState || identity);
|
|
3533
|
+
p.on("submit", (x) => res(onSubmit(x)));
|
|
3534
|
+
p.on("exit", (x) => res(onExit(x)));
|
|
3535
|
+
p.on("abort", (x) => rej(onAbort(x)));
|
|
3536
|
+
});
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
// loading-indicator.ts
|
|
3540
|
+
var import_node_process4 = __toESM(require("process"));
|
|
3541
|
+
var import_node_readline2 = __toESM(require("readline"));
|
|
3542
|
+
var import_sisteransi7 = require("sisteransi");
|
|
3543
|
+
var GRADIENT_COLORS = [
|
|
3544
|
+
"#ffffff",
|
|
3545
|
+
"#dadada",
|
|
3546
|
+
"#dadada",
|
|
3547
|
+
"#a8deaa",
|
|
3548
|
+
"#a8deaa",
|
|
3549
|
+
"#a8deaa",
|
|
3550
|
+
"#d0f0bd",
|
|
3551
|
+
"#d0f0bd",
|
|
3552
|
+
"#ffffed",
|
|
3553
|
+
"#ffffed",
|
|
3554
|
+
"#ffffed",
|
|
3555
|
+
"#ffffed",
|
|
3556
|
+
"#ffffed",
|
|
3557
|
+
"#ffffed",
|
|
3558
|
+
"#ffffed",
|
|
3559
|
+
"#ffffed",
|
|
3560
|
+
"#ffffed",
|
|
3561
|
+
"#f7f8ca",
|
|
3562
|
+
"#f7f8ca",
|
|
3563
|
+
"#eae6ba",
|
|
3564
|
+
"#eae6ba",
|
|
3565
|
+
"#eae6ba",
|
|
3566
|
+
"#dadada",
|
|
3567
|
+
"#dadada",
|
|
3568
|
+
"#ffffff"
|
|
3569
|
+
];
|
|
3570
|
+
var MAX_FRAMES = 8;
|
|
3571
|
+
var LEADING_FRAMES = Array.from(
|
|
3572
|
+
{ length: MAX_FRAMES * 2 },
|
|
3573
|
+
() => GRADIENT_COLORS[0]
|
|
3574
|
+
);
|
|
3575
|
+
var TRAILING_FRAMES = Array.from(
|
|
3576
|
+
{ length: MAX_FRAMES * 2 },
|
|
3577
|
+
() => GRADIENT_COLORS[GRADIENT_COLORS.length - 1]
|
|
3578
|
+
);
|
|
3579
|
+
var INDICATOR_FULL_FRAMES = [
|
|
3580
|
+
...LEADING_FRAMES,
|
|
3581
|
+
...GRADIENT_COLORS,
|
|
3582
|
+
...TRAILING_FRAMES,
|
|
3583
|
+
...reverse(GRADIENT_COLORS)
|
|
3584
|
+
];
|
|
3585
|
+
var INDICATOR_GRADIENT = reverse(
|
|
3586
|
+
INDICATOR_FULL_FRAMES.map((_, i) => loadingIndicatorFrame(i))
|
|
3587
|
+
);
|
|
3588
|
+
async function renderLoadingIndicator({
|
|
3589
|
+
start,
|
|
3590
|
+
end,
|
|
3591
|
+
while: update = () => sleep(100),
|
|
3592
|
+
noMotion = false,
|
|
3593
|
+
stdin = import_node_process4.default.stdin,
|
|
3594
|
+
stdout = import_node_process4.default.stdout
|
|
3595
|
+
}) {
|
|
3596
|
+
let act = update();
|
|
3597
|
+
let tooSlow = /* @__PURE__ */ Object.create(null);
|
|
3598
|
+
let result = await Promise.race([sleep(500).then(() => tooSlow), act]);
|
|
3599
|
+
if (result === tooSlow) {
|
|
3600
|
+
let loading = await gradient(color.green(start), {
|
|
3601
|
+
stdin,
|
|
3602
|
+
stdout,
|
|
3603
|
+
noMotion
|
|
3604
|
+
});
|
|
3605
|
+
await act;
|
|
3606
|
+
loading.stop();
|
|
3607
|
+
}
|
|
3608
|
+
stdout.write(`${" ".repeat(5)} ${color.green("\u2714")} ${color.green(end)}
|
|
3609
|
+
`);
|
|
3610
|
+
}
|
|
3611
|
+
function loadingIndicatorFrame(offset = 0) {
|
|
3612
|
+
let frames = INDICATOR_FULL_FRAMES.slice(offset, offset + (MAX_FRAMES - 2));
|
|
3613
|
+
if (frames.length < MAX_FRAMES - 2) {
|
|
3614
|
+
let filled = new Array(MAX_FRAMES - frames.length - 2).fill(
|
|
3615
|
+
GRADIENT_COLORS[0]
|
|
3616
|
+
);
|
|
3617
|
+
frames.push(...filled);
|
|
3618
|
+
}
|
|
3619
|
+
return frames;
|
|
3620
|
+
}
|
|
3621
|
+
function getGradientAnimationFrames() {
|
|
3622
|
+
return INDICATOR_GRADIENT.map(
|
|
3623
|
+
(colors) => " " + colors.map((g, i) => color.hex(g)("\u2588")).join("")
|
|
3624
|
+
);
|
|
3625
|
+
}
|
|
3626
|
+
async function gradient(text, { stdin = import_node_process4.default.stdin, stdout = import_node_process4.default.stdout, noMotion = false } = {}) {
|
|
3627
|
+
let { createLogUpdate } = await import("log-update");
|
|
3628
|
+
let logUpdate = createLogUpdate(stdout);
|
|
3629
|
+
let frameIndex = 0;
|
|
3630
|
+
let frames = getGradientAnimationFrames();
|
|
3631
|
+
let interval;
|
|
3632
|
+
let rl = import_node_readline2.default.createInterface({ input: stdin, escapeCodeTimeout: 50 });
|
|
3633
|
+
import_node_readline2.default.emitKeypressEvents(stdin, rl);
|
|
3634
|
+
if (stdin.isTTY) stdin.setRawMode(true);
|
|
3635
|
+
function keypress(char) {
|
|
3636
|
+
if (char === "") {
|
|
3637
|
+
loadingIndicator2.stop();
|
|
3638
|
+
import_node_process4.default.exit(0);
|
|
3639
|
+
}
|
|
3640
|
+
if (stdin.isTTY) stdin.setRawMode(true);
|
|
3641
|
+
stdout.write(import_sisteransi7.cursor.hide + import_sisteransi7.erase.lines(1));
|
|
3642
|
+
}
|
|
3643
|
+
let done = false;
|
|
3644
|
+
let loadingIndicator2 = {
|
|
3645
|
+
start() {
|
|
3646
|
+
stdout.write(import_sisteransi7.cursor.hide);
|
|
3647
|
+
stdin.on("keypress", keypress);
|
|
3648
|
+
logUpdate(`${frames[0]} ${text}`);
|
|
3649
|
+
async function loop() {
|
|
3650
|
+
if (done) return;
|
|
3651
|
+
if (frameIndex < frames.length - 1) {
|
|
3652
|
+
frameIndex++;
|
|
3653
|
+
} else {
|
|
3654
|
+
frameIndex = 0;
|
|
3655
|
+
}
|
|
3656
|
+
let frame = frames[frameIndex];
|
|
3657
|
+
logUpdate(
|
|
3658
|
+
`${(noMotion ? getMotionlessFrame(frameIndex) : color.supportsColor ? frame : getColorlessFrame(frameIndex)).padEnd(MAX_FRAMES - 1, " ")} ${text}`
|
|
3659
|
+
);
|
|
3660
|
+
if (!done) await sleep(20);
|
|
3661
|
+
loop();
|
|
3662
|
+
}
|
|
3663
|
+
loop();
|
|
3664
|
+
},
|
|
3665
|
+
stop() {
|
|
3666
|
+
done = true;
|
|
3667
|
+
stdin.removeListener("keypress", keypress);
|
|
3668
|
+
clearInterval(interval);
|
|
3669
|
+
logUpdate.clear();
|
|
3670
|
+
rl.close();
|
|
3671
|
+
}
|
|
3672
|
+
};
|
|
3673
|
+
loadingIndicator2.start();
|
|
3674
|
+
return loadingIndicator2;
|
|
3675
|
+
}
|
|
3676
|
+
function getColorlessFrame(frameIndex) {
|
|
3677
|
+
return (frameIndex % 3 === 0 ? ".. .. " : frameIndex % 3 === 1 ? " .. .." : ". .. .").padEnd(MAX_FRAMES - 1 + 20, " ");
|
|
3678
|
+
}
|
|
3679
|
+
function getMotionlessFrame(frameIndex) {
|
|
3680
|
+
return " ".repeat(MAX_FRAMES - 1);
|
|
3681
|
+
}
|
|
3682
|
+
|
|
3683
|
+
// copy-template.ts
|
|
3684
|
+
var import_node_process5 = __toESM(require("process"));
|
|
3685
|
+
var import_node_url = __toESM(require("url"));
|
|
3686
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
3687
|
+
var import_node_path2 = __toESM(require("path"));
|
|
3688
|
+
var import_node_stream = __toESM(require("stream"));
|
|
3689
|
+
var import_node_util = require("util");
|
|
3690
|
+
var import_web_fetch = require("@remix-run/web-fetch");
|
|
3691
|
+
var import_gunzip_maybe = __toESM(require("gunzip-maybe"));
|
|
3692
|
+
var import_tar_fs = __toESM(require("tar-fs"));
|
|
3693
|
+
var import_proxy_agent = require("proxy-agent");
|
|
3694
|
+
var defaultAgent = new import_proxy_agent.ProxyAgent();
|
|
3695
|
+
var httpsAgent = new import_proxy_agent.ProxyAgent();
|
|
3696
|
+
httpsAgent.protocol = "https:";
|
|
3697
|
+
function agent(url2) {
|
|
3698
|
+
return new URL(url2).protocol === "https:" ? httpsAgent : defaultAgent;
|
|
3699
|
+
}
|
|
3700
|
+
async function copyTemplate(template, destPath, options) {
|
|
3701
|
+
let { log: log2 = () => {
|
|
3702
|
+
} } = options;
|
|
3703
|
+
try {
|
|
3704
|
+
if (isLocalFilePath(template)) {
|
|
3705
|
+
log2(`Using the template from local file at "${template}"`);
|
|
3706
|
+
let filepath = template.startsWith("file://") ? import_node_url.default.fileURLToPath(template) : template;
|
|
3707
|
+
let isLocalDir = await copyTemplateFromLocalFilePath(filepath, destPath);
|
|
3708
|
+
return isLocalDir ? { localTemplateDirectory: filepath } : void 0;
|
|
3709
|
+
}
|
|
3710
|
+
if (isGithubRepoShorthand(template)) {
|
|
3711
|
+
log2(`Using the template from the "${template}" repo`);
|
|
3712
|
+
await copyTemplateFromGithubRepoShorthand(template, destPath, options);
|
|
3713
|
+
return;
|
|
3714
|
+
}
|
|
3715
|
+
if (isValidGithubRepoUrl(template)) {
|
|
3716
|
+
log2(`Using the template from "${template}"`);
|
|
3717
|
+
await copyTemplateFromGithubRepoUrl(template, destPath, options);
|
|
3718
|
+
return;
|
|
3719
|
+
}
|
|
3720
|
+
if (isUrl(template)) {
|
|
3721
|
+
log2(`Using the template from "${template}"`);
|
|
3722
|
+
await copyTemplateFromGenericUrl(template, destPath, options);
|
|
3723
|
+
return;
|
|
3724
|
+
}
|
|
3725
|
+
throw new CopyTemplateError(
|
|
3726
|
+
`"${color.bold(template)}" is an invalid template. Run ${color.bold(
|
|
3727
|
+
"create-react-router --help"
|
|
3728
|
+
)} to see supported template formats.`
|
|
3729
|
+
);
|
|
3730
|
+
} catch (error2) {
|
|
3731
|
+
await options.onError(error2);
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
function isLocalFilePath(input) {
|
|
3735
|
+
try {
|
|
3736
|
+
return input.startsWith("file://") || import_node_fs2.default.existsSync(
|
|
3737
|
+
import_node_path2.default.isAbsolute(input) ? input : import_node_path2.default.resolve(import_node_process5.default.cwd(), input)
|
|
3738
|
+
);
|
|
3739
|
+
} catch (_) {
|
|
3740
|
+
return false;
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
async function copyTemplateFromRemoteTarball(url2, destPath, options) {
|
|
3744
|
+
return await downloadAndExtractTarball(destPath, url2, options);
|
|
3745
|
+
}
|
|
3746
|
+
async function copyTemplateFromGithubRepoShorthand(repoShorthand, destPath, options) {
|
|
3747
|
+
let [owner, name, ...path4] = repoShorthand.split("/");
|
|
3748
|
+
let filePath = path4.length ? path4.join("/") : null;
|
|
3749
|
+
await downloadAndExtractRepoTarball(
|
|
3750
|
+
{ owner, name, filePath },
|
|
3751
|
+
destPath,
|
|
3752
|
+
options
|
|
3753
|
+
);
|
|
3754
|
+
}
|
|
3755
|
+
async function copyTemplateFromGithubRepoUrl(repoUrl, destPath, options) {
|
|
3756
|
+
await downloadAndExtractRepoTarball(getRepoInfo(repoUrl), destPath, options);
|
|
3757
|
+
}
|
|
3758
|
+
async function copyTemplateFromGenericUrl(url2, destPath, options) {
|
|
3759
|
+
await copyTemplateFromRemoteTarball(url2, destPath, options);
|
|
3760
|
+
}
|
|
3761
|
+
async function copyTemplateFromLocalFilePath(filePath, destPath) {
|
|
3762
|
+
if (filePath.endsWith(".tar.gz") || filePath.endsWith(".tgz")) {
|
|
3763
|
+
await extractLocalTarball(filePath, destPath);
|
|
3764
|
+
return false;
|
|
3765
|
+
}
|
|
3766
|
+
if (import_node_fs2.default.statSync(filePath).isDirectory()) {
|
|
3767
|
+
return true;
|
|
3768
|
+
}
|
|
3769
|
+
throw new CopyTemplateError(
|
|
3770
|
+
"The provided template is not a valid local directory or tarball."
|
|
3771
|
+
);
|
|
3772
|
+
}
|
|
3773
|
+
var pipeline = (0, import_node_util.promisify)(import_node_stream.default.pipeline);
|
|
3774
|
+
async function extractLocalTarball(tarballPath, destPath) {
|
|
3775
|
+
try {
|
|
3776
|
+
await pipeline(
|
|
3777
|
+
import_node_fs2.default.createReadStream(tarballPath),
|
|
3778
|
+
(0, import_gunzip_maybe.default)(),
|
|
3779
|
+
import_tar_fs.default.extract(destPath, { strip: 1 })
|
|
3780
|
+
);
|
|
3781
|
+
} catch (error2) {
|
|
3782
|
+
throw new CopyTemplateError(
|
|
3783
|
+
`There was a problem extracting the file from the provided template. Template filepath: \`${tarballPath}\` Destination directory: \`${destPath}\` ${error2}`
|
|
3784
|
+
);
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
async function downloadAndExtractRepoTarball(repo, destPath, options) {
|
|
3788
|
+
if (repo.branch && repo.filePath) {
|
|
3789
|
+
let tarballURL = `https://codeload.github.com/${repo.owner}/${repo.name}/tar.gz/${repo.branch}`;
|
|
3790
|
+
return await downloadAndExtractTarball(destPath, tarballURL, {
|
|
3791
|
+
...options,
|
|
3792
|
+
filePath: repo.filePath
|
|
3793
|
+
});
|
|
3794
|
+
}
|
|
3795
|
+
let url2 = `https://api.github.com/repos/${repo.owner}/${repo.name}/tarball`;
|
|
3796
|
+
if (repo.branch) {
|
|
3797
|
+
url2 += `/${repo.branch}`;
|
|
3798
|
+
}
|
|
3799
|
+
return await downloadAndExtractTarball(destPath, url2, {
|
|
3800
|
+
...options,
|
|
3801
|
+
filePath: repo.filePath ?? null
|
|
3802
|
+
});
|
|
3803
|
+
}
|
|
3804
|
+
async function downloadAndExtractTarball(downloadPath, tarballUrl, { token, filePath }) {
|
|
3805
|
+
let resourceUrl = tarballUrl;
|
|
3806
|
+
let headers = {};
|
|
3807
|
+
let isGithubUrl = new URL(tarballUrl).host.endsWith("github.com");
|
|
3808
|
+
if (token && isGithubUrl) {
|
|
3809
|
+
headers.Authorization = `token ${token}`;
|
|
3810
|
+
}
|
|
3811
|
+
if (isGithubReleaseAssetUrl(tarballUrl)) {
|
|
3812
|
+
let info2 = getGithubReleaseAssetInfo(tarballUrl);
|
|
3813
|
+
headers.Accept = "application/vnd.github.v3+json";
|
|
3814
|
+
let releaseUrl = info2.tag === "latest" ? `https://api.github.com/repos/${info2.owner}/${info2.name}/releases/latest` : `https://api.github.com/repos/${info2.owner}/${info2.name}/releases/tags/${info2.tag}`;
|
|
3815
|
+
let response2 = await (0, import_web_fetch.fetch)(releaseUrl, {
|
|
3816
|
+
agent: agent("https://api.github.com"),
|
|
3817
|
+
headers
|
|
3818
|
+
});
|
|
3819
|
+
if (response2.status !== 200) {
|
|
3820
|
+
throw new CopyTemplateError(
|
|
3821
|
+
`There was a problem fetching the file from GitHub. The request responded with a ${response2.status} status. Please try again later.`
|
|
3822
|
+
);
|
|
3823
|
+
}
|
|
3824
|
+
let body = await response2.json();
|
|
3825
|
+
if (!body || typeof body !== "object" || !body.assets || !Array.isArray(body.assets)) {
|
|
3826
|
+
throw new CopyTemplateError(
|
|
3827
|
+
"There was a problem fetching the file from GitHub. No asset was found at that url. Please try again later."
|
|
3828
|
+
);
|
|
3829
|
+
}
|
|
3830
|
+
let assetId = body.assets.find((asset) => {
|
|
3831
|
+
return info2.tag === "latest" ? asset?.browser_download_url?.includes(info2.asset) : asset?.browser_download_url === tarballUrl;
|
|
3832
|
+
})?.id;
|
|
3833
|
+
if (assetId == null) {
|
|
3834
|
+
throw new CopyTemplateError(
|
|
3835
|
+
"There was a problem fetching the file from GitHub. No asset was found at that url. Please try again later."
|
|
3836
|
+
);
|
|
3837
|
+
}
|
|
3838
|
+
resourceUrl = `https://api.github.com/repos/${info2.owner}/${info2.name}/releases/assets/${assetId}`;
|
|
3839
|
+
headers.Accept = "application/octet-stream";
|
|
3840
|
+
}
|
|
3841
|
+
let response = await (0, import_web_fetch.fetch)(resourceUrl, {
|
|
3842
|
+
agent: agent(resourceUrl),
|
|
3843
|
+
headers
|
|
3844
|
+
});
|
|
3845
|
+
if (!response.body || response.status !== 200) {
|
|
3846
|
+
if (token) {
|
|
3847
|
+
throw new CopyTemplateError(
|
|
3848
|
+
`There was a problem fetching the file${isGithubUrl ? " from GitHub" : ""}. The request responded with a ${response.status} status. Perhaps your \`--token\`is expired or invalid.`
|
|
3849
|
+
);
|
|
3850
|
+
}
|
|
3851
|
+
throw new CopyTemplateError(
|
|
3852
|
+
`There was a problem fetching the file${isGithubUrl ? " from GitHub" : ""}. The request responded with a ${response.status} status. Please try again later.`
|
|
3853
|
+
);
|
|
3854
|
+
}
|
|
3855
|
+
if (filePath) {
|
|
3856
|
+
filePath = filePath.split(import_node_path2.default.sep).join(import_node_path2.default.posix.sep);
|
|
3857
|
+
}
|
|
3858
|
+
let filePathHasFiles = false;
|
|
3859
|
+
try {
|
|
3860
|
+
let input = new import_node_stream.default.PassThrough();
|
|
3861
|
+
writeReadableStreamToWritable(response.body, input);
|
|
3862
|
+
await pipeline(
|
|
3863
|
+
input,
|
|
3864
|
+
(0, import_gunzip_maybe.default)(),
|
|
3865
|
+
import_tar_fs.default.extract(downloadPath, {
|
|
3866
|
+
map(header) {
|
|
3867
|
+
let originalDirName = header.name.split("/")[0];
|
|
3868
|
+
header.name = header.name.replace(`${originalDirName}/`, "");
|
|
3869
|
+
if (filePath) {
|
|
3870
|
+
if (filePath.endsWith(import_node_path2.default.posix.sep) && header.name.startsWith(filePath) || !filePath.endsWith(import_node_path2.default.posix.sep) && header.name.startsWith(filePath + import_node_path2.default.posix.sep)) {
|
|
3871
|
+
filePathHasFiles = true;
|
|
3872
|
+
header.name = header.name.replace(filePath, "");
|
|
3873
|
+
} else {
|
|
3874
|
+
header.name = "__IGNORE__";
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
return header;
|
|
3878
|
+
},
|
|
3879
|
+
ignore(_filename, header) {
|
|
3880
|
+
if (!header) {
|
|
3881
|
+
throw Error("Header is undefined");
|
|
3882
|
+
}
|
|
3883
|
+
return header.name === "__IGNORE__";
|
|
3884
|
+
}
|
|
3885
|
+
})
|
|
3886
|
+
);
|
|
3887
|
+
} catch (_) {
|
|
3888
|
+
throw new CopyTemplateError(
|
|
3889
|
+
`There was a problem extracting the file from the provided template. Template URL: \`${tarballUrl}\` Destination directory: \`${downloadPath}\``
|
|
3890
|
+
);
|
|
3891
|
+
}
|
|
3892
|
+
if (filePath && !filePathHasFiles) {
|
|
3893
|
+
throw new CopyTemplateError(
|
|
3894
|
+
`The path "${filePath}" was not found in this ${isGithubUrl ? "GitHub repo." : "tarball."}`
|
|
3895
|
+
);
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
async function writeReadableStreamToWritable(stream2, writable) {
|
|
3899
|
+
let reader = stream2.getReader();
|
|
3900
|
+
let flushable = writable;
|
|
3901
|
+
try {
|
|
3902
|
+
while (true) {
|
|
3903
|
+
let { done, value } = await reader.read();
|
|
3904
|
+
if (done) {
|
|
3905
|
+
writable.end();
|
|
3906
|
+
break;
|
|
3907
|
+
}
|
|
3908
|
+
writable.write(value);
|
|
3909
|
+
if (typeof flushable.flush === "function") {
|
|
3910
|
+
flushable.flush();
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
} catch (error2) {
|
|
3914
|
+
writable.destroy(error2);
|
|
3915
|
+
throw error2;
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
function isValidGithubRepoUrl(input) {
|
|
3919
|
+
if (!isUrl(input)) {
|
|
3920
|
+
return false;
|
|
3921
|
+
}
|
|
3922
|
+
try {
|
|
3923
|
+
let url2 = new URL(input);
|
|
3924
|
+
let pathSegments = url2.pathname.slice(1).split("/");
|
|
3925
|
+
return url2.protocol === "https:" && url2.hostname === "github.com" && // The pathname must have at least 2 segments. If it has more than 2, the
|
|
3926
|
+
// third must be "tree" and it must have at least 4 segments.
|
|
3927
|
+
// https://github.com/:owner/:repo
|
|
3928
|
+
// https://github.com/:owner/:repo/tree/:ref
|
|
3929
|
+
pathSegments.length >= 2 && (pathSegments.length > 2 ? pathSegments[2] === "tree" && pathSegments.length >= 4 : true);
|
|
3930
|
+
} catch (_) {
|
|
3931
|
+
return false;
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
function isGithubRepoShorthand(value) {
|
|
3935
|
+
if (isUrl(value)) {
|
|
3936
|
+
return false;
|
|
3937
|
+
}
|
|
3938
|
+
return /^[\w-]+\/[\w-.]+(\/[\w-.]+)*$/.test(value);
|
|
3939
|
+
}
|
|
3940
|
+
function isGithubReleaseAssetUrl(url2) {
|
|
3941
|
+
return url2.startsWith("https://github.com") && (url2.includes("/releases/download/") || url2.includes("/releases/latest/download/"));
|
|
3942
|
+
}
|
|
3943
|
+
function getGithubReleaseAssetInfo(browserUrl) {
|
|
3944
|
+
let url2 = new URL(browserUrl);
|
|
3945
|
+
let [, owner, name, , downloadOrLatest, tag, asset] = url2.pathname.split("/");
|
|
3946
|
+
if (downloadOrLatest === "latest" && tag === "download") {
|
|
3947
|
+
tag = "latest";
|
|
3948
|
+
}
|
|
3949
|
+
return {
|
|
3950
|
+
browserUrl,
|
|
3951
|
+
owner,
|
|
3952
|
+
name,
|
|
3953
|
+
asset,
|
|
3954
|
+
tag
|
|
3955
|
+
};
|
|
3956
|
+
}
|
|
3957
|
+
function getRepoInfo(validatedGithubUrl) {
|
|
3958
|
+
let url2 = new URL(validatedGithubUrl);
|
|
3959
|
+
let [, owner, name, tree, branch, ...file] = url2.pathname.split("/");
|
|
3960
|
+
let filePath = file.join("/");
|
|
3961
|
+
if (tree === void 0) {
|
|
3962
|
+
return {
|
|
3963
|
+
owner,
|
|
3964
|
+
name,
|
|
3965
|
+
branch: null,
|
|
3966
|
+
filePath: null
|
|
3967
|
+
};
|
|
3968
|
+
}
|
|
3969
|
+
return {
|
|
3970
|
+
owner,
|
|
3971
|
+
name,
|
|
3972
|
+
// If we've validated the GitHub URL and there is a tree, there will also be
|
|
3973
|
+
// a branch
|
|
3974
|
+
branch,
|
|
3975
|
+
filePath: filePath === "" || filePath === "/" ? null : filePath
|
|
3976
|
+
};
|
|
3977
|
+
}
|
|
3978
|
+
var CopyTemplateError = class extends Error {
|
|
3979
|
+
constructor(message) {
|
|
3980
|
+
super(message);
|
|
3981
|
+
this.name = "CopyTemplateError";
|
|
3982
|
+
}
|
|
3983
|
+
};
|
|
3984
|
+
|
|
3985
|
+
// index.ts
|
|
3986
|
+
async function createReactRouter(argv2) {
|
|
3987
|
+
let ctx = await getContext(argv2);
|
|
3988
|
+
if (ctx.help) {
|
|
3989
|
+
printHelp(ctx);
|
|
3990
|
+
return;
|
|
3991
|
+
}
|
|
3992
|
+
if (ctx.versionRequested) {
|
|
3993
|
+
log(version);
|
|
3994
|
+
return;
|
|
3995
|
+
}
|
|
3996
|
+
let steps = [
|
|
3997
|
+
introStep,
|
|
3998
|
+
projectNameStep,
|
|
3999
|
+
copyTemplateToTempDirStep,
|
|
4000
|
+
copyTempDirToAppDirStep,
|
|
4001
|
+
gitInitQuestionStep,
|
|
4002
|
+
installDependenciesQuestionStep,
|
|
4003
|
+
installDependenciesStep,
|
|
4004
|
+
gitInitStep,
|
|
4005
|
+
doneStep
|
|
4006
|
+
];
|
|
4007
|
+
try {
|
|
4008
|
+
for (let step of steps) {
|
|
4009
|
+
await step(ctx);
|
|
4010
|
+
}
|
|
4011
|
+
} catch (err) {
|
|
4012
|
+
if (ctx.debug) {
|
|
4013
|
+
console.error(err);
|
|
4014
|
+
}
|
|
4015
|
+
throw err;
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4018
|
+
async function getContext(argv2) {
|
|
4019
|
+
let flags = (0, import_arg.default)(
|
|
4020
|
+
{
|
|
4021
|
+
"--debug": Boolean,
|
|
4022
|
+
"--react-router-version": String,
|
|
4023
|
+
"-v": "--react-router-version",
|
|
4024
|
+
"--template": String,
|
|
4025
|
+
"--token": String,
|
|
4026
|
+
"--yes": Boolean,
|
|
4027
|
+
"-y": "--yes",
|
|
4028
|
+
"--install": Boolean,
|
|
4029
|
+
"--no-install": Boolean,
|
|
4030
|
+
"--package-manager": String,
|
|
4031
|
+
"--show-install-output": Boolean,
|
|
4032
|
+
"--git-init": Boolean,
|
|
4033
|
+
"--no-git-init": Boolean,
|
|
4034
|
+
"--help": Boolean,
|
|
4035
|
+
"-h": "--help",
|
|
4036
|
+
"--version": Boolean,
|
|
4037
|
+
"--V": "--version",
|
|
4038
|
+
"--no-color": Boolean,
|
|
4039
|
+
"--no-motion": Boolean,
|
|
4040
|
+
"--overwrite": Boolean
|
|
4041
|
+
},
|
|
4042
|
+
{ argv: argv2, permissive: true }
|
|
4043
|
+
);
|
|
4044
|
+
let {
|
|
4045
|
+
"--debug": debug2 = false,
|
|
4046
|
+
"--help": help = false,
|
|
4047
|
+
"--react-router-version": selectedReactRouterVersion,
|
|
4048
|
+
"--template": template,
|
|
4049
|
+
"--token": token,
|
|
4050
|
+
"--install": install,
|
|
4051
|
+
"--no-install": noInstall,
|
|
4052
|
+
"--package-manager": pkgManager,
|
|
4053
|
+
"--show-install-output": showInstallOutput = false,
|
|
4054
|
+
"--git-init": git,
|
|
4055
|
+
"--no-git-init": noGit,
|
|
4056
|
+
"--no-motion": noMotion,
|
|
4057
|
+
"--yes": yes,
|
|
4058
|
+
"--version": versionRequested,
|
|
4059
|
+
"--overwrite": overwrite
|
|
4060
|
+
} = flags;
|
|
4061
|
+
let cwd = flags["_"][0];
|
|
4062
|
+
let interactive = isInteractive();
|
|
4063
|
+
let projectName = cwd;
|
|
4064
|
+
if (!interactive) {
|
|
4065
|
+
yes = true;
|
|
4066
|
+
}
|
|
4067
|
+
if (selectedReactRouterVersion) {
|
|
4068
|
+
if (semver.valid(selectedReactRouterVersion)) {
|
|
4069
|
+
} else if (semver.coerce(selectedReactRouterVersion)) {
|
|
4070
|
+
selectedReactRouterVersion = semver.coerce(
|
|
4071
|
+
selectedReactRouterVersion
|
|
4072
|
+
).version;
|
|
4073
|
+
} else {
|
|
4074
|
+
log(
|
|
4075
|
+
`
|
|
4076
|
+
${color.warning(
|
|
4077
|
+
`${selectedReactRouterVersion} is an invalid version specifier. Using React Router v${version}.`
|
|
4078
|
+
)}`
|
|
4079
|
+
);
|
|
4080
|
+
selectedReactRouterVersion = void 0;
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
let context = {
|
|
4084
|
+
tempDir: import_node_path3.default.join(
|
|
4085
|
+
await import_node_fs3.default.promises.realpath(import_node_os2.default.tmpdir()),
|
|
4086
|
+
`create-react-router--${Math.random().toString(36).substr(2, 8)}`
|
|
4087
|
+
),
|
|
4088
|
+
cwd,
|
|
4089
|
+
overwrite,
|
|
4090
|
+
interactive,
|
|
4091
|
+
debug: debug2,
|
|
4092
|
+
git: git ?? (noGit ? false : yes),
|
|
4093
|
+
help,
|
|
4094
|
+
install: install ?? (noInstall ? false : yes),
|
|
4095
|
+
showInstallOutput,
|
|
4096
|
+
noMotion,
|
|
4097
|
+
pkgManager: validatePackageManager(
|
|
4098
|
+
pkgManager ?? // npm, pnpm, Yarn, and Bun set the user agent environment variable that can be used
|
|
4099
|
+
// to determine which package manager ran the command.
|
|
4100
|
+
(import_node_process6.default.env.npm_config_user_agent ?? "npm").split("/")[0]
|
|
4101
|
+
),
|
|
4102
|
+
projectName,
|
|
4103
|
+
prompt,
|
|
4104
|
+
reactRouterVersion: selectedReactRouterVersion || version,
|
|
4105
|
+
template,
|
|
4106
|
+
token,
|
|
4107
|
+
versionRequested
|
|
4108
|
+
};
|
|
4109
|
+
return context;
|
|
4110
|
+
}
|
|
4111
|
+
async function introStep(ctx) {
|
|
4112
|
+
log(
|
|
4113
|
+
`
|
|
4114
|
+
${" ".repeat(9)}${color.green(
|
|
4115
|
+
color.bold("create-react-router")
|
|
4116
|
+
)} ${color.bold(`v${ctx.reactRouterVersion}`)}`
|
|
4117
|
+
);
|
|
4118
|
+
if (!ctx.interactive) {
|
|
4119
|
+
log("");
|
|
4120
|
+
info("Shell is not interactive.", [
|
|
4121
|
+
`Using default options. This is equivalent to running with the `,
|
|
4122
|
+
color.reset("--yes"),
|
|
4123
|
+
` flag.`
|
|
4124
|
+
]);
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
async function projectNameStep(ctx) {
|
|
4128
|
+
if (!ctx.interactive && !ctx.cwd) {
|
|
4129
|
+
error("Oh no!", "No project directory provided");
|
|
4130
|
+
throw new Error("No project directory provided");
|
|
4131
|
+
}
|
|
4132
|
+
if (ctx.cwd) {
|
|
4133
|
+
await sleep(100);
|
|
4134
|
+
info("Directory:", [
|
|
4135
|
+
"Using ",
|
|
4136
|
+
color.reset(ctx.cwd),
|
|
4137
|
+
" as project directory"
|
|
4138
|
+
]);
|
|
4139
|
+
}
|
|
4140
|
+
if (!ctx.cwd) {
|
|
4141
|
+
let { name: name2 } = await ctx.prompt({
|
|
4142
|
+
name: "name",
|
|
4143
|
+
type: "text",
|
|
4144
|
+
label: title("dir"),
|
|
4145
|
+
message: "Where should we create your new project?",
|
|
4146
|
+
initial: "./my-react-router-app"
|
|
4147
|
+
});
|
|
4148
|
+
ctx.cwd = name2;
|
|
4149
|
+
ctx.projectName = toValidProjectName(name2);
|
|
4150
|
+
return;
|
|
4151
|
+
}
|
|
4152
|
+
let name = ctx.cwd;
|
|
4153
|
+
if (name === "." || name === "./") {
|
|
4154
|
+
let parts = import_node_process6.default.cwd().split(import_node_path3.default.sep);
|
|
4155
|
+
name = parts[parts.length - 1];
|
|
4156
|
+
} else if (name.startsWith("./") || name.startsWith("../")) {
|
|
4157
|
+
let parts = name.split("/");
|
|
4158
|
+
name = parts[parts.length - 1];
|
|
4159
|
+
}
|
|
4160
|
+
ctx.projectName = toValidProjectName(name);
|
|
4161
|
+
}
|
|
4162
|
+
async function copyTemplateToTempDirStep(ctx) {
|
|
4163
|
+
if (ctx.template) {
|
|
4164
|
+
log("");
|
|
4165
|
+
info("Template:", ["Using ", color.reset(ctx.template), "..."]);
|
|
4166
|
+
} else {
|
|
4167
|
+
log("");
|
|
4168
|
+
info("Using basic template");
|
|
4169
|
+
}
|
|
4170
|
+
let template = ctx.template ?? // TODO: (v7) Update to main branch
|
|
4171
|
+
"https://github.com/remix-run/react-router/tree/dev/templates/basic";
|
|
4172
|
+
await loadingIndicator({
|
|
4173
|
+
start: "Template copying...",
|
|
4174
|
+
end: "Template copied",
|
|
4175
|
+
while: async () => {
|
|
4176
|
+
await ensureDirectory(ctx.tempDir);
|
|
4177
|
+
if (ctx.debug) {
|
|
4178
|
+
debug(`Extracting to: ${ctx.tempDir}`);
|
|
4179
|
+
}
|
|
4180
|
+
let result = await copyTemplate(template, ctx.tempDir, {
|
|
4181
|
+
debug: ctx.debug,
|
|
4182
|
+
token: ctx.token,
|
|
4183
|
+
async onError(err) {
|
|
4184
|
+
error(
|
|
4185
|
+
"Oh no!",
|
|
4186
|
+
err instanceof CopyTemplateError ? err.message : "Something went wrong. Run `create-react-router --debug` to see more info.\n\nOpen an issue to report the problem at https://github.com/remix-run/react-router/issues/new"
|
|
4187
|
+
);
|
|
4188
|
+
throw err;
|
|
4189
|
+
},
|
|
4190
|
+
async log(message) {
|
|
4191
|
+
if (ctx.debug) {
|
|
4192
|
+
debug(message);
|
|
4193
|
+
await sleep(500);
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
});
|
|
4197
|
+
if (result?.localTemplateDirectory) {
|
|
4198
|
+
ctx.tempDir = import_node_path3.default.resolve(result.localTemplateDirectory);
|
|
4199
|
+
}
|
|
4200
|
+
},
|
|
4201
|
+
ctx
|
|
4202
|
+
});
|
|
4203
|
+
}
|
|
4204
|
+
async function copyTempDirToAppDirStep(ctx) {
|
|
4205
|
+
await ensureDirectory(ctx.cwd);
|
|
4206
|
+
let files1 = await getDirectoryFilesRecursive(ctx.tempDir);
|
|
4207
|
+
let files2 = await getDirectoryFilesRecursive(ctx.cwd);
|
|
4208
|
+
let collisions = files1.filter((f) => files2.includes(f)).sort((a, b) => a.localeCompare(b));
|
|
4209
|
+
if (collisions.length > 0) {
|
|
4210
|
+
let getFileList = (prefix) => {
|
|
4211
|
+
let moreFiles = collisions.length - 5;
|
|
4212
|
+
let lines2 = ["", ...collisions.slice(0, 5)];
|
|
4213
|
+
if (moreFiles > 0) {
|
|
4214
|
+
lines2.push(`and ${moreFiles} more...`);
|
|
4215
|
+
}
|
|
4216
|
+
return lines2.join(`
|
|
4217
|
+
${prefix}`);
|
|
4218
|
+
};
|
|
4219
|
+
if (ctx.overwrite) {
|
|
4220
|
+
info(
|
|
4221
|
+
"Overwrite:",
|
|
4222
|
+
`overwriting files due to \`--overwrite\`:${getFileList(" ")}`
|
|
4223
|
+
);
|
|
4224
|
+
} else if (!ctx.interactive) {
|
|
4225
|
+
error(
|
|
4226
|
+
"Oh no!",
|
|
4227
|
+
`Destination directory contains files that would be overwritten
|
|
4228
|
+
and no \`--overwrite\` flag was included in a non-interactive
|
|
4229
|
+
environment. The following files would be overwritten:` + getFileList(" ")
|
|
4230
|
+
);
|
|
4231
|
+
throw new Error(
|
|
4232
|
+
"File collisions detected in a non-interactive environment"
|
|
4233
|
+
);
|
|
4234
|
+
} else {
|
|
4235
|
+
if (ctx.debug) {
|
|
4236
|
+
debug(`Colliding files:${getFileList(" ")}`);
|
|
4237
|
+
}
|
|
4238
|
+
let { overwrite } = await ctx.prompt({
|
|
4239
|
+
name: "overwrite",
|
|
4240
|
+
type: "confirm",
|
|
4241
|
+
label: title("overwrite"),
|
|
4242
|
+
message: `Your project directory contains files that will be overwritten by
|
|
4243
|
+
this template (you can force with \`--overwrite\`)
|
|
4244
|
+
|
|
4245
|
+
Files that would be overwritten:${getFileList(" ")}
|
|
4246
|
+
|
|
4247
|
+
Do you wish to continue?
|
|
4248
|
+
`,
|
|
4249
|
+
initial: false
|
|
4250
|
+
});
|
|
4251
|
+
if (!overwrite) {
|
|
4252
|
+
throw new Error("Exiting to avoid overwriting files");
|
|
4253
|
+
}
|
|
4254
|
+
}
|
|
4255
|
+
}
|
|
4256
|
+
await import_fs_extra.default.copy(ctx.tempDir, ctx.cwd, {
|
|
4257
|
+
filter(src, dest) {
|
|
4258
|
+
let file = stripDirectoryFromPath(ctx.tempDir, src);
|
|
4259
|
+
let isIgnored = IGNORED_TEMPLATE_DIRECTORIES.includes(file);
|
|
4260
|
+
if (isIgnored) {
|
|
4261
|
+
if (ctx.debug) {
|
|
4262
|
+
debug(`Skipping copy of ${file} directory from template`);
|
|
4263
|
+
}
|
|
4264
|
+
return false;
|
|
4265
|
+
}
|
|
4266
|
+
return true;
|
|
4267
|
+
}
|
|
4268
|
+
});
|
|
4269
|
+
await updatePackageJSON(ctx);
|
|
4270
|
+
}
|
|
4271
|
+
async function installDependenciesQuestionStep(ctx) {
|
|
4272
|
+
if (ctx.install === void 0) {
|
|
4273
|
+
let { deps = true } = await ctx.prompt({
|
|
4274
|
+
name: "deps",
|
|
4275
|
+
type: "confirm",
|
|
4276
|
+
label: title("deps"),
|
|
4277
|
+
message: `Install dependencies with ${ctx.pkgManager}?`,
|
|
4278
|
+
hint: "recommended",
|
|
4279
|
+
initial: true
|
|
4280
|
+
});
|
|
4281
|
+
ctx.install = deps;
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
async function installDependenciesStep(ctx) {
|
|
4285
|
+
let { install, pkgManager, showInstallOutput, cwd } = ctx;
|
|
4286
|
+
if (!install) {
|
|
4287
|
+
await sleep(100);
|
|
4288
|
+
info("Skipping install step.", [
|
|
4289
|
+
"Remember to install dependencies after setup with ",
|
|
4290
|
+
color.reset(`${pkgManager} install`),
|
|
4291
|
+
"."
|
|
4292
|
+
]);
|
|
4293
|
+
return;
|
|
4294
|
+
}
|
|
4295
|
+
function runInstall() {
|
|
4296
|
+
return installDependencies({
|
|
4297
|
+
cwd,
|
|
4298
|
+
pkgManager,
|
|
4299
|
+
showInstallOutput
|
|
4300
|
+
});
|
|
4301
|
+
}
|
|
4302
|
+
if (showInstallOutput) {
|
|
4303
|
+
log("");
|
|
4304
|
+
info(`Install`, `Dependencies installing with ${pkgManager}...`);
|
|
4305
|
+
log("");
|
|
4306
|
+
await runInstall();
|
|
4307
|
+
log("");
|
|
4308
|
+
return;
|
|
4309
|
+
}
|
|
4310
|
+
log("");
|
|
4311
|
+
await loadingIndicator({
|
|
4312
|
+
start: `Dependencies installing with ${pkgManager}...`,
|
|
4313
|
+
end: "Dependencies installed",
|
|
4314
|
+
while: runInstall,
|
|
4315
|
+
ctx
|
|
4316
|
+
});
|
|
4317
|
+
}
|
|
4318
|
+
async function gitInitQuestionStep(ctx) {
|
|
4319
|
+
if (import_node_fs3.default.existsSync(import_node_path3.default.join(ctx.cwd, ".git"))) {
|
|
4320
|
+
info("Nice!", `Git has already been initialized`);
|
|
4321
|
+
return;
|
|
4322
|
+
}
|
|
4323
|
+
let git = ctx.git;
|
|
4324
|
+
if (ctx.git === void 0) {
|
|
4325
|
+
({ git } = await ctx.prompt({
|
|
4326
|
+
name: "git",
|
|
4327
|
+
type: "confirm",
|
|
4328
|
+
label: title("git"),
|
|
4329
|
+
message: `Initialize a new git repository?`,
|
|
4330
|
+
hint: "recommended",
|
|
4331
|
+
initial: true
|
|
4332
|
+
}));
|
|
4333
|
+
}
|
|
4334
|
+
ctx.git = git ?? false;
|
|
4335
|
+
}
|
|
4336
|
+
async function gitInitStep(ctx) {
|
|
4337
|
+
if (!ctx.git) {
|
|
4338
|
+
return;
|
|
4339
|
+
}
|
|
4340
|
+
if (import_node_fs3.default.existsSync(import_node_path3.default.join(ctx.cwd, ".git"))) {
|
|
4341
|
+
log("");
|
|
4342
|
+
info("Nice!", `Git has already been initialized`);
|
|
4343
|
+
return;
|
|
4344
|
+
}
|
|
4345
|
+
log("");
|
|
4346
|
+
await loadingIndicator({
|
|
4347
|
+
start: "Git initializing...",
|
|
4348
|
+
end: "Git initialized",
|
|
4349
|
+
while: async () => {
|
|
4350
|
+
let options = { cwd: ctx.cwd, stdio: "ignore" };
|
|
4351
|
+
let commitMsg = "Initial commit from create-react-router";
|
|
4352
|
+
try {
|
|
4353
|
+
await (0, import_execa.default)("git", ["init"], options);
|
|
4354
|
+
await (0, import_execa.default)("git", ["add", "."], options);
|
|
4355
|
+
await (0, import_execa.default)("git", ["commit", "-m", commitMsg], options);
|
|
4356
|
+
} catch (err) {
|
|
4357
|
+
error("Oh no!", "Failed to initialize git.");
|
|
4358
|
+
throw err;
|
|
4359
|
+
}
|
|
4360
|
+
},
|
|
4361
|
+
ctx
|
|
4362
|
+
});
|
|
4363
|
+
}
|
|
4364
|
+
async function doneStep(ctx) {
|
|
4365
|
+
let projectDir = import_node_path3.default.relative(import_node_process6.default.cwd(), ctx.cwd);
|
|
4366
|
+
let max = import_node_process6.default.stdout.columns;
|
|
4367
|
+
let prefix = max < 80 ? " " : " ".repeat(9);
|
|
4368
|
+
await sleep(200);
|
|
4369
|
+
log(`
|
|
4370
|
+
${color.bgWhite(color.black(" done "))} That's it!`);
|
|
4371
|
+
await sleep(100);
|
|
4372
|
+
if (projectDir !== "") {
|
|
4373
|
+
let enter = [
|
|
4374
|
+
`
|
|
4375
|
+
${prefix}Enter your project directory using`,
|
|
4376
|
+
color.cyan(`cd .${import_node_path3.default.sep}${projectDir}`)
|
|
4377
|
+
];
|
|
4378
|
+
let len = enter[0].length + (0, import_strip_ansi.default)(enter[1]).length;
|
|
4379
|
+
log(enter.join(len > max ? "\n" + prefix : " "));
|
|
4380
|
+
}
|
|
4381
|
+
log(
|
|
4382
|
+
`${prefix}Check out ${color.bold(
|
|
4383
|
+
"README.md"
|
|
4384
|
+
)} for development and deploy instructions.`
|
|
4385
|
+
);
|
|
4386
|
+
await sleep(100);
|
|
4387
|
+
log(
|
|
4388
|
+
`
|
|
4389
|
+
${prefix}Join the community at ${color.cyan(`https://rmx.as/discord`)}
|
|
4390
|
+
`
|
|
4391
|
+
);
|
|
4392
|
+
await sleep(200);
|
|
4393
|
+
}
|
|
4394
|
+
var packageManagerExecScript = {
|
|
4395
|
+
npm: "npx",
|
|
4396
|
+
yarn: "yarn",
|
|
4397
|
+
pnpm: "pnpm exec",
|
|
4398
|
+
bun: "bunx"
|
|
4399
|
+
};
|
|
4400
|
+
function validatePackageManager(pkgManager) {
|
|
4401
|
+
return packageManagerExecScript.hasOwnProperty(pkgManager) ? pkgManager : "npm";
|
|
4402
|
+
}
|
|
4403
|
+
async function installDependencies({
|
|
4404
|
+
pkgManager,
|
|
4405
|
+
cwd,
|
|
4406
|
+
showInstallOutput
|
|
4407
|
+
}) {
|
|
4408
|
+
try {
|
|
4409
|
+
await (0, import_execa.default)(pkgManager, ["install"], {
|
|
4410
|
+
cwd,
|
|
4411
|
+
stdio: showInstallOutput ? "inherit" : "ignore"
|
|
4412
|
+
});
|
|
4413
|
+
} catch (err) {
|
|
4414
|
+
error("Oh no!", "Failed to install dependencies.");
|
|
4415
|
+
throw err;
|
|
4416
|
+
}
|
|
4417
|
+
}
|
|
4418
|
+
async function updatePackageJSON(ctx) {
|
|
4419
|
+
let packageJSONPath = import_node_path3.default.join(ctx.cwd, "package.json");
|
|
4420
|
+
if (!import_node_fs3.default.existsSync(packageJSONPath)) {
|
|
4421
|
+
let relativePath = import_node_path3.default.relative(import_node_process6.default.cwd(), ctx.cwd);
|
|
4422
|
+
error(
|
|
4423
|
+
"Oh no!",
|
|
4424
|
+
`The provided template must be a React Router project with a \`package.json\` file, but that file does not exist in ${color.bold(relativePath)}.`
|
|
4425
|
+
);
|
|
4426
|
+
throw new Error(`package.json does not exist in ${ctx.cwd}`);
|
|
4427
|
+
}
|
|
4428
|
+
let contents = await import_node_fs3.default.promises.readFile(packageJSONPath, "utf-8");
|
|
4429
|
+
let packageJSON;
|
|
4430
|
+
try {
|
|
4431
|
+
packageJSON = JSON.parse(contents);
|
|
4432
|
+
if (!isValidJsonObject(packageJSON)) {
|
|
4433
|
+
throw Error();
|
|
4434
|
+
}
|
|
4435
|
+
} catch (err) {
|
|
4436
|
+
error(
|
|
4437
|
+
"Oh no!",
|
|
4438
|
+
`The provided template must be a React Router project with a \`package.json\` file, but that file is invalid.`
|
|
4439
|
+
);
|
|
4440
|
+
throw err;
|
|
4441
|
+
}
|
|
4442
|
+
for (let pkgKey of ["dependencies", "devDependencies"]) {
|
|
4443
|
+
let dependencies = packageJSON[pkgKey];
|
|
4444
|
+
if (!dependencies) continue;
|
|
4445
|
+
if (!isValidJsonObject(dependencies)) {
|
|
4446
|
+
error(
|
|
4447
|
+
"Oh no!",
|
|
4448
|
+
`The provided template must be a React Router project with a \`package.json\` file, but its ${pkgKey} value is invalid.`
|
|
4449
|
+
);
|
|
4450
|
+
throw new Error(`package.json ${pkgKey} are invalid`);
|
|
4451
|
+
}
|
|
4452
|
+
for (let dependency in dependencies) {
|
|
4453
|
+
let version2 = dependencies[dependency];
|
|
4454
|
+
if ((dependency.startsWith("@react-router/") || dependency === "react-router" || dependency === "react-router-dom") && version2 === "*") {
|
|
4455
|
+
dependencies[dependency] = semver.prerelease(ctx.reactRouterVersion) ? (
|
|
4456
|
+
// Templates created from prereleases should pin to a specific version
|
|
4457
|
+
ctx.reactRouterVersion
|
|
4458
|
+
) : "^" + ctx.reactRouterVersion;
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
packageJSON.name = ctx.projectName;
|
|
4463
|
+
import_node_fs3.default.promises.writeFile(
|
|
4464
|
+
packageJSONPath,
|
|
4465
|
+
JSON.stringify((0, import_sort_package_json.default)(packageJSON), null, 2),
|
|
4466
|
+
"utf-8"
|
|
4467
|
+
);
|
|
4468
|
+
}
|
|
4469
|
+
async function loadingIndicator(args) {
|
|
4470
|
+
let { ctx, ...rest } = args;
|
|
4471
|
+
await renderLoadingIndicator({
|
|
4472
|
+
...rest,
|
|
4473
|
+
noMotion: args.ctx.noMotion
|
|
4474
|
+
});
|
|
4475
|
+
}
|
|
4476
|
+
function title(text) {
|
|
4477
|
+
return align(color.bgWhite(` ${color.black(text)} `), "end", 7) + " ";
|
|
4478
|
+
}
|
|
4479
|
+
function printHelp(ctx) {
|
|
4480
|
+
let output = `
|
|
4481
|
+
${title("create-react-router")}
|
|
4482
|
+
|
|
4483
|
+
${color.heading("Usage")}:
|
|
4484
|
+
|
|
4485
|
+
${color.dim("$")} ${color.greenBright("create-react-router")} ${color.arg("<projectDir>")} ${color.arg("<...options>")}
|
|
4486
|
+
|
|
4487
|
+
${color.heading("Values")}:
|
|
4488
|
+
|
|
4489
|
+
${color.arg("projectDir")} ${color.dim(`The React Router project directory`)}
|
|
4490
|
+
|
|
4491
|
+
${color.heading("Options")}:
|
|
4492
|
+
|
|
4493
|
+
${color.arg("--help, -h")} ${color.dim(`Print this help message and exit`)}
|
|
4494
|
+
${color.arg("--version, -V")} ${color.dim(`Print the CLI version and exit`)}
|
|
4495
|
+
${color.arg("--no-color")} ${color.dim(`Disable ANSI colors in console output`)}
|
|
4496
|
+
${color.arg("--no-motion")} ${color.dim(`Disable animations in console output`)}
|
|
4497
|
+
|
|
4498
|
+
${color.arg("--template <name>")} ${color.dim(`The project template to use`)}
|
|
4499
|
+
${color.arg("--[no-]install")} ${color.dim(`Whether or not to install dependencies after creation`)}
|
|
4500
|
+
${color.arg("--package-manager")} ${color.dim(`The package manager to use`)}
|
|
4501
|
+
${color.arg("--show-install-output")} ${color.dim(`Whether to show the output of the install process`)}
|
|
4502
|
+
${color.arg("--[no-]git-init")} ${color.dim(`Whether or not to initialize a Git repository`)}
|
|
4503
|
+
${color.arg("--yes, -y")} ${color.dim(`Skip all option prompts and run setup`)}
|
|
4504
|
+
${color.arg("--react-router-version, -v")} ${color.dim(`The version of React Router to use`)}
|
|
4505
|
+
|
|
4506
|
+
${color.heading("Creating a new project")}:
|
|
4507
|
+
|
|
4508
|
+
React Router projects are created from templates. A template can be:
|
|
4509
|
+
|
|
4510
|
+
- a GitHub repo shorthand, :username/:repo or :username/:repo/:directory
|
|
4511
|
+
- the URL of a GitHub repo (or directory within it)
|
|
4512
|
+
- the URL of a tarball
|
|
4513
|
+
- a file path to a directory of files
|
|
4514
|
+
- a file path to a tarball
|
|
4515
|
+
${[
|
|
4516
|
+
"remix-run/react-router/templates/basic",
|
|
4517
|
+
"remix-run/react-router/examples/basic",
|
|
4518
|
+
":username/:repo",
|
|
4519
|
+
":username/:repo/:directory",
|
|
4520
|
+
"https://github.com/:username/:repo",
|
|
4521
|
+
"https://github.com/:username/:repo/tree/:branch",
|
|
4522
|
+
"https://github.com/:username/:repo/tree/:branch/:directory",
|
|
4523
|
+
"https://github.com/:username/:repo/archive/refs/tags/:tag.tar.gz",
|
|
4524
|
+
"https://example.com/template.tar.gz",
|
|
4525
|
+
"./path/to/template",
|
|
4526
|
+
"./path/to/template.tar.gz"
|
|
4527
|
+
].reduce((str, example) => {
|
|
4528
|
+
return `${str}
|
|
4529
|
+
${color.dim("$")} ${color.greenBright("create-react-router")} my-app ${color.arg(`--template ${example}`)}`;
|
|
4530
|
+
}, "")}
|
|
4531
|
+
|
|
4532
|
+
To create a new project from a template in a private GitHub repo,
|
|
4533
|
+
pass the \`token\` flag with a personal access token with access
|
|
4534
|
+
to that repo.
|
|
4535
|
+
`;
|
|
4536
|
+
log(output);
|
|
4537
|
+
}
|
|
4538
|
+
function align(text, dir, len) {
|
|
4539
|
+
let pad = Math.max(len - strip(text).length, 0);
|
|
4540
|
+
switch (dir) {
|
|
4541
|
+
case "start":
|
|
4542
|
+
return text + " ".repeat(pad);
|
|
4543
|
+
case "end":
|
|
4544
|
+
return " ".repeat(pad) + text;
|
|
4545
|
+
case "center":
|
|
4546
|
+
return " ".repeat(Math.floor(pad / 2)) + text + " ".repeat(Math.floor(pad / 2));
|
|
4547
|
+
default:
|
|
4548
|
+
return text;
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4552
|
+
// cli.ts
|
|
4553
|
+
import_node_process7.default.on("SIGINT", () => import_node_process7.default.exit(0));
|
|
4554
|
+
import_node_process7.default.on("SIGTERM", () => import_node_process7.default.exit(0));
|
|
4555
|
+
var argv = import_node_process7.default.argv.slice(2).filter((arg2) => arg2 !== "--");
|
|
4556
|
+
createReactRouter(argv).then(
|
|
4557
|
+
() => import_node_process7.default.exit(0),
|
|
4558
|
+
() => import_node_process7.default.exit(1)
|
|
4559
|
+
);
|
|
4560
|
+
/**
|
|
4561
|
+
* Adapted from https://github.com/withastro/cli-kit
|
|
4562
|
+
* @license MIT License Copyright (c) 2022 Nate Moore
|
|
4563
|
+
*/
|