orval 6.22.1 → 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 -121
- package/dist/bin/orval.js.map +1 -0
- package/dist/index.js +146 -130
- package/dist/index.js.map +1 -0
- package/package.json +11 -12
package/dist/bin/orval.js
CHANGED
|
@@ -370,14 +370,14 @@ var require_lodash = __commonJS({
|
|
|
370
370
|
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
371
371
|
}
|
|
372
372
|
function baseIsNative(value) {
|
|
373
|
-
if (!
|
|
373
|
+
if (!isObject7(value) || isMasked(value)) {
|
|
374
374
|
return false;
|
|
375
375
|
}
|
|
376
376
|
var pattern = isFunction5(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
|
|
377
377
|
return pattern.test(toSource(value));
|
|
378
378
|
}
|
|
379
379
|
function baseKeysIn(object) {
|
|
380
|
-
if (!
|
|
380
|
+
if (!isObject7(object)) {
|
|
381
381
|
return nativeKeysIn(object);
|
|
382
382
|
}
|
|
383
383
|
var isProto = isPrototype(object), result = [];
|
|
@@ -501,13 +501,13 @@ var require_lodash = __commonJS({
|
|
|
501
501
|
return isObjectLike(value) && isArrayLike(value);
|
|
502
502
|
}
|
|
503
503
|
function isFunction5(value) {
|
|
504
|
-
var tag =
|
|
504
|
+
var tag = isObject7(value) ? objectToString.call(value) : "";
|
|
505
505
|
return tag == funcTag || tag == genTag;
|
|
506
506
|
}
|
|
507
507
|
function isLength(value) {
|
|
508
508
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function isObject7(value) {
|
|
511
511
|
var type2 = typeof value;
|
|
512
512
|
return !!value && (type2 == "object" || type2 == "function");
|
|
513
513
|
}
|
|
@@ -537,11 +537,9 @@ var require_lodash = __commonJS({
|
|
|
537
537
|
// src/bin/orval.ts
|
|
538
538
|
var import_core12 = require("@orval/core");
|
|
539
539
|
var import_cac = require("cac");
|
|
540
|
-
var import_chalk7 = __toESM(require("chalk"));
|
|
541
540
|
|
|
542
541
|
// src/generate.ts
|
|
543
542
|
var import_core11 = require("@orval/core");
|
|
544
|
-
var import_chalk6 = __toESM(require("chalk"));
|
|
545
543
|
|
|
546
544
|
// src/import-specs.ts
|
|
547
545
|
var import_swagger_parser = __toESM(require("@apidevtools/swagger-parser"));
|
|
@@ -3345,7 +3343,8 @@ var generateClientFooter = ({
|
|
|
3345
3343
|
if (!footer) {
|
|
3346
3344
|
return {
|
|
3347
3345
|
implementation: "",
|
|
3348
|
-
implementationMock: `
|
|
3346
|
+
implementationMock: `
|
|
3347
|
+
]
|
|
3349
3348
|
`
|
|
3350
3349
|
};
|
|
3351
3350
|
}
|
|
@@ -3574,10 +3573,7 @@ var importOpenApi = async ({
|
|
|
3574
3573
|
target,
|
|
3575
3574
|
workspace,
|
|
3576
3575
|
specs,
|
|
3577
|
-
|
|
3578
|
-
tslint: output.tslint,
|
|
3579
|
-
tsconfig: output.tsconfig,
|
|
3580
|
-
packageJson: output.packageJson
|
|
3576
|
+
output
|
|
3581
3577
|
}
|
|
3582
3578
|
});
|
|
3583
3579
|
return {
|
|
@@ -3621,50 +3617,50 @@ var getApiSchemas = ({
|
|
|
3621
3617
|
workspace,
|
|
3622
3618
|
specs
|
|
3623
3619
|
}) => {
|
|
3624
|
-
return Object.entries(specs).reduce(
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
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
|
-
|
|
3620
|
+
return Object.entries(specs).reduce(
|
|
3621
|
+
(acc, [specKey, spec]) => {
|
|
3622
|
+
var _a, _b, _c, _d;
|
|
3623
|
+
const context = {
|
|
3624
|
+
specKey,
|
|
3625
|
+
target,
|
|
3626
|
+
workspace,
|
|
3627
|
+
specs,
|
|
3628
|
+
output
|
|
3629
|
+
};
|
|
3630
|
+
const schemaDefinition = (0, import_core3.generateSchemasDefinition)(
|
|
3631
|
+
!spec.openapi ? getAllSchemas(spec, specKey) : (_a = spec.components) == null ? void 0 : _a.schemas,
|
|
3632
|
+
context,
|
|
3633
|
+
output.override.components.schemas.suffix
|
|
3634
|
+
);
|
|
3635
|
+
const responseDefinition = (0, import_core3.generateComponentDefinition)(
|
|
3636
|
+
(_b = spec.components) == null ? void 0 : _b.responses,
|
|
3637
|
+
context,
|
|
3638
|
+
output.override.components.responses.suffix
|
|
3639
|
+
);
|
|
3640
|
+
const bodyDefinition = (0, import_core3.generateComponentDefinition)(
|
|
3641
|
+
(_c = spec.components) == null ? void 0 : _c.requestBodies,
|
|
3642
|
+
context,
|
|
3643
|
+
output.override.components.requestBodies.suffix
|
|
3644
|
+
);
|
|
3645
|
+
const parameters = (0, import_core3.generateParameterDefinition)(
|
|
3646
|
+
(_d = spec.components) == null ? void 0 : _d.parameters,
|
|
3647
|
+
context,
|
|
3648
|
+
output.override.components.parameters.suffix
|
|
3649
|
+
);
|
|
3650
|
+
const schemas = [
|
|
3651
|
+
...schemaDefinition,
|
|
3652
|
+
...responseDefinition,
|
|
3653
|
+
...bodyDefinition,
|
|
3654
|
+
...parameters
|
|
3655
|
+
];
|
|
3656
|
+
if (!schemas.length) {
|
|
3657
|
+
return acc;
|
|
3658
|
+
}
|
|
3659
|
+
acc[specKey] = schemas;
|
|
3663
3660
|
return acc;
|
|
3664
|
-
}
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
}, {});
|
|
3661
|
+
},
|
|
3662
|
+
{}
|
|
3663
|
+
);
|
|
3668
3664
|
};
|
|
3669
3665
|
var getAllSchemas = (spec, specKey) => {
|
|
3670
3666
|
var _a;
|
|
@@ -3733,7 +3729,7 @@ var resolveSpecs = async (path, { validate, ...options }, isUrl3, isOnlySchema)
|
|
|
3733
3729
|
return data;
|
|
3734
3730
|
}
|
|
3735
3731
|
return Object.fromEntries(
|
|
3736
|
-
Object.entries(data).map(([key, value]) => [import_core4.upath.resolve(key), value])
|
|
3732
|
+
Object.entries(data).sort().map(([key, value]) => [import_core4.upath.resolve(key), value])
|
|
3737
3733
|
);
|
|
3738
3734
|
} catch {
|
|
3739
3735
|
const file = await import_fs_extra.default.readFile(path, "utf8");
|
|
@@ -3782,7 +3778,7 @@ var import_chalk2 = __toESM(require("chalk"));
|
|
|
3782
3778
|
var package_default = {
|
|
3783
3779
|
name: "orval",
|
|
3784
3780
|
description: "A swagger client generator for typescript",
|
|
3785
|
-
version: "6.
|
|
3781
|
+
version: "6.24.0",
|
|
3786
3782
|
license: "MIT",
|
|
3787
3783
|
files: [
|
|
3788
3784
|
"dist"
|
|
@@ -3822,8 +3818,8 @@ var package_default = {
|
|
|
3822
3818
|
url: "https://github.com/anymaniax/orval"
|
|
3823
3819
|
},
|
|
3824
3820
|
scripts: {
|
|
3825
|
-
build: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --dts",
|
|
3826
|
-
dev: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --watch ./src --onSuccess 'yarn generate-api'",
|
|
3821
|
+
build: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --sourcemap --dts",
|
|
3822
|
+
dev: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --sourcemap --watch ./src --onSuccess 'yarn generate-api'",
|
|
3827
3823
|
lint: "eslint src/**/*.ts",
|
|
3828
3824
|
"generate-api": "node ./dist/bin/orval.js --config ../../samples/react-query/basic/orval.config.ts",
|
|
3829
3825
|
test: "tsc --noEmit && vitest --passWithNoTests"
|
|
@@ -3835,13 +3831,13 @@ var package_default = {
|
|
|
3835
3831
|
},
|
|
3836
3832
|
dependencies: {
|
|
3837
3833
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
3838
|
-
"@orval/angular": "6.
|
|
3839
|
-
"@orval/axios": "6.
|
|
3840
|
-
"@orval/core": "6.
|
|
3841
|
-
"@orval/mock": "6.
|
|
3842
|
-
"@orval/query": "6.
|
|
3843
|
-
"@orval/swr": "6.
|
|
3844
|
-
"@orval/zod": "6.
|
|
3834
|
+
"@orval/angular": "6.24.0",
|
|
3835
|
+
"@orval/axios": "6.24.0",
|
|
3836
|
+
"@orval/core": "6.24.0",
|
|
3837
|
+
"@orval/mock": "6.24.0",
|
|
3838
|
+
"@orval/query": "6.24.0",
|
|
3839
|
+
"@orval/swr": "6.24.0",
|
|
3840
|
+
"@orval/zod": "6.24.0",
|
|
3845
3841
|
ajv: "^8.12.0",
|
|
3846
3842
|
cac: "^6.7.14",
|
|
3847
3843
|
chalk: "^4.1.2",
|
|
@@ -3851,8 +3847,7 @@ var package_default = {
|
|
|
3851
3847
|
"find-up": "5.0.0",
|
|
3852
3848
|
"fs-extra": "^11.2.0",
|
|
3853
3849
|
"lodash.uniq": "^4.5.0",
|
|
3854
|
-
"
|
|
3855
|
-
"openapi3-ts": "^3.2.0",
|
|
3850
|
+
"openapi3-ts": "4.2.1",
|
|
3856
3851
|
"string-argv": "^0.3.2",
|
|
3857
3852
|
tsconfck: "^2.0.1"
|
|
3858
3853
|
}
|
|
@@ -4067,7 +4062,7 @@ var loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
|
|
|
4067
4062
|
|
|
4068
4063
|
// src/utils/options.ts
|
|
4069
4064
|
var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
|
|
4070
|
-
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;
|
|
4065
|
+
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;
|
|
4071
4066
|
const options = await ((0, import_core7.isFunction)(optionsExport) ? optionsExport() : optionsExport);
|
|
4072
4067
|
if (!options.input) {
|
|
4073
4068
|
(0, import_core7.createLogger)().error(import_chalk2.default.red(`Config require an input`));
|
|
@@ -4135,75 +4130,78 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
4135
4130
|
headers: (_n = outputOptions.headers) != null ? _n : false,
|
|
4136
4131
|
indexFiles: (_o = outputOptions.indexFiles) != null ? _o : true,
|
|
4137
4132
|
baseUrl: outputOptions.baseUrl,
|
|
4133
|
+
unionAddMissingProperties: (_p = outputOptions.unionAddMissingProperties) != null ? _p : false,
|
|
4138
4134
|
override: {
|
|
4139
4135
|
...outputOptions.override,
|
|
4140
4136
|
mock: {
|
|
4141
|
-
arrayMin: (
|
|
4142
|
-
arrayMax: (
|
|
4143
|
-
...(
|
|
4137
|
+
arrayMin: (_s = (_r = (_q = outputOptions.override) == null ? void 0 : _q.mock) == null ? void 0 : _r.arrayMin) != null ? _s : 1,
|
|
4138
|
+
arrayMax: (_v = (_u = (_t = outputOptions.override) == null ? void 0 : _t.mock) == null ? void 0 : _u.arrayMax) != null ? _v : 10,
|
|
4139
|
+
...(_x = (_w = outputOptions.override) == null ? void 0 : _w.mock) != null ? _x : {}
|
|
4144
4140
|
},
|
|
4145
4141
|
operations: normalizeOperationsAndTags(
|
|
4146
|
-
(
|
|
4142
|
+
(_z = (_y = outputOptions.override) == null ? void 0 : _y.operations) != null ? _z : {},
|
|
4147
4143
|
outputWorkspace
|
|
4148
4144
|
),
|
|
4149
4145
|
tags: normalizeOperationsAndTags(
|
|
4150
|
-
(
|
|
4146
|
+
(_B = (_A = outputOptions.override) == null ? void 0 : _A.tags) != null ? _B : {},
|
|
4151
4147
|
outputWorkspace
|
|
4152
4148
|
),
|
|
4153
4149
|
mutator: normalizeMutator(
|
|
4154
4150
|
outputWorkspace,
|
|
4155
|
-
(
|
|
4151
|
+
(_C = outputOptions.override) == null ? void 0 : _C.mutator
|
|
4156
4152
|
),
|
|
4157
|
-
formData: (
|
|
4153
|
+
formData: (_G = !(0, import_core7.isBoolean)((_D = outputOptions.override) == null ? void 0 : _D.formData) ? normalizeMutator(
|
|
4158
4154
|
outputWorkspace,
|
|
4159
|
-
(
|
|
4160
|
-
) : (
|
|
4161
|
-
formUrlEncoded: (
|
|
4155
|
+
(_E = outputOptions.override) == null ? void 0 : _E.formData
|
|
4156
|
+
) : (_F = outputOptions.override) == null ? void 0 : _F.formData) != null ? _G : true,
|
|
4157
|
+
formUrlEncoded: (_K = !(0, import_core7.isBoolean)((_H = outputOptions.override) == null ? void 0 : _H.formUrlEncoded) ? normalizeMutator(
|
|
4162
4158
|
outputWorkspace,
|
|
4163
|
-
(
|
|
4164
|
-
) : (
|
|
4159
|
+
(_I = outputOptions.override) == null ? void 0 : _I.formUrlEncoded
|
|
4160
|
+
) : (_J = outputOptions.override) == null ? void 0 : _J.formUrlEncoded) != null ? _K : true,
|
|
4165
4161
|
paramsSerializer: normalizeMutator(
|
|
4166
4162
|
outputWorkspace,
|
|
4167
|
-
(
|
|
4163
|
+
(_L = outputOptions.override) == null ? void 0 : _L.paramsSerializer
|
|
4168
4164
|
),
|
|
4169
|
-
header: ((
|
|
4170
|
-
requestOptions: (
|
|
4165
|
+
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,
|
|
4166
|
+
requestOptions: (_Q = (_P = outputOptions.override) == null ? void 0 : _P.requestOptions) != null ? _Q : true,
|
|
4171
4167
|
components: {
|
|
4172
4168
|
schemas: {
|
|
4173
4169
|
suffix: import_core7.RefComponentSuffix.schemas,
|
|
4174
|
-
|
|
4170
|
+
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",
|
|
4171
|
+
...(_X = (_W = (_V = outputOptions.override) == null ? void 0 : _V.components) == null ? void 0 : _W.schemas) != null ? _X : {}
|
|
4175
4172
|
},
|
|
4176
4173
|
responses: {
|
|
4177
4174
|
suffix: import_core7.RefComponentSuffix.responses,
|
|
4178
|
-
...(
|
|
4175
|
+
...(__ = (_Z = (_Y = outputOptions.override) == null ? void 0 : _Y.components) == null ? void 0 : _Z.responses) != null ? __ : {}
|
|
4179
4176
|
},
|
|
4180
4177
|
parameters: {
|
|
4181
4178
|
suffix: import_core7.RefComponentSuffix.parameters,
|
|
4182
|
-
...(
|
|
4179
|
+
...(_ba = (_aa = (_$ = outputOptions.override) == null ? void 0 : _$.components) == null ? void 0 : _aa.parameters) != null ? _ba : {}
|
|
4183
4180
|
},
|
|
4184
4181
|
requestBodies: {
|
|
4185
4182
|
suffix: import_core7.RefComponentSuffix.requestBodies,
|
|
4186
|
-
...(
|
|
4183
|
+
...(_ea = (_da = (_ca = outputOptions.override) == null ? void 0 : _ca.components) == null ? void 0 : _da.requestBodies) != null ? _ea : {}
|
|
4187
4184
|
}
|
|
4188
4185
|
},
|
|
4189
4186
|
query: {
|
|
4190
4187
|
useQuery: true,
|
|
4191
4188
|
useMutation: true,
|
|
4192
4189
|
signal: true,
|
|
4193
|
-
|
|
4190
|
+
shouldExportMutatorHooks: true,
|
|
4191
|
+
...normalizeQueryOptions((_fa = outputOptions.override) == null ? void 0 : _fa.query, workspace)
|
|
4194
4192
|
},
|
|
4195
4193
|
swr: {
|
|
4196
|
-
...(
|
|
4194
|
+
...(_ha = (_ga = outputOptions.override) == null ? void 0 : _ga.swr) != null ? _ha : {}
|
|
4197
4195
|
},
|
|
4198
4196
|
angular: {
|
|
4199
|
-
provideIn: (
|
|
4197
|
+
provideIn: (_ka = (_ja = (_ia = outputOptions.override) == null ? void 0 : _ia.angular) == null ? void 0 : _ja.provideIn) != null ? _ka : "root"
|
|
4200
4198
|
},
|
|
4201
|
-
useDates: ((
|
|
4202
|
-
useDeprecatedOperations: (
|
|
4203
|
-
useNativeEnums: (
|
|
4199
|
+
useDates: ((_la = outputOptions.override) == null ? void 0 : _la.useDates) || false,
|
|
4200
|
+
useDeprecatedOperations: (_na = (_ma = outputOptions.override) == null ? void 0 : _ma.useDeprecatedOperations) != null ? _na : true,
|
|
4201
|
+
useNativeEnums: (_pa = (_oa = outputOptions.override) == null ? void 0 : _oa.useNativeEnums) != null ? _pa : false
|
|
4204
4202
|
},
|
|
4205
|
-
allParamsOptional: (
|
|
4206
|
-
urlEncodeParameters: (
|
|
4203
|
+
allParamsOptional: (_qa = outputOptions.allParamsOptional) != null ? _qa : false,
|
|
4204
|
+
urlEncodeParameters: (_ra = outputOptions.urlEncodeParameters) != null ? _ra : false
|
|
4207
4205
|
},
|
|
4208
4206
|
hooks: options.hooks ? normalizeHooks(options.hooks) : {}
|
|
4209
4207
|
};
|
|
@@ -4326,6 +4324,11 @@ var normalizeHooks = (hooks) => {
|
|
|
4326
4324
|
...acc,
|
|
4327
4325
|
[key]: [hooks[key]]
|
|
4328
4326
|
};
|
|
4327
|
+
} else if ((0, import_core7.isObject)(hooks[key])) {
|
|
4328
|
+
return {
|
|
4329
|
+
...acc,
|
|
4330
|
+
[key]: [hooks[key]]
|
|
4331
|
+
};
|
|
4329
4332
|
}
|
|
4330
4333
|
return acc;
|
|
4331
4334
|
}, {});
|
|
@@ -4360,6 +4363,7 @@ var normalizeQueryOptions = (queryOptions = {}, outputWorkspace) => {
|
|
|
4360
4363
|
queryOptions == null ? void 0 : queryOptions.mutationOptions
|
|
4361
4364
|
)
|
|
4362
4365
|
} : {},
|
|
4366
|
+
...!(0, import_core7.isUndefined)(queryOptions.shouldExportMutatorHooks) ? { shouldExportMutatorHooks: queryOptions.shouldExportMutatorHooks } : {},
|
|
4363
4367
|
...!(0, import_core7.isUndefined)(queryOptions.signal) ? { signal: queryOptions.signal } : {},
|
|
4364
4368
|
...!(0, import_core7.isUndefined)(queryOptions.version) ? { version: queryOptions.version } : {}
|
|
4365
4369
|
};
|
|
@@ -4378,13 +4382,14 @@ var getDefaultFilesHeader = ({
|
|
|
4378
4382
|
|
|
4379
4383
|
// src/utils/watcher.ts
|
|
4380
4384
|
var import_core8 = require("@orval/core");
|
|
4381
|
-
var import_chalk3 = __toESM(require("chalk"));
|
|
4382
4385
|
var startWatcher = async (watchOptions, watchFn, defaultTarget = ".") => {
|
|
4383
4386
|
if (!watchOptions)
|
|
4384
4387
|
return;
|
|
4385
4388
|
const { watch } = await Promise.resolve().then(() => __toESM(require("chokidar")));
|
|
4386
4389
|
const ignored = ["**/{.git,node_modules}/**"];
|
|
4387
|
-
const watchPaths = typeof watchOptions === "boolean" ? defaultTarget : Array.isArray(watchOptions) ? watchOptions.filter(
|
|
4390
|
+
const watchPaths = typeof watchOptions === "boolean" ? defaultTarget : Array.isArray(watchOptions) ? watchOptions.filter(
|
|
4391
|
+
(path) => typeof path === "string"
|
|
4392
|
+
) : watchOptions;
|
|
4388
4393
|
(0, import_core8.log)(
|
|
4389
4394
|
`Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => '"' + v + '"').join(" | ") : '"' + watchPaths + '"'}`
|
|
4390
4395
|
);
|
|
@@ -4397,38 +4402,53 @@ var startWatcher = async (watchOptions, watchFn, defaultTarget = ".") => {
|
|
|
4397
4402
|
try {
|
|
4398
4403
|
await watchFn();
|
|
4399
4404
|
} catch (e) {
|
|
4400
|
-
(0, import_core8.
|
|
4405
|
+
(0, import_core8.logError)(e);
|
|
4401
4406
|
}
|
|
4402
4407
|
});
|
|
4403
4408
|
};
|
|
4404
4409
|
|
|
4405
4410
|
// src/write-specs.ts
|
|
4406
4411
|
var import_core10 = require("@orval/core");
|
|
4407
|
-
var
|
|
4412
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
4408
4413
|
var import_execa2 = __toESM(require("execa"));
|
|
4409
4414
|
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
4410
4415
|
var import_lodash2 = __toESM(require("lodash.uniq"));
|
|
4411
4416
|
|
|
4412
4417
|
// src/utils/executeHook.ts
|
|
4413
4418
|
var import_core9 = require("@orval/core");
|
|
4414
|
-
var
|
|
4419
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
4415
4420
|
var import_execa = __toESM(require("execa"));
|
|
4416
4421
|
var import_string_argv = require("string-argv");
|
|
4417
4422
|
var executeHook = async (name, commands = [], args = []) => {
|
|
4418
|
-
(0, import_core9.log)(
|
|
4423
|
+
(0, import_core9.log)(import_chalk3.default.white(`Running ${name} hook...`));
|
|
4419
4424
|
for (const command of commands) {
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4425
|
+
try {
|
|
4426
|
+
if ((0, import_core9.isString)(command)) {
|
|
4427
|
+
await executeCommand(command, args);
|
|
4428
|
+
} else if ((0, import_core9.isFunction)(command)) {
|
|
4429
|
+
await command(args);
|
|
4430
|
+
} else if ((0, import_core9.isObject)(command)) {
|
|
4431
|
+
await executeObjectCommand(command, args);
|
|
4426
4432
|
}
|
|
4427
|
-
}
|
|
4428
|
-
|
|
4433
|
+
} catch (e) {
|
|
4434
|
+
(0, import_core9.logError)(e, `Failed to run ${name} hook`);
|
|
4429
4435
|
}
|
|
4430
4436
|
}
|
|
4431
4437
|
};
|
|
4438
|
+
async function executeCommand(command, args) {
|
|
4439
|
+
const [cmd, ..._args] = [...(0, import_string_argv.parseArgsStringToArgv)(command), ...args];
|
|
4440
|
+
await (0, import_execa.default)(cmd, _args);
|
|
4441
|
+
}
|
|
4442
|
+
async function executeObjectCommand(command, args) {
|
|
4443
|
+
if (command.injectGeneratedDirsAndFiles === false) {
|
|
4444
|
+
args = [];
|
|
4445
|
+
}
|
|
4446
|
+
if ((0, import_core9.isString)(command.command)) {
|
|
4447
|
+
await executeCommand(command.command, args);
|
|
4448
|
+
} else if ((0, import_core9.isFunction)(command.command)) {
|
|
4449
|
+
await command.command();
|
|
4450
|
+
}
|
|
4451
|
+
}
|
|
4432
4452
|
|
|
4433
4453
|
// src/write-specs.ts
|
|
4434
4454
|
var getHeader = (option, info) => {
|
|
@@ -4442,12 +4462,15 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4442
4462
|
const { info = { title: "", version: 0 }, schemas, target } = builder;
|
|
4443
4463
|
const { output } = options;
|
|
4444
4464
|
const projectTitle = projectName || info.title;
|
|
4445
|
-
const specsName = Object.keys(schemas).reduce(
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4465
|
+
const specsName = Object.keys(schemas).reduce(
|
|
4466
|
+
(acc, specKey) => {
|
|
4467
|
+
const basePath = import_core10.upath.getSpecName(specKey, target);
|
|
4468
|
+
const name = basePath.slice(1).split("/").join("-");
|
|
4469
|
+
acc[specKey] = name;
|
|
4470
|
+
return acc;
|
|
4471
|
+
},
|
|
4472
|
+
{}
|
|
4473
|
+
);
|
|
4451
4474
|
const header = getHeader(output.override.header, info);
|
|
4452
4475
|
if (output.schemas) {
|
|
4453
4476
|
const rootSchemaPath = output.schemas;
|
|
@@ -4528,7 +4551,7 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4528
4551
|
await (0, import_execa2.default)("prettier", ["--write", ...paths]);
|
|
4529
4552
|
} catch (e) {
|
|
4530
4553
|
(0, import_core10.log)(
|
|
4531
|
-
|
|
4554
|
+
import_chalk4.default.yellow(
|
|
4532
4555
|
`\u26A0\uFE0F ${projectTitle ? `${projectTitle} - ` : ""}Prettier not found`
|
|
4533
4556
|
)
|
|
4534
4557
|
);
|
|
@@ -4578,11 +4601,11 @@ var generateSpecs = async (config, workspace, projectName) => {
|
|
|
4578
4601
|
try {
|
|
4579
4602
|
await generateSpec(workspace, options, projectName);
|
|
4580
4603
|
} catch (e) {
|
|
4581
|
-
(0, import_core11.
|
|
4604
|
+
(0, import_core11.logError)(e, projectName);
|
|
4582
4605
|
process.exit(1);
|
|
4583
4606
|
}
|
|
4584
4607
|
} else {
|
|
4585
|
-
(0, import_core11.
|
|
4608
|
+
(0, import_core11.logError)("Project not found");
|
|
4586
4609
|
process.exit(1);
|
|
4587
4610
|
}
|
|
4588
4611
|
return;
|
|
@@ -4595,7 +4618,7 @@ var generateSpecs = async (config, workspace, projectName) => {
|
|
|
4595
4618
|
acc.push(await generateSpec(workspace, options, projectName2));
|
|
4596
4619
|
} catch (e) {
|
|
4597
4620
|
hasErrors = true;
|
|
4598
|
-
(0, import_core11.
|
|
4621
|
+
(0, import_core11.logError)(e, projectName2);
|
|
4599
4622
|
}
|
|
4600
4623
|
return acc;
|
|
4601
4624
|
},
|
|
@@ -4679,7 +4702,7 @@ cli.command(
|
|
|
4679
4702
|
try {
|
|
4680
4703
|
await generateSpec(process.cwd(), normalizedOptions);
|
|
4681
4704
|
} catch (e) {
|
|
4682
|
-
(0, import_core12.
|
|
4705
|
+
(0, import_core12.logError)(e);
|
|
4683
4706
|
}
|
|
4684
4707
|
},
|
|
4685
4708
|
normalizedOptions.input.target
|
|
@@ -4688,7 +4711,7 @@ cli.command(
|
|
|
4688
4711
|
try {
|
|
4689
4712
|
await generateSpec(process.cwd(), normalizedOptions);
|
|
4690
4713
|
} catch (e) {
|
|
4691
|
-
(0, import_core12.
|
|
4714
|
+
(0, import_core12.logError)(e);
|
|
4692
4715
|
}
|
|
4693
4716
|
}
|
|
4694
4717
|
} else {
|
|
@@ -4714,3 +4737,4 @@ cli.parse(process.argv);
|
|
|
4714
4737
|
js-yaml/dist/js-yaml.mjs:
|
|
4715
4738
|
(*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
|
|
4716
4739
|
*/
|
|
4740
|
+
//# sourceMappingURL=orval.js.map
|