From 90e3eac92d3ec886978ef765c3d917def99165a0 Mon Sep 17 00:00:00 2001 From: SineMah Date: Sun, 31 Jul 2022 21:38:53 +0200 Subject: [PATCH 1/3] raise dependency versions --- composer.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 846a36c1..a862eb33 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ ], "require": { "php": ">=7.4", - "illuminate/container": "^8.0", - "illuminate/contracts": "^8.0", - "illuminate/database": "^8.0", - "illuminate/events": "^8.0", - "illuminate/support": "^8.0", - "illuminate/pagination": "^8.0", - "nesbot/carbon": "^2.0", + "illuminate/container": "^9.0", + "illuminate/contracts": "^9.0", + "illuminate/database": "^9.0", + "illuminate/events": "^9.0", + "illuminate/support": "^9.0", + "illuminate/pagination": "^9.0", + "nesbot/carbon": "^2.5", "laudis/neo4j-php-client": "^2.3.3" }, "require-dev": { From 54f5fb5da836f785bac5ef2f2df8f8e525cec453 Mon Sep 17 00:00:00 2001 From: SineMah Date: Sun, 31 Jul 2022 21:39:45 +0200 Subject: [PATCH 2/3] use class method getClassName to create stub name --- src/Migrations/MigrationCreator.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Migrations/MigrationCreator.php b/src/Migrations/MigrationCreator.php index adb467e1..b42d99cc 100644 --- a/src/Migrations/MigrationCreator.php +++ b/src/Migrations/MigrationCreator.php @@ -9,15 +9,14 @@ class MigrationCreator extends IlluminateMigrationCreator /** * Populate the place-holders in the migration stub. * - * @param string $name * @param string $stub * @param string $label * * @return string */ - protected function populateStub($name, $stub, $label) + protected function populateStub($stub, $label) { - $stub = str_replace('{{class}}', studly_case($name), $stub); + $stub = str_replace('{{class}}', $this->getClassName($stub), $stub); // Here we will replace the label place-holders with the label specified by // the developer, which is useful for quickly creating a labels creation From 59a7c8c8379cab1a0b37158c868f872419d5d9a8 Mon Sep 17 00:00:00 2001 From: SineMah Date: Sun, 31 Jul 2022 23:47:58 +0200 Subject: [PATCH 3/3] rework migration command --- src/Console/Migrations/BaseCommand.php | 20 ------ src/Console/Migrations/MigrateMakeCommand.php | 67 +++++++++---------- 2 files changed, 30 insertions(+), 57 deletions(-) diff --git a/src/Console/Migrations/BaseCommand.php b/src/Console/Migrations/BaseCommand.php index 0dd14ce0..bed27ff4 100644 --- a/src/Console/Migrations/BaseCommand.php +++ b/src/Console/Migrations/BaseCommand.php @@ -29,26 +29,6 @@ protected function getMigrationPath() return $this->laravel['path.base'].'/'.$path; } - $package = $this->input->getOption('package'); - - // If the package is in the list of migration paths we received we will put - // the migrations in that path. Otherwise, we will assume the package is - // is in the package directories and will place them in that location. - if (!is_null($package)) { - return $this->packagePath.'/'.$package.'/src/'.self::LABELS_DIRECTORY; - } - - $bench = $this->input->getOption('bench'); - - // Finally we will check for the workbench option, which is a shortcut into - // specifying the full path for a "workbench" project. Workbenches allow - // developers to develop packages along side a "standard" app install. - if (!is_null($bench)) { - $path = "/workbench/{$bench}/src/".self::LABELS_DIRECTORY; - - return $this->laravel['path.base'].$path; - } - return $this->laravel['path.database'].'/'.self::LABELS_DIRECTORY; } } diff --git a/src/Console/Migrations/MigrateMakeCommand.php b/src/Console/Migrations/MigrateMakeCommand.php index 6a83fbfd..42da6252 100644 --- a/src/Console/Migrations/MigrateMakeCommand.php +++ b/src/Console/Migrations/MigrateMakeCommand.php @@ -9,14 +9,15 @@ class MigrateMakeCommand extends BaseCommand { - /** - * {@inheritDoc} - */ - protected $name = 'neo4j:make:migration'; - /** - * {@inheritDoc} - */ + protected $signature = 'neo4j:make:migration {name : The name of the migration} + {--create= : The table to be created} + {--label= : The table to migrate} + {--path= : The location where the migration file should be created} + {--realpath : Indicate any provided migration file paths are pre-resolved absolute paths} + {--fullpath : Output the full path of the migration}'; + + protected $description = 'Create a new migration file'; /** @@ -49,19 +50,13 @@ public function __construct(MigrationCreator $creator, Composer $composer, $pack $this->composer = $composer; } - /** - * {@inheritDoc} - */ - public function fire() + public function handle() { - // It's possible for the developer to specify the tables to modify in this - // schema operation. The developer may also specify if this label needs - // to be freshly created so we can create the appropriate migrations. $name = $this->input->getArgument('name'); $label = $this->input->getOption('label'); - $modify = $this->input->getOption('create'); + $modify = $this->input->getOption('create') ?? false; if (!$label && is_string($modify)) { $label = $modify; @@ -70,7 +65,7 @@ public function fire() // 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, $label); + $this->writeMigration($name, $label, $modify); $this->composer->dumpAutoloads(); } @@ -84,40 +79,38 @@ public function fire() * * @return string */ - protected function writeMigration($name, $label) + protected function writeMigration(string $name, ?string $label, bool $modify) { - $path = $this->getMigrationPath(); + $file = pathinfo($this->creator->create( + $name, $this->getMigrationPath(), $label, $modify + ), PATHINFO_FILENAME); - $file = pathinfo($this->creator->create($name, $path, $label), PATHINFO_FILENAME); + $this->components->info(sprintf('Created migration [%s].', $file)); + } + + protected function getMigrationPath(): string + { + if (! is_null($targetPath = $this->input->getOption('path'))) { + return ! $this->usingRealPath() + ? $this->laravel->basePath().'/'.$targetPath + : $targetPath; + } - $this->line("Created Migration: $file"); + return parent::getMigrationPath(); } - /** - * {@inheritDoc} - */ - protected function getArguments() + protected function usingRealPath(): bool { - return array( - array('name', InputArgument::REQUIRED, 'The name of the migration'), - ); + return $this->input->hasOption('realpath') && $this->option('realpath'); } /** * {@inheritDoc} */ - protected function getOptions() + protected function getArguments() { return array( - array('bench', null, InputOption::VALUE_OPTIONAL, 'The workbench the migration belongs to.', null), - - array('create', null, InputOption::VALUE_OPTIONAL, 'The label schema to be created.'), - - array('package', null, InputOption::VALUE_OPTIONAL, 'The package the migration belongs to.', null), - - array('path', null, InputOption::VALUE_OPTIONAL, 'Where to store the migration.', null), - - array('label', null, InputOption::VALUE_OPTIONAL, 'The label to migrate.'), + array('name', InputArgument::REQUIRED, 'The name of the migration'), ); } }