MCPcopy Index your code
hub / github.com/jetify-com/devbox / Update

Method Update

internal/devbox/update.go:26–100  ·  view source on GitHub ↗
(ctx context.Context, opts devopt.UpdateOpts)

Source from the content-addressed store, hash-verified

24)
25
26func (d *Devbox) Update(ctx context.Context, opts devopt.UpdateOpts) error {
27 if len(opts.Pkgs) == 0 || slices.Contains(opts.Pkgs, "nixpkgs") {
28 if err := d.lockfile.UpdateStdenv(); err != nil {
29 return err
30 }
31 // if nixpkgs is the only package to update, just return here.
32 if len(opts.Pkgs) == 1 {
33 return nil
34 }
35 // Otherwise, remove nixpkgs and continue
36 opts.Pkgs = slices.DeleteFunc(opts.Pkgs, func(pkg string) bool {
37 return pkg == "nixpkgs"
38 })
39 }
40
41 inputs, err := d.inputsToUpdate(opts)
42 if err != nil {
43 return err
44 }
45
46 pendingPackagesToUpdate := []*devpkg.Package{}
47 for _, pkg := range inputs {
48 if pkg.IsLegacy() {
49 fmt.Fprintf(d.stderr, "Updating %s -> %s\n", pkg.Raw, pkg.LegacyToVersioned())
50
51 // Get the package from the config to get the Platforms and ExcludedPlatforms later
52 cfgPackage, ok := d.cfg.Root.GetPackage(pkg.Raw)
53 if !ok {
54 return fmt.Errorf("package %s not found in config", pkg.Raw)
55 }
56
57 if err := d.Remove(ctx, pkg.Raw); err != nil {
58 return err
59 }
60 // Calling Add function with the original package names, since
61 // Add will automatically append @latest if search is able to handle that.
62 // If not, it will fallback to the nixpkg format.
63 if err := d.Add(ctx, []string{pkg.Raw}, devopt.AddOpts{
64 Platforms: cfgPackage.Platforms,
65 ExcludePlatforms: cfgPackage.ExcludedPlatforms,
66 }); err != nil {
67 return err
68 }
69 } else {
70 pendingPackagesToUpdate = append(pendingPackagesToUpdate, pkg)
71 }
72 }
73
74 if err := d.updatePendingPackages(pendingPackagesToUpdate); err != nil {
75 return err
76 }
77
78 d.packagesBeingUpdated = inputs
79
80 mode := update
81 if opts.NoInstall {
82 mode = noInstall
83 }

Callers 2

updateCmdFuncFunction · 0.80
updateAllProjectsFunction · 0.80

Calls 13

inputsToUpdateMethod · 0.95
RemoveMethod · 0.95
AddMethod · 0.95
updatePendingPackagesMethod · 0.95
ensureStateIsUpToDateMethod · 0.95
FixMissingStorePathsMethod · 0.95
FlakeUpdateFunction · 0.92
FlakePathFunction · 0.92
UpdateFunction · 0.92
UpdateStdenvMethod · 0.80
IsLegacyMethod · 0.80
LegacyToVersionedMethod · 0.80

Tested by

no test coverage detected