forked from binjuhor/html-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·38 lines (31 loc) · 1.01 KB
/
build
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
#!/usr/bin/env php
<?php
include_once "vendor/autoload.php";
use GuzzleHttp\Exception\GuzzleException;
$appUrl = getVar('APP_URL', '');
$prodUrl = getVar('PRODUCT_URL', $appUrl);
$appEnv = getVar('ENV', 'development');
$files = glob('resources/views/*.blade.php');
if (file_exists('compiles/routes.txt')) {
exec('rm -rf compiles/*');
}
foreach ($files as $file) {
$filename = basename($file, '.blade.php');
echo "Generate page: {$appUrl}/{$filename}.html\n";
$client = new GuzzleHttp\Client();
try {
$client->request('GET', "{$appUrl}/?f={$filename}&build");
$file = fopen("compiles/routes.txt", "a");
if ($filename !== '404') {
fwrite($file, "{$prodUrl}/{$filename}.html\n");
}
fclose($file);
} catch (GuzzleException $e) {
echo "Error: " . $e->getMessage() . "\n";
}
}
exec('cp -r resources/assets compiles/assets');
exec('rm -rf compiles/404.html');
exec('find compiles -name .gitkeep -exec rm -f {} \;');
exec('rm -rf compiles/assets/scss');
echo "Build complete\n";