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

Function initDevboxUtilityProject

internal/devbox/util.go:24–62  ·  view source on GitHub ↗
(ctx context.Context, stderr io.Writer)

Source from the content-addressed store, hash-verified

22var utilProjectConfigPath string
23
24func 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
64func ensureDevboxUtilityConfig() (string, error) {
65 if utilProjectConfigPath != "" {

Callers 2

StartProcessManagerMethod · 0.85

Calls 5

OpenFunction · 0.70
AddMethod · 0.45
InstallMethod · 0.45

Tested by

no test coverage detected