Skip to content
prod e051e98
Browse

4 · Track and restore

Objective — make every vendor patch discoverable and re-applicable: log each one as a MOD-NNN, and run one restore script so composer install and vendor updates never quietly drop your work.

The overlay re-applies files; the tracking log explains them. Six months from now, a ZAJ:BEGIN MOD-001 marker in a vendor file means nothing without a record of what MOD-001 is, why it exists, and what breaks if it’s missing. The _CUSTOMIZATIONS log is that record — a numbered registry of every vendor modification.

The restore script closes the loop. Because a plain composer install restores vanilla vendor files, the script must run after it to copy your overlaid files back. It is also packaged as a downloadable kit so you can drop it into any project.

flowchart LR
L["_CUSTOMIZATIONS log<br/>MOD-NNN registry"] --> O["resources/<br/>vendor-customizations/"]
O --> S["restore script<br/>copies overlay → vendor/"]

1. Log each customization as a MOD-NNN entry

Section titled “1. Log each customization as a MOD-NNN entry”

Every vendor patch gets a numbered, documented entry so it can be re-applied confidently after any update. Treat the log as the single source of truth for “what did we change in vendor code, and why.”

  1. Add a MOD-NNN row for each customization, recording the fields that make it re-applicable.

    FieldWhat it captures
    IDMOD-NNN — a stable identifier matching the ZAJ:BEGIN marker in the file
    Filethe vendor path that was edited (e.g. app/Http/Controllers/HomeController.php)
    Vendorwhich CodeCanyon app/version the patch targets
    Problemwhat breaks without the patch
    Impactthe user-visible symptom (e.g. wrong migration count → redirect to /update)
    First addedthe date, so you can correlate with vendor releases
    • ✅ Each customization has one numbered row capturing file, vendor, problem, impact, and date.
  2. Keep an update checklist that lists every modified file and the action to take when a vendor update lands.

    FileModificationAction on vendor update
    app/Http/Controllers/HomeController.phpMOD-001Re-apply the ZajModules migration-path patch, then run the verification
    • ✅ The checklist names every file that will conflict on a vendor update and how to re-apply each patch.

2. Run the restore script after composer install

Section titled “2. Run the restore script after composer install”

The restore script reads the overlay and copies every customized file back over its vendor counterpart. Run it after any command that rewrites vendor/.

  1. Run the script after composer install (or after a vendor update).

    Terminal window
    composer install
    php Admin-Local/.../restore-vendor-customizations.php
    # Expected: "Found N customized package(s)" then a per-package "Restored N file(s)" summary
    • ✅ The summary lists each customized package and reports the files it restored.

The script scans resources/vendor-customizations/, finds each customized package folder, and recursively copies its files onto the matching package inside vendor/. If a package isn’t present in vendor/ (removed or renamed) it is skipped with a warning rather than failing the run. It also auto-extracts resources/vendor-customizations.zip if the unpacked directory isn’t there yet.

A restore that reports success still needs a behavioral check — confirm the patched logic produces the right result, not just that files were copied.

  1. Re-run the patch’s own verification. For the MOD-001 migration-scanner example, confirm the file count now matches the database count.

    Terminal window
    php artisan tinker --execute="
    \$files = count(File::glob(database_path('migrations/*.php')));
    \$files += count(File::glob(database_path('migrations-zaj/*.php')));
    \$files += count(File::glob(base_path('packages/ZajModules/*/src/Database/Migrations/*.php')));
    \$db = DB::table('migrations')->count();
    echo 'Files: '.\$files.' | DB: '.\$db.' | Diff: '.(\$files - \$db);
    "
    # Expected: Diff: 0 (or close to 0)
    • ✅ The diff is 0 (or near it), confirming the patched scanner now sees every migration path.
  2. Commit the re-applied patch with a message that names the MOD-NNN, so git log cross-references the registry.

    • ✅ The commit message references the MOD-NNN, e.g. “Re-apply ZajModules migration patch (MOD-001) after vendor update”.

The restore script is generic — it works for any customized package, not just one — which is why it ships as a reusable kit you can drop into a new project.

  1. Grab the packaged restore script from the kits and place it in your project’s scripts folder, then point your install/deploy routine at it.

    • ✅ The project has its own copy of restore-vendor-customizations.php wired into the install flow.

Do not mark this step done until every box below is checked.

  • 👤 Every patch logged — each customization has a MOD-NNN row (file, vendor, problem, impact, date) and an update-checklist entry.
  • 🤖 Restore runsrestore-vendor-customizations.php runs after composer install and reports each package restored.
  • 🤖 Patch verified — the patch’s own check passes (e.g. migration Diff: 0), not just “files copied”.
  • 🔀 Committed + wired — the re-applied patch is committed referencing its MOD-NNN, and the restore step is part of the install/deploy routine.

Vendor Updates — apply a new vendor release safely, restoring your customizations as part of the update.