Skip to content

Commit

Permalink
refactor(npm): remove use of pnpm <v9 id field
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jan 8, 2025
1 parent 08fe920 commit 66c41fc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
10 changes: 2 additions & 8 deletions npm/private/npm_translate_lock_generate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ sh_binary(
version = package_info.get("version")
deps = package_info.get("dependencies")
if version.startswith("file:"):
if version in packages and packages[version]["id"]:
dep_path = helpers.link_package(root_package, packages[version]["id"][len("file:"):])
else:
dep_path = helpers.link_package(root_package, version[len("file:"):])
dep_path = helpers.link_package(root_package, version[len("file:"):])
dep_key = "{}+{}".format(name, version)
transitive_deps = {}
for raw_package, raw_version in deps.items():
Expand Down Expand Up @@ -160,10 +157,7 @@ sh_binary(
link_package = helpers.link_package(root_package, import_path)
for dep_package, dep_version in dependencies.items():
if dep_version.startswith("file:"):
if dep_version in packages and packages[dep_version]["id"]:
dep_path = helpers.link_package(root_package, packages[dep_version]["id"][len("file:"):])
else:
dep_path = helpers.link_package(root_package, dep_version[len("file:"):])
dep_path = helpers.link_package(root_package, dep_version[len("file:"):])
dep_key = "{}+{}".format(dep_package, dep_version)
if not dep_key in fp_links.keys():
msg = "Expected to file: referenced package {} in first-party links".format(dep_key)
Expand Down
6 changes: 1 addition & 5 deletions npm/private/pnpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ 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.
def _new_package_info(id, name, dependencies, optional_dependencies, dev, has_bin, optional, requires_build, version, friendly_version, resolution):
def _new_package_info(name, dependencies, optional_dependencies, dev, has_bin, optional, requires_build, version, friendly_version, resolution):
return {
"id": id,
"name": name,
"dependencies": dependencies,
"optional_dependencies": optional_dependencies,
Expand Down Expand Up @@ -189,7 +188,6 @@ def _convert_v5_packages(packages):
package_key = _to_package_key(name, version)

package_info = _new_package_info(
id = package_snapshot.get("id", None),
name = name,
version = version,
friendly_version = friendly_version,
Expand Down Expand Up @@ -356,7 +354,6 @@ def _convert_v6_packages(packages):
package_key = _to_package_key(name, version)

package_info = _new_package_info(
id = package_snapshot.get("id", None),
name = name,
version = version,
friendly_version = friendly_version,
Expand Down Expand Up @@ -486,7 +483,6 @@ 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"?
name = name,
version = version,
friendly_version = friendly_version,
Expand Down
1 change: 0 additions & 1 deletion npm/private/test/parse_pnpm_lock_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ expected_importers = {
}
expected_packages = {
"@aspect-test/a@5.0.0": {
"id": None,
"name": "@aspect-test/a",
"dependencies": {
"@aspect-test/b": "5.0.0",
Expand Down

0 comments on commit 66c41fc

Please sign in to comment.