forked from code-golf/code-golf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatest-langs
executable file
·79 lines (73 loc) · 3.71 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
#!/usr/bin/env raku
use HTTP::Tiny;
use JSON::Fast;
use TOML::Thumb;
constant %paths = (
'BASIC' => 'en.wikipedia.org/wiki/FreeBASIC',
'Berry' => 'github.com/berry-lang/berry/releases/latest',
'C' => 'en.wikipedia.org/wiki/Tiny_C_Compiler',
'C#' => 'en.wikipedia.org/wiki/C_Sharp_(programming_language)',
'C++' => 'en.wikipedia.org/wiki/Clang',
'COBOL' => 'en.wikipedia.org/wiki/GnuCOBOL',
'Coconut' => 'github.com/evhub/coconut/releases/latest',
'Clojure' => 'github.com/babashka/babashka/releases/latest',
'Crystal' => 'github.com/crystal-lang/crystal/releases/latest',
'D' => 'en.wikipedia.org/wiki/D_(programming_language)',
'Dart' => 'en.wikipedia.org/wiki/Dart_(programming_language)',
'Elixir' => 'en.wikipedia.org/wiki/Elixir_(programming_language)',
'F#' => 'en.wikipedia.org/wiki/F_Sharp_(programming_language)',
'Factor' => 'github.com/factor/factor/releases/latest',
'Forth' => 'en.wikipedia.org/wiki/Gforth',
'Fortran' => 'en.wikipedia.org/wiki/GNU_Fortran',
'Go' => 'endoflife.date/api/go.json',
'Haskell' => 'en.wikipedia.org/wiki/Glasgow_Haskell_Compiler',
'Janet' => 'github.com/janet-lang/janet/releases/latest',
'Java' => 'endoflife.date/api/java.json',
'JavaScript' => 'en.wikipedia.org/wiki/V8_(JavaScript_engine)',
'Julia' => 'en.wikipedia.org/wiki/Julia_(programming_language)',
'Lisp' => 'en.wikipedia.org/wiki/CLISP',
'Lua' => 'en.wikipedia.org/wiki/Lua_(programming_language)',
'Nim' => 'en.wikipedia.org/wiki/Nim_(programming_language)',
'OCaml' => 'en.wikipedia.org/wiki/OCaml',
'PHP' => 'endoflife.date/api/php.json',
'Pascal' => 'en.wikipedia.org/wiki/Free_Pascal',
'Perl' => 'endoflife.date/api/perl.json',
'PowerShell' => 'endoflife.date/api/powershell.json',
'Prolog' => 'en.wikipedia.org/wiki/SWI-Prolog',
'Python' => 'endoflife.date/api/python.json',
'R' => 'en.wikipedia.org/wiki/R_(programming_language)',
'Raku' => 'en.wikipedia.org/wiki/Rakudo',
'Ruby' => 'endoflife.date/api/ruby.json',
'Rust' => 'en.wikipedia.org/wiki/Rust_(programming_language)',
'SQL' => 'en.wikipedia.org/wiki/SQLite',
'Swift' => 'en.wikipedia.org/wiki/Swift_(programming_language)',
'Tcl' => 'en.wikipedia.org/wiki/Tcl',
'TeX' => 'en.wikipedia.org/wiki/TeX',
'Uiua' => 'github.com/uiua-lang/uiua/releases/latest',
'V' => 'github.com/vlang/v/releases/latest',
'VimL' => 'en.wikipedia.org/wiki/Vim_(text_editor)',
'Wren' => 'github.com/wren-lang/wren/releases/latest',
'Zig' => 'en.wikipedia.org/wiki/Zig_(programming_language)',
);
my %langs = from-toml 'config/langs.toml'.IO;
for %langs.sort: *.key.fc -> (:key($name), :value(%lang)) {
my $old = %lang<version> ~~ / <[\d.]>+ \d+ /;
my $new = do with %paths{$name} {
state $ua = HTTP::Tiny.new :throw-exceptions;
my $res = $ua.get("https://$_")<content>.decode;
when / 'endoflife' / { $res.&from-json[0]<latest> }
when / 'github' / { $res ~~ / [ $name || 'Release' ] ' ' v? <(\d+ <[\d.]>+)> / }
when / 'wikipedia' / {
$res ~~ /
< Stable Preview > ' release' .+? '>' ( '#' \d+ ' "' )?
<(\d+ <[\d.]>+)>
/;
}
} // '?';
printf "%11s \e[%dm%11s → %s\e[0m\n",
$name,
$new eq '?' ?? 33
!! $old eq $new || $old.starts-with("$new.") ?? 32
!! 31,
$old, $new;
}