(ctx context.Context, stderr io.Writer)
| 22 | var utilProjectConfigPath string |
| 23 | |
| 24 | func initDevboxUtilityProject(ctx context.Context, stderr io.Writer) error { |
| 25 | devboxUtilityProjectPath, err := ensureDevboxUtilityConfig() |
| 26 | if err != nil { |
| 27 | return err |
| 28 | } |
| 29 | |
| 30 | box, err := Open(&devopt.Opts{ |
| 31 | Dir: devboxUtilityProjectPath, |
| 32 | Stderr: stderr, |
| 33 | }) |
| 34 | if err != nil { |
| 35 | return errors.WithStack(err) |
| 36 | } |
| 37 | |
| 38 | // Add all utilities here. |
| 39 | utilities := []string{ |
| 40 | "process-compose@" + processComposeVersion, |
| 41 | } |
| 42 | |
| 43 | // Skip Add for utilities whose exact versioned name is already in the |
| 44 | // config; calling Add anyway would print noisy "Package already in |
| 45 | // devbox.json" messages on every services interaction. A version mismatch |
| 46 | // (e.g. after bumping processComposeVersion) will fall through to Add, |
| 47 | // which replaces the existing package by canonical name. |
| 48 | existing := box.AllPackageNamesIncludingRemovedTriggerPackages() |
| 49 | toAdd := []string{} |
| 50 | for _, u := range utilities { |
| 51 | if !slices.Contains(existing, u) { |
| 52 | toAdd = append(toAdd, u) |
| 53 | } |
| 54 | } |
| 55 | if len(toAdd) > 0 { |
| 56 | if err = box.Add(ctx, toAdd, devopt.AddOpts{}); err != nil { |
| 57 | return err |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | return box.Install(ctx) |
| 62 | } |
| 63 | |
| 64 | func ensureDevboxUtilityConfig() (string, error) { |
| 65 | if utilProjectConfigPath != "" { |
no test coverage detected