Total Complexity | 5 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 8 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class GenerateBuildManifest extends AbstractBuildTask |
||
14 | { |
||
15 | public static string $description = 'Generating build manifest'; |
||
16 | |||
17 | public function __construct(?OutputStyle $output = null) |
||
18 | { |
||
19 | parent::__construct($output); |
||
20 | $this->output = null; |
||
21 | } |
||
22 | |||
23 | public function run(): void |
||
24 | { |
||
25 | $manifest = new Collection(); |
||
26 | |||
27 | /** @var \Hyde\Framework\Contracts\AbstractPage $page */ |
||
28 | foreach (Hyde::pages() as $page) { |
||
29 | $manifest->push([ |
||
|
|||
30 | 'page' => $page->getSourcePath(), |
||
31 | 'source_hash' => md5_file(Hyde::path($page->getSourcePath())), |
||
32 | 'output_hash' => $this->hashOutputPath(Hyde::getSiteOutputPath($page->getOutputPath())), |
||
33 | ]); |
||
34 | } |
||
35 | |||
36 | file_put_contents(Hyde::path(config('hyde.build_manifest_path', |
||
37 | 'storage/framework/cache/build-manifest.json') |
||
38 | ), $manifest->toJson()); |
||
39 | } |
||
40 | |||
41 | protected function hashOutputPath(string $path): ?string |
||
44 | } |
||
45 | } |
||
46 |