updated streamline-setup v2

This commit is contained in:
2025-01-15 08:53:49 -08:00
committed by alec.turner
parent a2ce9248f0
commit 4b569f81b0
20228 changed files with 2932048 additions and 63204 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ Only the latest major version of Laravel UI receives bug fixes. The table below
|---- |----|
| [1.x](https://github.com/laravel/ui/tree/1.x) | 5.8, 6.x |
| [2.x](https://github.com/laravel/ui/tree/2.x) | 7.x |
| [3.x](https://github.com/laravel/ui/tree/3.x) | 8.x |
| [3.x](https://github.com/laravel/ui/tree/3.x) | 8.x, 9.x |
| [4.x](https://github.com/laravel/ui/tree/4.x) | 9.x, 10.x, 11.x |
### Installation
@@ -93,7 +93,7 @@ By default, the Laravel `vite.config.js` file compiles your SASS and the `resour
#### Writing Vue Components
When using the `laravel/ui` package to scaffold your frontend, an `ExampleComponent.vue` Vue component will be placed in the `resources/js/components` directory. The `ExampleComponent.vue` file is an example of a [single file Vue component](https://vuejs.org/guide/single-file-components) which defines its JavaScript and HTML template in the same file. Single file components provide a very convenient approach to building JavaScript driven applications. The example component is registered in your `app.js` file:
When using the `laravel/ui` package to scaffold your frontend, an `ExampleComponent.vue` Vue component will be placed in the `resources/js/components` directory. The `ExampleComponent.vue` file is an example of a [single file Vue component](https://vuejs.org/guide/scaling-up/sfc.html) which defines its JavaScript and HTML template in the same file. Single file components provide a very convenient approach to building JavaScript driven applications. The example component is registered in your `app.js` file:
```javascript
import ExampleComponent from './components/ExampleComponent.vue';
+4 -3
View File
@@ -14,11 +14,12 @@
"illuminate/console": "^9.21|^10.0|^11.0",
"illuminate/filesystem": "^9.21|^10.0|^11.0",
"illuminate/support": "^9.21|^10.0|^11.0",
"illuminate/validation": "^9.21|^10.0|^11.0"
"illuminate/validation": "^9.21|^10.0|^11.0",
"symfony/console": "^6.0|^7.0"
},
"require-dev": {
"orchestra/testbench": "^7.0|^8.0|^9.0",
"phpunit/phpunit": "^9.3|^10.4"
"orchestra/testbench": "^7.35|^8.15|^9.0",
"phpunit/phpunit": "^9.3|^10.4|^11.0"
},
"autoload": {
"psr-4": {
@@ -4,7 +4,9 @@ namespace Laravel\Ui;
use Illuminate\Console\Command;
use InvalidArgumentException;
use Symfony\Component\Console\Attribute\AsCommand;
#[AsCommand(name: 'ui:auth')]
class AuthCommand extends Command
{
/**
@@ -116,7 +118,7 @@ class AuthCommand extends Command
$controller = app_path('Http/Controllers/HomeController.php');
if (file_exists($controller) && ! $this->option('force')) {
if ($this->components->confirm("The [HomeController.php] file already exists. Do you want to replace it?")) {
if ($this->components->confirm("The [HomeController.php] file already exists. Do you want to replace it?", true)) {
file_put_contents($controller, $this->compileStub('controllers/HomeController'));
}
} else {
@@ -126,7 +128,7 @@ class AuthCommand extends Command
$baseController = app_path('Http/Controllers/Controller.php');
if (file_exists($baseController) && ! $this->option('force')) {
if ($this->components->confirm("The [Controller.php] file already exists. Do you want to replace it?")) {
if ($this->components->confirm("The [Controller.php] file already exists. Do you want to replace it?", true)) {
file_put_contents($baseController, $this->compileStub('controllers/Controller'));
}
} else {
@@ -5,8 +5,10 @@ namespace Laravel\Ui;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Finder\SplFileInfo;
#[AsCommand(name: 'ui:controllers')]
class ControllersCommand extends Command
{
/**
@@ -4,7 +4,9 @@ namespace Laravel\Ui;
use Illuminate\Console\Command;
use InvalidArgumentException;
use Symfony\Component\Console\Attribute\AsCommand;
#[AsCommand(name: 'ui')]
class UiCommand extends Command
{
/**
@@ -35,5 +35,6 @@ class LoginController extends Controller
public function __construct()
{
$this->middleware('guest')->except('logout');
$this->middleware('auth')->only('logout');
}
}
@@ -3,19 +3,24 @@
namespace Laravel\Ui\Tests\AuthBackend;
use Illuminate\Auth\Events\Attempting;
use Illuminate\Auth\Events\Logout;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Request;
use Illuminate\Routing\Pipeline;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
use Illuminate\Testing\TestResponse;
use Illuminate\Validation\ValidationException;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;
#[WithMigration]
class AuthenticatesUsersTest extends TestCase
{
use AuthenticatesUsers;
use AuthenticatesUsers, RefreshDatabase;
protected function tearDown(): void
{
@@ -24,17 +29,7 @@ class AuthenticatesUsersTest extends TestCase
parent::tearDown();
}
/**
* Define database migrations.
*
* @return void
*/
protected function defineDatabaseMigrations()
{
$this->loadLaravelMigrations();
}
/** @test */
#[Test]
public function it_can_authenticate_a_user()
{
Event::fake();
@@ -57,7 +52,27 @@ class AuthenticatesUsersTest extends TestCase
});
}
/** @test */
#[Test]
public function it_can_deauthenticate_a_user()
{
Event::fake();
$user = UserFactory::new()->create();
$this->actingAs($user);
$request = Request::create('/logout', 'POST', [], [], [], [
'HTTP_ACCEPT' => 'application/json',
]);
$response = $this->handleRequestUsing(
$request, fn ($request) => $this->logout($request)
)->assertStatus(204);
Event::assertDispatched(fn (Logout $event) => $user->is($event->user));
}
#[Test]
public function it_can_authenticate_a_user_with_remember_as_false()
{
Event::fake();
@@ -81,9 +96,7 @@ class AuthenticatesUsersTest extends TestCase
});
}
/** @test */
#[Test]
public function it_can_authenticate_a_user_with_remember_as_true()
{
Event::fake();
@@ -107,7 +120,7 @@ class AuthenticatesUsersTest extends TestCase
});
}
/** @test */
#[Test]
public function it_cant_authenticate_a_user_with_invalid_password()
{
$user = UserFactory::new()->create();
@@ -131,7 +144,7 @@ class AuthenticatesUsersTest extends TestCase
], $response->exception->errors());
}
/** @test */
#[Test]
public function it_cant_authenticate_unknown_credential()
{
$request = Request::create('/login', 'POST', [
@@ -4,6 +4,7 @@ namespace Laravel\Ui\Tests\AuthBackend;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Foundation\Auth\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Request;
use Illuminate\Routing\Pipeline;
use Illuminate\Support\Facades\Auth;
@@ -11,24 +12,17 @@ use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Testing\TestResponse;
use Illuminate\Validation\ValidationException;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;
#[WithMigration]
class RegistersUsersTest extends TestCase
{
use RegistersUsers;
use RegistersUsers, RefreshDatabase;
/**
* Define database migrations.
*
* @return void
*/
protected function defineDatabaseMigrations()
{
$this->loadLaravelMigrations();
}
/** @test */
#[Test]
public function it_can_register_a_user()
{
$request = Request::create('/register', 'POST', [
@@ -2,20 +2,19 @@
namespace Laravel\Ui\Tests\AuthBackend;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\ThrottlesLogins as ThrottlesLoginsTrait;
use Orchestra\Testbench\TestCase;
use Illuminate\Http\Request;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class ThrottleLoginsTest extends TestCase
{
/**
* @test
* @dataProvider emailProvider
*/
#[Test]
#[DataProvider('emailProvider')]
public function it_can_generate_throttle_key(string $email, string $expectedEmail): void
{
$throttle = $this->getMockForTrait(ThrottlesLogins::class, [], '', true, true, true, ['username']);
$throttle = $this->createMock(ThrottlesLogins::class);
$throttle->method('username')->willReturn('email');
$reflection = new \ReflectionClass($throttle);
$method = $reflection->getMethod('throttleKey');
@@ -33,8 +32,18 @@ class ThrottleLoginsTest extends TestCase
return [
'lowercase special characters' => ['ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ', 'test@laravel.com'],
'uppercase special characters' => ['ⓉⒺⓈⓉ@ⓁⒶⓇⒶⓋⒺⓁ.ⒸⓄⓂ', 'test@laravel.com'],
'special character numbers' =>['test⑩⓸③@laravel.com', 'test1043@laravel.com'],
'special character numbers' => ['test⑩⓸③@laravel.com', 'test1043@laravel.com'],
'default email' => ['test@laravel.com', 'test@laravel.com'],
];
}
}
class ThrottlesLogins
{
use ThrottlesLoginsTrait;
public function username()
{
return 'email';
}
}