Outdated returns a map of package names to their available latest version.
(ctx context.Context)
| 50 | |
| 51 | // Outdated returns a map of package names to their available latest version. |
| 52 | func (d *Devbox) Outdated(ctx context.Context) (map[string]UpdateVersion, error) { |
| 53 | lockfile := d.Lockfile() |
| 54 | outdatedPackages := map[string]UpdateVersion{} |
| 55 | var warnings []string |
| 56 | |
| 57 | for _, pkg := range d.AllPackages() { |
| 58 | // For non-devbox packages, like flakes, we can skip for now |
| 59 | if !pkg.IsDevboxPackage { |
| 60 | continue |
| 61 | } |
| 62 | |
| 63 | lockPackage, err := lockfile.FetchResolvedPackage(pkg.Versioned(), false) |
| 64 | if err != nil { |
| 65 | warnings = append(warnings, fmt.Sprintf("Note: unable to check updates for %s", pkg.CanonicalName())) |
| 66 | continue |
| 67 | } |
| 68 | existingLockPackage := lockfile.Packages[pkg.Raw] |
| 69 | if lockPackage.Version == existingLockPackage.Version { |
| 70 | continue |
| 71 | } |
| 72 | |
| 73 | outdatedPackages[pkg.Versioned()] = UpdateVersion{Current: existingLockPackage.Version, Latest: lockPackage.Version} |
| 74 | } |
| 75 | |
| 76 | for _, warning := range warnings { |
| 77 | fmt.Fprintf(d.stderr, "%s\n", warning) |
| 78 | } |
| 79 | |
| 80 | return outdatedPackages, nil |
| 81 | } |
| 82 | |
| 83 | // Add adds the `pkgs` to the config (i.e. devbox.json) and nix profile for this |
| 84 | // devbox project |
no test coverage detected