-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: store package.json and deno.json JSR and npm deps in lockfile for tracking removable dependencies #13
feat: store package.json and deno.json JSR and npm deps in lockfile for tracking removable dependencies #13
Conversation
…ckage.json, just in case
… user to just delete it
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.
A few nits and questions, but not a blocker to land it
|
||
/// Graph used to analyze a lockfile to determine which packages | ||
/// and remotes can be removed based on config file changes. | ||
pub struct LockfilePackageGraph<FNvToJsrUrl: Fn(&str) -> Option<String>> { |
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.
Huh, I didn't know you could do that (or never seen that in the wild)
while let Some(id) = pending.pop_back() { | ||
if let Some(package) = packages.get_mut(&id) { |
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.
What if pacakges.get_mut()
returns None
? Is it assume it will be found by another root?
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.
It might occur if someone has been modifying the lockfile themselves. It's not a big deal in that case because then the package is already gone.
#[error("Integrity check failed for npm package: \"{package_display_id}\". Unable to verify that the package | ||
is the same as when the lockfile was generated. | ||
|
||
Actual: {actual} | ||
Expected: {expected} | ||
|
||
This could be caused by: | ||
* the lock file may be corrupt | ||
* the source itself may be corrupt | ||
|
||
Use \"--lock-write\" flag to regenerate the lockfile at \"{filename}\".", | ||
)] | ||
pub struct IntegrityCheckFailedError { |
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.
Question: will we surface these errors one-by-one or aggregate them and display them all at once?
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.
One-by-one as it currently does. It might be good to improve this in the future.
Updates the lockfile to keep track of JSR and npm dependencies stored in a deno.json or package.json. When a package is removed from a config file, then the dependency is also removed from the lockfile. This supports workspaces, so is nested under the "workspace" key:
A workspace with multiple members looks like this:
Additionally, JSR packages with their version constraints are now stored under "packages" in addition to "npm":
When
"jsr:@scope/package_a@1"
is removed from "workspace" -> "dependencies", then it knows it can remove@scope/[email protected]
and therefore@scope/[email protected]
(even though it's circular in this case) and@scope/[email protected]
. Additionally, it strips out the urls under "remote". This specific example can be seen in https://github.com/denoland/deno_lockfile/pull/13/files#diff-e13153f86e029e465847ec0daa572a7d0e96acaea1ff47c232136f826208fb86