|
| 1 | +# Chorale Plan Command |
| 2 | + |
| 3 | +The `plan` command is an advanced dry‑run that inspects your monorepo and prints exactly what would change — without writing anything. Use it to understand and validate changes before applying them. |
| 4 | + |
| 5 | +## Summary |
| 6 | + |
| 7 | +- Checks package versions against the monorepo root version |
| 8 | +- Computes package `composer.json` edits via the rule engine |
| 9 | +- Updates the root `composer.json` (require/replace) as an aggregator |
| 10 | +- Merges package dependencies into the root (with conflicts reported) |
| 11 | +- Decides which packages need a split (and why) |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +```bash |
| 16 | +php tools/chorale/bin/chorale plan [<vendor/name>] [options] |
| 17 | +``` |
| 18 | + |
| 19 | +- `<vendor/name>`: Optional composer package name to focus on a single package |
| 20 | + (e.g., `sonsofphp/cache`). This reduces noise for large monorepos. |
| 21 | + |
| 22 | +## Options |
| 23 | + |
| 24 | +- `--concise`: One‑line summaries only; omit detailed blocks |
| 25 | +- `--show-all`: Include no‑op summaries for debugging decisions |
| 26 | +- `--json`: Output as JSON; ideal for `apply` or external tooling |
| 27 | +- `--project-root=PATH`: Explicit project root (defaults to current directory) |
| 28 | +- `--paths=DIR ...`: Limit discovery to specific package path(s) |
| 29 | +- `--force-split`: Plan split steps even if content appears unchanged |
| 30 | +- `--verify-remote`: Verify remote state if local lockfiles are missing/stale |
| 31 | +- `--strict`: Exit non‑zero when issues are detected (e.g., conflicts, missing root version) |
| 32 | + |
| 33 | +## Examples |
| 34 | + |
| 35 | +```bash |
| 36 | +# All packages, detailed output |
| 37 | +php tools/chorale/bin/chorale plan |
| 38 | + |
| 39 | +# Concise one‑liners |
| 40 | +php tools/chorale/bin/chorale plan --concise |
| 41 | + |
| 42 | +# Show no‑ops too |
| 43 | +php tools/chorale/bin/chorale plan --show-all |
| 44 | + |
| 45 | +# JSON output for apply |
| 46 | +php tools/chorale/bin/chorale plan --json > plan.json |
| 47 | + |
| 48 | +# Focus on one package by composer name |
| 49 | +php tools/chorale/bin/chorale plan sonsofphp/cache |
| 50 | + |
| 51 | +# Focused + concise |
| 52 | +php tools/chorale/bin/chorale plan sonsofphp/cache --concise |
| 53 | + |
| 54 | +# Limit discovery to a folder (path) |
| 55 | +php tools/chorale/bin/chorale plan --paths src/SonsOfPHP/Component/Cache |
| 56 | +``` |
| 57 | + |
| 58 | +## Output Breakdown |
| 59 | + |
| 60 | +Plan output is grouped by step type: |
| 61 | + |
| 62 | +- `Split steps`: Shows package path → repo, splitter, branch, tag strategy, and reasons |
| 63 | +- `Package versions`: Shows the package name, target version, previous version, and reason |
| 64 | +- `Package metadata`: Lists keys to mirror and pretty‑prints the exact `apply` JSON block |
| 65 | +- `Root composer: aggregator`: Prints the final `require` and `replace` maps |
| 66 | +- `Root composer: dependency merge`: Prints merged `require` and `require‑dev`, plus conflicts |
| 67 | +- `Root composer: maintenance`: Maintenance actions like `validate` |
| 68 | + |
| 69 | +### Delta Notation |
| 70 | + |
| 71 | +Composer maps show a delta summary: |
| 72 | + |
| 73 | +``` |
| 74 | +[+added/-removed/~changed] |
| 75 | +``` |
| 76 | + |
| 77 | +This is printed inline in summaries and also included in JSON under `meta` as |
| 78 | +`delta_require`, `delta_replace`, and `delta_require_dev` where applicable. |
| 79 | + |
| 80 | +## JSON Schema (version 1) |
| 81 | + |
| 82 | +The `--json` output contains: |
| 83 | + |
| 84 | +- `steps`: Array of step objects with type‑specific fields |
| 85 | +- `noop`: Optional summary of skipped groups when `--show-all` is used |
| 86 | +- `meta`: For root steps, delta objects summarizing changes |
| 87 | + |
| 88 | +Example snippet (root update): |
| 89 | + |
| 90 | +```json |
| 91 | +{ |
| 92 | + "type": "composer-root-update", |
| 93 | + "root": "sonsofphp/monorepo", |
| 94 | + "root_version": "1.2.3", |
| 95 | + "require": { "sonsofphp/cache": "1.2.3" }, |
| 96 | + "replace": { "sonsofphp/cache": "1.2.3" }, |
| 97 | + "meta": { |
| 98 | + "delta_require": { "added": 1, "removed": 0, "changed": 0 }, |
| 99 | + "delta_replace": { "added": 1, "removed": 0, "changed": 0 } |
| 100 | + } |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +## Tips |
| 105 | + |
| 106 | +- Use `--concise` for quick scans, and omit it to see exact JSON diffs. |
| 107 | +- Combine the positional `<vendor/name>` with `--json` to isolate and export a single package’s plan. |
| 108 | +- For CI checks, run with `--strict` so the command exits non‑zero when action is required. |
| 109 | + |
0 commit comments