Skip to content

Commit 50012a6

Browse files
committed
Added contrib patching section to AI instructions.
1 parent 83472de commit 50012a6

15 files changed

Lines changed: 2203 additions & 6 deletions

File tree

.vortex/.ahoy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ commands:
5959
lint-markdown:
6060
cmd: ./tests/lint.markdown.sh
6161

62+
lint-markdown-fix:
63+
cmd: ./tests/lint.markdown.sh --fix
64+
6265
lint-docs:
6366
cmd: yarn --cwd=docs run lint
6467

.vortex/CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ cd .vortex/docs
237237
yarn install
238238

239239
# Development workflow
240-
yarn start # Start dev server
240+
yarn start # Start dev server
241241
yarn build # Build documentation
242242

243243
# Testing workflow
@@ -454,7 +454,7 @@ When script output changes, update corresponding test files:
454454
**Important**: Each system has independent dependencies and must be set up separately:
455455

456456
1. **Documentation** (`.vortex/docs/`): Requires Node.js/Yarn
457-
2. **Installer** (`.vortex/installer/`): Requires PHP/Composer
457+
2. **Installer** (`.vortex/installer/`): Requires PHP/Composer
458458
3. **Template** (`.vortex/tests/`): Requires PHP/Composer + Node.js + BATS
459459

460460
**Full Setup** (from `.vortex/`):
@@ -757,7 +757,7 @@ Each system:
757757
# Build failures
758758
yarn build --verbose # Check for detailed build errors
759759
760-
# Spellcheck failures
760+
# Spellcheck failures
761761
yarn spellcheck # Review American English violations
762762
npx cspell "content/**/*.md" # Check specific files
763763
@@ -983,7 +983,7 @@ $this->cmd('ahoy info', ['Docker', 'Compose']); // Both must be found in output
983983
// ✅ CORRECT - all strings have prefixes
984984
$this->cmd('ahoy info', [
985985
'* Xdebug', // Must contain "Xdebug"
986-
'* Disabled', // Must contain "Disabled"
986+
'* Disabled', // Must contain "Disabled"
987987
'! Enabled' // Must NOT contain "Enabled"
988988
]);
989989

.vortex/installer/tests/Fixtures/install/ai_instructions_claude/CLAUDE.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,188 @@ ahoy composer require --dev drupal/devel
347347
ahoy drush pm:install admin_toolbar pathauto
348348
```
349349

350+
### Patching Contributed Modules
351+
352+
When contributed modules need fixes or customizations, use the proper patching workflow with `cweagans/composer-patches`.
353+
354+
#### Prerequisites for Patching
355+
356+
- Project uses `cweagans/composer-patches` package
357+
- Git is available for version control
358+
- Access to Drupal.org git repositories
359+
360+
#### Patch Storage and Configuration
361+
362+
Patches are defined in `composer.json` under the `extra.patches` section:
363+
364+
```json
365+
{
366+
"extra": {
367+
"patches": {
368+
"drupal/module_name": {
369+
"Description of fix": "patches/module-name-description.patch",
370+
"Another fix": "https://www.drupal.org/files/issues/external-patch.patch"
371+
}
372+
}
373+
}
374+
}
375+
```
376+
377+
- **Local patches**: Store in `patches/` directory in project root
378+
- **External patches**: Reference URLs directly in composer.json
379+
- **Naming convention**: Use descriptive names like `module-name-description.patch`
380+
381+
#### Creating Module Patches
382+
383+
Step 1: Identify Module Version
384+
385+
Always work with the exact version and state used in your project:
386+
387+
```bash
388+
# Check installed version
389+
ahoy composer show drupal/module_name
390+
391+
# Verify version in composer.lock
392+
grep -A 20 "drupal/module_name" composer.lock
393+
```
394+
395+
Step 2: Clone Module from Git
396+
397+
**CRITICAL**: Always use the official Drupal git repository, not tarball downloads:
398+
399+
```bash
400+
# Create working directory
401+
cd /tmp && mkdir module_patch_work && cd module_patch_work
402+
403+
# Clone the module
404+
git clone https://git.drupalcode.org/project/module_name.git
405+
406+
# Navigate to module directory
407+
cd module_name
408+
409+
# Checkout the exact version/tag used in project
410+
git checkout 1.2.3 # Replace with actual version
411+
412+
# Create working branch
413+
git checkout -b fix-description
414+
```
415+
416+
Step 3: Apply Existing Patches
417+
418+
If your project already has patches for this module, apply them first to match the current state:
419+
420+
```bash
421+
# Apply each existing patch in order
422+
curl -s https://example.com/patch1.patch | patch -p1
423+
curl -s https://example.com/patch2.patch | patch -p1
424+
425+
# Commit the patches to establish baseline
426+
git add .
427+
git commit -m "Apply existing patches to match project state"
428+
```
429+
430+
Step 4: Make Required Changes
431+
432+
Edit the necessary files to implement your fix:
433+
434+
```bash
435+
# Make your changes using your preferred editor
436+
vim path/to/file.php
437+
438+
# Or use automated tools if applicable
439+
sed -i 's/old_code/new_code/' path/to/file.php
440+
```
441+
442+
Step 5: Generate Clean Patch
443+
444+
Create a proper git-based patch:
445+
446+
```bash
447+
# Stage your changes
448+
git add .
449+
450+
# Generate patch from staged changes
451+
git diff --cached > /path/to/project/patches/module-name-fix-description.patch
452+
```
453+
454+
Step 6: Test Patch Application
455+
456+
**ALWAYS test that your patch applies cleanly**:
457+
458+
```bash
459+
# Reset to test patch application
460+
git reset --hard HEAD
461+
462+
# Test patch applies without conflicts
463+
git apply /path/to/project/patches/module-name-fix-description.patch
464+
465+
# Verify changes were applied correctly
466+
git status
467+
git diff
468+
```
469+
470+
Step 7: Integrate into Project
471+
472+
Add the patch to your project's composer configuration and test:
473+
474+
```bash
475+
# Update the specific module to apply patch
476+
ahoy composer require drupal/module_name
477+
478+
# Verify no patch application errors
479+
# Check that functionality works as expected
480+
```
481+
482+
Step 8: Clean Up
483+
484+
Remove temporary working directory:
485+
486+
```bash
487+
rm -rf /tmp/module_patch_work
488+
```
489+
490+
#### Patching Best Practices
491+
492+
**✅ Do This:**
493+
494+
- Use descriptive patch names that explain what they fix
495+
- Keep patches focused - one fix per patch when possible
496+
- Follow Drupal coding standards in your changes
497+
- Test locally before committing patches
498+
- Document the issue being fixed in composer.json description
499+
- Include issue URLs when available from drupal.org
500+
501+
**❌ Avoid These Mistakes:**
502+
503+
- Working with tarball downloads instead of git repositories
504+
- Creating patches from modified project files
505+
- Skipping patch application testing
506+
- Creating patches without applying existing patches first
507+
- Assuming patches work across different module versions
508+
509+
#### Troubleshooting Patch Issues
510+
511+
**Patch Won't Apply:**
512+
513+
1. Check module version matches between patch creation and application
514+
2. Verify existing patches are applied in correct order
515+
3. Check for whitespace issues in patch file
516+
4. Ensure patch paths are correct (usually relative to module root)
517+
518+
**Patch Conflicts:**
519+
520+
1. Identify conflicting patches by applying them individually
521+
2. Update patch order in composer.json if needed
522+
3. Recreate patches against the current patched state
523+
4. Merge patches if they modify the same areas
524+
525+
**Performance Issues:**
526+
527+
1. Minimize external patch URLs to reduce download time
528+
2. Store frequently used patches locally in patches directory
529+
3. Keep patch files small and focused
530+
4. Remove obsolete patches when updating modules
531+
350532
### Adding JavaScript/CSS Libraries
351533

352534
For npm packages that need to be Drupal libraries, define them as inline

0 commit comments

Comments
 (0)