diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 89cbd7fc..b1ba0e99 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -4,7 +4,7 @@ ->in(__DIR__ . DIRECTORY_SEPARATOR . 'tests') ->in(__DIR__ . DIRECTORY_SEPARATOR . 'src') ->exclude(__DIR__ . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'Template') - ->append(['.php-cs-fixer.php', 'monorepo-builder.php', 'rector.php', './bin/split-repo.php']); + ->append(['.php-cs-fixer.php', 'rector.php', 'split-repo.php', './bin/split-repo.php']); $rules = [ '@Symfony' => true, diff --git a/bin/split-repo.php b/bin/split-repo.php index e88e7ab8..27fa77bb 100644 --- a/bin/split-repo.php +++ b/bin/split-repo.php @@ -33,6 +33,17 @@ public function validate(): int $progressbar->maks = count($paths); foreach ($paths as $path) { + $validate_assets = $this->validateAssetsFile(dirname(__DIR__), $path); + if (false === empty($validate_assets)) { + foreach ($validate_assets as $error) { + $progressbar->complete = static fn (): string => (string) fail($error); + $progressbar->current = $progressbar->maks + 1; + $progressbar->tick(); + + return 1; + } + } + if (false === $this->validateComposerVersion($composer_path = dirname(__DIR__) . $path . 'composer.json', $packages, $version)) { $progressbar->complete = static fn (): string => (string) fail('failed!'); $progressbar->current = $progressbar->maks + 1; @@ -89,6 +100,25 @@ private function validateComposerVersion(string $path, array $packages, string $ return true; } + /** + * Validate static asset file must include in split repo. + * + * @return string[] + */ + private function validateAssetsFile(string $base, string $path): array + { + $errors = []; + if (false === file_exists("{$base}{$path}LICENSE")) { + $errors[] = "license not found in {$path}."; + } + + if (false === file_exists("{$base}{$path}.github/workflows/close-pull-request.yml")) { + $errors[] = "close pr github workflow not found in {$path}."; + } + + return $errors; + } + /** * Load split configuration. * diff --git a/phpstan.neon b/phpstan.neon index a2d4a82c..ef63d0ca 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,7 @@ parameters: level: 6 paths: + - bin - src reportUnmatchedIgnoredErrors: true diff --git a/rector.php b/rector.php index e7011fe8..fea79dc0 100644 --- a/rector.php +++ b/rector.php @@ -13,6 +13,7 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->paths([ + __DIR__ . '/bin', __DIR__ . '/src', ]); diff --git a/split-repo.php b/split-repo.php index c917ecbd..ad1087f3 100644 --- a/split-repo.php +++ b/split-repo.php @@ -3,23 +3,23 @@ declare(strict_types=1); return [ - 'tag_version' => "0.35.6", + 'tag_version' => '0.35.6', 'split_repositorys' => [ - 'sonypradana/cache' => '/src/System/Cache/', + 'sonypradana/cache' => '/src/System/Cache/', 'sonypradana/collection' => '/src/System/Collection/', - 'sonypradana/console' => '/src/System/Console/', - 'sonypradana/container' => '/src/System/Container/', - 'sonypradana/cron' => '/src/System/Cron/', - 'sonypradana/database' => '/src/System/Database/', - 'sonypradana/file' => '/src/System/File/', - 'sonypradana/http' => '/src/System/Http/', - 'sonypradana/macroable' => '/src/System/Macroable/', - 'sonypradana/router' => '/src/System/Router/', - 'sonypradana/security' => '/src/System/Security/', - 'sonypradana/support' => '/src/System/Support/', - 'sonypradana/template' => '/src/System/Template/', - 'sonypradana/text' => '/src/System/Text/', - 'sonypradana/time' => '/src/System/Time/', - 'sonypradana/view' => '/src/System/View/', + 'sonypradana/console' => '/src/System/Console/', + 'sonypradana/container' => '/src/System/Container/', + 'sonypradana/cron' => '/src/System/Cron/', + 'sonypradana/database' => '/src/System/Database/', + 'sonypradana/file' => '/src/System/File/', + 'sonypradana/http' => '/src/System/Http/', + 'sonypradana/macroable' => '/src/System/Macroable/', + 'sonypradana/router' => '/src/System/Router/', + 'sonypradana/security' => '/src/System/Security/', + 'sonypradana/support' => '/src/System/Support/', + 'sonypradana/template' => '/src/System/Template/', + 'sonypradana/text' => '/src/System/Text/', + 'sonypradana/time' => '/src/System/Time/', + 'sonypradana/view' => '/src/System/View/', ], ]; diff --git a/src/System/Cache/.github/workflows/close-pull-request.yml b/src/System/Cache/.github/workflows/close-pull-request.yml new file mode 100644 index 00000000..083fc817 --- /dev/null +++ b/src/System/Cache/.github/workflows/close-pull-request.yml @@ -0,0 +1,13 @@ +name: Close Pull Request + +on: + pull_request_target: + types: [opened] + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: superbrothers/close-pull-request@v3 + with: + comment: "Thank you for your pull request. However, this repository is a read-only sub-split. Please submit your PR to https://github.com/sonypradana/php-library instead. Thanks!" diff --git a/src/System/Cache/LICENSE b/src/System/Cache/LICENSE new file mode 100644 index 00000000..afe73539 --- /dev/null +++ b/src/System/Cache/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 Angger Pradana + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.