diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d2e20dd89a..c5993dfb35 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -196,6 +196,17 @@ To update snapshots, run `npm run e2e -- -u`. If you made any changes, make sure to compile the code before running the tests. +### Performance benchmark + +To run the performance benchmark locally, you should have `hyperfine` (v1.16.1+) installed on your machine. +Prepare the local build, go to the `benchmark` folder, clean it up, do the preparations, and run the actual benchmark: + +```sh +(npm run compile && npm run pack:prepare && cd benchmark/ && git clean -dX -f . && git clean -dX -ff . && npm i && npm run make-test && npm test) +``` + +You might need to adjust the CLI versions that need to be tested in the `benchmark/package.json` file. + ## Project structure - **`__mocks__`**: contains basic mocks for e2e tests. diff --git a/benchmark/package.json b/benchmark/package.json index d53e11b671..b55fd02756 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -36,7 +36,9 @@ "cli-1.25": "npm:@redocly/cli@1.25.15", "cli-1.26": "npm:@redocly/cli@1.26.1", "cli-1.27": "npm:@redocly/cli@1.27.2", - "cli-1.28": "npm:@redocly/cli@1.28.2", + "cli-1.28": "npm:@redocly/cli@1.28.5", + "cli-1.29": "npm:@redocly/cli@1.29.0", + "cli-1.30": "npm:@redocly/cli@1.30.0", "cli-next": "file:../redocly-cli.tgz" } } diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index f80b2c53fa..7cbe7d19f1 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -25,7 +25,6 @@ import { handleTranslations } from './commands/translations'; import { handleEject } from './commands/eject'; import { PRODUCT_PLANS } from './commands/preview-project/constants'; import { commonPushHandler } from './commands/push'; -import { handleRun } from '@redocly/respect-core'; import type { Arguments } from 'yargs'; import type { OutputFormat, RuleSeverity } from '@redocly/openapi-core'; @@ -34,7 +33,7 @@ import type { PushStatusOptions } from './reunite/commands/push-status'; import type { PushArguments } from './types'; import type { EjectOptions } from './commands/eject'; -dotenv.config({ path: path.resolve(__dirname, '../.env') }); +dotenv.config({ path: path.resolve(process.cwd(), './.env') }); if (!('replaceAll' in String.prototype)) { require('core-js/actual/string/replace-all'); @@ -938,8 +937,9 @@ yargs }, }); }, - (argv) => { + async (argv) => { process.env.REDOCLY_CLI_COMMAND = 'respect'; + const { handleRun } = await import('@redocly/respect-core'); commandWrapper(handleRun)(argv); } )