Skip to content

Commit

Permalink
Merge pull request #68 from creative-commoners/pulls/1.9/phpversions
Browse files Browse the repository at this point in the history
FIX Update phpversions
  • Loading branch information
GuySartorelli authored Sep 18, 2023
2 parents e38a142 + 32e2b6d commit 3e51107
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
15 changes: 15 additions & 0 deletions consts.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
'8.1',
'8.2',
],
'5.1' => [
'8.1',
'8.2',
],
'5' => [
'8.1',
'8.2',
Expand Down Expand Up @@ -59,6 +63,17 @@
'recipe-blog',
];

// lockstepped repos that are "three less" e.g. silverstripe/admin 1 is for CMS 4
const LOCKSTEPPED_REPOS_VERSION_IS_THREE_LESS = [
'silverstripe-admin',
'silverstripe-asset-admin',
'silverstripe-assets',
'silverstripe-campaign-admin',
'silverstripe-errorpage',
'silverstripe-versioned',
'silverstripe-versioned-admin',
];

// Repositories that do not require silverstripe/installer to be explicitly added as a dependency for testing
const NO_INSTALLER_LOCKSTEPPED_REPOS = [
// these are/include recipe-cms or recipe-core, so we don't want to composer require installer
Expand Down
19 changes: 19 additions & 0 deletions job_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@ public function getInstallerVersion(): string
}
}
}
// has a lockstepped .x-dev requirement in composer.json
if (file_exists($this->composerJsonPath)) {
$json = json_decode(file_get_contents($this->composerJsonPath));
foreach (LOCKSTEPPED_REPOS as $lockedSteppedRepo) {
$composerRepo = 'silverstripe/' . str_replace('silverstripe-', '', $lockedSteppedRepo);
if (isset($json->require->{$composerRepo})) {
$version = $json->require->{$composerRepo};
if (preg_match('#^([0-9\.]+)\.x\-dev$#', $version, $matches)) {
$versionNumber = $matches[1];
// If the lockstepped dependency is "three less" (e.g. silverstripe/admin is 3 major
// versions behind silverstripe/installer), account for that here.
if (in_array($lockedSteppedRepo, LOCKSTEPPED_REPOS_VERSION_IS_THREE_LESS)) {
$versionNumber += 3;
}
return $versionNumber . '.x-dev';
}
}
}
}
// fallback to use the next-minor or latest-minor version of installer
$installerVersions = array_keys(INSTALLER_TO_PHP_VERSIONS);
$installerVersions = array_filter($installerVersions, fn($version) => substr($version, 0, 1) === $cmsMajor);
Expand Down
8 changes: 4 additions & 4 deletions tests/JobCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,11 @@ public function provideGetInstallerVersionCMS5FromComposer(): array
['myaccount/silverstripe-framework', '5', [], '5.x-dev'],
['myaccount/silverstripe-framework', '5.10', [], '5.10.x-dev'],
// fallback to looking at deps in composer.json, use current minor of installer .x-dev
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.x-dev'], '5.0.x-dev'],
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.x-dev'], '5.x-dev'],
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '5.0.x-dev'], '5.0.x-dev'],
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '^5'], '5.0.x-dev'],
['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/cms' => '^5'], '5.0.x-dev'],
['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/admin' => '^2'], '5.0.x-dev'],
['myaccount/silverstripe-admin', 'mybranch', ['silverstripe/framework' => '^5'], '5.1.x-dev'],
['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/cms' => '^5'], '5.1.x-dev'],
['myaccount/silverstripe-somemodule', 'mybranch', ['silverstripe/admin' => '^2'], '5.1.x-dev'],
['myaccount/silverstripe-somemodule', '3', ['silverstripe/framework' => '^5'], '5.x-dev'],
];
}
Expand Down

0 comments on commit 3e51107

Please sign in to comment.