CheckVersion checks the launcher and binary versions and prints a notice if they are out of date. It will set the checkVersionEnvName to indicate that the version check was done. Callers should call ClearEnvVar after their work is done.
(w io.Writer, commandPath string)
| 57 | // It will set the checkVersionEnvName to indicate that the version check was done. |
| 58 | // Callers should call ClearEnvVar after their work is done. |
| 59 | func CheckVersion(w io.Writer, commandPath string) { |
| 60 | if isDevBuild { |
| 61 | return |
| 62 | } |
| 63 | |
| 64 | if os.Getenv(envName) == "1" { |
| 65 | return |
| 66 | } |
| 67 | |
| 68 | if envir.IsDevboxCloud() { |
| 69 | return |
| 70 | } |
| 71 | |
| 72 | hasSkipPrefix := lo.ContainsBy( |
| 73 | commandSkipList, |
| 74 | func(skipPath string) bool { return strings.HasPrefix(commandPath, skipPath) }, |
| 75 | ) |
| 76 | if hasSkipPrefix { |
| 77 | return |
| 78 | } |
| 79 | |
| 80 | // check launcher version |
| 81 | launcherNotice := launcherVersionNotice() |
| 82 | if launcherNotice != "" { |
| 83 | ux.Finfo(w, launcherNotice) |
| 84 | |
| 85 | // fallthrough to alert the user about a new Devbox CLI binary being possibly available |
| 86 | } |
| 87 | |
| 88 | // check devbox CLI version |
| 89 | devboxNotice := devboxVersionNotice() |
| 90 | if devboxNotice != "" { |
| 91 | ux.Finfo(w, devboxNotice) |
| 92 | } |
| 93 | |
| 94 | os.Setenv(envName, "1") |
| 95 | } |
| 96 | |
| 97 | // SelfUpdate updates the devbox launcher and devbox CLI binary. |
| 98 | // It ignores and deletes the version cache. |