Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ title: Changelog

## [Unreleased](https://github.com/lets-cli/lets/releases/tag/v0.0.X)

* `[Added]` Add `update` as an alias for `lets self upgrade`.
* `[Added]` Add `checksum.files`, `checksum.sh`, and `checksum.persist` command checksum syntax while keeping the old checksum format compatible.
* `[Added]` Add `lets self upgrade --pre` to opt into upgrading to the latest prerelease.
* `[Added]` Add `lets self fix` config migration command with `--dry-run` preview output for deprecated checksum syntax.
Expand Down
56 changes: 29 additions & 27 deletions internal/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,37 +418,39 @@ func TestSelfCmd(t *testing.T) {
}
})

t.Run("should run self upgrade subcommand", func(t *testing.T) {
bufOut := new(bytes.Buffer)
called := false
for _, command := range []string{"upgrade", "update"} {
t.Run("should run self "+command+" subcommand", func(t *testing.T) {
bufOut := new(bytes.Buffer)
called := false

rootCmd := CreateRootCommand("v0.0.0-test", "")
rootCmd.SetArgs([]string{"self", command})
rootCmd.SetOut(bufOut)
rootCmd.SetErr(bufOut)
selfCmd := &cobra.Command{
Use: "self",
Short: "Manage lets CLI itself",
}
rootCmd.AddCommand(selfCmd)

rootCmd := CreateRootCommand("v0.0.0-test", "")
rootCmd.SetArgs([]string{"self", "upgrade"})
rootCmd.SetOut(bufOut)
rootCmd.SetErr(bufOut)
selfCmd := &cobra.Command{
Use: "self",
Short: "Manage lets CLI itself",
}
rootCmd.AddCommand(selfCmd)
selfCmd.AddCommand(initUpgradeCommandWith(func(_ *cobra.Command) (upgrade.Upgrader, error) {
return mockUpgraderFunc(func(ctx context.Context) error {
called = true

selfCmd.AddCommand(initUpgradeCommandWith(func(_ *cobra.Command) (upgrade.Upgrader, error) {
return mockUpgraderFunc(func(ctx context.Context) error {
called = true
return nil
}), nil
}))

return nil
}), nil
}))

err := rootCmd.Execute()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
err := rootCmd.Execute()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

if !called {
t.Fatal("expected upgrader to be called")
}
})
if !called {
t.Fatal("expected upgrader to be called")
}
})
}

t.Run("should pass pre flag to self upgrade factory", func(t *testing.T) {
bufOut := new(bytes.Buffer)
Expand Down
7 changes: 4 additions & 3 deletions internal/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ func upgradeProgress(stderr io.Writer, appSettings settings.Settings) fetch.Prog

func initUpgradeCommandWith(createUpgrader upgraderFactory) *cobra.Command {
upgradeCmd := &cobra.Command{
Use: "upgrade",
Short: "Upgrade lets to latest version",
Args: cobra.NoArgs,
Use: "upgrade",
Aliases: []string{"update"},
Short: "Upgrade lets to latest version",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
upgrader, err := createUpgrader(cmd)
if err != nil {
Expand Down
Loading