Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Feb 22, 2023
1 parent 8dac049 commit 61ca9dc
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 15 deletions.
6 changes: 5 additions & 1 deletion src/Illuminate/Cache/Console/CacheTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public function handle()

$this->components->info('Migration created successfully.');

$this->composer->dumpAutoloads();
if (preg_match('/^return new class/', $this->files->get($fullPath)) === 0) {
$this->components->info('Regenerating the Composer autoloader files.');

$this->composer->dumpAutoloads();
}
}

/**
Expand Down
28 changes: 21 additions & 7 deletions src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Contracts\Console\PromptsForMissingInput;
use Illuminate\Database\Migrations\MigrationCreator;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Composer;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -42,19 +43,28 @@ class MigrateMakeCommand extends BaseCommand implements PromptsForMissingInput
*/
protected $composer;

/**
* The filesystem instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;

/**
* Create a new migration install command instance.
*
* @param \Illuminate\Database\Migrations\MigrationCreator $creator
* @param \Illuminate\Support\Composer $composer
* @param \Illuminate\Filesystem\Filesystem $files
* @return void
*/
public function __construct(MigrationCreator $creator, Composer $composer)
public function __construct(MigrationCreator $creator, Composer $composer, Filesystem $files = null)
{
parent::__construct();

$this->creator = $creator;
$this->composer = $composer;
$this->files = $files ?? new Filesystem();
}

/**
Expand Down Expand Up @@ -92,9 +102,13 @@ public function handle()
// Now we are ready to write the migration out to disk. Once we've written
// the migration out, we will dump-autoload for the entire framework to
// make sure that the migrations are registered by the class loaders.
$this->writeMigration($name, $table, $create);
$fullPath = $this->writeMigration($name, $table, $create);

$this->composer->dumpAutoloads();
if (preg_match('/^return new class/', $this->files->get($fullPath)) === 0) {
$this->components->info('Regenerating the Composer autoloader files.');

$this->composer->dumpAutoloads();
}
}

/**
Expand All @@ -107,11 +121,11 @@ public function handle()
*/
protected function writeMigration($name, $table, $create)
{
$file = $this->creator->create(
return tap($this->creator->create(
$name, $this->getMigrationPath(), $table, $create
);

$this->components->info(sprintf('Migration [%s] created successfully.', $file));
), function ($file) {
$this->components->info(sprintf('Migration [%s] created successfully.', $file));
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public function handle()

$this->components->info('Migration created successfully.');

$this->composer->dumpAutoloads();
if (preg_match('/^return new class/', $this->files->get($fullPath)) === 0) {
$this->components->info('Regenerating the Composer autoloader files.');

$this->composer->dumpAutoloads();
}
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/Illuminate/Queue/Console/BatchesTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ public function handle()
$table = $this->laravel['config']['queue.batching.table'] ?? 'job_batches';

$this->replaceMigration(
$this->createBaseMigration($table), $table
$fullPath = $this->createBaseMigration($table), $table
);

$this->components->info('Migration created successfully.');

$this->composer->dumpAutoloads();
if (preg_match('/^return new class/', $this->files->get($fullPath)) === 0) {
$this->components->info('Regenerating the Composer autoloader files.');

$this->composer->dumpAutoloads();
}
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/Illuminate/Queue/Console/FailedTableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ public function handle()
$table = $this->laravel['config']['queue.failed.table'];

$this->replaceMigration(
$this->createBaseMigration($table), $table
$fullPath = $this->createBaseMigration($table), $table
);

$this->components->info('Migration created successfully.');

$this->composer->dumpAutoloads();
if (preg_match('/^return new class/', $this->files->get($fullPath)) === 0) {
$this->components->info('Regenerating the Composer autoloader files.');

$this->composer->dumpAutoloads();
}
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/Illuminate/Queue/Console/TableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ public function handle()
$table = $this->laravel['config']['queue.connections.database.table'];

$this->replaceMigration(
$this->createBaseMigration($table), $table
$fullPath = $this->createBaseMigration($table), $table
);

$this->components->info('Migration created successfully.');

$this->composer->dumpAutoloads();
if (preg_match('/^return new class/', $this->files->get($fullPath)) === 0) {
$this->components->info('Regenerating the Composer autoloader files.');

$this->composer->dumpAutoloads();
}
}

/**
Expand Down

0 comments on commit 61ca9dc

Please sign in to comment.