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

Method updateLockfile

internal/devbox/packages.go:361–399  ·  view source on GitHub ↗

updateLockfile will ensure devbox.lock is up to date with the current state of the project.update If recomputeState is true, then we will also update the state.json file.

(recomputeState bool)

Source from the content-addressed store, hash-verified

359// updateLockfile will ensure devbox.lock is up to date with the current state of the project.update
360// If recomputeState is true, then we will also update the state.json file.
361func (d *Devbox) updateLockfile(recomputeState bool) error {
362 // Ensure we clean out packages that are no longer needed.
363 d.lockfile.Tidy()
364
365 // Update lockfile with new packages that are not to be installed
366 for _, pkg := range d.AllPackages() {
367 if err := pkg.EnsureUninstallableIsInLockfile(); err != nil {
368 return err
369 }
370 }
371
372 // Update plugin versions in lockfile.
373 for _, pluginConfig := range d.Config().IncludedPluginConfigs() {
374 if err := d.PluginManager().UpdateLockfileVersion(pluginConfig); err != nil {
375 return err
376 }
377 }
378
379 // Save the lockfile at the very end, after all other operations were successful.
380 if err := d.lockfile.Save(); err != nil {
381 return err
382 }
383
384 // If we are recomputing state, then we need to update the local.lock file.
385 // If not, we leave the local.lock in a stale state, so that state is recomputed
386 // on the next ensureStateIsUpToDate call with mode=ensure.
387 if recomputeState {
388 configHash, err := d.ConfigHash()
389 if err != nil {
390 return err
391 }
392 return lock.UpdateAndSaveStateHashFile(lock.UpdateStateHashFileArgs{
393 ProjectDir: d.projectDir,
394 ConfigHash: configHash,
395 IsFish: isFishShell(),
396 })
397 }
398 return nil
399}
400
401// recomputeState updates the local state comprising of:
402// - plugins directories

Callers 1

ensureStateIsUpToDateMethod · 0.95

Calls 11

AllPackagesMethod · 0.95
ConfigMethod · 0.95
PluginManagerMethod · 0.95
ConfigHashMethod · 0.95
isFishShellFunction · 0.85
TidyMethod · 0.80
IncludedPluginConfigsMethod · 0.80
UpdateLockfileVersionMethod · 0.80
SaveMethod · 0.45

Tested by

no test coverage detected