Skip to content

Commit

Permalink
lint fix, add github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
stepanenko3 committed Mar 14, 2024
1 parent 68504cb commit 449ee54
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 34 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/" # Location of package manifests
schedule:
interval: "daily"
27 changes: 27 additions & 0 deletions .github/workflows/php-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# .github/workflows/duster.yml
name: PHP Lint

on:
push:
branches: main
pull_request:

jobs:
php-lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: "Setup PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "latest"

- name: "composer install"
run: composer install --no-cache --ignore-platform-reqs --no-interaction --prefer-dist --optimize-autoloader --apcu-autoloader

- name: "duster"
uses: tighten/duster-action@v2
with:
args: lint --using=phpstan,tlint,phpcs,pint
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"require-dev": {
"laravel/pint": "^1.2",
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^9.3"
"phpunit/phpunit": "^9.3",
"tightenco/duster": "^2.7"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

abstract class Action
{
private bool $failed = false;
protected ?string $errorMessage = null;

protected string | null $errorMessage = null;
private bool $failed = false;

public function __construct(
private Command $artisanCommnad,
Expand Down
5 changes: 3 additions & 2 deletions src/Console/Commands/AbstractInitializeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Container\Container;
use Illuminate\Support\Carbon;
use Stepanenko3\LaravelInitializer\Run;

use function Termwind\terminal;

abstract class AbstractInitializeCommand extends Command
Expand Down Expand Up @@ -117,8 +118,6 @@ public function writeOutput($text, $status)
});
}

abstract protected function title(): string;

public function choice(
$question,
array $choices,
Expand All @@ -130,4 +129,6 @@ public function choice(
) {
return $this->components->choice($question, $choices, $default);
}

abstract protected function title(): string;
}
4 changes: 2 additions & 2 deletions src/Contracts/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

interface Runner
{
public function when($value = null, callable $callback = null, callable $default = null);
public function when($value = null, ?callable $callback = null, ?callable $default = null);

public function unless($value = null, callable $callback = null, callable $default = null);
public function unless($value = null, ?callable $callback = null, ?callable $default = null);

public function choice(string $question, array $choices): self;

Expand Down
2 changes: 0 additions & 2 deletions src/Jobs/MakeCronTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class MakeCronTask

/**
* Execute the job.
*
* @return string
*/
public function handle(): string
{
Expand Down
2 changes: 0 additions & 2 deletions src/Jobs/MakeEchoServerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public function __construct(

/**
* Execute the job.
*
* @return string
*/
public function handle(): string
{
Expand Down
5 changes: 0 additions & 5 deletions src/Jobs/Supervisor/MakeSupervisorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function __construct(

/**
* Execute the job.
*
* @return string
*/
public function handle(): string
{
Expand Down Expand Up @@ -78,9 +76,6 @@ protected function getLogsPath(): string
return storage_path('logs');
}

/**
* @return string
*/
protected function configName(): string
{
return Str::slug($this->getApplicationName() . '-' . $this->processName);
Expand Down
36 changes: 18 additions & 18 deletions src/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Illuminate\Console\Command;
use Illuminate\Support\Traits\Conditionable;
use Stepanenko3\LaravelInitializer\Actions\{Action, Artisan, Callback, Dispatch, External, Publish, PublishTag};
use Stepanenko3\LaravelInitializer\Contracts\Runner as RunnerContract;
use Stepanenko3\LaravelInitializerActions\{Action, Artisan, Callback, Dispatch, External, Publish, PublishTag};

class Run implements RunnerContract
{
Expand All @@ -26,23 +26,6 @@ public function errorMessages(): array
return $this->errorMessages;
}

private function run(Action $action): self
{
$action();

if ($action->failed()) {
if (!$this->doneWithErrors) {
$this->doneWithErrors = true;
}

if ($message = $action->errorMessage()) {
$this->errorMessages[] = $message;
}
}

return $this;
}

public function choice(
string $question,
array $choices,
Expand Down Expand Up @@ -110,4 +93,21 @@ public function dispatchNow($job): RunnerContract
{
return $this->run(new Dispatch($this->artisanCommand, $job, true));
}

private function run(Action $action): self
{
$action();

if ($action->failed()) {
if (!$this->doneWithErrors) {
$this->doneWithErrors = true;
}

if ($message = $action->errorMessage()) {
$this->errorMessages[] = $message;
}
}

return $this;
}
}

0 comments on commit 449ee54

Please sign in to comment.