Skip to content

Commit

Permalink
Build improvements
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dpash committed Jun 10, 2024
1 parent f821b7b commit 136bd29
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ composer.lock

# OS X
**/.DS_Store

resources/models/raw
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
12 changes: 12 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand All @@ -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": {
Expand Down
2 changes: 0 additions & 2 deletions resources/models/raw/.gitignore

This file was deleted.

0 comments on commit 136bd29

Please sign in to comment.