diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c878d51..088b27e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -16,17 +16,15 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] php: [8.3, 8.2] - laravel: [11.*, 10.*] - stability: [prefer-lowest, prefer-stable] + laravel: [12.*] + stability: [prefer-stable] include: - - laravel: 11.* - testbench: 9.* - carbon: ^2.63 - - laravel: 10.* - testbench: 8.* - carbon: ^2.63 + - laravel: 12.* + testbench: 10.* + carbon: 3.* + collision: 8.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index e65dc3e..90bc46d 100644 --- a/composer.json +++ b/composer.json @@ -31,8 +31,7 @@ "pestphp/pest-plugin-laravel": "^2.3", "phpstan/extension-installer": "^1.3", "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "spatie/laravel-ray": "^1.35" + "phpstan/phpstan-phpunit": "^1.3" }, "autoload": { "psr-4": { diff --git a/configure.php b/configure.php index 0ecd73c..f8366ca 100644 --- a/configure.php +++ b/configure.php @@ -3,7 +3,7 @@ function ask(string $question, string $default = ''): string { - $answer = readline($question . ($default ? " ({$default})" : null) . ': '); + $answer = readline($question.($default ? " ({$default})" : null).': '); if (! $answer) { return $default; @@ -14,7 +14,7 @@ function ask(string $question, string $default = ''): string function confirm(string $question, bool $default = false): bool { - $answer = ask($question . ' (' . ($default ? 'Y/n' : 'y/N') . ')'); + $answer = ask($question.' ('.($default ? 'Y/n' : 'y/N').')'); if (! $answer) { return $default; @@ -25,7 +25,7 @@ function confirm(string $question, bool $default = false): bool function writeln(string $line): void { - echo $line . PHP_EOL; + echo $line.PHP_EOL; } function run(string $command): string @@ -84,7 +84,7 @@ function remove_prefix(string $prefix, string $content): string function remove_composer_deps(array $names) { - $data = json_decode(file_get_contents(__DIR__ . '/composer.json'), true); + $data = json_decode(file_get_contents(__DIR__.'/composer.json'), true); foreach ($data['require-dev'] as $name => $version) { if (in_array($name, $names, true)) { @@ -92,12 +92,12 @@ function remove_composer_deps(array $names) } } - file_put_contents(__DIR__ . '/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + file_put_contents(__DIR__.'/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } function remove_composer_script($scriptName) { - $data = json_decode(file_get_contents(__DIR__ . '/composer.json'), true); + $data = json_decode(file_get_contents(__DIR__.'/composer.json'), true); foreach ($data['scripts'] as $name => $script) { if ($scriptName === $name) { @@ -107,7 +107,7 @@ function remove_composer_script($scriptName) } } - file_put_contents(__DIR__ . '/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + file_put_contents(__DIR__.'/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } function remove_readme_paragraphs(string $file): void @@ -134,12 +134,12 @@ function determineSeparator(string $path): string function replaceForWindows(): array { - return preg_split('/\\r\\n|\\r|\\n/', run('dir /S /B * | findstr /v /i .git\ | findstr /v /i vendor | findstr /v /i ' . basename(__FILE__) . ' | findstr /r /i /M /F:/ ":author :vendor :package VendorName skeleton migration_table_name vendor_name vendor_slug author@domain.com"')); + return preg_split('/\\r\\n|\\r|\\n/', run('dir /S /B * | findstr /v /i .git\ | findstr /v /i vendor | findstr /v /i '.basename(__FILE__).' | findstr /r /i /M /F:/ ":author :vendor :package VendorName skeleton migration_table_name vendor_name vendor_slug author@domain.com"')); } function replaceForAllOtherOSes(): array { - return explode(PHP_EOL, run('grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|migration_table_name|vendor_name|vendor_slug|author@domain.com" --exclude-dir=vendor ./* ./.github/* | grep -v ' . basename(__FILE__))); + return explode(PHP_EOL, run('grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|migration_table_name|vendor_name|vendor_slug|author@domain.com" --exclude-dir=vendor ./* ./.github/* | grep -v '.basename(__FILE__))); } function getGitHubApiEndpoint(string $endpoint): ?stdClass @@ -273,7 +273,6 @@ function guessGitHubVendorInfo($authorName, $username): array $usePhpStan = confirm('Enable PhpStan?', true); $useLaravelPint = confirm('Enable Laravel Pint?', true); $useDependabot = confirm('Enable Dependabot?', true); -$useLaravelRay = confirm('Use Ray for debugging?', true); $useUpdateChangelogWorkflow = confirm('Use automatic changelog updater workflow?', true); writeln('------'); @@ -284,11 +283,10 @@ function guessGitHubVendorInfo($authorName, $username): array writeln("Class name : {$className}"); writeln('---'); writeln('Packages & Utilities'); -writeln('Use Laravel/Pint : ' . ($useLaravelPint ? 'yes' : 'no')); -writeln('Use Larastan/PhpStan : ' . ($usePhpStan ? 'yes' : 'no')); -writeln('Use Dependabot : ' . ($useDependabot ? 'yes' : 'no')); -writeln('Use Ray App : ' . ($useLaravelRay ? 'yes' : 'no')); -writeln('Use Auto-Changelog : ' . ($useUpdateChangelogWorkflow ? 'yes' : 'no')); +writeln('Use Laravel/Pint : '.($useLaravelPint ? 'yes' : 'no')); +writeln('Use Larastan/PhpStan : '.($usePhpStan ? 'yes' : 'no')); +writeln('Use Dependabot : '.($useDependabot ? 'yes' : 'no')); +writeln('Use Auto-Changelog : '.($useUpdateChangelogWorkflow ? 'yes' : 'no')); writeln('------'); writeln('This script will replace the above values in all relevant files in the project directory.'); @@ -318,26 +316,26 @@ function guessGitHubVendorInfo($authorName, $username): array ]); match (true) { - str_contains($file, determineSeparator('src/Skeleton.php')) => rename($file, determineSeparator('./src/' . $className . '.php')), - str_contains($file, determineSeparator('src/SkeletonServiceProvider.php')) => rename($file, determineSeparator('./src/' . $className . 'ServiceProvider.php')), - str_contains($file, determineSeparator('src/Facades/Skeleton.php')) => rename($file, determineSeparator('./src/Facades/' . $className . '.php')), - str_contains($file, determineSeparator('src/Commands/SkeletonCommand.php')) => rename($file, determineSeparator('./src/Commands/' . $className . 'Command.php')), - str_contains($file, determineSeparator('database/migrations/create_skeleton_table.php.stub')) => rename($file, determineSeparator('./database/migrations/create_' . title_snake($packageSlugWithoutPrefix) . '_table.php.stub')), - str_contains($file, determineSeparator('config/skeleton.php')) => rename($file, determineSeparator('./config/' . $packageSlugWithoutPrefix . '.php')), + str_contains($file, determineSeparator('src/Skeleton.php')) => rename($file, determineSeparator('./src/'.$className.'.php')), + str_contains($file, determineSeparator('src/SkeletonServiceProvider.php')) => rename($file, determineSeparator('./src/'.$className.'ServiceProvider.php')), + str_contains($file, determineSeparator('src/Facades/Skeleton.php')) => rename($file, determineSeparator('./src/Facades/'.$className.'.php')), + str_contains($file, determineSeparator('src/Commands/SkeletonCommand.php')) => rename($file, determineSeparator('./src/Commands/'.$className.'Command.php')), + str_contains($file, determineSeparator('database/migrations/create_skeleton_table.php.stub')) => rename($file, determineSeparator('./database/migrations/create_'.title_snake($packageSlugWithoutPrefix).'_table.php.stub')), + str_contains($file, determineSeparator('config/skeleton.php')) => rename($file, determineSeparator('./config/'.$packageSlugWithoutPrefix.'.php')), str_contains($file, 'README.md') => remove_readme_paragraphs($file), default => [], }; } if (! $useLaravelPint) { - safeUnlink(__DIR__ . '/.github/workflows/fix-php-code-style-issues.yml'); - safeUnlink(__DIR__ . '/pint.json'); + safeUnlink(__DIR__.'/.github/workflows/fix-php-code-style-issues.yml'); + safeUnlink(__DIR__.'/pint.json'); } if (! $usePhpStan) { - safeUnlink(__DIR__ . '/phpstan.neon.dist'); - safeUnlink(__DIR__ . '/phpstan-baseline.neon'); - safeUnlink(__DIR__ . '/.github/workflows/phpstan.yml'); + safeUnlink(__DIR__.'/phpstan.neon.dist'); + safeUnlink(__DIR__.'/phpstan-baseline.neon'); + safeUnlink(__DIR__.'/.github/workflows/phpstan.yml'); remove_composer_deps([ 'phpstan/extension-installer', @@ -350,16 +348,12 @@ function guessGitHubVendorInfo($authorName, $username): array } if (! $useDependabot) { - safeUnlink(__DIR__ . '/.github/dependabot.yml'); - safeUnlink(__DIR__ . '/.github/workflows/dependabot-auto-merge.yml'); -} - -if (! $useLaravelRay) { - remove_composer_deps(['spatie/laravel-ray']); + safeUnlink(__DIR__.'/.github/dependabot.yml'); + safeUnlink(__DIR__.'/.github/workflows/dependabot-auto-merge.yml'); } if (! $useUpdateChangelogWorkflow) { - safeUnlink(__DIR__ . '/.github/workflows/update-changelog.yml'); + safeUnlink(__DIR__.'/.github/workflows/update-changelog.yml'); } confirm('Execute `composer install` and run tests?') && run('composer install && composer test'); diff --git a/tests/TestCase.php b/tests/TestCase.php index b504517..d700567 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -13,7 +13,7 @@ protected function setUp(): void parent::setUp(); Factory::guessFactoryNamesUsing( - fn (string $modelName) => 'Backstage\Laravel\\AI\\Database\\Factories\\' . class_basename($modelName) . 'Factory' + fn (string $modelName) => 'Backstage\Laravel\\AI\\Database\\Factories\\'.class_basename($modelName).'Factory' ); }