|
1 | | -## Usage |
| 1 | +# Basic Usage |
2 | 2 |
|
3 | | -### Create *patchset* composer package |
| 3 | +There are two ways to specify and store patches, you can use any of them or both. |
4 | 4 |
|
5 | | -### Define patches in your root package |
| 5 | +## Create *patchset* composer package |
6 | 6 |
|
7 | | -### Applying patches to root package (root project folder) |
| 7 | +_Use this way to easily distribute your patchset and use it in multiple projects_ |
| 8 | + |
| 9 | + 1. Create a new composer package and change the package type in `composer.json` to `patchset` |
| 10 | + so it looks like this: |
| 11 | + |
| 12 | + ```json |
| 13 | + { |
| 14 | + "name": "your-vendor/your-patchset-name", |
| 15 | + "type": "patchset", |
| 16 | + "version": "1.0", |
| 17 | + "require": { |
| 18 | + "creativestyle/composer-plugin-patchset": "^1.0" |
| 19 | + } |
| 20 | + } |
| 21 | + ``` |
| 22 | + |
| 23 | + 2. Place your diff patch files in any directories inside the package you want |
| 24 | + 3. Define the patches in `composer.json` like this: |
| 25 | + |
| 26 | + ```json |
| 27 | + { |
| 28 | + "name": "your-vendor/your-patchset-name", |
| 29 | + "type": "patchset", |
| 30 | + "version": "1.0", |
| 31 | + "require": { |
| 32 | + "creativestyle/composer-plugin-patchset": "^1.0" |
| 33 | + }, |
| 34 | + "extra": { |
| 35 | + "patchset": { |
| 36 | + "some-vendor-a/package-to-patch": [ |
| 37 | + { |
| 38 | + "description": "Short patch description that is mandatory", |
| 39 | + "filename": "path/to/the-patch-file-relative-to-patchset-root.diff" |
| 40 | + }, |
| 41 | + { |
| 42 | + "description": "Patches with no version specified will be always applied", |
| 43 | + "filename": "second-patch-for-the-same-package.diff" |
| 44 | + } |
| 45 | + ], |
| 46 | + "some-vendor-b/package-to-patch": [ |
| 47 | + { |
| 48 | + "description": "Patch some other package", |
| 49 | + "filename": "patches/your-other-package-patch.diff", |
| 50 | + } |
| 51 | + ] |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + ``` |
| 56 | + |
| 57 | +## Define patches in your root package |
| 58 | + |
| 59 | +# Composer json configuration reference |
| 60 | + |
| 61 | +## Patch properties |
| 62 | + |
| 63 | +### `description` (string, mandatory) |
| 64 | + |
| 65 | +Short description (or name) of your patch. Keep it short as it will be displayed during patching. |
| 66 | + |
| 67 | +### `filename` (string, mandatory) |
| 68 | + |
| 69 | +Path to your diff file relative to the root of your patchset. Patches can be stored anywhere within |
| 70 | +the package. |
| 71 | + |
| 72 | +### `version-constraint` (string, default: `"*"`) |
| 73 | + |
| 74 | +A composer semver version constraint. If specified then the patch application will be attempted |
| 75 | +only if the target package's version matches the constraint. |
| 76 | + |
| 77 | +See [composer documenation](https://getcomposer.org/doc/articles/versions.md) for exact syntax reference. |
| 78 | + |
| 79 | +### `strip-path-components` (integer, default: `1`) |
| 80 | + |
| 81 | +How many leading path components to strip from filenames in diff when applying the patch. |
| 82 | + |
| 83 | +This has the same effect as the `-p{x}` switch of the patch command, where `{x}` is the value of this parameter. |
| 84 | + |
| 85 | +For 99% of the patches this will be the default `1`. Set this only if your patch was generated in some non-standard way. |
| 86 | + |
| 87 | +# Notable use-cases |
| 88 | + |
| 89 | +## Applying patches to root package (root project folder) |
8 | 90 |
|
9 | 91 | Define patches as you normally would. If your root package is not named the you should use special |
10 | 92 | `__root__` as package name. |
11 | 93 |
|
12 | | -**CAUTION** Since root package cannot be reinstalled once patches are applied they cannot be removed! |
| 94 | +**CAUTION!** Since root package cannot be reinstalled once patches are applied they cannot be removed! |
13 | 95 | This means that if you want to remove patches applied to root package you should reinstall the whole |
14 | 96 | project manually. The plugin will warn you when this is the case but will not fail. It will try |
15 | 97 | to apply any new root package patches though. |
16 | 98 |
|
17 | 99 | __New patches will be applied to the root package but then _application order_ is not guaranteed.__ |
18 | | - |
19 | | -### Options |
20 | | - |
21 | | -#### Strip defined number of components when applying patch (`-pX`) |
|
0 commit comments