aquaproj / aqua

Declarative CLI Version manager written in Go. Support Lazy Install, Registry, and continuous update with Renovate. CLI version is switched seamlessly
https://aquaproj.github.io
863 stars 39 forks source link

Support getting version from arbitrary URL for http packages #682

Open frezbo opened 2 years ago

frezbo commented 2 years ago

Feature Overview

Golang publishes the release information here available as json NodeJS publishes the release information here available as json

it would be nice if the http package support parsing the json using an expression and gathering the latest version information (this is sometimes required as the latest github release might not be the latest according to semver and could be just a backported release)

Just putting out here for ideas, currently I manage go and nodejs using a custom ansible code to get the latest versions which parse the release information from the json

Gowiem commented 1 year ago

To reiterate what I said in https://github.com/aquaproj/aqua-registry/issues/14082, I think this could be valuable and is worth doing. Here was thoughts on schema to support this:

I could see some schema like this working:

packages:
  - name: snaplet/cli
    type: http
    package_version_fetch:
       type: http
       url: https://<URL TO VERSION JSON ENDPOINT>
       json_path: .content.versions.latest
   ... 
suzuki-shunsuke commented 2 weeks ago

Feature Overview

Currently there is no way to handle interactively (select, update, remove, etc.) non released "nightly" versions.

Why is the feature needed?

Maybe if aqua could support a new json value for version_source attribute, in order to declare how to fetch and parse (e.g. https://github.com/itchyny/gojq) the available versions, we would be able to declare how to fetch all "nightly" and "release" versions. And then work with those interactively via the CLI, like searching and selecting them, using aqua g -s.

Workaround

No response

Example Code

Configuration

e.g. for Zig:

version_source: json
  # - file: versions.json # or a local file
  - url: https://ziglang.org/download/index.json
    query: "(keys | del(.[] | select(. == "master"))), [.master.version] | .[]"

or for Node.js:

version_source: json
  - url: https://nodejs.org/download/release/index.json
    query: "[.[].version]"
  - url: https://nodejs.org/download/nightly/index.json
    query: "[.[].version]"

Note

No response

It is yes, didn't search for that sorry. Although the solution above with json and jq is better I think. More flexible and is using an existing battle-tested/well-known tool, that can be easily included to aqua (as a go lib or the original one). It also allows local files as sources + version_source is an existing attribute (vs. a new package_version_fetch attribute that I read on the other issue). In any way allowing to customize the version fetching mechanism would be a very nice addition in my opinion.