Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into augmentation-improv…
Browse files Browse the repository at this point in the history
…ements
  • Loading branch information
duncanmcclean committed May 3, 2024
2 parents b3fb0ef + 751d448 commit fa0281d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Binary file added php-cs-fixer.phar
Binary file not shown.
21 changes: 17 additions & 4 deletions src/Console/Commands/GenerateMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace StatamicRadPack\Runway\Console\Commands;

use Facades\Statamic\Facades\Endpoint\Path;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Process;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use Statamic\Console\RunsInPlease;
use Statamic\Fields\Field;
use StatamicRadPack\Runway\Resource;
use StatamicRadPack\Runway\Runway;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\PhpExecutableFinder;

use function Laravel\Prompts\confirm;

Expand Down Expand Up @@ -335,9 +337,20 @@ protected function generateNewTableMigration(Resource $resource, array $columns)
$migrationContents
);

$rules = '@PSR2,@PhpCsFixer,no_space_after_class_name';
$rules = '@PSR2,@PhpCsFixer';

$process = new Process(['./vendor/bin/php-cs-fixer', 'fix', $migrationPath, '--rules='.$rules], base_path());
$process->run();
Process::path(base_path())->run(
(new PhpExecutableFinder())->find().
' /'.Path::makeRelative(__DIR__.'/../../../php-cs-fixer.phar').
' fix '.$migrationPath.' --rules='.$rules
);

// I can't figure out the PHP CS Fixer rule for it, so I'm just going to do it manually for now.
File::put(
$migrationPath,
Str::of(File::get($migrationPath))
->replace('return new class() extends Migration', 'return new class extends Migration')
->__toString()
);
}
}
4 changes: 2 additions & 2 deletions tests/Console/Commands/GenerateMigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function setUp(): void

Runway::discoverResources();

collect(File::glob(database_path('migrations/*')))->each(function ($path) {
File::delete($path);
collect(File::allFiles(database_path('migrations')))->each(function (SplFileInfo $file) {
File::delete($file->getRealPath());
});
}

Expand Down

0 comments on commit fa0281d

Please sign in to comment.