(stdOut, stdErr io.Writer)
| 109 | } |
| 110 | |
| 111 | func selfUpdateLauncher(stdOut, stdErr io.Writer) error { |
| 112 | installScript := "" |
| 113 | if cmdutil.Exists("curl") { |
| 114 | installScript = "curl -fsSL https://get.jetpack.io/devbox | bash" |
| 115 | } else if cmdutil.Exists("wget") { |
| 116 | installScript = "wget -qO- https://get.jetpack.io/devbox | bash" |
| 117 | } else { |
| 118 | return usererr.New("curl or wget is required to update devbox. Please install either and try again.") |
| 119 | } |
| 120 | |
| 121 | // Delete current version file. This will trigger an update when invoking any devbox command; |
| 122 | // in this case, inside triggerUpdate function. |
| 123 | if err := removeCurrentVersionFile(); err != nil { |
| 124 | return err |
| 125 | } |
| 126 | |
| 127 | // Fetch the new launcher. And installs the new devbox CLI binary. |
| 128 | cmd := exec.Command("sh", "-c", installScript) |
| 129 | cmd.Stdout = stdOut |
| 130 | cmd.Stderr = stdErr |
| 131 | if err := cmd.Run(); err != nil { |
| 132 | return errors.WithStack(err) |
| 133 | } |
| 134 | |
| 135 | // Previously, we have already updated the binary. So, we call triggerUpdate |
| 136 | // just to get the new version information. |
| 137 | updated, err := triggerUpdate(stdErr) |
| 138 | if err != nil { |
| 139 | return errors.WithStack(err) |
| 140 | } |
| 141 | |
| 142 | printSuccessMessage(stdErr, "Launcher", currentLauncherVersion(), updated.launcherVersion) |
| 143 | printSuccessMessage(stdErr, "Devbox", currentDevboxVersion, updated.devboxVersion) |
| 144 | |
| 145 | return nil |
| 146 | } |
| 147 | |
| 148 | // selfUpdateDevbox will update the devbox CLI binary to the latest version. |
| 149 | func selfUpdateDevbox(stdErr io.Writer) error { |
no test coverage detected