-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade: sst upgrade command handles package.json upgrades
- Loading branch information
Showing
8 changed files
with
123 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/fatih/color" | ||
"github.com/sst/ion/cmd/sst/cli" | ||
"github.com/sst/ion/cmd/sst/mosaic/ui" | ||
"github.com/sst/ion/pkg/global" | ||
) | ||
|
||
func CmdUpgrade(c *cli.Cli) error { | ||
if os.Getenv("npm_config_user_agent") != "" { | ||
updated, err := global.UpgradeNode( | ||
version, | ||
c.Positional(0), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
hasAny := false | ||
for file, newVersion := range updated { | ||
fmt.Print(ui.TEXT_SUCCESS_BOLD.Render(ui.IconCheck) + " ") | ||
fmt.Println(ui.TEXT_NORMAL.Render(file)) | ||
fmt.Println(" " + ui.TEXT_DIM.Render(newVersion)) | ||
if newVersion != version { | ||
hasAny = true | ||
} | ||
} | ||
if hasAny { | ||
var cmd *exec.Cmd | ||
if _, err := os.Stat("package-lock.json"); err == nil { | ||
cmd = exec.Command("npm", "install") | ||
} | ||
if _, err := os.Stat("yarn.lock"); err == nil { | ||
cmd = exec.Command("yarn", "install") | ||
} | ||
if _, err := os.Stat("pnpm-lock.yaml"); err == nil { | ||
cmd = exec.Command("pnpm", "install") | ||
} | ||
if _, err := os.Stat("bun.lockb"); err == nil { | ||
cmd = exec.Command("bun", "install") | ||
} | ||
if cmd != nil { | ||
fmt.Println() | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
cmd.Stdin = os.Stdin | ||
err := cmd.Run() | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
return nil | ||
} | ||
newVersion, err := global.Upgrade( | ||
version, | ||
c.Positional(0), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
newVersion = strings.TrimPrefix(newVersion, "v") | ||
fmt.Print(ui.TEXT_SUCCESS_BOLD.Render(ui.IconCheck)) | ||
if newVersion == version { | ||
color.New(color.FgWhite).Printf(" Already on latest %s\n", version) | ||
} else { | ||
color.New(color.FgWhite).Printf(" Upgraded %s ➜ ", version) | ||
color.New(color.FgCyan, color.Bold).Println(newVersion) | ||
} | ||
return nil | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,6 @@ | |
"typescript": "5.3.3" | ||
}, | ||
"dependencies": { | ||
"sst": "^0.1.7" | ||
"sst": "0.1.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
847612c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this update, I'm now seeing a bunch of warnings about
You are using a global installation of SST but you also have a local installation specified in your package.json. The local installation will be used but you should typically run it through your package manager.