kloudlite / kl

Kloudlite CLI Client
GNU Affero General Public License v3.0
5 stars 1 forks source link

notify developers of new cli version and enable update via kl update command #204

Closed abdheshnayak closed 8 hours ago

abdheshnayak commented 8 hours ago

Summary by Sourcery

Add a feature to notify developers of new CLI versions and enable updates via the 'kl update' command. Implement a version check mechanism to alert users when a new version is available and provide instructions for updating.

New Features:

Enhancements:

sourcery-ai[bot] commented 8 hours ago

Reviewer's Guide by Sourcery

This pull request implements a version check and update mechanism for the Kloudlite CLI tool. It adds functionality to notify developers of new CLI versions and enables updates via the 'kl update' command.

Sequence diagram for CLI version check and update

sequenceDiagram
    participant User
    participant CLI as Kloudlite CLI
    participant Updater
    participant FileClient

    User->>CLI: Start CLI
    CLI->>FileClient: GetExtraData()
    alt Last update check > 12 hours
        CLI->>Updater: NewUpdater()
        CLI->>Updater: CheckForUpdates()
        alt Update available
            Updater->>CLI: GetUpdateMessage()
            CLI->>User: Notify new version available
            CLI->>FileClient: SaveExtraData()
        end
    end

Updated class diagram for Updater

classDiagram
    class Updater {
        +CheckForUpdates() bool
        +GetUpdateMessage() *string
        +Update() error
        +GetUpdateUrl() *string
    }
    class updater {
        -releaseInfo map[string]string
        +fetchReleaseInfo() map[string]string
    }
    Updater <|.. updater
    updater --> Updater: implements
    class FileClient {
        +GetExtraData() ExtraData
        +SaveExtraData(data ExtraData)
    }
    class ExtraData {
        +string BaseUrl
        +string SelectedTeam
        +string DnsHostSuffix
        +map SelectedEnvs
        +time.Time LastUpdateCheck
    }

File-Level Changes

Change Details Files
Implemented version checking mechanism
  • Added a versionCheck function to periodically check for updates
  • Created a new updater package with functions to check for updates and retrieve update messages
  • Modified the root command to include version checking logic
clis/kl/root.go
pkg/updater/main.go
Enhanced the update command functionality
  • Modified the update command to use the new updater package
  • Removed the hidden flag from the update command
  • Updated the command to accept version as an argument instead of a flag
clis/kl/update.go
Updated data structures and constants
  • Added LastUpdateCheck field to ExtraData struct
  • Updated the UpdateURL constant
domain/fileclient/context.go
constants/main.go

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).