Skip to content

Conversation

@bodane
Copy link
Contributor

@bodane bodane commented Feb 1, 2026

Summary

  • Adds scripts/setup-local-packages.sh (macOS/Linux) and scripts/setup-local-packages.ps1 (Windows)
  • Scripts generate composer.local.json for each package by merging original composer.json with path repositories
  • Allows packages with host-uk/* dependencies to install locally via symlinks

Changes

  • New setup-local-packages.sh - Bash script requiring jq for JSON manipulation
  • New setup-local-packages.ps1 - PowerShell script using native JSON cmdlets
  • Updated CLAUDE.md with Local Package Linking documentation section

Test Plan

Tested on Windows:

.\scripts\setup-local-packages.ps1
cd packages\core-tenant
$env:COMPOSER='composer.local.json'; composer install
# Successfully installed with host-uk/core resolved from ../core-php (symlinked)

Verification

ls -la packages/core-tenant/vendor/host-uk/
# core -> /c/Users/user/github/core-devops/packages/core-php (symlink)

Closes #7


Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added automated setup scripts (PowerShell and Bash) for configuring local package repositories with symlinked path-based linking, automatic gitignore management, and support for single-package or bulk multi-package configuration.
  • Documentation

    • Added local package linking guidance section with setup instructions, quick-start scripts, per-package installation workflows, JSON configuration examples, and environment variable guidance for multi-package development.

✏️ Tip: You can customize this high-level summary in your review settings.

Adds cross-platform scripts (bash/PowerShell) that generate composer.local.json
files for each package. This allows packages with host-uk/* dependencies to
install via symlinked path repositories instead of failing on missing private
packages from Packagist.

Usage:
  ./scripts/setup-local-packages.sh       # macOS/Linux
  .\scripts\setup-local-packages.ps1      # Windows

Then: COMPOSER=composer.local.json composer install

Closes #7

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 1, 2026

🤖 Free Tier AI Analysis

Multiple AI services analyzed this PR:

Service Status Free Tier
Groq (Llama 3) success 14,400 req/day
Mistral skipped 1M tokens/month
Cohere skipped 1000 req/month
Cloudflare AI skipped 10K neurons/day

Add API keys to your fork secrets to enable more services.
All analysis runs on contributor's free tier allowance.

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

📝 Walkthrough

Walkthrough

Introduces local package linking for PHP dependency testing by adding setup scripts (PowerShell and Bash) that automatically configure composer.local.json files to use local path repositories for inter-package dependencies, with supporting documentation in CLAUDE.md.

Changes

Cohort / File(s) Summary
Documentation
CLAUDE.md
Adds "Local Package Linking" guidance section detailing local path-based linking for host-uk/core dependencies, quick setup scripts, per-package installation flow, and composer.local.json JSON example. Updates global repository scope listing and scripts section references.
Setup Scripts
scripts/setup-local-packages.ps1, scripts/setup-local-packages.sh
New automation scripts (PowerShell and Bash) that detect packages depending on host-uk/core, merge local path repositories into composer.json, generate composer.local.json (UTF-8 without BOM), and update .gitignore. Both support optional single-package targeting and include comprehensive error handling and colorized output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop along, dear developers true,
Local packages now link straight to you,
Composer.local.json weaves the threads,
No more waiting—test where the code spreads!
With shells and scripts both bash and pow'r divine,
Your monorepo dependencies align!

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(scripts): add local package linking for PHP dependency testing' accurately summarizes the main change: adding scripts for local package linking functionality.
Linked Issues check ✅ Passed The PR fully implements all coding requirements from issue #7: setup scripts for both Bash and PowerShell that configure composer.local.json with path repositories, documentation in CLAUDE.md, and mechanisms to link host-uk/* dependencies locally.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #7 objectives: the two setup scripts, CLAUDE.md documentation updates, and package listing updates are all necessary components of enabling local package linking.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/issue-7-local-package-linking

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@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: 4

🤖 Fix all issues with AI agents
In `@CLAUDE.md`:
- Around line 140-149: Add a short prerequisite note to the Quick Setup section
stating that jq is required on macOS/Linux before running
./scripts/setup-local-packages.sh (or any call to that script), so users install
jq (e.g., via brew or apt) to avoid JSON parsing errors; update the text near
the macOS/Linux example and mention jq is only required for macOS/Linux
invocations of ./scripts/setup-local-packages.sh.

In `@scripts/setup-local-packages.ps1`:
- Around line 59-64: The current script unconditionally overwrites the
"repositories" property, which drops existing Composer VCS/private entries;
update the logic that sets $original.repositories so it merges $PathRepositories
before any existing $original.repositories (i.e., if $original.repositories
exists, create a new array with $PathRepositories elements followed by the
existing entries, otherwise set it to $PathRepositories), then proceed to
ConvertTo-Json and WriteAllText($target, ...) as before using the UTF‑8 no‑BOM
encoding; reference the symbols $original, $PathRepositories, "repositories",
ConvertTo-Json and [System.IO.File]::WriteAllText to locate and modify the code.

In `@scripts/setup-local-packages.sh`:
- Around line 35-38: The jq presence check (the if ! command -v jq &> /dev/null
block) only tells users to run "brew install jq", which is macOS-specific;
update the error message to show cross-platform install guidance for macOS
(brew), common Linux package managers (apt-get, yum/dnf, pacman) and Windows
(choco or scoop) and optionally point to installing via WSL or the jq binary
download. Modify the echo in that block to include these platform-specific
commands and a short note to choose the appropriate installer for their OS so
users on Linux and Windows get correct instructions.
- Around line 65-67: The jq invocation that writes composer.local.json currently
replaces any existing .repositories with $REPOSITORIES; change it to merge the
new repositories into the existing .repositories (prepending $REPOSITORIES
before existing entries) instead of overwriting so VCS/private sources are
preserved. Update the jq expression used with variables composer_json,
REPOSITORIES and target to read the original .repositories (or use an empty
array if missing) and produce a combined array with $REPOSITORIES first, then
the original entries, then write to "$target". Ensure the updated command still
handles missing .repositories gracefully.

Comment on lines +140 to +149
```bash
# macOS/Linux - setup all packages
./scripts/setup-local-packages.sh

# Windows (PowerShell)
.\scripts\setup-local-packages.ps1

# Or setup a specific package
./scripts/setup-local-packages.sh core-tenant
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Find and examine the setup script
fd setup-local-packages.sh

Repository: host-uk/core-devops

Length of output: 94


🏁 Script executed:

# Read CLAUDE.md to see the context around lines 140-149
wc -l CLAUDE.md && sed -n '130,160p' CLAUDE.md

Repository: host-uk/core-devops

Length of output: 873


🏁 Script executed:

# Search for any existing jq mentions in CLAUDE.md
rg -n "jq" CLAUDE.md

Repository: host-uk/core-devops

Length of output: 45


🏁 Script executed:

# Read the setup script
cat scripts/setup-local-packages.sh

Repository: host-uk/core-devops

Length of output: 3669


Add a short jq prerequisite note for macOS/Linux.

The setup script requires jq for JSON manipulation, but the Quick Setup section doesn't mention it. Add a brief prerequisite line to prevent users from encountering errors.

📚 Suggested doc tweak
 ### Quick Setup

+macOS/Linux requires `jq` for JSON merging (install via `brew install jq` or your package manager).
+
 ```bash
 # macOS/Linux - setup all packages
 ./scripts/setup-local-packages.sh
🤖 Prompt for AI Agents
In `@CLAUDE.md` around lines 140 - 149, Add a short prerequisite note to the Quick
Setup section stating that jq is required on macOS/Linux before running
./scripts/setup-local-packages.sh (or any call to that script), so users install
jq (e.g., via brew or apt) to avoid JSON parsing errors; update the text near
the macOS/Linux example and mention jq is only required for macOS/Linux
invocations of ./scripts/setup-local-packages.sh.

Comment on lines +59 to +64
# Add repositories array (path repos must come first)
$original | Add-Member -NotePropertyName "repositories" -NotePropertyValue $PathRepositories -Force

# Write merged composer.local.json (UTF-8 without BOM for Composer compatibility)
$json = $original | ConvertTo-Json -Depth 10
[System.IO.File]::WriteAllText($target, $json, [System.Text.UTF8Encoding]::new($false))
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n scripts/setup-local-packages.ps1

Repository: host-uk/core-devops

Length of output: 4965


Preserve any existing Composer repositories when generating composer.local.json.

Overwriting repositories can drop required VCS/private entries and break installs for packages that already define them. Merge path repos ahead of existing ones instead.

🛠️ Suggested merge (path repos first)
-    $original | Add-Member -NotePropertyName "repositories" -NotePropertyValue $PathRepositories -Force
+    $existing = @()
+    if ($original.PSObject.Properties.Name -contains "repositories") {
+        $existing = $original.repositories
+    }
+    $merged = @($PathRepositories + $existing)
+    $original | Add-Member -NotePropertyName "repositories" -NotePropertyValue $merged -Force
🤖 Prompt for AI Agents
In `@scripts/setup-local-packages.ps1` around lines 59 - 64, The current script
unconditionally overwrites the "repositories" property, which drops existing
Composer VCS/private entries; update the logic that sets $original.repositories
so it merges $PathRepositories before any existing $original.repositories (i.e.,
if $original.repositories exists, create a new array with $PathRepositories
elements followed by the existing entries, otherwise set it to
$PathRepositories), then proceed to ConvertTo-Json and WriteAllText($target,
...) as before using the UTF‑8 no‑BOM encoding; reference the symbols $original,
$PathRepositories, "repositories", ConvertTo-Json and
[System.IO.File]::WriteAllText to locate and modify the code.

Comment on lines +35 to +38
# Check for jq (required for JSON manipulation)
if ! command -v jq &> /dev/null; then
echo "Error: jq is required but not installed. Install it with: brew install jq"
exit 1
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Locate and examine the setup-local-packages.sh file
find . -name "setup-local-packages.sh" -type f 2>/dev/null | head -5

Repository: host-uk/core-devops

Length of output: 96


🏁 Script executed:

#!/bin/bash
# Read the setup-local-packages.sh file with line numbers
cat -n ./scripts/setup-local-packages.sh

Repository: host-uk/core-devops

Length of output: 4474


Provide cross-platform installation guidance for jq.

The error message at line 37 references only brew install jq, which is misleading for Linux and Windows users. Provide guidance for all supported platforms.

📝 Suggested fix
# Check for jq (required for JSON manipulation)
if ! command -v jq &> /dev/null; then
-    echo "Error: jq is required but not installed. Install it with: brew install jq"
+    echo "Error: jq is required but not installed."
+    echo "Install: macOS (brew install jq) | Debian/Ubuntu (sudo apt-get install jq) | Fedora (sudo dnf install jq)"
     exit 1
 fi

Per coding guidelines: scripts/** must ensure cross-platform compatibility (macOS, Linux, Windows).

📝 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
# Check for jq (required for JSON manipulation)
if ! command -v jq &> /dev/null; then
echo "Error: jq is required but not installed. Install it with: brew install jq"
exit 1
# Check for jq (required for JSON manipulation)
if ! command -v jq &> /dev/null; then
echo "Error: jq is required but not installed."
echo "Install: macOS (brew install jq) | Debian/Ubuntu (sudo apt-get install jq) | Fedora (sudo dnf install jq)"
exit 1
fi
🤖 Prompt for AI Agents
In `@scripts/setup-local-packages.sh` around lines 35 - 38, The jq presence check
(the if ! command -v jq &> /dev/null block) only tells users to run "brew
install jq", which is macOS-specific; update the error message to show
cross-platform install guidance for macOS (brew), common Linux package managers
(apt-get, yum/dnf, pacman) and Windows (choco or scoop) and optionally point to
installing via WSL or the jq binary download. Modify the echo in that block to
include these platform-specific commands and a short note to choose the
appropriate installer for their OS so users on Linux and Windows get correct
instructions.

Comment on lines +65 to +67
# Merge repositories into composer.json and write to composer.local.json
jq --argjson repos "$REPOSITORIES" '. + {repositories: $repos}' "$composer_json" > "$target"

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Read the setup script to examine lines 65-67 and surrounding context
wc -l scripts/setup-local-packages.sh

Repository: host-uk/core-devops

Length of output: 98


🏁 Script executed:

# View the file around lines 65-67 with context
sed -n '50,80p' scripts/setup-local-packages.sh | cat -n

Repository: host-uk/core-devops

Length of output: 1106


🏁 Script executed:

# Also check what REPOSITORIES variable contains and how it's defined
cat scripts/setup-local-packages.sh | cat -n

Repository: host-uk/core-devops

Length of output: 4474


Merge path repositories before existing entries instead of replacing them.

The current jq command completely overwrites any pre-existing repositories configuration in composer.json when creating composer.local.json. If the original composer.json defines VCS or private sources, they will be lost when using COMPOSER=composer.local.json composer install, causing dependency resolution to fail.

🛠️ Suggested fix
-    jq --argjson repos "$REPOSITORIES" '. + {repositories: $repos}' "$composer_json" > "$target"
+    jq --argjson repos "$REPOSITORIES" '.repositories = ($repos + (.repositories // []))' "$composer_json" > "$target"
🤖 Prompt for AI Agents
In `@scripts/setup-local-packages.sh` around lines 65 - 67, The jq invocation that
writes composer.local.json currently replaces any existing .repositories with
$REPOSITORIES; change it to merge the new repositories into the existing
.repositories (prepending $REPOSITORIES before existing entries) instead of
overwriting so VCS/private sources are preserved. Update the jq expression used
with variables composer_json, REPOSITORIES and target to read the original
.repositories (or use an empty array if missing) and produce a combined array
with $REPOSITORIES first, then the original entries, then write to "$target".
Ensure the updated command still handles missing .repositories gracefully.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup local package linking for PHP dependency testing

2 participants