Skip to content

Commit

Permalink
Merge pull request #465 from hydephp/build-manifest
Browse files Browse the repository at this point in the history
Generate a build manifest after the build hydephp/develop@e9ecc57
  • Loading branch information
github-actions committed Sep 6, 2022
1 parent 22e2612 commit 7eb407d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Actions/PostBuildTasks/GenerateBuildManifest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Hyde\Framework\Actions\PostBuildTasks;

use Hyde\Framework\Contracts\AbstractBuildTask;
use Hyde\Framework\Hyde;
use Illuminate\Console\OutputStyle;
use Illuminate\Support\Collection;

class GenerateBuildManifest extends AbstractBuildTask
{
public function __construct(?OutputStyle $output = null)
{
parent::__construct($output);
$this->output = null;
}

public function run(): void
{
$manifest = new Collection();

/** @var \Hyde\Framework\Contracts\AbstractPage $page */
foreach (Hyde::pages() as $page) {
$manifest->push([
'page' => $page->getSourcePath(),
'source_hash' => md5(Hyde::path($page->getSourcePath())),
'output_hash' => md5(Hyde::path($page->getOutputPath())),
]);
}

file_put_contents(Hyde::path(config('hyde.build_manifest_path',
'storage/framework/cache/build-manifest.json')
), $manifest->toJson());
}
}
3 changes: 3 additions & 0 deletions src/Services/BuildTaskService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Hyde\Framework\Services;

use Hyde\Framework\Actions\PostBuildTasks\GenerateBuildManifest;
use Hyde\Framework\Contracts\BuildTaskContract;
use Hyde\Framework\Hyde;
use Illuminate\Console\OutputStyle;
Expand Down Expand Up @@ -31,6 +32,8 @@ public function runPostBuildTasks(): void
foreach ($this->getPostBuildTasks() as $task) {
$this->run($task);
}

$this->runIf(GenerateBuildManifest::class, config('hyde.generate_build_manifest', true));
}

public function getPostBuildTasks(): array
Expand Down

0 comments on commit 7eb407d

Please sign in to comment.