Skip to content

Commit

Permalink
feat: make portal-client dependency optional
Browse files Browse the repository at this point in the history
  • Loading branch information
hanna-skryl committed Oct 14, 2024
1 parent 88b7fcd commit ebb2469
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
46 changes: 20 additions & 26 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,6 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p
```

</details>
<details>
<summary>Installing without optional dependencies</summary>

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.
</details>

2. Create a `code-pushup.config.ts` configuration file (`.js` or `.mjs` extensions are also supported).

Expand Down Expand Up @@ -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.
<details>
<summary>Installation command for <code>npm</code>, <code>yarn</code> and <code>pnpm</code></summary>
```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
```
</details>
Once the package is installed, update your configuration file to include your portal credentials:
```ts
const config: CoreConfig = {
Expand Down
7 changes: 6 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
2 changes: 1 addition & 1 deletion packages/core/src/lib/load-portal-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function loadPortalClient(): Promise<
return await import('@code-pushup/portal-client');
} catch {

Check failure on line 8 in packages/core/src/lib/load-portal-client.ts

View workflow job for this annotation

GitHub Actions / Code PushUp

<✓> Code coverage | Branch coverage

1st branch is not taken in any test case.
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;
}

Check warning on line 13 in packages/core/src/lib/load-portal-client.ts

View workflow job for this annotation

GitHub Actions / Code PushUp

<✓> Code coverage | Line coverage

Lines 9-13 are not covered in any test case.
Expand Down

0 comments on commit ebb2469

Please sign in to comment.