Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Sep 18, 2024
1 parent 8150f95 commit 8ac4881
Show file tree
Hide file tree
Showing 45 changed files with 266 additions and 257 deletions.
2 changes: 1 addition & 1 deletion src/BreezeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function register()
*/
public function boot()
{
if (! $this->app->runningInConsole()) {
if (!$this->app->runningInConsole()) {
return;
}

Expand Down
78 changes: 43 additions & 35 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,29 @@ public function handle()
*/
protected function installTests()
{
(new Filesystem)->ensureDirectoryExists(base_path('tests/Feature'));
(new Filesystem())->ensureDirectoryExists(base_path('tests/Feature'));

$stubStack = match ($this->argument('stack')) {
'api' => 'api',
'livewire' => 'livewire-common',
'api' => 'api',
'livewire' => 'livewire-common',
'livewire-functional' => 'livewire-common',
default => 'default',
default => 'default',
};

if ($this->option('pest') || $this->isUsingPest()) {
if ($this->hasComposerPackage('phpunit/phpunit')) {
$this->removeComposerPackages(['phpunit/phpunit'], true);
}

if (! $this->requireComposerPackages(['pestphp/pest', 'pestphp/pest-plugin-laravel'], true)) {
if (!$this->requireComposerPackages(['pestphp/pest', 'pestphp/pest-plugin-laravel'], true)) {
return false;
}

(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/'.$stubStack.'/pest-tests/Feature', base_path('tests/Feature'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/'.$stubStack.'/pest-tests/Unit', base_path('tests/Unit'));
(new Filesystem)->copy(__DIR__.'/../../stubs/'.$stubStack.'/pest-tests/Pest.php', base_path('tests/Pest.php'));
(new Filesystem())->copyDirectory(__DIR__.'/../../stubs/'.$stubStack.'/pest-tests/Feature', base_path('tests/Feature'));
(new Filesystem())->copyDirectory(__DIR__.'/../../stubs/'.$stubStack.'/pest-tests/Unit', base_path('tests/Unit'));
(new Filesystem())->copy(__DIR__.'/../../stubs/'.$stubStack.'/pest-tests/Pest.php', base_path('tests/Pest.php'));
} else {
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/'.$stubStack.'/tests/Feature', base_path('tests/Feature'));
(new Filesystem())->copyDirectory(__DIR__.'/../../stubs/'.$stubStack.'/tests/Feature', base_path('tests/Feature'));
}

return true;
Expand All @@ -111,17 +111,18 @@ protected function installTests()
/**
* Install the given middleware names into the application.
*
* @param array|string $name
* @param string $group
* @param string $modifier
* @param array|string $name
* @param string $group
* @param string $modifier
*
* @return void
*/
protected function installMiddleware($names, $group = 'web', $modifier = 'append')
{
$bootstrapApp = file_get_contents(base_path('bootstrap/app.php'));

$names = collect(Arr::wrap($names))
->filter(fn ($name) => ! Str::contains($bootstrapApp, $name))
->filter(fn ($name) => !Str::contains($bootstrapApp, $name))
->whenNotEmpty(function ($names) use ($bootstrapApp, $group, $modifier) {
$names = $names->map(fn ($name) => "$name")->implode(','.PHP_EOL.' ');

Expand All @@ -142,15 +143,16 @@ protected function installMiddleware($names, $group = 'web', $modifier = 'append
/**
* Install the given middleware aliases into the application.
*
* @param array $aliases
* @param array $aliases
*
* @return void
*/
protected function installMiddlewareAliases($aliases)
{
$bootstrapApp = file_get_contents(base_path('bootstrap/app.php'));

$aliases = collect($aliases)
->filter(fn ($alias) => ! Str::contains($bootstrapApp, $alias))
->filter(fn ($alias) => !Str::contains($bootstrapApp, $alias))
->whenNotEmpty(function ($aliases) use ($bootstrapApp) {
$aliases = $aliases->map(fn ($name, $alias) => "'$alias' => $name")->implode(','.PHP_EOL.' ');

Expand All @@ -171,7 +173,8 @@ protected function installMiddlewareAliases($aliases)
/**
* Determine if the given Composer package is installed.
*
* @param string $package
* @param string $package
*
* @return bool
*/
protected function hasComposerPackage($package)
Expand All @@ -185,7 +188,8 @@ protected function hasComposerPackage($package)
/**
* Installs the given Composer Packages into the application.
*
* @param bool $asDev
* @param bool $asDev
*
* @return bool
*/
protected function requireComposerPackages(array $packages, $asDev = false)
Expand All @@ -212,7 +216,8 @@ protected function requireComposerPackages(array $packages, $asDev = false)
/**
* Removes the given Composer Packages from the application.
*
* @param bool $asDev
* @param bool $asDev
*
* @return bool
*/
protected function removeComposerPackages(array $packages, $asDev = false)
Expand All @@ -239,12 +244,13 @@ protected function removeComposerPackages(array $packages, $asDev = false)
/**
* Update the dependencies in the "package.json" file.
*
* @param bool $dev
* @param bool $dev
*
* @return void
*/
protected static function updateNodePackages(callable $callback, $dev = true)
{
if (! file_exists(base_path('package.json'))) {
if (!file_exists(base_path('package.json'))) {
return;
}

Expand Down Expand Up @@ -272,7 +278,7 @@ protected static function updateNodePackages(callable $callback, $dev = true)
*/
protected static function updateNodeScripts(callable $callback)
{
if (! file_exists(base_path('package.json'))) {
if (!file_exists(base_path('package.json'))) {
return;
}

Expand All @@ -295,7 +301,7 @@ protected static function updateNodeScripts(callable $callback)
*/
protected static function flushNodeModules()
{
tap(new Filesystem, function ($files) {
tap(new Filesystem(), function ($files) {
$files->deleteDirectory(base_path('node_modules'));

$files->delete(base_path('pnpm-lock.yaml'));
Expand All @@ -309,9 +315,10 @@ protected static function flushNodeModules()
/**
* Replace a given string within a given file.
*
* @param string $search
* @param string $replace
* @param string $path
* @param string $search
* @param string $replace
* @param string $path
*
* @return void
*/
protected function replaceInFile($search, $replace, $path)
Expand All @@ -326,13 +333,14 @@ protected function replaceInFile($search, $replace, $path)
*/
protected function phpBinary()
{
return (new PhpExecutableFinder)->find(false) ?: 'php';
return (new PhpExecutableFinder())->find(false) ?: 'php';
}

/**
* Run the given commands.
*
* @param array $commands
* @param array $commands
*
* @return void
*/
protected function runCommands($commands)
Expand Down Expand Up @@ -375,12 +383,12 @@ protected function promptForMissingArgumentsUsing()
'stack' => fn () => select(
label: 'Which Breeze stack would you like to install?',
options: [
'blade' => 'Blade with Alpine',
'livewire' => 'Livewire (Volt Class API) with Alpine',
'blade' => 'Blade with Alpine',
'livewire' => 'Livewire (Volt Class API) with Alpine',
'livewire-functional' => 'Livewire (Volt Functional API) with Alpine',
'react' => 'React with Inertia',
'vue' => 'Vue with Inertia',
'api' => 'API only',
'react' => 'React with Inertia',
'vue' => 'Vue with Inertia',
'api' => 'API only',
],
scroll: 6,
),
Expand All @@ -400,10 +408,10 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp
collect(multiselect(
label: 'Would you like any optional features?',
options: [
'dark' => 'Dark mode',
'ssr' => 'Inertia SSR',
'dark' => 'Dark mode',
'ssr' => 'Inertia SSR',
'typescript' => 'TypeScript',
'eslint' => 'ESLint with Prettier',
'eslint' => 'ESLint with Prettier',
]
))->each(fn ($option) => $input->setOption($option, true));
} elseif (in_array($stack, ['blade', 'livewire', 'livewire-functional'])) {
Expand Down
8 changes: 4 additions & 4 deletions src/Console/InstallsApiStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function installApiStack()
{
$this->runCommands(['php artisan install:api']);

$files = new Filesystem;
$files = new Filesystem();

// Controllers...
$files->ensureDirectoryExists(app_path('Http/Controllers/Auth'));
Expand Down Expand Up @@ -48,7 +48,7 @@ protected function installApiStack()
$files->copyDirectory(__DIR__.'/../../stubs/api/config', config_path());

// Environment...
if (! $files->exists(base_path('.env'))) {
if (!$files->exists(base_path('.env'))) {
copy(base_path('.env.example'), base_path('.env'));
}

Expand All @@ -58,7 +58,7 @@ protected function installApiStack()
);

// Tests...
if (! $this->installTests()) {
if (!$this->installTests()) {
return 1;
}

Expand All @@ -77,7 +77,7 @@ protected function installApiStack()
*/
protected function removeScaffoldingUnnecessaryForApis()
{
$files = new Filesystem;
$files = new Filesystem();

// Remove frontend related files...
$files->delete(base_path('package.json'));
Expand Down
30 changes: 15 additions & 15 deletions src/Console/InstallsBladeStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ protected function installBladeStack()
$this->updateNodePackages(function ($packages) {
return [
'@tailwindcss/forms' => '^0.5.2',
'alpinejs' => '^3.4.2',
'autoprefixer' => '^10.4.2',
'postcss' => '^8.4.31',
'tailwindcss' => '^3.1.0',
'alpinejs' => '^3.4.2',
'autoprefixer' => '^10.4.2',
'postcss' => '^8.4.31',
'tailwindcss' => '^3.1.0',
] + $packages;
});

// Controllers...
(new Filesystem)->ensureDirectoryExists(app_path('Http/Controllers'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/app/Http/Controllers', app_path('Http/Controllers'));
(new Filesystem())->ensureDirectoryExists(app_path('Http/Controllers'));
(new Filesystem())->copyDirectory(__DIR__.'/../../stubs/default/app/Http/Controllers', app_path('Http/Controllers'));

// Requests...
(new Filesystem)->ensureDirectoryExists(app_path('Http/Requests'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/app/Http/Requests', app_path('Http/Requests'));
(new Filesystem())->ensureDirectoryExists(app_path('Http/Requests'));
(new Filesystem())->copyDirectory(__DIR__.'/../../stubs/default/app/Http/Requests', app_path('Http/Requests'));

// Views...
(new Filesystem)->ensureDirectoryExists(resource_path('views'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/resources/views', resource_path('views'));
(new Filesystem())->ensureDirectoryExists(resource_path('views'));
(new Filesystem())->copyDirectory(__DIR__.'/../../stubs/default/resources/views', resource_path('views'));

if (! $this->option('dark')) {
if (!$this->option('dark')) {
$this->removeDarkClasses(
(new Finder)
(new Finder())
->in(resource_path('views'))
->name('*.blade.php')
->notPath('livewire/welcome/navigation.blade.php')
Expand All @@ -48,11 +48,11 @@ protected function installBladeStack()
}

// Components...
(new Filesystem)->ensureDirectoryExists(app_path('View/Components'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/app/View/Components', app_path('View/Components'));
(new Filesystem())->ensureDirectoryExists(app_path('View/Components'));
(new Filesystem())->copyDirectory(__DIR__.'/../../stubs/default/app/View/Components', app_path('View/Components'));

// Tests...
if (! $this->installTests()) {
if (!$this->installTests()) {
return 1;
}

Expand Down
Loading

0 comments on commit 8ac4881

Please sign in to comment.