Skip to content

Commit c0a16a3

Browse files
committed
[#2096] Updated to use cweagans/composer-patches v2.
1 parent a34110d commit c0a16a3

29 files changed

Lines changed: 940 additions & 157 deletions

File tree

.vortex/CLAUDE.md

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,33 @@ The installer uses a **baseline + diff** system for managing test fixtures:
330330

331331
### Updating Fixtures
332332

333-
**Critical**: Use the proper fixture update mechanism:
333+
**CRITICAL - Use the Unified Ahoy Command**:
334+
335+
The correct way to update fixtures is to use the unified `ahoy update-fixtures` command from the `.vortex` directory:
334336

335337
```bash
336-
cd .vortex/installer
338+
cd .vortex
337339

338-
# Update all fixtures
339-
UPDATE_FIXTURES=1 composer test
340+
# This is the CORRECT way to update all fixtures
341+
ahoy update-fixtures
342+
```
343+
344+
**What this command does**:
345+
346+
- Updates template test fixtures in `tests/` directory
347+
- Updates installer test fixtures in `installer/` directory
348+
- Handles baseline fixtures first
349+
- Updates all scenario-specific fixtures
350+
- Runs tests twice to properly handle fixture updates (first run may fail, second should pass)
351+
352+
**DO NOT manually run `UPDATE_FIXTURES=1` commands** - the `ahoy update-fixtures` command handles everything automatically.
353+
354+
### Alternative: Manual Fixture Updates (Advanced)
355+
356+
For specific fixture updates or debugging, you can use manual commands:
357+
358+
```bash
359+
cd .vortex/installer
340360

341361
# Update specific test fixtures
342362
UPDATE_FIXTURES=1 ./vendor/bin/phpunit --filter "testInstall.*baseline"
@@ -352,9 +372,10 @@ UPDATE_FIXTURES=1 ./vendor/bin/phpunit --filter 'testInstall.*"services.*no.*cla
352372

353373
### Fixture Update Process
354374

355-
1. **Baseline First**: Update baseline fixtures first
356-
2. **Scenario Diffs**: Run individual scenario tests to update their diffs
357-
3. **Validation**: Verify tests pass without UPDATE_FIXTURES flag
375+
1. **Use ahoy update-fixtures**: This is the standard and recommended approach
376+
2. **Alternative - Baseline First**: Update baseline fixtures manually if needed
377+
3. **Alternative - Scenario Diffs**: Run individual scenario tests to update specific diffs
378+
4. **Validation**: Verify tests pass without UPDATE_FIXTURES flag
358379

359380
## Script Output Formatters
360381

@@ -397,7 +418,7 @@ info "Finished executing example operations in non-production environment."
397418

398419
1. **Update Main Script**: Modify the script in the template (outside .vortex/)
399420
2. **Update BATS Tests**: Update test assertions in `.vortex/tests/bats/`
400-
3. **Update Installer Fixtures**: Use `UPDATE_FIXTURES=1` process
421+
3. **Update Installer Fixtures**: Run `ahoy update-fixtures` from `.vortex/` directory
401422

402423
### Provision Script BATS Test Logic
403424

@@ -712,12 +733,13 @@ Each system:
712733
713734
### 2. Installer System (.vortex/installer/)
714735
715-
**Fixture Updates Can Be Finicky**:
736+
**Fixture Updates**:
716737
717-
- The `UPDATE_FIXTURES=1` mechanism can have defects
718-
- Try updating baseline first, then individual scenarios
719-
- Use filtered test runs for specific scenarios
738+
- **Use `ahoy update-fixtures`** from `.vortex/` directory - this is the standard approach
739+
- The unified command updates all fixtures automatically
740+
- Runs tests twice to handle fixture updates properly (first run may fail, second should pass)
720741
- Be patient - full test suite can take several minutes
742+
- For debugging specific scenarios, manual `UPDATE_FIXTURES=1` commands can be used
721743
722744
**Handler Development**:
723745
@@ -771,10 +793,13 @@ yarn test --updateSnapshot # Update component snapshots
771793
**Fixture Update Issues**:
772794
773795
```bash
774-
# Try baseline first
775-
UPDATE_FIXTURES=1 ./vendor/bin/phpunit --filter "testInstall.*baseline"
796+
# RECOMMENDED: Use the unified command
797+
cd .vortex
798+
ahoy update-fixtures
776799
777-
# Then individual scenarios
800+
# ALTERNATIVE: Manual updates for specific scenarios
801+
cd .vortex/installer
802+
UPDATE_FIXTURES=1 ./vendor/bin/phpunit --filter "testInstall.*baseline"
778803
UPDATE_FIXTURES=1 ./vendor/bin/phpunit --filter 'testInstall.*"scenario_name"'
779804
780805
# Check for test timeouts - increase if needed
@@ -1209,7 +1234,9 @@ $this->cmd('ahoy export-db', '! Containers are not running.', arg: $args);
12091234
**Installer System** (`.vortex/installer/`):
12101235
12111236
- **CRITICAL**: NEVER directly modify files under `.vortex/installer/tests/Fixtures/`
1212-
- These are test fixtures that must be updated via `UPDATE_FIXTURES=1` mechanism
1237+
- These are test fixtures that must be updated via `ahoy update-fixtures` command from `.vortex/` directory
1238+
- The unified `ahoy update-fixtures` command handles all fixture updates automatically
1239+
- For debugging, manual `UPDATE_FIXTURES=1` commands can be used from `.vortex/installer/`
12131240
- Always test with baseline scenario first, then individual scenarios
12141241
- Preserve handler execution order and batching patterns
12151242

.vortex/docs/content/drupal/composer.mdx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,10 @@ The [`repositories`](https://getcomposer.org/doc/04-schema.md#repositories)
7979
section defines custom package repositories, essential for accessing packages
8080
outside the default Packagist repository.
8181

82-
See [Working with packages](../workflows/development#working-with-composer-packages) for more information on
83-
how to provide custom and override existing packages in your project.
84-
8582
- [`drupal`](https://www.drupal.org/docs/develop/using-composer/using-packagesdrupalorg):
8683
Serves as the official source for Drupal modules, themes, and distributions.
8784
It's crucial for a Drupal project using Composer, as it allows access to
8885
Drupal-specific packages not available on Packagist.
89-
- [`asset-packagist`](https://asset-packagist.org/): Enables the installation of
90-
Bower and NodeJs packages via Composer. This is especially important for Drupal
91-
projects needing front-end libraries and tools, bridging the gap between
92-
Composer's PHP-centric ecosystem and the broader world of front-end package
93-
management.
9486

9587
### `require`
9688

@@ -104,9 +96,11 @@ specifies the essential packages and libraries your project needs.
10496
install packages to the correct location based on the specified package type
10597
such as `drupal-module`, `drupal-theme`, `drupal-profile`, etc.
10698
- [`cweagans/composer-patches`](https://github.com/cweagans/composer-patches):
107-
Allows applying patches to Composer packages, useful for incorporating fixes
108-
not yet in official releases.
109-
See [Working with packages](../workflows/development#patching) for more
99+
Enables git-based patching of Composer packages, useful for incorporating fixes
100+
not yet in official releases. Version 2.x uses `git apply` for cross-platform
101+
consistency and generates a `patches.lock.json` file to ensure reproducible
102+
builds with SHA-256 checksums.
103+
See [Patching](../workflows/development#patching) for more
110104
information on how to work with patches.
111105
- `drupal/admin_toolbar`, `drupal/clamav`, `drupal/coffee`, etc. - Drupal
112106
modules that provide various site administration and development helping
@@ -266,9 +260,11 @@ a source of custom configuration for various packages. These packages read
266260
settings from this section to tailor their behavior according to the specific
267261
needs and structure of your Drupal project.
268262

269-
- [`composer-exit-on-patch-failure`](https://github.com/cweagans/composer-patches):
270-
This setting, when enabled, causes Composer to exit if a patch from
271-
the `cweagans/composer-patches` plugin fails to apply.
263+
- **patches.lock.json**: Automatically generated by `cweagans/composer-patches`
264+
v2.x. This file contains patch metadata and SHA-256 checksums, and must be
265+
committed to version control (like `composer.lock`). It ensures reproducible
266+
builds across teams and CI/CD environments by verifying patch integrity and
267+
making the patch state explicit and trackable.
272268
- [`drupal-scaffold`](https://www.drupal.org/docs/develop/using-composer/using-drupals-composer-scaffold):
273269
This setting controls which files should be scaffolded:
274270
- `locations`: Specifies the location of the web root (the directory

.vortex/docs/content/workflows/development.mdx

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,93 @@ To override package installation paths, modify `composer.json`:
217217

218218
### Patching
219219

220-
If you need to apply patches to included dependencies, use the `composer-patches` plugin. Add the patch definition in `composer.json` under the `extra.patches` section:
220+
Vortex uses [`cweagans/composer-patches`](https://github.com/cweagans/composer-patches) v2.x for applying patches to Composer dependencies. Version 2.x uses git-based patching with `git apply` for better cross-platform consistency.
221221

222-
```json
223-
"extra": {
224-
"patches": {
225-
"drupal/foobar": {
226-
"Patch description": "URL or local path to patch"
222+
:::tip
223+
224+
For official documentation, visit: [Composer Patches Recommended Workflows](https://docs.cweagans.net/composer-patches/usage/recommended-workflows/)
225+
226+
:::
227+
228+
#### Understanding `patches.lock.json`
229+
230+
Composer Patches v2.x automatically generates a `patches.lock.json` file that contains:
231+
232+
- Patch metadata (URLs, descriptions, target packages)
233+
- SHA-256 checksums for patch verification
234+
235+
**This file must be committed to version control** (like `composer.lock`).
236+
237+
**Benefits:**
238+
239+
- Ensures reproducible builds across teams and CI/CD environments
240+
- Verifies patch integrity with checksums
241+
- Prevents "works on my machine" issues with patches
242+
- Makes the patch state explicit and trackable
243+
244+
#### Adding a New Patch
245+
246+
1. Define the patch in `composer.json` under `extra.patches`:
247+
248+
```json
249+
"extra": {
250+
"patches": {
251+
"drupal/foobar": {
252+
"Fix for issue #123": "https://www.drupal.org/files/issues/fix-123.patch"
253+
}
227254
}
228255
}
229-
}
230-
```
256+
```
257+
258+
2. Regenerate `patches.lock.json`:
259+
260+
```bash
261+
composer patches-relock
262+
```
263+
264+
3. Remove and reinstall patched packages:
265+
266+
```bash
267+
composer patches-repatch
268+
```
269+
270+
:::warning
271+
`composer patches-repatch` removes patched dependencies from `vendor/` and reinstalls them. Ensure you have no unsaved changes in those directories.
272+
:::
273+
274+
4. Update `composer.lock`:
275+
276+
```bash
277+
composer update --lock
278+
```
279+
280+
#### Removing a Patch
281+
282+
1. Delete the patch definition from `composer.json`
283+
284+
2. Regenerate `patches.lock.json`:
285+
286+
```bash
287+
composer patches-relock
288+
```
289+
290+
3. Manually delete the affected dependency:
291+
292+
```bash
293+
rm -rf vendor/drupal/foobar
294+
```
295+
296+
4. Reinstall without the patch:
297+
298+
```bash
299+
composer patches-repatch
300+
```
301+
302+
5. Update `composer.lock`:
231303

232-
Run `composer update drupal/foobar` after adding patches to apply them.
304+
```bash
305+
composer update --lock
306+
```
233307

234308
## Resetting the codebase
235309

.vortex/docs/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"ddev",
2929
"dealerdirect",
3030
"drevops",
31+
"drupalcode",
3132
"drush",
3233
"ergebnis",
3334
"gherkinlint",

.vortex/installer/composer.json

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@
1818
},
1919
"require": {
2020
"php": ">=8.3",
21-
"alexskrypnyk/file": "^0.13",
21+
"alexskrypnyk/file": "^0.13.1",
2222
"alexskrypnyk/str2name": "^1.4",
23-
"composer/composer": "^2.8",
24-
"cweagans/composer-patches": "^1.7",
25-
"czproject/git-php": "^4.3",
26-
"laravel/prompts": "^0.3.7",
27-
"nikic/iter": "^2.4",
28-
"sebastian/diff": "*",
29-
"symfony/console": "^7.3",
30-
"symfony/filesystem": "^7.2",
31-
"symfony/yaml": "^7.2"
23+
"composer/composer": "^2.8.12",
24+
"cweagans/composer-patches": "^2",
25+
"czproject/git-php": "^4.5",
26+
"laravel/prompts": "^0.3.8",
27+
"nikic/iter": "^2.4.1",
28+
"sebastian/diff": "^7.0",
29+
"symfony/console": "^7.3.6",
30+
"symfony/filesystem": "^7.3.6",
31+
"symfony/yaml": "^7.3.5"
3232
},
3333
"require-dev": {
3434
"alexskrypnyk/phpunit-helpers": "^0.13",
35-
"bamarni/composer-bin-plugin": "^1.8",
36-
"dealerdirect/phpcodesniffer-composer-installer": "^1",
35+
"bamarni/composer-bin-plugin": "^1.8.2",
36+
"dealerdirect/phpcodesniffer-composer-installer": "^1.1.2",
3737
"drevops/phpcs-standard": "^0.2",
38-
"drupal/coder": "^8.3",
39-
"ergebnis/composer-normalize": "^2.45",
40-
"laravel/serializable-closure": "^2.0",
41-
"mockery/mockery": "^1.6",
42-
"phpstan/phpstan": "^2",
43-
"phpunit/phpunit": "^12",
44-
"rector/rector": "^2",
45-
"symfony/finder": "^7.2"
38+
"drupal/coder": "^8.3.31",
39+
"ergebnis/composer-normalize": "^2.48.2",
40+
"laravel/serializable-closure": "^2.0.6",
41+
"mockery/mockery": "^1.6.12",
42+
"phpstan/phpstan": "^2.1.31",
43+
"phpunit/phpunit": "^12.4.2",
44+
"rector/rector": "^2.2.7",
45+
"symfony/finder": "^7.3.5"
4646
},
4747
"repositories": [
4848
{
@@ -77,9 +77,6 @@
7777
},
7878
"sort-packages": true
7979
},
80-
"extra": {
81-
"composer-exit-on-patch-failure": true
82-
},
8380
"scripts": {
8481
"build": [
8582
"@composer bin box require --dev humbug/box",

0 commit comments

Comments
 (0)