Luke Towers 1085be50b5 Implement autoregistration of Laravel Mix packages for modules, plugins, & themes.
Also renamed default to winter.mix.js instead of winter-mix.js started on the mix:install support.

Refs: #440, #401.
2022-02-10 16:10:07 -06:00

59 lines
1.4 KiB
PHP

<?php namespace System\Console;
use File;
use Illuminate\Console\Command;
use System\Classes\MixAssets;
class MixList extends Command
{
/**
* @var string The console command name.
*/
protected $name = 'mix:list';
/**
* @var string The console command description.
*/
protected $description = 'List all registered Mix packages in this project.';
public function handle(): int
{
$this->line('');
$mixedAssets = MixAssets::instance();
$mixedAssets->fireCallbacks();
$packages = $mixedAssets->getPackages();
if (count($packages) === 0) {
$this->info('No packages have been registered.');
return 0;
}
$this->info('Packages registered:');
$this->line('');
$errors = [];
foreach ($packages as $name => $package) {
$this->info($name);
$this->line(' Path: ' . $package['path']);
$this->line(' Configuration: ' . $package['mix']);
if (!File::exists($package['mix'])) {
$errors[] = "The mix file for $name doesn't exist, try running artisan mix:install";
}
}
$this->line('');
if (!empty($errors)) {
foreach ($errors as $error) {
$this->error($error);
}
}
return 0;
}
}