Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jetpack Changelogger Laravel Package

automattic/jetpack-changelogger

Automattic’s Jetpack Changelogger helps you create and manage changelog entries with a simple workflow, keeping releases consistent across projects. Designed for Jetpack development, it streamlines collecting notes and generating clean, structured changelogs.

View on GitHub
Deep Wiki
Context7
## Getting Started

### Minimal Setup
1. **Installation**:
   ```bash
   composer require --dev automattic/jetpack-changelogger

Ensure the changelog directory exists with a .gitkeep file:

mkdir -p changelog && touch changelog/.gitkeep
  1. First Change File: Create a change file (e.g., changelog/feat-add-login.md) with metadata and content:

    Significance: minor
    Type: added
    Comment: New login feature
    
    Users can now log in via OAuth.
    
  2. Validate:

    composer exec -- changelogger validate changelog/feat-add-login.md
    
  3. Generate Changelog:

    composer exec -- changelogger write
    

Key Files to Review

  • composer.json: Configure extra.changelogger (e.g., changes-dir, types).
  • CHANGELOG.md: Default output file (customizable via config).
  • changelog/*.md: Change files for each PR.

Implementation Patterns

Workflow Integration

  1. PR-Based Changelogging:

    • Branch Naming: Use unique branch names (e.g., feat/login-oauth) to auto-generate filenames.
    • CI/CD Hook: Add a GitHub Action to validate change files on PR:
      - name: Validate Changelog
        run: composer exec changelogger validate changelog/*.md
      
  2. Release Process:

    • Pre-Release:
      composer exec changelogger add --significance=minor --type=added --comment="New feature" --entry="Description"
      
    • Finalize Release:
      composer exec changelogger write --version=1.2.0
      git add CHANGELOG.md changelog/.gitkeep
      
  3. Custom Types: Extend types in composer.json for domain-specific categories:

    "extra": {
      "changelogger": {
        "types": {
          "deprecated": "Deprecated",
          "security": "Security Fixes"
        }
      }
    }
    

Laravel-Specific Tips

  • Artisan Command: Create a custom command to wrap changelogger:

    // app/Console/Commands/GenerateChangelog.php
    use Symfony\Component\Process\Process;
    use Symfony\Component\Process\Exception\ProcessFailedException;
    
    class GenerateChangelog extends Command {
        protected $signature = 'changelog:generate {--version=}';
        public function handle() {
            $process = new Process(['changelogger', 'write', '--version=' . $this->option('version')]);
            $process->run();
            if (!$process->isSuccessful()) {
                throw new ProcessFailedException($process);
            }
            $this->info('Changelog generated!');
        }
    }
    

    Register in app/Console/Kernel.php:

    protected $commands = [
        Commands\GenerateChangelog::class,
    ];
    
  • Git Hooks: Use Laravel’s repository facade to trigger changelog updates post-merge:

    // app/Providers/AppServiceProvider.php
    use Illuminate\Support\Facades\Event;
    use Illuminate\Support\Facades\Process;
    
    public function boot() {
        Event::listen('repository.merged', function () {
            Process::run('composer exec changelogger validate changelog/*.md');
        });
    }
    

Gotchas and Tips

Pitfalls

  1. Empty Entries:

    • Issue: Patch-significance entries must have content (even if empty, use a placeholder like [ ]).
    • Fix: Validate with changelogger validate --strict.
  2. Version Bumps:

    • Issue: semver plugin may miscalculate if Significance is missing or invalid.
    • Fix: Use --version flag to override:
      composer exec changelogger write --version=1.0.0
      
  3. Plugin Conflicts:

    • Issue: Custom formatter or versioning plugins may break if not properly autoloaded.
    • Fix: Ensure plugins implement FormatterPlugin/VersioningPlugin and are PSR-4 compliant.
  4. Merge Conflicts:

    • Issue: Change files with identical names (e.g., changelog/feat-x.md) cause conflicts.
    • Fix: Enforce branch-name-based filenames (e.g., changelog/feat-login-{branch-name}.md).

Debugging

  • Dry Runs: Use --dry-run to preview changes:

    composer exec changelogger write --dry-run
    
  • Verbose Output: Enable debug mode:

    composer exec changelogger write -vvv
    

Extension Points

  1. Custom Formatter: Extend keepachangelog to support custom Markdown (e.g., tables):

    // app/Plugins/CustomFormatter.php
    namespace App\Plugins;
    use Automattic\Jetpack\Changelogger\FormatterPlugin;
    
    class CustomFormatter implements FormatterPlugin {
        public function format(array $entries) {
            // Custom logic (e.g., wrap entries in tables)
            return "```markdown\n| Version | Changes |\n|---------|---------|\n" . implode("\n", $entries) . "\n```";
        }
    }
    

    Register in composer.json:

    "extra": {
      "changelogger": {
        "formatter": {
          "class": "App\\Plugins\\CustomFormatter"
        }
      }
    }
    
  2. Git Metadata: Auto-populate Comment with PR numbers using a Laravel service:

    // app/Services/ChangelogService.php
    use Illuminate\Support\Facades\Http;
    
    class ChangelogService {
        public function getPrNumber(string $branch) {
            $response = Http::get("https://api.github.com/repos/{repo}/compare/{branch}...main");
            return $response->object()->commit->parents[0]->message ?? null;
        }
    }
    

    Hook into changelogger add via a custom script.

  3. WordPress Versioning: Use the wordpress plugin for decimal versions (e.g., 9.4):

    composer exec changelogger write --point-release
    

Config Quirks

  • Relative Paths: Ensure changelog and changes-dir paths are relative to composer.json (not project root).
  • Types Validation: Omit Type field if types is empty in config (defaults to Keep a Changelog types).
  • Link Templates: Customize ${new}/${old} in link-template for release notes:
    "link-template": "https://github.com/{repo}/releases/tag/v${new}"
    

---
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor