1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks; |
4
|
|
|
|
5
|
|
|
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Helpers\ComposerJsonFixes; |
6
|
|
|
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Runs the silverstripe/upgrade task "recompose". See: |
10
|
|
|
* https://github.com/silverstripe/silverstripe-upgrader#recompose' |
11
|
|
|
*/ |
12
|
|
|
class RecomposeHomeBrew extends Task |
13
|
|
|
{ |
14
|
|
|
protected $taskStep = 's20'; |
15
|
|
|
|
16
|
|
|
protected $requireLinesToAdd = [ |
17
|
|
|
'silverstripe/recipe-cms' => '^4.4', |
18
|
|
|
]; |
19
|
|
|
|
20
|
|
|
public function getTitle() |
21
|
|
|
{ |
22
|
|
|
return 'Update composer.json to ' . $this->mu()->getFrameworkComposerRestraint() . ''; |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function getDescription() |
26
|
|
|
{ |
27
|
|
|
return ' |
28
|
|
|
Updates the requirements in the composer.json file without any extras. |
29
|
|
|
We may need to look at "project-files" here and make sure they do not get muddled up.'; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function runActualTask($params = []): ?string |
33
|
|
|
{ |
34
|
|
|
$command = ''; |
35
|
|
|
foreach ($this->requireLinesToAdd as $package => $constraint) { |
36
|
|
|
if ($constraint === '') { |
37
|
|
|
if ($package === 'silverstripe/recipe-cms') { |
38
|
|
|
$this->requireLinesToAdd[$package] = $this->mu()->getFrameworkComposerRestraint(); |
39
|
|
|
} else { |
40
|
|
|
$this->requireLinesToAdd[$package] = '*'; |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
foreach ($this->requireLinesToAdd as $key => $value) { |
45
|
|
|
$command .= |
46
|
|
|
'$data["require"]["' . $key . '"] = "' . $value . '"; '; |
47
|
|
|
} |
48
|
|
|
ComposerJsonFixes::inst($this->mu())->UpdateJSONViaCommandLine( |
49
|
|
|
$this->mu()->getGitRootDir(), |
|
|
|
|
50
|
|
|
$command, |
51
|
|
|
'adding cms recipe version: ' . $this->mu()->getFrameworkComposerRestraint() |
52
|
|
|
); |
53
|
|
|
$this->setCommitMessage('API: upgrading composer requirements to SS4 '); |
54
|
|
|
return null; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
protected function hasCommitAndPush() |
58
|
|
|
{ |
59
|
|
|
return true; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|