forked from kint-php/kint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.php
58 lines (45 loc) · 1.73 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
<?php
use Symfony\Component\Finder\Finder;
require_once __DIR__.'/vendor/autoload.php';
$finder = new Finder();
$finder->files()->name('*.php')->in(__DIR__.'/src');
$files = iterator_to_array($finder);
sort($files);
$files[] = __DIR__.'/init_footer.php';
$files[] = __DIR__.'/init_helpers.php';
$output = '<?php';
foreach ($files as $file) {
$output .= substr(file_get_contents($file), 5); // strip opening tag
}
// Add CSS and JS
$output .= 'Kint_Renderer_Rich::$pre_render_sources[\'script\'] = ';
$output .= var_export(array(
file_get_contents(__DIR__.'/resources/compiled/rich.js').file_get_contents(__DIR__.'/resources/compiled/rich_microtime.js'),
), true);
$output .= ";\n";
$output .= 'Kint_Renderer_Plain::$pre_render_sources[\'style\'] = ';
$output .= var_export(array(
file_get_contents(__DIR__.'/resources/compiled/plain.css'),
), true);
$output .= ";\n";
mkdir(__DIR__.'/build');
file_put_contents(__DIR__.'/build/kint.php', $output);
$header = file_get_contents(__DIR__.'/init_header.php');
$minified = ltrim(substr(php_strip_whitespace(__DIR__.'/build/kint.php'), 5));
// Attach and write the different styles
$styles = array(
'kint.php' => 'original.css',
'kint-aante-light.php' => 'aante-light.css',
'kint-solarized.php' => 'solarized.css',
'kint-solarized-dark.php' => 'solarized-dark.css',
);
foreach ($styles as $outfile => $stylefile) {
$out = $minified;
$out .= 'Kint_Renderer_Rich::$pre_render_sources[\'style\'] = ';
$out .= var_export(array(
file_get_contents(__DIR__.'/resources/compiled/'.$stylefile),
), true);
$out .= ";\n";
$out = $header.'eval(gzuncompress('.var_export(gzcompress($out), true)."));//\0\n";
file_put_contents(__DIR__.'/build/'.$outfile, $out);
}