2022-05-27 04:08:51 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2022-05-27 04:08:51 +02:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use App\Libraries\MultiDB;
|
|
|
|
use App\Models\Backup;
|
|
|
|
use App\Models\Design;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
use stdClass;
|
|
|
|
|
|
|
|
class ReactBuilder extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'ninja:react';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Builds blade component for react includes';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$includes = '';
|
|
|
|
|
|
|
|
$directoryIterator = new \RecursiveDirectoryIterator(public_path('react'), \RecursiveDirectoryIterator::SKIP_DOTS);
|
|
|
|
|
|
|
|
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
|
2023-01-14 05:28:35 +01:00
|
|
|
if (str_contains($file->getFileName(), '.js') && !strpos($file->getFileName(), '.json')) {
|
2022-06-21 11:57:17 +02:00
|
|
|
if (str_contains($file->getFileName(), 'index.')) {
|
|
|
|
$includes .= '<script type="module" crossorigin src="/react/'.$file->getFileName().'"></script>'."\n";
|
|
|
|
} else {
|
|
|
|
$includes .= '<link rel="modulepreload" href="/react/'.$file->getFileName().'">'."\n";
|
|
|
|
}
|
2022-05-27 04:08:51 +02:00
|
|
|
}
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
if (str_contains($file->getFileName(), '.css')) {
|
|
|
|
$includes .= '<link rel="stylesheet" href="/react/'.$file->getFileName().'">'."\n";
|
2022-05-27 04:08:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
file_put_contents(resource_path('views/react/head.blade.php'), $includes);
|
|
|
|
}
|
|
|
|
}
|