Skip to content

Commit

Permalink
Merge pull request #100 from jessarcher/vite
Browse files Browse the repository at this point in the history
Add solution for missing Vite manifest
  • Loading branch information
freekmurze authored Jun 15, 2022
2 parents 08380af + 1864488 commit 0525985
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
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 tests/Solutions/ViteManifestNotFoundSolutionProviderTest.php
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();
});

0 comments on commit 0525985

Please sign in to comment.