Skip to content

Commit

Permalink
chore: add comments/docs for pnpm lockfile fields (#2060)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard authored Jan 12, 2025
1 parent ceb4e7f commit fd4ef5a
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion npm/private/pnpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,38 @@ def _new_import_info(dependencies, dev_dependencies, optional_dependencies):
#
# Metadata may come from different locations depending on the lockfile, this struct should
# have data normalized across lockfiles.
#
# Args:
# id: a "universal identifier of the package" only present when the id is not the same as the key
# Normally present when the package is an odd version (such as file: or link: package) while
# also having peer dependencies in the key.
#
# Removed in lockfile v9+ where snapshots/packages are separate.
#
# See https://github.com/pnpm/spec/blob/master/lockfile/6.0.md#packagesdependencypathid
#
# name:
# version:
# dependencies:
# optional_dependencies:
# friendly_version:
#
# dev_only: True if the package is exclusively a dev dependency throughout the workspace
# Removed in lockfile v9+
# See https://github.com/pnpm/spec/blob/master/lockfile/6.0.md#packagesdependencypathdev
#
# has_bin: True if the package has binaries
# See https://github.com/pnpm/spec/blob/master/lockfile/9.0.md#packagesdependencyidhasbin
#
# optional: True if the package is exclusively an optional dependency throughout the workspace
# TODO: Removed in lockfile v9+?
# See https://github.com/pnpm/spec/blob/master/lockfile/6.0.md#packagesdependencypathoptional
#
# requires_build: True if pnpm predicted the package requires a build step
# Removed in lockfile v9+
# See https://github.com/pnpm/spec/blob/master/lockfile/6.0.md#packagesdependencypathrequiresbuild
#
# resolution: the lockfile resolution field
def _new_package_info(id, name, dependencies, optional_dependencies, dev_only, has_bin, optional, requires_build, version, friendly_version, resolution):
return {
"id": id,
Expand Down Expand Up @@ -486,7 +518,7 @@ def _convert_v9_packages(packages, snapshots):
friendly_version = package_data["version"] if "version" in package_data else static_key[version_index + 1:]

package_info = _new_package_info(
id = package_data.get("id", None), # TODO: does v9 have "id"?
id = None, # pnpm v9+ no longer requires an id field
name = name,
version = version,
friendly_version = friendly_version,
Expand Down

0 comments on commit fd4ef5a

Please sign in to comment.