From 5845d691fc197bdceafa2147516cf325ce73c0ea Mon Sep 17 00:00:00 2001 From: Njogu Amos <29255728+njoguamos@users.noreply.github.com> Date: Mon, 17 Aug 2026 12:34:18 +0300 Subject: [PATCH] Install: laranail/package-tool --- composer.json | 9 + composer.lock | 324 ++++++++++++++++++++++++++++++++- src/AuthKitServiceProvider.php | 54 +++--- tests/Feature/PasskeyTest.php | 10 + 4 files changed, 364 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index f700069..099bd05 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "laravel/framework": "^13.0", "laravel/sanctum": "^4.0", "laravel/socialite": "^5.0", + "laranail/package-tools": "dev-main", "laranail/enumerator": "dev-main", "socialiteproviders/manager": "^4.4" }, @@ -53,9 +54,17 @@ } }, "repositories": [ + { + "type": "vcs", + "url": "https://github.com/laranail/console.git" + }, { "type": "vcs", "url": "https://github.com/laranail/enumerator.git" + }, + { + "type": "vcs", + "url": "https://github.com/laranail/package-tools.git" } ], "scripts": { diff --git a/composer.lock b/composer.lock index d3fa7a2..510a794 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "24f16d2890b16fe27e2f22fc23603a60", + "content-hash": "672b098591604aaff3d996544643e12e", "packages": [ { "name": "bacon/bacon-qr-code", @@ -1276,6 +1276,176 @@ ], "time": "2026-07-17T13:53:03+00:00" }, + { + "name": "laranail/console", + "version": "v0.1.0", + "source": { + "type": "git", + "url": "https://github.com/laranail/console.git", + "reference": "80abd5a834fd8a5570939475fe153e64ab805eb9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laranail/console/zipball/80abd5a834fd8a5570939475fe153e64ab805eb9", + "reference": "80abd5a834fd8a5570939475fe153e64ab805eb9", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "illuminate/console": "^13.0", + "illuminate/contracts": "^13.0", + "illuminate/support": "^13.0", + "laravel/prompts": "^0.3.18|^1.0", + "php": "^8.4.1 || ^8.5", + "symfony/console": "^8.0" + }, + "replace": { + "laranail/console-tools": "*", + "laranail/prompter": "*" + }, + "require-dev": { + "infection/infection": "^0.34", + "larastan/larastan": "^3.0", + "laravel/pint": "^1.18", + "mockery/mockery": "^1.6", + "orchestra/testbench": "^11.0", + "pestphp/pest": "^4.0", + "phpbench/phpbench": "^1.4", + "phpstan/phpstan": "^2.0", + "phpunit/phpunit": "^12.0", + "rector/rector": "^2.0", + "roave/security-advisories": "dev-latest", + "symfony/tui": "^8.2@dev" + }, + "suggest": { + "symfony/tui": "(experimental, PHP >= 8.4.1) Enables the full-screen TUI integration — Console::tui() + Console\\Tui\\RenderableWidget." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.1.x-dev" + }, + "laravel": { + "providers": [ + "Simtabi\\Laranail\\Console\\Providers\\ConsoleServiceProvider" + ], + "aliases": { + "Console": "Simtabi\\Laranail\\Console\\Facades\\Console", + "Prompter": "Simtabi\\Laranail\\Console\\Prompter\\Facades\\PrompterFacade" + } + } + }, + "autoload": { + "psr-4": { + "Simtabi\\Laranail\\Console\\": "src/Console/" + }, + "files": [ + "helpers/helpers.php" + ] + }, + "autoload-dev": { + "psr-4": { + "Simtabi\\Laranail\\Console\\Tools\\Tests\\": "tests/Tools/", + "Simtabi\\Laranail\\Console\\Prompter\\Tests\\": "tests/Prompter/", + "Simtabi\\Laranail\\Console\\Progress\\Tests\\": "tests/Progress/", + "Simtabi\\Laranail\\Console\\Benchmarks\\": "benchmarks/" + } + }, + "scripts": { + "test": [ + "vendor/bin/pest --no-coverage --colors=always" + ], + "bench": [ + "vendor/bin/phpbench run --report=aggregate" + ], + "test-coverage": [ + "vendor/bin/pest --coverage --colors=always" + ], + "test-dirty": [ + "@test --dirty --compact" + ], + "examples": [ + "php examples/tools/widgets.php > /dev/null", + "php examples/tools/design_system.php > /dev/null", + "php examples/tools/colors.php > /dev/null", + "php examples/tools/typography.php > /dev/null", + "php examples/tools/markdown.php > /dev/null", + "php examples/tools/theming.php > /dev/null", + "php examples/tools/barchart.php > /dev/null", + "php examples/tools/charts.php > /dev/null", + "php examples/tools/emoji.php > /dev/null", + "php examples/tools/symbols.php > /dev/null", + "php examples/tools/writing.php > /dev/null 2>&1", + "php examples/tools/interactive.php > /dev/null", + "php examples/tools/menu.php > /dev/null", + "php examples/tools/tui.php > /dev/null", + "php examples/prompter/validators.php > /dev/null" + ], + "lint": [ + "@pint", + "@phpstan", + "@rector" + ], + "pint": [ + "vendor/bin/pint --test" + ], + "pint-fix": [ + "vendor/bin/pint" + ], + "phpstan": [ + "vendor/bin/phpstan analyse --no-progress" + ], + "rector": [ + "vendor/bin/rector process --dry-run" + ], + "rector-fix": [ + "vendor/bin/rector process" + ], + "audit": [ + "@composer-audit" + ], + "composer-audit": [ + "@composer audit" + ] + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Simtabi LLC", + "email": "opensource@simtabi.com", + "homepage": "https://opensource.simtabi.com", + "role": "Organization" + }, + { + "name": "Imani Manyara", + "email": "imani@simtabi.com", + "role": "Maintainer" + } + ], + "description": "A Rich-class console toolkit for Laravel — fluent output formatter, spinners, progress bars, boxes, trees and tables, plus a fluent prompts/forms layer with validators.", + "homepage": "https://opensource.simtabi.com/products/laranail/console", + "keywords": [ + "artisan", + "console", + "formatter", + "forms", + "laranail", + "laravel", + "progress", + "prompts", + "spinner", + "terminal", + "tui" + ], + "support": { + "issues": "https://github.com/laranail/console/issues", + "source": "https://github.com/laranail/console", + "docs": "https://opensource.simtabi.com/documentation/laranail/console/" + }, + "time": "2026-08-15T07:40:05+00:00" + }, { "name": "laranail/enumerator", "version": "dev-main", @@ -1417,6 +1587,155 @@ ], "time": "2026-08-15T07:30:58+00:00" }, + { + "name": "laranail/package-tools", + "version": "dev-main", + "source": { + "type": "git", + "url": "https://github.com/laranail/package-tools.git", + "reference": "c9b7a368584e0752bda65d12fc2e21c795a194bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laranail/package-tools/zipball/c9b7a368584e0752bda65d12fc2e21c795a194bd", + "reference": "c9b7a368584e0752bda65d12fc2e21c795a194bd", + "shasum": "" + }, + "require": { + "illuminate/bus": "^13.0", + "illuminate/console": "^13.0", + "illuminate/contracts": "^13.0", + "illuminate/database": "^13.0", + "illuminate/filesystem": "^13.0", + "illuminate/http": "^13.0", + "illuminate/log": "^13.0", + "illuminate/queue": "^13.0", + "illuminate/support": "^13.0", + "laranail/console": "^0.1", + "php": "^8.4.1 || ^8.5", + "symfony/process": "^8.0" + }, + "require-dev": { + "fakerphp/faker": "^1.23", + "larastan/larastan": "^3.0", + "laravel/pint": "^1.18", + "mockery/mockery": "^1.6", + "orchestra/testbench": "^11.0", + "pestphp/pest": "^3.0", + "phpstan/phpstan": "^2.0", + "phpunit/phpunit": "^11.0", + "rector/rector": "^2.0", + "roave/security-advisories": "dev-latest", + "spatie/pest-plugin-test-time": "^2.2" + }, + "suggest": { + "fakerphp/faker": "Required by the InteractsWithSeedFiles trait's fake() generator (^1.23)." + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.1.x-dev" + }, + "laravel": { + "providers": [ + "Simtabi\\Laranail\\Package\\Tools\\Providers\\PackageToolsServiceProvider" + ], + "aliases": { + "PackageSeeder": "Simtabi\\Laranail\\Package\\Tools\\Facades\\PackageSeeder" + } + } + }, + "autoload": { + "psr-4": { + "Simtabi\\Laranail\\Package\\Tools\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Simtabi\\Laranail\\Package\\Tools\\Tests\\": "tests/" + }, + "classmap": [ + "tests/fixtures/" + ] + }, + "scripts": { + "setup": [ + "bash .scripts/init.sh" + ], + "test": [ + "vendor/bin/pest --colors=always" + ], + "test-coverage": [ + "@test --coverage" + ], + "test-dirty": [ + "@test --dirty --compact" + ], + "lint": [ + "@pint", + "@phpstan", + "@rector", + "@sync-check" + ], + "sync-check": [ + "@php tools/generate-timezone-enum.php --check" + ], + "pint": [ + "vendor/bin/pint --test" + ], + "pint-fix": [ + "vendor/bin/pint" + ], + "phpstan": [ + "vendor/bin/phpstan analyse --no-progress" + ], + "rector": [ + "vendor/bin/rector process --dry-run" + ], + "rector-fix": [ + "vendor/bin/rector process" + ], + "audit": [ + "@composer-audit" + ], + "composer-audit": [ + "@composer audit" + ] + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Simtabi LLC", + "email": "opensource@simtabi.com", + "homepage": "https://opensource.simtabi.com", + "role": "Organization" + }, + { + "name": "Imani Manyara", + "email": "imani@simtabi.com", + "role": "Maintainer" + } + ], + "description": "Runtime base library for building Laravel packages — fluent Package builder + abstract PackageServiceProvider with attribute-driven discovery, package-tools.doctor, and isolation testing.", + "homepage": "https://opensource.simtabi.com/products/laranail/package-tools", + "keywords": [ + "fluent-api", + "laranail", + "laravel", + "package-builder", + "package-tools", + "service-provider" + ], + "support": { + "issues": "https://github.com/laranail/package-tools/issues", + "source": "https://github.com/laranail/package-tools", + "docs": "https://opensource.simtabi.com/documentation/laranail/package-tools/" + }, + "time": "2026-08-15T07:41:08+00:00" + }, { "name": "laravel/fortify", "version": "v1.38.0", @@ -11713,7 +12032,8 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "laranail/enumerator": 20 + "laranail/enumerator": 20, + "laranail/package-tools": 20 }, "prefer-stable": true, "prefer-lowest": false, diff --git a/src/AuthKitServiceProvider.php b/src/AuthKitServiceProvider.php index 19a879e..8ed2de9 100644 --- a/src/AuthKitServiceProvider.php +++ b/src/AuthKitServiceProvider.php @@ -7,13 +7,32 @@ use Laravel\Fortify\Fortify; use Laravel\Passkeys\Passkeys; use Illuminate\Support\Facades\Event; -use Illuminate\Support\ServiceProvider; use Simtabi\Laranail\Auth\Models\Passkey; +use Simtabi\Laranail\Package\Tools\Package; use SocialiteProviders\Manager\SocialiteWasCalled; +use Simtabi\Laranail\Package\Tools\Providers\PackageServiceProvider; -class AuthKitServiceProvider extends ServiceProvider +class AuthKitServiceProvider extends PackageServiceProvider { - public function register(): void + public function configurePackage(Package $package): void + { + $package + ->name('laranail/auth-kit') + ->publish( + paths: ['config/auth-kit.php' => config_path(path: 'auth-kit.php')], + tag: 'auth-kit-config', + ) + ->publish( + paths: ['database/migrations/social' => database_path(path: 'migrations')], + tag: 'auth-kit-social-migrations', + ) + ->publish( + paths: ['database/migrations/passkeys' => database_path(path: 'migrations')], + tag: 'auth-kit-passkey-migrations', + ); + } + + public function packageRegistered(): void { $this->mergeConfigFrom(path: __DIR__.'/../config/auth-kit.php', key: 'auth-kit'); @@ -39,10 +58,9 @@ public function register(): void $this->app->bind(abstract: Contracts\ResolveSocialIdentityInterface::class, concrete: Actions\ResolveSocialIdentity::class); } - public function boot(): void + public function packageBooted(): void { $this->configureFortify(); - $this->registerMigrations(); $this->registerConfig(); $this->registerPayPalProvider(); } @@ -59,23 +77,6 @@ private function configureFortify(): void Fortify::resetUserPasswordsUsing(callback: Actions\ResetUserPassword::class); } - private function registerMigrations(): void - { - if (! $this->app->runningInConsole()) { - return; - } - - $this->publishes( - paths: [__DIR__.'/../database/migrations/social' => database_path(path: 'migrations')], - groups: 'auth-kit-social-migrations' - ); - - $this->publishes( - paths: [__DIR__.'/../database/migrations/passkeys' => database_path(path: 'migrations')], - groups: 'auth-kit-passkey-migrations' - ); - } - private function registerConfig(): void { foreach (config(key: 'auth-kit.social', default: []) as $provider => $providerConfig) { @@ -83,15 +84,6 @@ private function registerConfig(): void config()->set(key: "services.{$provider}", value: $providerConfig); } } - - if (! $this->app->runningInConsole()) { - return; - } - - $this->publishes( - paths: [__DIR__.'/../config/auth-kit.php' => config_path(path: 'auth-kit.php')], - groups: 'auth-kit-config' - ); } private function registerPayPalProvider(): void diff --git a/tests/Feature/PasskeyTest.php b/tests/Feature/PasskeyTest.php index fa8e2b5..cbf2ae9 100644 --- a/tests/Feature/PasskeyTest.php +++ b/tests/Feature/PasskeyTest.php @@ -41,6 +41,16 @@ ->toContain(realpath(dirname(__DIR__, 2) . '/database/migrations/passkeys')); }); +it('publishes the Auth Kit social migrations on demand', function (): void { + $paths = ServiceProvider::pathsToPublish( + provider: AuthKitServiceProvider::class, + group: 'auth-kit-social-migrations', + ); + + expect(array_map('realpath', array_keys($paths))) + ->toContain(realpath(dirname(__DIR__, 2) . '/database/migrations/social')); +}); + it('delegates passkey routes to the laravel passkeys controllers', function (): void { expect(Route::getRoutes()->getByName('passkey.login')->getActionName()) ->toBe(PasskeyLoginController::class . '@store')