Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add description field to output to licenses command output #5836

Merged
merged 4 commits into from Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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