Skip to content

Commit

Permalink
chore: deprecate lint option in the join command
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorKarpiuk committed Dec 7, 2023
1 parent 88cd624 commit a7b6ed1
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-books-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@redocly/cli": patch
---

Deprecated `--lint` option in the `join` command. The options are marked for removal in a future release. Use the [lint command](https://redocly.com/docs/cli/commands/lint/) separately to lint your APIs.
7 changes: 6 additions & 1 deletion docs/commands/join.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ redocly join --version

## Options

{% admonition type="warning" name="Important" %}
The `--lint` option is deprecated and is marked for removal in future releases.
Use the [lint command](./lint.md) separately to lint your APIs before bundling.
{% /admonition %}

| Option | Type | Description |
| ---------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| apis | [string] | **REQUIRED.** 1. Array of paths to API description files that you want to join. At least two input files are required.<br />2. A wildcard pattern to match API description files within a specific folder. |
| --config | string | Specify path to the [config file](../configuration/index.md). |
| --decorate | boolean | Run decorators. |
| --help | boolean | Show help. |
| --lint | boolean | Lint API description files. |
| --lint (**Deprecated**) | boolean | Lint API description files. |
| --lint-config | string | Specify the severity level for the configuration file. <br/> **Possible values:** `warn`, `error`, `off`. Default value is `warn`. |
| --output, -o | string | Name for the joined output file. Defaults to `openapi.yaml` or `openapi.json` (Depends on the extension of the first input file). **If the file already exists, it's overwritten.** |
| --prefix-components-with-info-prop | string | Prefix components with property value from info object. See the [prefix-components-with-info-prop section](#prefix-components-with-info-prop) below. |
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/__mocks__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export const checkIfRulesetExist = jest.fn();
export const sortTopLevelKeysForOas = jest.fn((document) => document);
export const getAndValidateFileExtension = jest.fn((fileName: string) => fileName.split('.').pop());
export const writeToFileByExtension = jest.fn();
export const checkForDeprecatedOptions = jest.fn();
30 changes: 9 additions & 21 deletions packages/cli/src/commands/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type { OutputExtensions, Skips, Totals } from '../types';
import { performance } from 'perf_hooks';
import { blue, gray, green, yellow } from 'colorette';
import { writeFileSync } from 'fs';
import { checkForDeprecatedOptions } from '../utils';

export type BundleOptions = {
apis?: string[];
Expand All @@ -47,8 +48,15 @@ export async function handleBundle(argv: BundleOptions, config: Config, version:
const apis = await getFallbackApisOrExit(argv.apis, config);
const totals: Totals = { errors: 0, warnings: 0, ignored: 0 };
const maxProblems = argv['max-problems'];
const deprecatedOptions: Array<keyof BundleOptions> = [
'lint',
'format',
'skip-rule',
'extends',
'max-problems',
];

checkForDeprecatedOptions(argv);
checkForDeprecatedOptions(argv, deprecatedOptions);

for (const { path, alias } of apis) {
try {
Expand Down Expand Up @@ -177,23 +185,3 @@ export async function handleBundle(argv: BundleOptions, config: Config, version:
throw new Error('Bundle failed.');
}
}

function checkForDeprecatedOptions(argv: BundleOptions) {
const deprecatedOptions: Array<keyof BundleOptions> = [
'lint',
'format',
'skip-rule',
'extends',
'max-problems',
];

for (const option of deprecatedOptions) {
if (argv[option]) {
process.stderr.write(
yellow(
`[WARNING] "${option}" option is deprecated and will be removed in a future release. \n\n`
)
);
}
}
}
4 changes: 3 additions & 1 deletion packages/cli/src/commands/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
sortTopLevelKeysForOas,
getAndValidateFileExtension,
writeToFileByExtension,
checkForDeprecatedOptions,
} from '../utils';
import { isObject, isString, keysOf } from '../js-utils';
import {
Expand Down Expand Up @@ -65,7 +66,6 @@ export type JoinOptions = {
'without-x-tag-groups'?: boolean;
output?: string;
config?: string;
extends?: undefined;
'lint-config'?: RuleSeverity;
};

Expand All @@ -76,6 +76,8 @@ export async function handleJoin(argv: JoinOptions, config: Config, packageVersi
return exitWithError(`At least 2 apis should be provided. \n\n`);
}

checkForDeprecatedOptions(argv, ['lint'] as Array<keyof JoinOptions>);

const fileExtension = getAndValidateFileExtension(argv.output || argv.apis[0]);

const {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ yargs
demandOption: true,
})
.option({
lint: { description: 'Lint definitions', type: 'boolean', default: false },
lint: { description: 'Lint definitions', type: 'boolean', default: false, hidden: true },
decorate: { description: 'Run decorators', type: 'boolean', default: false },
preprocess: { description: 'Run preprocessors', type: 'boolean', default: false },
'prefix-tags-with-info-prop': {
Expand Down
14 changes: 14 additions & 0 deletions packages/cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,17 @@ export function cleanArgs(args: CommandOptions) {
export function cleanRawInput(argv: string[]) {
return argv.map((entry) => entry.split('=').map(cleanString).join('=')).join(' ');
}

export function checkForDeprecatedOptions<T>(argv: T, deprecatedOptions: Array<keyof T>) {
for (const option of deprecatedOptions) {
if (argv[option]) {
process.stderr.write(
yellow(
`[WARNING] "${String(
option
)}" option is deprecated and will be removed in a future release. \n\n`
)
);
}
}
}

0 comments on commit a7b6ed1

Please sign in to comment.