-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.php
67 lines (57 loc) · 1.93 KB
/
build.php
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
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
$run = function (string $description, callable $execute): mixed {
try {
echo "\e[0m[ \e[36m..\e[0m ] \e[36m{$description}\e[0m";
$response = $execute();
echo "\33[2K\r\e[0m[ \e[1;32mOK\e[0m ] \e[36m{$description}\e[0m\n";
return $response;
} catch (\Throwable $t) {
echo "\33[2K\r\e[0m[ \e[1;31mERR\e[0m ] \e[36m{$description}\e[0m\n";
echo " \e[31m{$t->getMessage()}\e[0m\n";
die(1);
}
};
$stars = $run(
'Estatísticas do GitHub',
(new App\Crawler\GitHubApi(getenv('GITHUB_TOKEN')))
->addRepository('laravel', 'laravel/laravel')
->addRepository('slim', 'slimphp/Slim')
->addRepository('symfony', 'symfony/symfony')
->addRepository('composer', 'composer/composer')
->addRepository('awesomePhp', 'ziadoz/awesome-php')
->addOrganization('phpLeague', 'thephpleague')
->addOrganization('laminas', 'laminas')
);
$curlExec = new \App\CurlExec(
cachePath: \getenv('CACHE_PATH') ?: null,
);
[$latestPhpVersion, $latestPhpVersionReleaseDate] = $run(
'Última versão do PHP',
new App\Crawler\LatestPhpVersion(
'https://www.php.net/releases/active.php',
$curlExec,
)
);
$phpUsagePercentage = $run(
'Uso do PHP no w3techs.com',
new App\Crawler\PhpUsagePercentage(
'https://w3techs.com/technologies/history_overview/programming_language',
$curlExec,
)
);
[$wordpressCmsUsagePercentage, $wordpressTotalUsagePercentage] = $run(
'Uso do WordPress no w3techs.com',
new App\Crawler\WordpressUsagePercentage(
'https://w3techs.com/technologies/details/cm-wordpress',
$curlExec,
)
);
ob_start();
require __DIR__ . '/template/index.phtml';
$template = ob_get_clean();
$run(
'Gerando public/index.html',
fn() => file_put_contents(__DIR__ . '/public/index.html', $template, LOCK_EX)
);