orval 6.23.0 → 6.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/orval.js +145 -122
- package/dist/bin/orval.js.map +1 -0
- package/dist/index.js +146 -131
- package/dist/index.js.map +1 -0
- package/package.json +11 -12
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
|
|
33
33
|
// ../../node_modules/lodash.omit/index.js
|
|
34
34
|
var require_lodash = __commonJS({
|
|
35
|
-
"../../node_modules/lodash.omit/index.js"(
|
|
35
|
+
"../../node_modules/lodash.omit/index.js"(exports2, module2) {
|
|
36
36
|
"use strict";
|
|
37
37
|
var LARGE_ARRAY_SIZE = 200;
|
|
38
38
|
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
@@ -374,14 +374,14 @@ var require_lodash = __commonJS({
|
|
|
374
374
|
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
375
375
|
}
|
|
376
376
|
function baseIsNative(value) {
|
|
377
|
-
if (!
|
|
377
|
+
if (!isObject7(value) || isMasked(value)) {
|
|
378
378
|
return false;
|
|
379
379
|
}
|
|
380
380
|
var pattern = isFunction5(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
|
|
381
381
|
return pattern.test(toSource(value));
|
|
382
382
|
}
|
|
383
383
|
function baseKeysIn(object) {
|
|
384
|
-
if (!
|
|
384
|
+
if (!isObject7(object)) {
|
|
385
385
|
return nativeKeysIn(object);
|
|
386
386
|
}
|
|
387
387
|
var isProto = isPrototype(object), result = [];
|
|
@@ -505,13 +505,13 @@ var require_lodash = __commonJS({
|
|
|
505
505
|
return isObjectLike(value) && isArrayLike(value);
|
|
506
506
|
}
|
|
507
507
|
function isFunction5(value) {
|
|
508
|
-
var tag =
|
|
508
|
+
var tag = isObject7(value) ? objectToString.call(value) : "";
|
|
509
509
|
return tag == funcTag || tag == genTag;
|
|
510
510
|
}
|
|
511
511
|
function isLength(value) {
|
|
512
512
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
513
513
|
}
|
|
514
|
-
function
|
|
514
|
+
function isObject7(value) {
|
|
515
515
|
var type2 = typeof value;
|
|
516
516
|
return !!value && (type2 == "object" || type2 == "function");
|
|
517
517
|
}
|
|
@@ -548,11 +548,9 @@ __export(src_exports, {
|
|
|
548
548
|
});
|
|
549
549
|
module.exports = __toCommonJS(src_exports);
|
|
550
550
|
var import_core12 = require("@orval/core");
|
|
551
|
-
var import_chalk7 = __toESM(require("chalk"));
|
|
552
551
|
|
|
553
552
|
// src/generate.ts
|
|
554
553
|
var import_core11 = require("@orval/core");
|
|
555
|
-
var import_chalk6 = __toESM(require("chalk"));
|
|
556
554
|
|
|
557
555
|
// src/import-specs.ts
|
|
558
556
|
var import_swagger_parser = __toESM(require("@apidevtools/swagger-parser"));
|
|
@@ -3356,7 +3354,8 @@ var generateClientFooter = ({
|
|
|
3356
3354
|
if (!footer) {
|
|
3357
3355
|
return {
|
|
3358
3356
|
implementation: "",
|
|
3359
|
-
implementationMock: `
|
|
3357
|
+
implementationMock: `
|
|
3358
|
+
]
|
|
3360
3359
|
`
|
|
3361
3360
|
};
|
|
3362
3361
|
}
|
|
@@ -3585,10 +3584,7 @@ var importOpenApi = async ({
|
|
|
3585
3584
|
target,
|
|
3586
3585
|
workspace,
|
|
3587
3586
|
specs,
|
|
3588
|
-
|
|
3589
|
-
tslint: output.tslint,
|
|
3590
|
-
tsconfig: output.tsconfig,
|
|
3591
|
-
packageJson: output.packageJson
|
|
3587
|
+
output
|
|
3592
3588
|
}
|
|
3593
3589
|
});
|
|
3594
3590
|
return {
|
|
@@ -3632,50 +3628,50 @@ var getApiSchemas = ({
|
|
|
3632
3628
|
workspace,
|
|
3633
3629
|
specs
|
|
3634
3630
|
}) => {
|
|
3635
|
-
return Object.entries(specs).reduce(
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3631
|
+
return Object.entries(specs).reduce(
|
|
3632
|
+
(acc, [specKey, spec]) => {
|
|
3633
|
+
var _a, _b, _c, _d;
|
|
3634
|
+
const context = {
|
|
3635
|
+
specKey,
|
|
3636
|
+
target,
|
|
3637
|
+
workspace,
|
|
3638
|
+
specs,
|
|
3639
|
+
output
|
|
3640
|
+
};
|
|
3641
|
+
const schemaDefinition = (0, import_core3.generateSchemasDefinition)(
|
|
3642
|
+
!spec.openapi ? getAllSchemas(spec, specKey) : (_a = spec.components) == null ? void 0 : _a.schemas,
|
|
3643
|
+
context,
|
|
3644
|
+
output.override.components.schemas.suffix
|
|
3645
|
+
);
|
|
3646
|
+
const responseDefinition = (0, import_core3.generateComponentDefinition)(
|
|
3647
|
+
(_b = spec.components) == null ? void 0 : _b.responses,
|
|
3648
|
+
context,
|
|
3649
|
+
output.override.components.responses.suffix
|
|
3650
|
+
);
|
|
3651
|
+
const bodyDefinition = (0, import_core3.generateComponentDefinition)(
|
|
3652
|
+
(_c = spec.components) == null ? void 0 : _c.requestBodies,
|
|
3653
|
+
context,
|
|
3654
|
+
output.override.components.requestBodies.suffix
|
|
3655
|
+
);
|
|
3656
|
+
const parameters = (0, import_core3.generateParameterDefinition)(
|
|
3657
|
+
(_d = spec.components) == null ? void 0 : _d.parameters,
|
|
3658
|
+
context,
|
|
3659
|
+
output.override.components.parameters.suffix
|
|
3660
|
+
);
|
|
3661
|
+
const schemas = [
|
|
3662
|
+
...schemaDefinition,
|
|
3663
|
+
...responseDefinition,
|
|
3664
|
+
...bodyDefinition,
|
|
3665
|
+
...parameters
|
|
3666
|
+
];
|
|
3667
|
+
if (!schemas.length) {
|
|
3668
|
+
return acc;
|
|
3669
|
+
}
|
|
3670
|
+
acc[specKey] = schemas;
|
|
3674
3671
|
return acc;
|
|
3675
|
-
}
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
}, {});
|
|
3672
|
+
},
|
|
3673
|
+
{}
|
|
3674
|
+
);
|
|
3679
3675
|
};
|
|
3680
3676
|
var getAllSchemas = (spec, specKey) => {
|
|
3681
3677
|
var _a;
|
|
@@ -3744,7 +3740,7 @@ var resolveSpecs = async (path, { validate, ...options }, isUrl3, isOnlySchema)
|
|
|
3744
3740
|
return data;
|
|
3745
3741
|
}
|
|
3746
3742
|
return Object.fromEntries(
|
|
3747
|
-
Object.entries(data).map(([key, value]) => [import_core4.upath.resolve(key), value])
|
|
3743
|
+
Object.entries(data).sort().map(([key, value]) => [import_core4.upath.resolve(key), value])
|
|
3748
3744
|
);
|
|
3749
3745
|
} catch {
|
|
3750
3746
|
const file = await import_fs_extra.default.readFile(path, "utf8");
|
|
@@ -3793,7 +3789,7 @@ var import_chalk2 = __toESM(require("chalk"));
|
|
|
3793
3789
|
var package_default = {
|
|
3794
3790
|
name: "orval",
|
|
3795
3791
|
description: "A swagger client generator for typescript",
|
|
3796
|
-
version: "6.
|
|
3792
|
+
version: "6.24.0",
|
|
3797
3793
|
license: "MIT",
|
|
3798
3794
|
files: [
|
|
3799
3795
|
"dist"
|
|
@@ -3833,8 +3829,8 @@ var package_default = {
|
|
|
3833
3829
|
url: "https://github.com/anymaniax/orval"
|
|
3834
3830
|
},
|
|
3835
3831
|
scripts: {
|
|
3836
|
-
build: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --dts",
|
|
3837
|
-
dev: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --watch ./src --onSuccess 'yarn generate-api'",
|
|
3832
|
+
build: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --sourcemap --dts",
|
|
3833
|
+
dev: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --sourcemap --watch ./src --onSuccess 'yarn generate-api'",
|
|
3838
3834
|
lint: "eslint src/**/*.ts",
|
|
3839
3835
|
"generate-api": "node ./dist/bin/orval.js --config ../../samples/react-query/basic/orval.config.ts",
|
|
3840
3836
|
test: "tsc --noEmit && vitest --passWithNoTests"
|
|
@@ -3846,13 +3842,13 @@ var package_default = {
|
|
|
3846
3842
|
},
|
|
3847
3843
|
dependencies: {
|
|
3848
3844
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
3849
|
-
"@orval/angular": "6.
|
|
3850
|
-
"@orval/axios": "6.
|
|
3851
|
-
"@orval/core": "6.
|
|
3852
|
-
"@orval/mock": "6.
|
|
3853
|
-
"@orval/query": "6.
|
|
3854
|
-
"@orval/swr": "6.
|
|
3855
|
-
"@orval/zod": "6.
|
|
3845
|
+
"@orval/angular": "6.24.0",
|
|
3846
|
+
"@orval/axios": "6.24.0",
|
|
3847
|
+
"@orval/core": "6.24.0",
|
|
3848
|
+
"@orval/mock": "6.24.0",
|
|
3849
|
+
"@orval/query": "6.24.0",
|
|
3850
|
+
"@orval/swr": "6.24.0",
|
|
3851
|
+
"@orval/zod": "6.24.0",
|
|
3856
3852
|
ajv: "^8.12.0",
|
|
3857
3853
|
cac: "^6.7.14",
|
|
3858
3854
|
chalk: "^4.1.2",
|
|
@@ -3862,8 +3858,7 @@ var package_default = {
|
|
|
3862
3858
|
"find-up": "5.0.0",
|
|
3863
3859
|
"fs-extra": "^11.2.0",
|
|
3864
3860
|
"lodash.uniq": "^4.5.0",
|
|
3865
|
-
"
|
|
3866
|
-
"openapi3-ts": "^3.2.0",
|
|
3861
|
+
"openapi3-ts": "4.2.1",
|
|
3867
3862
|
"string-argv": "^0.3.2",
|
|
3868
3863
|
tsconfck: "^2.0.1"
|
|
3869
3864
|
}
|
|
@@ -4081,7 +4076,7 @@ function defineConfig(options) {
|
|
|
4081
4076
|
return options;
|
|
4082
4077
|
}
|
|
4083
4078
|
var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
|
|
4084
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa;
|
|
4079
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra;
|
|
4085
4080
|
const options = await ((0, import_core7.isFunction)(optionsExport) ? optionsExport() : optionsExport);
|
|
4086
4081
|
if (!options.input) {
|
|
4087
4082
|
(0, import_core7.createLogger)().error(import_chalk2.default.red(`Config require an input`));
|
|
@@ -4149,76 +4144,78 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
4149
4144
|
headers: (_n = outputOptions.headers) != null ? _n : false,
|
|
4150
4145
|
indexFiles: (_o = outputOptions.indexFiles) != null ? _o : true,
|
|
4151
4146
|
baseUrl: outputOptions.baseUrl,
|
|
4147
|
+
unionAddMissingProperties: (_p = outputOptions.unionAddMissingProperties) != null ? _p : false,
|
|
4152
4148
|
override: {
|
|
4153
4149
|
...outputOptions.override,
|
|
4154
4150
|
mock: {
|
|
4155
|
-
arrayMin: (
|
|
4156
|
-
arrayMax: (
|
|
4157
|
-
...(
|
|
4151
|
+
arrayMin: (_s = (_r = (_q = outputOptions.override) == null ? void 0 : _q.mock) == null ? void 0 : _r.arrayMin) != null ? _s : 1,
|
|
4152
|
+
arrayMax: (_v = (_u = (_t = outputOptions.override) == null ? void 0 : _t.mock) == null ? void 0 : _u.arrayMax) != null ? _v : 10,
|
|
4153
|
+
...(_x = (_w = outputOptions.override) == null ? void 0 : _w.mock) != null ? _x : {}
|
|
4158
4154
|
},
|
|
4159
4155
|
operations: normalizeOperationsAndTags(
|
|
4160
|
-
(
|
|
4156
|
+
(_z = (_y = outputOptions.override) == null ? void 0 : _y.operations) != null ? _z : {},
|
|
4161
4157
|
outputWorkspace
|
|
4162
4158
|
),
|
|
4163
4159
|
tags: normalizeOperationsAndTags(
|
|
4164
|
-
(
|
|
4160
|
+
(_B = (_A = outputOptions.override) == null ? void 0 : _A.tags) != null ? _B : {},
|
|
4165
4161
|
outputWorkspace
|
|
4166
4162
|
),
|
|
4167
4163
|
mutator: normalizeMutator(
|
|
4168
4164
|
outputWorkspace,
|
|
4169
|
-
(
|
|
4165
|
+
(_C = outputOptions.override) == null ? void 0 : _C.mutator
|
|
4170
4166
|
),
|
|
4171
|
-
formData: (
|
|
4167
|
+
formData: (_G = !(0, import_core7.isBoolean)((_D = outputOptions.override) == null ? void 0 : _D.formData) ? normalizeMutator(
|
|
4172
4168
|
outputWorkspace,
|
|
4173
|
-
(
|
|
4174
|
-
) : (
|
|
4175
|
-
formUrlEncoded: (
|
|
4169
|
+
(_E = outputOptions.override) == null ? void 0 : _E.formData
|
|
4170
|
+
) : (_F = outputOptions.override) == null ? void 0 : _F.formData) != null ? _G : true,
|
|
4171
|
+
formUrlEncoded: (_K = !(0, import_core7.isBoolean)((_H = outputOptions.override) == null ? void 0 : _H.formUrlEncoded) ? normalizeMutator(
|
|
4176
4172
|
outputWorkspace,
|
|
4177
|
-
(
|
|
4178
|
-
) : (
|
|
4173
|
+
(_I = outputOptions.override) == null ? void 0 : _I.formUrlEncoded
|
|
4174
|
+
) : (_J = outputOptions.override) == null ? void 0 : _J.formUrlEncoded) != null ? _K : true,
|
|
4179
4175
|
paramsSerializer: normalizeMutator(
|
|
4180
4176
|
outputWorkspace,
|
|
4181
|
-
(
|
|
4177
|
+
(_L = outputOptions.override) == null ? void 0 : _L.paramsSerializer
|
|
4182
4178
|
),
|
|
4183
|
-
header: ((
|
|
4184
|
-
requestOptions: (
|
|
4179
|
+
header: ((_M = outputOptions.override) == null ? void 0 : _M.header) === false ? false : (0, import_core7.isFunction)((_N = outputOptions.override) == null ? void 0 : _N.header) ? (_O = outputOptions.override) == null ? void 0 : _O.header : getDefaultFilesHeader,
|
|
4180
|
+
requestOptions: (_Q = (_P = outputOptions.override) == null ? void 0 : _P.requestOptions) != null ? _Q : true,
|
|
4185
4181
|
components: {
|
|
4186
4182
|
schemas: {
|
|
4187
4183
|
suffix: import_core7.RefComponentSuffix.schemas,
|
|
4188
|
-
itemSuffix: (
|
|
4189
|
-
...(
|
|
4184
|
+
itemSuffix: (_U = (_T = (_S = (_R = outputOptions.override) == null ? void 0 : _R.components) == null ? void 0 : _S.schemas) == null ? void 0 : _T.itemSuffix) != null ? _U : "Item",
|
|
4185
|
+
...(_X = (_W = (_V = outputOptions.override) == null ? void 0 : _V.components) == null ? void 0 : _W.schemas) != null ? _X : {}
|
|
4190
4186
|
},
|
|
4191
4187
|
responses: {
|
|
4192
4188
|
suffix: import_core7.RefComponentSuffix.responses,
|
|
4193
|
-
...(
|
|
4189
|
+
...(__ = (_Z = (_Y = outputOptions.override) == null ? void 0 : _Y.components) == null ? void 0 : _Z.responses) != null ? __ : {}
|
|
4194
4190
|
},
|
|
4195
4191
|
parameters: {
|
|
4196
4192
|
suffix: import_core7.RefComponentSuffix.parameters,
|
|
4197
|
-
...(
|
|
4193
|
+
...(_ba = (_aa = (_$ = outputOptions.override) == null ? void 0 : _$.components) == null ? void 0 : _aa.parameters) != null ? _ba : {}
|
|
4198
4194
|
},
|
|
4199
4195
|
requestBodies: {
|
|
4200
4196
|
suffix: import_core7.RefComponentSuffix.requestBodies,
|
|
4201
|
-
...(
|
|
4197
|
+
...(_ea = (_da = (_ca = outputOptions.override) == null ? void 0 : _ca.components) == null ? void 0 : _da.requestBodies) != null ? _ea : {}
|
|
4202
4198
|
}
|
|
4203
4199
|
},
|
|
4204
4200
|
query: {
|
|
4205
4201
|
useQuery: true,
|
|
4206
4202
|
useMutation: true,
|
|
4207
4203
|
signal: true,
|
|
4208
|
-
|
|
4204
|
+
shouldExportMutatorHooks: true,
|
|
4205
|
+
...normalizeQueryOptions((_fa = outputOptions.override) == null ? void 0 : _fa.query, workspace)
|
|
4209
4206
|
},
|
|
4210
4207
|
swr: {
|
|
4211
|
-
...(
|
|
4208
|
+
...(_ha = (_ga = outputOptions.override) == null ? void 0 : _ga.swr) != null ? _ha : {}
|
|
4212
4209
|
},
|
|
4213
4210
|
angular: {
|
|
4214
|
-
provideIn: (
|
|
4211
|
+
provideIn: (_ka = (_ja = (_ia = outputOptions.override) == null ? void 0 : _ia.angular) == null ? void 0 : _ja.provideIn) != null ? _ka : "root"
|
|
4215
4212
|
},
|
|
4216
|
-
useDates: ((
|
|
4217
|
-
useDeprecatedOperations: (
|
|
4218
|
-
useNativeEnums: (
|
|
4213
|
+
useDates: ((_la = outputOptions.override) == null ? void 0 : _la.useDates) || false,
|
|
4214
|
+
useDeprecatedOperations: (_na = (_ma = outputOptions.override) == null ? void 0 : _ma.useDeprecatedOperations) != null ? _na : true,
|
|
4215
|
+
useNativeEnums: (_pa = (_oa = outputOptions.override) == null ? void 0 : _oa.useNativeEnums) != null ? _pa : false
|
|
4219
4216
|
},
|
|
4220
|
-
allParamsOptional: (
|
|
4221
|
-
urlEncodeParameters: (
|
|
4217
|
+
allParamsOptional: (_qa = outputOptions.allParamsOptional) != null ? _qa : false,
|
|
4218
|
+
urlEncodeParameters: (_ra = outputOptions.urlEncodeParameters) != null ? _ra : false
|
|
4222
4219
|
},
|
|
4223
4220
|
hooks: options.hooks ? normalizeHooks(options.hooks) : {}
|
|
4224
4221
|
};
|
|
@@ -4341,6 +4338,11 @@ var normalizeHooks = (hooks) => {
|
|
|
4341
4338
|
...acc,
|
|
4342
4339
|
[key]: [hooks[key]]
|
|
4343
4340
|
};
|
|
4341
|
+
} else if ((0, import_core7.isObject)(hooks[key])) {
|
|
4342
|
+
return {
|
|
4343
|
+
...acc,
|
|
4344
|
+
[key]: [hooks[key]]
|
|
4345
|
+
};
|
|
4344
4346
|
}
|
|
4345
4347
|
return acc;
|
|
4346
4348
|
}, {});
|
|
@@ -4375,6 +4377,7 @@ var normalizeQueryOptions = (queryOptions = {}, outputWorkspace) => {
|
|
|
4375
4377
|
queryOptions == null ? void 0 : queryOptions.mutationOptions
|
|
4376
4378
|
)
|
|
4377
4379
|
} : {},
|
|
4380
|
+
...!(0, import_core7.isUndefined)(queryOptions.shouldExportMutatorHooks) ? { shouldExportMutatorHooks: queryOptions.shouldExportMutatorHooks } : {},
|
|
4378
4381
|
...!(0, import_core7.isUndefined)(queryOptions.signal) ? { signal: queryOptions.signal } : {},
|
|
4379
4382
|
...!(0, import_core7.isUndefined)(queryOptions.version) ? { version: queryOptions.version } : {}
|
|
4380
4383
|
};
|
|
@@ -4393,13 +4396,14 @@ var getDefaultFilesHeader = ({
|
|
|
4393
4396
|
|
|
4394
4397
|
// src/utils/watcher.ts
|
|
4395
4398
|
var import_core8 = require("@orval/core");
|
|
4396
|
-
var import_chalk3 = __toESM(require("chalk"));
|
|
4397
4399
|
var startWatcher = async (watchOptions, watchFn, defaultTarget = ".") => {
|
|
4398
4400
|
if (!watchOptions)
|
|
4399
4401
|
return;
|
|
4400
4402
|
const { watch } = await Promise.resolve().then(() => __toESM(require("chokidar")));
|
|
4401
4403
|
const ignored = ["**/{.git,node_modules}/**"];
|
|
4402
|
-
const watchPaths = typeof watchOptions === "boolean" ? defaultTarget : Array.isArray(watchOptions) ? watchOptions.filter(
|
|
4404
|
+
const watchPaths = typeof watchOptions === "boolean" ? defaultTarget : Array.isArray(watchOptions) ? watchOptions.filter(
|
|
4405
|
+
(path) => typeof path === "string"
|
|
4406
|
+
) : watchOptions;
|
|
4403
4407
|
(0, import_core8.log)(
|
|
4404
4408
|
`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => '"' + v + '"').join(" | ") : '"' + watchPaths + '"'}`
|
|
4405
4409
|
);
|
|
@@ -4412,38 +4416,53 @@ var startWatcher = async (watchOptions, watchFn, defaultTarget = ".") => {
|
|
|
4412
4416
|
try {
|
|
4413
4417
|
await watchFn();
|
|
4414
4418
|
} catch (e) {
|
|
4415
|
-
(0, import_core8.
|
|
4419
|
+
(0, import_core8.logError)(e);
|
|
4416
4420
|
}
|
|
4417
4421
|
});
|
|
4418
4422
|
};
|
|
4419
4423
|
|
|
4420
4424
|
// src/write-specs.ts
|
|
4421
4425
|
var import_core10 = require("@orval/core");
|
|
4422
|
-
var
|
|
4426
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
4423
4427
|
var import_execa2 = __toESM(require("execa"));
|
|
4424
4428
|
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
4425
4429
|
var import_lodash2 = __toESM(require("lodash.uniq"));
|
|
4426
4430
|
|
|
4427
4431
|
// src/utils/executeHook.ts
|
|
4428
4432
|
var import_core9 = require("@orval/core");
|
|
4429
|
-
var
|
|
4433
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
4430
4434
|
var import_execa = __toESM(require("execa"));
|
|
4431
4435
|
var import_string_argv = require("string-argv");
|
|
4432
4436
|
var executeHook = async (name, commands = [], args = []) => {
|
|
4433
|
-
(0, import_core9.log)(
|
|
4437
|
+
(0, import_core9.log)(import_chalk3.default.white(`Running ${name} hook...`));
|
|
4434
4438
|
for (const command of commands) {
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4439
|
+
try {
|
|
4440
|
+
if ((0, import_core9.isString)(command)) {
|
|
4441
|
+
await executeCommand(command, args);
|
|
4442
|
+
} else if ((0, import_core9.isFunction)(command)) {
|
|
4443
|
+
await command(args);
|
|
4444
|
+
} else if ((0, import_core9.isObject)(command)) {
|
|
4445
|
+
await executeObjectCommand(command, args);
|
|
4441
4446
|
}
|
|
4442
|
-
}
|
|
4443
|
-
|
|
4447
|
+
} catch (e) {
|
|
4448
|
+
(0, import_core9.logError)(e, `Failed to run ${name} hook`);
|
|
4444
4449
|
}
|
|
4445
4450
|
}
|
|
4446
4451
|
};
|
|
4452
|
+
async function executeCommand(command, args) {
|
|
4453
|
+
const [cmd, ..._args] = [...(0, import_string_argv.parseArgsStringToArgv)(command), ...args];
|
|
4454
|
+
await (0, import_execa.default)(cmd, _args);
|
|
4455
|
+
}
|
|
4456
|
+
async function executeObjectCommand(command, args) {
|
|
4457
|
+
if (command.injectGeneratedDirsAndFiles === false) {
|
|
4458
|
+
args = [];
|
|
4459
|
+
}
|
|
4460
|
+
if ((0, import_core9.isString)(command.command)) {
|
|
4461
|
+
await executeCommand(command.command, args);
|
|
4462
|
+
} else if ((0, import_core9.isFunction)(command.command)) {
|
|
4463
|
+
await command.command();
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4447
4466
|
|
|
4448
4467
|
// src/write-specs.ts
|
|
4449
4468
|
var getHeader = (option, info) => {
|
|
@@ -4457,12 +4476,15 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4457
4476
|
const { info = { title: "", version: 0 }, schemas, target } = builder;
|
|
4458
4477
|
const { output } = options;
|
|
4459
4478
|
const projectTitle = projectName || info.title;
|
|
4460
|
-
const specsName = Object.keys(schemas).reduce(
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4479
|
+
const specsName = Object.keys(schemas).reduce(
|
|
4480
|
+
(acc, specKey) => {
|
|
4481
|
+
const basePath = import_core10.upath.getSpecName(specKey, target);
|
|
4482
|
+
const name = basePath.slice(1).split("/").join("-");
|
|
4483
|
+
acc[specKey] = name;
|
|
4484
|
+
return acc;
|
|
4485
|
+
},
|
|
4486
|
+
{}
|
|
4487
|
+
);
|
|
4466
4488
|
const header = getHeader(output.override.header, info);
|
|
4467
4489
|
if (output.schemas) {
|
|
4468
4490
|
const rootSchemaPath = output.schemas;
|
|
@@ -4543,7 +4565,7 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4543
4565
|
await (0, import_execa2.default)("prettier", ["--write", ...paths]);
|
|
4544
4566
|
} catch (e) {
|
|
4545
4567
|
(0, import_core10.log)(
|
|
4546
|
-
|
|
4568
|
+
import_chalk4.default.yellow(
|
|
4547
4569
|
`\u26A0\uFE0F ${projectTitle ? `${projectTitle} - ` : ""}Prettier not found`
|
|
4548
4570
|
)
|
|
4549
4571
|
);
|
|
@@ -4593,11 +4615,11 @@ var generateSpecs = async (config, workspace, projectName) => {
|
|
|
4593
4615
|
try {
|
|
4594
4616
|
await generateSpec(workspace, options, projectName);
|
|
4595
4617
|
} catch (e) {
|
|
4596
|
-
(0, import_core11.
|
|
4618
|
+
(0, import_core11.logError)(e, projectName);
|
|
4597
4619
|
process.exit(1);
|
|
4598
4620
|
}
|
|
4599
4621
|
} else {
|
|
4600
|
-
(0, import_core11.
|
|
4622
|
+
(0, import_core11.logError)("Project not found");
|
|
4601
4623
|
process.exit(1);
|
|
4602
4624
|
}
|
|
4603
4625
|
return;
|
|
@@ -4610,7 +4632,7 @@ var generateSpecs = async (config, workspace, projectName) => {
|
|
|
4610
4632
|
acc.push(await generateSpec(workspace, options, projectName2));
|
|
4611
4633
|
} catch (e) {
|
|
4612
4634
|
hasErrors = true;
|
|
4613
|
-
(0, import_core11.
|
|
4635
|
+
(0, import_core11.logError)(e, projectName2);
|
|
4614
4636
|
}
|
|
4615
4637
|
return acc;
|
|
4616
4638
|
},
|
|
@@ -4672,11 +4694,7 @@ var generate = async (optionsExport, workspace = process.cwd(), options) => {
|
|
|
4672
4694
|
try {
|
|
4673
4695
|
await generateSpec(workspace, normalizedOptions);
|
|
4674
4696
|
} catch (e) {
|
|
4675
|
-
(0, import_core12.
|
|
4676
|
-
import_chalk7.default.red(
|
|
4677
|
-
`\u{1F6D1} ${(options == null ? void 0 : options.projectName) ? `${options == null ? void 0 : options.projectName} - ` : ""}${e}`
|
|
4678
|
-
)
|
|
4679
|
-
);
|
|
4697
|
+
(0, import_core12.logError)(e, options == null ? void 0 : options.projectName);
|
|
4680
4698
|
}
|
|
4681
4699
|
},
|
|
4682
4700
|
normalizedOptions.input.target
|
|
@@ -4685,11 +4703,7 @@ var generate = async (optionsExport, workspace = process.cwd(), options) => {
|
|
|
4685
4703
|
try {
|
|
4686
4704
|
return await generateSpec(workspace, normalizedOptions);
|
|
4687
4705
|
} catch (e) {
|
|
4688
|
-
(0, import_core12.
|
|
4689
|
-
import_chalk7.default.red(
|
|
4690
|
-
`\u{1F6D1} ${(options == null ? void 0 : options.projectName) ? `${options == null ? void 0 : options.projectName} - ` : ""}${e}`
|
|
4691
|
-
)
|
|
4692
|
-
);
|
|
4706
|
+
(0, import_core12.logError)(e, options == null ? void 0 : options.projectName);
|
|
4693
4707
|
}
|
|
4694
4708
|
}
|
|
4695
4709
|
};
|
|
@@ -4705,3 +4719,4 @@ var src_default = generate;
|
|
|
4705
4719
|
js-yaml/dist/js-yaml.mjs:
|
|
4706
4720
|
(*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
|
|
4707
4721
|
*/
|
|
4722
|
+
//# sourceMappingURL=index.js.map
|