forked from code-golf/code-golf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatest-langs
executable file
·87 lines (66 loc) · 2.2 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
#!/usr/bin/env perl6
use Cro::HTTP::Client;
# For C#, F#, and PowerShell, see:
# https://hub.docker.com/_/microsoft-dotnet-core-sdk/
# https://mcr.microsoft.com/v2/dotnet/core/sdk/tags/list
# The version string from code-golf contains the SDK version.
constant @langs = (
'C',
'http://download.savannah.gnu.org/releases/tinycc/?C=M&O=D',
/ 'tcc-' (<[\d.]>+) '.tar.bz2' /,
'Fortran',
'https://gcc.gnu.org/releases.html',
/ 'GCC ' (\d<[\d.]>+) /,
'Go',
'https://golang.org/project/',
/ 'var goVersion = "go' (<[\d.]>+) '"' /,
'Haskell',
'https://www.haskell.org/ghc/download.html',
/ 'download_ghc' .+? ">" (<[\d.]>+) /,
'Java',
# Note: need to manually change the number in this url for major releases.
'https://raw.githubusercontent.com/AdoptOpenJDK/openjdk-docker/master/14/jdk/alpine/Dockerfile.hotspot.releases.slim',
/ 'ENV JAVA_VERSION jdk-' (<[\d+.]>+) /,
'Julia',
'https://julialang.org/downloads/',
/ 'stable release: v' (<[\d.]>+) /,
'Lua',
'https://www.lua.org',
/ 'versions.html' .+? '>Lua ' (<[\d.]>+) /,
'Nim',
'https://nim-lang.org',
/ 'Version ' (<[\d.]>+) /,
'Perl',
'https://www.perl.org',
/ '"version-highlight">' (<[\d.]>+) /,
'PHP',
'https://www.php.net/downloads.php',
/ 'Stable</span>' \s* 'PHP ' (<[\d.]>+) /,
'Python',
'https://www.python.org',
/ 'Latest: <' .+? '>Python ' (<[\d.]>+) /,
'Ruby',
'https://www.ruby-lang.org/en/downloads/',
/ 'stable version is ' (<[\d.]>+) '.' /,
'Rust',
'https://www.rust-lang.org',
/ 'Version ' (<[\d.]>+) /,
'Swift',
'https://swift.org/download/',
/ 'Swift ' (<[\d.]>+) /,
);
constant $len = @langs[0, 3 … *]».chars.max;
my %current = (get('https://code.golf/about') ~~ m:g/
'<tr><th' .+? '>' (.+?) '<' .*? (<[\d+.]> ** 2..*)
/)».list.flat».Str.Hash;
for @langs -> $lang, $url, $re {
my $ver = get($url) ~~ $re ?? ~$0 !! '';
my $current = %current{$lang};
if $ver ne $current && "$ver.0" ne $current {
printf " %*s %s\n", $len, $lang, $ver;
}
}
sub get ($url) {
state $client = Cro::HTTP::Client.new(:!follow :http<1.1>);
await (await $client.get($url)).body;
}