generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from jessarcher/vite
Add solution for missing Vite manifest
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/Solutions/SolutionProviders/MissingViteManifestSolutionProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; | ||
|
||
use Illuminate\Support\Str; | ||
use Spatie\Ignition\Contracts\BaseSolution; | ||
use Spatie\Ignition\Contracts\HasSolutionsForThrowable; | ||
use Throwable; | ||
|
||
class MissingViteManifestSolutionProvider implements HasSolutionsForThrowable | ||
{ | ||
public function canSolve(Throwable $throwable): bool | ||
{ | ||
return Str::startsWith($throwable->getMessage(), 'Vite manifest not found'); | ||
} | ||
|
||
public function getSolutions(Throwable $throwable): array | ||
{ | ||
return [ | ||
BaseSolution::create('Missing Vite Manifest File') | ||
->setSolutionDescription('Did you forget to run `npm install && npm run dev`?'), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/Solutions/ViteManifestNotFoundSolutionProviderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Str; | ||
use Spatie\LaravelIgnition\Solutions\SolutionProviders\MissingViteManifestSolutionProvider; | ||
|
||
it('can solve a missing Vite manifest exception', function () { | ||
$canSolve = app(MissingViteManifestSolutionProvider::class) | ||
->canSolve(new Exception('Vite manifest not found at: public/build/manifest.json')); | ||
|
||
expect($canSolve)->toBeTrue(); | ||
}); | ||
|
||
it('can recommend running npm install and npm run dev', function () { | ||
/** @var \Spatie\Ignition\Contracts\Solution $solution */ | ||
$solution = app(MissingViteManifestSolutionProvider::class) | ||
->getSolutions(new Exception('Vite manifest not found at: public/build/manifest.json'))[0]; | ||
|
||
expect(Str::contains($solution->getSolutionDescription(), 'Did you forget to run `npm install && npm run dev`?'))->toBeTrue(); | ||
}); |