Skip to content

Commit 2295c7f

Browse files
Merge pull request #3779 from nexB/improve-npm-support
Resolve dependencies and improve JS support
2 parents c79da3f + 8f932da commit 2295c7f

File tree

1,210 files changed

+68721
-3927
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,210 files changed

+68721
-3927
lines changed

CHANGELOG.rst

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ v33.0.0 (next next, roadmap)
3434
of these in other summary plugins.
3535
See https://github.com/nexB/scancode-toolkit/issues/1745
3636

37+
v32.2.0 - (next, roadmap)
38+
-------------------------
39+
40+
- New and improved package/dependency data:
41+
- Added new attribute in DependentPackage `is_direct` to aid
42+
package resolution and dependency graph creation.
43+
- Added new attributes in PackageData: `is_private` and
44+
`is_virtual`. #3102 #3811
45+
https://github.com/nexB/scancode-toolkit/pull/3779
46+
47+
- Improved javascript package detection:
48+
- Add support for pnpm manifests and lockfiles #3766
49+
- Add support for npm, pnpm and yarn workspaces #3746
50+
- Improve resolved package and dependencies support in lockfiles for
51+
yarn.lock, package-lock.json, and pnpm. #3780
52+
- Add support for private packages. #3120
53+
- Add support for new dependency scopes across javascript
54+
- Lots of misc bugfixes in yarn and npm parsers.
55+
https://github.com/nexB/scancode-toolkit/pull/3779
56+
3757
- Improve cargo package detection support with various improvements
3858
and bugfixes:
3959
- Fix for parser crashing on cargo workspaces
@@ -43,14 +63,10 @@ v33.0.0 (next next, roadmap)
4363
- Better handle workspace data thorugh extra_data attribute
4464
See https://github.com/nexB/scancode-toolkit/pull/3783
4565

46-
- We now support parsing the Swift manifest JSON dump and the ``Package.resolved`` file https://github.com/nexB/scancode-toolkit/issues/2657.
47-
- Run the commands below on your local Swift project before running the scan.
48-
- ::
49-
50-
swift package dump-package > Package.swift.json
51-
- ::
52-
53-
swift package resolve
66+
- We now support parsing the Swift manifest JSON dump and the
67+
``Package.resolved`` file https://github.com/nexB/scancode-toolkit/issues/2657.
68+
Run the command below on your local Swift project before running the scan:
69+
`swift package dump-package > Package.swift.json && swift package resolve``
5470

5571
- New and updated licenses, including support for newly released
5672
SPDX license list versions:

docs/source/reference/available_package_parsers.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,24 @@ parsers in scancode-toolkit during documentation builds.
539539
- ``npm_shrinkwrap_json``
540540
- JavaScript
541541
- https://docs.npmjs.com/cli/v8/configuring-npm/npm-shrinkwrap-json
542+
* - pnpm pnpm-lock.yaml lockfile
543+
- ``*/pnpm-lock.yaml``
544+
- ``npm``
545+
- ``pnpm_lock_yaml``
546+
- JavaScript
547+
- https://github.com/pnpm/spec/blob/master/lockfile/6.0.md
548+
* - pnpm shrinkwrap.yaml lockfile
549+
- ``*/shrinkwrap.yaml``
550+
- ``npm``
551+
- ``pnpm_shrinkwrap_yaml``
552+
- JavaScript
553+
- https://github.com/pnpm/spec/blob/master/lockfile/4.md
554+
* - pnpm workspace yaml file
555+
- ``*/pnpm-workspace.yaml``
556+
- ``npm``
557+
- ``pnpm_workspace_yaml``
558+
- JavaScript
559+
- https://pnpm.io/pnpm-workspace_yaml
542560
* - yarn.lock lockfile v1 format
543561
- ``*/yarn.lock``
544562
- ``npm``
@@ -748,7 +766,7 @@ parsers in scancode-toolkit during documentation builds.
748766
- ``squashfs_disk_image``
749767
- None
750768
- https://en.wikipedia.org/wiki/SquashFS
751-
* - JSON dump of Package.swift created with ``swift package dump-package > Package.swift.json``
769+
* - JSON dump of Package.swift created with ``swift package dump-package > Package.swift.json``
752770
- ``*/Package.swift.json``
753771
- ``swift``
754772
- ``swift_package_manifest_json``

src/packagedcode/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
npm.NpmShrinkwrapJsonHandler,
151151
npm.YarnLockV1Handler,
152152
npm.YarnLockV2Handler,
153+
npm.PnpmShrinkwrapYamlHandler,
154+
npm.PnpmLockYamlHandler,
155+
npm.PnpmWorkspaceYamlHandler,
153156

154157
nuget.NugetNupkgHandler,
155158
nuget.NugetNuspecHandler,

src/packagedcode/bower.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ def parse(cls, location, package_only=False):
2929
with io.open(location, encoding='utf-8') as loc:
3030
package_data = json.load(loc)
3131

32-
# note: having no name is not a problem for private packages. See #1514
3332
name = package_data.get('name')
33+
is_private = False
34+
if not name:
35+
is_private = True
3436

3537
description = package_data.get('description')
3638
version = package_data.get('version')
@@ -99,5 +101,6 @@ def parse(cls, location, package_only=False):
99101
homepage_url=homepage_url,
100102
vcs_url=vcs_url,
101103
dependencies=dependencies,
104+
is_private=is_private,
102105
)
103106
yield models.PackageData.from_data(package_data, package_only)

src/packagedcode/models.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,15 @@ class DependentPackage(ModelMixin):
371371
'been resolved and this dependency url points to an '
372372
'exact version.')
373373

374+
is_direct = Boolean(
375+
default=True,
376+
label='is direct flag',
377+
help='True if this is a direct, first-level dependency, '
378+
'defined in the manifest of a package. False if this '
379+
'is an indirect, transitive dependency resolved from '
380+
'first level dependencies.'
381+
)
382+
374383
resolved_package = Mapping(
375384
label='resolved package data',
376385
help='A mapping of resolved package data for this dependent package, '
@@ -682,6 +691,24 @@ class PackageData(IdentifiablePackageData):
682691
'package type or datafile format.'
683692
)
684693

694+
is_private = Boolean(
695+
default=False,
696+
label='is private flag',
697+
help='True if this is a private package, either not meant to be '
698+
'published on a repository, and/or a local package without a '
699+
'name and version used primarily to track dependencies and '
700+
'other information, and build this package, for instance with '
701+
'JavaScript and PHP applications.'
702+
)
703+
704+
is_virtual = Boolean(
705+
default=False,
706+
label='is virtual flag',
707+
help='True if this package is created only from a manifest or lockfile, '
708+
'and not from its actual packaged code. The files of this package '
709+
'are not present in the codebase.'
710+
)
711+
685712
extra_data = Mapping(
686713
label='extra data',
687714
help='A mapping of arbitrary extra package data.',
@@ -1026,6 +1053,9 @@ class DatafileHandler:
10261053
# Informational: Default primary language for this parser.
10271054
default_primary_language = None
10281055

1056+
# If the datafilehandler contains only resolved dependencies
1057+
is_lockfile = False
1058+
10291059
# Informational: Description of this parser
10301060
description = None
10311061

0 commit comments

Comments
 (0)