Page MenuHomeDevCentral

D2547.diff
No OneTemporary

D2547.diff

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -37,10 +37,13 @@
# Build targets for monorepo maintenance
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-build-repo: $(GENERATED_FROM_TEMPLATES)
+build-repo: $(GENERATED_FROM_TEMPLATES) composer.json
clean-repo:
- ${RM} $(GENERATED_FROM_TEMPLATES)
+ ${RM} $(GENERATED_FROM_TEMPLATES) composer.json
$(GENERATED_FROM_TEMPLATES):
_utils/templates/resolve.py _templates/$@.in > $@
+
+composer.json:
+ _utils/templates/generate-compose-json.php > composer.json
diff --git a/_utils/templates/generate-compose-json.php b/_utils/templates/generate-compose-json.php
new file mode 100755
--- /dev/null
+++ b/_utils/templates/generate-compose-json.php
@@ -0,0 +1,95 @@
+#!/usr/bin/env php
+<?php
+
+# -------------------------------------------------------------
+# Generate composer.json from packages metadata
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Keruald
+# License: BSD-2-Clause
+# Dependencies: symfony/yaml, keruald/omnitools
+# -------------------------------------------------------------
+
+use Symfony\Component\Yaml\Parser as YamlParser;
+use Keruald\OmniTools\Collections\HashMap;
+
+require_once __DIR__ . "/../../vendor/autoload.php";
+
+# -------------------------------------------------------------
+# Helper methods to build elements from metadata
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+function getAutoload(array $packages_namespaces) : array {
+ return [
+ "psr-4" => HashMap::from($packages_namespaces)
+ ->flatMap(fn($package, $ns) => [
+ $ns . '\\' => $package . "/src/",
+ $ns . '\\Tests\\' => $package . "/tests/",
+ ])
+ ->toArray()
+ ];
+}
+
+function getReplace(array $packages) : array {
+ return HashMap::from($packages)
+ ->mapValuesAndKeys(fn($v) => ["keruald/$v", "self.version"])
+ ->toArray();
+}
+
+# -------------------------------------------------------------
+# Template
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+function run() : never {
+ $metadata = (new YamlParser())->parseFile("metadata.yml");
+ $flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
+
+ echo json_encode(getTemplate($metadata), $flags), "\n";
+
+ exit(0);
+}
+
+function getTemplate(array $metadata) : array {
+ return [
+ "name" => "keruald/keruald",
+ "type" => "library",
+ "description" => "Modular libraries to build frameworks and applications",
+ "keywords" => [
+ "framework",
+ "keruald",
+ ],
+ "license" => "BSD-2-Clause",
+ "homepage" => "https://keruald.nasqueron.org",
+ "authors" => [
+ [
+ "name" => "Sébastien Santoro",
+ "email" => "dereckson@espace-win.org",
+ ],
+ [
+ "name" => "Keruald contributors",
+ ],
+ ],
+ "require" => [
+ "ext-intl" => "*",
+ ],
+ "require-dev" => [
+ "ext-mbstring" => "*",
+ "ext-mysqli" => "*",
+ "ext-xmlwriter" => "*",
+ "nasqueron/codestyle" => "^0.0.1",
+ "phan/phan" => "^5.3.1",
+ "phpunit/phpunit" => "^9.5",
+ "symfony/yaml" => "^6.0.3",
+ "squizlabs/php_codesniffer" => "^3.6",
+ ],
+ "replace" => getReplace($metadata["packages"]),
+ "autoload" => getAutoload($metadata["packages_namespaces"]),
+ "scripts" => [
+ "lint-src" => "find */src -type f -name '*.php' | xargs -n1 php -l",
+ "lint-tests" => "find */tests -type f -name '*.php' | xargs -n1 php -l",
+ "test" => "vendor/bin/phpunit",
+ ],
+ "minimum-stability" => "dev",
+ ];
+}
+
+run();
diff --git a/composer.json b/composer.json
new file mode 100644
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,57 @@
+{
+ "name": "keruald/keruald",
+ "type": "library",
+ "description": "Modular libraries to build frameworks and applications",
+ "keywords": [
+ "framework",
+ "keruald"
+ ],
+ "license": "BSD-2-Clause",
+ "homepage": "https://keruald.nasqueron.org",
+ "authors": [
+ {
+ "name": "Sébastien Santoro",
+ "email": "dereckson@espace-win.org"
+ },
+ {
+ "name": "Keruald contributors"
+ }
+ ],
+ "require": {
+ "ext-intl": "*"
+ },
+ "require-dev": {
+ "ext-mbstring": "*",
+ "ext-mysqli": "*",
+ "ext-xmlwriter": "*",
+ "nasqueron/codestyle": "^0.0.1",
+ "phan/phan": "^5.3.1",
+ "phpunit/phpunit": "^9.5",
+ "symfony/yaml": "^6.0.3",
+ "squizlabs/php_codesniffer": "^3.6"
+ },
+ "replace": {
+ "keruald/commands": "self.version",
+ "keruald/database": "self.version",
+ "keruald/omnitools": "self.version",
+ "keruald/report": "self.version"
+ },
+ "autoload": {
+ "psr-4": {
+ "Keruald\\Commands\\": "commands/src/",
+ "Keruald\\Commands\\Tests\\": "commands/tests/",
+ "Keruald\\Database\\": "database/src/",
+ "Keruald\\Database\\Tests\\": "database/tests/",
+ "Keruald\\OmniTools\\": "omnitools/src/",
+ "Keruald\\OmniTools\\Tests\\": "omnitools/tests/",
+ "Keruald\\Reporting\\": "report/src/",
+ "Keruald\\Reporting\\Tests\\": "report/tests/"
+ }
+ },
+ "scripts": {
+ "lint-src": "find */src -type f -name '*.php' | xargs -n1 php -l",
+ "lint-tests": "find */tests -type f -name '*.php' | xargs -n1 php -l",
+ "test": "vendor/bin/phpunit"
+ },
+ "minimum-stability": "dev"
+}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 21:31 (22 h, 50 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2251023
Default Alt Text
D2547.diff (5 KB)

Event Timeline