-
Notifications
You must be signed in to change notification settings - Fork 270
feat: implement outdated command #2497
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,37 @@ const StateOutOfDateMessage = "Your devbox environment may be out of date. Run % | |
// packages.go has functions for adding, removing and getting info about nix | ||
// packages | ||
|
||
type UpdateVersion struct { | ||
Current string | ||
Latest string | ||
} | ||
|
||
// Outdated returns a map of package names to their available latest version. | ||
func (d *Devbox) Outdated(ctx context.Context) (map[string]UpdateVersion, error) { | ||
lockfile := d.Lockfile() | ||
outdatedPackages := map[string]UpdateVersion{} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, would prefer to use a slice over map. We don't need random access or deduplication. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gcurtis may not like this but we could just return that way we don't have to create a new struct at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm I don't mind the struct. Its nice to have the names There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How you prefer guys, here map doesn't create any performance problems, it is just a matter of some seconds to run the command, I chose readability over little optimization |
||
|
||
for _, pkg := range d.AllPackages() { | ||
// For non-devbox packages, like flakes or runx, we can skip for now | ||
if !pkg.IsDevboxPackage { | ||
continue | ||
} | ||
|
||
lockPackage, err := lockfile.FetchResolvedPackage(pkg.Versioned()) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to fetch resolved package") | ||
} | ||
existingLockPackage := lockfile.Packages[pkg.Raw] | ||
if lockPackage.Version == existingLockPackage.Version { | ||
continue | ||
} | ||
|
||
outdatedPackages[pkg.Versioned()] = UpdateVersion{Current: existingLockPackage.Version, Latest: lockPackage.Version} | ||
} | ||
|
||
return outdatedPackages, nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @guerinoni I think we need this function to be rewritten as so. I created this patch via copying here for clarity:
wdyt @gcurtis @mikeland73 ? The benefit of this is that it also works for
I don't think the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I aligned with this patch :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not runx? The versions are correct. Ideally we could also do it for flakes as well but our current flake update mechanism is a bit broken. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh good point, I forgot runx updating works properly. So all good |
||
} | ||
|
||
// Add adds the `pkgs` to the config (i.e. devbox.json) and nix profile for this | ||
// devbox project | ||
func (d *Devbox) Add(ctx context.Context, pkgsNames []string, opts devopt.AddOpts) error { | ||
|
Uh oh!
There was an error while loading. Please reload this page.