-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expanded test coverage for pnpm lockfile processing #2004
Open
Silic0nS0ldier
wants to merge
2
commits into
aspect-build:main
Choose a base branch
from
Silic0nS0ldier:expanded-npm-translate-lock-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,33 @@ def _new_import_info(dependencies, dev_dependencies, optional_dependencies): | |
"optional_dependencies": optional_dependencies, | ||
} | ||
|
||
# Metadata about a package. | ||
# | ||
# 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): | ||
""" | ||
Metadata about a package. | ||
|
||
Metadata may come from different locations depending on the lockfile, this struct should | ||
have data normalized across lockfiles. | ||
|
||
Args: | ||
id: The package id, if present. | ||
TODO Remove. Used for to resolve path of local packages, however `resolution` is a better source of truth. | ||
name: The package name. | ||
dependencies: A map of package dependencies. | ||
optional_dependencies: A map of optional package dependencies. | ||
dev: True if the package is a dev dependency, None otherwise. | ||
has_bin: True if the package has a bin field. | ||
optional: True if the package is an optional dependency. | ||
Determines if package should be omitted `no_optional = True` specified. | ||
requires_build: True if the package requires a build. | ||
NOTE: With pnpm v9, this cannot be known ahead of time. | ||
version: The resolved package version. | ||
e.g. `file:packages/a`, `1.2.3`, `1.2.3_at_scope_peer_2.0.2`. | ||
friendly_version: The package version, normalized for users. Used to target patches, etc. | ||
e.g. `file:packages/a`, `1.2.3`. | ||
resolution: The package resolution. | ||
e.g. { integrity: "..." } | ||
e.g. { type: "directory", directory: "packages/a" } | ||
""" | ||
return { | ||
"id": id, | ||
"name": name, | ||
|
@@ -218,20 +240,20 @@ def _convert_pnpm_v6_v9_version_peer_dep(version): | |
# with rules_js. | ||
# | ||
# Examples: | ||
# 1.2.3 | ||
# 1.2.3(@scope/[email protected])(@scope/[email protected]) | ||
# 4.5.6(patch_hash=o3deharooos255qt5xdujc3cuq) | ||
# 1.2.3 -> 1.2.3 | ||
# 1.2.3(@scope/[email protected])(@scope/[email protected]) -> 1.2.3_2001974805 | ||
# 4.5.6(patch_hash=o3deharooos255qt5xdujc3cuq) -> 4.5.6_o3deharooos255qt5xdujc3cuq | ||
if version[-1] == ")": | ||
# Drop the patch_hash= not present in v5 so (patch_hash=123) -> (123) like v5 | ||
version = version.replace("(patch_hash=", "(") | ||
|
||
# There is a peer dep if the string ends with ")" | ||
# There is a peer dep (or patch) if the string ends with ")" | ||
peer_dep_index = version.find("(") | ||
peer_dep = version[peer_dep_index:] | ||
if len(peer_dep) > 32: | ||
# Prevent long paths. The pnpm lockfile v6 no longer hashes long sequences of | ||
# peer deps so we must hash here to prevent extremely long file paths that lead to | ||
# "File name too long) build failures. | ||
# "File name too long" build failures. | ||
peer_dep = utils.hash(peer_dep) | ||
else: | ||
peer_dep = peer_dep.replace("(@", "(_at_").replace(")(", "_").replace("@", "_").replace("/", "_") | ||
|
@@ -603,4 +625,5 @@ pnpm = struct( | |
# Exported only to be tested | ||
pnpm_test = struct( | ||
strip_v5_peer_dep_or_patched_version = _strip_v5_peer_dep_or_patched_version, | ||
convert_pnpm_v6_v9_version_peer_dep = _convert_pnpm_v6_v9_version_peer_dep, | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I've ever seen this in any bazel repo, do you have any more info on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bazel does not ignore
.git
by default, meaning commands likebazel build //...
also search in.git
forBUILD
files.This is bad for performance (especially in a large repository with a long history).
Additionally while rare, a
.git
directory could have a file Bazel will attempt to process. For example a branch calledBUILD
would create a file.git/refs/remotes/origin/BUILD
containing the hash of the commit it current points to. Utter nonsense to Bazel that will fail the build/query/etc.