Created
October 24, 2019 16:14
-
-
Save JRaspass/419641525b44b80a1c6db99d6b48870b to your computer and use it in GitHub Desktop.
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
| use Cro::HTTP::Client; | |
| # data,deprecated,license | |
| my $url = 'http://fastapi.metacpan.org/v1/release/_search' | |
| ~ '?fields=dependency.module,dependency.version,main_module' | |
| ~ '&filter_path=_scroll_id,hits.hits.fields' | |
| ~ '&q=status:latest' | |
| ~ '&scroll=1m' | |
| ~ '&size=5000'; | |
| my %vers; | |
| loop { | |
| my %res = await ( await Cro::HTTP::Client.get: $url ).body; | |
| last unless %res<hits><hits>.elems; | |
| for %res<hits><hits>[] { | |
| next unless .<fields>:exists; | |
| my %fields = .<fields>; | |
| my %module = ( | |
| # :date(DateTime.new(|%fields<date>)), | |
| :name(%fields<main_module>[0]), | |
| ); | |
| #$_ = $_ eq 'true' with %fields<deprecated>; | |
| my $ver; | |
| with %fields<dependency.module> { | |
| with .first: * eq 'perl', :k { | |
| with %fields<dependency.version>[$_] { | |
| $ver = /^(v5\.\d+)/ ?? $0 | |
| !! /^5\.(\d\d\d)/ ?? "v5.{+$0}" | |
| !! /^5\.(\d\d)/ ?? "v5.{+($0 ~ '0')}" | |
| !! /^5\.(\d)/ ?? "v5.{+($0 ~ '00')}" | |
| !! /^5$/ ?? 'v5.0' | |
| !! /^0$/ ?? 'Any' | |
| !! warn "Unknown version '$_' %module<name>"; | |
| } | |
| } | |
| } | |
| $ver //= 'Any'; | |
| # Bump dev releases into the next stable. | |
| $ver = "v5.{$0 + 1}" if $ver ~~ /(\d+)$/ && $0 % 2; | |
| %vers{$ver}++; | |
| say "$ver %module<name>" if $ver.chars == 6; | |
| } | |
| $url = 'http://fastapi.metacpan.org/v1/_search/scroll?scroll=1m&scroll_id=' | |
| ~ %res<_scroll_id>; | |
| } | |
| printf "%-5s %d\n", .kv for %vers.pairs.sort: { .key.chars, .key }; | |
| CATCH { die await .response.body when X::Cro::HTTP::Error } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment