-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add self-update command #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5b17c21
feat(updater): add self-update package
sthbryan 6fb4715
feat(cli): add --update and --check flags
sthbryan 7f1762a
feat(i18n): add update command messages
sthbryan a070155
refactor(cli): extract uninstall command to internal/cli
sthbryan 08d64b5
refactor(cli): extract update command to internal/cli
sthbryan 41e550c
refactor(updater): extract unix apply into build-tagged file
sthbryan e1d0c7f
feat(updater): add Windows self-update via delayed .bat replacement
sthbryan c9e064d
chore: ignore *.old backup files from self-update
sthbryan ba7e572
feat(tui): notify about updates with 'u' shortcut to install
sthbryan a43756f
feat(i18n): add TUI update notification strings
sthbryan efaea80
feat(web): add /api/update endpoint with periodic check and apply
sthbryan 94a740f
feat(web): add UpdateBanner with apply button
sthbryan f9efb7b
feat(i18n): add web update banner strings
sthbryan 89674f0
feat(web): enhance UpdateBanner layout and button styling
sthbryan 3c37e1a
fix(updater): handle errors and clean up temp files
sthbryan c0acb56
fix(web): consistent update shape and runes-based store
sthbryan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # Binaries | ||
| /ftm | ||
| /ftm-* | ||
| *.old | ||
| *.exe | ||
| bin/ | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,33 @@ | ||
| package app | ||
|
|
||
| import ( | ||
| tea "github.com/charmbracelet/bubbletea" | ||
|
|
||
| "github.com/sthbryan/ftm/internal/updater" | ||
| "github.com/sthbryan/ftm/internal/version" | ||
| ) | ||
|
|
||
| const updateRepo = "sthbryan/ftm" | ||
|
|
||
| type updateCheckMsg struct { | ||
| info *updater.Info | ||
| err error | ||
| } | ||
|
|
||
| type updateApplyMsg struct { | ||
| err error | ||
| } | ||
|
|
||
| func checkUpdateCmd() tea.Cmd { | ||
| return func() tea.Msg { | ||
| info, err := updater.New(updateRepo).Check(version.Version) | ||
| return updateCheckMsg{info: info, err: err} | ||
| } | ||
| } | ||
|
|
||
| func applyUpdateCmd(info *updater.Info) tea.Cmd { | ||
| return func() tea.Msg { | ||
| err := updater.New(updateRepo).Apply(info) | ||
| return updateApplyMsg{err: err} | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,7 @@ | ||
| package cli | ||
|
|
||
| import "github.com/sthbryan/ftm/internal/i18n" | ||
|
|
||
| func Init() error { | ||
| return i18n.Load() | ||
| } |
This file contains hidden or 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,30 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
|
|
||
| "github.com/sthbryan/ftm/internal/i18n" | ||
| ) | ||
|
|
||
| func Uninstall() error { | ||
| binaryPath, err := exec.LookPath("ftm") | ||
| if err != nil { | ||
| return fmt.Errorf("%s", i18n.T("uninstall_not_found")) | ||
| } | ||
|
|
||
| absPath, err := filepath.EvalSymlinks(binaryPath) | ||
| if err != nil { | ||
| absPath = binaryPath | ||
| } | ||
|
|
||
| fmt.Println(i18n.TF("uninstall_removing", absPath)) | ||
| if err := os.Remove(absPath); err != nil { | ||
| return fmt.Errorf("%s", i18n.TF("uninstall_error", err.Error())) | ||
| } | ||
|
|
||
| fmt.Println(i18n.T("uninstall_success")) | ||
| return nil | ||
| } |
This file contains hidden or 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,40 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/sthbryan/ftm/internal/i18n" | ||
| "github.com/sthbryan/ftm/internal/updater" | ||
| "github.com/sthbryan/ftm/internal/version" | ||
| ) | ||
|
|
||
| const defaultRepo = "sthbryan/ftm" | ||
|
|
||
| func Update(checkOnly bool) error { | ||
| u := updater.New(defaultRepo) | ||
| info, err := u.Check(version.Version) | ||
| if err != nil { | ||
| return fmt.Errorf("%s", i18n.TF("update_check_failed", err.Error())) | ||
| } | ||
|
|
||
| fmt.Println(i18n.TF("update_current_version", info.CurrentVersion)) | ||
| fmt.Println(i18n.TF("update_latest_version", info.LatestVersion)) | ||
|
|
||
| if !info.HasUpdate { | ||
| fmt.Println(i18n.T("update_up_to_date")) | ||
| return nil | ||
| } | ||
|
|
||
| fmt.Println(i18n.TF("update_available", info.Tag)) | ||
| fmt.Println(i18n.TF("update_release_url", info.ReleaseURL)) | ||
| if checkOnly { | ||
| return nil | ||
| } | ||
|
|
||
| fmt.Println(i18n.TF("update_downloading", info.AssetName)) | ||
| if err := u.Apply(info); err != nil { | ||
| return fmt.Errorf("%s", i18n.TF("update_apply_failed", err.Error())) | ||
| } | ||
| fmt.Println(i18n.TF("update_success", info.LatestVersion)) | ||
| return nil | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.