Skip to content

Commit 1ff6ad5

Browse files
committed
Release v2.0.23: YAML configuration for command-line options and Wildcard Dependency Checking
New Features: - Command-line options configuration in YAML: Set default values for all command-line options in generate-composer-require.yaml - Available options: show-release-info, show-release-detail, show-impact-analysis, save-impact-to-file, verbose, debug - Command-line arguments always override YAML configuration - Benefits: Consistent defaults for team members, no need to remember long flags - Wildcard Dependency Checking: Extended dependency conflict detection to support wildcard constraints (^, ~, *) - Previously, dependency checking was skipped for packages with wildcard constraints - Now properly validates wildcard constraints against dependent package requirements - Improves conflict detection accuracy for framework constraints and version ranges Improvements: - Updated UPDATE_CASES.md: 15 fully supported cases (previously 14) - Updated IMPLEMENTATION_ROADMAP.md: Priority 7 (Wildcard Dependency Checking) completed - Updated CONFIGURATION.md: Added section for command-line options configuration - Updated README.md: Added examples and documentation for YAML configuration - Updated UPGRADING.md: Added migration notes for new features Quality: - All tests passing (140 tests, 689 assertions) - Code syntax verified (bash and PHP) - All classes loadable and functional - Code formatting corrected (PHP-CS-Fixer) See CHANGELOG.md for complete details.
1 parent 2459de8 commit 1ff6ad5

12 files changed

Lines changed: 589 additions & 34 deletions

README.md

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ Generates `composer require` commands from outdated dependencies. Works with any
2323
- ✅ Compares versions to avoid unnecessary updates
2424
-**Dependency compatibility checking**: Automatically detects and prevents dependency conflicts before suggesting updates
2525
-**Transitive dependency suggestions**: When conflicts are detected, automatically suggests updating required transitive dependencies with ready-to-use commands
26+
-**Conflict Impact Analysis**: Analyzes which packages would be affected by updating conflicting packages (optional with `--show-impact` flag)
27+
-**Save impact analysis**: Save impact analysis to file with `--save-impact` flag
2628
- ✅ Can execute commands directly with `--run` flag
2729
- ✅ Automatic installation via Composer plugin
2830
-**Release information and changelogs**: Shows GitHub release links and changelog previews for outdated packages
29-
-**Progress indicators**: Animated spinner shows activity during long-running operations
31+
-**Progress indicators**: Shows loading messages during long-running operations (dependency checking, fallback search, etc.)
3032
-**Help option**: Built-in `--help` flag for comprehensive usage information
3133
-**Verbose and Debug modes**: `-v, --verbose` and `--debug` options for troubleshooting and detailed information
3234
-**Multiple file extensions**: Supports both `.yaml` and `.yml` extensions for configuration files
@@ -86,6 +88,24 @@ The script automatically detects `process-updates.php` in `vendor/nowo-tech/comp
8688
# Execute commands directly
8789
./generate-composer-require.sh --run
8890

91+
# Show release information
92+
./generate-composer-require.sh --release-info
93+
94+
# Show full changelogs
95+
./generate-composer-require.sh --release-detail
96+
97+
# Show impact analysis for conflicting packages
98+
./generate-composer-require.sh --show-impact
99+
100+
# Save impact analysis to file
101+
./generate-composer-require.sh --save-impact
102+
103+
# Verbose output
104+
./generate-composer-require.sh --verbose
105+
106+
# Debug mode
107+
./generate-composer-require.sh --debug
108+
89109
# Show help
90110
./generate-composer-require.sh --help
91111
```
@@ -104,20 +124,23 @@ Example output:
104124
> **Note:** By default, release information is **not shown** (no API calls are made). Use `--release-info` or `--release-detail` to enable it.
105125
106126
**Available options:**
107-
- `--run` - Execute suggested commands
108-
- `--release-info` - Show release summary
109-
- `--release-detail` - Show full changelog
110-
- `-v, --verbose` - Show detailed information
111-
- `--debug` - Show debug information
112-
- `-h, --help` - Show help
127+
- `--run` - Execute suggested commands automatically
128+
- `--release-info` - Show release information (summary with links)
129+
- `--release-detail` - Show full release changelog for each package (implies `--release-info`)
130+
- `--no-release-info` - Skip release information section (default behavior)
131+
- `--show-impact, --impact` - Show impact analysis for conflicting packages (disabled by default)
132+
- `--save-impact` - Save impact analysis to `composer-update-impact.txt` file (implies `--show-impact`)
133+
- `-v, --verbose` - Show verbose output (configuration files, packages, etc.)
134+
- `--debug` - Show debug information (very detailed, includes file paths, parsing, etc.)
135+
- `-h, --help` - Show help message
113136

114137
For detailed usage information, see [Usage Guide](docs/USAGE.md).
115138

116139
## Configuration
117140

118141
The script searches for configuration files in the current directory (where `composer.json` is located). It supports both `.yaml` and `.yml` extensions, with `.yaml` taking priority.
119142

120-
Edit `generate-composer-require.yaml` to configure which packages to ignore or force include during updates:
143+
Edit `generate-composer-require.yaml` to configure which packages to ignore or force include during updates, and set default values for command-line options:
121144

122145
```yaml
123146
# Composer Update Helper Configuration
@@ -138,6 +161,15 @@ check-dependencies: true
138161
# ⚠️ WARNING: i18n feature is currently in DEVELOPMENT MODE
139162
#language: es
140163

164+
# Command-line options defaults (can be overridden via command-line arguments)
165+
# Set your preferred defaults here, then override them when needed via command-line flags
166+
show-release-info: false # Show release information by default
167+
show-release-detail: false # Show full changelog by default
168+
show-impact-analysis: false # Show impact analysis by default
169+
save-impact-to-file: false # Save impact analysis to file by default
170+
verbose: false # Verbose output by default
171+
debug: false # Debug mode by default
172+
141173
# List of packages to ignore during update
142174
# Ignored packages will still be displayed in the output with their available versions,
143175
# but won't be included in the composer require commands.
@@ -156,6 +188,8 @@ include:
156188
- another/package
157189
```
158190
191+
> 💡 **Tip**: Command-line arguments always override YAML configuration. For example, if you set `show-release-info: true` in YAML but run `./generate-composer-require.sh --no-release-info`, the release info will be disabled for that run.
192+
159193
For detailed configuration options including language settings, dependency checking, and backward compatibility, see [Configuration Guide](docs/CONFIGURATION.md).
160194

161195
For framework support details, see [Framework Support](docs/FRAMEWORKS.md).

bin/generate-composer-require.sh

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,82 @@ EOF
125125
fi
126126
}
127127

128-
# Parse arguments
129-
RUN_FLAG=""; SHOW_RELEASE_DETAIL=false; SHOW_RELEASE_INFO=false; SHOW_IMPACT_ANALYSIS=false; SAVE_IMPACT_TO_FILE=false; VERBOSE=false; DEBUG=false
128+
# Helper function to read YAML config value using PHP (if available)
129+
read_yaml_config_value() {
130+
local yaml_file="$1"
131+
local key="$2"
132+
local default="$3"
133+
134+
if [ ! -f "$yaml_file" ]; then
135+
echo "$default"
136+
return
137+
fi
138+
139+
# Try to use PHP if available (more reliable)
140+
if command -v php >/dev/null 2>&1; then
141+
local php_code="
142+
\$content = @file_get_contents('$yaml_file');
143+
if (!\$content) { echo '$default'; exit; }
144+
\$lines = explode(\"\\n\", \$content);
145+
foreach (\$lines as \$line) {
146+
\$line = trim(\$line);
147+
if (empty(\$line) || strpos(\$line, '#') === 0) continue;
148+
if (preg_match('/^' . preg_quote('$key', '/') . ':\\\\s*(.+)\$/', \$line, \$matches)) {
149+
\$value = trim(\$matches[1]);
150+
if (strtolower(\$value) === 'true') { echo 'true'; exit; }
151+
if (strtolower(\$value) === 'false') { echo 'false'; exit; }
152+
echo \$value; exit;
153+
}
154+
}
155+
echo '$default';
156+
"
157+
php -r "$php_code" 2>/dev/null || echo "$default"
158+
else
159+
# Fallback: simple grep (less reliable)
160+
local value=$(grep -E "^${key}:" "$yaml_file" 2>/dev/null | head -1 | sed 's/^[^:]*:[[:space:]]*//' | tr -d '\n')
161+
if [ -n "$value" ]; then
162+
echo "$value"
163+
else
164+
echo "$default"
165+
fi
166+
fi
167+
}
168+
169+
# Detect config file early (before parsing arguments) to read defaults
170+
config_info=$(detect_config_file)
171+
CONFIG_FILE=$(echo "$config_info" | cut -d'|' -f1)
172+
CONFIG_FILE_DISPLAY=$(echo "$config_info" | cut -d'|' -f2)
173+
CONFIG_FILE_SUFFIX=$(echo "$config_info" | cut -d'|' -f3)
174+
175+
# Read default values from YAML config (if config file exists)
176+
if [ -n "$CONFIG_FILE" ] && [ -f "$CONFIG_FILE" ]; then
177+
# Read boolean config values (default to false)
178+
YAML_SHOW_RELEASE_INFO=$(read_yaml_config_value "$CONFIG_FILE" "show-release-info" "false")
179+
YAML_SHOW_RELEASE_DETAIL=$(read_yaml_config_value "$CONFIG_FILE" "show-release-detail" "false")
180+
YAML_SHOW_IMPACT_ANALYSIS=$(read_yaml_config_value "$CONFIG_FILE" "show-impact-analysis" "false")
181+
YAML_SAVE_IMPACT_TO_FILE=$(read_yaml_config_value "$CONFIG_FILE" "save-impact-to-file" "false")
182+
YAML_VERBOSE=$(read_yaml_config_value "$CONFIG_FILE" "verbose" "false")
183+
YAML_DEBUG=$(read_yaml_config_value "$CONFIG_FILE" "debug" "false")
184+
else
185+
# No config file, use defaults
186+
YAML_SHOW_RELEASE_INFO="false"
187+
YAML_SHOW_RELEASE_DETAIL="false"
188+
YAML_SHOW_IMPACT_ANALYSIS="false"
189+
YAML_SAVE_IMPACT_TO_FILE="false"
190+
YAML_VERBOSE="false"
191+
YAML_DEBUG="false"
192+
fi
193+
194+
# Convert YAML values to boolean (normalize true/false strings)
195+
[ "$YAML_SHOW_RELEASE_INFO" = "true" ] && SHOW_RELEASE_INFO=true || SHOW_RELEASE_INFO=false
196+
[ "$YAML_SHOW_RELEASE_DETAIL" = "true" ] && SHOW_RELEASE_DETAIL=true || SHOW_RELEASE_DETAIL=false
197+
[ "$YAML_SHOW_IMPACT_ANALYSIS" = "true" ] && SHOW_IMPACT_ANALYSIS=true || SHOW_IMPACT_ANALYSIS=false
198+
[ "$YAML_SAVE_IMPACT_TO_FILE" = "true" ] && SAVE_IMPACT_TO_FILE=true || SAVE_IMPACT_TO_FILE=false
199+
[ "$YAML_VERBOSE" = "true" ] && VERBOSE=true || VERBOSE=false
200+
[ "$YAML_DEBUG" = "true" ] && DEBUG=true || DEBUG=false
201+
202+
# Parse arguments (command line arguments override YAML defaults)
203+
RUN_FLAG=""
130204
for arg in "$@"; do
131205
case "$arg" in
132206
-h|--help) show_help; exit 0 ;;
@@ -156,11 +230,8 @@ ${SCRIPT_DIR}/process-updates.php
156230
PROCESSOR_PHP=$(find_file_in_paths "$PROCESSOR_PATHS")
157231
[ -z "$PROCESSOR_PHP" ] && echo "$(get_msg processor_not_found)" >&2 && echo " $(get_msg please_install)" >&2 && exit 1
158232

159-
# Detect config file (delegates to helper)
160-
config_info=$(detect_config_file)
161-
CONFIG_FILE=$(echo "$config_info" | cut -d'|' -f1)
162-
CONFIG_FILE_DISPLAY=$(echo "$config_info" | cut -d'|' -f2)
163-
CONFIG_FILE_SUFFIX=$(echo "$config_info" | cut -d'|' -f3)
233+
# Config file already detected above (before parsing arguments)
234+
# CONFIG_FILE, CONFIG_FILE_DISPLAY, CONFIG_FILE_SUFFIX are already set
164235

165236
# Initialize language for translations after detecting config file
166237
if command -v t >/dev/null 2>&1 && command -v load_translations_sh >/dev/null 2>&1; then

bin/generate-composer-require.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,51 @@
1515
# When disabled (false), the tool will suggest all available updates without checking
1616
# dependency compatibility (faster but may suggest incompatible updates).
1717
# Default: true
18+
# Can be overridden with command line arguments
1819
check-dependencies: true
1920

21+
# Show release information by default
22+
# When enabled (true), shows release summary with links to GitHub releases and changelogs.
23+
# When disabled (false), no API calls are made for release information (faster execution).
24+
# Default: false
25+
# Can be overridden with --release-info, --release-detail, or --no-release-info
26+
show-release-info: false
27+
28+
# Show full release changelog by default
29+
# When enabled (true), shows full changelog for each package (implies show-release-info).
30+
# When disabled (false), only shows release summary if show-release-info is enabled.
31+
# Default: false
32+
# Can be overridden with --release-detail or --no-release-info
33+
show-release-detail: false
34+
35+
# Show impact analysis for conflicting packages by default
36+
# When enabled (true), shows which packages would be affected by updating conflicting packages.
37+
# When disabled (false), impact analysis is not shown (reduces output verbosity).
38+
# Default: false
39+
# Can be overridden with --show-impact, --impact, or --save-impact
40+
show-impact-analysis: false
41+
42+
# Save impact analysis to file by default
43+
# When enabled (true), saves impact analysis to composer-update-impact.txt (implies show-impact-analysis).
44+
# When disabled (false), impact analysis is only shown in output if show-impact-analysis is enabled.
45+
# Default: false
46+
# Can be overridden with --save-impact
47+
save-impact-to-file: false
48+
49+
# Verbose output by default
50+
# When enabled (true), shows detailed information including configuration files and packages.
51+
# When disabled (false), shows only essential information.
52+
# Default: false
53+
# Can be overridden with -v, --verbose, or --debug
54+
verbose: false
55+
56+
# Debug mode by default
57+
# When enabled (true), shows very detailed debug information including file paths and parsing details.
58+
# When disabled (false), debug information is not shown.
59+
# Default: false
60+
# Can be overridden with --debug
61+
debug: false
62+
2063
# Note: The following features are automatically enabled when check-dependencies is true:
2164
# - Abandoned Package Detection: Automatically detects and warns about abandoned packages
2265
# when they are filtered due to conflicts. Shows replacement package if available.

0 commit comments

Comments
 (0)