From 136bd29a7d27d9c58a98307a6a972fd8a6956b18 Mon Sep 17 00:00:00 2001 From: David Pashley Date: Thu, 6 Jun 2024 10:41:57 +0200 Subject: [PATCH] Build improvements This adds a `build` and `clean` commands to `composer.json` to enable easier discovery of the build process for new developers. Due to the `clean` deleting the raw directory. I've moved the gitignore into the top level `.gitignore`. The available commands are added to the README.md Add single schema generation commands to README We need to explain about the need for `--` in composer commands --- .gitignore | 2 ++ README.md | 35 +++++++++++++++++++++++++++++++++ composer.json | 12 +++++++++++ resources/models/raw/.gitignore | 2 -- 4 files changed, 49 insertions(+), 2 deletions(-) delete mode 100644 resources/models/raw/.gitignore diff --git a/.gitignore b/.gitignore index 2372080cc..aee43d2fb 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ composer.lock # OS X **/.DS_Store + +resources/models/raw diff --git a/README.md b/README.md index 04aa915bc..2a2f225ab 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ This README is divided into several sections: * [Naming conventions](#naming-conventions) * [API versions](#api-versions) * [Working with DTOs](#working-with-dtos) +* [Contributing](#contributing) ## Getting Started @@ -532,3 +533,37 @@ $response = $ordersApi->confirmShipment( confirmShipmentRequest: $confirmShipmentRequest, ) ``` + +## Contributing + +To regenerate the library, you can run + + # composer clean + # composer build + +Composer has a number of pre-configured scripts in `composer.json`: + +* `build`: Run all the stages to regenerate the PHP files +* `clean`: Delete all the generated PHP and JSON files +* `lint`: Run PHP-CS-Fixer +* `schema:download`: Download the schemas from Amazon +* `schema:generate`: Generate the PHP files from the schemas +* `schema:refactor`: Make local modifications to the schemas before generation + +If you want to generate a specific schema, you can use the `--schema` option: + + # composer schema:generate -- --schema=orders + +You can also generate just the seller or vendor schemas: + + # composer schema:refactor -- --category=seller + # composer schema:generate -- --category=vendor + +You can also combine both options: + + # composer schema:download -- --schema=orders --category=seller + +The schema commands use the underlying `./bin/console` command. To get a list of +available commands, run: + + # php ./bin/console list \ No newline at end of file diff --git a/composer.json b/composer.json index 599577a75..72abee50f 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,10 @@ "require": { "php": ">=8.2", "ext-curl": "*", + "ext-dom": "*", "ext-json": "*", "ext-mbstring": "*", + "ext-simplexml": "*", "guzzlehttp/guzzle": "^6.0|^7.0", "saloonphp/saloon": "^3.4", "openspout/openspout": "^4.23", @@ -55,6 +57,13 @@ } }, "scripts": { + "build": [ + "@schema:download", + "@schema:refactor", + "@schema:generate", + "@lint" + ], + "clean": "rm -rf src/Vendor src/Seller resources/models/seller resources/models/vendor resources/models/raw", "lint": [ "@pint", "@php-compatibility-check" @@ -63,6 +72,9 @@ "php-compatibility-check": "./vendor/bin/phpcs -p ./src ./bin --standard=PHPCompatibility --runtime-set testVersion 8.2-", "post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility", "post-update-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility", + "schema:download": "@php bin/console schema:download", + "schema:generate": "@php bin/console schema:generate", + "schema:refactor": "@php bin/console schema:refactor", "test": "vendor/bin/phpunit" }, "config": { diff --git a/resources/models/raw/.gitignore b/resources/models/raw/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/resources/models/raw/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore