Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle non-symantic version strings
Browse files Browse the repository at this point in the history
AaronFeledy committed Oct 30, 2024
1 parent b7f8193 commit 1504875
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
* Set default `composer` version to `2.8.1`
* Set default `composer` version to `2.2.24` for PHP 5.3-7.2
* Set default `composer` version to `1.10.27` for PHP <= 5.2
* Fixed bug causing `composer` 2.2.x to be installed when `composer_version` was set to a single digit version such as `1`

## v1.6.0 - [October 25, 2024](https://github.com/lando/php/releases/tag/v1.6.0)

11 changes: 8 additions & 3 deletions builders/php.js
Original file line number Diff line number Diff line change
@@ -9,13 +9,18 @@ const addBuildStep = require('./../utils/add-build-step');
/**
* Get the appropriate Composer version based on the PHP version.
* @param {string} phpVersion - The PHP version.
* @return {string} - The Composer version.
* @return {string|boolean} - The Composer version or false if we cannot parse the version.
*/
const getDefaultComposerVersion = phpVersion => {
if (semver.lt(semver.coerce(phpVersion), '5.3.2')) {
phpVersion = semver.coerce(phpVersion);
// Don't set a default composer version if we cannot
// parse the version such as with `custom`.
if (!phpVersion) return false;

if (semver.lt(phpVersion, '5.3.2')) {
// Use Composer 1 for PHP < 5.3.2
return '1';
} else if (semver.lt(semver.coerce(phpVersion), '7.3.0')) {
} else if (semver.lt(phpVersion, '7.3.0')) {
// Use Composer 2.2 LTS for PHP < 7.3
return '2.2.24';
} else {
4 changes: 2 additions & 2 deletions examples/5.6/README.md
Original file line number Diff line number Diff line change
@@ -112,8 +112,8 @@ lando exec defaults -- curl http://localhost/path_info.php/a/b.php | grep SCRIPT
# Should allow cli services to specify a boot up command
lando info -s cliworker --deep | grep Cmd | grep sleep | grep infinity

# Should install the latest composer 2.2.x by default.
lando exec cliworker -- composer --version --no-ansi | tee >(cat 1>&2) | grep -q "Composer version 2.2."
# Should use preinstalled composer 1.x when composer_version is false
lando exec cliworker -- composer --version --no-ansi | tee >(cat 1>&2) | grep -q "Composer version 1."
```

## Destroy tests

0 comments on commit 1504875

Please sign in to comment.