From b5b328abee7d294588e26c135ea678cc89eedb90 Mon Sep 17 00:00:00 2001 From: Richard Klees Date: Fri, 24 Nov 2023 16:48:13 +0100 Subject: [PATCH] Component: write bootstrap artifact --- .gitignore | 1 + cli/build_bootstrap.php | 90 +++++++++++++++++++ components/ILIAS/App/tests/RootFolderTest.php | 1 + composer.json | 1 + dependency_resolution.php | 16 ++++ .../development/component-rules.md | 4 +- 6 files changed, 112 insertions(+), 1 deletion(-) create mode 100755 cli/build_bootstrap.php create mode 100644 dependency_resolution.php rename components/ILIAS/README.md => docs/development/component-rules.md (98%) diff --git a/.gitignore b/.gitignore index 2185f905978e..7ab80d8b0172 100755 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ !/component/ILIAS # Generated Files +/artifacts /ilias.ini.php /ilias.log /db_template_writer.php diff --git a/cli/build_bootstrap.php b/cli/build_bootstrap.php new file mode 100755 index 000000000000..61797027920f --- /dev/null +++ b/cli/build_bootstrap.php @@ -0,0 +1,90 @@ +getFilename(), ".")) { + continue; + } + if (!$vendor->isDir()) { + echo " unexpected non-directory: {$vendor->getPathName()}\n"; + continue; + } + echo " Reading Components from Vendor \"{$vendor->getFilename()}\"...\n"; + $components = new \DirectoryIterator($vendor->getPathName()); + foreach ($components as $component) { + if (str_starts_with($component->getFilename(), ".")) { + continue; + } + if (!$vendor->isDir()) { + echo " unexpected non-directory: {$component->getPathName()}\n"; + continue; + } + if (!file_exists($component->getPathName() . "/Component.php")) { + echo " expected \"Component.php\" in {$component->getPathName()}\n"; + continue; + } + require_once($component->getPathName() . "/Component.php"); + $component_name = $vendor->getFilename() . "\\" . $component->getFileName(); + echo " Reading Component \"$component_name\"...\n"; + $component_info[] = $reader->read(new $component_name()); + } +} + +echo "Resolving Dependency using {$resolution_file}...\n"; +$disambiguation = require_once($resolution_file); + +$component_info = $resolver->resolveDependencies($disambiguation, ...$component_info); + +echo "Writing bootstrap to artifacts/bootstrap.php\n"; + +$bootstrap = $renderer->render(...$component_info); +if (!is_dir(__DIR__ . "/../artifacts")) { + mkdir(__DIR__ . "/../artifacts", 0755, true); +} +file_put_contents(__DIR__ . "/../artifacts/bootstrap.php", $bootstrap); diff --git a/components/ILIAS/App/tests/RootFolderTest.php b/components/ILIAS/App/tests/RootFolderTest.php index 6203a0b476ae..47838de04f11 100755 --- a/components/ILIAS/App/tests/RootFolderTest.php +++ b/components/ILIAS/App/tests/RootFolderTest.php @@ -44,6 +44,7 @@ final class RootFolderTest extends TestCase 'composer.json', 'composer_new.json', 'composer.lock', + 'dependency_resolution.php', 'ilias.ini.php', 'ilias_version.php', 'LICENSE', diff --git a/composer.json b/composer.json index 4fb3b5baf5b7..99d0494f45ea 100755 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ }, "scripts": { "post-autoload-dump": [ + "@php cli/build_bootstrap.php", "@php cli/setup.php build-artifacts --yes" ], "post-install-cmd": [ diff --git a/dependency_resolution.php b/dependency_resolution.php new file mode 100644 index 000000000000..ca6c70863cc2 --- /dev/null +++ b/dependency_resolution.php @@ -0,0 +1,16 @@ + [] +]; diff --git a/components/ILIAS/README.md b/docs/development/component-rules.md similarity index 98% rename from components/ILIAS/README.md rename to docs/development/component-rules.md index 1329a11a1b91..cf7fc6501103 100755 --- a/components/ILIAS/README.md +++ b/docs/development/component-rules.md @@ -1,3 +1,5 @@ +# TODO: This might be outdated but should definitely be put in another place. + # Components Services provide general functionalities used in the modules or in other services, @@ -70,4 +72,4 @@ This rules are to be understood according to [RFC2119](https://www.ietf.org/rfc/ 14. Libraries SHOULD NOT maintain an implicit internal state. All internal states SHOULD be made explicit. This means, e.g., that the usage of globals, static variables and the Singleton-pattern are prohibited. - \ No newline at end of file +