Skip to content
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

UX: updating to a newer version of Fantomas #847

Open
nojaf opened this issue Nov 4, 2021 · 2 comments
Open

UX: updating to a newer version of Fantomas #847

nojaf opened this issue Nov 4, 2021 · 2 comments

Comments

@nojaf
Copy link
Contributor

nojaf commented Nov 4, 2021

In #836, we introduced a whole new brave world of choosing your own Fantomas version.
These last weeks, we've published two new versions of Fantomas that are also compatible with Ionide.

The question remains, how do we want to inform the user of these updates?
We can easily detect new versions via the NuGet API:

#r "nuget: NuGet.Protocol"

open System
open System.Threading
open NuGet.Common
open NuGet.Versioning
open NuGet.Protocol
open NuGet.Protocol.Core.Types

type SemanticVersion with

    member this.Alpha: int option =
        if isNull this.Release then
            None
        else
            this.Release.Replace("alpha-", "")
            |> Int32.TryParse
            |> fun (success, alpha) -> if success then Some alpha else None

async {
    let logger = NullLogger.Instance
    let cancellationToken = CancellationToken.None

    let cache = new SourceCacheContext()

    let repository =
        Repository.Factory.GetCoreV3("https://api.nuget.org/v3/index.json")

    let! resource =
        repository.GetResourceAsync<FindPackageByIdResource>()
        |> Async.AwaitTask

    let! versions =
        resource.GetAllVersionsAsync(
            "fantomas-tool",
            cache,
            logger,

            cancellationToken
        )
        |> Async.AwaitTask

    versions
    |> Seq.filter (fun v ->
        v.Major = 4
        && v.Minor = 6
        && (Option.map (fun alpha -> alpha >= 4) v.Alpha
            |> Option.defaultValue true)
    )
    |> Seq.iter (fun v -> printfn "%A" v.Release)
}
|> Async.RunSynchronously

But how do we want to deal with this?
Some people will be interested in every version (alpha, beta, stable), while others will only care for revisions or minors.

@baronfel
Copy link
Contributor

baronfel commented Nov 4, 2021

In an ideal world, I think the user should be prompted:

  • once per repo
  • per stable version only
  • with an option to ignore the version specified

all of this is stuff that would probably live at the ionide/FSAC layers and not necessarily in the Fantomas.Client library itself (aside from maybe exposing an API to check the current version and query for the latest Fantomas version specifically), and might be conditioned behind a config flag like fsharp.fantomas.updateCheck: true|major|minor|patch|prerelease|ignore or something.

@nojaf
Copy link
Contributor Author

nojaf commented Nov 4, 2021

Yup, I have no intention of putting anything in Fantomas.Client for this.
There is an API though to get the current version of an F# file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants