Skip to content

Switched installer to upstream 'laravel/prompts' with fork-parity patch.#2497

Open
AlexSkrypnyk wants to merge 2 commits into
mainfrom
feature/prompts-upstream
Open

Switched installer to upstream 'laravel/prompts' with fork-parity patch.#2497
AlexSkrypnyk wants to merge 2 commits into
mainfrom
feature/prompts-upstream

Conversation

@AlexSkrypnyk
Copy link
Copy Markdown
Member

@AlexSkrypnyk AlexSkrypnyk commented May 19, 2026

Summary

Switches the installer's laravel/prompts dependency from the AlexSkrypnyk/prompts fork (resolved via a custom repositories VCS block) to the canonical package on Packagist, with the fork's three load-bearing customizations re-applied via a single cweagans/composer-patches v2 patch. The fork was a maintenance burden - every upstream version bump required waiting for the fork's release schedule before the installer could move to the new tag.

Changes

composer.json

  • Removed the repositories VCS block that overrode laravel/prompts resolution to github.com/AlexSkrypnyk/prompts.git.
  • Bumped the version constraint from ^0.3.14 to ^0.3.18 (current upstream).
  • Added extra.patches block registering patches/laravel-prompts-fork-parity.patch for laravel/prompts.

composer.lock

  • laravel/prompts now resolves from github.com/laravel/prompts.git at v0.3.18 (canonical Packagist).
  • Previously resolved from github.com/AlexSkrypnyk/prompts.git at v0.3.14.

patches/laravel-prompts-fork-parity.patch (new, 1317 lines)

Restores three behaviors that the installer depends on:

  1. description field on every Prompt class and renderer - added via a new RendersDescription trait. PromptManager::runPrompts() threads $handler->description($responses) into $args['description'] for every handler that returns a non-null description.
  2. Prompt::validateUsing(?Closure $callback) accepts null - allows TuiTrait::tuiTeardown() to clear the static validator between tests.
  3. Static validateUsing callback runs before the instance validate closure and receives $value - TuiTrait::tuiSetUp() uses this to intercept every prompt's validation and throw RuntimeException on failure, so non-interactive tests fail fast instead of hanging.

Also carries a minor Concerns/TypedValue.php truthy-check tweak (strlen($default) > 0 to !empty($default)) from the fork's main for byte-for-byte parity.

Two of the three behaviors have open upstream PRs: laravel/prompts#200 (description support) and laravel/prompts#186 (static validator precedence). If either lands upstream, the corresponding hunk can be dropped from the patch on the next bump.

patches/reroot-patch.php (new)

Helper script that converts diff -ruN absolute paths (e.g. /tmp/prompts-upstream/src/Foo.php) into a/src/Foo.php / b/src/Foo.php form suitable for composer-patches, and strips timestamps. Used on every re-roll.

patches.lock.json

Regenerated by composer-patches to include the new patch entry with its SHA-256 checksum.

.vortex/installer/CLAUDE.md

Added a ## Patches section documenting:

  • What each of the three patch behaviors does and why it is load-bearing.
  • Upstream PR tracking links.
  • Concrete re-roll procedure (must run on every laravel/prompts bump, since the description trait touches renderers that change frequently).

Before / After

Before
──────
composer.json
  "repositories": [
    { "type": "vcs",
      "url": "github.com/AlexSkrypnyk/prompts.git" }  ← override
  ]
  "laravel/prompts": "^0.3.14"

  Resolution flow:
  ┌─────────────┐   VCS override   ┌──────────────────────────┐
  │  composer   │ ───────────────► │  AlexSkrypnyk/prompts    │
  │  install    │                  │  (fork, v0.3.14)         │
  └─────────────┘                  │  customizations baked in │
                                   └──────────────────────────┘


After
─────
composer.json
  (no repositories block)
  "laravel/prompts": "^0.3.18"
  "extra": { "patches": { "laravel/prompts": "patches/..." } }

  Resolution flow:
  ┌─────────────┐   Packagist      ┌──────────────────────────┐
  │  composer   │ ───────────────► │  laravel/prompts         │
  │  install    │                  │  (canonical, v0.3.18)    │
  └─────────────┘                  └──────────────┬───────────┘
                                                  │
                                   composer-patches applies
                                   laravel-prompts-fork-parity.patch
                                                  │
                                                  ▼
                                   ┌──────────────────────────┐
                                   │  vendor/laravel/prompts  │
                                   │  + description support   │
                                   │  + nullable validateUsing│
                                   │  + validator precedence  │
                                   └──────────────────────────┘

Summary by CodeRabbit

  • New Features

    • All prompt types now support optional descriptions displayed alongside input fields during user interaction.
  • Enhancements

    • Improved static validator behavior to pass prompt context during validation.
  • Chores

    • Updated prompt library dependency to ^0.3.18.
    • Established patch management infrastructure for dependency compatibility.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Walkthrough

This PR integrates a patch to laravel/prompts ^0.3.18 that adds optional description field support to all prompt types. The patch updates Composer configuration, registers the patch via Composer extra.patches, and includes a utility script for rewriting patch headers. The patch itself adds description properties, updates validation callback signatures, and implements conditional description rendering across all prompt renderers using a shared trait.

Changes

Laravel Prompts Fork-Parity Patch

Layer / File(s) Summary
Patch Infrastructure Setup
.vortex/installer/composer.json, .vortex/installer/patches.lock.json, .vortex/installer/patches/reroot-patch.php
Composer dependency bumped from ^0.3.14 to ^0.3.18, custom VCS repository removed, patch registered via extra.patches, patches lockfile updated with entry metadata, and new reroot-patch.php utility added to rewrite diff -ruN headers for cross-prefix patch application.
Description Property and Core Changes
.vortex/installer/patches/laravel-prompts-fork-parity.patch (sections: Prompt classes, FormBuilder, validateUsing, helpers)
Public nullable ?string $description property added to all prompt classes via promoted constructors. Prompt::validateUsing accepts ?Closure with updated validation dispatch. Description parameter threaded through all FormBuilder methods and global helper functions (text, textarea, number, select, multiselect, confirm, suggest, search, multisearch, autocomplete).
Description Rendering in Default Theme
.vortex/installer/patches/laravel-prompts-fork-parity.patch (sections: RendersDescription trait, all renderers)
RendersDescription trait provides renderDescription(...) (trimming, word-wrapping) and calculateDescriptionWidth(...) utilities. All renderers (AutoComplete, Confirm, MultiSearch, MultiSelect, Number, Password, Search, Select, Suggest, Text, Textarea) integrate conditional description rendering with renderer-specific width calculations and layout adjustments including line breaks before options.
Patch System Documentation
.vortex/installer/CLAUDE.md
Comprehensive guide explaining the composer patch mechanism, behaviors restored (description rendering, nullable validation closure, static validator precedence), patch registration via lockfile, and explicit re-roll procedure for future laravel/prompts version updates.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 A patch to restore the fork's glow,
Descriptions now render, both high and low,
Prompts dressed in detail, validators made free,
The laravel prompts dance in harmony!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: switching from a forked 'laravel/prompts' to the upstream package while applying a fork-parity patch to restore required customizations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/prompts-upstream

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.vortex/installer/CLAUDE.md:
- Line 237: The current cleanup step that contains the command 'rm -f
~/Library/Caches/composer/patches/*.patch' only targets macOS; update that line
to be cross-platform by also removing patches from the Linux Composer cache
(e.g., ~/.cache/composer/patches) or, better, use a portable fallback that
expands XDG_CACHE_HOME (e.g., remove from
${XDG_CACHE_HOME:-$HOME/.cache}/composer/patches in addition to the macOS
cache), so the step deletes stale patch files on both macOS and Linux.

In @.vortex/installer/patches/laravel-prompts-fork-parity.patch:
- Around line 334-336: Clamp the computed wrap width before calling mbWordwrap:
after computing $targetWidth (from $calculateContentWidth() or
$this->calculateDescriptionWidth($prompt, $maxWidth)) ensure you limit it to the
terminal max by setting it to the minimum of the computed value and $maxWidth
(and optionally floor to at least 1) so that the call to
$this->mbWordwrap($prompt->description, $targetWidth, PHP_EOL) cannot exceed the
box width; update the block that computes $targetWidth and then calls mbWordwrap
accordingly, referencing calculateDescriptionWidth, $calculateContentWidth,
$maxWidth, $targetWidth and mbWordwrap.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2bf313b8-a199-49b2-9b3a-6b456e355193

📥 Commits

Reviewing files that changed from the base of the PR and between cd436ee and 3008e0a.

⛔ Files ignored due to path filters (1)
  • .vortex/installer/composer.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • .vortex/installer/CLAUDE.md
  • .vortex/installer/composer.json
  • .vortex/installer/patches.lock.json
  • .vortex/installer/patches/laravel-prompts-fork-parity.patch
  • .vortex/installer/patches/reroot-patch.php

/tmp/prompts-fork/

# 5. Refresh the lockfile and re-apply.
rm -f ~/Library/Caches/composer/patches/*.patch # macOS cache path
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make cache cleanup step cross-platform.

Line 237 hardcodes the macOS Composer cache path, so Linux contributors may skip stale patch cleanup unintentionally. Add Linux path (or a portable alternative) in the same step.

Suggested doc tweak
- rm -f ~/Library/Caches/composer/patches/*.patch  # macOS cache path
+ rm -f ~/Library/Caches/composer/patches/*.patch  # macOS cache path
+ rm -f ~/.cache/composer/patches/*.patch          # Linux cache path
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
rm -f ~/Library/Caches/composer/patches/*.patch # macOS cache path
rm -f ~/Library/Caches/composer/patches/*.patch # macOS cache path
rm -f ~/.cache/composer/patches/*.patch # Linux cache path
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.vortex/installer/CLAUDE.md at line 237, The current cleanup step that
contains the command 'rm -f ~/Library/Caches/composer/patches/*.patch' only
targets macOS; update that line to be cross-platform by also removing patches
from the Linux Composer cache (e.g., ~/.cache/composer/patches) or, better, use
a portable fallback that expands XDG_CACHE_HOME (e.g., remove from
${XDG_CACHE_HOME:-$HOME/.cache}/composer/patches in addition to the macOS
cache), so the step deletes stale patch files on both macOS and Linux.

Comment on lines +334 to +336
+ $targetWidth = $calculateContentWidth ? $calculateContentWidth() : $this->calculateDescriptionWidth($prompt, $maxWidth);
+
+ return $this->mbWordwrap($prompt->description, $targetWidth, PHP_EOL);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect description-width computations that may exceed max width.
rg -n -C2 'calculateDescriptionWidth|return max\(\$this->minWidth|mbWordwrap\(\$prompt->description' .vortex/installer/patches/laravel-prompts-fork-parity.patch

Repository: drevops/vortex

Length of output: 29257


Clamp description wrap width to prevent layout overflow.

Several calculateDescriptionWidth() implementations return values without clamping to $maxWidth (e.g., MultiSearchPrompt, MultiSelectPrompt, SearchPrompt, SelectPrompt). When these widths are passed directly to mbWordwrap() on line 336, they can exceed the terminal box width. Add clamping on line 334:

$targetWidth = $calculateContentWidth ? $calculateContentWidth() : $this->calculateDescriptionWidth($prompt, $maxWidth);
+$targetWidth = max(1, min($targetWidth, $maxWidth));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
+ $targetWidth = $calculateContentWidth ? $calculateContentWidth() : $this->calculateDescriptionWidth($prompt, $maxWidth);
+
+ return $this->mbWordwrap($prompt->description, $targetWidth, PHP_EOL);
$targetWidth = $calculateContentWidth ? $calculateContentWidth() : $this->calculateDescriptionWidth($prompt, $maxWidth);
$targetWidth = max(1, min($targetWidth, $maxWidth));
return $this->mbWordwrap($prompt->description, $targetWidth, PHP_EOL);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.vortex/installer/patches/laravel-prompts-fork-parity.patch around lines 334
- 336, Clamp the computed wrap width before calling mbWordwrap: after computing
$targetWidth (from $calculateContentWidth() or
$this->calculateDescriptionWidth($prompt, $maxWidth)) ensure you limit it to the
terminal max by setting it to the minimum of the computed value and $maxWidth
(and optionally floor to at least 1) so that the call to
$this->mbWordwrap($prompt->description, $targetWidth, PHP_EOL) cannot exceed the
box width; update the block that computes $targetWidth and then calls mbWordwrap
accordingly, referencing calculateDescriptionWidth, $calculateContentWidth,
$maxWidth, $targetWidth and mbWordwrap.

@github-actions
Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.53% (201/204)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk
Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.53% (201/204)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.51%. Comparing base (3156578) to head (3008e0a).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2497      +/-   ##
==========================================
- Coverage   79.97%   79.51%   -0.46%     
==========================================
  Files         129      122       -7     
  Lines        6895     6736     -159     
  Branches       47        3      -44     
==========================================
- Hits         5514     5356     -158     
+ Misses       1381     1380       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: BACKLOG

Development

Successfully merging this pull request may close these issues.

1 participant