@orval/hono 6.26.0

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/dist/index.js ADDED
@@ -0,0 +1,2806 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // ../../node_modules/universalify/index.js
34
+ var require_universalify = __commonJS({
35
+ "../../node_modules/universalify/index.js"(exports2) {
36
+ "use strict";
37
+ exports2.fromCallback = function(fn) {
38
+ return Object.defineProperty(function(...args) {
39
+ if (typeof args[args.length - 1] === "function")
40
+ fn.apply(this, args);
41
+ else {
42
+ return new Promise((resolve, reject) => {
43
+ args.push((err, res) => err != null ? reject(err) : resolve(res));
44
+ fn.apply(this, args);
45
+ });
46
+ }
47
+ }, "name", { value: fn.name });
48
+ };
49
+ exports2.fromPromise = function(fn) {
50
+ return Object.defineProperty(function(...args) {
51
+ const cb = args[args.length - 1];
52
+ if (typeof cb !== "function")
53
+ return fn.apply(this, args);
54
+ else {
55
+ args.pop();
56
+ fn.apply(this, args).then((r) => cb(null, r), cb);
57
+ }
58
+ }, "name", { value: fn.name });
59
+ };
60
+ }
61
+ });
62
+
63
+ // ../../node_modules/graceful-fs/polyfills.js
64
+ var require_polyfills = __commonJS({
65
+ "../../node_modules/graceful-fs/polyfills.js"(exports2, module2) {
66
+ "use strict";
67
+ var constants = require("constants");
68
+ var origCwd = process.cwd;
69
+ var cwd = null;
70
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
71
+ process.cwd = function() {
72
+ if (!cwd)
73
+ cwd = origCwd.call(process);
74
+ return cwd;
75
+ };
76
+ try {
77
+ process.cwd();
78
+ } catch (er) {
79
+ }
80
+ if (typeof process.chdir === "function") {
81
+ chdir = process.chdir;
82
+ process.chdir = function(d) {
83
+ cwd = null;
84
+ chdir.call(process, d);
85
+ };
86
+ if (Object.setPrototypeOf)
87
+ Object.setPrototypeOf(process.chdir, chdir);
88
+ }
89
+ var chdir;
90
+ module2.exports = patch;
91
+ function patch(fs2) {
92
+ if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
93
+ patchLchmod(fs2);
94
+ }
95
+ if (!fs2.lutimes) {
96
+ patchLutimes(fs2);
97
+ }
98
+ fs2.chown = chownFix(fs2.chown);
99
+ fs2.fchown = chownFix(fs2.fchown);
100
+ fs2.lchown = chownFix(fs2.lchown);
101
+ fs2.chmod = chmodFix(fs2.chmod);
102
+ fs2.fchmod = chmodFix(fs2.fchmod);
103
+ fs2.lchmod = chmodFix(fs2.lchmod);
104
+ fs2.chownSync = chownFixSync(fs2.chownSync);
105
+ fs2.fchownSync = chownFixSync(fs2.fchownSync);
106
+ fs2.lchownSync = chownFixSync(fs2.lchownSync);
107
+ fs2.chmodSync = chmodFixSync(fs2.chmodSync);
108
+ fs2.fchmodSync = chmodFixSync(fs2.fchmodSync);
109
+ fs2.lchmodSync = chmodFixSync(fs2.lchmodSync);
110
+ fs2.stat = statFix(fs2.stat);
111
+ fs2.fstat = statFix(fs2.fstat);
112
+ fs2.lstat = statFix(fs2.lstat);
113
+ fs2.statSync = statFixSync(fs2.statSync);
114
+ fs2.fstatSync = statFixSync(fs2.fstatSync);
115
+ fs2.lstatSync = statFixSync(fs2.lstatSync);
116
+ if (fs2.chmod && !fs2.lchmod) {
117
+ fs2.lchmod = function(path, mode, cb) {
118
+ if (cb)
119
+ process.nextTick(cb);
120
+ };
121
+ fs2.lchmodSync = function() {
122
+ };
123
+ }
124
+ if (fs2.chown && !fs2.lchown) {
125
+ fs2.lchown = function(path, uid, gid, cb) {
126
+ if (cb)
127
+ process.nextTick(cb);
128
+ };
129
+ fs2.lchownSync = function() {
130
+ };
131
+ }
132
+ if (platform === "win32") {
133
+ fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : function(fs$rename) {
134
+ function rename(from, to, cb) {
135
+ var start = Date.now();
136
+ var backoff = 0;
137
+ fs$rename(from, to, function CB(er) {
138
+ if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
139
+ setTimeout(function() {
140
+ fs2.stat(to, function(stater, st) {
141
+ if (stater && stater.code === "ENOENT")
142
+ fs$rename(from, to, CB);
143
+ else
144
+ cb(er);
145
+ });
146
+ }, backoff);
147
+ if (backoff < 100)
148
+ backoff += 10;
149
+ return;
150
+ }
151
+ if (cb)
152
+ cb(er);
153
+ });
154
+ }
155
+ if (Object.setPrototypeOf)
156
+ Object.setPrototypeOf(rename, fs$rename);
157
+ return rename;
158
+ }(fs2.rename);
159
+ }
160
+ fs2.read = typeof fs2.read !== "function" ? fs2.read : function(fs$read) {
161
+ function read(fd, buffer, offset, length, position, callback_) {
162
+ var callback;
163
+ if (callback_ && typeof callback_ === "function") {
164
+ var eagCounter = 0;
165
+ callback = function(er, _, __) {
166
+ if (er && er.code === "EAGAIN" && eagCounter < 10) {
167
+ eagCounter++;
168
+ return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
169
+ }
170
+ callback_.apply(this, arguments);
171
+ };
172
+ }
173
+ return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
174
+ }
175
+ if (Object.setPrototypeOf)
176
+ Object.setPrototypeOf(read, fs$read);
177
+ return read;
178
+ }(fs2.read);
179
+ fs2.readSync = typeof fs2.readSync !== "function" ? fs2.readSync : /* @__PURE__ */ function(fs$readSync) {
180
+ return function(fd, buffer, offset, length, position) {
181
+ var eagCounter = 0;
182
+ while (true) {
183
+ try {
184
+ return fs$readSync.call(fs2, fd, buffer, offset, length, position);
185
+ } catch (er) {
186
+ if (er.code === "EAGAIN" && eagCounter < 10) {
187
+ eagCounter++;
188
+ continue;
189
+ }
190
+ throw er;
191
+ }
192
+ }
193
+ };
194
+ }(fs2.readSync);
195
+ function patchLchmod(fs3) {
196
+ fs3.lchmod = function(path, mode, callback) {
197
+ fs3.open(
198
+ path,
199
+ constants.O_WRONLY | constants.O_SYMLINK,
200
+ mode,
201
+ function(err, fd) {
202
+ if (err) {
203
+ if (callback)
204
+ callback(err);
205
+ return;
206
+ }
207
+ fs3.fchmod(fd, mode, function(err2) {
208
+ fs3.close(fd, function(err22) {
209
+ if (callback)
210
+ callback(err2 || err22);
211
+ });
212
+ });
213
+ }
214
+ );
215
+ };
216
+ fs3.lchmodSync = function(path, mode) {
217
+ var fd = fs3.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
218
+ var threw = true;
219
+ var ret;
220
+ try {
221
+ ret = fs3.fchmodSync(fd, mode);
222
+ threw = false;
223
+ } finally {
224
+ if (threw) {
225
+ try {
226
+ fs3.closeSync(fd);
227
+ } catch (er) {
228
+ }
229
+ } else {
230
+ fs3.closeSync(fd);
231
+ }
232
+ }
233
+ return ret;
234
+ };
235
+ }
236
+ function patchLutimes(fs3) {
237
+ if (constants.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
238
+ fs3.lutimes = function(path, at, mt, cb) {
239
+ fs3.open(path, constants.O_SYMLINK, function(er, fd) {
240
+ if (er) {
241
+ if (cb)
242
+ cb(er);
243
+ return;
244
+ }
245
+ fs3.futimes(fd, at, mt, function(er2) {
246
+ fs3.close(fd, function(er22) {
247
+ if (cb)
248
+ cb(er2 || er22);
249
+ });
250
+ });
251
+ });
252
+ };
253
+ fs3.lutimesSync = function(path, at, mt) {
254
+ var fd = fs3.openSync(path, constants.O_SYMLINK);
255
+ var ret;
256
+ var threw = true;
257
+ try {
258
+ ret = fs3.futimesSync(fd, at, mt);
259
+ threw = false;
260
+ } finally {
261
+ if (threw) {
262
+ try {
263
+ fs3.closeSync(fd);
264
+ } catch (er) {
265
+ }
266
+ } else {
267
+ fs3.closeSync(fd);
268
+ }
269
+ }
270
+ return ret;
271
+ };
272
+ } else if (fs3.futimes) {
273
+ fs3.lutimes = function(_a, _b, _c, cb) {
274
+ if (cb)
275
+ process.nextTick(cb);
276
+ };
277
+ fs3.lutimesSync = function() {
278
+ };
279
+ }
280
+ }
281
+ function chmodFix(orig) {
282
+ if (!orig)
283
+ return orig;
284
+ return function(target, mode, cb) {
285
+ return orig.call(fs2, target, mode, function(er) {
286
+ if (chownErOk(er))
287
+ er = null;
288
+ if (cb)
289
+ cb.apply(this, arguments);
290
+ });
291
+ };
292
+ }
293
+ function chmodFixSync(orig) {
294
+ if (!orig)
295
+ return orig;
296
+ return function(target, mode) {
297
+ try {
298
+ return orig.call(fs2, target, mode);
299
+ } catch (er) {
300
+ if (!chownErOk(er))
301
+ throw er;
302
+ }
303
+ };
304
+ }
305
+ function chownFix(orig) {
306
+ if (!orig)
307
+ return orig;
308
+ return function(target, uid, gid, cb) {
309
+ return orig.call(fs2, target, uid, gid, function(er) {
310
+ if (chownErOk(er))
311
+ er = null;
312
+ if (cb)
313
+ cb.apply(this, arguments);
314
+ });
315
+ };
316
+ }
317
+ function chownFixSync(orig) {
318
+ if (!orig)
319
+ return orig;
320
+ return function(target, uid, gid) {
321
+ try {
322
+ return orig.call(fs2, target, uid, gid);
323
+ } catch (er) {
324
+ if (!chownErOk(er))
325
+ throw er;
326
+ }
327
+ };
328
+ }
329
+ function statFix(orig) {
330
+ if (!orig)
331
+ return orig;
332
+ return function(target, options, cb) {
333
+ if (typeof options === "function") {
334
+ cb = options;
335
+ options = null;
336
+ }
337
+ function callback(er, stats) {
338
+ if (stats) {
339
+ if (stats.uid < 0)
340
+ stats.uid += 4294967296;
341
+ if (stats.gid < 0)
342
+ stats.gid += 4294967296;
343
+ }
344
+ if (cb)
345
+ cb.apply(this, arguments);
346
+ }
347
+ return options ? orig.call(fs2, target, options, callback) : orig.call(fs2, target, callback);
348
+ };
349
+ }
350
+ function statFixSync(orig) {
351
+ if (!orig)
352
+ return orig;
353
+ return function(target, options) {
354
+ var stats = options ? orig.call(fs2, target, options) : orig.call(fs2, target);
355
+ if (stats) {
356
+ if (stats.uid < 0)
357
+ stats.uid += 4294967296;
358
+ if (stats.gid < 0)
359
+ stats.gid += 4294967296;
360
+ }
361
+ return stats;
362
+ };
363
+ }
364
+ function chownErOk(er) {
365
+ if (!er)
366
+ return true;
367
+ if (er.code === "ENOSYS")
368
+ return true;
369
+ var nonroot = !process.getuid || process.getuid() !== 0;
370
+ if (nonroot) {
371
+ if (er.code === "EINVAL" || er.code === "EPERM")
372
+ return true;
373
+ }
374
+ return false;
375
+ }
376
+ }
377
+ }
378
+ });
379
+
380
+ // ../../node_modules/graceful-fs/legacy-streams.js
381
+ var require_legacy_streams = __commonJS({
382
+ "../../node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
383
+ "use strict";
384
+ var Stream = require("stream").Stream;
385
+ module2.exports = legacy;
386
+ function legacy(fs2) {
387
+ return {
388
+ ReadStream,
389
+ WriteStream
390
+ };
391
+ function ReadStream(path, options) {
392
+ if (!(this instanceof ReadStream))
393
+ return new ReadStream(path, options);
394
+ Stream.call(this);
395
+ var self = this;
396
+ this.path = path;
397
+ this.fd = null;
398
+ this.readable = true;
399
+ this.paused = false;
400
+ this.flags = "r";
401
+ this.mode = 438;
402
+ this.bufferSize = 64 * 1024;
403
+ options = options || {};
404
+ var keys = Object.keys(options);
405
+ for (var index = 0, length = keys.length; index < length; index++) {
406
+ var key = keys[index];
407
+ this[key] = options[key];
408
+ }
409
+ if (this.encoding)
410
+ this.setEncoding(this.encoding);
411
+ if (this.start !== void 0) {
412
+ if ("number" !== typeof this.start) {
413
+ throw TypeError("start must be a Number");
414
+ }
415
+ if (this.end === void 0) {
416
+ this.end = Infinity;
417
+ } else if ("number" !== typeof this.end) {
418
+ throw TypeError("end must be a Number");
419
+ }
420
+ if (this.start > this.end) {
421
+ throw new Error("start must be <= end");
422
+ }
423
+ this.pos = this.start;
424
+ }
425
+ if (this.fd !== null) {
426
+ process.nextTick(function() {
427
+ self._read();
428
+ });
429
+ return;
430
+ }
431
+ fs2.open(this.path, this.flags, this.mode, function(err, fd) {
432
+ if (err) {
433
+ self.emit("error", err);
434
+ self.readable = false;
435
+ return;
436
+ }
437
+ self.fd = fd;
438
+ self.emit("open", fd);
439
+ self._read();
440
+ });
441
+ }
442
+ function WriteStream(path, options) {
443
+ if (!(this instanceof WriteStream))
444
+ return new WriteStream(path, options);
445
+ Stream.call(this);
446
+ this.path = path;
447
+ this.fd = null;
448
+ this.writable = true;
449
+ this.flags = "w";
450
+ this.encoding = "binary";
451
+ this.mode = 438;
452
+ this.bytesWritten = 0;
453
+ options = options || {};
454
+ var keys = Object.keys(options);
455
+ for (var index = 0, length = keys.length; index < length; index++) {
456
+ var key = keys[index];
457
+ this[key] = options[key];
458
+ }
459
+ if (this.start !== void 0) {
460
+ if ("number" !== typeof this.start) {
461
+ throw TypeError("start must be a Number");
462
+ }
463
+ if (this.start < 0) {
464
+ throw new Error("start must be >= zero");
465
+ }
466
+ this.pos = this.start;
467
+ }
468
+ this.busy = false;
469
+ this._queue = [];
470
+ if (this.fd === null) {
471
+ this._open = fs2.open;
472
+ this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
473
+ this.flush();
474
+ }
475
+ }
476
+ }
477
+ }
478
+ });
479
+
480
+ // ../../node_modules/graceful-fs/clone.js
481
+ var require_clone = __commonJS({
482
+ "../../node_modules/graceful-fs/clone.js"(exports2, module2) {
483
+ "use strict";
484
+ module2.exports = clone;
485
+ var getPrototypeOf = Object.getPrototypeOf || function(obj) {
486
+ return obj.__proto__;
487
+ };
488
+ function clone(obj) {
489
+ if (obj === null || typeof obj !== "object")
490
+ return obj;
491
+ if (obj instanceof Object)
492
+ var copy = { __proto__: getPrototypeOf(obj) };
493
+ else
494
+ var copy = /* @__PURE__ */ Object.create(null);
495
+ Object.getOwnPropertyNames(obj).forEach(function(key) {
496
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
497
+ });
498
+ return copy;
499
+ }
500
+ }
501
+ });
502
+
503
+ // ../../node_modules/graceful-fs/graceful-fs.js
504
+ var require_graceful_fs = __commonJS({
505
+ "../../node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
506
+ "use strict";
507
+ var fs2 = require("fs");
508
+ var polyfills = require_polyfills();
509
+ var legacy = require_legacy_streams();
510
+ var clone = require_clone();
511
+ var util = require("util");
512
+ var gracefulQueue;
513
+ var previousSymbol;
514
+ if (typeof Symbol === "function" && typeof Symbol.for === "function") {
515
+ gracefulQueue = Symbol.for("graceful-fs.queue");
516
+ previousSymbol = Symbol.for("graceful-fs.previous");
517
+ } else {
518
+ gracefulQueue = "___graceful-fs.queue";
519
+ previousSymbol = "___graceful-fs.previous";
520
+ }
521
+ function noop() {
522
+ }
523
+ function publishQueue(context, queue2) {
524
+ Object.defineProperty(context, gracefulQueue, {
525
+ get: function() {
526
+ return queue2;
527
+ }
528
+ });
529
+ }
530
+ var debug = noop;
531
+ if (util.debuglog)
532
+ debug = util.debuglog("gfs4");
533
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
534
+ debug = function() {
535
+ var m = util.format.apply(util, arguments);
536
+ m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
537
+ console.error(m);
538
+ };
539
+ if (!fs2[gracefulQueue]) {
540
+ queue = global[gracefulQueue] || [];
541
+ publishQueue(fs2, queue);
542
+ fs2.close = function(fs$close) {
543
+ function close(fd, cb) {
544
+ return fs$close.call(fs2, fd, function(err) {
545
+ if (!err) {
546
+ resetQueue();
547
+ }
548
+ if (typeof cb === "function")
549
+ cb.apply(this, arguments);
550
+ });
551
+ }
552
+ Object.defineProperty(close, previousSymbol, {
553
+ value: fs$close
554
+ });
555
+ return close;
556
+ }(fs2.close);
557
+ fs2.closeSync = function(fs$closeSync) {
558
+ function closeSync(fd) {
559
+ fs$closeSync.apply(fs2, arguments);
560
+ resetQueue();
561
+ }
562
+ Object.defineProperty(closeSync, previousSymbol, {
563
+ value: fs$closeSync
564
+ });
565
+ return closeSync;
566
+ }(fs2.closeSync);
567
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
568
+ process.on("exit", function() {
569
+ debug(fs2[gracefulQueue]);
570
+ require("assert").equal(fs2[gracefulQueue].length, 0);
571
+ });
572
+ }
573
+ }
574
+ var queue;
575
+ if (!global[gracefulQueue]) {
576
+ publishQueue(global, fs2[gracefulQueue]);
577
+ }
578
+ module2.exports = patch(clone(fs2));
579
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) {
580
+ module2.exports = patch(fs2);
581
+ fs2.__patched = true;
582
+ }
583
+ function patch(fs3) {
584
+ polyfills(fs3);
585
+ fs3.gracefulify = patch;
586
+ fs3.createReadStream = createReadStream;
587
+ fs3.createWriteStream = createWriteStream;
588
+ var fs$readFile = fs3.readFile;
589
+ fs3.readFile = readFile;
590
+ function readFile(path, options, cb) {
591
+ if (typeof options === "function")
592
+ cb = options, options = null;
593
+ return go$readFile(path, options, cb);
594
+ function go$readFile(path2, options2, cb2, startTime) {
595
+ return fs$readFile(path2, options2, function(err) {
596
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
597
+ enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
598
+ else {
599
+ if (typeof cb2 === "function")
600
+ cb2.apply(this, arguments);
601
+ }
602
+ });
603
+ }
604
+ }
605
+ var fs$writeFile = fs3.writeFile;
606
+ fs3.writeFile = writeFile;
607
+ function writeFile(path, data, options, cb) {
608
+ if (typeof options === "function")
609
+ cb = options, options = null;
610
+ return go$writeFile(path, data, options, cb);
611
+ function go$writeFile(path2, data2, options2, cb2, startTime) {
612
+ return fs$writeFile(path2, data2, options2, function(err) {
613
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
614
+ enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
615
+ else {
616
+ if (typeof cb2 === "function")
617
+ cb2.apply(this, arguments);
618
+ }
619
+ });
620
+ }
621
+ }
622
+ var fs$appendFile = fs3.appendFile;
623
+ if (fs$appendFile)
624
+ fs3.appendFile = appendFile;
625
+ function appendFile(path, data, options, cb) {
626
+ if (typeof options === "function")
627
+ cb = options, options = null;
628
+ return go$appendFile(path, data, options, cb);
629
+ function go$appendFile(path2, data2, options2, cb2, startTime) {
630
+ return fs$appendFile(path2, data2, options2, function(err) {
631
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
632
+ enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
633
+ else {
634
+ if (typeof cb2 === "function")
635
+ cb2.apply(this, arguments);
636
+ }
637
+ });
638
+ }
639
+ }
640
+ var fs$copyFile = fs3.copyFile;
641
+ if (fs$copyFile)
642
+ fs3.copyFile = copyFile;
643
+ function copyFile(src, dest, flags, cb) {
644
+ if (typeof flags === "function") {
645
+ cb = flags;
646
+ flags = 0;
647
+ }
648
+ return go$copyFile(src, dest, flags, cb);
649
+ function go$copyFile(src2, dest2, flags2, cb2, startTime) {
650
+ return fs$copyFile(src2, dest2, flags2, function(err) {
651
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
652
+ enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
653
+ else {
654
+ if (typeof cb2 === "function")
655
+ cb2.apply(this, arguments);
656
+ }
657
+ });
658
+ }
659
+ }
660
+ var fs$readdir = fs3.readdir;
661
+ fs3.readdir = readdir;
662
+ var noReaddirOptionVersions = /^v[0-5]\./;
663
+ function readdir(path, options, cb) {
664
+ if (typeof options === "function")
665
+ cb = options, options = null;
666
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
667
+ return fs$readdir(path2, fs$readdirCallback(
668
+ path2,
669
+ options2,
670
+ cb2,
671
+ startTime
672
+ ));
673
+ } : function go$readdir2(path2, options2, cb2, startTime) {
674
+ return fs$readdir(path2, options2, fs$readdirCallback(
675
+ path2,
676
+ options2,
677
+ cb2,
678
+ startTime
679
+ ));
680
+ };
681
+ return go$readdir(path, options, cb);
682
+ function fs$readdirCallback(path2, options2, cb2, startTime) {
683
+ return function(err, files) {
684
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
685
+ enqueue([
686
+ go$readdir,
687
+ [path2, options2, cb2],
688
+ err,
689
+ startTime || Date.now(),
690
+ Date.now()
691
+ ]);
692
+ else {
693
+ if (files && files.sort)
694
+ files.sort();
695
+ if (typeof cb2 === "function")
696
+ cb2.call(this, err, files);
697
+ }
698
+ };
699
+ }
700
+ }
701
+ if (process.version.substr(0, 4) === "v0.8") {
702
+ var legStreams = legacy(fs3);
703
+ ReadStream = legStreams.ReadStream;
704
+ WriteStream = legStreams.WriteStream;
705
+ }
706
+ var fs$ReadStream = fs3.ReadStream;
707
+ if (fs$ReadStream) {
708
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
709
+ ReadStream.prototype.open = ReadStream$open;
710
+ }
711
+ var fs$WriteStream = fs3.WriteStream;
712
+ if (fs$WriteStream) {
713
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
714
+ WriteStream.prototype.open = WriteStream$open;
715
+ }
716
+ Object.defineProperty(fs3, "ReadStream", {
717
+ get: function() {
718
+ return ReadStream;
719
+ },
720
+ set: function(val) {
721
+ ReadStream = val;
722
+ },
723
+ enumerable: true,
724
+ configurable: true
725
+ });
726
+ Object.defineProperty(fs3, "WriteStream", {
727
+ get: function() {
728
+ return WriteStream;
729
+ },
730
+ set: function(val) {
731
+ WriteStream = val;
732
+ },
733
+ enumerable: true,
734
+ configurable: true
735
+ });
736
+ var FileReadStream = ReadStream;
737
+ Object.defineProperty(fs3, "FileReadStream", {
738
+ get: function() {
739
+ return FileReadStream;
740
+ },
741
+ set: function(val) {
742
+ FileReadStream = val;
743
+ },
744
+ enumerable: true,
745
+ configurable: true
746
+ });
747
+ var FileWriteStream = WriteStream;
748
+ Object.defineProperty(fs3, "FileWriteStream", {
749
+ get: function() {
750
+ return FileWriteStream;
751
+ },
752
+ set: function(val) {
753
+ FileWriteStream = val;
754
+ },
755
+ enumerable: true,
756
+ configurable: true
757
+ });
758
+ function ReadStream(path, options) {
759
+ if (this instanceof ReadStream)
760
+ return fs$ReadStream.apply(this, arguments), this;
761
+ else
762
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
763
+ }
764
+ function ReadStream$open() {
765
+ var that = this;
766
+ open(that.path, that.flags, that.mode, function(err, fd) {
767
+ if (err) {
768
+ if (that.autoClose)
769
+ that.destroy();
770
+ that.emit("error", err);
771
+ } else {
772
+ that.fd = fd;
773
+ that.emit("open", fd);
774
+ that.read();
775
+ }
776
+ });
777
+ }
778
+ function WriteStream(path, options) {
779
+ if (this instanceof WriteStream)
780
+ return fs$WriteStream.apply(this, arguments), this;
781
+ else
782
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
783
+ }
784
+ function WriteStream$open() {
785
+ var that = this;
786
+ open(that.path, that.flags, that.mode, function(err, fd) {
787
+ if (err) {
788
+ that.destroy();
789
+ that.emit("error", err);
790
+ } else {
791
+ that.fd = fd;
792
+ that.emit("open", fd);
793
+ }
794
+ });
795
+ }
796
+ function createReadStream(path, options) {
797
+ return new fs3.ReadStream(path, options);
798
+ }
799
+ function createWriteStream(path, options) {
800
+ return new fs3.WriteStream(path, options);
801
+ }
802
+ var fs$open = fs3.open;
803
+ fs3.open = open;
804
+ function open(path, flags, mode, cb) {
805
+ if (typeof mode === "function")
806
+ cb = mode, mode = null;
807
+ return go$open(path, flags, mode, cb);
808
+ function go$open(path2, flags2, mode2, cb2, startTime) {
809
+ return fs$open(path2, flags2, mode2, function(err, fd) {
810
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
811
+ enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
812
+ else {
813
+ if (typeof cb2 === "function")
814
+ cb2.apply(this, arguments);
815
+ }
816
+ });
817
+ }
818
+ }
819
+ return fs3;
820
+ }
821
+ function enqueue(elem) {
822
+ debug("ENQUEUE", elem[0].name, elem[1]);
823
+ fs2[gracefulQueue].push(elem);
824
+ retry();
825
+ }
826
+ var retryTimer;
827
+ function resetQueue() {
828
+ var now = Date.now();
829
+ for (var i = 0; i < fs2[gracefulQueue].length; ++i) {
830
+ if (fs2[gracefulQueue][i].length > 2) {
831
+ fs2[gracefulQueue][i][3] = now;
832
+ fs2[gracefulQueue][i][4] = now;
833
+ }
834
+ }
835
+ retry();
836
+ }
837
+ function retry() {
838
+ clearTimeout(retryTimer);
839
+ retryTimer = void 0;
840
+ if (fs2[gracefulQueue].length === 0)
841
+ return;
842
+ var elem = fs2[gracefulQueue].shift();
843
+ var fn = elem[0];
844
+ var args = elem[1];
845
+ var err = elem[2];
846
+ var startTime = elem[3];
847
+ var lastTime = elem[4];
848
+ if (startTime === void 0) {
849
+ debug("RETRY", fn.name, args);
850
+ fn.apply(null, args);
851
+ } else if (Date.now() - startTime >= 6e4) {
852
+ debug("TIMEOUT", fn.name, args);
853
+ var cb = args.pop();
854
+ if (typeof cb === "function")
855
+ cb.call(null, err);
856
+ } else {
857
+ var sinceAttempt = Date.now() - lastTime;
858
+ var sinceStart = Math.max(lastTime - startTime, 1);
859
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
860
+ if (sinceAttempt >= desiredDelay) {
861
+ debug("RETRY", fn.name, args);
862
+ fn.apply(null, args.concat([startTime]));
863
+ } else {
864
+ fs2[gracefulQueue].push(elem);
865
+ }
866
+ }
867
+ if (retryTimer === void 0) {
868
+ retryTimer = setTimeout(retry, 0);
869
+ }
870
+ }
871
+ }
872
+ });
873
+
874
+ // ../../node_modules/fs-extra/lib/fs/index.js
875
+ var require_fs = __commonJS({
876
+ "../../node_modules/fs-extra/lib/fs/index.js"(exports2) {
877
+ "use strict";
878
+ var u = require_universalify().fromCallback;
879
+ var fs2 = require_graceful_fs();
880
+ var api = [
881
+ "access",
882
+ "appendFile",
883
+ "chmod",
884
+ "chown",
885
+ "close",
886
+ "copyFile",
887
+ "fchmod",
888
+ "fchown",
889
+ "fdatasync",
890
+ "fstat",
891
+ "fsync",
892
+ "ftruncate",
893
+ "futimes",
894
+ "lchmod",
895
+ "lchown",
896
+ "link",
897
+ "lstat",
898
+ "mkdir",
899
+ "mkdtemp",
900
+ "open",
901
+ "opendir",
902
+ "readdir",
903
+ "readFile",
904
+ "readlink",
905
+ "realpath",
906
+ "rename",
907
+ "rm",
908
+ "rmdir",
909
+ "stat",
910
+ "symlink",
911
+ "truncate",
912
+ "unlink",
913
+ "utimes",
914
+ "writeFile"
915
+ ].filter((key) => {
916
+ return typeof fs2[key] === "function";
917
+ });
918
+ Object.assign(exports2, fs2);
919
+ api.forEach((method) => {
920
+ exports2[method] = u(fs2[method]);
921
+ });
922
+ exports2.exists = function(filename, callback) {
923
+ if (typeof callback === "function") {
924
+ return fs2.exists(filename, callback);
925
+ }
926
+ return new Promise((resolve) => {
927
+ return fs2.exists(filename, resolve);
928
+ });
929
+ };
930
+ exports2.read = function(fd, buffer, offset, length, position, callback) {
931
+ if (typeof callback === "function") {
932
+ return fs2.read(fd, buffer, offset, length, position, callback);
933
+ }
934
+ return new Promise((resolve, reject) => {
935
+ fs2.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
936
+ if (err)
937
+ return reject(err);
938
+ resolve({ bytesRead, buffer: buffer2 });
939
+ });
940
+ });
941
+ };
942
+ exports2.write = function(fd, buffer, ...args) {
943
+ if (typeof args[args.length - 1] === "function") {
944
+ return fs2.write(fd, buffer, ...args);
945
+ }
946
+ return new Promise((resolve, reject) => {
947
+ fs2.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
948
+ if (err)
949
+ return reject(err);
950
+ resolve({ bytesWritten, buffer: buffer2 });
951
+ });
952
+ });
953
+ };
954
+ exports2.readv = function(fd, buffers, ...args) {
955
+ if (typeof args[args.length - 1] === "function") {
956
+ return fs2.readv(fd, buffers, ...args);
957
+ }
958
+ return new Promise((resolve, reject) => {
959
+ fs2.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
960
+ if (err)
961
+ return reject(err);
962
+ resolve({ bytesRead, buffers: buffers2 });
963
+ });
964
+ });
965
+ };
966
+ exports2.writev = function(fd, buffers, ...args) {
967
+ if (typeof args[args.length - 1] === "function") {
968
+ return fs2.writev(fd, buffers, ...args);
969
+ }
970
+ return new Promise((resolve, reject) => {
971
+ fs2.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
972
+ if (err)
973
+ return reject(err);
974
+ resolve({ bytesWritten, buffers: buffers2 });
975
+ });
976
+ });
977
+ };
978
+ if (typeof fs2.realpath.native === "function") {
979
+ exports2.realpath.native = u(fs2.realpath.native);
980
+ } else {
981
+ process.emitWarning(
982
+ "fs.realpath.native is not a function. Is fs being monkey-patched?",
983
+ "Warning",
984
+ "fs-extra-WARN0003"
985
+ );
986
+ }
987
+ }
988
+ });
989
+
990
+ // ../../node_modules/fs-extra/lib/mkdirs/utils.js
991
+ var require_utils = __commonJS({
992
+ "../../node_modules/fs-extra/lib/mkdirs/utils.js"(exports2, module2) {
993
+ "use strict";
994
+ var path = require("path");
995
+ module2.exports.checkPath = function checkPath(pth) {
996
+ if (process.platform === "win32") {
997
+ const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ""));
998
+ if (pathHasInvalidWinCharacters) {
999
+ const error = new Error(`Path contains invalid characters: ${pth}`);
1000
+ error.code = "EINVAL";
1001
+ throw error;
1002
+ }
1003
+ }
1004
+ };
1005
+ }
1006
+ });
1007
+
1008
+ // ../../node_modules/fs-extra/lib/mkdirs/make-dir.js
1009
+ var require_make_dir = __commonJS({
1010
+ "../../node_modules/fs-extra/lib/mkdirs/make-dir.js"(exports2, module2) {
1011
+ "use strict";
1012
+ var fs2 = require_fs();
1013
+ var { checkPath } = require_utils();
1014
+ var getMode = (options) => {
1015
+ const defaults = { mode: 511 };
1016
+ if (typeof options === "number")
1017
+ return options;
1018
+ return { ...defaults, ...options }.mode;
1019
+ };
1020
+ module2.exports.makeDir = async (dir, options) => {
1021
+ checkPath(dir);
1022
+ return fs2.mkdir(dir, {
1023
+ mode: getMode(options),
1024
+ recursive: true
1025
+ });
1026
+ };
1027
+ module2.exports.makeDirSync = (dir, options) => {
1028
+ checkPath(dir);
1029
+ return fs2.mkdirSync(dir, {
1030
+ mode: getMode(options),
1031
+ recursive: true
1032
+ });
1033
+ };
1034
+ }
1035
+ });
1036
+
1037
+ // ../../node_modules/fs-extra/lib/mkdirs/index.js
1038
+ var require_mkdirs = __commonJS({
1039
+ "../../node_modules/fs-extra/lib/mkdirs/index.js"(exports2, module2) {
1040
+ "use strict";
1041
+ var u = require_universalify().fromPromise;
1042
+ var { makeDir: _makeDir, makeDirSync } = require_make_dir();
1043
+ var makeDir = u(_makeDir);
1044
+ module2.exports = {
1045
+ mkdirs: makeDir,
1046
+ mkdirsSync: makeDirSync,
1047
+ // alias
1048
+ mkdirp: makeDir,
1049
+ mkdirpSync: makeDirSync,
1050
+ ensureDir: makeDir,
1051
+ ensureDirSync: makeDirSync
1052
+ };
1053
+ }
1054
+ });
1055
+
1056
+ // ../../node_modules/fs-extra/lib/path-exists/index.js
1057
+ var require_path_exists = __commonJS({
1058
+ "../../node_modules/fs-extra/lib/path-exists/index.js"(exports2, module2) {
1059
+ "use strict";
1060
+ var u = require_universalify().fromPromise;
1061
+ var fs2 = require_fs();
1062
+ function pathExists(path) {
1063
+ return fs2.access(path).then(() => true).catch(() => false);
1064
+ }
1065
+ module2.exports = {
1066
+ pathExists: u(pathExists),
1067
+ pathExistsSync: fs2.existsSync
1068
+ };
1069
+ }
1070
+ });
1071
+
1072
+ // ../../node_modules/fs-extra/lib/util/utimes.js
1073
+ var require_utimes = __commonJS({
1074
+ "../../node_modules/fs-extra/lib/util/utimes.js"(exports2, module2) {
1075
+ "use strict";
1076
+ var fs2 = require_fs();
1077
+ var u = require_universalify().fromPromise;
1078
+ async function utimesMillis(path, atime, mtime) {
1079
+ const fd = await fs2.open(path, "r+");
1080
+ let closeErr = null;
1081
+ try {
1082
+ await fs2.futimes(fd, atime, mtime);
1083
+ } finally {
1084
+ try {
1085
+ await fs2.close(fd);
1086
+ } catch (e) {
1087
+ closeErr = e;
1088
+ }
1089
+ }
1090
+ if (closeErr) {
1091
+ throw closeErr;
1092
+ }
1093
+ }
1094
+ function utimesMillisSync(path, atime, mtime) {
1095
+ const fd = fs2.openSync(path, "r+");
1096
+ fs2.futimesSync(fd, atime, mtime);
1097
+ return fs2.closeSync(fd);
1098
+ }
1099
+ module2.exports = {
1100
+ utimesMillis: u(utimesMillis),
1101
+ utimesMillisSync
1102
+ };
1103
+ }
1104
+ });
1105
+
1106
+ // ../../node_modules/fs-extra/lib/util/stat.js
1107
+ var require_stat = __commonJS({
1108
+ "../../node_modules/fs-extra/lib/util/stat.js"(exports2, module2) {
1109
+ "use strict";
1110
+ var fs2 = require_fs();
1111
+ var path = require("path");
1112
+ var u = require_universalify().fromPromise;
1113
+ function getStats(src, dest, opts) {
1114
+ const statFunc = opts.dereference ? (file) => fs2.stat(file, { bigint: true }) : (file) => fs2.lstat(file, { bigint: true });
1115
+ return Promise.all([
1116
+ statFunc(src),
1117
+ statFunc(dest).catch((err) => {
1118
+ if (err.code === "ENOENT")
1119
+ return null;
1120
+ throw err;
1121
+ })
1122
+ ]).then(([srcStat, destStat]) => ({ srcStat, destStat }));
1123
+ }
1124
+ function getStatsSync(src, dest, opts) {
1125
+ let destStat;
1126
+ const statFunc = opts.dereference ? (file) => fs2.statSync(file, { bigint: true }) : (file) => fs2.lstatSync(file, { bigint: true });
1127
+ const srcStat = statFunc(src);
1128
+ try {
1129
+ destStat = statFunc(dest);
1130
+ } catch (err) {
1131
+ if (err.code === "ENOENT")
1132
+ return { srcStat, destStat: null };
1133
+ throw err;
1134
+ }
1135
+ return { srcStat, destStat };
1136
+ }
1137
+ async function checkPaths(src, dest, funcName, opts) {
1138
+ const { srcStat, destStat } = await getStats(src, dest, opts);
1139
+ if (destStat) {
1140
+ if (areIdentical(srcStat, destStat)) {
1141
+ const srcBaseName = path.basename(src);
1142
+ const destBaseName = path.basename(dest);
1143
+ if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1144
+ return { srcStat, destStat, isChangingCase: true };
1145
+ }
1146
+ throw new Error("Source and destination must not be the same.");
1147
+ }
1148
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
1149
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
1150
+ }
1151
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
1152
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
1153
+ }
1154
+ }
1155
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1156
+ throw new Error(errMsg(src, dest, funcName));
1157
+ }
1158
+ return { srcStat, destStat };
1159
+ }
1160
+ function checkPathsSync(src, dest, funcName, opts) {
1161
+ const { srcStat, destStat } = getStatsSync(src, dest, opts);
1162
+ if (destStat) {
1163
+ if (areIdentical(srcStat, destStat)) {
1164
+ const srcBaseName = path.basename(src);
1165
+ const destBaseName = path.basename(dest);
1166
+ if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1167
+ return { srcStat, destStat, isChangingCase: true };
1168
+ }
1169
+ throw new Error("Source and destination must not be the same.");
1170
+ }
1171
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
1172
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
1173
+ }
1174
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
1175
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
1176
+ }
1177
+ }
1178
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1179
+ throw new Error(errMsg(src, dest, funcName));
1180
+ }
1181
+ return { srcStat, destStat };
1182
+ }
1183
+ async function checkParentPaths(src, srcStat, dest, funcName) {
1184
+ const srcParent = path.resolve(path.dirname(src));
1185
+ const destParent = path.resolve(path.dirname(dest));
1186
+ if (destParent === srcParent || destParent === path.parse(destParent).root)
1187
+ return;
1188
+ let destStat;
1189
+ try {
1190
+ destStat = await fs2.stat(destParent, { bigint: true });
1191
+ } catch (err) {
1192
+ if (err.code === "ENOENT")
1193
+ return;
1194
+ throw err;
1195
+ }
1196
+ if (areIdentical(srcStat, destStat)) {
1197
+ throw new Error(errMsg(src, dest, funcName));
1198
+ }
1199
+ return checkParentPaths(src, srcStat, destParent, funcName);
1200
+ }
1201
+ function checkParentPathsSync(src, srcStat, dest, funcName) {
1202
+ const srcParent = path.resolve(path.dirname(src));
1203
+ const destParent = path.resolve(path.dirname(dest));
1204
+ if (destParent === srcParent || destParent === path.parse(destParent).root)
1205
+ return;
1206
+ let destStat;
1207
+ try {
1208
+ destStat = fs2.statSync(destParent, { bigint: true });
1209
+ } catch (err) {
1210
+ if (err.code === "ENOENT")
1211
+ return;
1212
+ throw err;
1213
+ }
1214
+ if (areIdentical(srcStat, destStat)) {
1215
+ throw new Error(errMsg(src, dest, funcName));
1216
+ }
1217
+ return checkParentPathsSync(src, srcStat, destParent, funcName);
1218
+ }
1219
+ function areIdentical(srcStat, destStat) {
1220
+ return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
1221
+ }
1222
+ function isSrcSubdir(src, dest) {
1223
+ const srcArr = path.resolve(src).split(path.sep).filter((i) => i);
1224
+ const destArr = path.resolve(dest).split(path.sep).filter((i) => i);
1225
+ return srcArr.every((cur, i) => destArr[i] === cur);
1226
+ }
1227
+ function errMsg(src, dest, funcName) {
1228
+ return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
1229
+ }
1230
+ module2.exports = {
1231
+ // checkPaths
1232
+ checkPaths: u(checkPaths),
1233
+ checkPathsSync,
1234
+ // checkParent
1235
+ checkParentPaths: u(checkParentPaths),
1236
+ checkParentPathsSync,
1237
+ // Misc
1238
+ isSrcSubdir,
1239
+ areIdentical
1240
+ };
1241
+ }
1242
+ });
1243
+
1244
+ // ../../node_modules/fs-extra/lib/copy/copy.js
1245
+ var require_copy = __commonJS({
1246
+ "../../node_modules/fs-extra/lib/copy/copy.js"(exports2, module2) {
1247
+ "use strict";
1248
+ var fs2 = require_fs();
1249
+ var path = require("path");
1250
+ var { mkdirs } = require_mkdirs();
1251
+ var { pathExists } = require_path_exists();
1252
+ var { utimesMillis } = require_utimes();
1253
+ var stat = require_stat();
1254
+ async function copy(src, dest, opts = {}) {
1255
+ if (typeof opts === "function") {
1256
+ opts = { filter: opts };
1257
+ }
1258
+ opts.clobber = "clobber" in opts ? !!opts.clobber : true;
1259
+ opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
1260
+ if (opts.preserveTimestamps && process.arch === "ia32") {
1261
+ process.emitWarning(
1262
+ "Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
1263
+ "Warning",
1264
+ "fs-extra-WARN0001"
1265
+ );
1266
+ }
1267
+ const { srcStat, destStat } = await stat.checkPaths(src, dest, "copy", opts);
1268
+ await stat.checkParentPaths(src, srcStat, dest, "copy");
1269
+ const include = await runFilter(src, dest, opts);
1270
+ if (!include)
1271
+ return;
1272
+ const destParent = path.dirname(dest);
1273
+ const dirExists = await pathExists(destParent);
1274
+ if (!dirExists) {
1275
+ await mkdirs(destParent);
1276
+ }
1277
+ await getStatsAndPerformCopy(destStat, src, dest, opts);
1278
+ }
1279
+ async function runFilter(src, dest, opts) {
1280
+ if (!opts.filter)
1281
+ return true;
1282
+ return opts.filter(src, dest);
1283
+ }
1284
+ async function getStatsAndPerformCopy(destStat, src, dest, opts) {
1285
+ const statFn = opts.dereference ? fs2.stat : fs2.lstat;
1286
+ const srcStat = await statFn(src);
1287
+ if (srcStat.isDirectory())
1288
+ return onDir(srcStat, destStat, src, dest, opts);
1289
+ if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
1290
+ return onFile(srcStat, destStat, src, dest, opts);
1291
+ if (srcStat.isSymbolicLink())
1292
+ return onLink(destStat, src, dest, opts);
1293
+ if (srcStat.isSocket())
1294
+ throw new Error(`Cannot copy a socket file: ${src}`);
1295
+ if (srcStat.isFIFO())
1296
+ throw new Error(`Cannot copy a FIFO pipe: ${src}`);
1297
+ throw new Error(`Unknown file: ${src}`);
1298
+ }
1299
+ async function onFile(srcStat, destStat, src, dest, opts) {
1300
+ if (!destStat)
1301
+ return copyFile(srcStat, src, dest, opts);
1302
+ if (opts.overwrite) {
1303
+ await fs2.unlink(dest);
1304
+ return copyFile(srcStat, src, dest, opts);
1305
+ }
1306
+ if (opts.errorOnExist) {
1307
+ throw new Error(`'${dest}' already exists`);
1308
+ }
1309
+ }
1310
+ async function copyFile(srcStat, src, dest, opts) {
1311
+ await fs2.copyFile(src, dest);
1312
+ if (opts.preserveTimestamps) {
1313
+ if (fileIsNotWritable(srcStat.mode)) {
1314
+ await makeFileWritable(dest, srcStat.mode);
1315
+ }
1316
+ const updatedSrcStat = await fs2.stat(src);
1317
+ await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
1318
+ }
1319
+ return fs2.chmod(dest, srcStat.mode);
1320
+ }
1321
+ function fileIsNotWritable(srcMode) {
1322
+ return (srcMode & 128) === 0;
1323
+ }
1324
+ function makeFileWritable(dest, srcMode) {
1325
+ return fs2.chmod(dest, srcMode | 128);
1326
+ }
1327
+ async function onDir(srcStat, destStat, src, dest, opts) {
1328
+ if (!destStat) {
1329
+ await fs2.mkdir(dest);
1330
+ }
1331
+ const items = await fs2.readdir(src);
1332
+ await Promise.all(items.map(async (item) => {
1333
+ const srcItem = path.join(src, item);
1334
+ const destItem = path.join(dest, item);
1335
+ const include = await runFilter(srcItem, destItem, opts);
1336
+ if (!include)
1337
+ return;
1338
+ const { destStat: destStat2 } = await stat.checkPaths(srcItem, destItem, "copy", opts);
1339
+ return getStatsAndPerformCopy(destStat2, srcItem, destItem, opts);
1340
+ }));
1341
+ if (!destStat) {
1342
+ await fs2.chmod(dest, srcStat.mode);
1343
+ }
1344
+ }
1345
+ async function onLink(destStat, src, dest, opts) {
1346
+ let resolvedSrc = await fs2.readlink(src);
1347
+ if (opts.dereference) {
1348
+ resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
1349
+ }
1350
+ if (!destStat) {
1351
+ return fs2.symlink(resolvedSrc, dest);
1352
+ }
1353
+ let resolvedDest = null;
1354
+ try {
1355
+ resolvedDest = await fs2.readlink(dest);
1356
+ } catch (e) {
1357
+ if (e.code === "EINVAL" || e.code === "UNKNOWN")
1358
+ return fs2.symlink(resolvedSrc, dest);
1359
+ throw e;
1360
+ }
1361
+ if (opts.dereference) {
1362
+ resolvedDest = path.resolve(process.cwd(), resolvedDest);
1363
+ }
1364
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1365
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
1366
+ }
1367
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1368
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
1369
+ }
1370
+ await fs2.unlink(dest);
1371
+ return fs2.symlink(resolvedSrc, dest);
1372
+ }
1373
+ module2.exports = copy;
1374
+ }
1375
+ });
1376
+
1377
+ // ../../node_modules/fs-extra/lib/copy/copy-sync.js
1378
+ var require_copy_sync = __commonJS({
1379
+ "../../node_modules/fs-extra/lib/copy/copy-sync.js"(exports2, module2) {
1380
+ "use strict";
1381
+ var fs2 = require_graceful_fs();
1382
+ var path = require("path");
1383
+ var mkdirsSync = require_mkdirs().mkdirsSync;
1384
+ var utimesMillisSync = require_utimes().utimesMillisSync;
1385
+ var stat = require_stat();
1386
+ function copySync(src, dest, opts) {
1387
+ if (typeof opts === "function") {
1388
+ opts = { filter: opts };
1389
+ }
1390
+ opts = opts || {};
1391
+ opts.clobber = "clobber" in opts ? !!opts.clobber : true;
1392
+ opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
1393
+ if (opts.preserveTimestamps && process.arch === "ia32") {
1394
+ process.emitWarning(
1395
+ "Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
1396
+ "Warning",
1397
+ "fs-extra-WARN0002"
1398
+ );
1399
+ }
1400
+ const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
1401
+ stat.checkParentPathsSync(src, srcStat, dest, "copy");
1402
+ if (opts.filter && !opts.filter(src, dest))
1403
+ return;
1404
+ const destParent = path.dirname(dest);
1405
+ if (!fs2.existsSync(destParent))
1406
+ mkdirsSync(destParent);
1407
+ return getStats(destStat, src, dest, opts);
1408
+ }
1409
+ function getStats(destStat, src, dest, opts) {
1410
+ const statSync = opts.dereference ? fs2.statSync : fs2.lstatSync;
1411
+ const srcStat = statSync(src);
1412
+ if (srcStat.isDirectory())
1413
+ return onDir(srcStat, destStat, src, dest, opts);
1414
+ else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
1415
+ return onFile(srcStat, destStat, src, dest, opts);
1416
+ else if (srcStat.isSymbolicLink())
1417
+ return onLink(destStat, src, dest, opts);
1418
+ else if (srcStat.isSocket())
1419
+ throw new Error(`Cannot copy a socket file: ${src}`);
1420
+ else if (srcStat.isFIFO())
1421
+ throw new Error(`Cannot copy a FIFO pipe: ${src}`);
1422
+ throw new Error(`Unknown file: ${src}`);
1423
+ }
1424
+ function onFile(srcStat, destStat, src, dest, opts) {
1425
+ if (!destStat)
1426
+ return copyFile(srcStat, src, dest, opts);
1427
+ return mayCopyFile(srcStat, src, dest, opts);
1428
+ }
1429
+ function mayCopyFile(srcStat, src, dest, opts) {
1430
+ if (opts.overwrite) {
1431
+ fs2.unlinkSync(dest);
1432
+ return copyFile(srcStat, src, dest, opts);
1433
+ } else if (opts.errorOnExist) {
1434
+ throw new Error(`'${dest}' already exists`);
1435
+ }
1436
+ }
1437
+ function copyFile(srcStat, src, dest, opts) {
1438
+ fs2.copyFileSync(src, dest);
1439
+ if (opts.preserveTimestamps)
1440
+ handleTimestamps(srcStat.mode, src, dest);
1441
+ return setDestMode(dest, srcStat.mode);
1442
+ }
1443
+ function handleTimestamps(srcMode, src, dest) {
1444
+ if (fileIsNotWritable(srcMode))
1445
+ makeFileWritable(dest, srcMode);
1446
+ return setDestTimestamps(src, dest);
1447
+ }
1448
+ function fileIsNotWritable(srcMode) {
1449
+ return (srcMode & 128) === 0;
1450
+ }
1451
+ function makeFileWritable(dest, srcMode) {
1452
+ return setDestMode(dest, srcMode | 128);
1453
+ }
1454
+ function setDestMode(dest, srcMode) {
1455
+ return fs2.chmodSync(dest, srcMode);
1456
+ }
1457
+ function setDestTimestamps(src, dest) {
1458
+ const updatedSrcStat = fs2.statSync(src);
1459
+ return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
1460
+ }
1461
+ function onDir(srcStat, destStat, src, dest, opts) {
1462
+ if (!destStat)
1463
+ return mkDirAndCopy(srcStat.mode, src, dest, opts);
1464
+ return copyDir(src, dest, opts);
1465
+ }
1466
+ function mkDirAndCopy(srcMode, src, dest, opts) {
1467
+ fs2.mkdirSync(dest);
1468
+ copyDir(src, dest, opts);
1469
+ return setDestMode(dest, srcMode);
1470
+ }
1471
+ function copyDir(src, dest, opts) {
1472
+ fs2.readdirSync(src).forEach((item) => copyDirItem(item, src, dest, opts));
1473
+ }
1474
+ function copyDirItem(item, src, dest, opts) {
1475
+ const srcItem = path.join(src, item);
1476
+ const destItem = path.join(dest, item);
1477
+ if (opts.filter && !opts.filter(srcItem, destItem))
1478
+ return;
1479
+ const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
1480
+ return getStats(destStat, srcItem, destItem, opts);
1481
+ }
1482
+ function onLink(destStat, src, dest, opts) {
1483
+ let resolvedSrc = fs2.readlinkSync(src);
1484
+ if (opts.dereference) {
1485
+ resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
1486
+ }
1487
+ if (!destStat) {
1488
+ return fs2.symlinkSync(resolvedSrc, dest);
1489
+ } else {
1490
+ let resolvedDest;
1491
+ try {
1492
+ resolvedDest = fs2.readlinkSync(dest);
1493
+ } catch (err) {
1494
+ if (err.code === "EINVAL" || err.code === "UNKNOWN")
1495
+ return fs2.symlinkSync(resolvedSrc, dest);
1496
+ throw err;
1497
+ }
1498
+ if (opts.dereference) {
1499
+ resolvedDest = path.resolve(process.cwd(), resolvedDest);
1500
+ }
1501
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1502
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
1503
+ }
1504
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1505
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
1506
+ }
1507
+ return copyLink(resolvedSrc, dest);
1508
+ }
1509
+ }
1510
+ function copyLink(resolvedSrc, dest) {
1511
+ fs2.unlinkSync(dest);
1512
+ return fs2.symlinkSync(resolvedSrc, dest);
1513
+ }
1514
+ module2.exports = copySync;
1515
+ }
1516
+ });
1517
+
1518
+ // ../../node_modules/fs-extra/lib/copy/index.js
1519
+ var require_copy2 = __commonJS({
1520
+ "../../node_modules/fs-extra/lib/copy/index.js"(exports2, module2) {
1521
+ "use strict";
1522
+ var u = require_universalify().fromPromise;
1523
+ module2.exports = {
1524
+ copy: u(require_copy()),
1525
+ copySync: require_copy_sync()
1526
+ };
1527
+ }
1528
+ });
1529
+
1530
+ // ../../node_modules/fs-extra/lib/remove/index.js
1531
+ var require_remove = __commonJS({
1532
+ "../../node_modules/fs-extra/lib/remove/index.js"(exports2, module2) {
1533
+ "use strict";
1534
+ var fs2 = require_graceful_fs();
1535
+ var u = require_universalify().fromCallback;
1536
+ function remove(path, callback) {
1537
+ fs2.rm(path, { recursive: true, force: true }, callback);
1538
+ }
1539
+ function removeSync(path) {
1540
+ fs2.rmSync(path, { recursive: true, force: true });
1541
+ }
1542
+ module2.exports = {
1543
+ remove: u(remove),
1544
+ removeSync
1545
+ };
1546
+ }
1547
+ });
1548
+
1549
+ // ../../node_modules/fs-extra/lib/empty/index.js
1550
+ var require_empty = __commonJS({
1551
+ "../../node_modules/fs-extra/lib/empty/index.js"(exports2, module2) {
1552
+ "use strict";
1553
+ var u = require_universalify().fromPromise;
1554
+ var fs2 = require_fs();
1555
+ var path = require("path");
1556
+ var mkdir = require_mkdirs();
1557
+ var remove = require_remove();
1558
+ var emptyDir = u(async function emptyDir2(dir) {
1559
+ let items;
1560
+ try {
1561
+ items = await fs2.readdir(dir);
1562
+ } catch {
1563
+ return mkdir.mkdirs(dir);
1564
+ }
1565
+ return Promise.all(items.map((item) => remove.remove(path.join(dir, item))));
1566
+ });
1567
+ function emptyDirSync(dir) {
1568
+ let items;
1569
+ try {
1570
+ items = fs2.readdirSync(dir);
1571
+ } catch {
1572
+ return mkdir.mkdirsSync(dir);
1573
+ }
1574
+ items.forEach((item) => {
1575
+ item = path.join(dir, item);
1576
+ remove.removeSync(item);
1577
+ });
1578
+ }
1579
+ module2.exports = {
1580
+ emptyDirSync,
1581
+ emptydirSync: emptyDirSync,
1582
+ emptyDir,
1583
+ emptydir: emptyDir
1584
+ };
1585
+ }
1586
+ });
1587
+
1588
+ // ../../node_modules/fs-extra/lib/ensure/file.js
1589
+ var require_file = __commonJS({
1590
+ "../../node_modules/fs-extra/lib/ensure/file.js"(exports2, module2) {
1591
+ "use strict";
1592
+ var u = require_universalify().fromPromise;
1593
+ var path = require("path");
1594
+ var fs2 = require_fs();
1595
+ var mkdir = require_mkdirs();
1596
+ async function createFile(file) {
1597
+ let stats;
1598
+ try {
1599
+ stats = await fs2.stat(file);
1600
+ } catch {
1601
+ }
1602
+ if (stats && stats.isFile())
1603
+ return;
1604
+ const dir = path.dirname(file);
1605
+ let dirStats = null;
1606
+ try {
1607
+ dirStats = await fs2.stat(dir);
1608
+ } catch (err) {
1609
+ if (err.code === "ENOENT") {
1610
+ await mkdir.mkdirs(dir);
1611
+ await fs2.writeFile(file, "");
1612
+ return;
1613
+ } else {
1614
+ throw err;
1615
+ }
1616
+ }
1617
+ if (dirStats.isDirectory()) {
1618
+ await fs2.writeFile(file, "");
1619
+ } else {
1620
+ await fs2.readdir(dir);
1621
+ }
1622
+ }
1623
+ function createFileSync(file) {
1624
+ let stats;
1625
+ try {
1626
+ stats = fs2.statSync(file);
1627
+ } catch {
1628
+ }
1629
+ if (stats && stats.isFile())
1630
+ return;
1631
+ const dir = path.dirname(file);
1632
+ try {
1633
+ if (!fs2.statSync(dir).isDirectory()) {
1634
+ fs2.readdirSync(dir);
1635
+ }
1636
+ } catch (err) {
1637
+ if (err && err.code === "ENOENT")
1638
+ mkdir.mkdirsSync(dir);
1639
+ else
1640
+ throw err;
1641
+ }
1642
+ fs2.writeFileSync(file, "");
1643
+ }
1644
+ module2.exports = {
1645
+ createFile: u(createFile),
1646
+ createFileSync
1647
+ };
1648
+ }
1649
+ });
1650
+
1651
+ // ../../node_modules/fs-extra/lib/ensure/link.js
1652
+ var require_link = __commonJS({
1653
+ "../../node_modules/fs-extra/lib/ensure/link.js"(exports2, module2) {
1654
+ "use strict";
1655
+ var u = require_universalify().fromPromise;
1656
+ var path = require("path");
1657
+ var fs2 = require_fs();
1658
+ var mkdir = require_mkdirs();
1659
+ var { pathExists } = require_path_exists();
1660
+ var { areIdentical } = require_stat();
1661
+ async function createLink(srcpath, dstpath) {
1662
+ let dstStat;
1663
+ try {
1664
+ dstStat = await fs2.lstat(dstpath);
1665
+ } catch {
1666
+ }
1667
+ let srcStat;
1668
+ try {
1669
+ srcStat = await fs2.lstat(srcpath);
1670
+ } catch (err) {
1671
+ err.message = err.message.replace("lstat", "ensureLink");
1672
+ throw err;
1673
+ }
1674
+ if (dstStat && areIdentical(srcStat, dstStat))
1675
+ return;
1676
+ const dir = path.dirname(dstpath);
1677
+ const dirExists = await pathExists(dir);
1678
+ if (!dirExists) {
1679
+ await mkdir.mkdirs(dir);
1680
+ }
1681
+ await fs2.link(srcpath, dstpath);
1682
+ }
1683
+ function createLinkSync(srcpath, dstpath) {
1684
+ let dstStat;
1685
+ try {
1686
+ dstStat = fs2.lstatSync(dstpath);
1687
+ } catch {
1688
+ }
1689
+ try {
1690
+ const srcStat = fs2.lstatSync(srcpath);
1691
+ if (dstStat && areIdentical(srcStat, dstStat))
1692
+ return;
1693
+ } catch (err) {
1694
+ err.message = err.message.replace("lstat", "ensureLink");
1695
+ throw err;
1696
+ }
1697
+ const dir = path.dirname(dstpath);
1698
+ const dirExists = fs2.existsSync(dir);
1699
+ if (dirExists)
1700
+ return fs2.linkSync(srcpath, dstpath);
1701
+ mkdir.mkdirsSync(dir);
1702
+ return fs2.linkSync(srcpath, dstpath);
1703
+ }
1704
+ module2.exports = {
1705
+ createLink: u(createLink),
1706
+ createLinkSync
1707
+ };
1708
+ }
1709
+ });
1710
+
1711
+ // ../../node_modules/fs-extra/lib/ensure/symlink-paths.js
1712
+ var require_symlink_paths = __commonJS({
1713
+ "../../node_modules/fs-extra/lib/ensure/symlink-paths.js"(exports2, module2) {
1714
+ "use strict";
1715
+ var path = require("path");
1716
+ var fs2 = require_fs();
1717
+ var { pathExists } = require_path_exists();
1718
+ var u = require_universalify().fromPromise;
1719
+ async function symlinkPaths(srcpath, dstpath) {
1720
+ if (path.isAbsolute(srcpath)) {
1721
+ try {
1722
+ await fs2.lstat(srcpath);
1723
+ } catch (err) {
1724
+ err.message = err.message.replace("lstat", "ensureSymlink");
1725
+ throw err;
1726
+ }
1727
+ return {
1728
+ toCwd: srcpath,
1729
+ toDst: srcpath
1730
+ };
1731
+ }
1732
+ const dstdir = path.dirname(dstpath);
1733
+ const relativeToDst = path.join(dstdir, srcpath);
1734
+ const exists = await pathExists(relativeToDst);
1735
+ if (exists) {
1736
+ return {
1737
+ toCwd: relativeToDst,
1738
+ toDst: srcpath
1739
+ };
1740
+ }
1741
+ try {
1742
+ await fs2.lstat(srcpath);
1743
+ } catch (err) {
1744
+ err.message = err.message.replace("lstat", "ensureSymlink");
1745
+ throw err;
1746
+ }
1747
+ return {
1748
+ toCwd: srcpath,
1749
+ toDst: path.relative(dstdir, srcpath)
1750
+ };
1751
+ }
1752
+ function symlinkPathsSync(srcpath, dstpath) {
1753
+ if (path.isAbsolute(srcpath)) {
1754
+ const exists2 = fs2.existsSync(srcpath);
1755
+ if (!exists2)
1756
+ throw new Error("absolute srcpath does not exist");
1757
+ return {
1758
+ toCwd: srcpath,
1759
+ toDst: srcpath
1760
+ };
1761
+ }
1762
+ const dstdir = path.dirname(dstpath);
1763
+ const relativeToDst = path.join(dstdir, srcpath);
1764
+ const exists = fs2.existsSync(relativeToDst);
1765
+ if (exists) {
1766
+ return {
1767
+ toCwd: relativeToDst,
1768
+ toDst: srcpath
1769
+ };
1770
+ }
1771
+ const srcExists = fs2.existsSync(srcpath);
1772
+ if (!srcExists)
1773
+ throw new Error("relative srcpath does not exist");
1774
+ return {
1775
+ toCwd: srcpath,
1776
+ toDst: path.relative(dstdir, srcpath)
1777
+ };
1778
+ }
1779
+ module2.exports = {
1780
+ symlinkPaths: u(symlinkPaths),
1781
+ symlinkPathsSync
1782
+ };
1783
+ }
1784
+ });
1785
+
1786
+ // ../../node_modules/fs-extra/lib/ensure/symlink-type.js
1787
+ var require_symlink_type = __commonJS({
1788
+ "../../node_modules/fs-extra/lib/ensure/symlink-type.js"(exports2, module2) {
1789
+ "use strict";
1790
+ var fs2 = require_fs();
1791
+ var u = require_universalify().fromPromise;
1792
+ async function symlinkType(srcpath, type) {
1793
+ if (type)
1794
+ return type;
1795
+ let stats;
1796
+ try {
1797
+ stats = await fs2.lstat(srcpath);
1798
+ } catch {
1799
+ return "file";
1800
+ }
1801
+ return stats && stats.isDirectory() ? "dir" : "file";
1802
+ }
1803
+ function symlinkTypeSync(srcpath, type) {
1804
+ if (type)
1805
+ return type;
1806
+ let stats;
1807
+ try {
1808
+ stats = fs2.lstatSync(srcpath);
1809
+ } catch {
1810
+ return "file";
1811
+ }
1812
+ return stats && stats.isDirectory() ? "dir" : "file";
1813
+ }
1814
+ module2.exports = {
1815
+ symlinkType: u(symlinkType),
1816
+ symlinkTypeSync
1817
+ };
1818
+ }
1819
+ });
1820
+
1821
+ // ../../node_modules/fs-extra/lib/ensure/symlink.js
1822
+ var require_symlink = __commonJS({
1823
+ "../../node_modules/fs-extra/lib/ensure/symlink.js"(exports2, module2) {
1824
+ "use strict";
1825
+ var u = require_universalify().fromPromise;
1826
+ var path = require("path");
1827
+ var fs2 = require_fs();
1828
+ var { mkdirs, mkdirsSync } = require_mkdirs();
1829
+ var { symlinkPaths, symlinkPathsSync } = require_symlink_paths();
1830
+ var { symlinkType, symlinkTypeSync } = require_symlink_type();
1831
+ var { pathExists } = require_path_exists();
1832
+ var { areIdentical } = require_stat();
1833
+ async function createSymlink(srcpath, dstpath, type) {
1834
+ let stats;
1835
+ try {
1836
+ stats = await fs2.lstat(dstpath);
1837
+ } catch {
1838
+ }
1839
+ if (stats && stats.isSymbolicLink()) {
1840
+ const [srcStat, dstStat] = await Promise.all([
1841
+ fs2.stat(srcpath),
1842
+ fs2.stat(dstpath)
1843
+ ]);
1844
+ if (areIdentical(srcStat, dstStat))
1845
+ return;
1846
+ }
1847
+ const relative = await symlinkPaths(srcpath, dstpath);
1848
+ srcpath = relative.toDst;
1849
+ const toType = await symlinkType(relative.toCwd, type);
1850
+ const dir = path.dirname(dstpath);
1851
+ if (!await pathExists(dir)) {
1852
+ await mkdirs(dir);
1853
+ }
1854
+ return fs2.symlink(srcpath, dstpath, toType);
1855
+ }
1856
+ function createSymlinkSync(srcpath, dstpath, type) {
1857
+ let stats;
1858
+ try {
1859
+ stats = fs2.lstatSync(dstpath);
1860
+ } catch {
1861
+ }
1862
+ if (stats && stats.isSymbolicLink()) {
1863
+ const srcStat = fs2.statSync(srcpath);
1864
+ const dstStat = fs2.statSync(dstpath);
1865
+ if (areIdentical(srcStat, dstStat))
1866
+ return;
1867
+ }
1868
+ const relative = symlinkPathsSync(srcpath, dstpath);
1869
+ srcpath = relative.toDst;
1870
+ type = symlinkTypeSync(relative.toCwd, type);
1871
+ const dir = path.dirname(dstpath);
1872
+ const exists = fs2.existsSync(dir);
1873
+ if (exists)
1874
+ return fs2.symlinkSync(srcpath, dstpath, type);
1875
+ mkdirsSync(dir);
1876
+ return fs2.symlinkSync(srcpath, dstpath, type);
1877
+ }
1878
+ module2.exports = {
1879
+ createSymlink: u(createSymlink),
1880
+ createSymlinkSync
1881
+ };
1882
+ }
1883
+ });
1884
+
1885
+ // ../../node_modules/fs-extra/lib/ensure/index.js
1886
+ var require_ensure = __commonJS({
1887
+ "../../node_modules/fs-extra/lib/ensure/index.js"(exports2, module2) {
1888
+ "use strict";
1889
+ var { createFile, createFileSync } = require_file();
1890
+ var { createLink, createLinkSync } = require_link();
1891
+ var { createSymlink, createSymlinkSync } = require_symlink();
1892
+ module2.exports = {
1893
+ // file
1894
+ createFile,
1895
+ createFileSync,
1896
+ ensureFile: createFile,
1897
+ ensureFileSync: createFileSync,
1898
+ // link
1899
+ createLink,
1900
+ createLinkSync,
1901
+ ensureLink: createLink,
1902
+ ensureLinkSync: createLinkSync,
1903
+ // symlink
1904
+ createSymlink,
1905
+ createSymlinkSync,
1906
+ ensureSymlink: createSymlink,
1907
+ ensureSymlinkSync: createSymlinkSync
1908
+ };
1909
+ }
1910
+ });
1911
+
1912
+ // ../../node_modules/jsonfile/utils.js
1913
+ var require_utils2 = __commonJS({
1914
+ "../../node_modules/jsonfile/utils.js"(exports2, module2) {
1915
+ "use strict";
1916
+ function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
1917
+ const EOF = finalEOL ? EOL : "";
1918
+ const str = JSON.stringify(obj, replacer, spaces);
1919
+ return str.replace(/\n/g, EOL) + EOF;
1920
+ }
1921
+ function stripBom(content) {
1922
+ if (Buffer.isBuffer(content))
1923
+ content = content.toString("utf8");
1924
+ return content.replace(/^\uFEFF/, "");
1925
+ }
1926
+ module2.exports = { stringify, stripBom };
1927
+ }
1928
+ });
1929
+
1930
+ // ../../node_modules/jsonfile/index.js
1931
+ var require_jsonfile = __commonJS({
1932
+ "../../node_modules/jsonfile/index.js"(exports2, module2) {
1933
+ "use strict";
1934
+ var _fs;
1935
+ try {
1936
+ _fs = require_graceful_fs();
1937
+ } catch (_) {
1938
+ _fs = require("fs");
1939
+ }
1940
+ var universalify = require_universalify();
1941
+ var { stringify, stripBom } = require_utils2();
1942
+ async function _readFile(file, options = {}) {
1943
+ if (typeof options === "string") {
1944
+ options = { encoding: options };
1945
+ }
1946
+ const fs2 = options.fs || _fs;
1947
+ const shouldThrow = "throws" in options ? options.throws : true;
1948
+ let data = await universalify.fromCallback(fs2.readFile)(file, options);
1949
+ data = stripBom(data);
1950
+ let obj;
1951
+ try {
1952
+ obj = JSON.parse(data, options ? options.reviver : null);
1953
+ } catch (err) {
1954
+ if (shouldThrow) {
1955
+ err.message = `${file}: ${err.message}`;
1956
+ throw err;
1957
+ } else {
1958
+ return null;
1959
+ }
1960
+ }
1961
+ return obj;
1962
+ }
1963
+ var readFile = universalify.fromPromise(_readFile);
1964
+ function readFileSync(file, options = {}) {
1965
+ if (typeof options === "string") {
1966
+ options = { encoding: options };
1967
+ }
1968
+ const fs2 = options.fs || _fs;
1969
+ const shouldThrow = "throws" in options ? options.throws : true;
1970
+ try {
1971
+ let content = fs2.readFileSync(file, options);
1972
+ content = stripBom(content);
1973
+ return JSON.parse(content, options.reviver);
1974
+ } catch (err) {
1975
+ if (shouldThrow) {
1976
+ err.message = `${file}: ${err.message}`;
1977
+ throw err;
1978
+ } else {
1979
+ return null;
1980
+ }
1981
+ }
1982
+ }
1983
+ async function _writeFile(file, obj, options = {}) {
1984
+ const fs2 = options.fs || _fs;
1985
+ const str = stringify(obj, options);
1986
+ await universalify.fromCallback(fs2.writeFile)(file, str, options);
1987
+ }
1988
+ var writeFile = universalify.fromPromise(_writeFile);
1989
+ function writeFileSync(file, obj, options = {}) {
1990
+ const fs2 = options.fs || _fs;
1991
+ const str = stringify(obj, options);
1992
+ return fs2.writeFileSync(file, str, options);
1993
+ }
1994
+ var jsonfile = {
1995
+ readFile,
1996
+ readFileSync,
1997
+ writeFile,
1998
+ writeFileSync
1999
+ };
2000
+ module2.exports = jsonfile;
2001
+ }
2002
+ });
2003
+
2004
+ // ../../node_modules/fs-extra/lib/json/jsonfile.js
2005
+ var require_jsonfile2 = __commonJS({
2006
+ "../../node_modules/fs-extra/lib/json/jsonfile.js"(exports2, module2) {
2007
+ "use strict";
2008
+ var jsonFile = require_jsonfile();
2009
+ module2.exports = {
2010
+ // jsonfile exports
2011
+ readJson: jsonFile.readFile,
2012
+ readJsonSync: jsonFile.readFileSync,
2013
+ writeJson: jsonFile.writeFile,
2014
+ writeJsonSync: jsonFile.writeFileSync
2015
+ };
2016
+ }
2017
+ });
2018
+
2019
+ // ../../node_modules/fs-extra/lib/output-file/index.js
2020
+ var require_output_file = __commonJS({
2021
+ "../../node_modules/fs-extra/lib/output-file/index.js"(exports2, module2) {
2022
+ "use strict";
2023
+ var u = require_universalify().fromPromise;
2024
+ var fs2 = require_fs();
2025
+ var path = require("path");
2026
+ var mkdir = require_mkdirs();
2027
+ var pathExists = require_path_exists().pathExists;
2028
+ async function outputFile(file, data, encoding = "utf-8") {
2029
+ const dir = path.dirname(file);
2030
+ if (!await pathExists(dir)) {
2031
+ await mkdir.mkdirs(dir);
2032
+ }
2033
+ return fs2.writeFile(file, data, encoding);
2034
+ }
2035
+ function outputFileSync(file, ...args) {
2036
+ const dir = path.dirname(file);
2037
+ if (!fs2.existsSync(dir)) {
2038
+ mkdir.mkdirsSync(dir);
2039
+ }
2040
+ fs2.writeFileSync(file, ...args);
2041
+ }
2042
+ module2.exports = {
2043
+ outputFile: u(outputFile),
2044
+ outputFileSync
2045
+ };
2046
+ }
2047
+ });
2048
+
2049
+ // ../../node_modules/fs-extra/lib/json/output-json.js
2050
+ var require_output_json = __commonJS({
2051
+ "../../node_modules/fs-extra/lib/json/output-json.js"(exports2, module2) {
2052
+ "use strict";
2053
+ var { stringify } = require_utils2();
2054
+ var { outputFile } = require_output_file();
2055
+ async function outputJson(file, data, options = {}) {
2056
+ const str = stringify(data, options);
2057
+ await outputFile(file, str, options);
2058
+ }
2059
+ module2.exports = outputJson;
2060
+ }
2061
+ });
2062
+
2063
+ // ../../node_modules/fs-extra/lib/json/output-json-sync.js
2064
+ var require_output_json_sync = __commonJS({
2065
+ "../../node_modules/fs-extra/lib/json/output-json-sync.js"(exports2, module2) {
2066
+ "use strict";
2067
+ var { stringify } = require_utils2();
2068
+ var { outputFileSync } = require_output_file();
2069
+ function outputJsonSync(file, data, options) {
2070
+ const str = stringify(data, options);
2071
+ outputFileSync(file, str, options);
2072
+ }
2073
+ module2.exports = outputJsonSync;
2074
+ }
2075
+ });
2076
+
2077
+ // ../../node_modules/fs-extra/lib/json/index.js
2078
+ var require_json = __commonJS({
2079
+ "../../node_modules/fs-extra/lib/json/index.js"(exports2, module2) {
2080
+ "use strict";
2081
+ var u = require_universalify().fromPromise;
2082
+ var jsonFile = require_jsonfile2();
2083
+ jsonFile.outputJson = u(require_output_json());
2084
+ jsonFile.outputJsonSync = require_output_json_sync();
2085
+ jsonFile.outputJSON = jsonFile.outputJson;
2086
+ jsonFile.outputJSONSync = jsonFile.outputJsonSync;
2087
+ jsonFile.writeJSON = jsonFile.writeJson;
2088
+ jsonFile.writeJSONSync = jsonFile.writeJsonSync;
2089
+ jsonFile.readJSON = jsonFile.readJson;
2090
+ jsonFile.readJSONSync = jsonFile.readJsonSync;
2091
+ module2.exports = jsonFile;
2092
+ }
2093
+ });
2094
+
2095
+ // ../../node_modules/fs-extra/lib/move/move.js
2096
+ var require_move = __commonJS({
2097
+ "../../node_modules/fs-extra/lib/move/move.js"(exports2, module2) {
2098
+ "use strict";
2099
+ var fs2 = require_fs();
2100
+ var path = require("path");
2101
+ var { copy } = require_copy2();
2102
+ var { remove } = require_remove();
2103
+ var { mkdirp } = require_mkdirs();
2104
+ var { pathExists } = require_path_exists();
2105
+ var stat = require_stat();
2106
+ async function move(src, dest, opts = {}) {
2107
+ const overwrite = opts.overwrite || opts.clobber || false;
2108
+ const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, "move", opts);
2109
+ await stat.checkParentPaths(src, srcStat, dest, "move");
2110
+ const destParent = path.dirname(dest);
2111
+ const parsedParentPath = path.parse(destParent);
2112
+ if (parsedParentPath.root !== destParent) {
2113
+ await mkdirp(destParent);
2114
+ }
2115
+ return doRename(src, dest, overwrite, isChangingCase);
2116
+ }
2117
+ async function doRename(src, dest, overwrite, isChangingCase) {
2118
+ if (!isChangingCase) {
2119
+ if (overwrite) {
2120
+ await remove(dest);
2121
+ } else if (await pathExists(dest)) {
2122
+ throw new Error("dest already exists.");
2123
+ }
2124
+ }
2125
+ try {
2126
+ await fs2.rename(src, dest);
2127
+ } catch (err) {
2128
+ if (err.code !== "EXDEV") {
2129
+ throw err;
2130
+ }
2131
+ await moveAcrossDevice(src, dest, overwrite);
2132
+ }
2133
+ }
2134
+ async function moveAcrossDevice(src, dest, overwrite) {
2135
+ const opts = {
2136
+ overwrite,
2137
+ errorOnExist: true,
2138
+ preserveTimestamps: true
2139
+ };
2140
+ await copy(src, dest, opts);
2141
+ return remove(src);
2142
+ }
2143
+ module2.exports = move;
2144
+ }
2145
+ });
2146
+
2147
+ // ../../node_modules/fs-extra/lib/move/move-sync.js
2148
+ var require_move_sync = __commonJS({
2149
+ "../../node_modules/fs-extra/lib/move/move-sync.js"(exports2, module2) {
2150
+ "use strict";
2151
+ var fs2 = require_graceful_fs();
2152
+ var path = require("path");
2153
+ var copySync = require_copy2().copySync;
2154
+ var removeSync = require_remove().removeSync;
2155
+ var mkdirpSync = require_mkdirs().mkdirpSync;
2156
+ var stat = require_stat();
2157
+ function moveSync(src, dest, opts) {
2158
+ opts = opts || {};
2159
+ const overwrite = opts.overwrite || opts.clobber || false;
2160
+ const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
2161
+ stat.checkParentPathsSync(src, srcStat, dest, "move");
2162
+ if (!isParentRoot(dest))
2163
+ mkdirpSync(path.dirname(dest));
2164
+ return doRename(src, dest, overwrite, isChangingCase);
2165
+ }
2166
+ function isParentRoot(dest) {
2167
+ const parent = path.dirname(dest);
2168
+ const parsedPath = path.parse(parent);
2169
+ return parsedPath.root === parent;
2170
+ }
2171
+ function doRename(src, dest, overwrite, isChangingCase) {
2172
+ if (isChangingCase)
2173
+ return rename(src, dest, overwrite);
2174
+ if (overwrite) {
2175
+ removeSync(dest);
2176
+ return rename(src, dest, overwrite);
2177
+ }
2178
+ if (fs2.existsSync(dest))
2179
+ throw new Error("dest already exists.");
2180
+ return rename(src, dest, overwrite);
2181
+ }
2182
+ function rename(src, dest, overwrite) {
2183
+ try {
2184
+ fs2.renameSync(src, dest);
2185
+ } catch (err) {
2186
+ if (err.code !== "EXDEV")
2187
+ throw err;
2188
+ return moveAcrossDevice(src, dest, overwrite);
2189
+ }
2190
+ }
2191
+ function moveAcrossDevice(src, dest, overwrite) {
2192
+ const opts = {
2193
+ overwrite,
2194
+ errorOnExist: true,
2195
+ preserveTimestamps: true
2196
+ };
2197
+ copySync(src, dest, opts);
2198
+ return removeSync(src);
2199
+ }
2200
+ module2.exports = moveSync;
2201
+ }
2202
+ });
2203
+
2204
+ // ../../node_modules/fs-extra/lib/move/index.js
2205
+ var require_move2 = __commonJS({
2206
+ "../../node_modules/fs-extra/lib/move/index.js"(exports2, module2) {
2207
+ "use strict";
2208
+ var u = require_universalify().fromPromise;
2209
+ module2.exports = {
2210
+ move: u(require_move()),
2211
+ moveSync: require_move_sync()
2212
+ };
2213
+ }
2214
+ });
2215
+
2216
+ // ../../node_modules/fs-extra/lib/index.js
2217
+ var require_lib = __commonJS({
2218
+ "../../node_modules/fs-extra/lib/index.js"(exports2, module2) {
2219
+ "use strict";
2220
+ module2.exports = {
2221
+ // Export promiseified graceful-fs:
2222
+ ...require_fs(),
2223
+ // Export extra methods:
2224
+ ...require_copy2(),
2225
+ ...require_empty(),
2226
+ ...require_ensure(),
2227
+ ...require_json(),
2228
+ ...require_mkdirs(),
2229
+ ...require_move2(),
2230
+ ...require_output_file(),
2231
+ ...require_path_exists(),
2232
+ ...require_remove()
2233
+ };
2234
+ }
2235
+ });
2236
+
2237
+ // src/index.ts
2238
+ var src_exports = {};
2239
+ __export(src_exports, {
2240
+ builder: () => builder,
2241
+ default: () => src_default,
2242
+ generateExtraFiles: () => generateExtraFiles,
2243
+ generateHono: () => generateHono,
2244
+ getHonoDependencies: () => getHonoDependencies,
2245
+ getHonoFooter: () => getHonoFooter,
2246
+ getHonoHeader: () => getHonoHeader
2247
+ });
2248
+ module.exports = __toCommonJS(src_exports);
2249
+ var import_core2 = require("@orval/core");
2250
+
2251
+ // src/route.ts
2252
+ var import_core = require("@orval/core");
2253
+ var hasParam = (path) => /[^{]*{[\w*_-]*}.*/.test(path);
2254
+ var getRoutePath = (path) => {
2255
+ const matches = path.match(/([^{]*){?([\w*_-]*)}?(.*)/);
2256
+ if (!(matches == null ? void 0 : matches.length))
2257
+ return path;
2258
+ const prev = matches[1];
2259
+ const param = (0, import_core.sanitize)((0, import_core.camel)(matches[2]), {
2260
+ es5keyword: true,
2261
+ underscore: true,
2262
+ dash: true,
2263
+ dot: true
2264
+ });
2265
+ const next = hasParam(matches[3]) ? getRoutePath(matches[3]) : matches[3];
2266
+ if (hasParam(path)) {
2267
+ return `${prev}:${param}${next}`;
2268
+ } else {
2269
+ return `${prev}${param}${next}`;
2270
+ }
2271
+ };
2272
+ var getRoute = (route) => {
2273
+ const splittedRoute = route.split("/");
2274
+ return splittedRoute.reduce((acc, path, i) => {
2275
+ if (!path && !i) {
2276
+ return acc;
2277
+ }
2278
+ if (!path.includes("{")) {
2279
+ return `${acc}/${path}`;
2280
+ }
2281
+ return `${acc}/${getRoutePath(path)}`;
2282
+ }, "");
2283
+ };
2284
+
2285
+ // src/index.ts
2286
+ var import_fs_extra = __toESM(require_lib());
2287
+ var import_zod = require("@orval/zod");
2288
+ var HONO_DEPENDENCIES = [
2289
+ {
2290
+ exports: [
2291
+ {
2292
+ name: "Hono",
2293
+ values: true
2294
+ },
2295
+ {
2296
+ name: "Context"
2297
+ },
2298
+ {
2299
+ name: "Env"
2300
+ }
2301
+ ],
2302
+ dependency: "hono"
2303
+ },
2304
+ {
2305
+ exports: [
2306
+ {
2307
+ name: "zValidator",
2308
+ values: true
2309
+ }
2310
+ ],
2311
+ dependency: "@hono/zod-validator"
2312
+ }
2313
+ ];
2314
+ var getHonoDependencies = () => HONO_DEPENDENCIES;
2315
+ var getHonoHeader = ({
2316
+ verbOptions,
2317
+ output,
2318
+ tag,
2319
+ clientImplementation
2320
+ }) => {
2321
+ var _a, _b;
2322
+ const targetFileName = (_a = (0, import_core2.getFileInfo)(output.target)) == null ? void 0 : _a.filename;
2323
+ let handlers = "";
2324
+ if ((_b = output.override.hono) == null ? void 0 : _b.handlers) {
2325
+ handlers = Object.keys(verbOptions).filter(
2326
+ (operationName) => clientImplementation.includes(`${operationName}Handlers`)
2327
+ ).map((operationName) => {
2328
+ var _a2, _b2;
2329
+ const handlersPath = import_core2.upath.getSpecName(
2330
+ import_core2.upath.join((_a2 = output.override.hono.handlers) != null ? _a2 : "", `./${operationName}`),
2331
+ (_b2 = output.target) != null ? _b2 : ""
2332
+ );
2333
+ return `import { ${operationName}Handlers } from '.${handlersPath}';`;
2334
+ }).join("\n");
2335
+ } else {
2336
+ handlers = `import {
2337
+ ${Object.keys(verbOptions).map((operationName) => ` ${operationName}Handlers`).join(`,
2338
+ `)}
2339
+ } from './${tag != null ? tag : targetFileName}.handlers';`;
2340
+ }
2341
+ return `${handlers}
2342
+
2343
+
2344
+ const app = new Hono()
2345
+
2346
+ `;
2347
+ };
2348
+ var getHonoFooter = () => "export default app";
2349
+ var generateHonoRoute = ({ operationName, verb, queryParams, params, body }, { pathRoute }) => {
2350
+ const path = getRoute(pathRoute);
2351
+ return `
2352
+ app.${verb.toLowerCase()}('${path}',...${operationName}Handlers)`;
2353
+ };
2354
+ var generateHono = async (verbOptions, options) => {
2355
+ const routeImplementation = generateHonoRoute(verbOptions, options);
2356
+ return {
2357
+ implementation: routeImplementation ? `${routeImplementation}
2358
+
2359
+ ` : "",
2360
+ imports: [
2361
+ ...verbOptions.params.map((param) => param.imports).flat(),
2362
+ ...verbOptions.body.imports,
2363
+ ...verbOptions.queryParams ? [
2364
+ {
2365
+ name: verbOptions.queryParams.schema.name
2366
+ }
2367
+ ] : []
2368
+ ]
2369
+ };
2370
+ };
2371
+ var getHonoHandlers = ({
2372
+ handlerName,
2373
+ contextTypeName,
2374
+ verbOption
2375
+ }) => {
2376
+ return `
2377
+ export const ${handlerName} = factory.createHandlers(
2378
+ ${verbOption.headers ? `zValidator('header', ${verbOption.operationName}Header),
2379
+ ` : ""}${verbOption.params.length ? `zValidator('param', ${verbOption.operationName}Params),
2380
+ ` : ""}${verbOption.queryParams ? `zValidator('query', ${verbOption.operationName}QueryParams),
2381
+ ` : ""}${verbOption.body.definition ? `zValidator('json', ${verbOption.operationName}Body),
2382
+ ` : ""}(c: ${contextTypeName}) => {
2383
+
2384
+ },
2385
+ );`;
2386
+ };
2387
+ var getZvalidatorImports = (verbOption) => {
2388
+ let imports = [];
2389
+ if (verbOption.headers) {
2390
+ imports.push(`${verbOption.operationName}Header`);
2391
+ }
2392
+ if (verbOption.params.length) {
2393
+ imports.push(`${verbOption.operationName}Params`);
2394
+ }
2395
+ if (verbOption.queryParams) {
2396
+ imports.push(`${verbOption.operationName}QueryParams`);
2397
+ }
2398
+ if (verbOption.body.definition) {
2399
+ imports.push(`${verbOption.operationName}Body`);
2400
+ }
2401
+ return imports.join(",\n");
2402
+ };
2403
+ var getHandlerFix = ({
2404
+ rawFile,
2405
+ content,
2406
+ hasZValidator
2407
+ }) => {
2408
+ let newContent = content;
2409
+ if (!rawFile.includes("import { createFactory } from 'hono/factory';")) {
2410
+ newContent = `import { createFactory } from 'hono/factory';
2411
+ ${newContent}`;
2412
+ }
2413
+ if (!rawFile.includes("@hono/zod-validator") && hasZValidator) {
2414
+ newContent = `import { zValidator } from '@hono/zod-validator';
2415
+ ${newContent}`;
2416
+ }
2417
+ if (!rawFile.includes("const factory = createFactory();")) {
2418
+ newContent += "\nconst factory = createFactory();";
2419
+ }
2420
+ return newContent;
2421
+ };
2422
+ var getVerbOptionGroupByTag = (verbOptions) => {
2423
+ return Object.values(verbOptions).reduce(
2424
+ (acc, value) => {
2425
+ const tag = value.tags[0];
2426
+ if (!acc[tag]) {
2427
+ acc[tag] = [];
2428
+ }
2429
+ acc[tag].push(value);
2430
+ return acc;
2431
+ },
2432
+ {}
2433
+ );
2434
+ };
2435
+ var generateHandlers = async (verbOptions, output) => {
2436
+ const { pathWithoutExtension, extension, dirname, filename } = (0, import_core2.getFileInfo)(
2437
+ output.target
2438
+ );
2439
+ if (output.override.hono.handlers) {
2440
+ return Promise.all(
2441
+ Object.values(verbOptions).map(async (verbOption) => {
2442
+ var _a, _b, _c;
2443
+ const isTagMode = output.mode === "tags" || output.mode === "tags-split";
2444
+ const tag = (0, import_core2.kebab)((_a = verbOption.tags[0]) != null ? _a : "default");
2445
+ const outputPath = import_core2.upath.relativeSafe(
2446
+ (_b = output.override.hono.handlers) != null ? _b : "",
2447
+ isTagMode ? `${dirname}/${tag}/${tag}` : pathWithoutExtension
2448
+ );
2449
+ const handlerPath2 = import_core2.upath.join(
2450
+ (_c = output.override.hono.handlers) != null ? _c : "",
2451
+ `./${verbOption.operationName}` + extension
2452
+ );
2453
+ const hasZValidator2 = !!verbOption.headers || !!verbOption.params.length || !!verbOption.queryParams || !!verbOption.body;
2454
+ const isExist2 = import_fs_extra.default.existsSync(handlerPath2);
2455
+ const handlerName = `${verbOption.operationName}Handlers`;
2456
+ const contextTypeName = `${(0, import_core2.pascal)(verbOption.operationName)}Context`;
2457
+ if (isExist2) {
2458
+ const rawFile = await import_fs_extra.default.readFile(handlerPath2, "utf8");
2459
+ let content3 = getHandlerFix({
2460
+ rawFile,
2461
+ content: rawFile,
2462
+ hasZValidator: hasZValidator2
2463
+ });
2464
+ if (!rawFile.includes(handlerName)) {
2465
+ content3 += getHonoHandlers({
2466
+ handlerName,
2467
+ contextTypeName,
2468
+ verbOption
2469
+ });
2470
+ }
2471
+ return {
2472
+ content: content3,
2473
+ path: handlerPath2
2474
+ };
2475
+ }
2476
+ const content2 = `import { createFactory } from 'hono/factory';${hasZValidator2 ? `
2477
+ import { zValidator } from '@hono/zod-validator';` : ""}
2478
+ import { ${contextTypeName} } from '${outputPath}.context';
2479
+ import { ${getZvalidatorImports(verbOption)} } from '${outputPath}.zod';
2480
+
2481
+ const factory = createFactory();
2482
+
2483
+ ${getHonoHandlers({
2484
+ handlerName,
2485
+ contextTypeName,
2486
+ verbOption
2487
+ })}
2488
+ `;
2489
+ return {
2490
+ content: content2,
2491
+ path: handlerPath2
2492
+ };
2493
+ })
2494
+ );
2495
+ }
2496
+ if (output.mode === "tags" || output.mode === "tags-split") {
2497
+ const groupByTags = getVerbOptionGroupByTag(verbOptions);
2498
+ return Promise.all(
2499
+ Object.entries(groupByTags).map(async ([tag, verbs]) => {
2500
+ const handlerPath2 = output.mode === "tags" ? import_core2.upath.join(dirname, `${(0, import_core2.kebab)(tag)}.handlers${extension}`) : import_core2.upath.join(dirname, tag, tag + ".handlers" + extension);
2501
+ const hasZValidator2 = verbs.some(
2502
+ (verb) => !!verb.headers || !!verb.params.length || !!verb.queryParams || !!verb.body
2503
+ );
2504
+ const isExist2 = import_fs_extra.default.existsSync(handlerPath2);
2505
+ if (isExist2) {
2506
+ const rawFile = await import_fs_extra.default.readFile(handlerPath2, "utf8");
2507
+ let content3 = getHandlerFix({
2508
+ rawFile,
2509
+ content: rawFile,
2510
+ hasZValidator: hasZValidator2
2511
+ });
2512
+ content3 += Object.values(verbs).reduce((acc, verbOption) => {
2513
+ const handlerName = `${verbOption.operationName}Handlers`;
2514
+ const contextTypeName = `${(0, import_core2.pascal)(
2515
+ verbOption.operationName
2516
+ )}Context`;
2517
+ if (!rawFile.includes(handlerName)) {
2518
+ acc += getHonoHandlers({
2519
+ handlerName,
2520
+ contextTypeName,
2521
+ verbOption
2522
+ });
2523
+ }
2524
+ return acc;
2525
+ }, "");
2526
+ return {
2527
+ content: content3,
2528
+ path: handlerPath2
2529
+ };
2530
+ }
2531
+ const outputRelativePath2 = `./${(0, import_core2.kebab)(tag)}`;
2532
+ let content2 = `import { createFactory } from 'hono/factory';${hasZValidator2 ? `
2533
+ import { zValidator } from '@hono/zod-validator';` : ""}
2534
+ import { ${Object.values(verbs).map((verb) => `${(0, import_core2.pascal)(verb.operationName)}Context`).join(",\n")} } from '${outputRelativePath2}.context';
2535
+ import { ${Object.values(verbs).map((verb) => getZvalidatorImports(verb)).join(",\n")} } from '${outputRelativePath2}.zod';
2536
+
2537
+ const factory = createFactory();`;
2538
+ content2 += Object.values(verbs).reduce((acc, verbOption) => {
2539
+ const handlerName = `${verbOption.operationName}Handlers`;
2540
+ const contextTypeName = `${(0, import_core2.pascal)(verbOption.operationName)}Context`;
2541
+ acc += getHonoHandlers({
2542
+ handlerName,
2543
+ contextTypeName,
2544
+ verbOption
2545
+ });
2546
+ return acc;
2547
+ }, "");
2548
+ return {
2549
+ content: content2,
2550
+ path: handlerPath2
2551
+ };
2552
+ })
2553
+ );
2554
+ }
2555
+ const hasZValidator = Object.values(verbOptions).some(
2556
+ (verb) => !!verb.headers || !!verb.params.length || !!verb.queryParams || !!verb.body
2557
+ );
2558
+ const handlerPath = import_core2.upath.join(dirname, `${filename}.handlers${extension}`);
2559
+ const isExist = import_fs_extra.default.existsSync(handlerPath);
2560
+ if (isExist) {
2561
+ const rawFile = await import_fs_extra.default.readFile(handlerPath, "utf8");
2562
+ let content2 = getHandlerFix({
2563
+ rawFile,
2564
+ content: rawFile,
2565
+ hasZValidator
2566
+ });
2567
+ content2 += Object.values(verbOptions).reduce((acc, verbOption) => {
2568
+ const handlerName = `${verbOption.operationName}Handlers`;
2569
+ const contextTypeName = `${(0, import_core2.pascal)(verbOption.operationName)}Context`;
2570
+ if (!rawFile.includes(handlerName)) {
2571
+ acc += getHonoHandlers({
2572
+ handlerName,
2573
+ contextTypeName,
2574
+ verbOption
2575
+ });
2576
+ }
2577
+ return acc;
2578
+ }, "");
2579
+ return [
2580
+ {
2581
+ content: content2,
2582
+ path: handlerPath
2583
+ }
2584
+ ];
2585
+ }
2586
+ const outputRelativePath = `./${filename}`;
2587
+ let content = `import { createFactory } from 'hono/factory';${hasZValidator ? `
2588
+ import { zValidator } from '@hono/zod-validator';` : ""}
2589
+ import { ${Object.values(verbOptions).map((verb) => `${(0, import_core2.pascal)(verb.operationName)}Context`).join(",\n")} } from '${outputRelativePath}.context';
2590
+ import { ${Object.values(verbOptions).map((verb) => getZvalidatorImports(verb)).join(",\n")} } from '${outputRelativePath}.zod';
2591
+
2592
+ const factory = createFactory();`;
2593
+ content += Object.values(verbOptions).reduce((acc, verbOption) => {
2594
+ const handlerName = `${verbOption.operationName}Handlers`;
2595
+ const contextTypeName = `${(0, import_core2.pascal)(verbOption.operationName)}Context`;
2596
+ acc += getHonoHandlers({
2597
+ handlerName,
2598
+ contextTypeName,
2599
+ verbOption
2600
+ });
2601
+ return acc;
2602
+ }, "");
2603
+ return [
2604
+ {
2605
+ content,
2606
+ path: handlerPath
2607
+ }
2608
+ ];
2609
+ };
2610
+ var getContext = (verbOption) => {
2611
+ var _a;
2612
+ const paramType = verbOption.params.length ? `param: {
2613
+ ${verbOption.params.map((property) => property.definition).join(",\n ")},
2614
+ },` : "";
2615
+ const queryType = verbOption.queryParams ? `query: ${(_a = verbOption.queryParams) == null ? void 0 : _a.schema.name},` : "";
2616
+ const bodyType = verbOption.body.definition ? `json: ${verbOption.body.definition},` : "";
2617
+ const hasIn = !!paramType || !!queryType || !!bodyType;
2618
+ return `export type ${(0, import_core2.pascal)(
2619
+ verbOption.operationName
2620
+ )}Context<E extends Env = any> = Context<E, '${verbOption.pathRoute}', ${hasIn ? `{ in: { ${paramType}${queryType}${bodyType} }}` : ""}>`;
2621
+ };
2622
+ var getHeader = (option, info) => {
2623
+ if (!option) {
2624
+ return "";
2625
+ }
2626
+ const header = option(info);
2627
+ return Array.isArray(header) ? (0, import_core2.jsDoc)({ description: header }) : header;
2628
+ };
2629
+ var generateContext = async (verbOptions, output, context) => {
2630
+ const header = getHeader(
2631
+ output.override.header,
2632
+ context.specs[context.specKey].info
2633
+ );
2634
+ const { extension, dirname, filename } = (0, import_core2.getFileInfo)(output.target);
2635
+ if (output.mode === "tags" || output.mode === "tags-split") {
2636
+ const groupByTags = getVerbOptionGroupByTag(verbOptions);
2637
+ let relativeSchemasPath2 = output.mode === "tags-split" ? "../" : "";
2638
+ relativeSchemasPath2 += output.schemas ? import_core2.upath.relativeSafe(dirname, (0, import_core2.getFileInfo)(output.schemas).dirname) : `${filename}.schemas`;
2639
+ return Promise.all(
2640
+ Object.entries(groupByTags).map(async ([tag, verbs]) => {
2641
+ let content2 = `${header}import type { Context, Env } from 'hono';
2642
+
2643
+ `;
2644
+ const contexts2 = verbs.map((verb) => getContext(verb)).join("\n");
2645
+ const imps2 = verbs.flatMap((verb) => {
2646
+ let imports = [];
2647
+ if (verb.params.length) {
2648
+ imports.push(...verb.params.map((param) => param.imports).flat());
2649
+ }
2650
+ if (verb.queryParams) {
2651
+ imports.push({
2652
+ name: verb.queryParams.schema.name
2653
+ });
2654
+ }
2655
+ if (verb.body.definition) {
2656
+ imports.push(...verb.body.imports);
2657
+ }
2658
+ return imports;
2659
+ }).filter((imp) => contexts2.includes(imp.name));
2660
+ if (contexts2.includes("NonReadonly<")) {
2661
+ content2 += (0, import_core2.getOrvalGeneratedTypes)();
2662
+ content2 += "\n";
2663
+ }
2664
+ content2 += `import { ${imps2.map((imp) => imp.name).join(",\n")} } from '${relativeSchemasPath2}';
2665
+
2666
+ `;
2667
+ content2 += contexts2;
2668
+ const contextPath2 = output.mode === "tags" ? import_core2.upath.join(dirname, `${(0, import_core2.kebab)(tag)}.context${extension}`) : import_core2.upath.join(dirname, tag, tag + ".context" + extension);
2669
+ return {
2670
+ content: content2,
2671
+ path: contextPath2
2672
+ };
2673
+ })
2674
+ );
2675
+ }
2676
+ let content = `${header}import type { Context, Env } from 'hono';
2677
+
2678
+ `;
2679
+ const contextPath = import_core2.upath.join(dirname, `${filename}.context${extension}`);
2680
+ const contexts = Object.values(verbOptions).map((verbOption) => getContext(verbOption)).join("\n");
2681
+ const imps = Object.values(verbOptions).flatMap((verb) => {
2682
+ let imports = [];
2683
+ if (verb.params.length) {
2684
+ imports.push(...verb.params.map((param) => param.imports).flat());
2685
+ }
2686
+ if (verb.queryParams) {
2687
+ imports.push({
2688
+ name: verb.queryParams.schema.name
2689
+ });
2690
+ }
2691
+ if (verb.body.definition) {
2692
+ imports.push(...verb.body.imports);
2693
+ }
2694
+ return imports;
2695
+ }).filter((imp) => contexts.includes(imp.name));
2696
+ if (contexts.includes("NonReadonly<")) {
2697
+ content += (0, import_core2.getOrvalGeneratedTypes)();
2698
+ content += "\n";
2699
+ }
2700
+ const relativeSchemasPath = output.schemas ? import_core2.upath.relativeSafe(dirname, (0, import_core2.getFileInfo)(output.schemas).dirname) : "./" + filename + ".schemas";
2701
+ content += `import { ${imps.map((imp) => imp.name).join(",\n")} } from '${relativeSchemasPath}';
2702
+
2703
+ `;
2704
+ content += contexts;
2705
+ return [
2706
+ {
2707
+ content,
2708
+ path: contextPath
2709
+ }
2710
+ ];
2711
+ };
2712
+ var generateZodFiles = async (verbOptions, output, context) => {
2713
+ const { pathWithoutExtension, extension, dirname, filename } = (0, import_core2.getFileInfo)(
2714
+ output.target
2715
+ );
2716
+ const header = getHeader(
2717
+ output.override.header,
2718
+ context.specs[context.specKey].info
2719
+ );
2720
+ if (output.mode === "tags" || output.mode === "tags-split") {
2721
+ const groupByTags = getVerbOptionGroupByTag(verbOptions);
2722
+ return Promise.all(
2723
+ Object.entries(groupByTags).map(async ([tag, verbs]) => {
2724
+ let content2 = `${header}import { z as zod } from 'zod';
2725
+
2726
+ `;
2727
+ const zodPath2 = output.mode === "tags" ? import_core2.upath.join(dirname, `${(0, import_core2.kebab)(tag)}.zod${extension}`) : import_core2.upath.join(dirname, tag, tag + ".zod" + extension);
2728
+ const zods2 = await Promise.all(
2729
+ verbs.map(
2730
+ (verbOption) => (0, import_zod.generateZod)(
2731
+ verbOption,
2732
+ {
2733
+ route: verbOption.route,
2734
+ pathRoute: verbOption.pathRoute,
2735
+ override: output.override,
2736
+ context,
2737
+ mock: output.mock,
2738
+ output: output.target
2739
+ },
2740
+ output.client
2741
+ )
2742
+ )
2743
+ );
2744
+ content2 += zods2.map((zod) => zod.implementation).join("\n");
2745
+ return {
2746
+ content: content2,
2747
+ path: zodPath2
2748
+ };
2749
+ })
2750
+ );
2751
+ }
2752
+ let content = `${header}import { z as zod } from 'zod';
2753
+
2754
+ `;
2755
+ const zodPath = import_core2.upath.join(dirname, `${filename}.zod${extension}`);
2756
+ const zods = await Promise.all(
2757
+ Object.values(verbOptions).map(
2758
+ (verbOption) => (0, import_zod.generateZod)(
2759
+ verbOption,
2760
+ {
2761
+ route: verbOption.route,
2762
+ pathRoute: verbOption.pathRoute,
2763
+ override: output.override,
2764
+ context,
2765
+ mock: output.mock,
2766
+ output: output.target
2767
+ },
2768
+ output.client
2769
+ )
2770
+ )
2771
+ );
2772
+ content += zods.map((zod) => zod.implementation).join("\n");
2773
+ return [
2774
+ {
2775
+ content,
2776
+ path: zodPath
2777
+ }
2778
+ ];
2779
+ };
2780
+ var generateExtraFiles = async (verbOptions, output, context) => {
2781
+ const [handlers, contexts, zods] = await Promise.all([
2782
+ generateHandlers(verbOptions, output),
2783
+ generateContext(verbOptions, output, context),
2784
+ generateZodFiles(verbOptions, output, context)
2785
+ ]);
2786
+ return [...handlers, ...contexts, ...zods];
2787
+ };
2788
+ var honoClientBuilder = {
2789
+ client: generateHono,
2790
+ dependencies: getHonoDependencies,
2791
+ header: getHonoHeader,
2792
+ footer: getHonoFooter,
2793
+ extraFiles: generateExtraFiles
2794
+ };
2795
+ var builder = () => () => honoClientBuilder;
2796
+ var src_default = builder;
2797
+ // Annotate the CommonJS export names for ESM import in node:
2798
+ 0 && (module.exports = {
2799
+ builder,
2800
+ generateExtraFiles,
2801
+ generateHono,
2802
+ getHonoDependencies,
2803
+ getHonoFooter,
2804
+ getHonoHeader
2805
+ });
2806
+ //# sourceMappingURL=index.js.map