Skip to content

Commit

Permalink
Merge pull request #12 from whitecube/package-installation
Browse files Browse the repository at this point in the history
Reworked package installation
  • Loading branch information
voidgraphics authored Apr 12, 2023
2 parents c6b00d2 + 2169174 commit 481cb52
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 37 deletions.
13 changes: 1 addition & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,7 @@
],
"require": {
"php": "^8.0",
"laravel/ui": "^4.0",
"barryvdh/laravel-debugbar": "^3.6",
"whitecube/bem-components": "^1.1",
"whitecube/laravel-sluggable": "^1.6"
},
"require-dev": {
"pestphp/pest-plugin-laravel": "^1.4.0",
"laravel/pint": "^1.0",
"laravel/helpers": "^1.3",
"orchestra/testbench": "^7.0|^8.0",
"phpunit/phpunit": "^9.0|^10.0",
"spatie/laravel-log-dumper": "^1.4"
"laravel/ui": "^4.0"
},
"autoload": {
"psr-4": {
Expand Down
62 changes: 62 additions & 0 deletions src/Composer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Whitecube\LaravelPreset;

use \File;
use Laravel\Ui\UiCommand;

class Composer
{
protected static $composer;

public static function install(UiCommand $command)
{
$command->info('Installing composer packages & scripts...');

static::$composer = app()->make(\Whitecube\LaravelPreset\Support\Composer::class);

static::installPackages($command);
static::copyStub();
}

public static function installPackages()
{
$packages = [
'barryvdh/laravel-debugbar',
'pestphp/pest',
'pestphp/pest-plugin-laravel',
'laravel/pint',
'spatie/laravel-log-dumper',
'spatie/laravel-ray'
];

static::$composer->run(['require', ...$packages]);
}

public static function copyStub()
{
File::ensureDirectoryExists('app/Console/Commands');
copy(__DIR__ . '/stubs/ComposerEnv.stub', app_path('Console/Commands/ComposerEnv.php'));
}

public static function addComposerScripts()
{
static::$composer->run([
'config',
'scripts.pre-install-cmd',
'App\\Console\\Commands\\ComposerEnv::loadLocalRepositories'
]);

static::$composer->run([
'config',
'scripts.pre-update-cmd',
'App\\Console\\Commands\\ComposerEnv::loadLocalRepositories'
]);

static::$composer->run([
'config',
'scripts.fix-style',
'./vendor/bin/pint --preset laravel'
]);
}
}
21 changes: 0 additions & 21 deletions src/ComposerEnv.php

This file was deleted.

5 changes: 2 additions & 3 deletions src/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class Pest
public static function install(UiCommand $command)
{
$command->info('Preparing Pest...');
$command->call('pest:install', [
'--no-interaction' => true,
]);

shell_exec('./vendor/bin/pest --init');
}
}
2 changes: 1 addition & 1 deletion src/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public static function install(UiCommand $command)
Sass::install($command);
Assets::install($command);
Storage::install($command);
Composer::install($command);
Pest::install($command);
ComposerEnv::install($command);

$command->info('Installing NPM packages...');
shell_exec('yarn');
Expand Down

0 comments on commit 481cb52

Please sign in to comment.