|
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
|
|
|
* Updates the composer requirements to reflect the new version and package names |
|
10
|
|
|
* in the composer file of your module |
|
11
|
|
|
*/ |
|
12
|
|
|
class RemoveComposerRequirements extends Task |
|
13
|
|
|
{ |
|
14
|
|
|
protected $taskStep = 's20'; |
|
15
|
|
|
|
|
16
|
|
|
protected $packages = [ |
|
17
|
|
|
'silverstripe/recipe-cms', |
|
18
|
|
|
'silverstripe/admin', |
|
19
|
|
|
'silverstripe/assets', |
|
20
|
|
|
'silverstripe/config', |
|
21
|
|
|
'silverstripe/admin', |
|
22
|
|
|
|
|
23
|
|
|
'silverstripe/cms', |
|
24
|
|
|
'silverstripe/framework', |
|
25
|
|
|
'silverstripe/asset-admin', |
|
26
|
|
|
'silverstripe/campaign-admin', |
|
27
|
|
|
'silverstripe/errorpage', |
|
28
|
|
|
'silverstripe/graphql', |
|
29
|
|
|
'silverstripe/reports', |
|
30
|
|
|
'silverstripe/siteconfig', |
|
31
|
|
|
'silverstripe/versioned-admin', |
|
32
|
|
|
'silverstripe/versioned', |
|
33
|
|
|
'php', |
|
34
|
|
|
]; |
|
35
|
|
|
|
|
36
|
|
|
public function getTitle() |
|
37
|
|
|
{ |
|
38
|
|
|
return 'Remove composer.json requirements for basic packages like silverstripe/framework, silverstripe/admin, etc.'; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getDescription() |
|
42
|
|
|
{ |
|
43
|
|
|
return ' |
|
44
|
|
|
Remove requirements in composer.json file for |
|
45
|
|
|
' . (count($this->packages) ? implode(', ', $this->packages) : 'old packages - if any') . ' |
|
46
|
|
|
For example, we remove silverstripe/framework requirement from 3 to 4.'; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function runActualTask($params = []): ?string |
|
50
|
|
|
{ |
|
51
|
|
|
foreach ($this->packages as $package) { |
|
52
|
|
|
$command = 'unset($data["require"]["' . $package . '"]);'; |
|
53
|
|
|
|
|
54
|
|
|
$comment = 'remove the requirement for ' . $package . ' from ' . $this->mu()->getGitRootDir(); |
|
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
ComposerJsonFixes::inst($this->mu())->UpdateJSONViaCommandLine( |
|
57
|
|
|
$this->mu()->getGitRootDir(), |
|
58
|
|
|
$command, |
|
59
|
|
|
$comment |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
$this->setCommitMessage('API: remove composer requirements - removing requirements for: ' . implode(', ', $this->packages)); |
|
63
|
|
|
return null; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
protected function hasCommitAndPush() |
|
67
|
|
|
{ |
|
68
|
|
|
return true; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|