@redocly/cli 1.34.4 → 2.0.0-next.1
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/README.md +34 -3
- package/bin/cli.js +1 -1
- package/lib/auth/device-flow.d.ts +1 -0
- package/lib/auth/device-flow.d.ts.map +1 -0
- package/lib/auth/device-flow.js +15 -17
- package/lib/auth/device-flow.js.map +1 -0
- package/lib/auth/oauth-client.d.ts +1 -0
- package/lib/auth/oauth-client.d.ts.map +1 -0
- package/lib/auth/oauth-client.js +21 -23
- package/lib/auth/oauth-client.js.map +1 -0
- package/lib/commands/auth.d.ts +3 -5
- package/lib/commands/auth.d.ts.map +1 -0
- package/lib/commands/auth.js +19 -44
- package/lib/commands/auth.js.map +1 -0
- package/lib/commands/build-docs/index.d.ts +4 -3
- package/lib/commands/build-docs/index.d.ts.map +1 -0
- package/lib/commands/build-docs/index.js +23 -24
- package/lib/commands/build-docs/index.js.map +1 -0
- package/lib/commands/build-docs/types.d.ts +2 -1
- package/lib/commands/build-docs/types.d.ts.map +1 -0
- package/lib/commands/build-docs/types.js +2 -2
- package/lib/commands/build-docs/types.js.map +1 -0
- package/lib/commands/build-docs/utils.d.ts +3 -2
- package/lib/commands/build-docs/utils.d.ts.map +1 -0
- package/lib/commands/build-docs/utils.js +35 -37
- package/lib/commands/build-docs/utils.js.map +1 -0
- package/lib/commands/bundle.d.ts +6 -3
- package/lib/commands/bundle.d.ts.map +1 -0
- package/lib/commands/bundle.js +34 -38
- package/lib/commands/bundle.js.map +1 -0
- package/lib/commands/eject.d.ts +3 -2
- package/lib/commands/eject.d.ts.map +1 -0
- package/lib/commands/eject.js +11 -13
- package/lib/commands/eject.js.map +1 -0
- package/lib/commands/join.d.ts +4 -3
- package/lib/commands/join.d.ts.map +1 -0
- package/lib/commands/join.js +79 -81
- package/lib/commands/join.js.map +1 -0
- package/lib/commands/lint.d.ts +8 -6
- package/lib/commands/lint.d.ts.map +1 -0
- package/lib/commands/lint.js +53 -62
- package/lib/commands/lint.js.map +1 -0
- package/lib/commands/preview-project/constants.d.ts +2 -1
- package/lib/commands/preview-project/constants.d.ts.map +1 -0
- package/lib/commands/preview-project/constants.js +4 -6
- package/lib/commands/preview-project/constants.js.map +1 -0
- package/lib/commands/preview-project/index.d.ts +3 -2
- package/lib/commands/preview-project/index.d.ts.map +1 -0
- package/lib/commands/preview-project/index.js +21 -23
- package/lib/commands/preview-project/index.js.map +1 -0
- package/lib/commands/preview-project/types.d.ts +3 -2
- package/lib/commands/preview-project/types.d.ts.map +1 -0
- package/lib/commands/preview-project/types.js +2 -2
- package/lib/commands/preview-project/types.js.map +1 -0
- package/lib/commands/split/index.d.ts +4 -3
- package/lib/commands/split/index.d.ts.map +1 -0
- package/lib/commands/split/index.js +53 -57
- package/lib/commands/split/index.js.map +1 -0
- package/lib/commands/split/types.d.ts +2 -2
- package/lib/commands/split/types.d.ts.map +1 -0
- package/lib/commands/split/types.js +11 -13
- package/lib/commands/split/types.js.map +1 -0
- package/lib/commands/stats.d.ts +3 -2
- package/lib/commands/stats.d.ts.map +1 -0
- package/lib/commands/stats.js +21 -24
- package/lib/commands/stats.js.map +1 -0
- package/lib/commands/translations.d.ts +3 -2
- package/lib/commands/translations.d.ts.map +1 -0
- package/lib/commands/translations.js +11 -13
- package/lib/commands/translations.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +109 -239
- package/lib/index.js.map +1 -0
- package/lib/otel.d.ts +2 -1
- package/lib/otel.d.ts.map +1 -0
- package/lib/otel.js +22 -23
- package/lib/otel.js.map +1 -0
- package/lib/reunite/api/api-client.d.ts +4 -3
- package/lib/reunite/api/api-client.d.ts.map +1 -0
- package/lib/reunite/api/api-client.js +14 -20
- package/lib/reunite/api/api-client.js.map +1 -0
- package/lib/reunite/api/api-keys.d.ts +2 -1
- package/lib/reunite/api/api-keys.d.ts.map +1 -0
- package/lib/reunite/api/api-keys.js +4 -20
- package/lib/reunite/api/api-keys.js.map +1 -0
- package/lib/reunite/api/domains.d.ts +5 -2
- package/lib/reunite/api/domains.d.ts.map +1 -0
- package/lib/reunite/api/domains.js +6 -15
- package/lib/reunite/api/domains.js.map +1 -0
- package/lib/reunite/api/index.d.ts +4 -3
- package/lib/reunite/api/index.d.ts.map +1 -0
- package/lib/reunite/api/index.js +4 -19
- package/lib/reunite/api/index.js.map +1 -0
- package/lib/reunite/api/types.d.ts +1 -0
- package/lib/reunite/api/types.d.ts.map +1 -0
- package/lib/reunite/api/types.js +2 -2
- package/lib/reunite/api/types.js.map +1 -0
- package/lib/reunite/commands/push-status.d.ts +6 -5
- package/lib/reunite/commands/push-status.d.ts.map +1 -0
- package/lib/reunite/commands/push-status.js +31 -37
- package/lib/reunite/commands/push-status.js.map +1 -0
- package/lib/reunite/commands/push.d.ts +6 -6
- package/lib/reunite/commands/push.d.ts.map +1 -0
- package/lib/reunite/commands/push.js +31 -40
- package/lib/reunite/commands/push.js.map +1 -0
- package/lib/reunite/commands/utils.d.ts +4 -3
- package/lib/reunite/commands/utils.d.ts.map +1 -0
- package/lib/reunite/commands/utils.js +9 -12
- package/lib/reunite/commands/utils.js.map +1 -0
- package/lib/reunite/utils.d.ts +1 -0
- package/lib/reunite/utils.d.ts.map +1 -0
- package/lib/reunite/utils.js +2 -5
- package/lib/reunite/utils.js.map +1 -0
- package/lib/types.d.ts +15 -27
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -5
- package/lib/types.js.map +1 -0
- package/lib/utils/assert-node-version.d.ts +1 -0
- package/lib/utils/assert-node-version.d.ts.map +1 -0
- package/lib/utils/assert-node-version.js +8 -10
- package/lib/utils/assert-node-version.js.map +1 -0
- package/lib/utils/error.d.ts +4 -0
- package/lib/utils/error.d.ts.map +1 -0
- package/lib/utils/error.js +8 -0
- package/lib/utils/error.js.map +1 -0
- package/lib/utils/fetch-with-timeout.d.ts +1 -0
- package/lib/utils/fetch-with-timeout.d.ts.map +1 -0
- package/lib/utils/fetch-with-timeout.js +6 -8
- package/lib/utils/fetch-with-timeout.js.map +1 -0
- package/lib/utils/{getCommandNameFromArgs.d.ts → get-command-name-from-args.d.ts} +1 -0
- package/lib/utils/get-command-name-from-args.d.ts.map +1 -0
- package/lib/utils/get-command-name-from-args.js +4 -0
- package/lib/utils/get-command-name-from-args.js.map +1 -0
- package/lib/utils/js-utils.d.ts +1 -0
- package/lib/utils/js-utils.d.ts.map +1 -0
- package/lib/utils/js-utils.js +8 -12
- package/lib/utils/js-utils.js.map +1 -0
- package/lib/utils/miscellaneous.d.ts +9 -48
- package/lib/utils/miscellaneous.d.ts.map +1 -0
- package/lib/utils/miscellaneous.js +131 -269
- package/lib/utils/miscellaneous.js.map +1 -0
- package/lib/utils/package.d.ts +2 -0
- package/lib/utils/package.d.ts.map +1 -0
- package/lib/utils/package.js +4 -0
- package/lib/utils/package.js.map +1 -0
- package/lib/utils/platform.d.ts +1 -0
- package/lib/utils/platform.d.ts.map +1 -0
- package/lib/utils/platform.js +5 -9
- package/lib/utils/platform.js.map +1 -0
- package/lib/utils/proxy-agent.d.ts +3 -0
- package/lib/utils/proxy-agent.d.ts.map +1 -0
- package/lib/utils/proxy-agent.js +6 -0
- package/lib/utils/proxy-agent.js.map +1 -0
- package/lib/utils/spinner.d.ts +1 -0
- package/lib/utils/spinner.d.ts.map +1 -0
- package/lib/utils/spinner.js +8 -10
- package/lib/utils/spinner.js.map +1 -0
- package/lib/utils/telemetry.d.ts +40 -0
- package/lib/utils/telemetry.d.ts.map +1 -0
- package/lib/utils/telemetry.js +138 -0
- package/lib/utils/telemetry.js.map +1 -0
- package/lib/utils/update-version-notifier.d.ts +1 -1
- package/lib/utils/update-version-notifier.d.ts.map +1 -0
- package/lib/utils/update-version-notifier.js +35 -38
- package/lib/utils/update-version-notifier.js.map +1 -0
- package/lib/utils/validate-positive-number.d.ts +2 -0
- package/lib/utils/validate-positive-number.d.ts.map +1 -0
- package/lib/utils/validate-positive-number.js +13 -0
- package/lib/utils/validate-positive-number.js.map +1 -0
- package/lib/wrapper.d.ts +3 -3
- package/lib/wrapper.d.ts.map +1 -0
- package/lib/wrapper.js +39 -26
- package/lib/wrapper.js.map +1 -0
- package/package.json +16 -17
- package/CHANGELOG.md +0 -777
- package/lib/__mocks__/@redocly/openapi-core.d.ts +0 -99
- package/lib/__mocks__/@redocly/openapi-core.js +0 -84
- package/lib/__mocks__/documents.d.ts +0 -150
- package/lib/__mocks__/documents.js +0 -123
- package/lib/__mocks__/fs.d.ts +0 -8
- package/lib/__mocks__/fs.js +0 -9
- package/lib/__mocks__/perf_hooks.d.ts +0 -3
- package/lib/__mocks__/perf_hooks.js +0 -6
- package/lib/__mocks__/redoc.d.ts +0 -6
- package/lib/__mocks__/redoc.js +0 -5
- package/lib/__tests__/commands/build-docs.test.d.ts +0 -1
- package/lib/__tests__/commands/build-docs.test.js +0 -54
- package/lib/__tests__/commands/bundle.test.d.ts +0 -1
- package/lib/__tests__/commands/bundle.test.js +0 -235
- package/lib/__tests__/commands/join.test.d.ts +0 -1
- package/lib/__tests__/commands/join.test.js +0 -274
- package/lib/__tests__/commands/lint.test.d.ts +0 -1
- package/lib/__tests__/commands/lint.test.js +0 -149
- package/lib/__tests__/commands/push-region.test.d.ts +0 -1
- package/lib/__tests__/commands/push-region.test.js +0 -90
- package/lib/__tests__/commands/push.test.d.ts +0 -1
- package/lib/__tests__/commands/push.test.js +0 -496
- package/lib/__tests__/fetch-with-timeout.test.d.ts +0 -1
- package/lib/__tests__/fetch-with-timeout.test.js +0 -64
- package/lib/__tests__/fixtures/config.d.ts +0 -21
- package/lib/__tests__/fixtures/config.js +0 -24
- package/lib/__tests__/spinner.test.d.ts +0 -1
- package/lib/__tests__/spinner.test.js +0 -43
- package/lib/__tests__/utils.test.d.ts +0 -1
- package/lib/__tests__/utils.test.js +0 -651
- package/lib/__tests__/wrapper.test.d.ts +0 -1
- package/lib/__tests__/wrapper.test.js +0 -76
- package/lib/auth/__tests__/device-flow.test.d.ts +0 -1
- package/lib/auth/__tests__/device-flow.test.js +0 -62
- package/lib/auth/__tests__/oauth-client.test.d.ts +0 -1
- package/lib/auth/__tests__/oauth-client.test.js +0 -93
- package/lib/commands/preview-docs/index.d.ts +0 -12
- package/lib/commands/preview-docs/index.js +0 -127
- package/lib/commands/preview-docs/preview-server/default.hbs +0 -24
- package/lib/commands/preview-docs/preview-server/hot.js +0 -59
- package/lib/commands/preview-docs/preview-server/oauth2-redirect.html +0 -21
- package/lib/commands/preview-docs/preview-server/preview-server.d.ts +0 -5
- package/lib/commands/preview-docs/preview-server/preview-server.js +0 -113
- package/lib/commands/preview-docs/preview-server/server.d.ts +0 -22
- package/lib/commands/preview-docs/preview-server/server.js +0 -85
- package/lib/commands/push.d.ts +0 -44
- package/lib/commands/push.js +0 -301
- package/lib/commands/split/__tests__/index.test.d.ts +0 -1
- package/lib/commands/split/__tests__/index.test.js +0 -91
- package/lib/reunite/api/__tests__/api-keys.test.d.ts +0 -1
- package/lib/reunite/api/__tests__/api-keys.test.js +0 -26
- package/lib/reunite/api/__tests__/api.client.test.d.ts +0 -1
- package/lib/reunite/api/__tests__/api.client.test.js +0 -337
- package/lib/reunite/api/__tests__/domains.test.d.ts +0 -1
- package/lib/reunite/api/__tests__/domains.test.js +0 -32
- package/lib/reunite/commands/__tests__/push-status.test.d.ts +0 -1
- package/lib/reunite/commands/__tests__/push-status.test.js +0 -563
- package/lib/reunite/commands/__tests__/push.test.d.ts +0 -1
- package/lib/reunite/commands/__tests__/push.test.js +0 -315
- package/lib/reunite/commands/__tests__/utils.test.d.ts +0 -1
- package/lib/reunite/commands/__tests__/utils.test.js +0 -51
- package/lib/utils/__mocks__/miscellaneous.d.ts +0 -43
- package/lib/utils/__mocks__/miscellaneous.js +0 -24
- package/lib/utils/getCommandNameFromArgs.js +0 -6
- package/src/__mocks__/@redocly/openapi-core.ts +0 -88
- package/src/__mocks__/documents.ts +0 -124
- package/src/__mocks__/fs.ts +0 -6
- package/src/__mocks__/perf_hooks.ts +0 -3
- package/src/__mocks__/redoc.ts +0 -2
- package/src/__tests__/commands/build-docs.test.ts +0 -59
- package/src/__tests__/commands/bundle.test.ts +0 -285
- package/src/__tests__/commands/join.test.ts +0 -334
- package/src/__tests__/commands/lint.test.ts +0 -190
- package/src/__tests__/commands/push-region.test.ts +0 -104
- package/src/__tests__/commands/push.test.ts +0 -553
- package/src/__tests__/fetch-with-timeout.test.ts +0 -81
- package/src/__tests__/fixtures/config.ts +0 -21
- package/src/__tests__/fixtures/openapi.json +0 -0
- package/src/__tests__/fixtures/openapi.yaml +0 -0
- package/src/__tests__/fixtures/redocly.yaml +0 -0
- package/src/__tests__/spinner.test.ts +0 -51
- package/src/__tests__/utils.test.ts +0 -781
- package/src/__tests__/wrapper.test.ts +0 -91
- package/src/auth/__tests__/device-flow.test.ts +0 -73
- package/src/auth/__tests__/oauth-client.test.ts +0 -117
- package/src/auth/device-flow.ts +0 -175
- package/src/auth/oauth-client.ts +0 -111
- package/src/commands/auth.ts +0 -66
- package/src/commands/build-docs/index.ts +0 -55
- package/src/commands/build-docs/template.hbs +0 -23
- package/src/commands/build-docs/types.ts +0 -25
- package/src/commands/build-docs/utils.ts +0 -110
- package/src/commands/bundle.ts +0 -154
- package/src/commands/eject.ts +0 -42
- package/src/commands/join.ts +0 -794
- package/src/commands/lint.ts +0 -169
- package/src/commands/preview-docs/index.ts +0 -183
- package/src/commands/preview-docs/preview-server/default.hbs +0 -24
- package/src/commands/preview-docs/preview-server/hot.js +0 -59
- package/src/commands/preview-docs/preview-server/oauth2-redirect.html +0 -21
- package/src/commands/preview-docs/preview-server/preview-server.ts +0 -159
- package/src/commands/preview-docs/preview-server/server.ts +0 -92
- package/src/commands/preview-project/constants.ts +0 -23
- package/src/commands/preview-project/index.ts +0 -71
- package/src/commands/preview-project/types.ts +0 -12
- package/src/commands/push.ts +0 -470
- package/src/commands/split/__tests__/fixtures/samples.json +0 -61
- package/src/commands/split/__tests__/fixtures/spec.json +0 -70
- package/src/commands/split/__tests__/fixtures/webhooks.json +0 -85
- package/src/commands/split/__tests__/index.test.ts +0 -156
- package/src/commands/split/index.ts +0 -397
- package/src/commands/split/types.ts +0 -60
- package/src/commands/stats.ts +0 -140
- package/src/commands/translations.ts +0 -32
- package/src/custom.d.ts +0 -1
- package/src/index.ts +0 -970
- package/src/otel.ts +0 -59
- package/src/reunite/api/__tests__/api-keys.test.ts +0 -37
- package/src/reunite/api/__tests__/api.client.test.ts +0 -452
- package/src/reunite/api/__tests__/domains.test.ts +0 -41
- package/src/reunite/api/api-client.ts +0 -381
- package/src/reunite/api/api-keys.ts +0 -26
- package/src/reunite/api/domains.ts +0 -23
- package/src/reunite/api/index.ts +0 -3
- package/src/reunite/api/types.ts +0 -108
- package/src/reunite/commands/__tests__/push-status.test.ts +0 -653
- package/src/reunite/commands/__tests__/push.test.ts +0 -385
- package/src/reunite/commands/__tests__/utils.test.ts +0 -62
- package/src/reunite/commands/push-status.ts +0 -325
- package/src/reunite/commands/push.ts +0 -235
- package/src/reunite/commands/utils.ts +0 -66
- package/src/reunite/utils.ts +0 -1
- package/src/types.ts +0 -64
- package/src/utils/__mocks__/miscellaneous.ts +0 -24
- package/src/utils/assert-node-version.ts +0 -19
- package/src/utils/fetch-with-timeout.ts +0 -30
- package/src/utils/getCommandNameFromArgs.ts +0 -5
- package/src/utils/js-utils.ts +0 -24
- package/src/utils/miscellaneous.ts +0 -729
- package/src/utils/platform.ts +0 -31
- package/src/utils/spinner.ts +0 -50
- package/src/utils/update-version-notifier.ts +0 -115
- package/src/wrapper.ts +0 -77
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/lib/commands/bundle.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { OutputExtensions,
|
|
2
|
-
import type { CommandArgs } from '../wrapper';
|
|
1
|
+
import type { OutputExtensions, VerifyConfigOptions } from '../types.js';
|
|
2
|
+
import type { CommandArgs } from '../wrapper.js';
|
|
3
3
|
export type BundleOptions = {
|
|
4
4
|
apis?: string[];
|
|
5
5
|
extends?: string[];
|
|
@@ -10,5 +10,8 @@ export type BundleOptions = {
|
|
|
10
10
|
metafile?: string;
|
|
11
11
|
'remove-unused-components'?: boolean;
|
|
12
12
|
'keep-url-references'?: boolean;
|
|
13
|
-
|
|
13
|
+
'skip-decorator'?: string[];
|
|
14
|
+
'skip-preprocessor'?: string[];
|
|
15
|
+
} & VerifyConfigOptions;
|
|
14
16
|
export declare function handleBundle({ argv, config, version, collectSpecData, }: CommandArgs<BundleOptions>): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/commands/bundle.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAU,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC,GAAG,mBAAmB,CAAC;AAExB,wBAAsB,YAAY,CAAC,EACjC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,eAAe,GAChB,EAAE,WAAW,CAAC,aAAa,CAAC,iBA4G5B"}
|
package/lib/commands/bundle.js
CHANGED
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const miscellaneous_1 = require("../utils/miscellaneous");
|
|
9
|
-
async function handleBundle({ argv, config, version, collectSpecData, }) {
|
|
1
|
+
import { performance } from 'perf_hooks';
|
|
2
|
+
import { blue, gray, green, yellow } from 'colorette';
|
|
3
|
+
import { writeFileSync } from 'fs';
|
|
4
|
+
import { formatProblems, getTotals, bundle, logger } from '@redocly/openapi-core';
|
|
5
|
+
import { dumpBundle, getExecutionTime, getFallbackApisOrExit, getOutputFileName, handleError, printUnusedWarnings, saveBundle, sortTopLevelKeysForOas, formatPath, } from '../utils/miscellaneous.js';
|
|
6
|
+
import { AbortFlowError } from '../utils/error.js';
|
|
7
|
+
export async function handleBundle({ argv, config, version, collectSpecData, }) {
|
|
10
8
|
const removeUnusedComponents = argv['remove-unused-components'] ||
|
|
11
|
-
config.
|
|
12
|
-
const apis = await
|
|
9
|
+
config.resolvedConfig.decorators?.hasOwnProperty('remove-unused-components'); // FIXME: also on `apis` level
|
|
10
|
+
const apis = await getFallbackApisOrExit(argv.apis, config);
|
|
13
11
|
const totals = { errors: 0, warnings: 0, ignored: 0 };
|
|
14
|
-
const deprecatedOptions = [];
|
|
15
|
-
(0, miscellaneous_1.checkForDeprecatedOptions)(argv, deprecatedOptions);
|
|
16
12
|
for (const { path, alias, output } of apis) {
|
|
17
13
|
try {
|
|
18
|
-
const startedAt =
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const { bundle: result, problems, ...meta } = await (0, openapi_core_1.bundle)({
|
|
25
|
-
config: resolvedConfig,
|
|
14
|
+
const startedAt = performance.now();
|
|
15
|
+
const aliasConfig = config.forAlias(alias);
|
|
16
|
+
aliasConfig.skipPreprocessors(argv['skip-preprocessor']);
|
|
17
|
+
aliasConfig.skipDecorators(argv['skip-decorator']);
|
|
18
|
+
logger.info(gray(`bundling ${formatPath(path)}...\n`));
|
|
19
|
+
const { bundle: result, problems, ...meta } = await bundle({
|
|
26
20
|
ref: path,
|
|
21
|
+
config: aliasConfig,
|
|
27
22
|
dereference: argv.dereferenced,
|
|
28
23
|
removeUnusedComponents,
|
|
29
24
|
keepUrlRefs: argv['keep-url-references'],
|
|
30
25
|
collectSpecData,
|
|
31
26
|
});
|
|
32
|
-
const fileTotals =
|
|
33
|
-
const { outputFile, ext } =
|
|
27
|
+
const fileTotals = getTotals(problems);
|
|
28
|
+
const { outputFile, ext } = getOutputFileName({
|
|
34
29
|
entrypoint: path,
|
|
35
30
|
output,
|
|
36
31
|
argvOutput: argv.output,
|
|
@@ -39,53 +34,54 @@ async function handleBundle({ argv, config, version, collectSpecData, }) {
|
|
|
39
34
|
});
|
|
40
35
|
if (fileTotals.errors === 0 || argv.force) {
|
|
41
36
|
if (!outputFile) {
|
|
42
|
-
const bundled =
|
|
43
|
-
|
|
37
|
+
const bundled = dumpBundle(sortTopLevelKeysForOas(result.parsed), argv.ext || 'yaml', argv.dereferenced);
|
|
38
|
+
logger.output(bundled);
|
|
44
39
|
}
|
|
45
40
|
else {
|
|
46
|
-
const bundled =
|
|
47
|
-
|
|
41
|
+
const bundled = dumpBundle(sortTopLevelKeysForOas(result.parsed), ext, argv.dereferenced);
|
|
42
|
+
saveBundle(outputFile, bundled);
|
|
48
43
|
}
|
|
49
44
|
}
|
|
50
45
|
totals.errors += fileTotals.errors;
|
|
51
46
|
totals.warnings += fileTotals.warnings;
|
|
52
47
|
totals.ignored += fileTotals.ignored;
|
|
53
|
-
|
|
48
|
+
formatProblems(problems, {
|
|
54
49
|
format: 'codeframe',
|
|
55
50
|
totals: fileTotals,
|
|
56
51
|
version,
|
|
57
52
|
});
|
|
58
53
|
if (argv.metafile) {
|
|
59
54
|
if (apis.length > 1) {
|
|
60
|
-
|
|
55
|
+
logger.warn(`[WARNING] "--metafile" cannot be used with multiple apis. Skipping...`);
|
|
61
56
|
}
|
|
62
57
|
{
|
|
63
|
-
|
|
58
|
+
writeFileSync(argv.metafile, JSON.stringify(meta), 'utf-8');
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
|
-
const elapsed =
|
|
61
|
+
const elapsed = getExecutionTime(startedAt);
|
|
67
62
|
if (fileTotals.errors > 0) {
|
|
68
63
|
if (argv.force) {
|
|
69
|
-
|
|
64
|
+
logger.info(`❓ Created a bundle for ${blue(formatPath(path))} at ${blue(outputFile || 'stdout')} with errors ${green(elapsed)}.\n${yellow('Errors ignored because of --force')}.\n`);
|
|
70
65
|
}
|
|
71
66
|
else {
|
|
72
|
-
|
|
67
|
+
logger.info(`❌ Errors encountered while bundling ${blue(formatPath(path))}: bundle not created (use --force to ignore errors).\n`);
|
|
73
68
|
}
|
|
74
69
|
}
|
|
75
70
|
else {
|
|
76
|
-
|
|
71
|
+
logger.info(`📦 Created a bundle for ${blue(formatPath(path))} at ${blue(outputFile || 'stdout')} ${green(elapsed)}.\n`);
|
|
77
72
|
}
|
|
78
73
|
const removedCount = meta.visitorsData?.['remove-unused-components']?.removedCount;
|
|
79
74
|
if (removedCount) {
|
|
80
|
-
|
|
75
|
+
logger.info(gray(`🧹 Removed ${removedCount} unused components.\n`));
|
|
81
76
|
}
|
|
82
77
|
}
|
|
83
78
|
catch (e) {
|
|
84
|
-
|
|
79
|
+
handleError(e, path);
|
|
85
80
|
}
|
|
86
81
|
}
|
|
87
|
-
|
|
82
|
+
printUnusedWarnings(config);
|
|
88
83
|
if (!(totals.errors === 0 || argv.force)) {
|
|
89
|
-
throw new
|
|
84
|
+
throw new AbortFlowError('Bundle failed.');
|
|
90
85
|
}
|
|
91
86
|
}
|
|
87
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/commands/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAA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vB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CACzB,CAAC;YACJ,CAAC;YAED,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,0BAA0B,CAAC,EAAE,YAAY,CAAC;YACnF,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,YAAY,uBAAuB,CAAC,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE5B,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
package/lib/commands/eject.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CommandArgs } from '../wrapper';
|
|
2
|
-
import type { VerifyConfigOptions } from '../types';
|
|
1
|
+
import type { CommandArgs } from '../wrapper.js';
|
|
2
|
+
import type { VerifyConfigOptions } from '../types.js';
|
|
3
3
|
export type EjectOptions = {
|
|
4
4
|
type: 'component';
|
|
5
5
|
path?: string;
|
|
@@ -7,3 +7,4 @@ export type EjectOptions = {
|
|
|
7
7
|
force: boolean;
|
|
8
8
|
} & VerifyConfigOptions;
|
|
9
9
|
export declare const handleEject: ({ argv }: CommandArgs<EjectOptions>) => Promise<void>;
|
|
10
|
+
//# sourceMappingURL=eject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eject.d.ts","sourceRoot":"","sources":["../../src/commands/eject.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,mBAAmB,CAAC;AAExB,eAAO,MAAM,WAAW,aAAoB,WAAW,CAAC,YAAY,CAAC,kBA4BpE,CAAC"}
|
package/lib/commands/eject.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const projectDir = sanitize(argv['project-dir'], platform_1.sanitizePath);
|
|
11
|
-
const child = (0, child_process_1.spawn)(npxExecutableName, [
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { logger } from '@redocly/openapi-core';
|
|
3
|
+
import { getPlatformSpawnArgs, sanitizePath } from '../utils/platform.js';
|
|
4
|
+
export const handleEject = async ({ argv }) => {
|
|
5
|
+
logger.info(`\nLaunching eject using NPX.\n\n`);
|
|
6
|
+
const { npxExecutableName, sanitize, shell } = getPlatformSpawnArgs();
|
|
7
|
+
const path = sanitize(argv.path, sanitizePath);
|
|
8
|
+
const projectDir = sanitize(argv['project-dir'], sanitizePath);
|
|
9
|
+
const child = spawn(npxExecutableName, [
|
|
12
10
|
'-y',
|
|
13
11
|
'@redocly/realm',
|
|
14
12
|
'eject',
|
|
@@ -21,8 +19,8 @@ const handleEject = async ({ argv }) => {
|
|
|
21
19
|
shell,
|
|
22
20
|
});
|
|
23
21
|
child.on('error', (error) => {
|
|
24
|
-
|
|
22
|
+
logger.info(`Eject launch failed: ${error.message}`);
|
|
25
23
|
throw new Error('Eject launch failed.');
|
|
26
24
|
});
|
|
27
25
|
};
|
|
28
|
-
|
|
26
|
+
//# sourceMappingURL=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ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CommandArgs } from '../wrapper';
|
|
2
|
-
import type { VerifyConfigOptions } from '../types';
|
|
1
|
+
import type { CommandArgs } from '../wrapper.js';
|
|
2
|
+
import type { VerifyConfigOptions } from '../types.js';
|
|
3
3
|
export type JoinOptions = {
|
|
4
4
|
apis: string[];
|
|
5
5
|
'prefix-tags-with-info-prop'?: string;
|
|
@@ -8,4 +8,5 @@ export type JoinOptions = {
|
|
|
8
8
|
'without-x-tag-groups'?: boolean;
|
|
9
9
|
output?: string;
|
|
10
10
|
} & VerifyConfigOptions;
|
|
11
|
-
export declare function handleJoin({ argv, config, version: packageVersion, collectSpecData, }: CommandArgs<JoinOptions>): Promise<
|
|
11
|
+
export declare function handleJoin({ argv, config, version: packageVersion, collectSpecData, }: CommandArgs<JoinOptions>): Promise<undefined>;
|
|
12
|
+
//# sourceMappingURL=join.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../src/commands/join.ts"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAgBvD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,kCAAkC,CAAC,EAAE,MAAM,CAAC;IAC5C,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,mBAAmB,CAAC;AAExB,wBAAsB,UAAU,CAAC,EAC/B,IAAI,EACJ,MAAM,EACN,OAAO,EAAE,cAAc,EACvB,eAAe,GAChB,EAAE,WAAW,CAAC,WAAW,CAAC,sBA4jB1B"}
|
package/lib/commands/join.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const js_utils_1 = require("../utils/js-utils");
|
|
11
|
-
const types_1 = require("./split/types");
|
|
12
|
-
const split_1 = require("./split");
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { red, blue, yellow, green } from 'colorette';
|
|
3
|
+
import { performance } from 'node:perf_hooks';
|
|
4
|
+
import { SpecVersion, BaseResolver, formatProblems, getTotals, detectSpec, bundleDocument, isRef, dequal, logger, } from '@redocly/openapi-core';
|
|
5
|
+
import { getFallbackApisOrExit, printExecutionTime, sortTopLevelKeysForOas, getAndValidateFileExtension, writeToFileByExtension, } from '../utils/miscellaneous.js';
|
|
6
|
+
import { exitWithError } from '../utils/error.js';
|
|
7
|
+
import { isObject, isString, keysOf } from '../utils/js-utils.js';
|
|
8
|
+
import { COMPONENTS, OPENAPI3_METHOD } from './split/types.js';
|
|
9
|
+
import { crawl, startsWithComponents } from './split/index.js';
|
|
13
10
|
const Tags = 'tags';
|
|
14
11
|
const xTagGroups = 'x-tagGroups';
|
|
15
12
|
let potentialConflictsTotal = 0;
|
|
16
|
-
async function handleJoin({ argv, config, version: packageVersion, collectSpecData, }) {
|
|
17
|
-
const startedAt =
|
|
13
|
+
export async function handleJoin({ argv, config, version: packageVersion, collectSpecData, }) {
|
|
14
|
+
const startedAt = performance.now();
|
|
18
15
|
const { 'prefix-components-with-info-prop': prefixComponentsWithInfoProp, 'prefix-tags-with-filename': prefixTagsWithFilename, 'prefix-tags-with-info-prop': prefixTagsWithInfoProp, 'without-x-tag-groups': withoutXTagGroups, output, } = argv;
|
|
19
16
|
const usedTagsOptions = [
|
|
20
17
|
prefixTagsWithFilename && 'prefix-tags-with-filename',
|
|
@@ -22,60 +19,60 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
22
19
|
withoutXTagGroups && 'without-x-tag-groups',
|
|
23
20
|
].filter(Boolean);
|
|
24
21
|
if (usedTagsOptions.length > 1) {
|
|
25
|
-
return
|
|
22
|
+
return exitWithError(`You use ${yellow(usedTagsOptions.join(', '))} together.\nPlease choose only one!`);
|
|
26
23
|
}
|
|
27
|
-
const apis = await
|
|
24
|
+
const apis = await getFallbackApisOrExit(argv.apis, config);
|
|
28
25
|
if (apis.length < 2) {
|
|
29
|
-
return
|
|
26
|
+
return exitWithError(`At least 2 APIs should be provided.`);
|
|
30
27
|
}
|
|
31
|
-
const fileExtension =
|
|
28
|
+
const fileExtension = getAndValidateFileExtension(output || apis[0].path);
|
|
32
29
|
const specFilename = output || `openapi.${fileExtension}`;
|
|
33
|
-
const externalRefResolver = new
|
|
30
|
+
const externalRefResolver = new BaseResolver(config.resolve);
|
|
34
31
|
const documents = await Promise.all(apis.map(({ path }) => externalRefResolver.resolveDocument(null, path, true)));
|
|
35
32
|
const decorators = new Set([
|
|
36
|
-
...Object.keys(config.
|
|
37
|
-
...Object.keys(config.
|
|
38
|
-
...Object.keys(config.
|
|
33
|
+
...Object.keys(config.decorators.oas3_0),
|
|
34
|
+
...Object.keys(config.decorators.oas3_1),
|
|
35
|
+
...Object.keys(config.decorators.oas2),
|
|
39
36
|
]);
|
|
40
|
-
config.
|
|
37
|
+
config.skipDecorators(Array.from(decorators));
|
|
41
38
|
const preprocessors = new Set([
|
|
42
|
-
...Object.keys(config.
|
|
43
|
-
...Object.keys(config.
|
|
44
|
-
...Object.keys(config.
|
|
39
|
+
...Object.keys(config.preprocessors.oas3_0),
|
|
40
|
+
...Object.keys(config.preprocessors.oas3_1),
|
|
41
|
+
...Object.keys(config.preprocessors.oas2),
|
|
45
42
|
]);
|
|
46
|
-
config.
|
|
47
|
-
const bundleResults = await Promise.all(documents.map((document) =>
|
|
43
|
+
config.skipPreprocessors(Array.from(preprocessors));
|
|
44
|
+
const bundleResults = await Promise.all(documents.map((document) => bundleDocument({
|
|
48
45
|
document,
|
|
49
|
-
config
|
|
50
|
-
externalRefResolver: new
|
|
46
|
+
config,
|
|
47
|
+
externalRefResolver: new BaseResolver(config.resolve),
|
|
51
48
|
}).catch((e) => {
|
|
52
|
-
|
|
49
|
+
exitWithError(`${e.message}: ${blue(document.source.absoluteRef)}`);
|
|
53
50
|
})));
|
|
54
51
|
for (const { problems, bundle: document } of bundleResults) {
|
|
55
|
-
const fileTotals =
|
|
52
|
+
const fileTotals = getTotals(problems);
|
|
56
53
|
if (fileTotals.errors) {
|
|
57
|
-
|
|
54
|
+
formatProblems(problems, {
|
|
58
55
|
totals: fileTotals,
|
|
59
56
|
version: packageVersion,
|
|
60
57
|
});
|
|
61
|
-
|
|
58
|
+
exitWithError(`❌ Errors encountered while bundling ${blue(document.source.absoluteRef)}: join will not proceed.`);
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
61
|
let oasVersion = null;
|
|
65
62
|
for (const document of documents) {
|
|
66
63
|
try {
|
|
67
|
-
const version =
|
|
64
|
+
const version = detectSpec(document.parsed);
|
|
68
65
|
collectSpecData?.(document.parsed);
|
|
69
|
-
if (version !==
|
|
70
|
-
return
|
|
66
|
+
if (version !== SpecVersion.OAS3_0 && version !== SpecVersion.OAS3_1) {
|
|
67
|
+
return exitWithError(`Only OpenAPI 3.0 and OpenAPI 3.1 are supported: ${blue(document.source.absoluteRef)}.`);
|
|
71
68
|
}
|
|
72
69
|
oasVersion = oasVersion ?? version;
|
|
73
70
|
if (oasVersion !== version) {
|
|
74
|
-
return
|
|
71
|
+
return exitWithError(`All APIs must use the same OpenAPI version: ${blue(document.source.absoluteRef)}.`);
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
catch (e) {
|
|
78
|
-
return
|
|
75
|
+
return exitWithError(`${e.message}: ${blue(document.source.absoluteRef)}.`);
|
|
79
76
|
}
|
|
80
77
|
}
|
|
81
78
|
const joinedDef = {};
|
|
@@ -94,9 +91,9 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
94
91
|
const tagsPrefix = prefixTagsWithFilename
|
|
95
92
|
? apiFilename
|
|
96
93
|
: getInfoPrefix(info, prefixTagsWithInfoProp, 'tags');
|
|
97
|
-
const componentsPrefix = getInfoPrefix(info, prefixComponentsWithInfoProp,
|
|
94
|
+
const componentsPrefix = getInfoPrefix(info, prefixComponentsWithInfoProp, COMPONENTS);
|
|
98
95
|
if (openapi.hasOwnProperty('x-tagGroups')) {
|
|
99
|
-
|
|
96
|
+
logger.warn(`warning: x-tagGroups at ${blue(api)} will be skipped \n`);
|
|
100
97
|
}
|
|
101
98
|
const context = {
|
|
102
99
|
api,
|
|
@@ -122,10 +119,10 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
122
119
|
iteratePotentialConflicts(potentialConflicts, withoutXTagGroups);
|
|
123
120
|
const noRefs = true;
|
|
124
121
|
if (potentialConflictsTotal) {
|
|
125
|
-
return
|
|
122
|
+
return exitWithError(`Please fix conflicts before running ${yellow('join')}.`);
|
|
126
123
|
}
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
writeToFileByExtension(sortTopLevelKeysForOas(joinedDef), specFilename, noRefs);
|
|
125
|
+
printExecutionTime('join', startedAt, specFilename);
|
|
129
126
|
function populateTags({ api, apiFilename, apiTitle, tags, potentialConflicts, tagsPrefix, componentsPrefix, }) {
|
|
130
127
|
if (!joinedDef.hasOwnProperty(Tags)) {
|
|
131
128
|
joinedDef[Tags] = [];
|
|
@@ -210,7 +207,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
210
207
|
const { externalDocs } = openapi;
|
|
211
208
|
if (externalDocs) {
|
|
212
209
|
if (joinedDef.hasOwnProperty('externalDocs')) {
|
|
213
|
-
|
|
210
|
+
logger.warn(`warning: skip externalDocs from ${blue(path.basename(api))} \n`);
|
|
214
211
|
return;
|
|
215
212
|
}
|
|
216
213
|
joinedDef['externalDocs'] = externalDocs;
|
|
@@ -218,12 +215,12 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
218
215
|
}
|
|
219
216
|
function collectPaths(openapi, { apiFilename, apiTitle, api, potentialConflicts, tagsPrefix, componentsPrefix, }) {
|
|
220
217
|
const { paths } = openapi;
|
|
221
|
-
const operationsSet = new Set(
|
|
218
|
+
const operationsSet = new Set(keysOf(OPENAPI3_METHOD));
|
|
222
219
|
if (paths) {
|
|
223
220
|
if (!joinedDef.hasOwnProperty('paths')) {
|
|
224
221
|
joinedDef['paths'] = {};
|
|
225
222
|
}
|
|
226
|
-
for (const path of
|
|
223
|
+
for (const path of keysOf(paths)) {
|
|
227
224
|
if (!joinedDef.paths.hasOwnProperty(path)) {
|
|
228
225
|
joinedDef.paths[path] = {};
|
|
229
226
|
}
|
|
@@ -231,7 +228,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
231
228
|
potentialConflicts.paths[path] = {};
|
|
232
229
|
}
|
|
233
230
|
const pathItem = paths[path];
|
|
234
|
-
for (const field of
|
|
231
|
+
for (const field of keysOf(pathItem)) {
|
|
235
232
|
if (operationsSet.has(field)) {
|
|
236
233
|
collectPathOperation(pathItem, path, field);
|
|
237
234
|
}
|
|
@@ -251,7 +248,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
251
248
|
const fieldValue = pathItem[field];
|
|
252
249
|
if (joinedDef.paths[path].hasOwnProperty(field) &&
|
|
253
250
|
joinedDef.paths[path][field] !== fieldValue) {
|
|
254
|
-
|
|
251
|
+
logger.warn(`warning: different ${field} values in ${path}\n`);
|
|
255
252
|
return;
|
|
256
253
|
}
|
|
257
254
|
joinedDef.paths[path][field] = fieldValue;
|
|
@@ -268,7 +265,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
268
265
|
for (const pathServer of joinedDef.paths[path].servers) {
|
|
269
266
|
if (pathServer.url === server.url) {
|
|
270
267
|
if (!isServersEqual(pathServer, server)) {
|
|
271
|
-
|
|
268
|
+
exitWithError(`Different server values for (${server.url}) in ${path}.`);
|
|
272
269
|
}
|
|
273
270
|
isFoundServer = true;
|
|
274
271
|
}
|
|
@@ -290,16 +287,16 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
290
287
|
for (const pathParameter of joinedDef.paths[path]
|
|
291
288
|
.parameters) {
|
|
292
289
|
// Compare $ref only if both are reference objects
|
|
293
|
-
if (
|
|
290
|
+
if (isRef(pathParameter) && isRef(parameter)) {
|
|
294
291
|
if (pathParameter['$ref'] === parameter['$ref']) {
|
|
295
292
|
isFoundParameter = true;
|
|
296
293
|
}
|
|
297
294
|
}
|
|
298
295
|
// Compare properties only if both are reference objects
|
|
299
|
-
if (!
|
|
296
|
+
if (!isRef(pathParameter) && !isRef(parameter)) {
|
|
300
297
|
if (pathParameter.name === parameter.name && pathParameter.in === parameter.in) {
|
|
301
|
-
if (!
|
|
302
|
-
|
|
298
|
+
if (!dequal(pathParameter.schema, parameter.schema)) {
|
|
299
|
+
exitWithError(`Different parameter schemas for (${parameter.name}) in ${path}.`);
|
|
303
300
|
}
|
|
304
301
|
isFoundParameter = true;
|
|
305
302
|
}
|
|
@@ -365,20 +362,20 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
365
362
|
}
|
|
366
363
|
function isServersEqual(serverOne, serverTwo) {
|
|
367
364
|
if (serverOne.description === serverTwo.description) {
|
|
368
|
-
return
|
|
365
|
+
return dequal(serverOne.variables, serverTwo.variables);
|
|
369
366
|
}
|
|
370
367
|
return false;
|
|
371
368
|
}
|
|
372
369
|
function collectComponents(openapi, { api, potentialConflicts, componentsPrefix }) {
|
|
373
370
|
const { components } = openapi;
|
|
374
371
|
if (components) {
|
|
375
|
-
if (!joinedDef.hasOwnProperty(
|
|
376
|
-
joinedDef[
|
|
372
|
+
if (!joinedDef.hasOwnProperty(COMPONENTS)) {
|
|
373
|
+
joinedDef[COMPONENTS] = {};
|
|
377
374
|
}
|
|
378
375
|
for (const [component, componentObj] of Object.entries(components)) {
|
|
379
|
-
if (!potentialConflicts[
|
|
380
|
-
potentialConflicts[
|
|
381
|
-
joinedDef[
|
|
376
|
+
if (!potentialConflicts[COMPONENTS].hasOwnProperty(component)) {
|
|
377
|
+
potentialConflicts[COMPONENTS][component] = {};
|
|
378
|
+
joinedDef[COMPONENTS][component] = {};
|
|
382
379
|
}
|
|
383
380
|
for (const item of Object.keys(componentObj)) {
|
|
384
381
|
const componentPrefix = addPrefix(item, componentsPrefix);
|
|
@@ -392,7 +389,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
392
389
|
}
|
|
393
390
|
}
|
|
394
391
|
function collectWebhooks(oasVersion, openapi, { apiFilename, apiTitle, api, potentialConflicts, tagsPrefix, componentsPrefix, }) {
|
|
395
|
-
const webhooks = oasVersion ===
|
|
392
|
+
const webhooks = oasVersion === SpecVersion.OAS3_1 ? 'webhooks' : 'x-webhooks';
|
|
396
393
|
const openapiWebhooks = openapi[webhooks];
|
|
397
394
|
if (openapiWebhooks) {
|
|
398
395
|
if (!joinedDef.hasOwnProperty(webhooks)) {
|
|
@@ -430,11 +427,11 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
430
427
|
function addInfoSectionAndSpecVersion(documents, prefixComponentsWithInfoProp) {
|
|
431
428
|
const firstApi = documents[0];
|
|
432
429
|
const openapi = firstApi.parsed;
|
|
433
|
-
const componentsPrefix = getInfoPrefix(openapi.info, prefixComponentsWithInfoProp,
|
|
430
|
+
const componentsPrefix = getInfoPrefix(openapi.info, prefixComponentsWithInfoProp, COMPONENTS);
|
|
434
431
|
if (!openapi.openapi)
|
|
435
|
-
|
|
432
|
+
exitWithError('Version of specification is not found.');
|
|
436
433
|
if (!openapi.info)
|
|
437
|
-
|
|
434
|
+
exitWithError('Info section is not found in specification.');
|
|
438
435
|
if (openapi.info?.description) {
|
|
439
436
|
openapi.info.description = addComponentsPrefix(openapi.info.description, componentsPrefix);
|
|
440
437
|
}
|
|
@@ -443,7 +440,7 @@ async function handleJoin({ argv, config, version: packageVersion, collectSpecDa
|
|
|
443
440
|
}
|
|
444
441
|
}
|
|
445
442
|
function doesComponentsDiffer(curr, next) {
|
|
446
|
-
return !
|
|
443
|
+
return !dequal(Object.values(curr)[0], Object.values(next)[0]);
|
|
447
444
|
}
|
|
448
445
|
function validateComponentsDifference(files) {
|
|
449
446
|
let isDiffer = false;
|
|
@@ -460,11 +457,11 @@ function iteratePotentialConflicts(potentialConflicts, withoutXTagGroups) {
|
|
|
460
457
|
for (const [key, value] of Object.entries(potentialConflicts[group])) {
|
|
461
458
|
const conflicts = filterConflicts(value);
|
|
462
459
|
if (conflicts.length) {
|
|
463
|
-
if (group ===
|
|
460
|
+
if (group === COMPONENTS) {
|
|
464
461
|
for (const [_, conflict] of Object.entries(conflicts)) {
|
|
465
462
|
if (validateComponentsDifference(conflict[1])) {
|
|
466
463
|
conflict[1] = conflict[1].map((c) => Object.keys(c)[0]);
|
|
467
|
-
showConflicts(
|
|
464
|
+
showConflicts(green(group) + ' => ' + key, [conflict]);
|
|
468
465
|
potentialConflictsTotal += 1;
|
|
469
466
|
}
|
|
470
467
|
}
|
|
@@ -475,7 +472,7 @@ function iteratePotentialConflicts(potentialConflicts, withoutXTagGroups) {
|
|
|
475
472
|
}
|
|
476
473
|
else {
|
|
477
474
|
potentialConflictsTotal += conflicts.length;
|
|
478
|
-
showConflicts(
|
|
475
|
+
showConflicts(green(group) + ' => ' + key, conflicts);
|
|
479
476
|
}
|
|
480
477
|
}
|
|
481
478
|
if (group === 'tags' && !withoutXTagGroups) {
|
|
@@ -487,15 +484,15 @@ function iteratePotentialConflicts(potentialConflicts, withoutXTagGroups) {
|
|
|
487
484
|
}
|
|
488
485
|
function duplicateTagDescriptionWarning(conflicts) {
|
|
489
486
|
const tagsKeys = conflicts.map(([tagName]) => `\`${tagName}\``);
|
|
490
|
-
const joinString =
|
|
491
|
-
|
|
487
|
+
const joinString = yellow(', ');
|
|
488
|
+
logger.warn(`\nwarning: ${tagsKeys.length} conflict(s) on the ${red(tagsKeys.join(joinString))} tags description.\n`);
|
|
492
489
|
}
|
|
493
490
|
function prefixTagSuggestion(conflictsLength) {
|
|
494
|
-
|
|
491
|
+
logger.info(green(`\n${conflictsLength} conflict(s) on tags.\nSuggestion: please use ${blue('prefix-tags-with-filename')}, ${blue('prefix-tags-with-info-prop')} or ${blue('without-x-tag-groups')} to prevent naming conflicts.\n\n`));
|
|
495
492
|
}
|
|
496
493
|
function showConflicts(key, conflicts) {
|
|
497
494
|
for (const [path, files] of conflicts) {
|
|
498
|
-
|
|
495
|
+
logger.warn(`Conflict on ${key} : ${red(path)} in files: ${blue(files)} \n`);
|
|
499
496
|
}
|
|
500
497
|
}
|
|
501
498
|
function filterConflicts(entities) {
|
|
@@ -531,26 +528,26 @@ function getInfoPrefix(info, prefixArg, type) {
|
|
|
531
528
|
if (!prefixArg)
|
|
532
529
|
return '';
|
|
533
530
|
if (!info)
|
|
534
|
-
|
|
531
|
+
exitWithError('Info section is not found in specification.');
|
|
535
532
|
if (!info[prefixArg])
|
|
536
|
-
|
|
537
|
-
if (!
|
|
538
|
-
|
|
533
|
+
exitWithError(`${yellow(`prefix-${type}-with-info-prop`)} argument value is not found in info section.`);
|
|
534
|
+
if (!isString(info[prefixArg]))
|
|
535
|
+
exitWithError(`${yellow(`prefix-${type}-with-info-prop`)} argument value should be string.`);
|
|
539
536
|
if (info[prefixArg].length > 50)
|
|
540
|
-
|
|
537
|
+
exitWithError(`${yellow(`prefix-${type}-with-info-prop`)} argument value length should not exceed 50 characters.`);
|
|
541
538
|
return info[prefixArg].replaceAll(/\s/g, '_');
|
|
542
539
|
}
|
|
543
540
|
function replace$Refs(obj, componentsPrefix) {
|
|
544
|
-
|
|
545
|
-
if (node.$ref && typeof node.$ref === 'string' &&
|
|
541
|
+
crawl(obj, (node) => {
|
|
542
|
+
if (node.$ref && typeof node.$ref === 'string' && startsWithComponents(node.$ref)) {
|
|
546
543
|
const name = path.basename(node.$ref);
|
|
547
544
|
node.$ref = node.$ref.replace(name, componentsPrefix + '_' + name);
|
|
548
545
|
}
|
|
549
|
-
else if (
|
|
546
|
+
else if (isObject(node.discriminator) && isObject(node.discriminator.mapping)) {
|
|
550
547
|
const { mapping } = node.discriminator;
|
|
551
548
|
for (const name of Object.keys(mapping)) {
|
|
552
549
|
const mappingPointer = mapping[name];
|
|
553
|
-
if (typeof mappingPointer === 'string' &&
|
|
550
|
+
if (typeof mappingPointer === 'string' && startsWithComponents(mappingPointer)) {
|
|
554
551
|
mapping[name] = mappingPointer
|
|
555
552
|
.split('/')
|
|
556
553
|
.map((name, i, arr) => {
|
|
@@ -564,3 +561,4 @@ function replace$Refs(obj, componentsPrefix) {
|
|
|
564
561
|
}
|
|
565
562
|
});
|
|
566
563
|
}
|
|
564
|
+
//# sourceMappingURL=join.js.map
|