|
4 | 4 | declare(strict_types=1); |
5 | 5 |
|
6 | 6 | $dirName = basename(dirname(__DIR__)); |
| 7 | +$isSyliusOfficial = getenv('SYLIUS') === '1'; |
7 | 8 |
|
8 | | -if (!preg_match('/^[A-Z][a-zA-Z0-9]*Plugin$/', $dirName)) { |
9 | | - fwrite(STDERR, "\n"); |
10 | | - fwrite(STDERR, " \033[41;37m ERROR \033[0m Directory name must end with 'Plugin' suffix\n"); |
11 | | - fwrite(STDERR, "\n"); |
12 | | - fwrite(STDERR, " Current: {$dirName}\n"); |
13 | | - fwrite(STDERR, " Expected: {$dirName}Plugin (or similar PascalCase name ending with Plugin)\n"); |
14 | | - fwrite(STDERR, "\n"); |
15 | | - fwrite(STDERR, " Example:\n"); |
16 | | - fwrite(STDERR, " composer create-project sylius/plugin-skeleton WishlistPlugin\n"); |
17 | | - fwrite(STDERR, "\n"); |
| 9 | +if ($isSyliusOfficial) { |
| 10 | + if (!preg_match('/^[A-Z][a-zA-Z0-9]*Plugin$/', $dirName) || str_starts_with($dirName, 'Sylius')) { |
| 11 | + fwrite(STDERR, "\n"); |
| 12 | + fwrite(STDERR, " \033[41;37m ERROR \033[0m Official Sylius plugin directory should not have 'Sylius' prefix\n"); |
| 13 | + fwrite(STDERR, "\n"); |
| 14 | + fwrite(STDERR, " Current: {$dirName}\n"); |
| 15 | + fwrite(STDERR, " Expected: MailerLitePlugin, InvoicingPlugin, etc.\n"); |
| 16 | + fwrite(STDERR, "\n"); |
| 17 | + fwrite(STDERR, " Example:\n"); |
| 18 | + fwrite(STDERR, " SYLIUS=1 composer create-project sylius/plugin-skeleton MailerLitePlugin\n"); |
| 19 | + fwrite(STDERR, "\n"); |
18 | 20 |
|
19 | | - exit(1); |
| 21 | + exit(1); |
| 22 | + } |
| 23 | +} else { |
| 24 | + if (!preg_match('/^Sylius[A-Z][a-zA-Z0-9]*Plugin$/', $dirName)) { |
| 25 | + fwrite(STDERR, "\n"); |
| 26 | + fwrite(STDERR, " \033[41;37m ERROR \033[0m Community plugin directory must start with 'Sylius' prefix\n"); |
| 27 | + fwrite(STDERR, "\n"); |
| 28 | + fwrite(STDERR, " Current: {$dirName}\n"); |
| 29 | + fwrite(STDERR, " Expected: Sylius{$dirName}\n"); |
| 30 | + fwrite(STDERR, "\n"); |
| 31 | + fwrite(STDERR, " Example:\n"); |
| 32 | + fwrite(STDERR, " composer create-project sylius/plugin-skeleton SyliusWishlistPlugin\n"); |
| 33 | + fwrite(STDERR, "\n"); |
| 34 | + |
| 35 | + exit(1); |
| 36 | + } |
20 | 37 | } |
21 | 38 |
|
22 | 39 | unlink(__FILE__); |
0 commit comments