From c0044479e6e57224eadafdd1b3bb2472f1d6b8d4 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Tue, 7 Feb 2017 17:17:35 +0200 Subject: [PATCH] Initial commit, superhelio:reload --- CHANGELOG.md | 5 +++ README.md | 80 +++++++++++++++++++++++++++++++++++++++++ composer.json | 44 +++++++++++++++++++++++ src/Commands/Reload.php | 60 +++++++++++++++++++++++++++++++ src/Facade.php | 13 +++++++ src/ServiceProvider.php | 42 ++++++++++++++++++++++ tests/.gitkeep | 0 7 files changed, 244 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 README.md create mode 100644 composer.json create mode 100644 src/Commands/Reload.php create mode 100644 src/Facade.php create mode 100644 src/ServiceProvider.php create mode 100644 tests/.gitkeep diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c5716cf --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Change Log +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). diff --git a/README.md b/README.md new file mode 100644 index 0000000..de752e2 --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +# Laravel Commands by [SuperHelio](link-author) + +[![Latest Version on Packagist][ico-version]][link-packagist] +[![Software License][ico-license]](LICENSE.md) +[![Build Status][ico-travis]][link-travis] +[![Coverage Status][ico-scrutinizer]][link-scrutinizer] +[![Quality Score][ico-code-quality]][link-code-quality] +[![Total Downloads][ico-downloads]][link-downloads] + +This is a collection of Laravel Artisan commands created to help everyone +in their development work. We try to keep these as useful as possible. + +## Install + +### Step 1: Install Through Composer + +``` bash +$ composer require superhelio/commands --dev +``` + +### Step 2: Add the Service Provider + +You'll only want to use these generators for local development, so you don't want to update the production `providers` array in `config/app.php`. Instead, add the provider in `app/Providers/AppServiceProvider.php`, like so: + +```php +public function register() +{ + if ($this->app->environment() == 'local') { + $this->app->register('SuperHelio\Commands\ServiceProvider'); + } +} +``` + +## Usage + +- *superhelio:reload* + - Reset database, migrate and seed + - `php artisan superhelio:reload` + +## Change log + +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. + +## Testing + +``` bash +$ composer test +``` + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. + +## Security + +If you discover any security related issues, please contact [SuperHelio](link-author). + +## Credits + +- [SuperHelio][link-author] +- [All Contributors][link-contributors] + +## License + +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. + +[ico-version]: https://img.shields.io/packagist/v/superhelio/commands.svg?style=flat-square +[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square +[ico-travis]: https://img.shields.io/travis/superhelio/commands/master.svg?style=flat-square +[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/superhelio/commands.svg?style=flat-square +[ico-code-quality]: https://img.shields.io/scrutinizer/g/superhelio/commands.svg?style=flat-square +[ico-downloads]: https://img.shields.io/packagist/dt/superhelio/commands.svg?style=flat-square + +[link-packagist]: https://packagist.org/packages/superhelio/commands +[link-travis]: https://travis-ci.org/superhelio/commands +[link-scrutinizer]: https://scrutinizer-ci.com/g/superhelio/commands/code-structure +[link-code-quality]: https://scrutinizer-ci.com/g/superhelio/commands +[link-downloads]: https://packagist.org/packages/superhelio/commands +[link-author]: https://github.com/superhelio +[link-contributors]: ../../contributors diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d827076 --- /dev/null +++ b/composer.json @@ -0,0 +1,44 @@ +{ + "name": "superhelio/commands", + "description": "Laravel Commands", + "keywords": [ + "laravel", + "superhelio", + "commands" + ], + "homepage": "https://github.com/superhelio/commands", + "license": "MIT", + "authors": [ + { + "name": "SuperHelio", + "email": "hello@superhelio.com", + "homepage": "https://superhelio.com", + "role": "Developer" + } + ], + "require": { + "php" : ">=5.5.0", + "illuminate/support": "~5.2" + }, + "require-dev": { + "phpunit/phpunit" : "4.*" + }, + "autoload": { + "psr-4": { + "Superhelio\\Commands\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Superhelio\\Commands\\Test\\": "tests" + } + }, + "scripts": { + "test": "phpunit" + }, + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + } +} diff --git a/src/Commands/Reload.php b/src/Commands/Reload.php new file mode 100644 index 0000000..7bf6f69 --- /dev/null +++ b/src/Commands/Reload.php @@ -0,0 +1,60 @@ +confirm('Rollback all your database tables, recreate them and seed?')) { + $this->call( + 'migrate:reset', + [ + '--no-interaction' => true, + '--env' => 'development', + '--verbose' => 3 + ] + ); + $this->call( + 'migrate', + [ + '--seed' => true, + '--no-interaction' => true, + '--env' => 'development', + '--verbose' => 3 + ] + ); + } + } +} diff --git a/src/Facade.php b/src/Facade.php new file mode 100644 index 0000000..e593f94 --- /dev/null +++ b/src/Facade.php @@ -0,0 +1,13 @@ +registerReloader(); + } + + private function registerReloader() + { + $this->app->singleton('command.superhelio.reload', function ($app) { + return $app['Superhelio\Commands\Commands\Reload']; + }); + $this->commands('command.superhelio.reload'); + } +} diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29