forked from mollie/Shopware6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch-composer.php
58 lines (43 loc) · 1.71 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
53
54
55
56
57
58
<?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.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-dev']["shopware/core"] = $swVersion;
$composerContent['require-dev']["shopware/administration"] = $swVersion;
$composerContent['require-dev']["shopware/storefront"] = $swVersion;
unset($composerContent['require']["shopware/core"]);
unset($composerContent['require']["shopware/administration"]);
unset($composerContent['require']["shopware/storefront"]);
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;
unset($composerContent['require-dev']["shopware/core"]);
unset($composerContent['require-dev']["shopware/administration"]);
unset($composerContent['require-dev']["shopware/storefront"]);
return $composerContent;
}