Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v2.1.0'
Browse files Browse the repository at this point in the history
* release/v2.1.0:
  Remove badges with issues
  Enforce naming convention consistency
  Refactor migrations and artisan commands, and tweak service provider publishes functionality
  Drop PHP 7.1 travis test
  Update composer deps
  • Loading branch information
Omranic committed Jun 2, 2019
2 parents aaccb85 + d53b782 commit 84a1642
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 45 deletions.
1 change: 0 additions & 1 deletion .travis.yml
@@ -1,7 +1,6 @@
language: php

php:
- 7.1
- 7.2
- 7.3

Expand Down
11 changes: 5 additions & 6 deletions README.md
Expand Up @@ -4,7 +4,6 @@

[![Packagist](https://img.shields.io/packagist/v/rinvex/laravel-addresses.svg?label=Packagist&style=flat-square)](https://packagist.org/packages/rinvex/laravel-addresses)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/rinvex/laravel-addresses.svg?label=Scrutinizer&style=flat-square)](https://scrutinizer-ci.com/g/rinvex/laravel-addresses/)
[![Code Climate](https://img.shields.io/codeclimate/github/rinvex/laravel-addresses.svg?label=CodeClimate&style=flat-square)](https://codeclimate.com/github/rinvex/laravel-addresses)
[![Travis](https://img.shields.io/travis/rinvex/laravel-addresses.svg?label=TravisCI&style=flat-square)](https://travis-ci.org/rinvex/laravel-addresses)
[![StyleCI](https://styleci.io/repos/87485079/shield)](https://styleci.io/repos/87485079)
[![License](https://img.shields.io/packagist/l/rinvex/laravel-addresses.svg?label=License&style=flat-square)](https://github.com/rinvex/laravel-addresses/blob/develop/LICENSE)
Expand All @@ -17,14 +16,14 @@
composer require rinvex/laravel-addresses
```

2. Execute migrations via the following command:
```
php artisan rinvex:migrate:addresses
2. Publish resources (migrations and config files):
```shell
php artisan rinvex:publish:addresses
```

3. **Optional** if you want to change the configurations:
3. Execute migrations via the following command:
```shell
php artisan rinvex:publish:addresses
php artisan rinvex:migrate:addresses
```

4. Done!
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -59,7 +59,7 @@
"require-dev": {
"codedungeon/phpunit-result-printer": "^0.26.0",
"illuminate/container": "~5.8.0",
"phpunit/phpunit": "^8.0.0"
"phpunit/phpunit": "^8.1.0"
},
"autoload": {
"classmap": [
Expand Down
15 changes: 13 additions & 2 deletions src/Console/Commands/MigrateCommand.php
Expand Up @@ -29,7 +29,18 @@ class MigrateCommand extends Command
*/
public function handle(): void
{
$this->warn($this->description);
$this->call('migrate', ['--step' => true, '--path' => 'vendor/rinvex/laravel-addresses/database/migrations', '--force' => $this->option('force')]);
$this->alert($this->description);

if (file_exists($path = 'database/migrations/rinvex/laravel-addresses')) {
$this->call('migrate', [
'--step' => true,
'--path' => $path,
'--force' => $this->option('force'),
]);
} else {
$this->warn('No migrations found! Consider publish them first: <fg=green>php artisan rinvex:publish:addresses</>');
}

$this->line('');
}
}
20 changes: 17 additions & 3 deletions src/Console/Commands/PublishCommand.php
Expand Up @@ -13,7 +13,7 @@ class PublishCommand extends Command
*
* @var string
*/
protected $signature = 'rinvex:publish:addresses {--force : Overwrite any existing files.}';
protected $signature = 'rinvex:publish:addresses {--force : Overwrite any existing files.} {--R|resource=all}';

/**
* The console command description.
Expand All @@ -29,7 +29,21 @@ class PublishCommand extends Command
*/
public function handle(): void
{
$this->warn($this->description);
$this->call('vendor:publish', ['--tag' => 'rinvex-addresses-config', '--force' => $this->option('force')]);
$this->alert($this->description);

switch ($this->option('resource')) {
case 'config':
$this->call('vendor:publish', ['--tag' => 'rinvex-addresses-config', '--force' => $this->option('force')]);
break;
case 'migrations':
$this->call('vendor:publish', ['--tag' => 'rinvex-addresses-migrations', '--force' => $this->option('force')]);
break;
default:
$this->call('vendor:publish', ['--tag' => 'rinvex-addresses-config', '--force' => $this->option('force')]);
$this->call('vendor:publish', ['--tag' => 'rinvex-addresses-migrations', '--force' => $this->option('force')]);
break;
}

$this->line('');
}
}
15 changes: 13 additions & 2 deletions src/Console/Commands/RollbackCommand.php
Expand Up @@ -29,7 +29,18 @@ class RollbackCommand extends Command
*/
public function handle(): void
{
$this->warn($this->description);
$this->call('migrate:reset', ['--path' => 'vendor/rinvex/laravel-addresses/database/migrations', '--force' => $this->option('force')]);
$this->alert($this->description);

if (file_exists($path = 'database/migrations/rinvex/laravel-addresses')) {
$this->call('migrate:reset', [
'--step' => true,
'--path' => $path,
'--force' => $this->option('force'),
]);
} else {
$this->warn('No migrations found! Consider publish them first: <fg=green>php artisan rinvex:publish:addresses</>');
}

$this->line('');
}
}
35 changes: 5 additions & 30 deletions src/Providers/AddressesServiceProvider.php
Expand Up @@ -6,12 +6,15 @@

use Rinvex\Addresses\Models\Address;
use Illuminate\Support\ServiceProvider;
use Rinvex\Support\Traits\ConsoleTools;
use Rinvex\Addresses\Console\Commands\MigrateCommand;
use Rinvex\Addresses\Console\Commands\PublishCommand;
use Rinvex\Addresses\Console\Commands\RollbackCommand;

class AddressesServiceProvider extends ServiceProvider
{
use ConsoleTools;

/**
* The commands to be registered.
*
Expand Down Expand Up @@ -44,36 +47,8 @@ public function register()
*/
public function boot()
{
// Load migrations
! $this->app->runningInConsole() || $this->loadMigrationsFrom(__DIR__.'/../../database/migrations');

// Publish Resources
! $this->app->runningInConsole() || $this->publishResources();
}

/**
* Publish resources.
*
* @return void
*/
protected function publishResources(): void
{
$this->publishes([realpath(__DIR__.'/../../config/config.php') => config_path('rinvex.addresses.php')], 'rinvex-addresses-config');
$this->publishes([realpath(__DIR__.'/../../database/migrations') => database_path('migrations')], 'rinvex-addresses-migrations');
}

/**
* Register console commands.
*
* @return void
*/
protected function registerCommands(): void
{
// Register artisan commands
foreach ($this->commands as $key => $value) {
$this->app->singleton($value, $key);
}

$this->commands(array_values($this->commands));
! $this->app->runningInConsole() || $this->publishesConfig('rinvex/laravel-addresses');
! $this->app->runningInConsole() || $this->publishesMigrations('rinvex/laravel-addresses');
}
}

0 comments on commit 84a1642

Please sign in to comment.