feat: drop linting option from bundle command (#1503)

This commit is contained in:
Dmytro Anansky
2024-04-02 12:12:16 +03:00
committed by GitHub
parent 2d16014b67
commit 9343b35cdd
26 changed files with 67 additions and 968 deletions

View File

@@ -0,0 +1,5 @@
---
"@redocly/cli": minor
---
Removed lint support from the bundle command to support a wider range of use cases. Users should update to [run lint and bundle separately](https://redocly.com/docs/cli/guides/lint-and-bundle/).

View File

@@ -1,23 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`E2E bundle lint format bundle lint: should be formatted by format: checkstyle 1`] = `
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="4.3">
<file name="openapi.yaml">
<error line="20" column="11" severity="error" message="Expected type \`MediaType\` (object) but got \`null\`" source="spec" />
</file>
</checkstyle>
[WARNING] "lint" option is deprecated and will be removed in a future release.
[WARNING] "format" option is deprecated and will be removed in a future release.
[WARNING] "max-problems" option is deprecated and will be removed in a future release.
❌ Validation failed with 1 error.
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file.
bundling ./openapi.yaml...
📦 Created a bundle for ./openapi.yaml at /tmp/null.yaml <test>ms.
`;

View File

@@ -1,30 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`E2E bundle lint format bundle lint: should be formatted by format: codeframe 1`] = `
[WARNING] "lint" option is deprecated and will be removed in a future release.
[WARNING] "format" option is deprecated and will be removed in a future release.
[WARNING] "max-problems" option is deprecated and will be removed in a future release.
[1] openapi.yaml:20:11 at #/paths/~1my_post/post/requestBody/content/application~1json
Expected type \`MediaType\` (object) but got \`null\`
18 | requestBody:
19 | content:
20 | application/json:
| ^^^^^^^^^^^^^^^^^
21 |
Error was generated by the spec rule.
❌ Validation failed with 1 error.
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file.
bundling ./openapi.yaml...
📦 Created a bundle for ./openapi.yaml at /tmp/null.yaml <test>ms.
`;

View File

@@ -1,34 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`E2E bundle lint format bundle lint: no format parameter or empty value should be formatted as codeframe 1`] = `
index.ts bundle [apis...]
Bundle a multi-file API description to a single file.
Positionals:
apis [array] [default: []]
Options:
--version Show version number. [boolean]
--help Show help. [boolean]
-o, --output Output file. [string]
--ext Bundle file extension.
[choices: "json", "yaml", "yml"]
--skip-preprocessor Ignore certain preprocessors. [array]
--skip-decorator Ignore certain decorators. [array]
-d, --dereferenced Produce a fully dereferenced bundle. [boolean]
-f, --force Produce bundle output even when errors occur.
[boolean]
--config Path to the config file. [string]
--metafile Produce metadata about the bundle [string]
--remove-unused-components Remove unused components.
[boolean] [default: false]
-k, --keep-url-references Keep absolute url references. [boolean]
--lint-config Severity level for config file linting.
[choices: "warn", "error", "off"] [default: "warn"]
Invalid values:
Argument: format, Given: true, Choices: "stylish", "codeframe", "json", "checkstyle"
`;

View File

@@ -1,49 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`E2E bundle lint format bundle lint: should be formatted by format: json 1`] = `
{
"totals": {
"errors": 1,
"warnings": 0,
"ignored": 0
},
"version": "<version>",
"problems": [
{
"ruleId": "spec",
"severity": "error",
"message": "Expected type \`MediaType\` (object) but got \`null\`",
"suggest": [],
"location": [
{
"source": {
"ref": "openapi.yaml"
},
"pointer": "#/paths/~1my_post/post/requestBody/content/application~1json",
"reportOnKey": false
}
]
}
]
}{
"totals": {
"errors": 0,
"warnings": 0,
"ignored": 0
},
"version": "<version>",
"problems": []
}
[WARNING] "lint" option is deprecated and will be removed in a future release.
[WARNING] "format" option is deprecated and will be removed in a future release.
[WARNING] "max-problems" option is deprecated and will be removed in a future release.
❌ Validation failed with 1 error.
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file.
bundling ./openapi.yaml...
📦 Created a bundle for ./openapi.yaml at /tmp/null.yaml <test>ms.
`;

View File

@@ -1,28 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`E2E bundle lint format bundle lint: no format parameter or empty value should be formatted as codeframe 1`] = `
[WARNING] "lint" option is deprecated and will be removed in a future release.
[WARNING] "max-problems" option is deprecated and will be removed in a future release.
[1] openapi.yaml:20:11 at #/paths/~1my_post/post/requestBody/content/application~1json
Expected type \`MediaType\` (object) but got \`null\`
18 | requestBody:
19 | content:
20 | application/json:
| ^^^^^^^^^^^^^^^^^
21 |
Error was generated by the spec rule.
❌ Validation failed with 1 error.
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file.
bundling ./openapi.yaml...
📦 Created a bundle for ./openapi.yaml at /tmp/null.yaml <test>ms.
`;

View File

@@ -1,20 +0,0 @@
openapi: 3.1.0
servers:
- url: https://api.redocly-example.com/v1
security: []
info:
title: Title
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
description: Description
version: 1.0.0
paths:
/my_post:
post:
operationId: my_post
summary: my_post
requestBody:
content:
application/json:

View File

@@ -1,5 +0,0 @@
apis:
main:
root: ./openapi.yaml
extends:
- recommended

View File

@@ -1,20 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`E2E bundle lint format bundle lint: should be formatted by format: stylish 1`] = `
[WARNING] "lint" option is deprecated and will be removed in a future release.
[WARNING] "format" option is deprecated and will be removed in a future release.
[WARNING] "max-problems" option is deprecated and will be removed in a future release.
openapi.yaml:
20:11 error spec Expected type \`MediaType\` (object) but got \`null\`
❌ Validation failed with 1 error.
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file.
bundling ./openapi.yaml...
📦 Created a bundle for ./openapi.yaml at /tmp/null.yaml <test>ms.
`;

View File

@@ -1,118 +0,0 @@
openapi: 3.0.0
info:
version: 1.0.0
title: Swagger Petstore
description: Information about Petstore
license:
name: MIT
url: 'https://opensource.org/licenses/MIT'
servers:
- url: 'http://petstore.swagger.io/v1'
security: []
paths:
/pets:
get:
summay: List all pets
operationIds: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int
responses:
'200':
description: An paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/Pets'
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/pets/{petId}':
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: '#/components/schemas/Pets'
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: '#/components/schemas/Pet'

View File

@@ -1,118 +0,0 @@
openapi: 3.0.0
info:
version: 1.0.0
title: Swagger Petstore
description: Information about Petstore
license:
name: MIT
url: 'https://opensource.org/licenses/MIT'
servers:
- url: 'http://petstore.swagger.io/v1'
security: []
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int
responses:
'200':
description: An paged array of pets
header:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/Pets'
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/pets/{petId}':
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: '#/components/schemas/Pets'
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: '#/components/schemas/Pet'

View File

@@ -1,8 +0,0 @@
apis:
foo:
root: ./foo.yaml
bar:
root: ./bar.yaml
extends:
- recommended

View File

@@ -1,265 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`E2E bundle max-problems-argument 1`] = `
openapi: 3.0.0
info:
version: 1.0.0
title: Swagger Petstore
description: Information about Petstore
license:
name: MIT
url: https://opensource.org/licenses/MIT
servers:
- url: http://petstore.swagger.io/v1
security: []
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int
responses:
'200':
description: An paged array of pets
header:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/Pets'
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: '#/components/schemas/Pets'
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: '#/components/schemas/Pet'
openapi: 3.0.0
info:
version: 1.0.0
title: Swagger Petstore
description: Information about Petstore
license:
name: MIT
url: https://opensource.org/licenses/MIT
servers:
- url: http://petstore.swagger.io/v1
security: []
paths:
/pets:
get:
summay: List all pets
operationIds: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int
responses:
'200':
description: An paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/Pets'
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: '#/components/schemas/Pets'
'400':
description: An error response
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: '#/components/schemas/Pet'
[WARNING] "lint" option is deprecated and will be removed in a future release.
[WARNING] "format" option is deprecated and will be removed in a future release.
[WARNING] "max-problems" option is deprecated and will be removed in a future release.
foo.yaml:
30:11 error spec Property \`header\` is not expected here.
❌ Validation failed with 1 error.
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file.
bundling ./foo.yaml...
📦 Created a bundle for ./foo.yaml at stdout <test>ms.
bar.yaml:
15:7 error spec Property \`summay\` is not expected here.
< ... 3 more problems hidden > increase with \`--max-problems N\`
❌ Validation failed with 3 errors and 1 warning.
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file.
bundling ./bar.yaml...
📦 Created a bundle for ./bar.yaml at stdout <test>ms.
`;

View File

@@ -358,8 +358,6 @@ describe('E2E', () => {
const excludeFolders = [
'bundle-remove-unused-components',
'bundle-remove-unused-components-from-config',
'bundle-lint-format',
'max-problems-argument',
];
const folderPath = join(__dirname, 'bundle');
const contents = readdirSync(folderPath).filter((folder) => !excludeFolders.includes(folder));
@@ -379,51 +377,6 @@ describe('E2E', () => {
(<any>expect(result)).toMatchSpecificSnapshot(join(testPath, 'snapshot.js'));
});
}
it('max-problems-argument', () => {
const folderPath = join(__dirname, 'bundle/max-problems-argument');
const entryPoints = getEntrypoints(folderPath);
const args = getParams('../../../packages/cli/src/index.ts', 'bundle', [
'--lint',
'--max-problems=1',
'--format=stylish',
...entryPoints,
]);
const result = getCommandOutput(args, folderPath);
(<any>expect(result)).toMatchSpecificSnapshot(join(folderPath, 'snapshot.js'));
});
});
describe('bundle lint format', () => {
const folderPath = join(__dirname, 'bundle/bundle-lint-format');
const entryPoints = getEntrypoints(folderPath);
const args = getParams('../../../packages/cli/src/index.ts', 'bundle', [
'--lint',
'--max-problems=1',
'-o=/tmp/null',
...entryPoints,
]);
test.each(['codeframe', 'stylish', 'json', 'checkstyle'])(
'bundle lint: should be formatted by format: %s',
(format) => {
const params = [...args, `--format=${format}`];
const result = getCommandOutput(params, folderPath);
(<any>expect(result)).toMatchSpecificSnapshot(
join(folderPath, `${format}-format-snapshot.js`)
);
}
);
test.each(['noFormatParameter', 'emptyFormatValue'])(
'bundle lint: no format parameter or empty value should be formatted as codeframe',
(format) => {
const formatArgument = format === 'emptyFormatValue' ? ['--format'] : [];
const params = [...args, ...formatArgument];
const result = getCommandOutput(params, folderPath);
(<any>expect(result)).toMatchSpecificSnapshot(join(folderPath, `${format}-snapshot.js`));
}
);
});
describe('bundle with option: remove-unused-components', () => {
@@ -502,10 +455,7 @@ describe('E2E', () => {
test('bundle should resolve $refs in preprocessors', () => {
const testPath = join(folderPath, 'resolve-refs-in-preprocessors');
const args = getParams('../../../packages/cli/src/index.ts', 'bundle', [
'openapi.yaml',
'--lint',
]);
const args = getParams('../../../packages/cli/src/index.ts', 'bundle', ['openapi.yaml']);
const result = getCommandOutput(args, testPath);
(<any>expect(result)).toMatchSpecificSnapshot(join(testPath, 'snapshot.js'));
});

View File

@@ -52,25 +52,6 @@ components:
error_code:
type: number
[WARNING] "lint" option is deprecated and will be removed in a future release.
[1] openapi.yaml:4:1 at #/info
Info object should contain \`license\` field.
2 | servers:
3 | - url: http://redocly-example.com:8080
4 | info:
| ^^^^
5 | title: Test
6 | version: 1.0.0
Warning was generated by the info-license rule.
Woohoo! Your API descriptions are valid. 🎉
You have 1 warning.
bundling openapi.yaml...
📦 Created a bundle for openapi.yaml at stdout <test>ms.

View File

@@ -16,12 +16,7 @@ describe('webpack-bundle test', () => {
test('bundle check', () => {
const folderPath = join(__dirname, 'webpack-bundle/bundle');
const entryPoint = getEntrypoints(folderPath);
const args = getParams('../../../dist/bundle.js', 'bundle', [
'--max-problems=1',
'-o=/tmp/null',
'--lint',
...entryPoint,
]);
const args = getParams('../../../dist/bundle.js', 'bundle', ['-o=/tmp/null', ...entryPoint]);
const result = getCommandOutput(args, folderPath);
(<any>expect(result)).toMatchSpecificSnapshot(join(folderPath, 'snapshot.js'));
});

View File

@@ -2,8 +2,6 @@
exports[`webpack-bundle test bundle-workflows 1`] = `
[WARNING] "extends" option is deprecated and will be removed in a future release.
bundling ./openapi.yaml...
📦 Created a bundle for ./openapi.yaml at bundle.yaml <test>ms.

View File

@@ -2,12 +2,6 @@
exports[`webpack-bundle test bundle check 1`] = `
[WARNING] "lint" option is deprecated and will be removed in a future release.
[WARNING] "max-problems" option is deprecated and will be removed in a future release.
Woohoo! Your API descriptions are valid. 🎉
bundling ./openapi.yaml...
📦 Created a bundle for ./openapi.yaml at /tmp/null.yaml <test>ms.

View File

@@ -20,32 +20,23 @@ redocly bundle --version
## Options
{% admonition type="warning" name="Important" %}
The `--lint` switch and all related options (`--extends`, `--max-problems`, `--skip-rule`, `--format`) are deprecated and are 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] | List of API description root filenames or names assigned in the `apis` section of your Redocly configuration file. Default values are all names defined in the `apis` section within your configuration file. |
| --config | string | Specify path to the [config file](#custom-configuration-file). |
| --dereferenced, -d | boolean | Generate fully dereferenced bundle. |
| --ext | string | Specify bundled file extension. Possible values are `json`, `yaml`, or `yml`. Default value is `yaml`. |
| --extends (**Deprecated**) | [string] | Can be used in combination with `--lint` to [extend a specific configuration](./lint.md#extend-configuration). Default values are taken from the Redocly configuration file. |
| --force, -f | boolean | Generate bundle output even when errors occur. |
| --format (**Deprecated**) | string | Format for the output. Possible values are `codeframe`, `stylish`, `json`, or `checkstyle`. Default value is `codeframe`. |
| --help | boolean | Show help. |
| --keep-url-references, -k | boolean | Keep absolute url references. |
| --lint (**Deprecated**) | boolean | Lint API description files. Default value is `false`. |
| --lint-config | string | Specify the severity level for the configuration file. <br/> **Possible values:** `warn`, `error`, `off`. Default value is `warn`. |
| --max-problems (**Deprecated**) | integer | Truncate output to display the specified maximum number of problems. Default value is `100`. |
| --metafile | string | Path for the bundle metadata file. |
| --output, -o | string | Name or folder for the bundle file. If you don't specify the file extension, `.yaml` is used by default. If the specified folder doesn't exist, it's created automatically. **If the file specified as the bundler's output already exists, it's overwritten.** |
| --remove-unused-components | boolean | Remove unused components from the `bundle` output. |
| --skip-decorator | [string] | Ignore certain decorators. See the [Skip preprocessor, rule, or decorator section](#skip-preprocessor-rule-or-decorator). |
| --skip-preprocessor | [string] | Ignore certain preprocessors. See the [Skip preprocessor, rule, or decorator section](#skip-preprocessor-rule-or-decorator). |
| --skip-rule (**Deprecated**) | [string] | Ignore certain rules. See the [Skip preprocessor, rule, or decorator section](#skip-preprocessor-rule-or-decorator). |
| --version | boolean | Show version number. |
| Option | Type | Description |
| -------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| apis | [string] | List of API description root filenames or names assigned in the `apis` section of your Redocly configuration file. Default values are all names defined in the `apis` section within your configuration file. |
| --config | string | Specify path to the [config file](#custom-configuration-file). |
| --dereferenced, -d | boolean | Generate fully dereferenced bundle. |
| --ext | string | Specify bundled file extension. Possible values are `json`, `yaml`, or `yml`. Default value is `yaml`. |
| --extends | [string] | Can be used in combination with `--lint` to [extend a specific configuration](./lint.md#extend-configuration). Default values are taken from the Redocly configuration file. |
| --force, -f | boolean | Generate bundle output even when errors occur. |
| --help | boolean | Show help. |
| --keep-url-references, -k | boolean | Keep absolute url references. |
| --lint-config | string | Specify the severity level for the configuration file. <br/> **Possible values:** `warn`, `error`, `off`. Default value is `warn`. |
| --metafile | string | Path for the bundle metadata file. |
| --output, -o | string | Name or folder for the bundle file. If you don't specify the file extension, `.yaml` is used by default. If the specified folder doesn't exist, it's created automatically. **If the file specified as the bundler's output already exists, it's overwritten.** |
| --remove-unused-components | boolean | Remove unused components from the `bundle` output. |
| --skip-decorator | [string] | Ignore certain decorators. See the [Skip preprocessor, rule, or decorator section](#skip-preprocessor-rule-or-decorator). |
| --skip-preprocessor | [string] | Ignore certain preprocessors. See the [Skip preprocessor, rule, or decorator section](#skip-preprocessor-rule-or-decorator). |
| --version | boolean | Show version number. |
## Examples
@@ -100,13 +91,6 @@ You may want to skip specific preprocessors, rules, or decorators upon running t
redocly bundle --skip-preprocessor=discriminator-mapping-to-one-of --skip-preprocessor=another-example
```
{% /tab %}
{% tab label="Skip rules" %}
```bash
redocly bundle --skip-rule=no-sibling-refs --skip-rule=no-parent-tags
```
{% /tab %}
{% tab label="Skip decorators" %}

View File

@@ -59,7 +59,6 @@ additionalProperties:
Change the severity level of any rules in your extended configurations.
Some rules may also receive additional configurations.
Rules run during the `lint` command after preprocessors.
They run during the `bundle` command between preprocessors and decorators if the `--lint` option is used.
additionalProperties:
description: >-
List each rule by name.

View File

@@ -97,7 +97,6 @@ properties:
Change the severity level of any rules in your extended configurations.
Some rules may also receive additional configurations.
Rules run during the `lint` command after preprocessors.
They run during the `bundle` command between preprocessors and decorators if the `--lint` option is used.
additionalProperties:
description: >-
List each rule by name.
@@ -197,7 +196,6 @@ properties:
Change the severity level of any rules in your extended configurations.
Some rules may also receive additional configurations.
Rules run during the `lint` command after preprocessors.
They run during the `bundle` command between preprocessors and decorators if the `--lint` option is used.
additionalProperties:
description: >-
List each rule by name.

View File

@@ -27,19 +27,6 @@ Custom plugins can extend the built-in functionality of Redocly in the following
- **Write custom decorators in JavaScript**. Not all API descriptions are exactly as we'd like them to be before passing them to the next stage of the API lifecycle. Redocly has a selection of [decorators available](../decorators), but if you need to build something more then [visit the documentation for building decorators in custom plugins](./custom-decorators.md).
### Order of execution
Some commands, such as using `bundle` with `--lint`, may execute more than one type of functionality. The order is preprocessors first, then linting rules, and finally the decorators are applied.
```mermaid
graph LR
A(1. preprocessors) ==> B(2. rules)
B ==> V(3. decorators)
style A fill:#codaf9,stroke:#0044d4,stroke-width:4px
style B fill:#codaf9,stroke:#0044d4,stroke-width:4px
style V fill:#codaf9,stroke:#0044d4,stroke-width:4px
```
## Add custom plugins to your project
Each plugin can contain any or many of each type of extension (rules, configuration, decorators, etc).

View File

@@ -39,10 +39,6 @@ redocly bundle openapi.yaml -o bundled.yaml
All the references are brought into a single file, that you can then pass on to other tools in your API workflow.
{% admonition type="info" %}
Pass `--lint` to the bundle command to have Redocly CLI check your API meets the expected standards before bundling. [Learn more about API standards and linting](./api-standards.md)
{% /admonition %}
## Combine OpenAPI files
{% admonition type="warning" %}

View File

@@ -1,4 +1,4 @@
import { lint, bundle, getTotals, getMergedConfig } from '@redocly/openapi-core';
import { bundle, getTotals, getMergedConfig } from '@redocly/openapi-core';
import { BundleOptions, handleBundle } from '../../commands/bundle';
import { handleError } from '../../utils/miscellaneous';
@@ -25,21 +25,18 @@ describe('bundle', () => {
});
afterEach(() => {
(lint as jest.Mock).mockClear();
(bundle as jest.Mock).mockClear();
(getTotals as jest.Mock).mockReset();
});
it('bundles definitions w/o linting', async () => {
it('bundles definitions', async () => {
const apis = ['foo.yaml', 'bar.yaml'];
await commandWrapper(handleBundle)({
apis,
ext: 'yaml',
format: 'codeframe',
} as Arguments<BundleOptions>);
expect(lint).toBeCalledTimes(0);
expect(bundle).toBeCalledTimes(apis.length);
});
@@ -49,48 +46,25 @@ describe('bundle', () => {
await commandWrapper(handleBundle)({
apis,
ext: 'yaml',
format: 'codeframe',
} as Arguments<BundleOptions>);
await exitCb?.();
expect(processExitMock).toHaveBeenCalledWith(0);
});
it('bundles definitions w/ linting', async () => {
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
(getTotals as jest.Mock).mockReturnValue({
errors: 0,
warnings: 0,
ignored: 0,
});
await commandWrapper(handleBundle)({
apis,
ext: 'yaml',
format: 'codeframe',
lint: true,
} as Arguments<BundleOptions>);
expect(lint).toBeCalledTimes(apis.length);
expect(bundle).toBeCalledTimes(apis.length);
});
it('exits with code 0 when bundles definitions w/linting w/o errors', async () => {
it('exits with code 0 when bundles definitions w/o errors', async () => {
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
await commandWrapper(handleBundle)({
apis,
ext: 'yaml',
format: 'codeframe',
lint: true,
} as Arguments<BundleOptions>);
await exitCb?.();
expect(processExitMock).toHaveBeenCalledWith(0);
});
it('exits with code 1 when bundles definitions w/linting w/errors', async () => {
it('exits with code 1 when bundles definitions w/errors', async () => {
const apis = ['foo.yaml'];
(getTotals as jest.Mock).mockReturnValue({
@@ -102,11 +76,8 @@ describe('bundle', () => {
await commandWrapper(handleBundle)({
apis,
ext: 'yaml',
format: 'codeframe',
lint: true,
} as Arguments<BundleOptions>);
expect(lint).toBeCalledTimes(apis.length);
await exitCb?.();
expect(processExitMock).toHaveBeenCalledWith(1);
});
@@ -121,8 +92,6 @@ describe('bundle', () => {
await commandWrapper(handleBundle)({
apis,
ext: 'json',
format: 'codeframe',
lint: false,
} as Arguments<BundleOptions>);
expect(handleError).toHaveBeenCalledTimes(1);
@@ -141,8 +110,6 @@ describe('bundle', () => {
await commandWrapper(handleBundle)({
apis,
ext: 'yaml',
format: 'codeframe',
lint: false,
} as Arguments<BundleOptions>);
expect(handleError).toHaveBeenCalledTimes(0);

View File

@@ -1,12 +1,4 @@
import {
formatProblems,
getTotals,
getMergedConfig,
lint,
bundle,
Config,
OutputFormat,
} from '@redocly/openapi-core';
import { formatProblems, getTotals, getMergedConfig, bundle, Config } from '@redocly/openapi-core';
import {
dumpBundle,
getExecutionTime,
@@ -15,8 +7,6 @@ import {
handleError,
printUnusedWarnings,
saveBundle,
printLintTotals,
checkIfRulesetExist,
sortTopLevelKeysForOas,
} from '../utils/miscellaneous';
import type { OutputExtensions, Skips, Totals } from '../types';
@@ -27,15 +17,12 @@ import { checkForDeprecatedOptions } from '../utils/miscellaneous';
export type BundleOptions = {
apis?: string[];
'max-problems'?: number;
extends?: string[];
config?: string;
format?: OutputFormat;
output?: string;
ext: OutputExtensions;
dereferenced?: boolean;
force?: boolean;
lint?: boolean;
metafile?: string;
'remove-unused-components'?: boolean;
'keep-url-references'?: boolean;
@@ -47,14 +34,7 @@ export async function handleBundle(argv: BundleOptions, config: Config, version:
config.rawConfig?.styleguide?.decorators?.hasOwnProperty('remove-unused-components');
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',
];
const deprecatedOptions: Array<keyof BundleOptions> = [];
checkForDeprecatedOptions(argv, deprecatedOptions);
@@ -64,38 +44,9 @@ export async function handleBundle(argv: BundleOptions, config: Config, version:
const resolvedConfig = getMergedConfig(config, alias);
const { styleguide } = resolvedConfig;
styleguide.skipRules(argv['skip-rule']);
styleguide.skipPreprocessors(argv['skip-preprocessor']);
styleguide.skipDecorators(argv['skip-decorator']);
if (argv.lint) {
checkIfRulesetExist(styleguide.rules);
if (config.styleguide.recommendedFallback) {
process.stderr.write(
`No configurations were provided -- using built in ${blue(
'recommended'
)} configuration by default.\n\n`
);
}
const results = await lint({
ref: path,
config: resolvedConfig,
});
const fileLintTotals = getTotals(results);
totals.errors += fileLintTotals.errors;
totals.warnings += fileLintTotals.warnings;
totals.ignored += fileLintTotals.ignored;
formatProblems(results, {
format: argv.format || 'codeframe',
totals: fileLintTotals,
version,
maxProblems: maxProblems,
});
printLintTotals(fileLintTotals, 2);
}
process.stderr.write(gray(`bundling ${path}...\n`));
const {
@@ -132,8 +83,7 @@ export async function handleBundle(argv: BundleOptions, config: Config, version:
totals.ignored += fileTotals.ignored;
formatProblems(problems, {
format: argv.format || 'codeframe',
maxProblems: maxProblems,
format: 'codeframe',
totals: fileTotals,
version,
});

View File

@@ -2,6 +2,7 @@
import './utils/assert-node-version';
import * as yargs from 'yargs';
import * as colors from 'colorette';
import { outputExtensions, PushArguments, regionChoices } from './types';
import { RedoclyClient } from '@redocly/openapi-core';
import { previewDocs } from './commands/preview-docs';
@@ -416,28 +417,11 @@ yargs
description: 'Output file.',
alias: 'o',
},
format: {
description: 'Use a specific output format.',
choices: ['stylish', 'codeframe', 'json', 'checkstyle'] as ReadonlyArray<OutputFormat>,
hidden: true,
},
'max-problems': {
requiresArg: true,
description: 'Reduce output to a maximum of N problems.',
type: 'number',
hidden: true,
},
ext: {
description: 'Bundle file extension.',
requiresArg: true,
choices: outputExtensions,
},
'skip-rule': {
description: 'Ignore certain rules.',
array: true,
type: 'string',
hidden: true,
},
'skip-preprocessor': {
description: 'Ignore certain preprocessors.',
array: true,
@@ -462,12 +446,6 @@ yargs
description: 'Path to the config file.',
type: 'string',
},
lint: {
description: 'Lint API descriptions',
type: 'boolean',
default: false,
hidden: true,
},
metafile: {
description: 'Produce metadata about the bundle',
type: 'string',
@@ -494,8 +472,43 @@ yargs
choices: ['warn', 'error', 'off'] as ReadonlyArray<RuleSeverity>,
default: 'warn' as RuleSeverity,
},
format: {
hidden: true,
deprecated: true,
},
lint: {
hidden: true,
deprecated: true,
},
'skip-rule': {
hidden: true,
deprecated: true,
array: true,
type: 'string',
},
'max-problems': {
hidden: true,
deprecated: true,
},
}),
(argv) => {
const DEPRECATED_OPTIONS = ['lint', 'format', 'skip-rule', 'max-problems'];
const LINT_AND_BUNDLE_DOCUMENTATION_LINK =
'https://redocly.com/docs/cli/guides/lint-and-bundle/#lint-and-bundle-api-descriptions-with-redocly-cli';
DEPRECATED_OPTIONS.forEach((option) => {
if (argv[option]) {
process.stdout.write(
`${colors.red(
`Option --${option} is no longer supported. Please use separate commands, as described in the ${LINT_AND_BUNDLE_DOCUMENTATION_LINK}.`
)}`
);
process.stdout.write('\n\n');
yargs.showHelp();
process.exit(1);
}
});
process.env.REDOCLY_CLI_COMMAND = 'bundle';
commandWrapper(handleBundle)(argv);
}