diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..88e99d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor +composer.lock \ No newline at end of file diff --git a/composer.json b/composer.json index c0adfc1..325de85 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ } ], "require": { - "php": ">=7.4", - "laravel/framework": ">=8.0" + "php": "^8.2", + "laravel/framework": "11.*" }, "config": { "sort-packages": true diff --git a/src/Core/Commands/MakeAction.php b/src/Core/Commands/MakeAction.php new file mode 100644 index 0000000..ad73e5d --- /dev/null +++ b/src/Core/Commands/MakeAction.php @@ -0,0 +1,49 @@ +moduleExists()) return; + + // CREATE ACTIONS DIRECTORY IF NOT FOUND + if (!file_exists($actions = $this->getPath('Actions'))) + File::makeDirectory($actions, 0777, true, true); + + $content = str_replace('{{ class }}', $this->name, file_get_contents(__DIR__ . '/stubs/action.stub')); + $content = str_replace('{{ namespace }}', $this->getNamespace('Actions'), $content); + + // SAVING action + if (file_exists($path = $this->getPath('Actions/' . $this->fullName . '.php')) && !$this->option('force')) { + $this->error('Action is already exists!'); + return false; + } + + if (!File::isDirectory($dir = dirname($path))) + File::makeDirectory($dir, 0755, true, true); + + if (File::put($path, $content)) { + $this->info('Action created successfully.'); + } else { + $this->warn('There is something wrong.'); + } + + // CREATE TEST + if ($this->option('test') || $this->option('pest')) { + $command = 'module:make:test ' . $this->module . ' Actions/' . $this->fullName; + $command .= $this->option('pest') ? ' --pest' : null; + Artisan::call($command, [], $this->getOutput()); + } + } +} diff --git a/src/Core/Commands/MakeClass.php b/src/Core/Commands/MakeClass.php new file mode 100644 index 0000000..c75c557 --- /dev/null +++ b/src/Core/Commands/MakeClass.php @@ -0,0 +1,49 @@ +moduleExists()) return; + + // CREATE CLASSES DIRECTORY IF NOT FOUND + if (!file_exists($classes = $this->getPath('Classes'))) + File::makeDirectory($classes, 0777, true, true); + + $content = str_replace('{{ class }}', $this->name, file_get_contents(__DIR__ . '/stubs/class.stub')); + $content = str_replace('{{ namespace }}', $this->getNamespace('Classes'), $content); + + // SAVING CLASS + if (file_exists($path = $this->getPath('Classes/' . $this->fullName . '.php')) && !$this->option('force')) { + $this->error('Class is already exists!'); + return false; + } + + if (!File::isDirectory($dir = dirname($path))) + File::makeDirectory($dir, 0755, true, true); + + if (File::put($path, $content)) { + $this->info('Class created successfully.'); + } else { + $this->warn('There is something wrong.'); + } + + // CREATE TEST + if ($this->option('test') || $this->option('pest')) { + $command = 'module:make:test ' . $this->module . ' Classes/' . $this->fullName; + $command .= $this->option('pest') ? ' --pest' : null; + Artisan::call($command, [], $this->getOutput()); + } + } +} diff --git a/src/Core/Commands/MakeEnum.php b/src/Core/Commands/MakeEnum.php new file mode 100644 index 0000000..c35548a --- /dev/null +++ b/src/Core/Commands/MakeEnum.php @@ -0,0 +1,49 @@ +moduleExists()) return; + + // CREATE ENUMS DIRECTORY IF NOT FOUND + if (!file_exists($enums = $this->getPath('Enums'))) + File::makeDirectory($enums, 0777, true, true); + + $content = str_replace('{{ class }}', $this->name, file_get_contents(__DIR__ . '/stubs/enum.stub')); + $content = str_replace('{{ namespace }}', $this->getNamespace('Enums'), $content); + + // SAVING ENUM + if (file_exists($path = $this->getPath('Enums/' . $this->fullName . '.php')) && !$this->option('force')) { + $this->error('Enum is already exists!'); + return false; + } + + if (!File::isDirectory($dir = dirname($path))) + File::makeDirectory($dir, 0755, true, true); + + if (File::put($path, $content)) { + $this->info('Enum created successfully.'); + } else { + $this->warn('There is something wrong.'); + } + + // CREATE TEST + if ($this->option('test') || $this->option('pest')) { + $command = 'module:make:test ' . $this->module . ' Enums/' . $this->fullName; + $command .= $this->option('pest') ? ' --pest' : null; + Artisan::call($command, [], $this->getOutput()); + } + } +} diff --git a/src/Core/Commands/MakeInterface.php b/src/Core/Commands/MakeInterface.php new file mode 100644 index 0000000..1df99c7 --- /dev/null +++ b/src/Core/Commands/MakeInterface.php @@ -0,0 +1,49 @@ +moduleExists()) return; + + // CREATE INTERFACES DIRECTORY IF NOT FOUND + if (!file_exists($interfaces = $this->getPath('Interfaces'))) + File::makeDirectory($interfaces, 0777, true, true); + + $content = str_replace('{{ interface }}', $this->name, file_get_contents(__DIR__ . '/stubs/interface.stub')); + $content = str_replace('{{ namespace }}', $this->getNamespace('Interfaces'), $content); + + // SAVING INTERFACE + if (file_exists($path = $this->getPath('Interfaces/' . $this->fullName . '.php')) && !$this->option('force')) { + $this->error('Interface is already exists!'); + return false; + } + + if (!File::isDirectory($dir = dirname($path))) + File::makeDirectory($dir, 0755, true, true); + + if (File::put($path, $content)) { + $this->info('Interface created successfully.'); + } else { + $this->warn('There is something wrong.'); + } + + // CREATE TEST + if ($this->option('test') || $this->option('pest')) { + $command = 'module:make:test ' . $this->module . ' Interfaces/' . $this->fullName; + $command .= $this->option('pest') ? ' --pest' : null; + Artisan::call($command, [], $this->getOutput()); + } + } +} diff --git a/src/Core/Commands/MakeScope.php b/src/Core/Commands/MakeScope.php new file mode 100644 index 0000000..f1dfb73 --- /dev/null +++ b/src/Core/Commands/MakeScope.php @@ -0,0 +1,49 @@ +moduleExists()) return; + + // CREATE SCOPES DIRECTORY IF NOT FOUND + if (!file_exists($scopes = $this->getPath('Scopes'))) + File::makeDirectory($scopes, 0777, true, true); + + $content = str_replace('{{ class }}', $this->name, file_get_contents(__DIR__ . '/stubs/scope.stub')); + $content = str_replace('{{ namespace }}', $this->getNamespace('Scopes'), $content); + + // SAVING SCOPE + if (file_exists($path = $this->getPath('Scopes/' . $this->fullName . '.php')) && !$this->option('force')) { + $this->error('Scope is already exists!'); + return false; + } + + if (!File::isDirectory($dir = dirname($path))) + File::makeDirectory($dir, 0755, true, true); + + if (File::put($path, $content)) { + $this->info('Scope created successfully.'); + } else { + $this->warn('There is something wrong.'); + } + + // CREATE TEST + if ($this->option('test') || $this->option('pest')) { + $command = 'module:make:test ' . $this->module . ' Scopes/' . $this->fullName; + $command .= $this->option('pest') ? ' --pest' : null; + Artisan::call($command, [], $this->getOutput()); + } + } +} diff --git a/src/Core/Commands/MakeService.php b/src/Core/Commands/MakeService.php new file mode 100644 index 0000000..38c2187 --- /dev/null +++ b/src/Core/Commands/MakeService.php @@ -0,0 +1,49 @@ +moduleExists()) return; + + // CREATE SERVICES DIRECTORY IF NOT FOUND + if (!file_exists($services = $this->getPath('Services'))) + File::makeDirectory($services, 0777, true, true); + + $content = str_replace('{{ class }}', $this->name, file_get_contents(__DIR__ . '/stubs/service.stub')); + $content = str_replace('{{ namespace }}', $this->getNamespace('Services'), $content); + + // SAVING SERVICE CLASS + if (file_exists($path = $this->getPath('Services/' . $this->fullName . '.php')) && !$this->option('force')) { + $this->error('Service is already exists!'); + return false; + } + + if (!File::isDirectory($dir = dirname($path))) + File::makeDirectory($dir, 0755, true, true); + + if (File::put($path, $content)) { + $this->info('Service created successfully.'); + } else { + $this->warn('There is something wrong.'); + } + + // CREATE TEST + if ($this->option('test') || $this->option('pest')) { + $command = 'module:make:test ' . $this->module . ' Services/' . $this->fullName; + $command .= $this->option('pest') ? ' --pest' : null; + Artisan::call($command, [], $this->getOutput()); + } + } +} diff --git a/src/Core/Commands/MakeTrait.php b/src/Core/Commands/MakeTrait.php new file mode 100644 index 0000000..1ef0819 --- /dev/null +++ b/src/Core/Commands/MakeTrait.php @@ -0,0 +1,49 @@ +moduleExists()) return; + + // CREATE TRAITS DIRECTORY IF NOT FOUND + if (!file_exists($traits = $this->getPath('Traits'))) + File::makeDirectory($traits, 0777, true, true); + + $content = str_replace('{{ trait }}', $this->name, file_get_contents(__DIR__ . '/stubs/trait.stub')); + $content = str_replace('{{ namespace }}', $this->getNamespace('Traits'), $content); + + // SAVING TRAIT + if (file_exists($path = $this->getPath('Traits/' . $this->fullName . '.php')) && !$this->option('force')) { + $this->error('Trait is already exists!'); + return false; + } + + if (!File::isDirectory($dir = dirname($path))) + File::makeDirectory($dir, 0755, true, true); + + if (File::put($path, $content)) { + $this->info('Trait created successfully.'); + } else { + $this->warn('There is something wrong.'); + } + + // CREATE TEST + if ($this->option('test') || $this->option('pest')) { + $command = 'module:make:test ' . $this->module . ' Traits/' . $this->fullName; + $command .= $this->option('pest') ? ' --pest' : null; + Artisan::call($command, [], $this->getOutput()); + } + } +} diff --git a/src/Core/Commands/stubs/action.stub b/src/Core/Commands/stubs/action.stub new file mode 100644 index 0000000..9515c6e --- /dev/null +++ b/src/Core/Commands/stubs/action.stub @@ -0,0 +1,14 @@ +