-
Notifications
You must be signed in to change notification settings - Fork 53
/
switch-composer.php
52 lines (39 loc) · 1.47 KB
/
switch-composer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
$env = (count($argv) >= 2) ? (string)$argv[1] : '';
$composerContent = file_get_contents(__DIR__ . '/composer.json');
$composerContent = json_decode($composerContent, true);
// >= 6.4.0.0
const SW_VERSIONS_RELEASE = '6.4.5.0 - 6.7.0.0';
const SW_VERSIONS_DEV = '*';
if ($env === 'prod') {
$composerContent = moveToProd($composerContent, SW_VERSIONS_RELEASE);
} else {
$composerContent = moveToDev($composerContent, SW_VERSIONS_DEV);
}
file_put_contents(__DIR__ . '/composer.json', json_encode($composerContent, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
/**
* @param array $composerContent
* @param string $swVersion
* @return array
*/
function moveToDev(array $composerContent, string $swVersion)
{
$composerContent['require']["shopware/core"] = $swVersion;
$composerContent['require']["shopware/administration"] = $swVersion;
$composerContent['require']["shopware/storefront"] = $swVersion;
$composerContent['require']["shopware/elasticsearch"] = $swVersion;
return $composerContent;
}
/**
* @param array $composerContent
* @param string $swVersion
* @return array
*/
function moveToProd(array $composerContent, string $swVersion)
{
$composerContent['require']["shopware/core"] = $swVersion;
$composerContent['require']["shopware/administration"] = $swVersion;
$composerContent['require']["shopware/storefront"] = $swVersion;
$composerContent['require']["shopware/elasticsearch"] = $swVersion;
return $composerContent;
}