Skip to content

Commit

Permalink
fix(pnpm): npm aliases to url specifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed May 31, 2024
1 parent 57e9e69 commit 0594057
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion e2e/pnpm_lockfiles/lockfile-test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def lockfile_test(name = None):
# Odd git/http versions
":node_modules/debug",
":node_modules/hello",
# ":node_modules/jsonify", TODO: v9
":node_modules/jsonify",

# npm: alias
":node_modules/@aspect-test/a2",
Expand Down
5 changes: 4 additions & 1 deletion e2e/pnpm_lockfiles/v90/snapshots/defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions npm/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _convert_v5_v6_file_package(package_path, package_snapshot):
else:
friendly_version = package_snapshot["version"] if "version" in package_snapshot else version

return _to_package_key(name, version), name, version, friendly_version
return name, version, friendly_version

def _convert_v5_packages(packages):
result = {}
Expand All @@ -207,22 +207,22 @@ def _convert_v5_packages(packages):

if package_path.startswith("file:"):
# direct reference to file
package_key, name, version, friendly_version = _convert_v5_v6_file_package(package_path, package_snapshot)
name, version, friendly_version = _convert_v5_v6_file_package(package_path, package_snapshot)
elif "name" in package_snapshot and "version" in package_snapshot:
# key/path is complicated enough the real name+version are properties
name = package_snapshot["name"]
version = _strip_v5_default_registry_to_version(name, package_path)
friendly_version = package_snapshot["version"]
package_key = _to_package_key(name, version)
elif package_path.startswith("/"):
# a simple /name/version[_peer_info]
name, version = package_path[1:].rsplit("/", 1)
friendly_version = _strip_v5_peer_dep_or_patched_version(version)
package_key = _to_package_key(name, version)
else:
msg = "unexpected package path: {} of {}".format(package_path, package_snapshot)
fail(msg)

package_key = _to_package_key(name, version)

package_info = _new_package_info(
id = package_snapshot.get("id", None),
name = name,
Expand Down Expand Up @@ -364,22 +364,22 @@ def _convert_v6_packages(packages):

if package_path.startswith("file:"):
# direct reference to file
package_key, name, version, friendly_version = _convert_v5_v6_file_package(package_path, package_snapshot)
name, version, friendly_version = _convert_v5_v6_file_package(package_path, package_snapshot)
elif "name" in package_snapshot and "version" in package_snapshot:
# key/path is complicated enough the real name+version are properties
name = package_snapshot["name"]
version = _strip_v6_default_registry_to_version(name, package_path)
friendly_version = package_snapshot["version"]
package_key = _to_package_key(name, version)
elif package_path.startswith("/"):
# plain /pkg@version(_peer_info)
name, version = package_path[1:].rsplit("@", 1)
friendly_version = _strip_v5_peer_dep_or_patched_version(version) # NOTE: already converted to v5 peer style
package_key = _to_package_key(name, version)
else:
msg = "unexpected package path: {} of {}".format(package_path, package_snapshot)
fail(msg)

package_key = _to_package_key(name, version)

package_info = _new_package_info(
id = package_snapshot.get("id", None),
name = name,
Expand Down Expand Up @@ -501,9 +501,6 @@ def _convert_v9_packages(packages, snapshots):
# package_data can have the resolved "version" for things like https:// deps
friendly_version = package_data["version"] if "version" in package_data else static_key[version_index + 1:]

# Convert the package_key to a rules_js compatible format
package_key = _to_package_key(name, version)

package_info = _new_package_info(
id = package_data.get("id", None), # TODO: does v9 have "id"?
name = name,
Expand Down

0 comments on commit 0594057

Please sign in to comment.