dpl/scripts/hn/publish-assets.php

19 lines
884 B
PHP

<?php
// Run only after building the selected hn theme, within the hn deployment checkout.
require __DIR__.'/../../vendor/autoload.php';
$app = require __DIR__.'/../../bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
if (!App\Support\SiteProfile::isHn()) {
throw new RuntimeException('hn asset publication requires SITE_PROFILE=hn.');
}
$theme = config('site.theme', 'EZ');
$build = $theme === 'EZ' ? 'build:hn' : 'build:hardnerd';
if (!is_file(base_path('theme/'.$theme.'/assets/.vite/manifest.json'))) {
throw new RuntimeException('Build '.$theme.' first: cd frontends && npm ci && npm run '.$build);
}
if (!Illuminate\Support\Facades\File::copyDirectory(base_path('theme/'.$theme), public_path('theme/'.$theme))) {
throw new RuntimeException('Failed to publish '.$theme.' assets.');
}
echo $theme." assets published for hn.\n";