From a2083c5db142d8154457499b5afd0294bfa3abaf Mon Sep 17 00:00:00 2001 From: Narayan Adhikary Date: Thu, 27 Feb 2020 06:22:27 +0600 Subject: [PATCH] Initial commit --- .gitattributes | 2 + LICENSE | 22 ++ README.md | 119 ++++++++ composer.json | 42 +++ config/wovosoft-crud.php | 32 +++ skeleton/.coveralls.yml | 3 + skeleton/.editorconfig | 15 ++ skeleton/.gitattributes.tpl | 14 + skeleton/.gitignore.tpl | 5 + skeleton/.styleci.yml | 1 + skeleton/.travis.yml | 42 +++ skeleton/LICENSE.tpl | 22 ++ skeleton/README.md.tpl | 41 +++ skeleton/composer.json.tpl | 48 ++++ skeleton/phpunit.xml | 21 ++ skeleton/src/ServiceProvider.php.tpl | 37 +++ src/Commands/CrudCommand.php | 69 +++++ src/Commands/MakeController.php | 109 ++++++++ src/Commands/MakeModel.php | 92 +++++++ src/Commands/PackageNew.php | 86 ++++++ src/Commands/PackageRemove.php | 65 +++++ src/Commands/RemoveController.php | 87 ++++++ src/Commands/RemoveModel.php | 75 ++++++ src/Commands/Traits/ChangesComposerJson.php | 141 ++++++++++ src/Commands/Traits/CopiesSkeleton.php | 255 ++++++++++++++++++ src/Commands/Traits/InteractsWithComposer.php | 57 ++++ src/Commands/Traits/InteractsWithGit.php | 58 ++++ src/Commands/Traits/InteractsWithUser.php | 118 ++++++++ .../Traits/ManipulatesPackageFolder.php | 55 ++++ src/Exceptions/RuntimeException.php | 41 +++ src/ServiceProvider.php | 43 +++ stubs/Controller.php.tpl | 80 ++++++ stubs/Facade.php.tpl | 13 + stubs/MainClass.php.tpl | 7 + stubs/MainClassTest.php.tpl | 27 ++ stubs/Model.php.tpl | 13 + stubs/config.php | 5 + stubs/routes.php.tpl | 13 + stubs/seeder.stub | 16 ++ 39 files changed, 1991 insertions(+) create mode 100644 .gitattributes create mode 100644 LICENSE create mode 100644 README.md create mode 100644 composer.json create mode 100644 config/wovosoft-crud.php create mode 100644 skeleton/.coveralls.yml create mode 100644 skeleton/.editorconfig create mode 100644 skeleton/.gitattributes.tpl create mode 100644 skeleton/.gitignore.tpl create mode 100644 skeleton/.styleci.yml create mode 100644 skeleton/.travis.yml create mode 100644 skeleton/LICENSE.tpl create mode 100644 skeleton/README.md.tpl create mode 100644 skeleton/composer.json.tpl create mode 100644 skeleton/phpunit.xml create mode 100644 skeleton/src/ServiceProvider.php.tpl create mode 100644 src/Commands/CrudCommand.php create mode 100644 src/Commands/MakeController.php create mode 100644 src/Commands/MakeModel.php create mode 100644 src/Commands/PackageNew.php create mode 100644 src/Commands/PackageRemove.php create mode 100644 src/Commands/RemoveController.php create mode 100644 src/Commands/RemoveModel.php create mode 100644 src/Commands/Traits/ChangesComposerJson.php create mode 100644 src/Commands/Traits/CopiesSkeleton.php create mode 100644 src/Commands/Traits/InteractsWithComposer.php create mode 100644 src/Commands/Traits/InteractsWithGit.php create mode 100644 src/Commands/Traits/InteractsWithUser.php create mode 100644 src/Commands/Traits/ManipulatesPackageFolder.php create mode 100644 src/Exceptions/RuntimeException.php create mode 100644 src/ServiceProvider.php create mode 100644 stubs/Controller.php.tpl create mode 100644 stubs/Facade.php.tpl create mode 100644 stubs/MainClass.php.tpl create mode 100644 stubs/MainClassTest.php.tpl create mode 100644 stubs/Model.php.tpl create mode 100644 stubs/config.php create mode 100644 stubs/routes.php.tpl create mode 100644 stubs/seeder.stub diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7e7dbe0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2016 Narayan Adhikary + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..fb219b3 --- /dev/null +++ b/README.md @@ -0,0 +1,119 @@ +Laravel Package Generator for WovoCMS +========================= + +[![Build Status](https://travis-ci.org/wovosoft/crud.svg?branch=master)](https://travis-ci.org/wovosoft/crud) [![styleci](https://styleci.io/repos/96041272/shield)](https://styleci.io/repos/96041272) [![Packagist](https://img.shields.io/packagist/v/melihovv/laravel-package-generator.svg)](https://packagist.org/packages/wovosoft/crud) [![Packagist](https://poser.pugx.org/melihovv/laravel-package-generator/d/total.svg)](https://packagist.org/packages/wovosoft/crud) [![Packagist](https://img.shields.io/packagist/l/wovosoft/crud.svg)](https://packagist.org/packages/wovosoft/crud) + +Simple package to quickly generate basic structure for other WovoCMS laravel packages. + +## Install + +Install via composer +```bash +composer require --dev wovosoft/crud +``` + +Publish package config if you want customize default values +```bash +php artisan vendor:publish --provider="Wovosoft\Crud\ServiceProvider" --tag="config" +``` + +## Available commands for Packages + +### Make A New Package +`php artisan crud:make_package {vendor} {package}` \ +or, with inraction\ +`php artisan crud:make_package -i` + + +Example: `php artisan crud:make_package Wovosoft SomeAwesomePackage` + +This command will: + +* Create `packages/wovosoft/some-awesome-package` folder +* Register package in app composer.json +* Copy package skeleton from skeleton folder to created folder (you can provide +your custom skeleton path in config) +* Run `git init packages/wovosoft/some-awesome-package` +* Run `composer update wovosoft/some-awesome-package` +* Run `composer dump-autoload` + +With interactive `-i` flag you will be prompted for every needed value from you. + + ### Remove A Package +`php artisan crud:remove_package {vendor} {package} ` + +Example: `php artisan crud:remove_package Wovosoft SomeAwesomePackage` + +This command will: + +* Run `composer remove wovosoft/some-awesome-package` +* Remove `packages/wovosoft/some-awesome-package` folder +* Unregister package in app composer.json +* Run `composer dump-autoload` + +**Interactive mode also possible.** +## Available Commands For Controller Generation +### Make a Controller +`php artisan crud:make_controller {vendor} {package} {controller} {model}` \ + +#### With Interaction Mode +`php artisan crud:make_controller -i` + +### Remove A Controller +`php artisan crud:remove_controller {vendor} {package} {controller}` +#### With Interaction Mode +`php artisan crud:remove_controller -i` + +## Available Commands for Model Generation +### Make a Model +`php artisan crud:make_model {vendor} {package} {model}` +#### With Interaction Mode +`php artisan crud:make_model -i` +### Remove a Model +`php artisan crud:remove_model {vendor} {package} {model}` +#### With Interaction Model +`php artisan crud:remove_model -i` + +## CRUD Console Application +> There is a Console Application available. To run all above Artisan Commands from a single terminal with less commands, please run `php artisan crud -i` or `php artisan crud`. Then you can see the all available commands in a multiple choice form. Just select an option and that command will start executing immediately in interaction mode. You can then follow the rest of the ongoing processes. + +## Custom skeleton +> This package will copy all folders and files from specified skeleton path to package folder. You can use templates in your skeleton. All files with `tpl` extension will be provided with some variables available to use in them. `tpl` extension will be stripped. + +### Available variables to use in templates: + +* vendor (e.g. Wovosoft) +* package (e.g. SomeAwesomePackage) +* vendorFolderName (e.g. wovosoft) +* packageFolderName (e.g. some-awesome-package) +* packageHumanName (e.g. Some awesome package) +* composerName (e.g. wovosoft/some-awesome-package) +* composerDesc (e.g. A some awesome package) +* composerKeywords (e.g. some,awesome,package) +* licence (e.g. MIT) +* phpVersion (e.g. >=7.0) +* aliasName (e.g. some-awesome-package) +* configFileName (e.g. some-awesome-package) +* year (e.g. 2017) +* name (e.g. Narayan Adhikary) +* email (e.g. narayanadhikary24@gmail.com) +* githubPackageUrl (e.g. https://github.com/wovosoft/some-awesome-package) +* controller (Name of the Controller for Controller Generation) +* model (Name of the Model for Model Generation) + +## Things you need to do manually: + +* Service provider and alias registration (if you use laravel <5.5) +* In README.md: + * StyleCI repository identifier + * Package description + * Usage section + +## Security + +If you discover any security related issues, please email narayanadhikary24@gmail.com instead of using the issue tracker. + +## Credits + +- [Narayan Adhikary](https://github.com/narai420) +- [Wovo Soft](https://gitlab.com/wovosoft) diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..be8d0d2 --- /dev/null +++ b/composer.json @@ -0,0 +1,42 @@ +{ + "name": "wovosoft/crud", + "description": "A laravel package generator for WovoCMS", + "license": "MIT", + "keywords": [ + "laravel", + "package", + "generator" + ], + "type": "library", + "authors": [ + { + "name": "Narayan Adhikary", + "email": "narayanahdikary24@gmail.com" + } + ], + "require": { + "php": ">=7.2", + "illuminate/container": "^6.0", + "illuminate/console": "^6.0", + "illuminate/filesystem": "^6.0", + "illuminate/support": "^6.0", + "illuminate/view": "^6.0" + }, + "autoload": { + "psr-4": { + "Wovosoft\\Crud\\": "src" + } + }, + "extra": { + "laravel": { + "providers": [ + "Wovosoft\\Crud\\ServiceProvider" + ] + } + }, + "config": { + "preferred-install": "dist", + "sort-packages": true, + "optimize-autoloader": true + } +} diff --git a/config/wovosoft-crud.php b/config/wovosoft-crud.php new file mode 100644 index 0000000..af9090c --- /dev/null +++ b/config/wovosoft-crud.php @@ -0,0 +1,32 @@ + null, + 'init_git_onCreate' => false, + 'register_package_to_composer_dot_json' => true, + 'composer_update_onCreate' => true, + 'composer_dumpAutoload_onCreate' => true, + 'directories_to_create' => [ + "database/migrations", + "database/factories", + "database/seeds", + "src/Traits", + "src/Models", + "src/Http/Controllers", + "resources/js", + "resources/lang", + "resources/views", + ] + +]; diff --git a/skeleton/.coveralls.yml b/skeleton/.coveralls.yml new file mode 100644 index 0000000..428247c --- /dev/null +++ b/skeleton/.coveralls.yml @@ -0,0 +1,3 @@ +coverage_clover: tests/logs/clover.xml +json_path: tests/logs/coveralls-upload.json +service_name: travis-ci diff --git a/skeleton/.editorconfig b/skeleton/.editorconfig new file mode 100644 index 0000000..8ccf5d1 --- /dev/null +++ b/skeleton/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[Makefile] +indent_style = tab + +[*.php] +indent_size = 4 diff --git a/skeleton/.gitattributes.tpl b/skeleton/.gitattributes.tpl new file mode 100644 index 0000000..ae8db70 --- /dev/null +++ b/skeleton/.gitattributes.tpl @@ -0,0 +1,14 @@ +* text=auto +/.github export-ignore +/tests export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/.styleci.yml export-ignore +/.sensiolabs.yml export-ignore +/.coveralls.yml export-ignore +/phpunit.xml export-ignore +/CHANGELOG-* export-ignore +/CONTRIBUTING.md export-ignore +/CODE_OF_CONDUCT.md export-ignore diff --git a/skeleton/.gitignore.tpl b/skeleton/.gitignore.tpl new file mode 100644 index 0000000..496fb2e --- /dev/null +++ b/skeleton/.gitignore.tpl @@ -0,0 +1,5 @@ +/vendor +/.idea +/node_modules +/composer.lock +/.phpunit.result.cache diff --git a/skeleton/.styleci.yml b/skeleton/.styleci.yml new file mode 100644 index 0000000..0285f17 --- /dev/null +++ b/skeleton/.styleci.yml @@ -0,0 +1 @@ +preset: laravel diff --git a/skeleton/.travis.yml b/skeleton/.travis.yml new file mode 100644 index 0000000..1ac871c --- /dev/null +++ b/skeleton/.travis.yml @@ -0,0 +1,42 @@ +language: php + +sudo: false + +notifications: + email: + on_success: never + on_failure: always + +matrix: + include: + - php: 7.2 + env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-lowest' + - php: 7.2 + env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-stable' + - php: 7.3 + env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-lowest' + - php: 7.3 + env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-stable' + - php: 7.4snapshot + env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-lowest' + - php: 7.4snapshot + env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-stable' + fast_finish: true + allow_failures: + - php: 7.4snapshot + +before_install: + - composer config discard-changes true + - composer validate --no-check-all --strict + - travis_retry composer self-update + - travis_retry composer require "laravel/framework:${LARAVEL}" "orchestra/testbench:${TESTBENCH}" --no-interaction --no-update + +install: + - travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction --no-suggest + - travis_retry composer require --dev satooshi/php-coveralls + +script: + - composer run phpunit -- --coverage-clover ./tests/logs/clover.xml + +after_script: + - php vendor/bin/php-coveralls -v diff --git a/skeleton/LICENSE.tpl b/skeleton/LICENSE.tpl new file mode 100644 index 0000000..1ea86e3 --- /dev/null +++ b/skeleton/LICENSE.tpl @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) <> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/skeleton/README.md.tpl b/skeleton/README.md.tpl new file mode 100644 index 0000000..c904df9 --- /dev/null +++ b/skeleton/README.md.tpl @@ -0,0 +1,41 @@ +# + +[![Build Status](https://travis-ci.org//.svg?branch=master)](https://travis-ci.org//) +[![styleci](https://styleci.io/repos/CHANGEME/shield)](https://styleci.io/repos/CHANGEME) +[![Coverage Status](https://coveralls.io/repos/github///badge.svg?branch=master)](https://coveralls.io/github//?branch=master) + +[![Packagist](https://img.shields.io/packagist/v//.svg)](https://packagist.org/packages//) +[![Packagist](https://poser.pugx.org///d/total.svg)](https://packagist.org/packages//) +[![Packagist](https://img.shields.io/packagist/l//.svg)](https://packagist.org/packages//) + +Package description: CHANGE ME + +## Installation + +Install via composer +```bash +composer require / +``` + +### Publish Configuration File + +```bash +php artisan vendor:publish --provider="\\ServiceProvider" --tag="config" +``` + +## Usage + +CHANGE ME + +## Security + +If you discover any security related issues, please email +instead of using the issue tracker. + +## Credits + +- []() +- [All contributors](/graphs/contributors) + +This package is bootstrapped with the help of +[wovosoft/crud](https://github.com/wovosoft/crud). diff --git a/skeleton/composer.json.tpl b/skeleton/composer.json.tpl new file mode 100644 index 0000000..3e9b60d --- /dev/null +++ b/skeleton/composer.json.tpl @@ -0,0 +1,48 @@ +{ + "name": "", + "description": "", + "license": "", + "keywords": [ + + ], + "type": "library", + "authors": [ + { + "name": "", + "email": "" + } + ], + "require": { + "php": "", + "illuminate/support": "^6.0" + }, + "require-dev": { + "orchestra/testbench": "^4.0", + "phpunit/phpunit": "^8.0" + }, + "autoload": { + "psr-4": { + "\\\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "\\\\Tests\\": "tests" + } + }, + "scripts": { + "phpunit": "phpunit" + }, + "extra": { + "laravel": { + "providers": [ + "\\\\ServiceProvider" + ] + } + }, + "config": { + "preferred-install": "dist", + "sort-packages": true, + "optimize-autoloader": true + } +} diff --git a/skeleton/phpunit.xml b/skeleton/phpunit.xml new file mode 100644 index 0000000..6208ecc --- /dev/null +++ b/skeleton/phpunit.xml @@ -0,0 +1,21 @@ + + + + + tests + + + + + src + + + diff --git a/skeleton/src/ServiceProvider.php.tpl b/skeleton/src/ServiceProvider.php.tpl new file mode 100644 index 0000000..4a21390 --- /dev/null +++ b/skeleton/src/ServiceProvider.php.tpl @@ -0,0 +1,37 @@ + + +namespace \; + +class ServiceProvider extends \Illuminate\Support\ServiceProvider +{ + const CONFIG_PATH = __DIR__ . '/../config/.php'; + + public function boot() + { + if ($this->app->runningInConsole()) { + $this->publishes([ + self::CONFIG_PATH => config_path('.php'), + ], 'config'); + } + + + $this->loadMigrationsFrom(__DIR__ . "/../database/migrations"); + $this->loadRoutesFrom(__DIR__ . "/routes.php"); + $this->loadFactoriesFrom(__DIR__ . "/../database/factories"); + $this->loadViewsFrom(__DIR__ . "/../resources/views", ''); + $this->loadTranslationsFrom(__DIR__ . "/../resources/lang", ''); + //$this->loadJsonTranslationsFrom(__DIR__."/../resources/lang"); + } + + public function register() + { + $this->mergeConfigFrom( + self::CONFIG_PATH, + '' + ); + + $this->app->bind('', function () { + return new (); + }); + } +} diff --git a/src/Commands/CrudCommand.php b/src/Commands/CrudCommand.php new file mode 100644 index 0000000..e173bc6 --- /dev/null +++ b/src/Commands/CrudCommand.php @@ -0,0 +1,69 @@ +getCommand(null); + $this->call("crud:" . $type, [ + "-i" => true + ]); + if ($this->choice("Do you want to run mode Commands?", [ + "YES", + "NO" + ], 0) == "YES") { + $this->call("crud", [ + "-i" => true + ]); + } + } + + protected function getCommand($default = null) + { + return $default ?? $this->choice( + 'What do you want to generate?', + [ + "make_package", + "remove_package", + "make_model", + "remove_model", + "make_controller", + "remove_controller", + ], 0); + } +} diff --git a/src/Commands/MakeController.php b/src/Commands/MakeController.php new file mode 100644 index 0000000..4ab8263 --- /dev/null +++ b/src/Commands/MakeController.php @@ -0,0 +1,109 @@ +getVendor('vendor'); + $package = $this->getPackage('package'); + $model = $this->getModel('model'); + $controller = $this->getController('controller'); + + + $vendorFolderName = $this->getVendorFolderName($vendor); + $packageFolderName = $this->getPackageFolderName($package); + + + $relPackagePath = base_path("packages/$vendorFolderName/$packageFolderName/src/Http/Controllers/$controller.php.tpl"); + $target = base_path("packages/$vendorFolderName/$packageFolderName/src/Http/Controllers/$controller.php"); + + if (File::exists($target)) { + $this->warn('Controller Already Exits. Exiting...'); + return; + } + if (!File::exists(dirname($relPackagePath))) { + File::makeDirectory(dirname($relPackagePath), 0755, true); + } + if (!File::exists($relPackagePath)) { + File::copy(__DIR__ . '/../../stubs/Controller.php.tpl', $relPackagePath); + $this->info("Controller Stub copied to $relPackagePath"); + } + + $this->info('Trying to parse the stub'); + + $phpEngine = app()->make(PhpEngine::class); + try { + $newFileContent = $phpEngine->get($relPackagePath, [ + "vendor" => $vendor, + "package" => $package, + "controller" => $controller, + "model" => $model, + ]); + } catch (\Exception $e) { + $this->error("Template [$relPackagePath] contains syntax errors"); + $this->error($e->getMessage()); + $this->error("LINE # " . $e->getLine()); + } + $this->info("Stub Parsing Successful. Putting Parsed content to Controller File"); + File::put($target, $newFileContent); + File::delete($relPackagePath); + + $route_file = base_path("packages/$vendorFolderName/$packageFolderName" . "/src/routes.php"); + if (File::exists($target) && File::exists($route_file)) { + File::put($route_file, Str::replaceLast( + "//MAPPING_AREA_FOR_CRUD_DO_NOT_REMOVE_OR_EDIT_THIS_LINE//", + $vendor . "\\" . $package . "\\" . "Http\Controllers" . "\\" . $controller . "::routes();\n" . + "\t\t//MAPPING_AREA_FOR_CRUD_DO_NOT_REMOVE_OR_EDIT_THIS_LINE//", + File::get(base_path("packages/$vendorFolderName/$packageFolderName" . "/src/routes.php")) + )); + } + $this->info("Stub File Deleted Successfully"); + $this->info("Controller Created Successfully"); + + } +} diff --git a/src/Commands/MakeModel.php b/src/Commands/MakeModel.php new file mode 100644 index 0000000..46ff773 --- /dev/null +++ b/src/Commands/MakeModel.php @@ -0,0 +1,92 @@ +getVendor('vendor'); + $package = $this->getPackage('package'); + $model = $this->getModel('model'); + $table = $this->getTable('table'); + + $vendorFolderName = $this->getVendorFolderName($vendor); + $packageFolderName = $this->getPackageFolderName($package); + + $relPackagePath = base_path("packages/$vendorFolderName/$packageFolderName/src/Models/$model.php.tpl"); + $target = base_path("packages/$vendorFolderName/$packageFolderName/src/Models/$model.php"); + if (File::exists($target)) { + $this->warn('Model Already Exits. Exiting...'); + return; + } + if (!File::exists(dirname($relPackagePath))) { + File::makeDirectory(dirname($relPackagePath), 0755, true); + } + if (!File::exists($relPackagePath)) { + File::copy(__DIR__ . '/../../stubs/Model.php.tpl', $relPackagePath); + $this->info("Model Stub copied to $relPackagePath"); + } + $this->info('Trying to parse the stub'); + + $phpEngine = app()->make(PhpEngine::class); + try { + $newFileContent = $phpEngine->get($relPackagePath, [ + "vendor" => $vendor, + "package" => $package, + "model" => $model, + "table" => $table + ]); + } catch (\Exception $e) { + $this->error("Template [$relPackagePath] contains syntax errors"); + $this->error($e->getMessage()); + $this->error("LINE # " . $e->getLine()); + } + $this->info("Stub Parsing Successful. Putting Parsed content to Model file"); + File::put($target, $newFileContent); + File::delete($relPackagePath); + $this->info("Stub File Deleted Successfully"); + $this->info("Model Created Successfully"); + + } +} diff --git a/src/Commands/PackageNew.php b/src/Commands/PackageNew.php new file mode 100644 index 0000000..05f9a0a --- /dev/null +++ b/src/Commands/PackageNew.php @@ -0,0 +1,86 @@ +getVendor(); + $package = $this->getPackage(); + + $vendorFolderName = $this->getVendorFolderName($vendor); + $packageFolderName = $this->getPackageFolderName($package); + + $relPackagePath = "packages/$vendorFolderName/$packageFolderName"; + $packagePath = base_path($relPackagePath); + + try { + if (!$vendor && !$package) { + $this->warn("Vendor and Package name is required"); + return false; + } + $this->createPackageFolder($packagePath); + if (config('wovosoft-crud.register_package_to_composer_dot_json')) { + $this->registerPackage($vendorFolderName, $packageFolderName, $relPackagePath); + } + + $this->copySkeleton($packagePath, $vendor, $package, $vendorFolderName, $packageFolderName); + + if (config('wovosoft-crud.init_git_onCreate')) { + $this->initRepo($packagePath); + } + if (config('wovosoft-crud.composer_update_onCreate')) { + $this->composerUpdatePackage($vendorFolderName, $packageFolderName); + } + if (config('wovosoft-crud.composer_dumpAutoload_onCreate')) { + $this->composerDumpAutoload(); + } + + + $this->info('Finished. Are you ready to write awesome package?'); + + return 0; + } catch (Exception $e) { + $this->error($e->getMessage()); + + return -1; + } + } +} diff --git a/src/Commands/PackageRemove.php b/src/Commands/PackageRemove.php new file mode 100644 index 0000000..af6237c --- /dev/null +++ b/src/Commands/PackageRemove.php @@ -0,0 +1,65 @@ +getVendor(); + $package = $this->getPackage(); + + $vendorFolderName = $this->getVendorFolderName($vendor); + $packageFolderName = $this->getPackageFolderName($package); + + $relPackagePath = "packages/$vendorFolderName/$packageFolderName"; + $packagePath = base_path($relPackagePath); + + try { + $this->composerRemovePackage($vendorFolderName, $packageFolderName); + $this->removePackageFolder($packagePath); + $this->unregisterPackage($vendor, $package, "packages/$vendorFolderName/$packageFolderName"); + $this->composerDumpAutoload(); + + return 0; + } catch (Exception $e) { + $this->error($e->getMessage()); + + return -1; + } + } +} diff --git a/src/Commands/RemoveController.php b/src/Commands/RemoveController.php new file mode 100644 index 0000000..32b0a57 --- /dev/null +++ b/src/Commands/RemoveController.php @@ -0,0 +1,87 @@ +getVendor('vendor'); + $package = $this->getPackage('package'); + $controller = $this->getController('controller'); + + + $vendorFolderName = $this->getVendorFolderName($vendor); + $packageFolderName = $this->getPackageFolderName($package); + + + $target = base_path("packages/$vendorFolderName/$packageFolderName/src/Http/Controllers/$controller.php"); + + if (!File::exists($target)) { + $this->warn("Controller Doesn't Exists"); + return; + } + + try { + $this->info('Trying to delete the controller file...'); + if (File::delete($target)) { + $this->info("$target Controller Deleted Successfully."); + $route_file = base_path("packages/$vendorFolderName/$packageFolderName" . "/src/routes.php"); + $this->info("Trying to delete $target reference from $route_file"); + if (File::exists($route_file) && File::put($route_file, Str::replaceLast( + $vendor . "\\" . $package . "\\" . "Http\Controllers" . "\\" . $controller . "::routes();", + "", + File::get($route_file)) + )) { + $this->info("Controller routes successfully deleted from $route_file"); + } else { + $this->error("Unable to delete Controller routes from $route_file.\nPlease Check Manually."); + } + } else { + $this->error("Unable to delete $target Controller."); + } + } catch (\Exception $e) { + $this->error($e->getMessage()); + } + } +} diff --git a/src/Commands/RemoveModel.php b/src/Commands/RemoveModel.php new file mode 100644 index 0000000..653ca77 --- /dev/null +++ b/src/Commands/RemoveModel.php @@ -0,0 +1,75 @@ +getVendor('vendor'); + $package = $this->getPackage('package'); + $model = $this->getModel('model'); + + + $vendorFolderName = $this->getVendorFolderName($vendor); + $packageFolderName = $this->getPackageFolderName($package); + + + $target = base_path("packages/$vendorFolderName/$packageFolderName/src/Models/$model.php"); + + if (!File::exists($target)) { + $this->warn("Model Doesn't Exists"); + return; + } + + try { + $this->info('Trying to delete the model file...'); + if (File::delete($target)) { + $this->info("$target Model Deleted Successfully."); + } else { + $this->error("Unable to delete $target Model."); + } + } catch (\Exception $e) { + $this->error($e->getMessage()); + } + } +} diff --git a/src/Commands/Traits/ChangesComposerJson.php b/src/Commands/Traits/ChangesComposerJson.php new file mode 100644 index 0000000..678ecb1 --- /dev/null +++ b/src/Commands/Traits/ChangesComposerJson.php @@ -0,0 +1,141 @@ +info('Register package in composer.json.'); + + $composerJson = $this->loadComposerJson(); + + if (!isset($composerJson['repositories'])) { + Arr::set($composerJson, 'repositories', []); + } + + $filtered = array_filter($composerJson['repositories'], function ($repository) use ($relPackagePath) { + return $repository['type'] === 'path' + && $repository['url'] === $relPackagePath; + }); + + if (count($filtered) === 0) { + $this->info('Register composer repository for package.'); + + $composerJson['repositories']["$vendor/$package"] = (object)[ + 'type' => 'path', + 'url' => "./$relPackagePath", + ]; + } else { + $this->info('Composer repository for package is already registered.'); + } + + Arr::set($composerJson, "require.$vendor/$package", 'dev-master'); + + $this->saveComposerJson($composerJson); + + $this->info('Package was successfully registered in composer.json.'); + } + + /** + * Unregister package from composer.json. + * + * @param $vendor + * @param $package + * + * @throws FileNotFoundException + * @throws RuntimeException + */ + protected function unregisterPackage($vendor, $package, $relPackagePath) + { + $this->info('Unregister package from composer.json.'); + + $composerJson = $this->loadComposerJson(); + + unset($composerJson['require']["$vendor\\$package\\"]); + + $repositories = array_filter($composerJson['repositories'], function ($repository) use ($relPackagePath) { + return $repository['type'] !== 'path' + || $repository['url'] !== $relPackagePath; + }); + + $composerJson['repositories'] = $repositories; + + if (count($composerJson['repositories']) === 0) { + unset($composerJson['repositories']); + } + + $this->saveComposerJson($composerJson); + + $this->info('Package was successfully unregistered from composer.json.'); + } + + /** + * Load and parse content of composer.json. + * + * @return array + * + * @throws FileNotFoundException + * @throws RuntimeException + */ + protected function loadComposerJson() + { + $composerJsonPath = $this->getComposerJsonPath(); + + if (!File::exists($composerJsonPath)) { + throw new FileNotFoundException('composer.json does not exist'); + } + + $composerJsonContent = File::get($composerJsonPath); + $composerJson = json_decode($composerJsonContent, true); + + if (!is_array($composerJson)) { + throw new RuntimeException("Invalid composer.json file [$composerJsonPath]"); + } + + return $composerJson; + } + + /** + * @param array $composerJson + * + * @throws RuntimeException + */ + protected function saveComposerJson($composerJson) + { + $newComposerJson = json_encode( + $composerJson, + JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES + ); + + $composerJsonPath = $this->getComposerJsonPath(); + if (File::put($composerJsonPath, $newComposerJson) === false) { + throw new RuntimeException("Cannot write to composer.json [$composerJsonPath]"); + } + } + + /** + * Get composer.json path. + * + * @return string + */ + protected function getComposerJsonPath() + { + return base_path('composer.json'); + } +} diff --git a/src/Commands/Traits/CopiesSkeleton.php b/src/Commands/Traits/CopiesSkeleton.php new file mode 100644 index 0000000..6e856d4 --- /dev/null +++ b/src/Commands/Traits/CopiesSkeleton.php @@ -0,0 +1,255 @@ +info('Copy skeleton.'); + + $skeletonDirPath = $this->getPathFromConfig( + 'skeleton_dir_path', $this->packageBaseDir . '/skeleton' + ); + +// this copies dirs which has files. We need to copy empty dirs too + foreach (File::allFiles($skeletonDirPath, true) as $filePath) { + $filePath = realpath($filePath); + $destFilePath = Str::replaceFirst( + $skeletonDirPath, $packagePath, $filePath + ); + + $this->copyFileWithDirsCreating($filePath, $destFilePath); + } + + + $this->copyStubs($packagePath, $package, $packageFolderName); + + $variables = $this->getVariables( + $vendor, $package, $vendorFolderName, $packageFolderName + ); + $this->replaceTemplates($packagePath, $variables); + + $this->info('Skeleton was successfully copied.'); + } + + /** + * Copy stubs. + * + * @param $packagePath + * @param $package + * @param $packageFolderName + */ + protected function copyStubs($packagePath, $package, $packageFolderName) + { + $facadeFilePath = $this->packageBaseDir . '/stubs/Facade.php.tpl'; + $mainClassFilePath = $this->packageBaseDir . '/stubs/MainClass.php.tpl'; + $mainClassTestFilePath = $this->packageBaseDir . '/stubs/MainClassTest.php.tpl'; + $configFilePath = $this->packageBaseDir . '/stubs/config.php'; + $routeFilePath = $this->packageBaseDir . '/stubs/routes.php.tpl'; + + $filePaths = [ + $facadeFilePath => "$packagePath/src/Facades/$package.php.tpl", + $mainClassFilePath => "$packagePath/src/$package.php.tpl", + $routeFilePath => "$packagePath/src/routes.php.tpl", + $mainClassTestFilePath => "$packagePath/tests/{$package}Test.php.tpl", + $configFilePath => "$packagePath/config/$packageFolderName.php", + ]; + + foreach ($filePaths as $filePath => $destFilePath) { + $this->copyFileWithDirsCreating($filePath, $destFilePath); + } + + foreach (config('wovosoft-crud.directories_to_create') as $directory_to_create) { + if (!File::exists("$packagePath/$directory_to_create")) { + if (!File::makeDirectory("$packagePath/$directory_to_create", 0755, true)) { + throw new RuntimeException("Cannot create $directory_to_create folder"); + } + $this->info("$directory_to_create Folder Created"); + } + } + + } + + /** + * Substitute all variables in *.tpl files and remove tpl extension. + * + * @param string $packagePath + * @param array $variables + */ + protected function replaceTemplates($packagePath, $variables) + { + $phpEngine = app()->make(PhpEngine::class); + + foreach (File::allFiles($packagePath, true) as $filePath) { + $filePath = realpath($filePath); + + if (!Str::endsWith($filePath, '.tpl')) { + continue; + } + + try { + $newFileContent = $phpEngine->get($filePath, $variables); + } catch (Exception $e) { + $this->error("Template [$filePath] contains syntax errors"); + $this->error($e->getMessage()); + continue; + } + + $filePathWithoutTplExt = Str::replaceLast( + '.tpl', '', $filePath + ); + + File::put($filePathWithoutTplExt, $newFileContent); + File::delete($filePath); + } + } + + /** + * Copy source file to destination with needed directories creating. + * + * @param string $src + * @param string $dest + */ + protected function copyFileWithDirsCreating($src, $dest) + { + $dirPathOfDestFile = dirname($dest); + + if (!File::exists($dirPathOfDestFile)) { + File::makeDirectory($dirPathOfDestFile, 0755, true); + } + + if (!File::exists($dest)) { + File::copy($src, $dest); + } + } + + /** + * Get variables for substitution in templates. + * + * @param string $vendor + * @param string $package + * @param string $vendorFolderName + * @param string $packageFolderName + * + * @return array + */ + protected function getVariables( + $vendor, + $package, + $vendorFolderName, + $packageFolderName + ) + { + $packageWords = str_replace('-', ' ', Str::snake($packageFolderName)); + + $composerDescription = $this->askUser( + 'The composer description?', "A $packageWords" + ); + $composerKeywords = $this->getComposerKeywords($packageWords); + + $packageHumanName = $this->askUser( + 'The package human name?', Str::title($packageWords) + ); + + return [ + 'vendor' => $vendor, + 'package' => $package, + 'vendorFolderName' => $vendorFolderName, + 'packageFolderName' => $packageFolderName, + 'packageHumanName' => $packageHumanName, + + 'composerName' => "$vendorFolderName/$packageFolderName", + 'composerDesc' => $composerDescription, + 'composerKeywords' => $composerKeywords, + 'license' => $this->askUser('The package licence?', 'MIT'), + 'phpVersion' => $this->askUser('Php version constraint?', '>=7.2'), + + 'aliasName' => $packageFolderName, + 'configFileName' => $packageFolderName, + + 'year' => date('Y'), + + 'name' => $this->askUser('Your name?'), + 'email' => $this->askUser('Your email?'), + 'githubPackageUrl' => "https://github.com/$vendorFolderName/$packageFolderName", + ]; + } + + /** + * Get path from config. + * + * @param string $configName + * @param string $default + * + * @return string + * + * @throws RuntimeException + */ + protected function getPathFromConfig($configName, $default) + { + $path = config("wovosoft-crud.$configName"); + + if (empty($path)) { + $path = $default; + } else { + $path = base_path($path); + } + + $realPath = realpath($path); + + if ($realPath === false) { + throw RuntimeException::noAccessTo($path); + } + + return $realPath; + } + + /** + * Get composer keywords. + * + * @param $packageWords + * + * @return string + */ + protected function getComposerKeywords($packageWords) + { + $keywords = $this->askUser( + 'The composer keywords? (comma delimited)', str_replace(' ', ',', $packageWords) + ); + $keywords = explode(',', $keywords); + $keywords = array_map(function ($keyword) { + return "\"$keyword\""; + }, $keywords); + + return implode(",\n" . str_repeat(' ', 4), $keywords); + } +} diff --git a/src/Commands/Traits/InteractsWithComposer.php b/src/Commands/Traits/InteractsWithComposer.php new file mode 100644 index 0000000..05de5e4 --- /dev/null +++ b/src/Commands/Traits/InteractsWithComposer.php @@ -0,0 +1,57 @@ +composerRunCommand('composer dump-autoload'); + } + + /** + * Run "composer update $vendor/$package". + * + * @param string $vendor + * @param string $package + */ + protected function composerUpdatePackage($vendor, $package) + { + $this->composerRunCommand("composer update --ignore-platform-reqs $vendor/$package"); + } + + /** + * Run "composer remove $vendor/$package". + * + * @param string $vendor + * @param string $package + */ + protected function composerRemovePackage($vendor, $package) + { + $this->composerRunCommand("composer remove --ignore-platform-reqs $vendor/$package"); + } + + /** + * Run arbitrary composer command. + * + * @param $command + */ + protected function composerRunCommand($command) + { + $this->info("Run \"$command\"."); + + $output = []; + exec($command, $output, $returnStatusCode); + + if ($returnStatusCode !== 0) { + throw RuntimeException::commandExecutionFailed($command, $returnStatusCode); + } + + $this->info("\"$command\" was successfully ran."); + } +} diff --git a/src/Commands/Traits/InteractsWithGit.php b/src/Commands/Traits/InteractsWithGit.php new file mode 100644 index 0000000..6a81c42 --- /dev/null +++ b/src/Commands/Traits/InteractsWithGit.php @@ -0,0 +1,58 @@ +info("Run \"$command\"."); + + File::makeDirectory($dest, 0755, true); + + $output = []; + exec($command, $output, $returnStatusCode); + + if ($returnStatusCode !== 0) { + throw RuntimeException::commandExecutionFailed( + $command, $returnStatusCode + ); + } + + $this->info("\"$command\" was successfully ran."); + } + + /** + * Init git repo. + * @param string $repoPath + */ + protected function initRepo($repoPath) + { + $command = "git init $repoPath"; + $this->info("Run \"$command\"."); + + $output = []; + exec($command, $output, $returnStatusCode); + + if ($returnStatusCode !== 0) { + throw RuntimeException::commandExecutionFailed( + $command, $returnStatusCode + ); + } + + $this->info("\"$command\" was successfully ran."); + } +} diff --git a/src/Commands/Traits/InteractsWithUser.php b/src/Commands/Traits/InteractsWithUser.php new file mode 100644 index 0000000..bfbd06f --- /dev/null +++ b/src/Commands/Traits/InteractsWithUser.php @@ -0,0 +1,118 @@ +argument('vendor') ?: $default; + + return $this->askUser('The vendor name?', $vendor); + } + + /** + * Get Model Name + * @param string $default + * @return string + */ + protected function getModel($default = '') + { + $vendor = $this->argument('model') ?: $default; + + return $this->askUser('The Model name?', $vendor); + } + + /** + * Getting Controller Name + * @param string $default + * @return string + */ + protected function getController($default = '') + { + $vendor = $this->argument('controller') ?: $default; + + return $this->askUser('The Controller name?', $vendor); + } + + /** + * Getting table name + * @param string $default + * @return string + */ + protected function getTable($default = '') + { + $vendor = $this->option('table') ?: $default; + + return $this->askUser('The Table name?', $vendor); + } + + + /** + * Get the name of package for the namespace. + * + * @param string $default + * + * @return string + */ + protected function getPackage($default = '') + { + $package = $this->argument('package') ?: $default; + + return $this->askUser('The package name?', $package); + } + + /** + * Get vendor folder name. + * + * @param string $vendor + * + * @return string + */ + protected function getVendorFolderName($vendor) + { + $vendorFolderName = Str::kebab($vendor); + + return $this->askUser('The vendor folder name?', $vendorFolderName); + } + + /** + * Get package folder name. + * + * @param string $package + * + * @return string + */ + protected function getPackageFolderName($package) + { + $packageFolderName = Str::kebab($package); + + return $this->askUser('The package folder name?', $packageFolderName); + } + + /** + * Ask user. + * + * @param $question + * @param $defaultValue + * + * @return string + */ + protected function askUser($question, $defaultValue = '') + { + if ($this->option('interactive') || $defaultValue == "") { + return $this->ask($question, $defaultValue); + } + + return trim($defaultValue); + } +} diff --git a/src/Commands/Traits/ManipulatesPackageFolder.php b/src/Commands/Traits/ManipulatesPackageFolder.php new file mode 100644 index 0000000..2c87dc8 --- /dev/null +++ b/src/Commands/Traits/ManipulatesPackageFolder.php @@ -0,0 +1,55 @@ +info('Create package folder.'); + + if (File::exists($packagePath)) { + $this->info('Package folder already exists. Skipping.'); + + return; + } + + if (! File::makeDirectory($packagePath, 0755, true)) { + throw new RuntimeException('Cannot create package folder'); + } + + $this->info('Package folder was successfully created.'); + } + + /** + * Remove package folder. + * + * @param $packagePath + * + * @throws RuntimeException + */ + protected function removePackageFolder($packagePath) + { + $this->info('Remove package folder.'); + + if (File::exists($packagePath)) { + if (! File::deleteDirectory($packagePath)) { + throw new RuntimeException('Cannot remove package folder'); + } + + $this->info('Package folder was successfully removed.'); + } else { + $this->info('Package folder does not exists. Skipping.'); + } + } +} diff --git a/src/Exceptions/RuntimeException.php b/src/Exceptions/RuntimeException.php new file mode 100644 index 0000000..6d3331d --- /dev/null +++ b/src/Exceptions/RuntimeException.php @@ -0,0 +1,41 @@ +publishes([ + self::CONFIG_PATH => config_path('wovosoft-crud.php'), + ], 'config'); + + if ($this->app->runningInConsole()) { + $this->commands([ + PackageNew::class, + PackageRemove::class, + MakeModel::class, + RemoveModel::class, + MakeController::class, + RemoveController::class, + CrudCommand::class + ]); + } + } + + public function register() + { + $this->mergeConfigFrom( + self::CONFIG_PATH, + 'wovosoft-crud' + ); + } +} diff --git a/stubs/Controller.php.tpl b/stubs/Controller.php.tpl new file mode 100644 index 0000000..ecfa9ab --- /dev/null +++ b/stubs/Controller.php.tpl @@ -0,0 +1,80 @@ + + + +namespace \\Http\Controllers; + +use App\Http\Controllers\Controller; + +use Bornodhoni\CMSBase\Traits\BaseControllerTrait; +use Illuminate\Http\Request; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Route; +use Symfony\Component\HttpFoundation\Response; +use as ItemModel; + +class extends Controller +{ + use BaseControllerTrait; + public $itemModel; + /** + * @var array List of Relations to be loaded with the list() method + */ + public $listWith = [ + + ]; + /** + * @var array List of Columns to be selected with the list() method + */ + public $listSelectedColumns = [ + "*" + ]; + + public function __construct() + { + $this->itemModel = ItemModel::class; + } + + public static function routes() + { + Route::post("/list", '\\' . __CLASS__ . '@list')->name('.List'); + Route::post("/search", '\\' . __CLASS__ . '@search')->name('.Search'); + Route::post("/store", '\\' . __CLASS__ . '@store')->name('.Store'); + Route::post("/delete", '\\' . __CLASS__ . '@delete')->name('.Delete'); + } + + public function store(Request $request) + { + try { + $item = ItemModel::findOrNew($request->post('id')); + if ($request->post('id')) { + $item->updated_at = Carbon::now(); + } + $item->saveOrFail(); + return response()->json([ + "status" => true, + "title" => 'SUCCESS!', + "type" => "success", + "msg" => ($request->post('id') ? 'Edited' : 'Added') . ' Successfully' + ]); + } catch (\Exception $exception) { + if(env('APP_DEBUG')){ + return response()->json([ + "code" => $exception->getCode(), + "status" => false, + "title" => 'Failed!', + "type" => "warning", + "msg" => $exception->getMessage(), + "line" => $exception->getLine(), + "file" => $exception->getFile(), + "trace" => $exception->getTrace(), + ], Response::HTTP_FORBIDDEN, [], JSON_PRETTY_PRINT); + } + return response()->json([ + "status" => false, + "title" => 'Failed!', + "type" => "warning", + "msg" => "Unable to Process the request" + ], Response::HTTP_FORBIDDEN); + } + } +} diff --git a/stubs/Facade.php.tpl b/stubs/Facade.php.tpl new file mode 100644 index 0000000..d684251 --- /dev/null +++ b/stubs/Facade.php.tpl @@ -0,0 +1,13 @@ + + +namespace \\Facades; + +use Illuminate\Support\Facades\Facade; + +class extends Facade +{ + protected static function getFacadeAccessor() + { + return ''; + } +} diff --git a/stubs/MainClass.php.tpl b/stubs/MainClass.php.tpl new file mode 100644 index 0000000..84d7ccd --- /dev/null +++ b/stubs/MainClass.php.tpl @@ -0,0 +1,7 @@ + + +namespace \; + +class +{ +} diff --git a/stubs/MainClassTest.php.tpl b/stubs/MainClassTest.php.tpl new file mode 100644 index 0000000..cddaf2d --- /dev/null +++ b/stubs/MainClassTest.php.tpl @@ -0,0 +1,27 @@ + + +namespace \\Tests; + +use \\Facades\; +use \\ServiceProvider; +use Orchestra\Testbench\TestCase; + +class Test extends TestCase +{ + protected function getPackageProviders($app) + { + return [ServiceProvider::class]; + } + + protected function getPackageAliases($app) + { + return [ + '' => ::class, + ]; + } + + public function testExample() + { + $this->assertEquals(1, 1); + } +} diff --git a/stubs/Model.php.tpl b/stubs/Model.php.tpl new file mode 100644 index 0000000..4262de0 --- /dev/null +++ b/stubs/Model.php.tpl @@ -0,0 +1,13 @@ + + +namespace \\Models; + +use Illuminate\Database\Eloquent\Model; + +class extends Model +{ + protected $table = ""; + //protected $fillable = []; + + +} diff --git a/stubs/config.php b/stubs/config.php new file mode 100644 index 0000000..ca5d8ed --- /dev/null +++ b/stubs/config.php @@ -0,0 +1,5 @@ + + +use Illuminate\Support\Facades\Route; +//MAPPING_AREA_FOR_CRUD_DO_NOT_REMOVE_OR_EDIT_THIS_LINE_USE_AREA// + + +Route::name('.') + ->prefix('backend') + ->middleware(['web', 'auth']) + ->group(function () { + + //MAPPING_AREA_FOR_CRUD_DO_NOT_REMOVE_OR_EDIT_THIS_LINE// +}); diff --git a/stubs/seeder.stub b/stubs/seeder.stub new file mode 100644 index 0000000..4aa3845 --- /dev/null +++ b/stubs/seeder.stub @@ -0,0 +1,16 @@ +