Skip to content

Commit

Permalink
Remove LazyComponentCommand and introduce LazyInstallCommand
Browse files Browse the repository at this point in the history
LazyComponentCommand was deleted as it was no longer needed. Instead, a new command, LazyInstallCommand, was introduced. This new command prompts the user to install npm dependencies and initialize tailwindcss. The purpose of this change was to implement an improved installation process and provide better user interaction.
  • Loading branch information
CrazyBoy49z committed Oct 15, 2023
1 parent 46b7af9 commit b91fe8b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
19 changes: 0 additions & 19 deletions src/Commands/LazyComponentCommand.php

This file was deleted.

48 changes: 48 additions & 0 deletions src/Commands/LazyInstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Step2dev\LazyUI\Commands;

use Illuminate\Console\Command;
use function Laravel\Prompts\confirm;

class LazyInstallCommand extends Command
{
public $signature = 'lazy-ui:install-package';

public $description = 'My command';

public function handle(): int
{
if (confirm(
label: 'Do you want to install npm dependency?',
default: true,
hint: 'This will install all the npm dependencies for lazy-ui'
)) {
$packages = [
'-D tailwindcss postcss autoprefixer sass',
'-D daisyui@latest',
'axios',
'quill',
'sanitize-html',
'theme-change',
'alpinejs',
];

foreach ($packages as $package) {
$this->info('Run command "npm i '.$package.'"');
shell_exec('npm i '.$package);
}
}

if (confirm(
label: 'Do you want initialize tailwindcss?',
default: true,
hint: 'This will initialize tailwindcss'
)) {
$this->info('Run command "npm i npx tailwindcss init"');
shell_exec('npx tailwindcss init');
}

return self::SUCCESS;
}
}
4 changes: 3 additions & 1 deletion src/LazyUiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Step2dev\LazyUI\Commands\LazyComponentCommand;
use Step2dev\LazyUI\Commands\LazyInstallCommand;
use Step2dev\LazyUI\Components\Accordion;
use Step2dev\LazyUI\Components\Alert;
use Step2dev\LazyUI\Components\Avatar;
Expand Down Expand Up @@ -126,11 +127,12 @@ public function configurePackage(Package $package): void
Toggle::class,
Tooltip::class,
)
->hasCommand(LazyComponentCommand::class)
->hasCommand(LazyInstallCommand::class)
->hasInstallCommand(static function (InstallCommand $command) {
$command
->startWith(static function (InstallCommand $installCommand) {
$installCommand->info('Installing Lazy Ui...');
$installCommand->call('lazy-ui:install-package');
})
->publishConfigFile()
->askToStarRepoOnGitHub('step2dev/lazy-ui')
Expand Down

0 comments on commit b91fe8b

Please sign in to comment.