mirror of
https://github.com/superhelio/commands.git
synced 2026-01-26 03:33:59 +00:00
feat: update dependencies, add linting, fix codebase, cleanup (#11)
* chore(deps): update dependencies * feat(tests): add matrix testing, problem matcher * feat(lint): add php-cs-fixer, fix codebase
This commit is contained in:
16
.editorconfig
Normal file
16
.editorconfig
Normal file
@@ -0,0 +1,16 @@
|
||||
# EditorConfig is awesome: https://editorconfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
max_line_length = 100
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
|
||||
43
.github/workflows/phpunit.yml
vendored
43
.github/workflows/phpunit.yml
vendored
@@ -6,15 +6,40 @@ jobs:
|
||||
build-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php_version:
|
||||
- 7.4
|
||||
- 8.0
|
||||
- 8.1
|
||||
- 8.2
|
||||
- 8.3
|
||||
- latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: php-actions/composer@v5
|
||||
|
||||
- name: PHPUnit Tests
|
||||
uses: php-actions/phpunit@v2
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php_extensions: xdebug mbstring
|
||||
bootstrap: vendor/autoload.php
|
||||
configuration: phpunit.xml
|
||||
args: --coverage-text
|
||||
php-version: ${{ matrix.php_version }}
|
||||
tools: composer, phpunit
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache Composer dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-${{ matrix.php_version }}-${{ hashFiles('**/composer.json') }}
|
||||
|
||||
- name: Install Dependencies
|
||||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||
|
||||
- name: Configure matchers
|
||||
uses: mheap/phpunit-matcher-action@v1
|
||||
|
||||
- name: Run tests
|
||||
run: composer test-ci
|
||||
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
vendor
|
||||
vendor
|
||||
composer.lock
|
||||
|
||||
15
.php-cs-fixer.dist.php
Normal file
15
.php-cs-fixer.dist.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$finder = (new PhpCsFixer\Finder())
|
||||
->in(__DIR__);
|
||||
|
||||
return (new PhpCsFixer\Config())
|
||||
->setRules([
|
||||
'@PhpCsFixer' => true,
|
||||
'@PHP74Migration' => true,
|
||||
'@PSR12' => true,
|
||||
'strict_param' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
||||
21
.travis.yml
21
.travis.yml
@@ -1,21 +0,0 @@
|
||||
language: php
|
||||
php:
|
||||
- 7.3
|
||||
- 7.4
|
||||
- 8.0
|
||||
- nightly
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
fast_finish: true
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache/files
|
||||
before_script:
|
||||
- phpenv global "$TRAVIS_PHP_VERSION"
|
||||
- composer config extra.platform.php $TRAVIS_PHP_VERSION
|
||||
install:
|
||||
- flags="--ansi --prefer-dist --no-interaction --optimize-autoloader --no-suggest --no-progress"
|
||||
- travis_wait 30 composer install $flags
|
||||
script:
|
||||
- ./vendor/bin/phpunit -c phpunit.xml
|
||||
26
README.md
26
README.md
@@ -2,9 +2,6 @@
|
||||
|
||||
[![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
|
||||
@@ -16,7 +13,7 @@ This package requires PHP 7.3 or later. The `composer.lock` file has been genera
|
||||
|
||||
### Step 1: Install Through Composer
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ composer require superhelio/commands --dev
|
||||
```
|
||||
|
||||
@@ -35,12 +32,12 @@ public function register()
|
||||
|
||||
## Usage
|
||||
|
||||
- *superhelio:gozer*
|
||||
- Force delete database tables that have your table prefix
|
||||
- `php artisan superhelio:gozer`
|
||||
- *superhelio:reload*
|
||||
- Reset database, migrate and seed
|
||||
- `php artisan superhelio:reload`
|
||||
- _superhelio:gozer_
|
||||
- Force delete database tables that have your table prefix
|
||||
- `php artisan superhelio:gozer`
|
||||
- _superhelio:reload_
|
||||
- Reset database, migrate and seed
|
||||
- `php artisan superhelio:reload`
|
||||
|
||||
## Change log
|
||||
|
||||
@@ -48,7 +45,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recen
|
||||
|
||||
## Testing
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ composer test
|
||||
```
|
||||
|
||||
@@ -67,15 +64,8 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
|
||||
|
||||
[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]: https://github.com/superhelio/commands/graphs/contributors
|
||||
|
||||
@@ -17,14 +17,15 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php" : ">=7.3",
|
||||
"illuminate/support": "^5.3|^6.0|^7.0|^8.0",
|
||||
"doctrine/dbal": "^2.5|^2.6"
|
||||
"php": "^7.4|^8",
|
||||
"illuminate/support": "^5.3|^6|^7|^8|^9|^10|^11",
|
||||
"doctrine/dbal": "^2.5|^2.6|^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"roave/security-advisories": "dev-master",
|
||||
"phpunit/phpunit" : "^8.0",
|
||||
"orchestra/testbench": "^3.3|^4|^5|^6"
|
||||
"phpunit/phpunit": "^8.0",
|
||||
"orchestra/testbench": "^3.3|^4|^5|^6|^7|^8",
|
||||
"friendsofphp/php-cs-fixer": "^3.9"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -37,7 +38,9 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phpunit"
|
||||
"lint": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --diff --allow-risky=yes",
|
||||
"test": "phpunit",
|
||||
"test-ci": "phpunit --teamcity"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
||||
6849
composer.lock
generated
6849
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -76,16 +76,14 @@ class Gozer extends Command
|
||||
*/
|
||||
$tables = $this->getFilteredTables($tables);
|
||||
|
||||
/**
|
||||
* Check that we got at least one table, bail out if not
|
||||
*/
|
||||
// Check that we got at least one table, bail out if not
|
||||
if ($tables->count() < 1) {
|
||||
$this->info('There are no tables, only Zuul.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Bid your farewells to these tables.
|
||||
* Last look and confirmation.
|
||||
*/
|
||||
@@ -95,27 +93,22 @@ class Gozer extends Command
|
||||
));
|
||||
$this->line('');
|
||||
|
||||
/**
|
||||
* Last confirmation before dropping tables
|
||||
*/
|
||||
// Last confirmation before dropping tables
|
||||
if ($this->confirm('Really delete those tables?')) {
|
||||
|
||||
/** Fancy pants progress bar to see your tables get destroyed */
|
||||
$bar = $this->output->createProgressBar($tables->count());
|
||||
|
||||
Schema::disableForeignKeyConstraints();
|
||||
$tables->each(function ($table) use ($bar, $connection) {
|
||||
|
||||
/** Drop the table */
|
||||
// Drop the table
|
||||
$connection->dropTable($table);
|
||||
|
||||
/** Advance our progress bar */
|
||||
// Advance our progress bar
|
||||
$bar->advance();
|
||||
|
||||
});
|
||||
Schema::enableForeignKeyConstraints();
|
||||
|
||||
/** Progress bar is now finished */
|
||||
// Progress bar is now finished
|
||||
$bar->finish();
|
||||
}
|
||||
|
||||
@@ -134,7 +127,7 @@ class Gozer extends Command
|
||||
public function getConnection()
|
||||
{
|
||||
try {
|
||||
/** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $connection */
|
||||
// @var \Doctrine\DBAL\Schema\AbstractSchemaManager $connection
|
||||
return app('db')->connection()->getDoctrineSchemaManager();
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
@@ -144,8 +137,6 @@ class Gozer extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $connection
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getTables(\Doctrine\DBAL\Schema\AbstractSchemaManager $connection)
|
||||
@@ -168,7 +159,7 @@ class Gozer extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* This is mainly for testing purposes
|
||||
* This is mainly for testing purposes.
|
||||
*
|
||||
* @param string $prefix
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,7 @@ class Reload extends Command
|
||||
[
|
||||
'--no-interaction' => true,
|
||||
'--env' => 'development',
|
||||
'--verbose' => 3
|
||||
'--verbose' => 3,
|
||||
]
|
||||
);
|
||||
$this->call(
|
||||
@@ -42,7 +42,7 @@ class Reload extends Command
|
||||
'--seed' => true,
|
||||
'--no-interaction' => true,
|
||||
'--env' => 'development',
|
||||
'--verbose' => 3
|
||||
'--verbose' => 3,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@ namespace Superhelio\Commands;
|
||||
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
|
||||
|
||||
/**
|
||||
* Class PackageServiceProvider
|
||||
* Class PackageServiceProvider.
|
||||
*
|
||||
* @package Superhelio\Commands
|
||||
* @see http://laravel.com/docs/master/packages#service-providers
|
||||
* @see http://laravel.com/docs/master/providers
|
||||
*/
|
||||
@@ -17,6 +16,7 @@ class ServiceProvider extends BaseServiceProvider
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @see http://laravel.com/docs/master/providers#deferred-providers
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = false;
|
||||
@@ -25,7 +25,6 @@ class ServiceProvider extends BaseServiceProvider
|
||||
* Register the service provider.
|
||||
*
|
||||
* @see http://laravel.com/docs/master/providers#the-register-method
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
|
||||
@@ -7,6 +7,10 @@ use Superhelio\Commands\Commands\Gozer;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
{
|
||||
/**
|
||||
@@ -22,8 +26,6 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
* Define environment setup.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getEnvironmentSetUp($app)
|
||||
{
|
||||
@@ -51,16 +53,16 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
{
|
||||
return [
|
||||
\Superhelio\Commands\Tests\Stubs\ServiceProvider::class,
|
||||
\Superhelio\Commands\ServiceProvider::class
|
||||
\Superhelio\Commands\ServiceProvider::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function test_database_is_there_and_functions()
|
||||
public function testDatabaseIsThereAndFunctions()
|
||||
{
|
||||
DB::table('users')->insert([
|
||||
'name' => 'User name',
|
||||
'email' => 'hello@gozer.dev',
|
||||
'password' => bcrypt('123')
|
||||
'password' => bcrypt('123'),
|
||||
]);
|
||||
|
||||
$users = DB::table('users')->where('id', '=', 1)->first();
|
||||
@@ -69,17 +71,17 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
self::assertTrue(Hash::check('123', $users->password));
|
||||
}
|
||||
|
||||
public function test_dbal_is_installed()
|
||||
public function testDbalIsInstalled()
|
||||
{
|
||||
self::assertTrue(class_exists('\\Doctrine\\DBAL\\Schema\\Schema'));
|
||||
}
|
||||
|
||||
public function test_gozer_is_installed()
|
||||
public function testGozerIsInstalled()
|
||||
{
|
||||
self::assertTrue(class_exists('\\Superhelio\\Commands\\Commands\\Gozer'));
|
||||
}
|
||||
|
||||
public function test_gozer_has_required_methods_and_properties()
|
||||
public function testGozerHasRequiredMethodsAndProperties()
|
||||
{
|
||||
$gozer = new ReflectionClass('\\Superhelio\\Commands\\Commands\\Gozer');
|
||||
self::assertTrue($gozer->hasMethod('handle'));
|
||||
@@ -88,14 +90,14 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
self::assertTrue($gozer->hasProperty('dbPrefix'));
|
||||
}
|
||||
|
||||
public function test_gozer_finds_database_prefix()
|
||||
public function testGozerFindsDatabasePrefix()
|
||||
{
|
||||
$gozer = new Gozer();
|
||||
|
||||
self::assertEquals('gozerTest__', $gozer->getDatabasePrefix());
|
||||
}
|
||||
|
||||
public function test_gozer_finds_users_table()
|
||||
public function testGozerFindsUsersTable()
|
||||
{
|
||||
$gozer = new Gozer();
|
||||
|
||||
@@ -110,15 +112,15 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
self::assertContains('gozerTest__users', $filteredTables->toArray());
|
||||
}
|
||||
|
||||
public function test_gozer_table_filtering_works()
|
||||
public function testGozerTableFilteringWorks()
|
||||
{
|
||||
$gozer = new Gozer();
|
||||
$tables = array(
|
||||
$tables = [
|
||||
'gozerTest__users',
|
||||
'gozerTest__migrations',
|
||||
'this_should_be_filtered',
|
||||
'filter_me_too'
|
||||
);
|
||||
'filter_me_too',
|
||||
];
|
||||
|
||||
$gozer->setDatabasePrefix('gozerTest__');
|
||||
$filtered = $gozer->getFilteredTables($tables);
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace Superhelio\Commands\Tests;
|
||||
|
||||
use Superhelio\Commands\Commands\Reload;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ReloadTest extends \Orchestra\Testbench\TestCase
|
||||
{
|
||||
public function testReloadTest()
|
||||
@@ -13,12 +13,12 @@ class ReloadTest extends \Orchestra\Testbench\TestCase
|
||||
self::assertTrue(true);
|
||||
}
|
||||
|
||||
public function test_reload_is_installed()
|
||||
public function testReloadIsInstalled()
|
||||
{
|
||||
self::assertTrue(class_exists('\\Superhelio\\Commands\\Commands\\Reload'));
|
||||
}
|
||||
|
||||
public function test_reload_has_required_methods_and_properties()
|
||||
public function testReloadHasRequiredMethodsAndProperties()
|
||||
{
|
||||
$reload = new \ReflectionClass('\\Superhelio\\Commands\\Commands\\Reload');
|
||||
self::assertTrue($reload->hasMethod('handle'));
|
||||
|
||||
@@ -6,6 +6,6 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
$this->loadMigrationsFrom(dirname(__DIR__) . '/migrations');
|
||||
$this->loadMigrationsFrom(dirname(__DIR__).'/migrations');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ class CreateUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
@@ -25,8 +23,6 @@ class CreateUsersTable extends Migration
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user