@hyper-fetch/cli 7.5.2 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/.eslintrc.cjs +18 -0
  2. package/__tests__/codegen/openapi/schemas/v2/petstore-expanded.json +210 -0
  3. package/__tests__/codegen/openapi/schemas/v3/broken-schema.json +3604 -0
  4. package/__tests__/codegen/openapi/schemas/v3/petstore-expanded.json +638 -0
  5. package/__tests__/codegen/openapi/v3/generator.spec.ts +367 -0
  6. package/__tests__/codegen/openapi/v3/operations.spec.ts +52 -0
  7. package/__tests__/codegen/openapi/v3/utils.spec.ts +28 -0
  8. package/__tests__/commands/generate/generate.spec.ts +106 -0
  9. package/__tests__/commands/init/.gitkeep +0 -0
  10. package/__tests__/tsconfig.json +22 -0
  11. package/__tests__/vitest.setup.ts +10 -0
  12. package/dist/cli/index.d.ts +3 -0
  13. package/dist/cli/index.d.ts.map +1 -0
  14. package/dist/cli.js +12969 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/codegen/index.d.ts +2 -0
  17. package/dist/codegen/index.d.ts.map +1 -0
  18. package/dist/codegen/openapi/generator.d.ts +61 -0
  19. package/dist/codegen/openapi/generator.d.ts.map +1 -0
  20. package/dist/codegen/openapi/http-methods.enum.d.ts +11 -0
  21. package/dist/codegen/openapi/http-methods.enum.d.ts.map +1 -0
  22. package/dist/codegen/openapi/index.d.ts +4 -0
  23. package/dist/codegen/openapi/index.d.ts.map +1 -0
  24. package/dist/codegen/openapi/openapi.types.d.ts +11 -0
  25. package/dist/codegen/openapi/openapi.types.d.ts.map +1 -0
  26. package/dist/codegen/openapi/operations.d.ts +6 -0
  27. package/dist/codegen/openapi/operations.d.ts.map +1 -0
  28. package/dist/codegen/openapi/utils.d.ts +7 -0
  29. package/dist/codegen/openapi/utils.d.ts.map +1 -0
  30. package/dist/commands/add.d.ts +10 -0
  31. package/dist/commands/add.d.ts.map +1 -0
  32. package/dist/commands/generate.d.ts +14 -0
  33. package/dist/commands/generate.d.ts.map +1 -0
  34. package/dist/commands/init.d.ts +3 -0
  35. package/dist/commands/init.d.ts.map +1 -0
  36. package/dist/config/auto-init.d.ts +6 -0
  37. package/dist/config/auto-init.d.ts.map +1 -0
  38. package/dist/config/get-config.d.ts +4 -0
  39. package/dist/config/get-config.d.ts.map +1 -0
  40. package/dist/config/get-ts-alias.d.ts +2 -0
  41. package/dist/config/get-ts-alias.d.ts.map +1 -0
  42. package/dist/config/schema.d.ts +21 -0
  43. package/dist/config/schema.d.ts.map +1 -0
  44. package/dist/generator-f5QJtrBW.js +194000 -0
  45. package/dist/generator-f5QJtrBW.js.map +1 -0
  46. package/dist/index.d.ts +2 -103
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +3 -3091
  49. package/dist/preflights/preflight-add.d.ts +27 -0
  50. package/dist/preflights/preflight-add.d.ts.map +1 -0
  51. package/dist/preflights/preflight-generate.d.ts +8 -0
  52. package/dist/preflights/preflight-generate.d.ts.map +1 -0
  53. package/dist/utils/errors.d.ts +14 -0
  54. package/dist/utils/errors.d.ts.map +1 -0
  55. package/dist/utils/handle-error.d.ts +2 -0
  56. package/dist/utils/handle-error.d.ts.map +1 -0
  57. package/dist/utils/highlighter.d.ts +7 -0
  58. package/dist/utils/highlighter.d.ts.map +1 -0
  59. package/dist/utils/logger.d.ts +8 -0
  60. package/dist/utils/logger.d.ts.map +1 -0
  61. package/dist/utils/resolve-import.d.ts +3 -0
  62. package/dist/utils/resolve-import.d.ts.map +1 -0
  63. package/dist/utils/show-help.d.ts +3 -0
  64. package/dist/utils/show-help.d.ts.map +1 -0
  65. package/dist/utils/spinner.d.ts +5 -0
  66. package/dist/utils/spinner.d.ts.map +1 -0
  67. package/dist/utils/zod-to-table.d.ts +6 -0
  68. package/dist/utils/zod-to-table.d.ts.map +1 -0
  69. package/package.json +5 -8
  70. package/project.json +4 -0
  71. package/src/codegen/openapi/generator.ts +4 -3
  72. package/src/codegen/openapi/openapi.types.ts +2 -2
  73. package/src/codegen/openapi/operations.ts +1 -1
  74. package/src/codegen/openapi/utils.ts +1 -1
  75. package/src/commands/add.ts +2 -2
  76. package/src/commands/init.ts +4 -3
  77. package/src/config/auto-init.ts +54 -0
  78. package/src/config/get-config.ts +5 -14
  79. package/src/preflights/preflight-add.ts +2 -2
  80. package/src/preflights/preflight-generate.ts +3 -3
  81. package/src/utils/show-help.ts +1 -1
  82. package/tsconfig.json +1 -1
  83. package/vite.config.ts +45 -0
  84. package/.eslintrc.json +0 -11
  85. package/dist/index.js.map +0 -7
package/dist/index.js CHANGED
@@ -1,3091 +1,3 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __defProps = Object.defineProperties;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
- var __getOwnPropNames = Object.getOwnPropertyNames;
9
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
13
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
- var __spreadValues = (a, b) => {
15
- for (var prop in b || (b = {}))
16
- if (__hasOwnProp.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- if (__getOwnPropSymbols)
19
- for (var prop of __getOwnPropSymbols(b)) {
20
- if (__propIsEnum.call(b, prop))
21
- __defNormalProp(a, prop, b[prop]);
22
- }
23
- return a;
24
- };
25
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
- var __commonJS = (cb, mod) => function __require() {
27
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
28
- };
29
- var __copyProps = (to, from, except, desc) => {
30
- if (from && typeof from === "object" || typeof from === "function") {
31
- for (let key of __getOwnPropNames(from))
32
- if (!__hasOwnProp.call(to, key) && key !== except)
33
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
- }
35
- return to;
36
- };
37
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
- // If the importer is in node compatibility mode or this is not an ESM
39
- // file that has been converted to a CommonJS file using a Babel-
40
- // compatible transform (i.e. "__esModule" has not been set), then set
41
- // "default" to the CommonJS "module.exports" for node compatibility.
42
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
- mod
44
- ));
45
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
46
- var __async = (__this, __arguments, generator) => {
47
- return new Promise((resolve3, reject) => {
48
- var fulfilled = (value) => {
49
- try {
50
- step(generator.next(value));
51
- } catch (e) {
52
- reject(e);
53
- }
54
- };
55
- var rejected = (value) => {
56
- try {
57
- step(generator.throw(value));
58
- } catch (e) {
59
- reject(e);
60
- }
61
- };
62
- var step = (x) => x.done ? resolve3(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
63
- step((generator = generator.apply(__this, __arguments)).next());
64
- });
65
- };
66
-
67
- // ../../node_modules/tsconfig-paths/lib/filesystem.js
68
- var require_filesystem = __commonJS({
69
- "../../node_modules/tsconfig-paths/lib/filesystem.js"(exports2) {
70
- "use strict";
71
- Object.defineProperty(exports2, "__esModule", { value: true });
72
- exports2.removeExtension = exports2.fileExistsAsync = exports2.readJsonFromDiskAsync = exports2.readJsonFromDiskSync = exports2.fileExistsSync = void 0;
73
- var fs6 = require("fs");
74
- function fileExistsSync(path6) {
75
- if (!fs6.existsSync(path6)) {
76
- return false;
77
- }
78
- try {
79
- var stats = fs6.statSync(path6);
80
- return stats.isFile();
81
- } catch (err) {
82
- return false;
83
- }
84
- }
85
- exports2.fileExistsSync = fileExistsSync;
86
- function readJsonFromDiskSync(packageJsonPath) {
87
- if (!fs6.existsSync(packageJsonPath)) {
88
- return void 0;
89
- }
90
- return require(packageJsonPath);
91
- }
92
- exports2.readJsonFromDiskSync = readJsonFromDiskSync;
93
- function readJsonFromDiskAsync(path6, callback) {
94
- fs6.readFile(path6, "utf8", function(err, result) {
95
- if (err || !result) {
96
- return callback();
97
- }
98
- var json = JSON.parse(result);
99
- return callback(void 0, json);
100
- });
101
- }
102
- exports2.readJsonFromDiskAsync = readJsonFromDiskAsync;
103
- function fileExistsAsync(path22, callback2) {
104
- fs6.stat(path22, function(err, stats) {
105
- if (err) {
106
- return callback2(void 0, false);
107
- }
108
- callback2(void 0, stats ? stats.isFile() : false);
109
- });
110
- }
111
- exports2.fileExistsAsync = fileExistsAsync;
112
- function removeExtension(path6) {
113
- return path6.substring(0, path6.lastIndexOf(".")) || path6;
114
- }
115
- exports2.removeExtension = removeExtension;
116
- }
117
- });
118
-
119
- // ../../node_modules/tsconfig-paths/lib/mapping-entry.js
120
- var require_mapping_entry = __commonJS({
121
- "../../node_modules/tsconfig-paths/lib/mapping-entry.js"(exports2) {
122
- "use strict";
123
- Object.defineProperty(exports2, "__esModule", { value: true });
124
- exports2.getAbsoluteMappingEntries = void 0;
125
- var path6 = require("path");
126
- function getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll) {
127
- var sortedKeys = sortByLongestPrefix(Object.keys(paths));
128
- var absolutePaths = [];
129
- for (var _i = 0, sortedKeys_1 = sortedKeys; _i < sortedKeys_1.length; _i++) {
130
- var key = sortedKeys_1[_i];
131
- absolutePaths.push({
132
- pattern: key,
133
- paths: paths[key].map(function(pathToResolve) {
134
- return path6.resolve(absoluteBaseUrl, pathToResolve);
135
- })
136
- });
137
- }
138
- if (!paths["*"] && addMatchAll) {
139
- absolutePaths.push({
140
- pattern: "*",
141
- paths: ["".concat(absoluteBaseUrl.replace(/\/$/, ""), "/*")]
142
- });
143
- }
144
- return absolutePaths;
145
- }
146
- exports2.getAbsoluteMappingEntries = getAbsoluteMappingEntries;
147
- function sortByLongestPrefix(arr) {
148
- return arr.concat().sort(function(a, b) {
149
- return getPrefixLength(b) - getPrefixLength(a);
150
- });
151
- }
152
- function getPrefixLength(pattern) {
153
- var prefixLength = pattern.indexOf("*");
154
- return pattern.substr(0, prefixLength).length;
155
- }
156
- }
157
- });
158
-
159
- // ../../node_modules/tsconfig-paths/lib/try-path.js
160
- var require_try_path = __commonJS({
161
- "../../node_modules/tsconfig-paths/lib/try-path.js"(exports2) {
162
- "use strict";
163
- Object.defineProperty(exports2, "__esModule", { value: true });
164
- exports2.exhaustiveTypeException = exports2.getStrippedPath = exports2.getPathsToTry = void 0;
165
- var path6 = require("path");
166
- var path_1 = require("path");
167
- var filesystem_1 = require_filesystem();
168
- function getPathsToTry(extensions, absolutePathMappings, requestedModule) {
169
- if (!absolutePathMappings || !requestedModule || requestedModule[0] === ".") {
170
- return void 0;
171
- }
172
- var pathsToTry = [];
173
- for (var _i = 0, absolutePathMappings_1 = absolutePathMappings; _i < absolutePathMappings_1.length; _i++) {
174
- var entry = absolutePathMappings_1[_i];
175
- var starMatch = entry.pattern === requestedModule ? "" : matchStar(entry.pattern, requestedModule);
176
- if (starMatch !== void 0) {
177
- var _loop_1 = function(physicalPathPattern2) {
178
- var physicalPath = physicalPathPattern2.replace("*", starMatch);
179
- pathsToTry.push({ type: "file", path: physicalPath });
180
- pathsToTry.push.apply(pathsToTry, extensions.map(function(e) {
181
- return { type: "extension", path: physicalPath + e };
182
- }));
183
- pathsToTry.push({
184
- type: "package",
185
- path: path6.join(physicalPath, "/package.json")
186
- });
187
- var indexPath = path6.join(physicalPath, "/index");
188
- pathsToTry.push.apply(pathsToTry, extensions.map(function(e) {
189
- return { type: "index", path: indexPath + e };
190
- }));
191
- };
192
- for (var _a = 0, _b = entry.paths; _a < _b.length; _a++) {
193
- var physicalPathPattern = _b[_a];
194
- _loop_1(physicalPathPattern);
195
- }
196
- }
197
- }
198
- return pathsToTry.length === 0 ? void 0 : pathsToTry;
199
- }
200
- exports2.getPathsToTry = getPathsToTry;
201
- function getStrippedPath(tryPath) {
202
- return tryPath.type === "index" ? (0, path_1.dirname)(tryPath.path) : tryPath.type === "file" ? tryPath.path : tryPath.type === "extension" ? (0, filesystem_1.removeExtension)(tryPath.path) : tryPath.type === "package" ? tryPath.path : exhaustiveTypeException(tryPath.type);
203
- }
204
- exports2.getStrippedPath = getStrippedPath;
205
- function exhaustiveTypeException(check) {
206
- throw new Error("Unknown type ".concat(check));
207
- }
208
- exports2.exhaustiveTypeException = exhaustiveTypeException;
209
- function matchStar(pattern, search) {
210
- if (search.length < pattern.length) {
211
- return void 0;
212
- }
213
- if (pattern === "*") {
214
- return search;
215
- }
216
- var star = pattern.indexOf("*");
217
- if (star === -1) {
218
- return void 0;
219
- }
220
- var part1 = pattern.substring(0, star);
221
- var part2 = pattern.substring(star + 1);
222
- if (search.substr(0, star) !== part1) {
223
- return void 0;
224
- }
225
- if (search.substr(search.length - part2.length) !== part2) {
226
- return void 0;
227
- }
228
- return search.substr(star, search.length - part2.length);
229
- }
230
- }
231
- });
232
-
233
- // ../../node_modules/tsconfig-paths/lib/match-path-sync.js
234
- var require_match_path_sync = __commonJS({
235
- "../../node_modules/tsconfig-paths/lib/match-path-sync.js"(exports2) {
236
- "use strict";
237
- Object.defineProperty(exports2, "__esModule", { value: true });
238
- exports2.matchFromAbsolutePaths = exports2.createMatchPath = void 0;
239
- var path6 = require("path");
240
- var Filesystem = require_filesystem();
241
- var MappingEntry = require_mapping_entry();
242
- var TryPath = require_try_path();
243
- function createMatchPath2(absoluteBaseUrl, paths, mainFields, addMatchAll) {
244
- if (mainFields === void 0) {
245
- mainFields = ["main"];
246
- }
247
- if (addMatchAll === void 0) {
248
- addMatchAll = true;
249
- }
250
- var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
251
- return function(requestedModule, readJson, fileExists, extensions) {
252
- return matchFromAbsolutePaths(absolutePaths, requestedModule, readJson, fileExists, extensions, mainFields);
253
- };
254
- }
255
- exports2.createMatchPath = createMatchPath2;
256
- function matchFromAbsolutePaths(absolutePathMappings, requestedModule, readJson, fileExists, extensions, mainFields) {
257
- if (readJson === void 0) {
258
- readJson = Filesystem.readJsonFromDiskSync;
259
- }
260
- if (fileExists === void 0) {
261
- fileExists = Filesystem.fileExistsSync;
262
- }
263
- if (extensions === void 0) {
264
- extensions = Object.keys(require.extensions);
265
- }
266
- if (mainFields === void 0) {
267
- mainFields = ["main"];
268
- }
269
- var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
270
- if (!tryPaths) {
271
- return void 0;
272
- }
273
- return findFirstExistingPath(tryPaths, readJson, fileExists, mainFields);
274
- }
275
- exports2.matchFromAbsolutePaths = matchFromAbsolutePaths;
276
- function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExists) {
277
- for (var index = 0; index < mainFields.length; index++) {
278
- var mainFieldSelector = mainFields[index];
279
- var candidateMapping = typeof mainFieldSelector === "string" ? packageJson[mainFieldSelector] : mainFieldSelector.reduce(function(obj, key) {
280
- return obj[key];
281
- }, packageJson);
282
- if (candidateMapping && typeof candidateMapping === "string") {
283
- var candidateFilePath = path6.join(path6.dirname(packageJsonPath), candidateMapping);
284
- if (fileExists(candidateFilePath)) {
285
- return candidateFilePath;
286
- }
287
- }
288
- }
289
- return void 0;
290
- }
291
- function findFirstExistingPath(tryPaths, readJson, fileExists, mainFields) {
292
- if (readJson === void 0) {
293
- readJson = Filesystem.readJsonFromDiskSync;
294
- }
295
- if (mainFields === void 0) {
296
- mainFields = ["main"];
297
- }
298
- for (var _i = 0, tryPaths_1 = tryPaths; _i < tryPaths_1.length; _i++) {
299
- var tryPath = tryPaths_1[_i];
300
- if (tryPath.type === "file" || tryPath.type === "extension" || tryPath.type === "index") {
301
- if (fileExists(tryPath.path)) {
302
- return TryPath.getStrippedPath(tryPath);
303
- }
304
- } else if (tryPath.type === "package") {
305
- var packageJson = readJson(tryPath.path);
306
- if (packageJson) {
307
- var mainFieldMappedFile = findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists);
308
- if (mainFieldMappedFile) {
309
- return mainFieldMappedFile;
310
- }
311
- }
312
- } else {
313
- TryPath.exhaustiveTypeException(tryPath.type);
314
- }
315
- }
316
- return void 0;
317
- }
318
- }
319
- });
320
-
321
- // ../../node_modules/tsconfig-paths/lib/match-path-async.js
322
- var require_match_path_async = __commonJS({
323
- "../../node_modules/tsconfig-paths/lib/match-path-async.js"(exports2) {
324
- "use strict";
325
- Object.defineProperty(exports2, "__esModule", { value: true });
326
- exports2.matchFromAbsolutePathsAsync = exports2.createMatchPathAsync = void 0;
327
- var path6 = require("path");
328
- var TryPath = require_try_path();
329
- var MappingEntry = require_mapping_entry();
330
- var Filesystem = require_filesystem();
331
- function createMatchPathAsync(absoluteBaseUrl, paths, mainFields, addMatchAll) {
332
- if (mainFields === void 0) {
333
- mainFields = ["main"];
334
- }
335
- if (addMatchAll === void 0) {
336
- addMatchAll = true;
337
- }
338
- var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
339
- return function(requestedModule, readJson, fileExists, extensions, callback) {
340
- return matchFromAbsolutePathsAsync(absolutePaths, requestedModule, readJson, fileExists, extensions, callback, mainFields);
341
- };
342
- }
343
- exports2.createMatchPathAsync = createMatchPathAsync;
344
- function matchFromAbsolutePathsAsync(absolutePathMappings, requestedModule, readJson, fileExists, extensions, callback, mainFields) {
345
- if (readJson === void 0) {
346
- readJson = Filesystem.readJsonFromDiskAsync;
347
- }
348
- if (fileExists === void 0) {
349
- fileExists = Filesystem.fileExistsAsync;
350
- }
351
- if (extensions === void 0) {
352
- extensions = Object.keys(require.extensions);
353
- }
354
- if (mainFields === void 0) {
355
- mainFields = ["main"];
356
- }
357
- var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
358
- if (!tryPaths) {
359
- return callback();
360
- }
361
- findFirstExistingPath(tryPaths, readJson, fileExists, callback, 0, mainFields);
362
- }
363
- exports2.matchFromAbsolutePathsAsync = matchFromAbsolutePathsAsync;
364
- function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index) {
365
- if (index === void 0) {
366
- index = 0;
367
- }
368
- if (index >= mainFields.length) {
369
- return doneCallback(void 0, void 0);
370
- }
371
- var tryNext = function() {
372
- return findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index + 1);
373
- };
374
- var mainFieldSelector = mainFields[index];
375
- var mainFieldMapping = typeof mainFieldSelector === "string" ? packageJson[mainFieldSelector] : mainFieldSelector.reduce(function(obj, key) {
376
- return obj[key];
377
- }, packageJson);
378
- if (typeof mainFieldMapping !== "string") {
379
- return tryNext();
380
- }
381
- var mappedFilePath = path6.join(path6.dirname(packageJsonPath), mainFieldMapping);
382
- fileExistsAsync(mappedFilePath, function(err, exists) {
383
- if (err) {
384
- return doneCallback(err);
385
- }
386
- if (exists) {
387
- return doneCallback(void 0, mappedFilePath);
388
- }
389
- return tryNext();
390
- });
391
- }
392
- function findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index, mainFields) {
393
- if (index === void 0) {
394
- index = 0;
395
- }
396
- if (mainFields === void 0) {
397
- mainFields = ["main"];
398
- }
399
- var tryPath = tryPaths[index];
400
- if (tryPath.type === "file" || tryPath.type === "extension" || tryPath.type === "index") {
401
- fileExists(tryPath.path, function(err, exists) {
402
- if (err) {
403
- return doneCallback(err);
404
- }
405
- if (exists) {
406
- return doneCallback(void 0, TryPath.getStrippedPath(tryPath));
407
- }
408
- if (index === tryPaths.length - 1) {
409
- return doneCallback();
410
- }
411
- return findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index + 1, mainFields);
412
- });
413
- } else if (tryPath.type === "package") {
414
- readJson(tryPath.path, function(err, packageJson) {
415
- if (err) {
416
- return doneCallback(err);
417
- }
418
- if (packageJson) {
419
- return findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists, function(mainFieldErr, mainFieldMappedFile) {
420
- if (mainFieldErr) {
421
- return doneCallback(mainFieldErr);
422
- }
423
- if (mainFieldMappedFile) {
424
- return doneCallback(void 0, mainFieldMappedFile);
425
- }
426
- return findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index + 1, mainFields);
427
- });
428
- }
429
- return findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index + 1, mainFields);
430
- });
431
- } else {
432
- TryPath.exhaustiveTypeException(tryPath.type);
433
- }
434
- }
435
- }
436
- });
437
-
438
- // ../../node_modules/json5/lib/unicode.js
439
- var require_unicode = __commonJS({
440
- "../../node_modules/json5/lib/unicode.js"(exports2, module2) {
441
- "use strict";
442
- module2.exports.Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
443
- module2.exports.ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
444
- module2.exports.ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
445
- }
446
- });
447
-
448
- // ../../node_modules/json5/lib/util.js
449
- var require_util = __commonJS({
450
- "../../node_modules/json5/lib/util.js"(exports2, module2) {
451
- "use strict";
452
- var unicode = require_unicode();
453
- module2.exports = {
454
- isSpaceSeparator(c) {
455
- return typeof c === "string" && unicode.Space_Separator.test(c);
456
- },
457
- isIdStartChar(c) {
458
- return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "$" || c === "_" || unicode.ID_Start.test(c));
459
- },
460
- isIdContinueChar(c) {
461
- return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c === "$" || c === "_" || c === "\u200C" || c === "\u200D" || unicode.ID_Continue.test(c));
462
- },
463
- isDigit(c) {
464
- return typeof c === "string" && /[0-9]/.test(c);
465
- },
466
- isHexDigit(c) {
467
- return typeof c === "string" && /[0-9A-Fa-f]/.test(c);
468
- }
469
- };
470
- }
471
- });
472
-
473
- // ../../node_modules/json5/lib/parse.js
474
- var require_parse = __commonJS({
475
- "../../node_modules/json5/lib/parse.js"(exports2, module2) {
476
- "use strict";
477
- var util = require_util();
478
- var source;
479
- var parseState;
480
- var stack;
481
- var pos;
482
- var line;
483
- var column;
484
- var token;
485
- var key;
486
- var root;
487
- module2.exports = function parse(text, reviver) {
488
- source = String(text);
489
- parseState = "start";
490
- stack = [];
491
- pos = 0;
492
- line = 1;
493
- column = 0;
494
- token = void 0;
495
- key = void 0;
496
- root = void 0;
497
- do {
498
- token = lex();
499
- parseStates[parseState]();
500
- } while (token.type !== "eof");
501
- if (typeof reviver === "function") {
502
- return internalize({ "": root }, "", reviver);
503
- }
504
- return root;
505
- };
506
- function internalize(holder, name, reviver) {
507
- const value = holder[name];
508
- if (value != null && typeof value === "object") {
509
- if (Array.isArray(value)) {
510
- for (let i = 0; i < value.length; i++) {
511
- const key2 = String(i);
512
- const replacement = internalize(value, key2, reviver);
513
- if (replacement === void 0) {
514
- delete value[key2];
515
- } else {
516
- Object.defineProperty(value, key2, {
517
- value: replacement,
518
- writable: true,
519
- enumerable: true,
520
- configurable: true
521
- });
522
- }
523
- }
524
- } else {
525
- for (const key2 in value) {
526
- const replacement = internalize(value, key2, reviver);
527
- if (replacement === void 0) {
528
- delete value[key2];
529
- } else {
530
- Object.defineProperty(value, key2, {
531
- value: replacement,
532
- writable: true,
533
- enumerable: true,
534
- configurable: true
535
- });
536
- }
537
- }
538
- }
539
- }
540
- return reviver.call(holder, name, value);
541
- }
542
- var lexState;
543
- var buffer;
544
- var doubleQuote;
545
- var sign;
546
- var c;
547
- function lex() {
548
- lexState = "default";
549
- buffer = "";
550
- doubleQuote = false;
551
- sign = 1;
552
- for (; ; ) {
553
- c = peek();
554
- const token2 = lexStates[lexState]();
555
- if (token2) {
556
- return token2;
557
- }
558
- }
559
- }
560
- function peek() {
561
- if (source[pos]) {
562
- return String.fromCodePoint(source.codePointAt(pos));
563
- }
564
- }
565
- function read() {
566
- const c2 = peek();
567
- if (c2 === "\n") {
568
- line++;
569
- column = 0;
570
- } else if (c2) {
571
- column += c2.length;
572
- } else {
573
- column++;
574
- }
575
- if (c2) {
576
- pos += c2.length;
577
- }
578
- return c2;
579
- }
580
- var lexStates = {
581
- default() {
582
- switch (c) {
583
- case " ":
584
- case "\v":
585
- case "\f":
586
- case " ":
587
- case "\xA0":
588
- case "\uFEFF":
589
- case "\n":
590
- case "\r":
591
- case "\u2028":
592
- case "\u2029":
593
- read();
594
- return;
595
- case "/":
596
- read();
597
- lexState = "comment";
598
- return;
599
- case void 0:
600
- read();
601
- return newToken("eof");
602
- }
603
- if (util.isSpaceSeparator(c)) {
604
- read();
605
- return;
606
- }
607
- return lexStates[parseState]();
608
- },
609
- comment() {
610
- switch (c) {
611
- case "*":
612
- read();
613
- lexState = "multiLineComment";
614
- return;
615
- case "/":
616
- read();
617
- lexState = "singleLineComment";
618
- return;
619
- }
620
- throw invalidChar(read());
621
- },
622
- multiLineComment() {
623
- switch (c) {
624
- case "*":
625
- read();
626
- lexState = "multiLineCommentAsterisk";
627
- return;
628
- case void 0:
629
- throw invalidChar(read());
630
- }
631
- read();
632
- },
633
- multiLineCommentAsterisk() {
634
- switch (c) {
635
- case "*":
636
- read();
637
- return;
638
- case "/":
639
- read();
640
- lexState = "default";
641
- return;
642
- case void 0:
643
- throw invalidChar(read());
644
- }
645
- read();
646
- lexState = "multiLineComment";
647
- },
648
- singleLineComment() {
649
- switch (c) {
650
- case "\n":
651
- case "\r":
652
- case "\u2028":
653
- case "\u2029":
654
- read();
655
- lexState = "default";
656
- return;
657
- case void 0:
658
- read();
659
- return newToken("eof");
660
- }
661
- read();
662
- },
663
- value() {
664
- switch (c) {
665
- case "{":
666
- case "[":
667
- return newToken("punctuator", read());
668
- case "n":
669
- read();
670
- literal("ull");
671
- return newToken("null", null);
672
- case "t":
673
- read();
674
- literal("rue");
675
- return newToken("boolean", true);
676
- case "f":
677
- read();
678
- literal("alse");
679
- return newToken("boolean", false);
680
- case "-":
681
- case "+":
682
- if (read() === "-") {
683
- sign = -1;
684
- }
685
- lexState = "sign";
686
- return;
687
- case ".":
688
- buffer = read();
689
- lexState = "decimalPointLeading";
690
- return;
691
- case "0":
692
- buffer = read();
693
- lexState = "zero";
694
- return;
695
- case "1":
696
- case "2":
697
- case "3":
698
- case "4":
699
- case "5":
700
- case "6":
701
- case "7":
702
- case "8":
703
- case "9":
704
- buffer = read();
705
- lexState = "decimalInteger";
706
- return;
707
- case "I":
708
- read();
709
- literal("nfinity");
710
- return newToken("numeric", Infinity);
711
- case "N":
712
- read();
713
- literal("aN");
714
- return newToken("numeric", NaN);
715
- case '"':
716
- case "'":
717
- doubleQuote = read() === '"';
718
- buffer = "";
719
- lexState = "string";
720
- return;
721
- }
722
- throw invalidChar(read());
723
- },
724
- identifierNameStartEscape() {
725
- if (c !== "u") {
726
- throw invalidChar(read());
727
- }
728
- read();
729
- const u = unicodeEscape();
730
- switch (u) {
731
- case "$":
732
- case "_":
733
- break;
734
- default:
735
- if (!util.isIdStartChar(u)) {
736
- throw invalidIdentifier();
737
- }
738
- break;
739
- }
740
- buffer += u;
741
- lexState = "identifierName";
742
- },
743
- identifierName() {
744
- switch (c) {
745
- case "$":
746
- case "_":
747
- case "\u200C":
748
- case "\u200D":
749
- buffer += read();
750
- return;
751
- case "\\":
752
- read();
753
- lexState = "identifierNameEscape";
754
- return;
755
- }
756
- if (util.isIdContinueChar(c)) {
757
- buffer += read();
758
- return;
759
- }
760
- return newToken("identifier", buffer);
761
- },
762
- identifierNameEscape() {
763
- if (c !== "u") {
764
- throw invalidChar(read());
765
- }
766
- read();
767
- const u = unicodeEscape();
768
- switch (u) {
769
- case "$":
770
- case "_":
771
- case "\u200C":
772
- case "\u200D":
773
- break;
774
- default:
775
- if (!util.isIdContinueChar(u)) {
776
- throw invalidIdentifier();
777
- }
778
- break;
779
- }
780
- buffer += u;
781
- lexState = "identifierName";
782
- },
783
- sign() {
784
- switch (c) {
785
- case ".":
786
- buffer = read();
787
- lexState = "decimalPointLeading";
788
- return;
789
- case "0":
790
- buffer = read();
791
- lexState = "zero";
792
- return;
793
- case "1":
794
- case "2":
795
- case "3":
796
- case "4":
797
- case "5":
798
- case "6":
799
- case "7":
800
- case "8":
801
- case "9":
802
- buffer = read();
803
- lexState = "decimalInteger";
804
- return;
805
- case "I":
806
- read();
807
- literal("nfinity");
808
- return newToken("numeric", sign * Infinity);
809
- case "N":
810
- read();
811
- literal("aN");
812
- return newToken("numeric", NaN);
813
- }
814
- throw invalidChar(read());
815
- },
816
- zero() {
817
- switch (c) {
818
- case ".":
819
- buffer += read();
820
- lexState = "decimalPoint";
821
- return;
822
- case "e":
823
- case "E":
824
- buffer += read();
825
- lexState = "decimalExponent";
826
- return;
827
- case "x":
828
- case "X":
829
- buffer += read();
830
- lexState = "hexadecimal";
831
- return;
832
- }
833
- return newToken("numeric", sign * 0);
834
- },
835
- decimalInteger() {
836
- switch (c) {
837
- case ".":
838
- buffer += read();
839
- lexState = "decimalPoint";
840
- return;
841
- case "e":
842
- case "E":
843
- buffer += read();
844
- lexState = "decimalExponent";
845
- return;
846
- }
847
- if (util.isDigit(c)) {
848
- buffer += read();
849
- return;
850
- }
851
- return newToken("numeric", sign * Number(buffer));
852
- },
853
- decimalPointLeading() {
854
- if (util.isDigit(c)) {
855
- buffer += read();
856
- lexState = "decimalFraction";
857
- return;
858
- }
859
- throw invalidChar(read());
860
- },
861
- decimalPoint() {
862
- switch (c) {
863
- case "e":
864
- case "E":
865
- buffer += read();
866
- lexState = "decimalExponent";
867
- return;
868
- }
869
- if (util.isDigit(c)) {
870
- buffer += read();
871
- lexState = "decimalFraction";
872
- return;
873
- }
874
- return newToken("numeric", sign * Number(buffer));
875
- },
876
- decimalFraction() {
877
- switch (c) {
878
- case "e":
879
- case "E":
880
- buffer += read();
881
- lexState = "decimalExponent";
882
- return;
883
- }
884
- if (util.isDigit(c)) {
885
- buffer += read();
886
- return;
887
- }
888
- return newToken("numeric", sign * Number(buffer));
889
- },
890
- decimalExponent() {
891
- switch (c) {
892
- case "+":
893
- case "-":
894
- buffer += read();
895
- lexState = "decimalExponentSign";
896
- return;
897
- }
898
- if (util.isDigit(c)) {
899
- buffer += read();
900
- lexState = "decimalExponentInteger";
901
- return;
902
- }
903
- throw invalidChar(read());
904
- },
905
- decimalExponentSign() {
906
- if (util.isDigit(c)) {
907
- buffer += read();
908
- lexState = "decimalExponentInteger";
909
- return;
910
- }
911
- throw invalidChar(read());
912
- },
913
- decimalExponentInteger() {
914
- if (util.isDigit(c)) {
915
- buffer += read();
916
- return;
917
- }
918
- return newToken("numeric", sign * Number(buffer));
919
- },
920
- hexadecimal() {
921
- if (util.isHexDigit(c)) {
922
- buffer += read();
923
- lexState = "hexadecimalInteger";
924
- return;
925
- }
926
- throw invalidChar(read());
927
- },
928
- hexadecimalInteger() {
929
- if (util.isHexDigit(c)) {
930
- buffer += read();
931
- return;
932
- }
933
- return newToken("numeric", sign * Number(buffer));
934
- },
935
- string() {
936
- switch (c) {
937
- case "\\":
938
- read();
939
- buffer += escape();
940
- return;
941
- case '"':
942
- if (doubleQuote) {
943
- read();
944
- return newToken("string", buffer);
945
- }
946
- buffer += read();
947
- return;
948
- case "'":
949
- if (!doubleQuote) {
950
- read();
951
- return newToken("string", buffer);
952
- }
953
- buffer += read();
954
- return;
955
- case "\n":
956
- case "\r":
957
- throw invalidChar(read());
958
- case "\u2028":
959
- case "\u2029":
960
- separatorChar(c);
961
- break;
962
- case void 0:
963
- throw invalidChar(read());
964
- }
965
- buffer += read();
966
- },
967
- start() {
968
- switch (c) {
969
- case "{":
970
- case "[":
971
- return newToken("punctuator", read());
972
- }
973
- lexState = "value";
974
- },
975
- beforePropertyName() {
976
- switch (c) {
977
- case "$":
978
- case "_":
979
- buffer = read();
980
- lexState = "identifierName";
981
- return;
982
- case "\\":
983
- read();
984
- lexState = "identifierNameStartEscape";
985
- return;
986
- case "}":
987
- return newToken("punctuator", read());
988
- case '"':
989
- case "'":
990
- doubleQuote = read() === '"';
991
- lexState = "string";
992
- return;
993
- }
994
- if (util.isIdStartChar(c)) {
995
- buffer += read();
996
- lexState = "identifierName";
997
- return;
998
- }
999
- throw invalidChar(read());
1000
- },
1001
- afterPropertyName() {
1002
- if (c === ":") {
1003
- return newToken("punctuator", read());
1004
- }
1005
- throw invalidChar(read());
1006
- },
1007
- beforePropertyValue() {
1008
- lexState = "value";
1009
- },
1010
- afterPropertyValue() {
1011
- switch (c) {
1012
- case ",":
1013
- case "}":
1014
- return newToken("punctuator", read());
1015
- }
1016
- throw invalidChar(read());
1017
- },
1018
- beforeArrayValue() {
1019
- if (c === "]") {
1020
- return newToken("punctuator", read());
1021
- }
1022
- lexState = "value";
1023
- },
1024
- afterArrayValue() {
1025
- switch (c) {
1026
- case ",":
1027
- case "]":
1028
- return newToken("punctuator", read());
1029
- }
1030
- throw invalidChar(read());
1031
- },
1032
- end() {
1033
- throw invalidChar(read());
1034
- }
1035
- };
1036
- function newToken(type, value) {
1037
- return {
1038
- type,
1039
- value,
1040
- line,
1041
- column
1042
- };
1043
- }
1044
- function literal(s) {
1045
- for (const c2 of s) {
1046
- const p = peek();
1047
- if (p !== c2) {
1048
- throw invalidChar(read());
1049
- }
1050
- read();
1051
- }
1052
- }
1053
- function escape() {
1054
- const c2 = peek();
1055
- switch (c2) {
1056
- case "b":
1057
- read();
1058
- return "\b";
1059
- case "f":
1060
- read();
1061
- return "\f";
1062
- case "n":
1063
- read();
1064
- return "\n";
1065
- case "r":
1066
- read();
1067
- return "\r";
1068
- case "t":
1069
- read();
1070
- return " ";
1071
- case "v":
1072
- read();
1073
- return "\v";
1074
- case "0":
1075
- read();
1076
- if (util.isDigit(peek())) {
1077
- throw invalidChar(read());
1078
- }
1079
- return "\0";
1080
- case "x":
1081
- read();
1082
- return hexEscape();
1083
- case "u":
1084
- read();
1085
- return unicodeEscape();
1086
- case "\n":
1087
- case "\u2028":
1088
- case "\u2029":
1089
- read();
1090
- return "";
1091
- case "\r":
1092
- read();
1093
- if (peek() === "\n") {
1094
- read();
1095
- }
1096
- return "";
1097
- case "1":
1098
- case "2":
1099
- case "3":
1100
- case "4":
1101
- case "5":
1102
- case "6":
1103
- case "7":
1104
- case "8":
1105
- case "9":
1106
- throw invalidChar(read());
1107
- case void 0:
1108
- throw invalidChar(read());
1109
- }
1110
- return read();
1111
- }
1112
- function hexEscape() {
1113
- let buffer2 = "";
1114
- let c2 = peek();
1115
- if (!util.isHexDigit(c2)) {
1116
- throw invalidChar(read());
1117
- }
1118
- buffer2 += read();
1119
- c2 = peek();
1120
- if (!util.isHexDigit(c2)) {
1121
- throw invalidChar(read());
1122
- }
1123
- buffer2 += read();
1124
- return String.fromCodePoint(parseInt(buffer2, 16));
1125
- }
1126
- function unicodeEscape() {
1127
- let buffer2 = "";
1128
- let count = 4;
1129
- while (count-- > 0) {
1130
- const c2 = peek();
1131
- if (!util.isHexDigit(c2)) {
1132
- throw invalidChar(read());
1133
- }
1134
- buffer2 += read();
1135
- }
1136
- return String.fromCodePoint(parseInt(buffer2, 16));
1137
- }
1138
- var parseStates = {
1139
- start() {
1140
- if (token.type === "eof") {
1141
- throw invalidEOF();
1142
- }
1143
- push();
1144
- },
1145
- beforePropertyName() {
1146
- switch (token.type) {
1147
- case "identifier":
1148
- case "string":
1149
- key = token.value;
1150
- parseState = "afterPropertyName";
1151
- return;
1152
- case "punctuator":
1153
- pop();
1154
- return;
1155
- case "eof":
1156
- throw invalidEOF();
1157
- }
1158
- },
1159
- afterPropertyName() {
1160
- if (token.type === "eof") {
1161
- throw invalidEOF();
1162
- }
1163
- parseState = "beforePropertyValue";
1164
- },
1165
- beforePropertyValue() {
1166
- if (token.type === "eof") {
1167
- throw invalidEOF();
1168
- }
1169
- push();
1170
- },
1171
- beforeArrayValue() {
1172
- if (token.type === "eof") {
1173
- throw invalidEOF();
1174
- }
1175
- if (token.type === "punctuator" && token.value === "]") {
1176
- pop();
1177
- return;
1178
- }
1179
- push();
1180
- },
1181
- afterPropertyValue() {
1182
- if (token.type === "eof") {
1183
- throw invalidEOF();
1184
- }
1185
- switch (token.value) {
1186
- case ",":
1187
- parseState = "beforePropertyName";
1188
- return;
1189
- case "}":
1190
- pop();
1191
- }
1192
- },
1193
- afterArrayValue() {
1194
- if (token.type === "eof") {
1195
- throw invalidEOF();
1196
- }
1197
- switch (token.value) {
1198
- case ",":
1199
- parseState = "beforeArrayValue";
1200
- return;
1201
- case "]":
1202
- pop();
1203
- }
1204
- },
1205
- end() {
1206
- }
1207
- };
1208
- function push() {
1209
- let value;
1210
- switch (token.type) {
1211
- case "punctuator":
1212
- switch (token.value) {
1213
- case "{":
1214
- value = {};
1215
- break;
1216
- case "[":
1217
- value = [];
1218
- break;
1219
- }
1220
- break;
1221
- case "null":
1222
- case "boolean":
1223
- case "numeric":
1224
- case "string":
1225
- value = token.value;
1226
- break;
1227
- }
1228
- if (root === void 0) {
1229
- root = value;
1230
- } else {
1231
- const parent = stack[stack.length - 1];
1232
- if (Array.isArray(parent)) {
1233
- parent.push(value);
1234
- } else {
1235
- Object.defineProperty(parent, key, {
1236
- value,
1237
- writable: true,
1238
- enumerable: true,
1239
- configurable: true
1240
- });
1241
- }
1242
- }
1243
- if (value !== null && typeof value === "object") {
1244
- stack.push(value);
1245
- if (Array.isArray(value)) {
1246
- parseState = "beforeArrayValue";
1247
- } else {
1248
- parseState = "beforePropertyName";
1249
- }
1250
- } else {
1251
- const current = stack[stack.length - 1];
1252
- if (current == null) {
1253
- parseState = "end";
1254
- } else if (Array.isArray(current)) {
1255
- parseState = "afterArrayValue";
1256
- } else {
1257
- parseState = "afterPropertyValue";
1258
- }
1259
- }
1260
- }
1261
- function pop() {
1262
- stack.pop();
1263
- const current = stack[stack.length - 1];
1264
- if (current == null) {
1265
- parseState = "end";
1266
- } else if (Array.isArray(current)) {
1267
- parseState = "afterArrayValue";
1268
- } else {
1269
- parseState = "afterPropertyValue";
1270
- }
1271
- }
1272
- function invalidChar(c2) {
1273
- if (c2 === void 0) {
1274
- return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
1275
- }
1276
- return syntaxError(`JSON5: invalid character '${formatChar(c2)}' at ${line}:${column}`);
1277
- }
1278
- function invalidEOF() {
1279
- return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
1280
- }
1281
- function invalidIdentifier() {
1282
- column -= 5;
1283
- return syntaxError(`JSON5: invalid identifier character at ${line}:${column}`);
1284
- }
1285
- function separatorChar(c2) {
1286
- console.warn(`JSON5: '${formatChar(c2)}' in strings is not valid ECMAScript; consider escaping`);
1287
- }
1288
- function formatChar(c2) {
1289
- const replacements = {
1290
- "'": "\\'",
1291
- '"': '\\"',
1292
- "\\": "\\\\",
1293
- "\b": "\\b",
1294
- "\f": "\\f",
1295
- "\n": "\\n",
1296
- "\r": "\\r",
1297
- " ": "\\t",
1298
- "\v": "\\v",
1299
- "\0": "\\0",
1300
- "\u2028": "\\u2028",
1301
- "\u2029": "\\u2029"
1302
- };
1303
- if (replacements[c2]) {
1304
- return replacements[c2];
1305
- }
1306
- if (c2 < " ") {
1307
- const hexString = c2.charCodeAt(0).toString(16);
1308
- return "\\x" + ("00" + hexString).substring(hexString.length);
1309
- }
1310
- return c2;
1311
- }
1312
- function syntaxError(message) {
1313
- const err = new SyntaxError(message);
1314
- err.lineNumber = line;
1315
- err.columnNumber = column;
1316
- return err;
1317
- }
1318
- }
1319
- });
1320
-
1321
- // ../../node_modules/json5/lib/stringify.js
1322
- var require_stringify = __commonJS({
1323
- "../../node_modules/json5/lib/stringify.js"(exports2, module2) {
1324
- "use strict";
1325
- var util = require_util();
1326
- module2.exports = function stringify(value, replacer, space) {
1327
- const stack = [];
1328
- let indent = "";
1329
- let propertyList;
1330
- let replacerFunc;
1331
- let gap = "";
1332
- let quote;
1333
- if (replacer != null && typeof replacer === "object" && !Array.isArray(replacer)) {
1334
- space = replacer.space;
1335
- quote = replacer.quote;
1336
- replacer = replacer.replacer;
1337
- }
1338
- if (typeof replacer === "function") {
1339
- replacerFunc = replacer;
1340
- } else if (Array.isArray(replacer)) {
1341
- propertyList = [];
1342
- for (const v of replacer) {
1343
- let item;
1344
- if (typeof v === "string") {
1345
- item = v;
1346
- } else if (typeof v === "number" || v instanceof String || v instanceof Number) {
1347
- item = String(v);
1348
- }
1349
- if (item !== void 0 && propertyList.indexOf(item) < 0) {
1350
- propertyList.push(item);
1351
- }
1352
- }
1353
- }
1354
- if (space instanceof Number) {
1355
- space = Number(space);
1356
- } else if (space instanceof String) {
1357
- space = String(space);
1358
- }
1359
- if (typeof space === "number") {
1360
- if (space > 0) {
1361
- space = Math.min(10, Math.floor(space));
1362
- gap = " ".substr(0, space);
1363
- }
1364
- } else if (typeof space === "string") {
1365
- gap = space.substr(0, 10);
1366
- }
1367
- return serializeProperty("", { "": value });
1368
- function serializeProperty(key, holder) {
1369
- let value2 = holder[key];
1370
- if (value2 != null) {
1371
- if (typeof value2.toJSON5 === "function") {
1372
- value2 = value2.toJSON5(key);
1373
- } else if (typeof value2.toJSON === "function") {
1374
- value2 = value2.toJSON(key);
1375
- }
1376
- }
1377
- if (replacerFunc) {
1378
- value2 = replacerFunc.call(holder, key, value2);
1379
- }
1380
- if (value2 instanceof Number) {
1381
- value2 = Number(value2);
1382
- } else if (value2 instanceof String) {
1383
- value2 = String(value2);
1384
- } else if (value2 instanceof Boolean) {
1385
- value2 = value2.valueOf();
1386
- }
1387
- switch (value2) {
1388
- case null:
1389
- return "null";
1390
- case true:
1391
- return "true";
1392
- case false:
1393
- return "false";
1394
- }
1395
- if (typeof value2 === "string") {
1396
- return quoteString(value2, false);
1397
- }
1398
- if (typeof value2 === "number") {
1399
- return String(value2);
1400
- }
1401
- if (typeof value2 === "object") {
1402
- return Array.isArray(value2) ? serializeArray(value2) : serializeObject(value2);
1403
- }
1404
- return void 0;
1405
- }
1406
- function quoteString(value2) {
1407
- const quotes = {
1408
- "'": 0.1,
1409
- '"': 0.2
1410
- };
1411
- const replacements = {
1412
- "'": "\\'",
1413
- '"': '\\"',
1414
- "\\": "\\\\",
1415
- "\b": "\\b",
1416
- "\f": "\\f",
1417
- "\n": "\\n",
1418
- "\r": "\\r",
1419
- " ": "\\t",
1420
- "\v": "\\v",
1421
- "\0": "\\0",
1422
- "\u2028": "\\u2028",
1423
- "\u2029": "\\u2029"
1424
- };
1425
- let product = "";
1426
- for (let i = 0; i < value2.length; i++) {
1427
- const c = value2[i];
1428
- switch (c) {
1429
- case "'":
1430
- case '"':
1431
- quotes[c]++;
1432
- product += c;
1433
- continue;
1434
- case "\0":
1435
- if (util.isDigit(value2[i + 1])) {
1436
- product += "\\x00";
1437
- continue;
1438
- }
1439
- }
1440
- if (replacements[c]) {
1441
- product += replacements[c];
1442
- continue;
1443
- }
1444
- if (c < " ") {
1445
- let hexString = c.charCodeAt(0).toString(16);
1446
- product += "\\x" + ("00" + hexString).substring(hexString.length);
1447
- continue;
1448
- }
1449
- product += c;
1450
- }
1451
- const quoteChar = quote || Object.keys(quotes).reduce((a, b) => quotes[a] < quotes[b] ? a : b);
1452
- product = product.replace(new RegExp(quoteChar, "g"), replacements[quoteChar]);
1453
- return quoteChar + product + quoteChar;
1454
- }
1455
- function serializeObject(value2) {
1456
- if (stack.indexOf(value2) >= 0) {
1457
- throw TypeError("Converting circular structure to JSON5");
1458
- }
1459
- stack.push(value2);
1460
- let stepback = indent;
1461
- indent = indent + gap;
1462
- let keys = propertyList || Object.keys(value2);
1463
- let partial = [];
1464
- for (const key of keys) {
1465
- const propertyString = serializeProperty(key, value2);
1466
- if (propertyString !== void 0) {
1467
- let member = serializeKey(key) + ":";
1468
- if (gap !== "") {
1469
- member += " ";
1470
- }
1471
- member += propertyString;
1472
- partial.push(member);
1473
- }
1474
- }
1475
- let final;
1476
- if (partial.length === 0) {
1477
- final = "{}";
1478
- } else {
1479
- let properties;
1480
- if (gap === "") {
1481
- properties = partial.join(",");
1482
- final = "{" + properties + "}";
1483
- } else {
1484
- let separator = ",\n" + indent;
1485
- properties = partial.join(separator);
1486
- final = "{\n" + indent + properties + ",\n" + stepback + "}";
1487
- }
1488
- }
1489
- stack.pop();
1490
- indent = stepback;
1491
- return final;
1492
- }
1493
- function serializeKey(key) {
1494
- if (key.length === 0) {
1495
- return quoteString(key, true);
1496
- }
1497
- const firstChar = String.fromCodePoint(key.codePointAt(0));
1498
- if (!util.isIdStartChar(firstChar)) {
1499
- return quoteString(key, true);
1500
- }
1501
- for (let i = firstChar.length; i < key.length; i++) {
1502
- if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
1503
- return quoteString(key, true);
1504
- }
1505
- }
1506
- return key;
1507
- }
1508
- function serializeArray(value2) {
1509
- if (stack.indexOf(value2) >= 0) {
1510
- throw TypeError("Converting circular structure to JSON5");
1511
- }
1512
- stack.push(value2);
1513
- let stepback = indent;
1514
- indent = indent + gap;
1515
- let partial = [];
1516
- for (let i = 0; i < value2.length; i++) {
1517
- const propertyString = serializeProperty(String(i), value2);
1518
- partial.push(propertyString !== void 0 ? propertyString : "null");
1519
- }
1520
- let final;
1521
- if (partial.length === 0) {
1522
- final = "[]";
1523
- } else {
1524
- if (gap === "") {
1525
- let properties = partial.join(",");
1526
- final = "[" + properties + "]";
1527
- } else {
1528
- let separator = ",\n" + indent;
1529
- let properties = partial.join(separator);
1530
- final = "[\n" + indent + properties + ",\n" + stepback + "]";
1531
- }
1532
- }
1533
- stack.pop();
1534
- indent = stepback;
1535
- return final;
1536
- }
1537
- };
1538
- }
1539
- });
1540
-
1541
- // ../../node_modules/json5/lib/index.js
1542
- var require_lib = __commonJS({
1543
- "../../node_modules/json5/lib/index.js"(exports2, module2) {
1544
- "use strict";
1545
- var parse = require_parse();
1546
- var stringify = require_stringify();
1547
- var JSON5 = {
1548
- parse,
1549
- stringify
1550
- };
1551
- module2.exports = JSON5;
1552
- }
1553
- });
1554
-
1555
- // ../../node_modules/strip-bom/index.js
1556
- var require_strip_bom = __commonJS({
1557
- "../../node_modules/strip-bom/index.js"(exports2, module2) {
1558
- "use strict";
1559
- module2.exports = (x) => {
1560
- if (typeof x !== "string") {
1561
- throw new TypeError("Expected a string, got " + typeof x);
1562
- }
1563
- if (x.charCodeAt(0) === 65279) {
1564
- return x.slice(1);
1565
- }
1566
- return x;
1567
- };
1568
- }
1569
- });
1570
-
1571
- // ../../node_modules/tsconfig-paths/lib/tsconfig-loader.js
1572
- var require_tsconfig_loader = __commonJS({
1573
- "../../node_modules/tsconfig-paths/lib/tsconfig-loader.js"(exports2) {
1574
- "use strict";
1575
- var __assign = exports2 && exports2.__assign || function() {
1576
- __assign = Object.assign || function(t) {
1577
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1578
- s = arguments[i];
1579
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1580
- t[p] = s[p];
1581
- }
1582
- return t;
1583
- };
1584
- return __assign.apply(this, arguments);
1585
- };
1586
- Object.defineProperty(exports2, "__esModule", { value: true });
1587
- exports2.loadTsconfig = exports2.walkForTsConfig = exports2.tsConfigLoader = void 0;
1588
- var path6 = require("path");
1589
- var fs6 = require("fs");
1590
- var JSON5 = require_lib();
1591
- var StripBom = require_strip_bom();
1592
- function tsConfigLoader(_a) {
1593
- var getEnv = _a.getEnv, cwd = _a.cwd, _b = _a.loadSync, loadSync = _b === void 0 ? loadSyncDefault : _b;
1594
- var TS_NODE_PROJECT = getEnv("TS_NODE_PROJECT");
1595
- var TS_NODE_BASEURL = getEnv("TS_NODE_BASEURL");
1596
- var loadResult = loadSync(cwd, TS_NODE_PROJECT, TS_NODE_BASEURL);
1597
- return loadResult;
1598
- }
1599
- exports2.tsConfigLoader = tsConfigLoader;
1600
- function loadSyncDefault(cwd, filename, baseUrl) {
1601
- var configPath = resolveConfigPath(cwd, filename);
1602
- if (!configPath) {
1603
- return {
1604
- tsConfigPath: void 0,
1605
- baseUrl: void 0,
1606
- paths: void 0
1607
- };
1608
- }
1609
- var config = loadTsconfig(configPath);
1610
- return {
1611
- tsConfigPath: configPath,
1612
- baseUrl: baseUrl || config && config.compilerOptions && config.compilerOptions.baseUrl,
1613
- paths: config && config.compilerOptions && config.compilerOptions.paths
1614
- };
1615
- }
1616
- function resolveConfigPath(cwd, filename) {
1617
- if (filename) {
1618
- var absolutePath = fs6.lstatSync(filename).isDirectory() ? path6.resolve(filename, "./tsconfig.json") : path6.resolve(cwd, filename);
1619
- return absolutePath;
1620
- }
1621
- if (fs6.statSync(cwd).isFile()) {
1622
- return path6.resolve(cwd);
1623
- }
1624
- var configAbsolutePath = walkForTsConfig(cwd);
1625
- return configAbsolutePath ? path6.resolve(configAbsolutePath) : void 0;
1626
- }
1627
- function walkForTsConfig(directory, readdirSync) {
1628
- if (readdirSync === void 0) {
1629
- readdirSync = fs6.readdirSync;
1630
- }
1631
- var files = readdirSync(directory);
1632
- var filesToCheck = ["tsconfig.json", "jsconfig.json"];
1633
- for (var _i = 0, filesToCheck_1 = filesToCheck; _i < filesToCheck_1.length; _i++) {
1634
- var fileToCheck = filesToCheck_1[_i];
1635
- if (files.indexOf(fileToCheck) !== -1) {
1636
- return path6.join(directory, fileToCheck);
1637
- }
1638
- }
1639
- var parentDirectory = path6.dirname(directory);
1640
- if (directory === parentDirectory) {
1641
- return void 0;
1642
- }
1643
- return walkForTsConfig(parentDirectory, readdirSync);
1644
- }
1645
- exports2.walkForTsConfig = walkForTsConfig;
1646
- function loadTsconfig(configFilePath, existsSync5, readFileSync4) {
1647
- if (existsSync5 === void 0) {
1648
- existsSync5 = fs6.existsSync;
1649
- }
1650
- if (readFileSync4 === void 0) {
1651
- readFileSync4 = function(filename) {
1652
- return fs6.readFileSync(filename, "utf8");
1653
- };
1654
- }
1655
- if (!existsSync5(configFilePath)) {
1656
- return void 0;
1657
- }
1658
- var configString = readFileSync4(configFilePath);
1659
- var cleanedJson = StripBom(configString);
1660
- var config;
1661
- try {
1662
- config = JSON5.parse(cleanedJson);
1663
- } catch (e) {
1664
- throw new Error("".concat(configFilePath, " is malformed ").concat(e.message));
1665
- }
1666
- var extendedConfig = config.extends;
1667
- if (extendedConfig) {
1668
- var base = void 0;
1669
- if (Array.isArray(extendedConfig)) {
1670
- base = extendedConfig.reduce(function(currBase, extendedConfigElement) {
1671
- return mergeTsconfigs(currBase, loadTsconfigFromExtends(configFilePath, extendedConfigElement, existsSync5, readFileSync4));
1672
- }, {});
1673
- } else {
1674
- base = loadTsconfigFromExtends(configFilePath, extendedConfig, existsSync5, readFileSync4);
1675
- }
1676
- return mergeTsconfigs(base, config);
1677
- }
1678
- return config;
1679
- }
1680
- exports2.loadTsconfig = loadTsconfig;
1681
- function loadTsconfigFromExtends(configFilePath, extendedConfigValue, existsSync5, readFileSync4) {
1682
- var _a;
1683
- if (typeof extendedConfigValue === "string" && extendedConfigValue.indexOf(".json") === -1) {
1684
- extendedConfigValue += ".json";
1685
- }
1686
- var currentDir = path6.dirname(configFilePath);
1687
- var extendedConfigPath = path6.join(currentDir, extendedConfigValue);
1688
- if (extendedConfigValue.indexOf("/") !== -1 && extendedConfigValue.indexOf(".") !== -1 && !existsSync5(extendedConfigPath)) {
1689
- extendedConfigPath = path6.join(currentDir, "node_modules", extendedConfigValue);
1690
- }
1691
- var config = loadTsconfig(extendedConfigPath, existsSync5, readFileSync4) || {};
1692
- if ((_a = config.compilerOptions) === null || _a === void 0 ? void 0 : _a.baseUrl) {
1693
- var extendsDir = path6.dirname(extendedConfigValue);
1694
- config.compilerOptions.baseUrl = path6.join(extendsDir, config.compilerOptions.baseUrl);
1695
- }
1696
- return config;
1697
- }
1698
- function mergeTsconfigs(base, config) {
1699
- base = base || {};
1700
- config = config || {};
1701
- return __assign(__assign(__assign({}, base), config), { compilerOptions: __assign(__assign({}, base.compilerOptions), config.compilerOptions) });
1702
- }
1703
- }
1704
- });
1705
-
1706
- // ../../node_modules/tsconfig-paths/lib/config-loader.js
1707
- var require_config_loader = __commonJS({
1708
- "../../node_modules/tsconfig-paths/lib/config-loader.js"(exports2) {
1709
- "use strict";
1710
- Object.defineProperty(exports2, "__esModule", { value: true });
1711
- exports2.configLoader = exports2.loadConfig = void 0;
1712
- var TsConfigLoader2 = require_tsconfig_loader();
1713
- var path6 = require("path");
1714
- function loadConfig3(cwd) {
1715
- if (cwd === void 0) {
1716
- cwd = process.cwd();
1717
- }
1718
- return configLoader({ cwd });
1719
- }
1720
- exports2.loadConfig = loadConfig3;
1721
- function configLoader(_a) {
1722
- var cwd = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader2.tsConfigLoader : _b;
1723
- if (explicitParams) {
1724
- var absoluteBaseUrl = path6.isAbsolute(explicitParams.baseUrl) ? explicitParams.baseUrl : path6.join(cwd, explicitParams.baseUrl);
1725
- return {
1726
- resultType: "success",
1727
- configFileAbsolutePath: "",
1728
- baseUrl: explicitParams.baseUrl,
1729
- absoluteBaseUrl,
1730
- paths: explicitParams.paths,
1731
- mainFields: explicitParams.mainFields,
1732
- addMatchAll: explicitParams.addMatchAll
1733
- };
1734
- }
1735
- var loadResult = tsConfigLoader({
1736
- cwd,
1737
- getEnv: function(key) {
1738
- return process.env[key];
1739
- }
1740
- });
1741
- if (!loadResult.tsConfigPath) {
1742
- return {
1743
- resultType: "failed",
1744
- message: "Couldn't find tsconfig.json"
1745
- };
1746
- }
1747
- return {
1748
- resultType: "success",
1749
- configFileAbsolutePath: loadResult.tsConfigPath,
1750
- baseUrl: loadResult.baseUrl,
1751
- absoluteBaseUrl: path6.resolve(path6.dirname(loadResult.tsConfigPath), loadResult.baseUrl || ""),
1752
- paths: loadResult.paths || {},
1753
- addMatchAll: loadResult.baseUrl !== void 0
1754
- };
1755
- }
1756
- exports2.configLoader = configLoader;
1757
- }
1758
- });
1759
-
1760
- // ../../node_modules/minimist/index.js
1761
- var require_minimist = __commonJS({
1762
- "../../node_modules/minimist/index.js"(exports2, module2) {
1763
- "use strict";
1764
- function hasKey(obj, keys) {
1765
- var o = obj;
1766
- keys.slice(0, -1).forEach(function(key2) {
1767
- o = o[key2] || {};
1768
- });
1769
- var key = keys[keys.length - 1];
1770
- return key in o;
1771
- }
1772
- function isNumber(x) {
1773
- if (typeof x === "number") {
1774
- return true;
1775
- }
1776
- if (/^0x[0-9a-f]+$/i.test(x)) {
1777
- return true;
1778
- }
1779
- return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
1780
- }
1781
- function isConstructorOrProto(obj, key) {
1782
- return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
1783
- }
1784
- module2.exports = function(args, opts) {
1785
- if (!opts) {
1786
- opts = {};
1787
- }
1788
- var flags = {
1789
- bools: {},
1790
- strings: {},
1791
- unknownFn: null
1792
- };
1793
- if (typeof opts.unknown === "function") {
1794
- flags.unknownFn = opts.unknown;
1795
- }
1796
- if (typeof opts.boolean === "boolean" && opts.boolean) {
1797
- flags.allBools = true;
1798
- } else {
1799
- [].concat(opts.boolean).filter(Boolean).forEach(function(key2) {
1800
- flags.bools[key2] = true;
1801
- });
1802
- }
1803
- var aliases = {};
1804
- function aliasIsBoolean(key2) {
1805
- return aliases[key2].some(function(x) {
1806
- return flags.bools[x];
1807
- });
1808
- }
1809
- Object.keys(opts.alias || {}).forEach(function(key2) {
1810
- aliases[key2] = [].concat(opts.alias[key2]);
1811
- aliases[key2].forEach(function(x) {
1812
- aliases[x] = [key2].concat(aliases[key2].filter(function(y) {
1813
- return x !== y;
1814
- }));
1815
- });
1816
- });
1817
- [].concat(opts.string).filter(Boolean).forEach(function(key2) {
1818
- flags.strings[key2] = true;
1819
- if (aliases[key2]) {
1820
- [].concat(aliases[key2]).forEach(function(k) {
1821
- flags.strings[k] = true;
1822
- });
1823
- }
1824
- });
1825
- var defaults = opts.default || {};
1826
- var argv = { _: [] };
1827
- function argDefined(key2, arg2) {
1828
- return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
1829
- }
1830
- function setKey(obj, keys, value2) {
1831
- var o = obj;
1832
- for (var i2 = 0; i2 < keys.length - 1; i2++) {
1833
- var key2 = keys[i2];
1834
- if (isConstructorOrProto(o, key2)) {
1835
- return;
1836
- }
1837
- if (o[key2] === void 0) {
1838
- o[key2] = {};
1839
- }
1840
- if (o[key2] === Object.prototype || o[key2] === Number.prototype || o[key2] === String.prototype) {
1841
- o[key2] = {};
1842
- }
1843
- if (o[key2] === Array.prototype) {
1844
- o[key2] = [];
1845
- }
1846
- o = o[key2];
1847
- }
1848
- var lastKey = keys[keys.length - 1];
1849
- if (isConstructorOrProto(o, lastKey)) {
1850
- return;
1851
- }
1852
- if (o === Object.prototype || o === Number.prototype || o === String.prototype) {
1853
- o = {};
1854
- }
1855
- if (o === Array.prototype) {
1856
- o = [];
1857
- }
1858
- if (o[lastKey] === void 0 || flags.bools[lastKey] || typeof o[lastKey] === "boolean") {
1859
- o[lastKey] = value2;
1860
- } else if (Array.isArray(o[lastKey])) {
1861
- o[lastKey].push(value2);
1862
- } else {
1863
- o[lastKey] = [o[lastKey], value2];
1864
- }
1865
- }
1866
- function setArg(key2, val, arg2) {
1867
- if (arg2 && flags.unknownFn && !argDefined(key2, arg2)) {
1868
- if (flags.unknownFn(arg2) === false) {
1869
- return;
1870
- }
1871
- }
1872
- var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
1873
- setKey(argv, key2.split("."), value2);
1874
- (aliases[key2] || []).forEach(function(x) {
1875
- setKey(argv, x.split("."), value2);
1876
- });
1877
- }
1878
- Object.keys(flags.bools).forEach(function(key2) {
1879
- setArg(key2, defaults[key2] === void 0 ? false : defaults[key2]);
1880
- });
1881
- var notFlags = [];
1882
- if (args.indexOf("--") !== -1) {
1883
- notFlags = args.slice(args.indexOf("--") + 1);
1884
- args = args.slice(0, args.indexOf("--"));
1885
- }
1886
- for (var i = 0; i < args.length; i++) {
1887
- var arg = args[i];
1888
- var key;
1889
- var next;
1890
- if (/^--.+=/.test(arg)) {
1891
- var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
1892
- key = m[1];
1893
- var value = m[2];
1894
- if (flags.bools[key]) {
1895
- value = value !== "false";
1896
- }
1897
- setArg(key, value, arg);
1898
- } else if (/^--no-.+/.test(arg)) {
1899
- key = arg.match(/^--no-(.+)/)[1];
1900
- setArg(key, false, arg);
1901
- } else if (/^--.+/.test(arg)) {
1902
- key = arg.match(/^--(.+)/)[1];
1903
- next = args[i + 1];
1904
- if (next !== void 0 && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
1905
- setArg(key, next, arg);
1906
- i += 1;
1907
- } else if (/^(true|false)$/.test(next)) {
1908
- setArg(key, next === "true", arg);
1909
- i += 1;
1910
- } else {
1911
- setArg(key, flags.strings[key] ? "" : true, arg);
1912
- }
1913
- } else if (/^-[^-]+/.test(arg)) {
1914
- var letters = arg.slice(1, -1).split("");
1915
- var broken = false;
1916
- for (var j = 0; j < letters.length; j++) {
1917
- next = arg.slice(j + 2);
1918
- if (next === "-") {
1919
- setArg(letters[j], next, arg);
1920
- continue;
1921
- }
1922
- if (/[A-Za-z]/.test(letters[j]) && next[0] === "=") {
1923
- setArg(letters[j], next.slice(1), arg);
1924
- broken = true;
1925
- break;
1926
- }
1927
- if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
1928
- setArg(letters[j], next, arg);
1929
- broken = true;
1930
- break;
1931
- }
1932
- if (letters[j + 1] && letters[j + 1].match(/\W/)) {
1933
- setArg(letters[j], arg.slice(j + 2), arg);
1934
- broken = true;
1935
- break;
1936
- } else {
1937
- setArg(letters[j], flags.strings[letters[j]] ? "" : true, arg);
1938
- }
1939
- }
1940
- key = arg.slice(-1)[0];
1941
- if (!broken && key !== "-") {
1942
- if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
1943
- setArg(key, args[i + 1], arg);
1944
- i += 1;
1945
- } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
1946
- setArg(key, args[i + 1] === "true", arg);
1947
- i += 1;
1948
- } else {
1949
- setArg(key, flags.strings[key] ? "" : true, arg);
1950
- }
1951
- }
1952
- } else {
1953
- if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
1954
- argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
1955
- }
1956
- if (opts.stopEarly) {
1957
- argv._.push.apply(argv._, args.slice(i + 1));
1958
- break;
1959
- }
1960
- }
1961
- }
1962
- Object.keys(defaults).forEach(function(k) {
1963
- if (!hasKey(argv, k.split("."))) {
1964
- setKey(argv, k.split("."), defaults[k]);
1965
- (aliases[k] || []).forEach(function(x) {
1966
- setKey(argv, x.split("."), defaults[k]);
1967
- });
1968
- }
1969
- });
1970
- if (opts["--"]) {
1971
- argv["--"] = notFlags.slice();
1972
- } else {
1973
- notFlags.forEach(function(k) {
1974
- argv._.push(k);
1975
- });
1976
- }
1977
- return argv;
1978
- };
1979
- }
1980
- });
1981
-
1982
- // ../../node_modules/tsconfig-paths/lib/register.js
1983
- var require_register = __commonJS({
1984
- "../../node_modules/tsconfig-paths/lib/register.js"(exports2) {
1985
- "use strict";
1986
- var __spreadArray = exports2 && exports2.__spreadArray || function(to, from, pack) {
1987
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1988
- if (ar || !(i in from)) {
1989
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1990
- ar[i] = from[i];
1991
- }
1992
- }
1993
- return to.concat(ar || Array.prototype.slice.call(from));
1994
- };
1995
- Object.defineProperty(exports2, "__esModule", { value: true });
1996
- exports2.register = void 0;
1997
- var match_path_sync_1 = require_match_path_sync();
1998
- var config_loader_1 = require_config_loader();
1999
- var noOp = function() {
2000
- return void 0;
2001
- };
2002
- function getCoreModules(builtinModules) {
2003
- builtinModules = builtinModules || [
2004
- "assert",
2005
- "buffer",
2006
- "child_process",
2007
- "cluster",
2008
- "crypto",
2009
- "dgram",
2010
- "dns",
2011
- "domain",
2012
- "events",
2013
- "fs",
2014
- "http",
2015
- "https",
2016
- "net",
2017
- "os",
2018
- "path",
2019
- "punycode",
2020
- "querystring",
2021
- "readline",
2022
- "stream",
2023
- "string_decoder",
2024
- "tls",
2025
- "tty",
2026
- "url",
2027
- "util",
2028
- "v8",
2029
- "vm",
2030
- "zlib"
2031
- ];
2032
- var coreModules = {};
2033
- for (var _i = 0, builtinModules_1 = builtinModules; _i < builtinModules_1.length; _i++) {
2034
- var module_1 = builtinModules_1[_i];
2035
- coreModules[module_1] = true;
2036
- }
2037
- return coreModules;
2038
- }
2039
- function register(params) {
2040
- var cwd;
2041
- var explicitParams;
2042
- if (params) {
2043
- cwd = params.cwd;
2044
- if (params.baseUrl || params.paths) {
2045
- explicitParams = params;
2046
- }
2047
- } else {
2048
- var minimist = require_minimist();
2049
- var argv = minimist(process.argv.slice(2), {
2050
- // eslint-disable-next-line id-denylist
2051
- string: ["project"],
2052
- alias: {
2053
- project: ["P"]
2054
- }
2055
- });
2056
- cwd = argv.project;
2057
- }
2058
- var configLoaderResult = (0, config_loader_1.configLoader)({
2059
- cwd: cwd !== null && cwd !== void 0 ? cwd : process.cwd(),
2060
- explicitParams
2061
- });
2062
- if (configLoaderResult.resultType === "failed") {
2063
- console.warn("".concat(configLoaderResult.message, ". tsconfig-paths will be skipped"));
2064
- return noOp;
2065
- }
2066
- var matchPath = (0, match_path_sync_1.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
2067
- var Module = require("module");
2068
- var originalResolveFilename = Module._resolveFilename;
2069
- var coreModules = getCoreModules(Module.builtinModules);
2070
- Module._resolveFilename = function(request, _parent) {
2071
- var isCoreModule = coreModules.hasOwnProperty(request);
2072
- if (!isCoreModule) {
2073
- var found = matchPath(request);
2074
- if (found) {
2075
- var modifiedArguments = __spreadArray([found], [].slice.call(arguments, 1), true);
2076
- return originalResolveFilename.apply(this, modifiedArguments);
2077
- }
2078
- }
2079
- return originalResolveFilename.apply(this, arguments);
2080
- };
2081
- return function() {
2082
- Module._resolveFilename = originalResolveFilename;
2083
- };
2084
- }
2085
- exports2.register = register;
2086
- }
2087
- });
2088
-
2089
- // ../../node_modules/tsconfig-paths/lib/index.js
2090
- var require_lib2 = __commonJS({
2091
- "../../node_modules/tsconfig-paths/lib/index.js"(exports2) {
2092
- "use strict";
2093
- Object.defineProperty(exports2, "__esModule", { value: true });
2094
- exports2.loadConfig = exports2.register = exports2.matchFromAbsolutePathsAsync = exports2.createMatchPathAsync = exports2.matchFromAbsolutePaths = exports2.createMatchPath = void 0;
2095
- var match_path_sync_1 = require_match_path_sync();
2096
- Object.defineProperty(exports2, "createMatchPath", { enumerable: true, get: function() {
2097
- return match_path_sync_1.createMatchPath;
2098
- } });
2099
- Object.defineProperty(exports2, "matchFromAbsolutePaths", { enumerable: true, get: function() {
2100
- return match_path_sync_1.matchFromAbsolutePaths;
2101
- } });
2102
- var match_path_async_1 = require_match_path_async();
2103
- Object.defineProperty(exports2, "createMatchPathAsync", { enumerable: true, get: function() {
2104
- return match_path_async_1.createMatchPathAsync;
2105
- } });
2106
- Object.defineProperty(exports2, "matchFromAbsolutePathsAsync", { enumerable: true, get: function() {
2107
- return match_path_async_1.matchFromAbsolutePathsAsync;
2108
- } });
2109
- var register_1 = require_register();
2110
- Object.defineProperty(exports2, "register", { enumerable: true, get: function() {
2111
- return register_1.register;
2112
- } });
2113
- var config_loader_1 = require_config_loader();
2114
- Object.defineProperty(exports2, "loadConfig", { enumerable: true, get: function() {
2115
- return config_loader_1.loadConfig;
2116
- } });
2117
- }
2118
- });
2119
-
2120
- // src/cli/index.ts
2121
- var import_commander3 = require("commander");
2122
- var import_prompts3 = require("@inquirer/prompts");
2123
-
2124
- // package.json
2125
- var package_default = {
2126
- name: "@hyper-fetch/cli",
2127
- version: "0.0.0",
2128
- description: "Hyper Fetch cli for code generation and utilities",
2129
- author: "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
2130
- homepage: "https://hyperfetch.bettertyped.com/",
2131
- license: "Apache-2.0",
2132
- main: "dist/index.js",
2133
- module: "dist/index.js",
2134
- types: "dist/index.d.ts",
2135
- source: "src/index.ts",
2136
- cli: "src/cli/index.ts",
2137
- climain: "dist/index.js",
2138
- bin: "dist/index.js",
2139
- scripts: {
2140
- clean: "npx rimraf dist",
2141
- test: "node --experimental-vm-modules ../../node_modules/jest/bin/jest --watchAll --maxWorkers=3 --forceExit",
2142
- "test:pipeline": "node --experimental-vm-modules ../../node_modules/jest/bin/jest --watchAll=false --maxWorkers=1 --no-cache --forceExit",
2143
- dev: "npx tsx ./src/cli/index.ts",
2144
- prebuild: "yarn update:version",
2145
- build: "yarn clean && node ../../scripts/build.js",
2146
- postbuild: "yarn rollup -c ../../rollup.config.js",
2147
- "update:version": "node ../../scripts/update-package-version.js --prefix hyper-fetch-cli-v",
2148
- lint: "eslint . --ext .js,.jsx,.tsx,.ts --fix",
2149
- format: "prettier --write .",
2150
- typescheck: "tsc --noEmit --emitDeclarationOnly false",
2151
- tests: "yarn lint-staged",
2152
- release: "yarn semantic-release --extends ../../release.config.js -t 'hyper-fetch-cli-v${version}'"
2153
- },
2154
- publishConfig: {
2155
- access: "public",
2156
- registry: "https://registry.npmjs.com/"
2157
- },
2158
- repository: {
2159
- type: "git",
2160
- url: "git+https://github.com/BetterTyped/hyper-fetch.git",
2161
- directory: "packages/cli"
2162
- },
2163
- bugs: {
2164
- url: "https://github.com/BetterTyped/hyper-fetch/issues"
2165
- },
2166
- dependencies: {
2167
- "@anttiviljami/dtsgenerator": "^3.20.0",
2168
- "@apidevtools/json-schema-ref-parser": "^11.9.3",
2169
- "@hyper-fetch/core": "*",
2170
- "@inquirer/prompts": "^7.6.0",
2171
- chalk: "^5.4.1",
2172
- "cli-table3": "^0.6.5",
2173
- commander: "^11.0.0",
2174
- execa: "^8.0.1",
2175
- "fs-extra": "^11.3.0",
2176
- lodash: "^4.17.21",
2177
- "openapi-types": "^12.1.3",
2178
- ora: "^8.2.0",
2179
- prettier: "^3.6.2",
2180
- react: "^19.1.0",
2181
- "react-dom": "^19.1.0",
2182
- zod: "^4.0.2"
2183
- },
2184
- devDependencies: {
2185
- "@types/fs-extra": "^11.0.4",
2186
- "abortcontroller-polyfill": "^1.7.5"
2187
- },
2188
- "lint-staged": {
2189
- "*.{js,jsx,ts,tsx}": [
2190
- "yarn jest --passWithNoTests"
2191
- ]
2192
- },
2193
- keywords: [
2194
- "codegen",
2195
- "openapi",
2196
- "hyper fetch",
2197
- "swagger",
2198
- "openapi schema",
2199
- "code generator"
2200
- ]
2201
- };
2202
-
2203
- // src/commands/generate.ts
2204
- var import_commander = require("commander");
2205
- var import_zod4 = require("zod");
2206
- var path4 = __toESM(require("node:path"));
2207
- var fs4 = __toESM(require("fs-extra"));
2208
- var import_prompts = require("@inquirer/prompts");
2209
-
2210
- // src/utils/handle-error.ts
2211
- var import_chalk2 = __toESM(require("chalk"));
2212
- var import_zod = require("zod");
2213
-
2214
- // src/utils/logger.ts
2215
- var import_chalk = __toESM(require("chalk"));
2216
- var logger = {
2217
- info(...args) {
2218
- console.log(import_chalk.default.cyan("\u2139"), import_chalk.default.blue.bold("info"), ...args);
2219
- },
2220
- warn(...args) {
2221
- console.log(import_chalk.default.yellow("\u26A0"), import_chalk.default.yellow.bold("warn"), ...args);
2222
- },
2223
- error(...args) {
2224
- console.log(import_chalk.default.red("\u2716"), import_chalk.default.red.bold("error"), ...args);
2225
- },
2226
- success(...args) {
2227
- console.log(import_chalk.default.green("\u2714"), import_chalk.default.green.bold("success"), ...args);
2228
- },
2229
- break() {
2230
- console.log("");
2231
- }
2232
- };
2233
-
2234
- // src/utils/handle-error.ts
2235
- function handleError(error) {
2236
- logger.break();
2237
- logger.error(`Something went wrong. Please check the error below for more details.`);
2238
- logger.error(`If the problem persists, please open an issue on GitHub.`);
2239
- logger.break();
2240
- if (typeof error === "string") {
2241
- logger.error(error);
2242
- logger.break();
2243
- process.exit(1);
2244
- }
2245
- if (error instanceof import_zod.z.ZodError) {
2246
- logger.error("Validation failed:");
2247
- for (const [key, value] of Object.entries(error.flatten().fieldErrors)) {
2248
- logger.error(`- ${import_chalk2.default.cyan(key)}: ${value}`);
2249
- }
2250
- logger.break();
2251
- process.exit(1);
2252
- }
2253
- if (error instanceof Error) {
2254
- logger.error(error.message);
2255
- logger.break();
2256
- process.exit(1);
2257
- }
2258
- logger.error(JSON.stringify({ error }));
2259
- logger.break();
2260
- process.exit(1);
2261
- }
2262
-
2263
- // src/preflights/preflight-generate.ts
2264
- var path2 = __toESM(require("node:path"));
2265
- var fs2 = __toESM(require("fs-extra"));
2266
-
2267
- // src/utils/errors.ts
2268
- var MISSING_DIR_OR_EMPTY_PROJECT = "1";
2269
-
2270
- // src/config/get-config.ts
2271
- var path = __toESM(require("node:path"));
2272
- var fs = __toESM(require("fs-extra"));
2273
- var import_tsconfig_paths2 = __toESM(require_lib2());
2274
-
2275
- // ../../node_modules/kleur/colors.mjs
2276
- var FORCE_COLOR;
2277
- var NODE_DISABLE_COLORS;
2278
- var NO_COLOR;
2279
- var TERM;
2280
- var isTTY = true;
2281
- if (typeof process !== "undefined") {
2282
- ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
2283
- isTTY = process.stdout && process.stdout.isTTY;
2284
- }
2285
- var $ = {
2286
- enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY)
2287
- };
2288
- function init(x, y) {
2289
- let rgx = new RegExp(`\\x1b\\[${y}m`, "g");
2290
- let open = `\x1B[${x}m`, close = `\x1B[${y}m`;
2291
- return function(txt) {
2292
- if (!$.enabled || txt == null) return txt;
2293
- return open + (!!~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close;
2294
- };
2295
- }
2296
- var reset = init(0, 0);
2297
- var bold = init(1, 22);
2298
- var dim = init(2, 22);
2299
- var italic = init(3, 23);
2300
- var underline = init(4, 24);
2301
- var inverse = init(7, 27);
2302
- var hidden = init(8, 28);
2303
- var strikethrough = init(9, 29);
2304
- var black = init(30, 39);
2305
- var red = init(31, 39);
2306
- var green = init(32, 39);
2307
- var yellow = init(33, 39);
2308
- var blue = init(34, 39);
2309
- var magenta = init(35, 39);
2310
- var cyan = init(36, 39);
2311
- var white = init(37, 39);
2312
- var gray = init(90, 39);
2313
- var grey = init(90, 39);
2314
- var bgBlack = init(40, 49);
2315
- var bgRed = init(41, 49);
2316
- var bgGreen = init(42, 49);
2317
- var bgYellow = init(43, 49);
2318
- var bgBlue = init(44, 49);
2319
- var bgMagenta = init(45, 49);
2320
- var bgCyan = init(46, 49);
2321
- var bgWhite = init(47, 49);
2322
-
2323
- // src/utils/highlighter.ts
2324
- var highlighter = {
2325
- error: red,
2326
- warn: yellow,
2327
- info: cyan,
2328
- success: green
2329
- };
2330
-
2331
- // src/utils/resolve-import.ts
2332
- var import_tsconfig_paths = __toESM(require_lib2());
2333
- function resolveImport(importPath, config) {
2334
- return __async(this, null, function* () {
2335
- return (0, import_tsconfig_paths.createMatchPath)(config.absoluteBaseUrl, config.paths)(importPath, void 0, () => true, [
2336
- ".ts",
2337
- ".tsx",
2338
- ".jsx",
2339
- ".js",
2340
- ".css"
2341
- ]);
2342
- });
2343
- }
2344
-
2345
- // src/config/schema.ts
2346
- var import_zod2 = require("zod");
2347
- var configSchema = import_zod2.z.object({
2348
- tsx: import_zod2.z.boolean(),
2349
- aliases: import_zod2.z.object({
2350
- api: import_zod2.z.string(),
2351
- hooks: import_zod2.z.string(),
2352
- ui: import_zod2.z.string(),
2353
- components: import_zod2.z.string(),
2354
- lib: import_zod2.z.string()
2355
- }),
2356
- resolvedPaths: import_zod2.z.object({
2357
- cwd: import_zod2.z.string(),
2358
- api: import_zod2.z.string(),
2359
- hooks: import_zod2.z.string(),
2360
- ui: import_zod2.z.string(),
2361
- components: import_zod2.z.string(),
2362
- lib: import_zod2.z.string()
2363
- })
2364
- });
2365
-
2366
- // src/config/get-config.ts
2367
- function resolveConfigPaths(cwd, config) {
2368
- return __async(this, null, function* () {
2369
- var _a;
2370
- const tsConfig = yield (0, import_tsconfig_paths2.loadConfig)(cwd);
2371
- if (tsConfig.resultType === "failed") {
2372
- throw new Error(`Failed to load ${config.tsx ? "tsconfig" : "jsconfig"}.json. ${(_a = tsConfig.message) != null ? _a : ""}`.trim());
2373
- }
2374
- return configSchema.parse(__spreadProps(__spreadValues({}, config), {
2375
- resolvedPaths: {
2376
- cwd,
2377
- api: yield resolveImport(config.aliases.api, tsConfig),
2378
- components: yield resolveImport(config.aliases.components, tsConfig),
2379
- lib: yield resolveImport(config.aliases.lib, tsConfig),
2380
- hooks: yield resolveImport(config.aliases.hooks, tsConfig),
2381
- ui: yield resolveImport(config.aliases.ui, tsConfig)
2382
- }
2383
- }));
2384
- });
2385
- }
2386
- function getConfig(cwd) {
2387
- return __async(this, null, function* () {
2388
- if (!fs.existsSync(path.resolve(cwd, "api.json"))) {
2389
- logger.break();
2390
- logger.error(
2391
- `An invalid ${highlighter.info("api.json")} file was found at ${highlighter.info(
2392
- cwd
2393
- )}.
2394
- Before you can add or generate SDKs, you must create a valid ${highlighter.info(
2395
- "api.json"
2396
- )} file by running the ${highlighter.info("init")} command.`
2397
- );
2398
- logger.break();
2399
- process.exit(1);
2400
- }
2401
- const { data, error } = yield configSchema.omit({ resolvedPaths: true }).safeParseAsync(JSON.parse(fs.readFileSync(path.resolve(cwd, "api.json"), "utf8")));
2402
- if (error) {
2403
- handleError(error);
2404
- }
2405
- if (!data) {
2406
- throw new Error(`Invalid configuration found in ${highlighter.info(cwd)}.`);
2407
- }
2408
- return resolveConfigPaths(cwd, data);
2409
- });
2410
- }
2411
-
2412
- // src/preflights/preflight-generate.ts
2413
- function preFlightGenerate(options) {
2414
- return __async(this, null, function* () {
2415
- const errors = {};
2416
- if (!fs2.existsSync(options.cwd) || !fs2.existsSync(path2.resolve(options.cwd, "package.json"))) {
2417
- errors[MISSING_DIR_OR_EMPTY_PROJECT] = true;
2418
- handleError(errors);
2419
- }
2420
- try {
2421
- const config = yield getConfig(options.cwd);
2422
- return {
2423
- errors,
2424
- config
2425
- };
2426
- } catch (error) {
2427
- logger.break();
2428
- logger.error(
2429
- `An invalid ${highlighter.info("api.json")} file was found at ${highlighter.info(
2430
- options.cwd
2431
- )}.
2432
- Before you can add SDKs, you must create a valid ${highlighter.info(
2433
- "api.json"
2434
- )} file by running the ${highlighter.info("init")} command.`
2435
- );
2436
- logger.break();
2437
- process.exit(1);
2438
- }
2439
- });
2440
- }
2441
-
2442
- // src/codegen/openapi/generator.ts
2443
- var import_dtsGenerator = __toESM(require("@anttiviljami/dtsgenerator/dist/core/dtsGenerator"));
2444
- var import_json_schema_ref_parser = __toESM(require("@apidevtools/json-schema-ref-parser"));
2445
- var import_type = require("@anttiviljami/dtsgenerator/dist/core/type");
2446
- var lodash = __toESM(require("lodash"));
2447
- var prettier = __toESM(require("prettier"));
2448
- var fs3 = __toESM(require("fs-extra"));
2449
- var path3 = __toESM(require("node:path"));
2450
- var import_core = require("@hyper-fetch/core");
2451
-
2452
- // src/codegen/openapi/http-methods.enum.ts
2453
- var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
2454
- HttpMethod2["GET"] = "get";
2455
- HttpMethod2["PUT"] = "put";
2456
- HttpMethod2["POST"] = "post";
2457
- HttpMethod2["PATCH"] = "patch";
2458
- HttpMethod2["DELETE"] = "delete";
2459
- HttpMethod2["OPTIONS"] = "options";
2460
- HttpMethod2["HEAD"] = "head";
2461
- HttpMethod2["TRACE"] = "trace";
2462
- return HttpMethod2;
2463
- })(HttpMethod || {});
2464
-
2465
- // src/codegen/openapi/operations.ts
2466
- function getAvailableOperations(openApiJson) {
2467
- const paths = openApiJson.paths || {};
2468
- return Object.entries(paths).flatMap(([path6, pathObject]) => {
2469
- return Object.values(HttpMethod).map((method) => ({ path: path6, method, operation: pathObject == null ? void 0 : pathObject[method] })).filter(({ operation }) => operation == null ? void 0 : operation.operationId).map(({ operation, method }) => {
2470
- const op = __spreadProps(__spreadValues({}, operation), {
2471
- operationId: operation.operationId,
2472
- path: path6,
2473
- method
2474
- });
2475
- return op;
2476
- });
2477
- });
2478
- }
2479
-
2480
- // src/codegen/openapi/utils.ts
2481
- function adjustPathParamsFormat(path6) {
2482
- return path6.replace(/}/g, "").replace(/{/g, ":");
2483
- }
2484
- function createTypeBaseName(str) {
2485
- const capitalizeFirstLetter = (s) => {
2486
- return s.charAt(0).toUpperCase() + s.slice(1);
2487
- };
2488
- return str.split("_").map(capitalizeFirstLetter).join("");
2489
- }
2490
- function normalizeOperationId(key) {
2491
- return key.replace(/\/(.)/g, (_match, p1) => {
2492
- return p1.toUpperCase();
2493
- }).replace(/}/g, "").replace(/{/g, "$").replace(/^\//, "").replace(/[^0-9A-Za-z_$]+/g, "_");
2494
- }
2495
- var isUrl = (schemaPath) => {
2496
- try {
2497
- return Boolean(new URL(schemaPath));
2498
- } catch (e) {
2499
- return false;
2500
- }
2501
- };
2502
-
2503
- // src/codegen/openapi/generator.ts
2504
- var formatSchema = (obj, indent = 1) => {
2505
- const indentation = " ".repeat(indent);
2506
- const entries = Object.entries(obj).map(([key, value]) => {
2507
- const formattedKey = key.includes("-") ? `"${key}"` : key;
2508
- if (typeof value === "string") {
2509
- return `${indentation}${formattedKey}: ${value};`;
2510
- }
2511
- if (typeof value === "object" && value !== null) {
2512
- return `${indentation}${formattedKey}: {
2513
- ${formatSchema(value, indent + 1)}
2514
- ${indentation}};`;
2515
- }
2516
- return "";
2517
- }).join("\n");
2518
- return entries;
2519
- };
2520
- var _OpenapiRequestGenerator = class _OpenapiRequestGenerator {
2521
- constructor(openapiDocument) {
2522
- __publicField(this, "openapiDocument");
2523
- __publicField(this, "generateRequestsFromSchema", () => __async(this, null, function* () {
2524
- const { schemaTypes, exportedTypes } = yield _OpenapiRequestGenerator.prepareSchema(this.openapiDocument);
2525
- const generatedTypes = [];
2526
- const schemaTree = {};
2527
- getAvailableOperations(this.openapiDocument).forEach((operation) => {
2528
- const meta = _OpenapiRequestGenerator.generateMethodMetadata(operation, exportedTypes);
2529
- const operationTypes = _OpenapiRequestGenerator.generateTypes(meta);
2530
- const requestInstanceType = _OpenapiRequestGenerator.generateRequestInstanceType(meta, operationTypes);
2531
- generatedTypes.push(Object.values(operationTypes).join("\n"));
2532
- const { path: relPath, method } = meta;
2533
- const segments = relPath.split("/").filter(Boolean);
2534
- let currentLevel = schemaTree;
2535
- for (const segment of segments) {
2536
- let key;
2537
- if (segment.startsWith(":")) {
2538
- key = `$${segment.slice(1)}`;
2539
- } else if (segment.includes("-")) {
2540
- key = segment.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
2541
- } else {
2542
- key = segment;
2543
- }
2544
- if (!currentLevel[key]) {
2545
- currentLevel[key] = {};
2546
- }
2547
- currentLevel = currentLevel[key];
2548
- }
2549
- currentLevel[`$${method.toLowerCase()}`] = requestInstanceType;
2550
- });
2551
- const sdkSchema = `export type SdkSchema<Client extends ClientInstance> = {
2552
- ${formatSchema(schemaTree)}
2553
- }`;
2554
- const createSdkFn = `
2555
-
2556
- export type { Components };
2557
-
2558
- export const createSdk = <Client extends ClientInstance>(client: Client, options?: Parameters<typeof coreCreateSdk>[1] | undefined) => {
2559
- return coreCreateSdk<Client, SdkSchema<Client>>(client, options);
2560
- };
2561
- `;
2562
- return { schemaTypes, generatedTypes, sdkSchema, createSdkFn };
2563
- }));
2564
- this.openapiDocument = openapiDocument;
2565
- }
2566
- generateFile(_0) {
2567
- return __async(this, arguments, function* ({ config, fileName }) {
2568
- const defaultFileName = "openapi.client";
2569
- const { schemaTypes, generatedTypes, sdkSchema, createSdkFn } = yield this.generateRequestsFromSchema();
2570
- const contents = [
2571
- `import { createSdk as coreCreateSdk, ClientInstance, Request } from "@hyper-fetch/core";`,
2572
- "\n\n",
2573
- schemaTypes,
2574
- "\n\n",
2575
- generatedTypes.join("\n\n"),
2576
- "\n\n",
2577
- sdkSchema,
2578
- "\n\n",
2579
- createSdkFn
2580
- ].join("");
2581
- const prettierOpts = {
2582
- printWidth: 120,
2583
- tabWidth: 2,
2584
- useTabs: false,
2585
- semi: true,
2586
- singleQuote: false,
2587
- trailingComma: "all",
2588
- bracketSpacing: true,
2589
- bracketSameLine: false,
2590
- proseWrap: "always",
2591
- arrowParens: "always",
2592
- parser: "typescript"
2593
- };
2594
- const fName = fileName || defaultFileName;
2595
- const extension = config.tsx ? ".ts" : ".js";
2596
- const hasExtension = [".ts", ".js", ".tsx", ".jsx"].some((ext) => fName.endsWith(ext));
2597
- const generatedPath = path3.join(config.resolvedPaths.api, `${fName}${hasExtension ? "" : extension}`);
2598
- const file = yield prettier.format(contents, prettierOpts);
2599
- yield fs3.writeFile(generatedPath, file, {
2600
- flag: "w"
2601
- });
2602
- return generatedPath;
2603
- });
2604
- }
2605
- static generateRequestInstanceType({ id, path: endpoint, queryParamsRequired }, types) {
2606
- const Response = types[`${createTypeBaseName(id)}ResponseType`] ? `${createTypeBaseName(id)}ResponseType` : void 0;
2607
- const Payload = types[`${createTypeBaseName(id)}RequestBody`] ? `${createTypeBaseName(id)}RequestBody` : void 0;
2608
- const LocalError = types[`${createTypeBaseName(id)}ErrorType`] ? `${createTypeBaseName(id)}ErrorType` : void 0;
2609
- const QueryParams = types[`${createTypeBaseName(id)}QueryParams`] ? `${createTypeBaseName(id)}QueryParams` : void 0;
2610
- const QueryParamsGeneric = QueryParams && !queryParamsRequired ? `${QueryParams} | undefined` : QueryParams;
2611
- return `Request<${Response}, ${Payload}, ${QueryParamsGeneric}, ${LocalError}, "${endpoint}", Client>`;
2612
- }
2613
- static generateHyperFetchRequest({
2614
- id,
2615
- path: relPath,
2616
- method,
2617
- queryParamsRequired
2618
- }, types) {
2619
- const Response = types[`${createTypeBaseName(id)}ResponseType`] ? `${createTypeBaseName(id)}ResponseType` : void 0;
2620
- const Payload = types[`${createTypeBaseName(id)}RequestBody`] ? `${createTypeBaseName(id)}RequestBody` : void 0;
2621
- const LocalError = types[`${createTypeBaseName(id)}ErrorType`] ? `${createTypeBaseName(id)}ErrorType` : void 0;
2622
- const QueryParams = types[`${createTypeBaseName(id)}QueryParams`] ? `${createTypeBaseName(id)}QueryParams` : void 0;
2623
- const getVariableName = (str) => str.charAt(0).toLowerCase() + str.slice(1);
2624
- let genericType = "";
2625
- const addToGenericType = (key, value) => {
2626
- if (genericType) {
2627
- genericType += ",";
2628
- }
2629
- genericType += `${key}:${value}`;
2630
- };
2631
- if (Response) {
2632
- addToGenericType("response", Response);
2633
- }
2634
- if (Payload) {
2635
- addToGenericType("payload", Payload);
2636
- }
2637
- if (LocalError) {
2638
- addToGenericType("error", LocalError);
2639
- }
2640
- if (QueryParams) {
2641
- const key = !queryParamsRequired ? "queryParams?" : "queryParams";
2642
- addToGenericType(key, QueryParams);
2643
- }
2644
- if (genericType) {
2645
- genericType = `<{${genericType}}>`;
2646
- }
2647
- return `export const ${getVariableName(
2648
- createTypeBaseName(id)
2649
- )} = client.createRequest${genericType}()({method: "${method}", endpoint: "${relPath}"})`;
2650
- }
2651
- static generateTypes({
2652
- id,
2653
- pathParametersType,
2654
- queryParametersType,
2655
- requestBodyType,
2656
- errorType,
2657
- responseType
2658
- }) {
2659
- const typeName = createTypeBaseName(id);
2660
- const types = {};
2661
- if (pathParametersType) {
2662
- types[`${typeName}PathParams`] = `export type ${typeName}PathParams = ${pathParametersType}`;
2663
- }
2664
- if (queryParametersType) {
2665
- types[`${typeName}QueryParams`] = `export type ${typeName}QueryParams = ${queryParametersType}`;
2666
- }
2667
- if (requestBodyType) {
2668
- types[`${typeName}RequestBody`] = `export type ${typeName}RequestBody = ${requestBodyType}`;
2669
- }
2670
- if (errorType) {
2671
- types[`${typeName}ErrorType`] = `export type ${typeName}ErrorType = ${errorType}`;
2672
- }
2673
- if (responseType) {
2674
- types[`${typeName}ResponseType`] = `export type ${typeName}ResponseType = ${responseType}`;
2675
- }
2676
- return types;
2677
- }
2678
- static generateMethodMetadata(operation, exportTypes) {
2679
- var _a, _b, _c;
2680
- const { operationId, method, path: relPath } = operation;
2681
- const normalizedOperationId = normalizeOperationId(operationId);
2682
- const pathParametersType = (_a = lodash.find(exportTypes, {
2683
- schemaRef: `#/paths/${normalizedOperationId}/pathParameters`
2684
- })) == null ? void 0 : _a.path;
2685
- const queryParametersType = (_b = lodash.find(exportTypes, {
2686
- schemaRef: `#/paths/${normalizedOperationId}/queryParameters`
2687
- })) == null ? void 0 : _b.path;
2688
- const requestBodyType = (_c = lodash.find(exportTypes, {
2689
- schemaRef: `#/paths/${normalizedOperationId}/requestBody`
2690
- })) == null ? void 0 : _c.path;
2691
- const responseTypePaths = lodash.chain(exportTypes).filter(({ schemaRef }) => schemaRef.startsWith(`#/paths/${normalizedOperationId}/responses/2`)).map(({ path: responsePath }) => responsePath).value();
2692
- const errorTypePaths = lodash.chain(exportTypes).filter(
2693
- ({ schemaRef }) => schemaRef.startsWith(`#/paths/${normalizedOperationId}/responses/4`) || schemaRef.startsWith(`#/paths/${normalizedOperationId}/responses/5`)
2694
- ).map(({ path: errorPath }) => errorPath).value();
2695
- const responseType = !lodash.isEmpty(responseTypePaths) ? responseTypePaths.join(" | ") : "any";
2696
- const errorType = !lodash.isEmpty(errorTypePaths) ? errorTypePaths.join(" | ") : "undefined";
2697
- const queryParamsRequired = Array.isArray(operation.parameters) ? operation.parameters.some((p) => {
2698
- return "in" in p && p.in === "query" && p.required === true;
2699
- }) : false;
2700
- return {
2701
- id: normalizedOperationId,
2702
- pathParametersType,
2703
- queryParametersType,
2704
- requestBodyType,
2705
- errorType,
2706
- responseType,
2707
- path: adjustPathParamsFormat(relPath),
2708
- method: method ? method.toUpperCase() : "get" /* GET */,
2709
- queryParamsRequired
2710
- };
2711
- }
2712
- static validateSchema(openapiDocument) {
2713
- const errors = [];
2714
- function validateRefs(obj, refPath = "") {
2715
- if (!obj || typeof obj !== "object") return;
2716
- if (obj.$ref && typeof obj.$ref === "string" && obj.$ref.endsWith("/")) {
2717
- errors.push({
2718
- path: refPath,
2719
- ref: obj.$ref,
2720
- message: `Invalid reference "${obj.$ref}" - reference path cannot end with '/'`
2721
- });
2722
- }
2723
- Object.entries(obj).forEach(([key, value]) => {
2724
- const newPath = refPath ? `${refPath}.${key}` : key;
2725
- validateRefs(value, newPath);
2726
- });
2727
- }
2728
- validateRefs(openapiDocument);
2729
- if (errors.length > 0) {
2730
- const errorMessages = errors.map((err) => `Invalid reference at ${err.path}: ${err.message}`);
2731
- throw new Error(`Schema validation failed. The following errors were found:
2732
- ${errorMessages.join("\n")}`);
2733
- }
2734
- }
2735
- static prepareSchema(openapiDocument) {
2736
- return __async(this, null, function* () {
2737
- _OpenapiRequestGenerator.validateSchema(openapiDocument);
2738
- const rootSchema = yield import_json_schema_ref_parser.default.bundle(openapiDocument);
2739
- const schema = (0, import_type.parseSchema)(rootSchema);
2740
- const generator = new import_dtsGenerator.default([schema]);
2741
- const schemaTypes = yield generator.generate();
2742
- const exportedTypes = generator.getExports();
2743
- return { schemaTypes, exportedTypes };
2744
- });
2745
- }
2746
- };
2747
- __publicField(_OpenapiRequestGenerator, "getSchemaFromUrl", (_0) => __async(null, [_0], function* ({ url, config }) {
2748
- if (isUrl(url)) {
2749
- const client = (0, import_core.createClient)({ url });
2750
- const getSchema = client.createRequest()({ endpoint: "" });
2751
- const { data, error } = yield getSchema.send();
2752
- if (data) {
2753
- return data;
2754
- }
2755
- if ((error == null ? void 0 : error.code) === "ECONNREFUSED") {
2756
- throw new Error(`Cannot reach the server: ${url}`);
2757
- }
2758
- throw error || new Error("Failed to fetch schema");
2759
- }
2760
- const schema = fs3.readFileSync(path3.join(config.resolvedPaths.cwd, url), "utf-8");
2761
- return JSON.parse(schema);
2762
- }));
2763
- var OpenapiRequestGenerator = _OpenapiRequestGenerator;
2764
-
2765
- // src/utils/spinner.ts
2766
- var import_ora = __toESM(require("ora"));
2767
- function spinner(text, options) {
2768
- return (0, import_ora.default)({
2769
- text,
2770
- isSilent: options == null ? void 0 : options.silent
2771
- });
2772
- }
2773
-
2774
- // src/utils/show-help.ts
2775
- var import_cli_table3 = __toESM(require("cli-table3"));
2776
-
2777
- // src/utils/zod-to-table.ts
2778
- var import_zod3 = require("zod");
2779
- var zodToTable = (schema) => {
2780
- if (schema instanceof import_zod3.z.ZodObject) {
2781
- const { shape } = schema;
2782
- return Object.keys(shape).map((key) => {
2783
- const fieldSchema = shape[key];
2784
- return {
2785
- name: key,
2786
- description: fieldSchema.description
2787
- };
2788
- });
2789
- }
2790
- return [];
2791
- };
2792
-
2793
- // src/utils/show-help.ts
2794
- var showHelp = (schema) => {
2795
- const rows = zodToTable(schema).map(({ name, description }) => [`--${name}`, description || ""]);
2796
- const maxOptionLength = rows.reduce((max, row) => Math.max(max, row[0].length), 0);
2797
- const terminalWidth = process.stdout.columns;
2798
- const tableOptions = {
2799
- head: ["Option", "Description"],
2800
- style: {
2801
- head: ["blue"]
2802
- },
2803
- wordWrap: true
2804
- };
2805
- if (terminalWidth) {
2806
- const tableOverhead = 7;
2807
- const optionColWidth = maxOptionLength + 2;
2808
- const descriptionColWidth = terminalWidth - optionColWidth - tableOverhead;
2809
- if (descriptionColWidth > 10) {
2810
- tableOptions.colWidths = [optionColWidth, descriptionColWidth];
2811
- }
2812
- }
2813
- const table = new import_cli_table3.default(tableOptions);
2814
- table.push(...rows);
2815
- console.log(table.toString());
2816
- };
2817
-
2818
- // src/commands/generate.ts
2819
- var generateOptionsSchema = import_zod4.z.object({
2820
- template: import_zod4.z.enum(["openapi", "swagger"]).describe("API provider template to use"),
2821
- url: import_zod4.z.string().describe("The URL to generate the schema from"),
2822
- fileName: import_zod4.z.string().describe("The output file for the SDK."),
2823
- cwd: import_zod4.z.string().describe("The working directory. defaults to the current directory."),
2824
- overwrite: import_zod4.z.boolean().optional().describe("Overwrite existing files.")
2825
- });
2826
- var generate = new import_commander.Command().name("Generate").description("Generate SDK from a schema, url or service").option("-t, --template <template>", "API provider template to use").option("-u, --url <url>", "The URL to generate the schema from").option("-f, --fileName <fileName>", "The output file for the SDK.").option("-o, --overwrite", "overwrite existing files.").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("-h, --help <help>", "display help for command").action((opts) => __async(null, null, function* () {
2827
- try {
2828
- const help = process.argv.includes("--help") || process.argv.includes("-h");
2829
- if (help) {
2830
- return showHelp(generateOptionsSchema);
2831
- }
2832
- const { config } = yield preFlightGenerate(opts);
2833
- if (!opts.template) {
2834
- opts.template = yield (0, import_prompts.select)({
2835
- message: "What source we want to use?",
2836
- choices: [
2837
- { name: "OpenAPI (v3)", value: "openapi" },
2838
- { name: "Swagger", value: "swagger" }
2839
- ]
2840
- });
2841
- }
2842
- if (!opts.url) {
2843
- opts.url = yield (0, import_prompts.input)({
2844
- message: "Enter the URL to generate the schema from:",
2845
- validate: (value) => {
2846
- const result = import_zod4.z.url("Please enter a valid URL.").safeParse(value);
2847
- if (result.success) return true;
2848
- return result.error.message;
2849
- }
2850
- });
2851
- }
2852
- if (!opts.fileName) {
2853
- opts.fileName = yield (0, import_prompts.input)({
2854
- message: "Enter the file name for the SDK:",
2855
- default: `api-${opts.template}.sdk.ts`
2856
- });
2857
- }
2858
- const fileExists = fs4.existsSync(path4.join(opts.cwd, opts.fileName));
2859
- if (opts.overwrite === void 0 && fileExists) {
2860
- opts.overwrite = yield (0, import_prompts.confirm)({ message: "Overwrite existing files?" });
2861
- }
2862
- if (opts.overwrite === false && fileExists) {
2863
- return logger.info(`File ${opts.fileName} already exists. Use --overwrite to overwrite.`);
2864
- }
2865
- const options = generateOptionsSchema.parse(opts);
2866
- const componentSpinner = spinner(`Writing ${options.fileName}...`).start();
2867
- switch (options.template) {
2868
- case "openapi": {
2869
- const openapiSchema = yield OpenapiRequestGenerator.getSchemaFromUrl({ url: options.url, config });
2870
- const generator = new OpenapiRequestGenerator(openapiSchema);
2871
- yield generator.generateFile({ fileName: options.fileName, config });
2872
- componentSpinner.succeed();
2873
- return process.exit(0);
2874
- }
2875
- case "swagger": {
2876
- const openapiSchema = yield OpenapiRequestGenerator.getSchemaFromUrl({ url: options.url, config });
2877
- const generator = new OpenapiRequestGenerator(openapiSchema);
2878
- yield generator.generateFile({ fileName: options.fileName, config });
2879
- componentSpinner.succeed();
2880
- return process.exit(0);
2881
- }
2882
- default: {
2883
- componentSpinner.fail();
2884
- throw new Error(`Invalid template: ${options.template}`);
2885
- }
2886
- }
2887
- } catch (err) {
2888
- handleError(err);
2889
- }
2890
- }));
2891
-
2892
- // src/commands/init.ts
2893
- var import_commander2 = require("commander");
2894
- var import_prompts2 = require("@inquirer/prompts");
2895
- var import_zod5 = require("zod");
2896
- var path5 = __toESM(require("node:path"));
2897
- var fs5 = __toESM(require("fs-extra"));
2898
-
2899
- // src/config/get-ts-alias.ts
2900
- var import_tsconfig_paths3 = __toESM(require_lib2());
2901
- function getTsConfigAliasPrefix(cwd) {
2902
- return __async(this, null, function* () {
2903
- var _a, _b, _c;
2904
- const tsConfig = yield (0, import_tsconfig_paths3.loadConfig)(cwd);
2905
- if ((tsConfig == null ? void 0 : tsConfig.resultType) === "failed" || !Object.entries(tsConfig == null ? void 0 : tsConfig.paths).length) {
2906
- return null;
2907
- }
2908
- for (const [alias, paths] of Object.entries(tsConfig.paths)) {
2909
- if (paths.includes("./*") || paths.includes("./src/*") || paths.includes("./app/*") || paths.includes("./resources/js/*")) {
2910
- return (_a = alias.replace(/\/\*$/, "")) != null ? _a : null;
2911
- }
2912
- }
2913
- return (_c = (_b = Object.keys(tsConfig == null ? void 0 : tsConfig.paths)) == null ? void 0 : _b[0].replace(/\/\*$/, "")) != null ? _c : null;
2914
- });
2915
- }
2916
-
2917
- // src/commands/init.ts
2918
- var initOptionsSchema = import_zod5.z.object({
2919
- yes: import_zod5.z.boolean().optional().describe("skip confirmation prompt."),
2920
- cwd: import_zod5.z.string().describe("the working directory. defaults to the current directory.")
2921
- });
2922
- var init2 = new import_commander2.Command().name("Init").description("Initialize HyperFetch Client configuration.").option("-y, --yes", "skip confirmation prompt.", false).option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("-h, --help <help>", "display help for command").action((opts) => __async(null, null, function* () {
2923
- try {
2924
- const help = process.argv.includes("--help") || process.argv.includes("-h");
2925
- if (help) {
2926
- return showHelp(initOptionsSchema);
2927
- }
2928
- const { cwd, yes } = initOptionsSchema.parse(opts);
2929
- let config = {};
2930
- let mainPath;
2931
- let apiDir;
2932
- if (yes) {
2933
- mainPath = "src";
2934
- apiDir = "api";
2935
- } else {
2936
- mainPath = yield (0, import_prompts2.select)({
2937
- message: "Select the main directory for your project:",
2938
- choices: [
2939
- { name: "src", value: "src" },
2940
- { name: "app", value: "app" },
2941
- { name: "other", value: "other" }
2942
- ]
2943
- });
2944
- if (mainPath === "other") {
2945
- mainPath = yield (0, import_prompts2.input)({
2946
- message: "Enter the path to the main directory:",
2947
- validate: (value) => {
2948
- if (!value) return "Path cannot be empty.";
2949
- return true;
2950
- }
2951
- });
2952
- }
2953
- apiDir = yield (0, import_prompts2.input)({
2954
- message: "Enter the name of the API directory:",
2955
- default: "api",
2956
- validate: (value) => {
2957
- if (!value) return "Directory name cannot be empty.";
2958
- return true;
2959
- }
2960
- });
2961
- }
2962
- const fullPath = path5.join(cwd, mainPath, apiDir);
2963
- const relativePath = path5.join(mainPath, apiDir);
2964
- const configPath = path5.join(cwd, "api.json");
2965
- const aliasPrefix = (yield getTsConfigAliasPrefix(cwd)) || "";
2966
- const alias = aliasPrefix ? `${aliasPrefix}/` : "";
2967
- const defaultAliases = {
2968
- api: `${alias}${apiDir}`,
2969
- hooks: `${alias}hooks`,
2970
- ui: `${alias}components/ui`,
2971
- components: `${alias}components`,
2972
- lib: `${alias}lib`
2973
- };
2974
- const defaultConfig = {
2975
- tsx: true,
2976
- aliases: defaultAliases
2977
- };
2978
- logger.break();
2979
- const steps = [
2980
- {
2981
- name: `Initialize API directory at ${relativePath}`,
2982
- action: () => __async(null, null, function* () {
2983
- if (!fs5.existsSync(fullPath)) {
2984
- yield fs5.mkdir(fullPath, { recursive: true });
2985
- }
2986
- })
2987
- },
2988
- {
2989
- name: "Setup configuration",
2990
- action: (currentConfig) => __async(null, null, function* () {
2991
- if (fs5.existsSync(configPath)) {
2992
- const existingConfig = JSON.parse(fs5.readFileSync(configPath, "utf8"));
2993
- const { success, error, data } = configSchema.omit({ resolvedPaths: true }).safeParse(__spreadProps(__spreadValues(__spreadValues({}, defaultConfig), existingConfig), {
2994
- aliases: __spreadValues(__spreadValues({}, defaultConfig.aliases), existingConfig.aliases)
2995
- }));
2996
- if (error) {
2997
- logger.break();
2998
- logger.error(`Invalid configuration found in ${configPath}.`);
2999
- handleError(error);
3000
- logger.break();
3001
- }
3002
- if (success) {
3003
- return data;
3004
- }
3005
- }
3006
- return currentConfig;
3007
- })
3008
- },
3009
- {
3010
- name: "Setup Aliases",
3011
- action: (currentConfig) => __async(null, null, function* () {
3012
- if (currentConfig.aliases) {
3013
- return currentConfig;
3014
- }
3015
- return __spreadProps(__spreadValues({}, currentConfig), {
3016
- aliases: defaultAliases
3017
- });
3018
- })
3019
- },
3020
- {
3021
- name: `Create api.json configuration file`,
3022
- action: (currentConfig) => __async(null, null, function* () {
3023
- const finalConfig = __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), currentConfig), {
3024
- aliases: __spreadValues(__spreadValues({}, defaultConfig.aliases), currentConfig.aliases)
3025
- });
3026
- configSchema.omit({ resolvedPaths: true }).parse(finalConfig);
3027
- yield fs5.writeFile(configPath, JSON.stringify(finalConfig, null, 2));
3028
- })
3029
- }
3030
- ];
3031
- logger.break();
3032
- logger.info("Starting HyperFetch CLI initialization...");
3033
- for (const step of steps) {
3034
- const s = spinner(step.name).start();
3035
- const result = yield step.action(config);
3036
- if (result) {
3037
- config = result;
3038
- }
3039
- s.succeed();
3040
- }
3041
- logger.break();
3042
- logger.info("Configuration has been generated successfully! \u{1F389}");
3043
- logger.info(`You can now find your configuration at ${configPath}`);
3044
- } catch (err) {
3045
- handleError(err);
3046
- }
3047
- }));
3048
-
3049
- // src/cli/index.ts
3050
- var program = new import_commander3.Command();
3051
- program.name("hyper-fetch").description("CLI for Hyper Fetch").version(package_default.version);
3052
- var commands = {
3053
- init: init2,
3054
- // add,
3055
- generate
3056
- };
3057
- Object.values(commands).forEach((command) => {
3058
- program.addCommand(command);
3059
- });
3060
- var main = () => __async(null, null, function* () {
3061
- try {
3062
- let chosenCommand;
3063
- if (process.argv[2] && Object.keys(commands).includes(process.argv[2])) {
3064
- const command = commands[process.argv[2]];
3065
- chosenCommand = command.name();
3066
- }
3067
- if (!chosenCommand) {
3068
- chosenCommand = yield (0, import_prompts3.select)({
3069
- message: "What do you want to do?",
3070
- choices: program.commands.map((cmd) => ({
3071
- name: cmd.name(),
3072
- value: cmd.name(),
3073
- description: cmd.description()
3074
- }))
3075
- });
3076
- yield program.parseAsync([process.argv[0], process.argv[1], chosenCommand]);
3077
- } else {
3078
- yield program.parseAsync([process.argv[0], process.argv[1], chosenCommand, ...process.argv.slice(3)]);
3079
- }
3080
- } catch (e) {
3081
- handleError(e);
3082
- if (e instanceof Error) {
3083
- if (e.message.includes("User force closed the prompt")) {
3084
- process.exit(0);
3085
- }
3086
- }
3087
- process.exit(1);
3088
- }
3089
- });
3090
- main();
3091
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_generator = require("./generator-f5QJtrBW.js");
3
+ exports.OpenapiRequestGenerator = require_generator.OpenapiRequestGenerator;