@orval/hono 7.11.2 → 7.12.2

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