From ebb2469ff380387a8ba2ab762600a1a60acce067 Mon Sep 17 00:00:00 2001 From: hanna-skryl Date: Mon, 14 Oct 2024 12:26:28 -0400 Subject: [PATCH] feat: make portal-client dependency optional --- packages/cli/README.md | 46 +++++++++------------ packages/core/package.json | 7 +++- packages/core/src/lib/load-portal-client.ts | 2 +- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index 86af08a0e..d68c65d75 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -44,31 +44,6 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p ``` -
- Installing without optional dependencies - - To avoid installing optional dependencies like `@code-pushup/portal-client`, use the commands below. Please note that omitting this dependency will limit the upload functionality. - - **npm** - - ```sh - npm install @code-pushup/cli --omit=dev --omit=optional - ``` - - **pnpm** - - `pnpm` requires reinstalling all packages to skip optional dependencies. The `--no-optional` flag applies globally, omitting all optional dependencies across the workspace. For more granular control, you can customize dependency behavior using a [`.pnpmfile.cjs`](https://pnpm.io/pnpmfile) configuration file. - - ```sh - pnpm add --save-dev @code-pushup/cli - rm -rf pnpm-lock.yaml node_modules - pnpm install --no-optional - ``` - - **yarn** - - `yarn` does not support omitting optional dependencies. -
2. Create a `code-pushup.config.ts` configuration file (`.js` or `.mjs` extensions are also supported). @@ -143,7 +118,26 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p ## Portal integration -If you have access to the Code PushUp portal, provide credentials in order to upload reports. +If you have access to the Code PushUp portal, you can enable report uploads by installing the `@code-pushup/portal-client` package. + +
+Installation command for npm, yarn and pnpm + +```sh +npm install --save-dev @code-pushup/portal-client +``` + +```sh +yarn add --dev @code-pushup/portal-client +``` + +```sh +pnpm add --save-dev @code-pushup/portal-client +``` + +
+ +Once the package is installed, update your configuration file to include your portal credentials: ```ts const config: CoreConfig = { diff --git a/packages/core/package.json b/packages/core/package.json index af8e630b9..b13d39e97 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -8,7 +8,12 @@ "@code-pushup/utils": "0.51.0", "ansis": "^3.3.0" }, - "optionalDependencies": { + "peerDependencies": { "@code-pushup/portal-client": "^0.9.0" + }, + "peerDependenciesMeta": { + "@code-pushup/portal-client": { + "optional": true + } } } diff --git a/packages/core/src/lib/load-portal-client.ts b/packages/core/src/lib/load-portal-client.ts index 2cd2a3840..2010b22f9 100644 --- a/packages/core/src/lib/load-portal-client.ts +++ b/packages/core/src/lib/load-portal-client.ts @@ -7,7 +7,7 @@ export async function loadPortalClient(): Promise< return await import('@code-pushup/portal-client'); } catch { ui().logger.error( - 'Optional dependency @code-pushup/portal-client is not available. Make sure it is installed to enable upload functionality.', + 'Optional peer dependency @code-pushup/portal-client is not available. Make sure it is installed to enable upload functionality.', ); return null; }