MCPcopy Create free account
hub / github.com/jetify-com/devbox / selfUpdateLauncher

Function selfUpdateLauncher

internal/vercheck/vercheck.go:111–146  ·  view source on GitHub ↗
(stdOut, stdErr io.Writer)

Source from the content-addressed store, hash-verified

109}
110
111func 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.
149func selfUpdateDevbox(stdErr io.Writer) error {

Callers 1

SelfUpdateFunction · 0.85

Calls 8

ExistsFunction · 0.92
NewFunction · 0.92
removeCurrentVersionFileFunction · 0.85
triggerUpdateFunction · 0.85
printSuccessMessageFunction · 0.85
currentLauncherVersionFunction · 0.85
CommandMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected