1
0
Fork 0
mirror of https://github.com/archtechx/airwire.git synced 2025-12-12 10:44:03 +00:00

write readme

This commit is contained in:
Samuel Štancl 2021-05-20 22:38:02 +02:00
parent d26fa93f1e
commit 28e16d6bef
7 changed files with 619 additions and 5 deletions

View file

@ -2,6 +2,7 @@
namespace Airwire;
use Airwire\Commands\ComponentCommand;
use Airwire\Commands\GenerateDefinitions;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
@ -12,7 +13,7 @@ class AirwireServiceProvider extends ServiceProvider
{
public function boot()
{
$this->commands([GenerateDefinitions::class]);
$this->commands([GenerateDefinitions::class, ComponentCommand::class]);
$this->loadDefaultTransformers();

View file

@ -0,0 +1,41 @@
<?php
namespace Airwire\Commands;
use Illuminate\Support\Str;
use Illuminate\Console\Command;
class ComponentCommand extends Command
{
protected $signature = 'airwire:component {name}';
protected $description = 'Create a new Airwire component';
public function handle()
{
$name = Str::studly($this->argument('name'));
if (! is_dir($path = app_path('Airwire'))) {
mkdir($path);
}
file_put_contents($path . '/' . $name . '.php', <<<PHP
<?php
namespace App\Airwire;
use Airwire\Attributes\Wired;
use Airwire\Component;
class {$name} extends Component
{
//
}
PHP);
$this->line("✨ Component app/Airwire/{$name}.php has been created!\n");
$this->warn("🚧 Don't forget to register the component! Add the following line to AppServiceProvider:");
$this->line("\n\n Airwire::component('" . Str::snake($name) . "', {$name}::class);\n\n");
}
}

View file

@ -12,7 +12,7 @@ class GenerateDefinitions extends Command
protected $signature = 'airwire:generate';
protected $description = 'Command description';
protected $description = 'Generate TypeScript definitions.';
public function handle()
{