Skip to content
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

Handle additional path-based version specifiers #25

Conversation

taylormadore
Copy link
Contributor

Add handling for more path-based version specifiers

These are all valid version specifiers for path-style packages in package.json/yarn.lock:

./some/relative/path
../some/relative/path
file:some/relative/path
file:../some/relative/path
link:some/relative/path
link:../some/relative/path
/some/absolute/path

Ensure that the Package class provides a path in each of these cases.

@@ -46,7 +46,7 @@ def __init__(
self.version = version
self.url = url
self.checksum = checksum
self.relpath = relpath
self.path = path

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to keep relpath as an alias to path for backward compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point 👍

@eskultety
Copy link
Member

Apart from existing comments LGTM.

Copy link

@a-ovchinnikov a-ovchinnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM with two small suggestions.

self.dependencies = dependencies or {}
self.alias = alias

@property
def relpath(self) -> Optional[str]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a note stating that this is deprecated and is left for backward compatibility only.

elif version_path.is_absolute() or version.startswith(("./", "../")):
return str(version_path)
else:
return None

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor, non-blocking suggestion: could you please add a short comment or a link to a doc about when this branch could be reached?

It is possible to have an absolute path as the version specifier in
Yarn-generated package.json and yarn.lock files. This makes the
Package.relpath field name slightly misleading. Add Package.path
instead and retain Package.relpath only for backwards compatibility.
This will make the naming more accurate for future commits.

Signed-off-by: Taylor Madore <[email protected]>
These are all valid version specifiers for path-style packages in
package.json/yarn.lock:

./some/relative/path
../some/relative/path
file:some/relative/path
file:../some/relative/path
link:some/relative/path
link:../some/relative/path\
/some/absolute/path

Ensure that the Package class provides a path in each of these cases.

Signed-off-by: Taylor Madore <[email protected]>
Copy link

@a-ovchinnikov a-ovchinnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@taylormadore taylormadore merged commit 85749ab into containerbuildsystem:master Oct 30, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants