Repository navigation
Expand file tree
/
Copy pathAdminInstallException.php
More file actions
126 lines (113 loc) · 5.42 KB
/
Copy pathAdminInstallException.php
File metadata and controls
126 lines (113 loc) · 5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
declare(strict_types=1);
namespace NyonCode\WireAdmin\Exceptions;
use NyonCode\WireCore\Foundation\Contracts\WireException;
use RuntimeException;
/**
* A step of `wire-admin:install` that could not be taken.
*
* Every case is about the shape of the application rather than a bad argument —
* a directory that cannot be created, a provider list that is not there or is
* not the file Laravel generates — so `RuntimeException` is the base, per
* ADR 0022, and each message ends with the line the developer has to add or fix
* by hand.
*
* Thrown rather than returned as a status, because the installer's hooks are
* deliberately not wrapped in a try/catch by the toolkit: a step that cannot
* finish stops the run instead of printing a tick beside something that did not
* happen. The one case the command catches on purpose is the provider list,
* where the rest of the install is still worth completing — see
* `WireAdminServiceProvider::scaffoldApplication()`.
*/
final class AdminInstallException extends RuntimeException implements WireException
{
public static function layoutDirectoryNotWritable(string $directory): self
{
return new self(
"The admin layout could not be written: [{$directory}] does not exist and cannot be created. ".
'Create it, or copy the layout from the package stub '.
'(vendor/nyoncode/wire-admin/stubs/admin-layout.blade.stub) yourself.'
);
}
/**
* The same failure for the files that are not the layout.
*
* Named separately because the advice differs: the layout has one stub and
* one address, while these are written in pairs and land wherever the caller
* asked for them — so the message points at the file it was writing rather
* than at a stub path that would be the wrong one.
*/
public static function stubDirectoryNotWritable(string $directory, string $target): self
{
return new self(
"[{$target}] could not be written: [{$directory}] does not exist and cannot be created. ".
'Create it and run the installer again.'
);
}
public static function stylesheetMissing(string $file, string $line): self
{
return new self(
"[{$file}] does not exist, so Tailwind was not pointed at the packages' views. ".
"Add [{$line}] to whichever stylesheet imports Tailwind, with the path adjusted to where it lives. ".
'Until it is there the shell renders unstyled — Tailwind skips vendor/ because .gitignore does.'
);
}
public static function stylesheetNotTailwind(string $file, string $line): self
{
return new self(
"[{$file}] does not import Tailwind, so [{$line}] was not written into a file that would ignore it. ".
'Add that line to the stylesheet that does import Tailwind, below the import. '.
'Until it is there the shell renders unstyled — Tailwind skips vendor/ because .gitignore does.'
);
}
public static function providerListMissing(string $file, string $provider): self
{
return new self(
"[{$file}] does not exist, so [{$provider}] could not be registered. ".
'This is an application that keeps its providers elsewhere — add '.
"[{$provider}::class] to that list by hand. Until it is registered, ".
'pages render in whatever layout the application already names.'
);
}
public static function providerListNotEditable(string $file, string $provider): self
{
return new self(
"[{$file}] is not the list Laravel generates — it does not end in a returned array — ".
"so [{$provider}] was not added to it rather than being written into something ".
'this installer does not understand. Add it by hand.'
);
}
public static function dashboardConfigMissing(string $file, string $dashboard): self
{
return new self(
"[{$file}] does not exist, so [{$dashboard}] was not registered. ".
'Publish it with `php artisan vendor:publish --tag=wire-core::config` and add '.
"[\\{$dashboard}::class] to its `dashboards` list. Until it is there the dashboard ".
'is a class nothing reads: no menu entry, no route, and the admin goes back to '.
'forwarding its own address to whichever page sorts first.'
);
}
public static function dashboardConfigNotEditable(string $file, string $dashboard): self
{
return new self(
"[{$file}] has no `dashboards` list this installer could read, so [{$dashboard}] ".
'was not written into something it does not understand. Add '.
"[\\{$dashboard}::class] to that list by hand."
);
}
public static function packageJsonMissing(string $file, string $package): self
{
return new self(
"[{$file}] does not exist, so [{$package}] was not added to it. The stylesheet ".
"names it as a Tailwind plugin — run `npm install -D {$package}` wherever this ".
'application builds its assets, or the build fails on the missing plugin.'
);
}
public static function packageJsonNotEditable(string $file, string $package): self
{
return new self(
"[{$file}] is not valid JSON, so [{$package}] was not written into it. ".
"Run `npm install -D {$package}` yourself."
);
}
}