|
9 | 9 | is_dir($destPath) || mkdir($destPath, 0777, true); |
10 | 10 | $manifest = []; |
11 | 11 | require 'snappymail/v/0.0.0/app/libraries/RainLoop/Plugins/AbstractPlugin.php'; |
| 12 | + $keys = [ |
| 13 | + 'author', |
| 14 | + 'category', |
| 15 | + 'description', |
| 16 | + 'file', |
| 17 | + 'id', |
| 18 | + 'license', |
| 19 | + 'name', |
| 20 | + 'release', |
| 21 | + 'required', |
| 22 | + 'type', |
| 23 | + 'url', |
| 24 | + 'version' |
| 25 | + ]; |
12 | 26 | foreach (glob('plugins/*', GLOB_NOSORT | GLOB_ONLYDIR) as $dir) { |
13 | | - require "{$dir}/index.php"; |
14 | | - $name = basename($dir); |
15 | | - $class = new ReflectionClass(str_replace('-', '', $name) . 'Plugin'); |
16 | | - $manifest_item = []; |
17 | | - foreach ($class->getConstants() as $key => $value) { |
18 | | - $manifest_item[\strtolower($key)] = $value; |
19 | | - } |
20 | | - $version = $manifest_item['version']; |
21 | | - if (0 < floatval($version)) { |
22 | | - echo "+ {$name} {$version}\n"; |
23 | | - $manifest_item['type'] = 'plugin'; |
24 | | - $manifest_item['id'] = $name; |
25 | | - $manifest_item['file'] = "{$dir}-{$version}.tgz"; |
26 | | - ksort($manifest_item); |
27 | | - $manifest[$name] = $manifest_item; |
28 | | - $tar_destination = "{$destPath}{$name}-{$version}.tar"; |
29 | | - $tgz_destination = "{$destPath}{$name}-{$version}.tgz"; |
30 | | - @unlink($tgz_destination); |
31 | | - @unlink("{$tar_destination}.gz"); |
32 | | - $tar = new PharData($tar_destination); |
33 | | - $tar->buildFromDirectory('./plugins/', "@{$name}@"); |
34 | | - $tar->compress(Phar::GZ); |
35 | | - unlink($tar_destination); |
36 | | - rename("{$tar_destination}.gz", $tgz_destination); |
37 | | - } else { |
38 | | - echo "- {$name} {$version}\n"; |
| 27 | + if (is_file("{$dir}/index.php")) { |
| 28 | + require "{$dir}/index.php"; |
| 29 | + $name = basename($dir); |
| 30 | + $class = new ReflectionClass(str_replace('-', '', $name) . 'Plugin'); |
| 31 | + $manifest_item = []; |
| 32 | + foreach ($class->getConstants() as $key => $value) { |
| 33 | + $key = \strtolower($key); |
| 34 | + if (in_array($key, $keys)) { |
| 35 | + $manifest_item[$key] = $value; |
| 36 | + } |
| 37 | + } |
| 38 | + $version = $manifest_item['version']; |
| 39 | + if (0 < floatval($version)) { |
| 40 | + echo "+ {$name} {$version}\n"; |
| 41 | + $manifest_item['type'] = 'plugin'; |
| 42 | + $manifest_item['id'] = $name; |
| 43 | + $manifest_item['file'] = "{$dir}-{$version}.tgz"; |
| 44 | + ksort($manifest_item); |
| 45 | + $manifest[$name] = $manifest_item; |
| 46 | + $tar_destination = "{$destPath}{$name}-{$version}.tar"; |
| 47 | + $tgz_destination = "{$destPath}{$name}-{$version}.tgz"; |
| 48 | + @unlink($tgz_destination); |
| 49 | + @unlink("{$tar_destination}.gz"); |
| 50 | + $tar = new PharData($tar_destination); |
| 51 | + $tar->buildFromDirectory('./plugins/', "@{$name}@"); |
| 52 | + $tar->compress(Phar::GZ); |
| 53 | + unlink($tar_destination); |
| 54 | + rename("{$tar_destination}.gz", $tgz_destination); |
| 55 | + } else { |
| 56 | + echo "- {$name} {$version}\n"; |
| 57 | + } |
39 | 58 | } |
40 | 59 | } |
41 | 60 |
|
|
0 commit comments