Skip to content

Commit

Permalink
feat: add description field to output to licenses command output (#5836)
Browse files Browse the repository at this point in the history
Add the `description`-field to the output of the `licenses list`-command so that
for each package the description in the package manifest gets listed too
  • Loading branch information
weyert committed Dec 25, 2022
1 parent 339c0a7 commit 1d3995f
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 47 deletions.
7 changes: 7 additions & 0 deletions .changeset/chilly-flies-bow.md
@@ -0,0 +1,7 @@
---
"pnpm": minor
"@pnpm/license-scanner": patch
"@pnpm/plugin-commands-licenses": patch
---

Add the 'description'-field to the licenses output [#5836](https://github.com/pnpm/pnpm/pull/5836).
2 changes: 2 additions & 0 deletions reviewing/license-scanner/src/licenses.ts
Expand Up @@ -19,6 +19,7 @@ export interface LicensePackage {
licenseContents?: string
author?: string
homepage?: string
description?: string
repository?: string
path?: string
}
Expand Down Expand Up @@ -52,6 +53,7 @@ function getDependenciesFromLicenseNode (
licenseContents: dependencyNode.licenseContents,
author: dependencyNode.author as string,
homepage: dependencyNode.homepage as string,
description: dependencyNode.description,
repository: dependencyNode.repository as string,
path: dependencyNode.dir,
},
Expand Down
2 changes: 2 additions & 0 deletions reviewing/license-scanner/src/lockfileToLicenseNodeTree.ts
Expand Up @@ -17,6 +17,7 @@ export interface LicenseNode {
dir: string
author?: string
homepage?: string
description?: string
repository?: string
integrity?: string
requires?: Record<string, string>
Expand Down Expand Up @@ -90,6 +91,7 @@ export async function lockfileToLicenseNode (
licenseContents: packageInfo.licenseContents,
author: packageInfo.author,
homepage: packageInfo.homepage,
description: packageInfo.description,
repository: packageInfo.repository,
dir: packageInfo.path as string,
}
Expand Down
2 changes: 2 additions & 0 deletions reviewing/license-scanner/test/licenses.spec.ts
Expand Up @@ -76,6 +76,7 @@ describe('licences', () => {
expect(licensePackages).toEqual([
{
belongsTo: 'dependencies',
description: 'Package Description',
version: '1.0.0',
name: 'bar',
license: 'MIT',
Expand All @@ -87,6 +88,7 @@ describe('licences', () => {
},
{
belongsTo: 'dependencies',
description: 'Package Description',
version: '1.0.0',
name: 'foo',
license: 'Unknown',
Expand Down
4 changes: 4 additions & 0 deletions reviewing/plugin-commands-licenses/src/outputRenderer.ts
Expand Up @@ -35,6 +35,9 @@ function renderDetails (licensePackage: LicensePackage) {
if (licensePackage.author) {
outputs.push(licensePackage.author)
}
if (licensePackage.description) {
outputs.push(licensePackage.description)
}
if (licensePackage.homepage) {
outputs.push(chalk.underline(licensePackage.homepage))
}
Expand Down Expand Up @@ -63,6 +66,7 @@ function renderLicensesJson (licensePackages: readonly LicensePackage[]) {
licenseContents: licensePkg.licenseContents,
author: licensePkg.author,
homepage: licensePkg.homepage,
description: licensePkg.description,
} as LicensePackageJson
}),
].flat()
Expand Down
111 changes: 64 additions & 47 deletions reviewing/plugin-commands-licenses/test/__snapshots__/index.ts.snap

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions reviewing/plugin-commands-licenses/test/index.ts
Expand Up @@ -118,6 +118,7 @@ test('pnpm licenses: output as json', async () => {
'license',
'author',
'homepage',
'description',
])
expect(packagesWithMIT[0].name).toBe('is-positive')
})
Expand Down

0 comments on commit 1d3995f

Please sign in to comment.