diff --git a/.env.dev b/.env.dev
index ee64a43..43e54c6 100644
--- a/.env.dev
+++ b/.env.dev
@@ -1,2 +1,2 @@
APP_NAME=Revive
-APP_VERSION=3.0.2
+APP_VERSION=3.0.3
diff --git a/app/Actions/Clean.php b/app/Actions/Clean.php
index 621abb4..ec9cf17 100644
--- a/app/Actions/Clean.php
+++ b/app/Actions/Clean.php
@@ -2,7 +2,7 @@
namespace App\Actions;
-use App\Support\Tool;
+use App\Contracts\Tool;
use Illuminate\Console\Command;
class Clean
diff --git a/app/Commands/FixCommand.php b/app/Commands/FixCommand.php
index c7c7f3d..faf11ac 100644
--- a/app/Commands/FixCommand.php
+++ b/app/Commands/FixCommand.php
@@ -2,8 +2,8 @@
namespace App\Commands;
-use App\Support\ConfiguresForLintOrFix;
-use App\Support\GetsCleaner;
+use App\Concerns\ConfiguresForLintOrFix;
+use App\Concerns\GetsCleaner;
use Exception;
use LaravelZero\Framework\Commands\Command;
use LaravelZero\Framework\Exceptions\ConsoleException;
@@ -30,7 +30,7 @@ public function handle(): int
} catch (Exception $exception) {
$this->error($exception->getMessage());
- return 1;
+ return Command::FAILURE;
}
}
}
diff --git a/app/Commands/GitHubActionsCommand.php b/app/Commands/GitHubActionsCommand.php
index 6c2490a..2fc46ba 100644
--- a/app/Commands/GitHubActionsCommand.php
+++ b/app/Commands/GitHubActionsCommand.php
@@ -2,13 +2,14 @@
namespace App\Commands;
+use App\Concerns\CommandHelpers;
use Illuminate\Support\Str;
use LaravelZero\Framework\Commands\Command;
-use function Termwind\render;
-
class GitHubActionsCommand extends Command
{
+ use CommandHelpers;
+
protected $signature = 'github-actions';
protected $description = 'Publish GitHub Actions';
@@ -47,16 +48,4 @@ public function handle(): int
return Command::SUCCESS;
}
-
- private function success(string $message): void
- {
- render(<<
-
Success
-
- {$message}
-
-
- HTML);
- }
}
diff --git a/app/Commands/HuskyHooksCommand.php b/app/Commands/HuskyHooksCommand.php
index e01a8ae..66ad684 100644
--- a/app/Commands/HuskyHooksCommand.php
+++ b/app/Commands/HuskyHooksCommand.php
@@ -2,24 +2,23 @@
namespace App\Commands;
+use App\Concerns\CommandHelpers;
use LaravelZero\Framework\Commands\Command;
use RuntimeException;
use Symfony\Component\Process\Process;
-use function Termwind\render;
-
class HuskyHooksCommand extends Command
{
+ use CommandHelpers;
+
protected $signature = 'husky-hooks';
protected $description = 'Publish Husky Hooks';
/**
* Execute the console command.
- *
- * @return mixed
*/
- public function handle()
+ public function handle(): int
{
$choices = [
'Lint only' => 'lint',
@@ -57,6 +56,8 @@ public function handle()
$this->runCommands(["npx husky add ./.husky/pre-commit 'npx --no-install lint-staged'"]);
$this->success('Husky Pre-Commit Git Hook added');
+
+ return Command::SUCCESS;
}
/**
@@ -80,16 +81,4 @@ protected function runCommands(array $commands): void
$this->output->write(' ' . $line);
});
}
-
- private function success(string $message): void
- {
- render(<<
- Success
-
- {$message}
-
-
- HTML);
- }
}
diff --git a/app/Commands/LintCommand.php b/app/Commands/LintCommand.php
index 64031fb..f73d916 100644
--- a/app/Commands/LintCommand.php
+++ b/app/Commands/LintCommand.php
@@ -2,8 +2,8 @@
namespace App\Commands;
-use App\Support\ConfiguresForLintOrFix;
-use App\Support\GetsCleaner;
+use App\Concerns\ConfiguresForLintOrFix;
+use App\Concerns\GetsCleaner;
use Exception;
use LaravelZero\Framework\Commands\Command;
use LaravelZero\Framework\Exceptions\ConsoleException;
@@ -30,7 +30,7 @@ public function handle(): int
} catch (Exception $exception) {
$this->error($exception->getMessage());
- return 1;
+ return Command::FAILURE;
}
}
}
diff --git a/app/Support/Tool.php b/app/Concerns/CommandHelpers.php
similarity index 71%
rename from app/Support/Tool.php
rename to app/Concerns/CommandHelpers.php
index e8ad170..070eb9e 100644
--- a/app/Support/Tool.php
+++ b/app/Concerns/CommandHelpers.php
@@ -1,27 +1,19 @@
=> ' . $heading . '');
+ render('>> success: ' . $message . '
');
}
- public function success(string $message): void
+ public function heading(string $heading): void
{
- render('>> success: ' . $message . '
');
+ render('=> ' . $heading . '
');
}
public function failure(string $message): void
diff --git a/app/Support/ConfiguresForLintOrFix.php b/app/Concerns/ConfiguresForLintOrFix.php
similarity index 97%
rename from app/Support/ConfiguresForLintOrFix.php
rename to app/Concerns/ConfiguresForLintOrFix.php
index b2e48bf..b0d59da 100644
--- a/app/Support/ConfiguresForLintOrFix.php
+++ b/app/Concerns/ConfiguresForLintOrFix.php
@@ -1,6 +1,6 @@
app->singleton(ErrorsManager::class, fn () => new ErrorsManager);
diff --git a/app/Providers/ReviveServiceProvider.php b/app/Providers/ReviveServiceProvider.php
index 974e73b..cf6990f 100644
--- a/app/Providers/ReviveServiceProvider.php
+++ b/app/Providers/ReviveServiceProvider.php
@@ -9,7 +9,7 @@
class ReviveServiceProvider extends ServiceProvider
{
- public function register()
+ public function register(): void
{
$this->app->singleton(ReviveConfig::class, function () {
$input = $this->app->get(InputInterface::class);
diff --git a/app/Repositories/PintConfigurationJsonRepository.php b/app/Repositories/PintConfigurationJsonRepository.php
index 20889ff..86e82a5 100644
--- a/app/Repositories/PintConfigurationJsonRepository.php
+++ b/app/Repositories/PintConfigurationJsonRepository.php
@@ -2,6 +2,8 @@
namespace App\Repositories;
+use JsonException;
+
class PintConfigurationJsonRepository extends ConfigurationJsonRepository
{
/**
@@ -11,10 +13,14 @@ public function __construct(
protected $path,
protected $preset,
protected array $exclude
- ) {}
+ ) {
+ parent::__construct($path, $preset);
+ }
/**
* @return array|string>
+ *
+ * @throws JsonException
*/
protected function get(): array
{
@@ -29,6 +35,8 @@ protected function get(): array
/**
* @return array|string>
+ *
+ * @throws JsonException
*/
protected function getPintConfig(): array
{
diff --git a/app/Support/PhpCodeSniffer.php b/app/Support/PhpCodeSniffer.php
index 215fbac..16f0911 100644
--- a/app/Support/PhpCodeSniffer.php
+++ b/app/Support/PhpCodeSniffer.php
@@ -2,6 +2,7 @@
namespace App\Support;
+use App\Contracts\Tool;
use App\Project;
use PHP_CodeSniffer\Config;
use PHP_CodeSniffer\Runner;
diff --git a/app/Support/PhpCsFixer.php b/app/Support/PhpCsFixer.php
index 7ae5315..6d9e0ba 100644
--- a/app/Support/PhpCsFixer.php
+++ b/app/Support/PhpCsFixer.php
@@ -3,9 +3,9 @@
namespace App\Support;
use App\Actions\ElaborateSummary;
+use App\Contracts\Tool;
use App\Project;
use ArrayIterator;
-use PhpCsFixer\Config;
use PhpCsFixer\ConfigInterface;
use PhpCsFixer\ConfigurationException\InvalidConfigurationException;
use PhpCsFixer\Console\ConfigurationResolver;
diff --git a/app/Support/Pint.php b/app/Support/Pint.php
index 2be70ec..f48fad4 100644
--- a/app/Support/Pint.php
+++ b/app/Support/Pint.php
@@ -5,6 +5,7 @@
use App\Actions\ElaborateSummary;
use App\Actions\FixCode;
use App\Commands\DefaultCommand;
+use App\Contracts\Tool;
class Pint extends Tool
{
diff --git a/app/Support/ReviveConfig.php b/app/Support/ReviveConfig.php
index 9bd987b..c16551c 100644
--- a/app/Support/ReviveConfig.php
+++ b/app/Support/ReviveConfig.php
@@ -6,6 +6,7 @@
use Exception;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
+use JsonException;
use Symfony\Component\Finder\Finder;
class ReviveConfig
@@ -29,40 +30,6 @@ public function __construct(
$this->config = static::scopeConfigPaths($this->config);
}
- /**
- * @return array
- */
- public static function loadLocal(): array
- {
- if (file_exists(Project::path() . '/revive.json')) {
- return tap(json_decode(
- file_get_contents(Project::path() . '/revive.json'),
- true,
- 512,
- JSON_THROW_ON_ERROR
- ), function ($configuration) {
- if (! is_array($configuration)) {
- abort(1, 'The configuration file revive.json is not valid JSON.');
- }
- });
- }
-
- if (file_exists(Project::path() . '/vendor/devanoxltd/laravel-revive/revive.json')) {
- return tap(json_decode(
- file_get_contents(Project::path() . '/vendor/devanoxltd/laravel-revive/revive.json'),
- true,
- 512,
- JSON_THROW_ON_ERROR
- ), function ($configuration) {
- if (! is_array($configuration)) {
- abort(1, 'The configuration file revive.json is not valid JSON.');
- }
- });
- }
-
- return [];
- }
-
/**
* @param array|string> $config
* @return array|string>
@@ -143,6 +110,42 @@ public static function globPath(string $path): array
}
}
+ /**
+ * @return array
+ *
+ * @throws JsonException
+ */
+ public static function loadLocal(): array
+ {
+ if (file_exists(Project::path() . '/revive.json')) {
+ return tap(json_decode(
+ file_get_contents(Project::path() . '/revive.json'),
+ true,
+ 512,
+ JSON_THROW_ON_ERROR
+ ), function ($configuration) {
+ if (! is_array($configuration)) {
+ abort(1, 'The configuration file revive.json is not valid JSON.');
+ }
+ });
+ }
+
+ if (file_exists(Project::path() . '/vendor/devanoxltd/laravel-revive/revive.json')) {
+ return tap(json_decode(
+ file_get_contents(Project::path() . '/vendor/devanoxltd/laravel-revive/revive.json'),
+ true,
+ 512,
+ JSON_THROW_ON_ERROR
+ ), function ($configuration) {
+ if (! is_array($configuration)) {
+ abort(1, 'The configuration file revive.json is not valid JSON.');
+ }
+ });
+ }
+
+ return [];
+ }
+
public function get(string $key, mixed $default = null): mixed
{
return Arr::get($this->config, $key, $default);
diff --git a/app/Support/TLint.php b/app/Support/TLint.php
index e7a5470..3e55b0f 100644
--- a/app/Support/TLint.php
+++ b/app/Support/TLint.php
@@ -2,10 +2,14 @@
namespace App\Support;
+use App\Contracts\Tool;
use Illuminate\Console\Command;
+use Psr\Container\ContainerExceptionInterface;
+use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\OutputInterface;
+use Throwable;
use Tighten\TLint\Commands\BaseCommand;
use Tighten\TLint\Commands\FormatCommand;
use Tighten\TLint\Commands\LintCommand;
@@ -61,6 +65,11 @@ private function executeCommand(BaseCommand $tlintCommand): bool
->isEmpty();
}
+ /**
+ * @throws ContainerExceptionInterface
+ * @throws Throwable
+ * @throws NotFoundExceptionInterface
+ */
private function executeCommandOnPath(string $path, Application $application): int
{
$path = '"' . str_replace('\\', '\\\\', $path) . '"';
diff --git a/app/Support/UserScript.php b/app/Support/UserScript.php
index 6adaed0..2166f19 100644
--- a/app/Support/UserScript.php
+++ b/app/Support/UserScript.php
@@ -2,6 +2,11 @@
namespace App\Support;
+use App\Contracts\Tool;
+use Illuminate\Console\Command;
+use JsonException;
+use Psr\Container\ContainerExceptionInterface;
+use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Exception\ProcessTimedOutException;
use Symfony\Component\Process\Process;
@@ -15,7 +20,9 @@ public function __construct(
protected string $name,
protected array $command,
protected ReviveConfig $reviveConfig,
- ) {}
+ ) {
+ parent::__construct($reviveConfig);
+ }
public function lint(): int
{
@@ -24,6 +31,11 @@ public function lint(): int
return $this->process();
}
+ /**
+ * @throws ContainerExceptionInterface
+ * @throws NotFoundExceptionInterface
+ * @throws JsonException
+ */
public function fix(): int
{
$this->heading('Fixing using ' . $this->name);
@@ -31,6 +43,11 @@ public function fix(): int
return $this->process();
}
+ /**
+ * @throws ContainerExceptionInterface
+ * @throws NotFoundExceptionInterface
+ * @throws JsonException
+ */
private function process(): int
{
$reviveConfig = ReviveConfig::loadLocal();
@@ -46,7 +63,7 @@ private function process(): int
} catch (ProcessTimedOutException $e) {
$this->failure($e->getMessage() . '
You can overwrite this timeout with the processTimeout key in your revive.json file.');
- return 1;
+ return Command::FAILURE;
}
}
}
diff --git a/standards/Devanox/ruleset.xml b/standards/Devanox/ruleset.xml
index 2938ea2..ee3fdd0 100644
--- a/standards/Devanox/ruleset.xml
+++ b/standards/Devanox/ruleset.xml
@@ -20,8 +20,9 @@
-
+
/public/index.php
+ */tests/*