@@ -18,7 +18,17 @@ use Pdp\Logger;
18
18
use Pdp \Installer ;
19
19
use Pdp \Manager ;
20
20
21
- require dirname (__DIR__ ).'/vendor/autoload.php ' ;
21
+ function get_vendor_path (): ?string
22
+ {
23
+ for ($ i = 1 ; $ i <= 5 ; $ i ++) {
24
+ $ vendor = dirname (__DIR__ , $ i ).'/vendor ' ;
25
+ if (is_dir ($ vendor ) && file_exists ($ vendor .'/autoload.php ' )) {
26
+ return $ vendor ;
27
+ }
28
+ }
29
+
30
+ return null ;
31
+ }
22
32
23
33
function writeln (array $ messages , $ output ): int
24
34
{
@@ -41,6 +51,20 @@ function fail(string $message, $output = STDERR): int
41
51
return writeln ($ messages , $ output );
42
52
}
43
53
54
+ $ vendor = get_vendor_path ();
55
+ if (null === $ vendor ) {
56
+ $ message = <<<TEXT
57
+ You must set up the project dependencies using composer
58
+ see https://getcomposer.org
59
+ TEXT ;
60
+
61
+ fail ($ message );
62
+
63
+ die (1 );
64
+ }
65
+
66
+ require $ vendor .'/autoload.php ' ;
67
+
44
68
/**
45
69
* CLI colors
46
70
*/
@@ -72,7 +96,7 @@ if (isset($arguments['help']) || isset($arguments['h'])) {
72
96
$ helpText = <<<HELP
73
97
{$ yellow }Usage: $ reset
74
98
$ script [options]
75
-
99
+
76
100
{$ yellow }Options: $ reset
77
101
$ green --%s $ reset refreshes the Public Suffix List cache
78
102
$ green --%s=URL $ reset set the URL to use to refresh the PSL cache ( {$ yellow }default: $ reset %s)
@@ -84,15 +108,15 @@ if (isset($arguments['help']) || isset($arguments['h'])) {
84
108
85
109
{$ yellow }Help: $ reset
86
110
The {$ green }update-psl $ reset command updates your PDP local cache.
87
-
111
+
88
112
{$ yellow }Examples: $ reset
89
113
90
114
Refresh all caches using the default settings
91
115
$ green$ script$ reset
92
-
93
- Refresh only the PSL cache for a TTL of 3 DAY
116
+
117
+ Refresh only the PSL cache for a TTL of 3 DAY
94
118
$ green$ script --psl --ttl="3 DAYS" $ reset
95
-
119
+
96
120
Refresh all caches using another cache directory
97
121
$ green$ script --cache-dir=/temp $ reset
98
122
0 commit comments