Skip to content

Commit

Permalink
Merge pull request #10 from fuelviews/decouple-deps-add-install-command
Browse files Browse the repository at this point in the history
Decouple deps add install command
  • Loading branch information
thejmitchener authored Jun 12, 2024
2 parents 7aa08e7 + 03da52d commit e5489f5
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 13 deletions.
16 changes: 4 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,19 @@
"role": "Developer"
}
],
"repositories": [
{
"type": "vcs",
"url": "[email protected]:fuelviews/laravel-forms.git"
}
],
"require": {
"php": "^8.2",
"illuminate/contracts": "^10.0 || ^11.0",
"illuminate/support": "^10.0 || ^11.0",
"spatie/laravel-package-tools": "^1.16",
"ralphjsmit/laravel-glide": "^1.2.1",
"fuelviews/laravel-forms": "^0.0"
"spatie/laravel-package-tools": "^1.16"
},
"require-dev": {
"laravel/pint": "^1.14",
"nunomaduro/collision": "^8.1.1||^7.10.0",
"orchestra/testbench": "^9.0.0||^8.22.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-arch": "^2.7",
"pestphp/pest-plugin-laravel": "^2.3"
"pestphp/pest-plugin-laravel": "^2.3",
"ralphjsmit/laravel-glide": "^1.2.1",
"livewire/livewire": "^3.5"
},
"autoload": {
"psr-4": {
Expand Down
54 changes: 54 additions & 0 deletions src/Commands/NavigationInstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Fuelviews\Navigation\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

class NavigationInstallCommand extends Command
{
protected $signature = 'navigation:install';

protected $description = 'Install packages and dependencies';

public function __construct()
{
parent::__construct();
}

public function handle()
{
$packages = [
'ralphjsmit/laravel-glide' => '^1.2',
];

$requireCommand = 'composer require';
foreach ($packages as $package => $version) {
$requireCommand .= " {$package}:{$version}";
}

$this->info('Installing packages...');

$this->runShellCommand($requireCommand);

$this->info('Packages installed successfully.');
}

private function runShellCommand($command)
{
$process = Process::fromShellCommandline($command);

// Set the input to the process's standard input, allowing for interaction
$process->setTty(Process::isTtySupported());

// Run the process
$process->run(function ($type, $buffer) {
$this->output->write($buffer);
});

if (! $process->isSuccessful()) {
throw new ProcessFailedException($process);
}
}
}
4 changes: 3 additions & 1 deletion src/NavigationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Fuelviews\Navigation;

use Fuelviews\Navigation\Commands\NavigationInstallCommand;
use Fuelviews\Navigation\View\Components\Desktop\DesktopDropdownButton;
use Fuelviews\Navigation\View\Components\Desktop\DesktopNavigation;
use Fuelviews\Navigation\View\Components\Mobile\MobileNavigation;
Expand All @@ -19,7 +20,8 @@ public function configurePackage(Package $package): void
->name('navigation')
->hasConfigFile('navigation')
->hasViews('navigation')
->hasViewComponents('navigation', NavigationScroll::class, TopBar::class);
->hasViewComponents('navigation', NavigationScroll::class, TopBar::class)
->hasCommand(NavigationInstallCommand::class);
}

public function bootingPackage(): void
Expand Down

0 comments on commit e5489f5

Please sign in to comment.