forked from code-golf/code-golf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatest-langs
executable file
·143 lines (134 loc) · 7.7 KB
/
latest-langs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env raku
use HTTP::Tiny;
use JSON::Fast;
use TOML::Thumb;
# Pass "--all" to see all languages regardless of version status.
unit sub MAIN(Bool :$all, *@langs);
constant %paths = (
'05AB1E' => 'github.com/Adriandmen/05AB1E',
'><>' => 'github.com/primo-ppcg/fish-jit',
'ALGOL 68' => 'jmvdveer.home.xs4all.nl/en.download.algol-68-genie-current.html',
'APL' => 'dyalog.com/download-zone.htm?p=download',
'Arturo' => 'github.com/arturo-lang/arturo/releases/latest',
'Assembly' => 'registry.npmjs.org/@defasm/core/latest',
'AWK' => 'ftp.gnu.org/gnu/gawk/?C=M;O=D',
'Bash' => 'en.wikipedia.org/wiki/Bash_(Unix_shell)',
'BASIC' => 'en.wikipedia.org/wiki/FreeBASIC',
'Befunge' => 'github.com/VorpalBlade/cfunge',
'Berry' => 'github.com/berry-lang/berry/releases/latest',
'BQN' => 'aplwiki.com/wiki/BQN',
'brainfuck' => 'github.com/primo-ppcg/bfci',
'C' => 'en.wikipedia.org/wiki/Tiny_C_Compiler',
'C#' => 'en.wikipedia.org/wiki/C_Sharp_(programming_language)',
'C++' => 'en.wikipedia.org/wiki/Clang',
'Civet' => 'registry.npmjs.org/@danielx/civet/latest',
'CJam' => 'sourceforge.net/projects/cjam/files',
'Clojure' => 'github.com/babashka/babashka/releases/latest',
'COBOL' => 'en.wikipedia.org/wiki/GnuCOBOL',
'Coconut' => 'pypi.org/pypi/coconut/json',
'CoffeeScript' => 'registry.npmjs.org/coffeescript/latest',
'Common Lisp' => 'en.wikipedia.org/wiki/CLISP',
'Crystal' => 'github.com/crystal-lang/crystal/releases/latest',
'D' => 'en.wikipedia.org/wiki/D_(programming_language)',
'Dart' => 'en.wikipedia.org/wiki/Dart_(programming_language)',
'Egel' => 'github.com/egel-lang/egel/releases/latest',
'Elixir' => 'en.wikipedia.org/wiki/Elixir_(programming_language)',
'F#' => 'en.wikipedia.org/wiki/F_Sharp_(programming_language)',
'Factor' => 'github.com/factor/factor/releases/latest',
'Fennel' => 'fennel-lang.org/downloads/?C=M;O=D',
'Forth' => 'en.wikipedia.org/wiki/Gforth',
'Fortran' => 'en.wikipedia.org/wiki/GNU_Compiler_Collection',
'Gleam' => 'github.com/gleam-lang/gleam/releases/latest',
'Go' => 'endoflife.date/api/go.json',
'GolfScript' => 'github.com/lynn/golfscript/tree/code-golf',
'Groovy' => 'en.wikipedia.org/wiki/Apache_Groovy',
'Harbour' => 'github.com/harbour/core',
'Hare' => 'lists.sr.ht/~sircmpwn/hare-announce?search=release',
'Haskell' => 'pkgs.alpinelinux.org/package/edge/community/x86_64/ghc',
'Haxe' => 'github.com/HaxeFoundation/haxe/releases/latest',
'Hexagony' => 'github.com/SirBogman/Hexagony',
'Hush' => 'crates.io/api/v1/crates/hush',
'Hy' => 'pypi.org/pypi/hy/json',
'iogii' => 'golfscript.com/iogii/source.html',
'J' => 'en.wikipedia.org/wiki/J_(programming_language)',
'Janet' => 'github.com/janet-lang/janet/releases/latest',
'Java' => 'endoflife.date/api/java.json',
'JavaScript' => 'en.wikipedia.org/wiki/V8_(JavaScript_engine)',
'jq' => 'github.com/jqlang/jq/releases/latest',
'Julia' => 'github.com/JuliaLang/julia/releases/latest',
'K' => 'codeberg.org/ngn/k',
'Kotlin' => 'github.com/JetBrains/kotlin/releases/latest',
'Lua' => 'en.wikipedia.org/wiki/Lua_(programming_language)',
'Nim' => 'en.wikipedia.org/wiki/Nim_(programming_language)',
'OCaml' => 'en.wikipedia.org/wiki/OCaml',
'Odin' => 'github.com/odin-lang/Odin/releases/latest',
'Pascal' => 'en.wikipedia.org/wiki/Free_Pascal',
'Perl' => 'endoflife.date/api/perl.json',
'PHP' => 'endoflife.date/api/php.json',
'PowerShell' => 'endoflife.date/api/powershell.json',
'Prolog' => 'swi-prolog.discourse.group/c/releases',
'Python' => 'endoflife.date/api/python.json',
'R' => 'en.wikipedia.org/wiki/R_(programming_language)',
'Racket' => 'github.com/racket/racket/releases/latest',
'Raku' => 'github.com/rakudo/rakudo/releases/latest',
'Rebol' => 'en.wikipedia.org/wiki/Rebol',
'Rexx' => 'regina-rexx.sourceforge.io',
'Rockstar 2' => 'github.com/RockstarLang/rockstar/releases/latest',
'Ruby' => 'endoflife.date/api/ruby.json',
'Rust' => 'en.wikipedia.org/wiki/Rust_(programming_language)',
'Scala' => 'github.com/scala/scala/releases/latest',
'Scheme' => 'en.wikipedia.org/wiki/Chez_Scheme',
'sed' => 'git.savannah.gnu.org/cgit/sed.git/refs',
'SQL' => 'en.wikipedia.org/wiki/SQLite',
'Squirrel' => 'github.com/albertodemichelis/squirrel/releases/latest',
'Swift' => 'github.com/swiftlang/swift/releases/latest',
'Tcl' => 'en.wikipedia.org/wiki/Tcl',
'TeX' => 'en.wikipedia.org/wiki/TeX',
'Uiua' => 'crates.io/api/v1/crates/uiua',
'V' => 'en.wikipedia.org/wiki/V_(programming_language)',
'VimL' => 'en.wikipedia.org/wiki/Vim_(text_editor)',
'Wren' => 'github.com/wren-lang/wren/releases/latest',
'Zig' => 'github.com/ziglang/zig/releases/latest',
);
my %langs = from-toml 'config/data/langs.toml'.IO;
# Dotted decimal, hyphenated date, or Git SHA.
my regex ver { \d+ ( <[.-]> \d+ )+ | <xdigit> ** 7..* }
for %langs{ @langs || * }:p.sort: *.key.fc -> (:key($name), :value(%lang)) {
my $old = %lang<version> ~~ / <ver> /;
my $new = do with %paths{$name} {
state $ua = HTTP::Tiny.new :throw-exceptions;
my $res = $ua.get("https://$_")<content>.decode;
when / 'alpinelinux' / { $res ~~ / 'Version' .+? <(<ver>)> '-r' \d+ / }
when / 'aplwiki' / { $res ~~ / ' release' .+? <(<ver>)> / }
when / 'codeberg' / { $res ~~ / '"shortsha">' <(<ver>)> / }
when / 'crates.io' / { $res.&from-json<crate><max_stable_version> }
when / 'dyalog.com' / { $res ~~ / <(<ver>)> ' for Linux (DEB)' / }
when / 'endoflife' / { $res.&from-json[0]<latest> }
when / 'fennel-lang' / { $res ~~ / 'fennel-' <(<ver>)> / }
when / 'ftp.gnu.org' / { $res ~~ / 'gawk-' <(<ver>)> '.tar.xz' / }
when / 'golfscript.com' / { $res ~~ / '(Alpha)' .+? <(<ver>)> / }
when / 'jmvdveer' / { $res ~~ / 'algol68g-' <(<ver>)> / }
when / 'lists.sr.ht' / { $res ~~ / 'Hare ' <(<ver>)> ' release' / }
when / 'npmjs.org' / { $res.&from-json[0]<version> }
when / 'pypi.org' / { $res.&from-json<info><version> }
when / 'regina-rexx' / { $res ~~ / '<b>Current</b> ' <(<ver>)> / }
when / 'savannah' / { $res ~~ / 'snapshot/sed-' <(<ver>)> / }
when / 'sourceforge' / { $res ~~ / 'Latest' .+? <(<ver>)> / }
when / 'swi-prolog' / { $res ~~ / 'stable' .+? <(<ver>)> / }
when / 'github.com' / {
.ends-with('/releases/latest')
?? $res ~~ m:i/ [ $name || < dev release version > ] <[\ -]> v? <(<ver>)> /
!! $res ~~ / '"currentOid":"' <( <xdigit> ** 7 )> /;
}
when / 'wikipedia' / {
$res ~~ /
< Stable Preview > ' release' .+? '>' ( '#' \d+ ' "' )?
<(<ver>)>
/;
}
} // '?';
my $match = $old eq $new || $old.starts-with("$new.") || "$old.0" eq $new;
my $code = $new eq '?' ?? 33 !! $match ?? 32 !! 31;
printf "%12s \e[%dm%11s → %s\e[0m\n", $name, $code, $old, $new
if $all || @langs.elems || !$match;
}