diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 297d71d..2ceb744 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,7 +6,7 @@ jobs: php-cs-fixer: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 493122d..d11e59b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,10 +7,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.4', '8.0'] + php-versions: ['8.0', '8.1', '8.2'] steps: - - uses: actions/checkout@v2.3.4 - - uses: php-actions/composer@v6 + - uses: actions/checkout@v3 with: - php_version: ${{ matrix.php-versions }} - - uses: NWBY/pest-action@v1.2.0 + ref: ${{ github.head_ref }} + + - name: Install Dependencies via Composer + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: Run tests + run: composer test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 71bdbd2..badab99 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,6 +34,6 @@ php spinupwp app:build spinupwp Commit the changes to the main branch. -On GitHub, [create a new release](https://github.com/deliciousbrains/spinupwp-cli/releases/new). Set the tag and release title to the semantic version, but prepend the letter **v**. For example, if releasing version `1.1.1`, the tag and release title should be `v1.1.1`. Leave target set to main and add any release notes to the description field. +On GitHub, [create a new release](https://github.com/spinupwp/spinupwp-cli/releases/new). Set the tag and release title to the semantic version, but prepend the letter **v**. For example, if releasing version `1.1.1`, the tag and release title should be `v1.1.1`. Leave target set to main and add any release notes to the description field. -Hit 'Publish release' to finalize the release. This will automatically update [Packagist](https://packagist.org/packages/deliciousbrains/spinupwp-cli) with the latest version. +Hit 'Publish release' to finalize the release. This will automatically update [Packagist](https://packagist.org/packages/spinupwp/spinupwp-cli) with the latest version. diff --git a/app/Commands/BaseCommand.php b/app/Commands/BaseCommand.php index bb560a9..9d1cb60 100644 --- a/app/Commands/BaseCommand.php +++ b/app/Commands/BaseCommand.php @@ -5,11 +5,11 @@ use App\Commands\Concerns\InteractsWithIO; use App\Repositories\ConfigRepository; use App\Repositories\SpinupWpRepository; -use DeliciousBrains\SpinupWp\Exceptions\ValidationException; use Exception; use GuzzleHttp\Client; use Illuminate\Support\Str; use LaravelZero\Framework\Commands\Command; +use SpinupWp\Exceptions\ValidationException; abstract class BaseCommand extends Command { @@ -82,7 +82,7 @@ protected function apiToken(): string { $apiToken = $this->config->get('api_token', $this->profile()); - if (!$apiToken) { + if (!$apiToken || !is_string($apiToken)) { throw new Exception("The API token for the profile {$this->profile()} is not yet configured"); } diff --git a/app/Commands/Concerns/InteractsWithIO.php b/app/Commands/Concerns/InteractsWithIO.php index 9dab008..0bdc10b 100644 --- a/app/Commands/Concerns/InteractsWithIO.php +++ b/app/Commands/Concerns/InteractsWithIO.php @@ -220,7 +220,7 @@ public function queueResources(Collection $resources, string $endpoint, string $ if ($shouldWait) { sleep(1); } - $eventId = call_user_func(fn () => $resource->$endpoint()); + $eventId = call_user_func(fn () => $resource->$endpoint()); $events[] = ["{$eventId}", $resource->{$resourcesId}]; } catch (\Exception $e) { if ($resources->count() === 1) { diff --git a/app/Commands/Concerns/SpecifyFields.php b/app/Commands/Concerns/SpecifyFields.php index 9f9aaf7..aba1183 100644 --- a/app/Commands/Concerns/SpecifyFields.php +++ b/app/Commands/Concerns/SpecifyFields.php @@ -3,7 +3,7 @@ namespace App\Commands\Concerns; use App\Field; -use DeliciousBrains\SpinupWp\Resources\Resource; +use SpinupWp\Resources\Resource; trait SpecifyFields { diff --git a/app/Commands/Sites/Sites.php b/app/Commands/Sites/Sites.php index a551c5a..db4bc9f 100644 --- a/app/Commands/Sites/Sites.php +++ b/app/Commands/Sites/Sites.php @@ -26,29 +26,29 @@ protected function setUp(): void (new Field('HTTPS', 'https')) ->couldBeEnabledOrDisabled(), (new Field('Database Table Prefix', 'database')) - ->withIgnoreRule(fn ($value) => empty($value['table_prefix'])) + ->withIgnoreRule(fn ($value) => empty($value['table_prefix'])) ->withTransformRule(fn ($value) => $value['table_prefix']), (new Field('Git', 'git')) ->couldBeEnabledOrDisabled(), (new Field('Repository', 'git')) ->withAliases(['git.repo']) - ->withIgnoreRule(fn ($value) => !$value['enabled']) + ->withIgnoreRule(fn ($value) => !$value['enabled']) ->withTransformRule(fn ($value) => $value['repo']), (new Field('Branch', 'git')) ->withAliases(['git.branch']) - ->withIgnoreRule(fn ($value) => !$value['enabled']) + ->withIgnoreRule(fn ($value) => !$value['enabled']) ->withTransformRule(fn ($value) => $value['branch']), (new Field('Deploy Script', 'git')) ->withAliases(['git.deploy_script']) - ->withIgnoreRule(fn ($value) => !$value['enabled']) + ->withIgnoreRule(fn ($value) => !$value['enabled']) ->withTransformRule(fn ($value) => $value['deploy_script']), (new Field('Push-to-deploy', 'git')) ->withAliases(['git.push_enabled']) - ->withIgnoreRule(fn ($value) => !$value['enabled'] || !$value['push_enabled']) + ->withIgnoreRule(fn ($value) => !$value['enabled'] || !$value['push_enabled']) ->withTransformRule(fn ($value) => $value['push_enabled'] ? 'Enabled' : 'Disabled'), (new Field('Deployment URL', 'git')) ->withAliases(['git.deployment_url']) - ->withIgnoreRule(fn ($value) => !$value['enabled'] || !$value['push_enabled']) + ->withIgnoreRule(fn ($value) => !$value['enabled'] || !$value['push_enabled']) ->withTransformRule(fn ($value) => $value['deployment_url']), (new Field('WP Core Update', 'wp_core_update')) ->yesOrNo(), @@ -65,11 +65,11 @@ protected function setUp(): void ->withTransformRule(fn ($value) => $value['database'] ? 'Enabled' : 'Disabled'), (new Field('Backup Retention Period', 'backups')) ->withAliases(['backups.retention_period']) - ->withIgnoreRule(fn ($value) => !$value['files'] && $value['database']) + ->withIgnoreRule(fn ($value) => !$value['files'] && $value['database']) ->withTransformRule(fn ($value) => $value['retention_period'] . ' days'), (new Field('Next Backup Time', 'backups')) ->withAliases(['backups.next_run_time']) - ->withIgnoreRule(fn ($value) => !(bool) $value['next_run_time']) + ->withIgnoreRule(fn ($value) => !(bool) $value['next_run_time']) ->withTransformRule(fn ($value) => $value['next_run_time']), (new Field('Uploads Directory Protection', 'nginx')) ->withAliases(['nginx.uploads_directory_protected']) @@ -84,7 +84,7 @@ protected function setUp(): void ->couldBeEnabledOrDisabled(), (new Field('Basic Auth Username', 'basic_auth')) ->withAliases(['basic_auth.username']) - ->withIgnoreRule(fn ($value) => !$value['enabled']) + ->withIgnoreRule(fn ($value) => !$value['enabled']) ->withTransformRule(fn ($value) => $value['username']), (new Field('Created At', 'created_at')), (new Field('Status', 'status')) diff --git a/app/Field.php b/app/Field.php index f58ffe3..dca9554 100644 --- a/app/Field.php +++ b/app/Field.php @@ -3,7 +3,7 @@ namespace App; use Closure; -use DeliciousBrains\SpinupWp\Resources\Resource; +use SpinupWp\Resources\Resource; class Field { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5b4b8c8..06a5ab7 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,8 +4,8 @@ use App\Repositories\ConfigRepository; use App\Repositories\SpinupWpRepository; -use DeliciousBrains\SpinupWp\SpinupWp; use Illuminate\Support\ServiceProvider; +use SpinupWp\SpinupWp; class AppServiceProvider extends ServiceProvider { diff --git a/app/Repositories/SpinupWpRepository.php b/app/Repositories/SpinupWpRepository.php index d3c40f0..6843996 100644 --- a/app/Repositories/SpinupWpRepository.php +++ b/app/Repositories/SpinupWpRepository.php @@ -2,15 +2,14 @@ namespace App\Repositories; -use App\Helpers\OptionsHelper; -use DeliciousBrains\SpinupWp\Endpoints\Event; -use DeliciousBrains\SpinupWp\Endpoints\Server; -use DeliciousBrains\SpinupWp\Endpoints\Site; -use DeliciousBrains\SpinupWp\Resources\Server as ServerResource; -use DeliciousBrains\SpinupWp\Resources\Site as SiteResource; -use DeliciousBrains\SpinupWp\SpinupWp; use GuzzleHttp\Client; use Illuminate\Support\Collection; +use SpinupWp\Endpoints\Event; +use SpinupWp\Endpoints\Server; +use SpinupWp\Endpoints\Site; +use SpinupWp\Resources\Server as ServerResource; +use SpinupWp\Resources\Site as SiteResource; +use SpinupWp\SpinupWp; /** * @method SpinupWp setApiKey(string $apiKey) diff --git a/bin/box b/bin/box new file mode 100755 index 0000000..bd431d7 Binary files /dev/null and b/bin/box differ diff --git a/builds/spinupwp b/builds/spinupwp index 6547a7a..926bc4e 100755 Binary files a/builds/spinupwp and b/builds/spinupwp differ diff --git a/composer.json b/composer.json index 9751f04..f65b555 100644 --- a/composer.json +++ b/composer.json @@ -4,15 +4,15 @@ "keywords": ["spinupwp", "cli"], "license": "MIT", "require": { - "php": "^7.4|^8.0", - "spinupwp/spinupwp-php-sdk": "^0.5.2" + "php": "^8.0", + "spinupwp/spinupwp-php-sdk": "^1.0.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", - "laravel-zero/framework": "^8.9", + "laravel-zero/framework": "<=9.2.0", "mockery/mockery": "^1.4.3", "pestphp/pest": "^1.3", - "phpstan/phpstan": "^0.12.99" + "phpstan/phpstan": "^1.8" }, "autoload": { "psr-4": { @@ -27,7 +27,10 @@ "config": { "preferred-install": "dist", "sort-packages": true, - "optimize-autoloader": true + "optimize-autoloader": true, + "allow-plugins": { + "pestphp/pest-plugin": true + } }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/config/app.php b/config/app.php index 73f0544..33657cd 100644 --- a/config/app.php +++ b/config/app.php @@ -26,7 +26,7 @@ | */ - 'version' => '1.0.0', + 'version' => '1.1.0', /* |-------------------------------------------------------------------------- diff --git a/config/commands.php b/config/commands.php index 65ce57a..72518fe 100644 --- a/config/commands.php +++ b/config/commands.php @@ -93,7 +93,7 @@ */ 'remove' => [ - // .. + \LaravelZero\Framework\Commands\TestMakeCommand::class, ], ]; diff --git a/phpstan.neon b/phpstan.neon index 0d037f6..99a3d44 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,8 +9,8 @@ parameters: checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false universalObjectCratesClasses: - - DeliciousBrains\SpinupWp\Resources\Resource - - DeliciousBrains\SpinupWp\Endpoints\Endpoint - excludes_analyse: + - SpinupWp\Resources\Resource + - SpinupWp\Endpoints\Endpoint + excludePaths: - vendor/* - tests/* diff --git a/tests/Feature/Commands/SitesGetCommandTest.php b/tests/Feature/Commands/SitesGetCommandTest.php index 3c48bbd..1183650 100644 --- a/tests/Feature/Commands/SitesGetCommandTest.php +++ b/tests/Feature/Commands/SitesGetCommandTest.php @@ -55,7 +55,7 @@ 'wp_plugin_updates' => 3, 'git' => [ 'enabled' => true, - 'repo' => 'git@github.com:deliciousbrains/spinupwp-composer-site.git', + 'repo' => 'git@github.com:spinupwp/spinupwp-composer-site.git', 'branch' => 'main', 'deploy_script' => 'composer install --optimize-autoload --no-dev', 'push_enabled' => true, @@ -108,7 +108,7 @@ ->expectsTable([], [ ['Domain', 'hellfish.media'], ['Git', 'Enabled'], - ['Repository', 'git@github.com:deliciousbrains/spinupwp-composer-site.git'], + ['Repository', 'git@github.com:spinupwp/spinupwp-composer-site.git'], ['Branch', 'main'], ['Deploy Script', 'composer install --optimize-autoload --no-dev'], ['Push-to-deploy', 'Enabled'],