Redocly / redocly-cli

βš’οΈ Redocly CLI makes OpenAPI easy. Lint/validate to any standard, generate beautiful docs, and more.
https://redocly.com/docs/cli/
MIT License
852 stars 129 forks source link

fix: fix issues with https-agent-proxy for cli and openapi-core packages #1493

Closed malis42 closed 2 weeks ago

malis42 commented 3 months ago

What/Why/How?

Adding https-proxy-agent package to fix issues with requests when using CLI behind proxy. Create better mechanism for handling env.REDOCLY_DOMAIN usage in few modules.

Now if you need to run the CLI tool behind a proxy, you can use the HTTP_PROXY and HTTPS_PROXY environment variables to configure the proxy settings.

https-proxy-agent package was used for node-fetch requests. Now we pass agent for every fetchWithTimeout request, as well as other regular fetch request.

After encountering problems with some of the packages from https-proxy-agent dependencies, we had to ignore this package for browser environment, by modyfing packages/core/package.json like so:

  "browser": {
    "https-proxy-agent": false
  },

This is 3rd attempt to release this fix after previous two were reverted: https://github.com/Redocly/redocly-cli/pull/1461 and https://github.com/Redocly/redocly-cli/pull/1433

Reference

Reverts Redocly/redocly-cli#1468

Resolves https://github.com/Redocly/redocly-cli/issues/1404 Fixes https://github.com/Redocly/redocly-cli/issues/529 Fixes https://github.com/Redocly/redocly-cli/issues/1146 Resolves https://github.com/Redocly/redocly-cli/pull/1433

Testing

Fixed unit tests. Tested with few CLI commands: push, lint etc.

Screenshots (optional)

n/a

Has code been changed?

Yes

Check yourself

Security

changeset-bot[bot] commented 3 months ago

πŸ¦‹ Changeset detected

Latest commit: 68a3f637bb03a3b6d0dde0bdb8f29a56aecd3e99

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | --------------------- | ----- | | @redocly/openapi-core | Minor | | @redocly/cli | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

github-actions[bot] commented 3 months ago
Command Mean [s] Min [s] Max [s] Relative
redocly lint packages/core/src/benchmark/benches/rebilly.yaml 1.003 Β± 0.048 0.969 1.135 1.01 Β± 0.05
redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml 0.990 Β± 0.016 0.971 1.025 1.00
github-actions[bot] commented 3 months ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟑 Statements 77.25% 4499/5824
🟑 Branches 67.5% 2478/3671
🟑 Functions 70.9% 748/1055
🟑 Lines 77.45% 4234/5467
Show new covered files 🐣
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------- | :--------- | :------- | :-------- | :---- | | 🟒 |
`...` / domains.ts
| 100% | 76.92% | 100% | 100% |
Show files with reduced coverage πŸ”»
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------- | | 🟑 |
`...` / config.ts
| 70.32% |
77.3% (+1.11% πŸ”Ό)
|
67.86% (-1.11% πŸ”»)
| 70% | | 🟑 |
`...` / index.ts
|
62.12% (-3.16% πŸ”»)
|
64.29% (-4.29% πŸ”»)
|
69.57% (-1.27% πŸ”»)
|
62.12% (-3.16% πŸ”»)
| | 🟑 |
`...` / push.ts
| 73.53% | 68.46% | 54.55% | 75.93% | | 🟑 |
`...` / api-client.ts
|
75.44% (-4.56% πŸ”»)
|
41.38% (-4.77% πŸ”»)
| 75% |
74.55% (-4.62% πŸ”»)
|

Test suite run success

747 tests passing in 105 suites.

Report generated by πŸ§ͺjest coverage report action from 68a3f637bb03a3b6d0dde0bdb8f29a56aecd3e99