Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address Missing Mix Manifest Error #317

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/IgnitionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Facade\Ignition\SolutionProviders\MissingAppKeySolutionProvider;
use Facade\Ignition\SolutionProviders\MissingColumnSolutionProvider;
use Facade\Ignition\SolutionProviders\MissingImportSolutionProvider;
use Facade\Ignition\SolutionProviders\MissingMixManifestSolutionProvider;
use Facade\Ignition\SolutionProviders\MissingPackageSolutionProvider;
use Facade\Ignition\SolutionProviders\RunningLaravelDuskInProductionProvider;
use Facade\Ignition\SolutionProviders\SolutionProviderRepository;
Expand Down Expand Up @@ -371,6 +372,7 @@ protected function getDefaultSolutions(): array
MissingColumnSolutionProvider::class,
UnknownValidationSolutionProvider::class,
UndefinedPropertySolutionProvider::class,
MissingMixManifestSolutionProvider::class,
];
}

Expand Down
25 changes: 25 additions & 0 deletions src/SolutionProviders/MissingMixManifestSolutionProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php


namespace Facade\Ignition\SolutionProviders;

use Facade\IgnitionContracts\BaseSolution;
use Facade\IgnitionContracts\HasSolutionsForThrowable;
use Illuminate\Support\Str;
use Throwable;

class MissingMixManifestSolutionProvider implements HasSolutionsForThrowable
{
public function canSolve(Throwable $throwable): bool
{
return Str::startsWith($throwable->getMessage(), 'The Mix manifest does not exist');
}

public function getSolutions(Throwable $throwable): array
{
return [
BaseSolution::create('Missing Mix Manifest File')
->setSolutionDescription('Did you forget to run `npm install && npm run dev`?'),
];
}
}
31 changes: 31 additions & 0 deletions tests/Solutions/MixManifestNotFoundSolutionProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php


namespace Facade\Ignition\Tests\Solutions;

use Exception;
use Facade\Ignition\SolutionProviders\MissingMixManifestSolutionProvider;
use Facade\Ignition\Tests\TestCase;
use Illuminate\Support\Str;

class MixManifestNotFoundSolutionProviderTest extends TestCase
{
/** @test */
public function it_can_solve_a_missing_mix_manifest_exception()
{
$canSolve = app(MissingMixManifestSolutionProvider::class)
->canSolve(new Exception('The Mix manifest does not exist.'));

$this->assertTrue($canSolve);
}

/** @test */
public function it_can_recommend_running_npm_install_and_npm_run_dev()
{
/** @var \Facade\IgnitionContracts\Solution $solution */
$solution = app(MissingMixManifestSolutionProvider::class)
->getSolutions(new Exception('The Mix manifest does not exist.'))[0];

$this->assertTrue(Str::contains($solution->getSolutionDescription(), 'Did you forget to run `npm install && npm run dev`?'));
}
}