Skip to content

Commit c007174

Browse files
Lagojaguerinoni
authored andcommitted
fix typo
1 parent 9672a6d commit c007174

File tree

4 files changed

+39
-70
lines changed

4 files changed

+39
-70
lines changed

internal/boxcli/list.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Jetify Inc. and contributors. All rights reserved.
1+
// Copyright 2025 Jetify Inc. and contributors. All rights reserved.
22
// Use of this source code is governed by the license in the LICENSE file.
33

44
package boxcli
@@ -15,7 +15,8 @@ import (
1515
)
1616

1717
type listCmdFlags struct {
18-
config configFlags
18+
config configFlags
19+
outdated bool
1920
}
2021

2122
func listCmd() *cobra.Command {
@@ -34,6 +35,10 @@ func listCmd() *cobra.Command {
3435
return errors.WithStack(err)
3536
}
3637

38+
if flags.outdated {
39+
return printOutdatedPackages(cmd, box)
40+
}
41+
3742
for _, pkg := range box.AllPackagesIncludingRemovedTriggerPackages() {
3843
resolvedVersion, err := pkg.ResolvedVersion()
3944
if err != nil {
@@ -57,6 +62,28 @@ func listCmd() *cobra.Command {
5762
return nil
5863
},
5964
}
65+
66+
cmd.Flags().BoolVar(&flags.outdated, "outdated", false, "List outdated packages")
6067
flags.config.register(cmd)
6168
return cmd
6269
}
70+
71+
// printOutdatedPackages prints a list of outdated packages.
72+
func printOutdatedPackages(cmd *cobra.Command, box *devbox.Devbox) error {
73+
results, err := box.Outdated(cmd.Context())
74+
if err != nil {
75+
return errors.WithStack(err)
76+
}
77+
78+
if len(results) == 0 {
79+
cmd.Println("Your packages are up to date!")
80+
return nil
81+
}
82+
83+
cmd.Println("The following packages can be updated:")
84+
for pkg, version := range results {
85+
cmd.Printf(" * %-30s %s -> %s\n", pkg, version.Current, version.Latest)
86+
}
87+
88+
return nil
89+
}

internal/boxcli/outdated.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

internal/boxcli/root.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func RootCmd() *cobra.Command {
6666
command.AddCommand(infoCmd())
6767
command.AddCommand(initCmd())
6868
command.AddCommand(installCmd())
69-
command.AddCommand(outdatedCmd())
7069
command.AddCommand(integrateCmd())
7170
command.AddCommand(listCmd())
7271
command.AddCommand(logCmd())

internal/devbox/packages.go

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"go.jetpack.io/devbox/internal/devpkg"
2626
"go.jetpack.io/devbox/internal/devpkg/pkgtype"
2727
"go.jetpack.io/devbox/internal/lock"
28-
"go.jetpack.io/devbox/internal/searcher"
2928
"go.jetpack.io/devbox/internal/setup"
3029
"go.jetpack.io/devbox/internal/shellgen"
3130
"go.jetpack.io/devbox/internal/telemetry"
@@ -51,36 +50,25 @@ type UpdateVersion struct {
5150

5251
// Outdated returns a map of package names to their available latest version.
5352
func (d *Devbox) Outdated(ctx context.Context) (map[string]UpdateVersion, error) {
54-
ctx, task := trace.NewTask(ctx, "devboxOutdated")
55-
defer task.End()
56-
53+
lockfile := d.Lockfile()
5754
outdatedPackages := map[string]UpdateVersion{}
5855

5956
for _, pkg := range d.AllPackages() {
60-
if strings.HasSuffix(pkg.Versioned(), "latest") {
57+
// For non-devbox packages, like flakes or runx, we can skip for now
58+
if !pkg.IsDevboxPackage {
6159
continue
6260
}
6361

64-
result, err := searcher.Client().Search(ctx, pkg.CanonicalName())
62+
lockPackage, err := lockfile.FetchResolvedPackage(pkg.Versioned())
6563
if err != nil {
66-
return nil, err
64+
return nil, errors.Wrap(err, "failed to fetch resolved package")
6765
}
68-
69-
for _, p := range result.Packages {
70-
if p.Name == pkg.CanonicalName() {
71-
for _, v := range p.Versions {
72-
vv, err := pkg.ResolvedVersion()
73-
if err != nil {
74-
return nil, err
75-
}
76-
77-
if v.Version > vv {
78-
outdatedPackages[p.Name] = UpdateVersion{Current: vv, Latest: v.Version}
79-
break
80-
}
81-
}
82-
}
66+
existingLockPackage := lockfile.Packages[pkg.Raw]
67+
if lockPackage.Version == existingLockPackage.Version {
68+
continue
8369
}
70+
71+
outdatedPackages[pkg.Versioned()] = UpdateVersion{Current: existingLockPackage.Version, Latest: lockPackage.Version}
8472
}
8573

8674
return outdatedPackages, nil

0 commit comments

Comments
 (0)