mirror of
https://github.com/flarum/core.git
synced 2025-07-18 23:31:17 +02:00
Asset Publish Command (#2731)
This commit is contained in:
committed by
GitHub
parent
3e173afa24
commit
804564a09a
@@ -12,6 +12,7 @@ namespace Flarum\Console;
|
|||||||
use Flarum\Database\Console\MigrateCommand;
|
use Flarum\Database\Console\MigrateCommand;
|
||||||
use Flarum\Database\Console\ResetCommand;
|
use Flarum\Database\Console\ResetCommand;
|
||||||
use Flarum\Foundation\AbstractServiceProvider;
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
|
use Flarum\Foundation\Console\AssetsPublishCommand;
|
||||||
use Flarum\Foundation\Console\CacheClearCommand;
|
use Flarum\Foundation\Console\CacheClearCommand;
|
||||||
use Flarum\Foundation\Console\InfoCommand;
|
use Flarum\Foundation\Console\InfoCommand;
|
||||||
use Illuminate\Console\Scheduling\Schedule as LaravelSchedule;
|
use Illuminate\Console\Scheduling\Schedule as LaravelSchedule;
|
||||||
@@ -37,6 +38,7 @@ class ConsoleServiceProvider extends AbstractServiceProvider
|
|||||||
|
|
||||||
$this->container->singleton('flarum.console.commands', function () {
|
$this->container->singleton('flarum.console.commands', function () {
|
||||||
return [
|
return [
|
||||||
|
AssetsPublishCommand::class,
|
||||||
CacheClearCommand::class,
|
CacheClearCommand::class,
|
||||||
InfoCommand::class,
|
InfoCommand::class,
|
||||||
MigrateCommand::class,
|
MigrateCommand::class,
|
||||||
|
@@ -88,12 +88,5 @@ class MigrateCommand extends AbstractCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->container->make(SettingsRepositoryInterface::class)->set('version', Application::VERSION);
|
$this->container->make(SettingsRepositoryInterface::class)->set('version', Application::VERSION);
|
||||||
|
|
||||||
$this->info('Publishing assets...');
|
|
||||||
|
|
||||||
$this->container->make('files')->copyDirectory(
|
|
||||||
$this->paths->vendor.'/components/font-awesome/webfonts',
|
|
||||||
$this->paths->public.'/assets/fonts'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* For detailed copyright and license information, please view the
|
||||||
|
* LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Foundation\Console;
|
||||||
|
|
||||||
|
use Flarum\Console\AbstractCommand;
|
||||||
|
use Flarum\Extension\ExtensionManager;
|
||||||
|
use Flarum\Foundation\Paths;
|
||||||
|
use Illuminate\Contracts\Container\Container;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
|
||||||
|
class AssetsPublishCommand extends AbstractCommand
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Container
|
||||||
|
*/
|
||||||
|
protected $container;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Paths
|
||||||
|
*/
|
||||||
|
protected $paths;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Container $container
|
||||||
|
* @param Paths $paths
|
||||||
|
*/
|
||||||
|
public function __construct(Container $container, Paths $paths)
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
$this->paths = $paths;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->setName('assets:publish')
|
||||||
|
->setDescription('Publish core and extension assets.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function fire()
|
||||||
|
{
|
||||||
|
$this->info('Publishing core assets...');
|
||||||
|
|
||||||
|
$target = $this->container->make('filesystem')->disk('flarum-assets');
|
||||||
|
$local = new Filesystem();
|
||||||
|
|
||||||
|
$pathPrefix = $this->paths->vendor.'/components/font-awesome/webfonts';
|
||||||
|
$assetFiles = $local->allFiles($pathPrefix);
|
||||||
|
|
||||||
|
foreach ($assetFiles as $fullPath) {
|
||||||
|
$relPath = substr($fullPath, strlen($pathPrefix));
|
||||||
|
$target->put("fonts/$relPath", $local->get($fullPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('Publishing extension assets...');
|
||||||
|
|
||||||
|
$extensions = $this->container->make(ExtensionManager::class);
|
||||||
|
$extensions->getMigrator()->setOutput($this->output);
|
||||||
|
|
||||||
|
foreach ($extensions->getEnabledExtensions() as $name => $extension) {
|
||||||
|
if ($extension->hasAssets()) {
|
||||||
|
$this->info('Publishing for extension: '.$name);
|
||||||
|
$extension->copyAssetsTo($target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user