@pnpm/deps.compliance.sbom 1100.0.2 → 1100.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { type PackageSnapshot } from '@pnpm/lockfile.utils';
2
2
  import type { StoreIndex } from '@pnpm/store.index';
3
- import type { Registries } from '@pnpm/types';
3
+ import type { DepPath, Registries } from '@pnpm/types';
4
4
  export interface PkgMetadata {
5
5
  license?: string;
6
6
  description?: string;
@@ -14,4 +14,4 @@ export interface GetPkgMetadataOptions {
14
14
  lockfileDir: string;
15
15
  virtualStoreDirMaxLength: number;
16
16
  }
17
- export declare function getPkgMetadata(depPath: string, snapshot: PackageSnapshot, registries: Registries, opts: GetPkgMetadataOptions): Promise<PkgMetadata>;
17
+ export declare function getPkgMetadata(depPath: DepPath, snapshot: PackageSnapshot, registries: Registries, opts: GetPkgMetadataOptions): Promise<PkgMetadata>;
@@ -1,4 +1,5 @@
1
- import { pkgSnapshotToResolution } from '@pnpm/lockfile.utils';
1
+ import { isSpdxLicenseExpression, resolveLicense } from '@pnpm/deps.compliance.license-resolver';
2
+ import { packageIdFromSnapshot, pkgSnapshotToResolution } from '@pnpm/lockfile.utils';
2
3
  import { readPackageJson } from '@pnpm/pkg-manifest.reader';
3
4
  import { readPackageFileMap } from '@pnpm/store.pkg-finder';
4
5
  import pLimit from 'p-limit';
@@ -7,7 +8,7 @@ export async function getPkgMetadata(depPath, snapshot, registries, opts) {
7
8
  return limitMetadataReads(() => getPkgMetadataUnclamped(depPath, snapshot, registries, opts));
8
9
  }
9
10
  async function getPkgMetadataUnclamped(depPath, snapshot, registries, opts) {
10
- const id = snapshot.id ?? depPath;
11
+ const id = packageIdFromSnapshot(depPath, snapshot);
11
12
  const resolution = pkgSnapshotToResolution(depPath, snapshot, registries);
12
13
  let files;
13
14
  try {
@@ -23,30 +24,29 @@ async function getPkgMetadataUnclamped(depPath, snapshot, registries, opts) {
23
24
  if (!manifestPath)
24
25
  return {};
25
26
  const manifest = await readPackageJson(manifestPath);
26
- return extractMetadata(manifest);
27
+ return extractMetadata(manifest, files);
27
28
  }
28
- function extractMetadata(manifest) {
29
+ async function extractMetadata(manifest, files) {
30
+ const license = await resolveLicense({ manifest, files });
29
31
  return {
30
- license: parseLicenseField(manifest.license),
32
+ license: serializableLicense(license),
31
33
  description: manifest.description,
32
34
  author: parseAuthorField(manifest.author),
33
35
  homepage: manifest.homepage,
34
36
  repository: parseRepositoryField(manifest.repository),
35
37
  };
36
38
  }
37
- function parseLicenseField(field) {
38
- if (typeof field === 'string')
39
- return field;
40
- if (field && typeof field === 'object' && 'type' in field) {
41
- return field.type;
42
- }
43
- if (Array.isArray(field)) {
44
- return field
45
- .map((l) => l.type)
46
- .filter(Boolean)
47
- .join(' OR ') || undefined;
48
- }
49
- return undefined;
39
+ // Drop:
40
+ // - missing / "Unknown" — so serializers emit NOASSERTION / absence.
41
+ // - LICENSE-file-detected values that aren't SPDX-valid (e.g. "Eclipse Public
42
+ // License 1.0") would produce non-compliant SPDX output. Manifest-declared
43
+ // licenses are trusted as-is; authors use SPDX expressions there.
44
+ function serializableLicense(license) {
45
+ if (!license || license.name === 'Unknown')
46
+ return undefined;
47
+ if (license.licenseFile && !isSpdxLicenseExpression(license.name))
48
+ return undefined;
49
+ return license.name;
50
50
  }
51
51
  function parseAuthorField(field) {
52
52
  if (!field)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/deps.compliance.sbom",
3
- "version": "1100.0.2",
3
+ "version": "1100.0.3",
4
4
  "description": "Generate SBOM from pnpm lockfile",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -30,14 +30,15 @@
30
30
  "@cyclonedx/cyclonedx-library": "10.0.0",
31
31
  "p-limit": "^7.1.0",
32
32
  "ssri": "13.0.1",
33
- "@pnpm/lockfile.detect-dep-types": "1100.0.1",
34
- "@pnpm/lockfile.types": "1100.0.1",
35
- "@pnpm/lockfile.utils": "1100.0.1",
36
- "@pnpm/lockfile.walker": "1100.0.1",
33
+ "@pnpm/deps.compliance.license-resolver": "1100.0.0",
34
+ "@pnpm/lockfile.detect-dep-types": "1100.0.2",
35
+ "@pnpm/lockfile.utils": "1100.0.2",
36
+ "@pnpm/lockfile.walker": "1100.0.2",
37
+ "@pnpm/lockfile.types": "1100.0.2",
37
38
  "@pnpm/pkg-manifest.reader": "1100.0.1",
38
- "@pnpm/store.index": "1100.0.0",
39
- "@pnpm/store.pkg-finder": "1100.0.2",
40
- "@pnpm/types": "1101.0.0"
39
+ "@pnpm/store.pkg-finder": "1100.0.3",
40
+ "@pnpm/types": "1101.0.0",
41
+ "@pnpm/store.index": "1100.0.0"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "@pnpm/logger": ">=1001.0.0 <1002.0.0"
@@ -45,8 +46,9 @@
45
46
  "devDependencies": {
46
47
  "@jest/globals": "30.3.0",
47
48
  "@types/ssri": "^7.1.5",
48
- "@pnpm/deps.compliance.sbom": "1100.0.2",
49
- "@pnpm/logger": "1100.0.0"
49
+ "@pnpm/deps.compliance.sbom": "1100.0.3",
50
+ "@pnpm/logger": "1100.0.0",
51
+ "@pnpm/store.cafs": "1100.0.2"
50
52
  },
51
53
  "engines": {
52
54
  "node": ">=22.13"