-
Notifications
You must be signed in to change notification settings - Fork 3
/
upgrade-to-4.4.php
executable file
·61 lines (53 loc) · 2.18 KB
/
upgrade-to-4.4.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
59
60
#!/usr/bin/php
<?php
require __DIR__.'/util/globrecursive.php';
if (is_file('vkwf_branch') || is_file('kwf_branch')) {
die("This script will update from 4.3, update to 4.3 first.\n");
}
if (!is_file('composer.json')) {
die("composer.json not found.\n");
}
$changed = false;
$c = json_decode(file_get_contents('composer.json'));
foreach ($c->require as $packageName=>$packageVersion) {
if (substr($packageVersion, 0, 4) == "4.3.") {
$c->require->$packageName = '4.4.x-dev';
$changed = true;
}
}
if (isset($c->require->{'koala-framework/kwf-reactjs'})) {
$c->require->{'koala-framework/kwf-reactjs'} = '1.1.x-dev';
}
if (!$changed) {
die("This script will update from 4.3, update to 4.3 first.\n");
}
file_put_contents('composer.json', json_encode($c, (defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0) + (defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0) ));
$usesMedialelement = false;
$files = array_merge(glob_recursive('*.php'), glob_recursive('*.ini'));
foreach ($files as $file) {
$c = file_get_contents($file);
$origC = $c;
$c = str_replace("Kwc_Advanced_VideoPlayer_", 'Mediaelement_Kwc_VideoPlayer_', $c);
$c = str_replace("Kwc_Advanced_AudioPlayer_", 'Mediaelement_Kwc_AudioPlayer_', $c);
if ($c != $origC) {
echo "Videoplayer and/or Audioplayer is used, change them to use Kwc_Mediaelement\n";
file_put_contents($file, $c);
$usesMedialelement = true;
}
}
if ($usesMedialelement) {
$c = json_decode(file_get_contents('composer.json'));
$updateComposerJson = true;
foreach ($c->require as $packageName=>$packageVersion) {
if ($packageName == "koala-framework/kwc-mediaelement") {
$updateComposerJson = false;
}
}
if ($updateComposerJson) {
$c->require->{'koala-framework/kwc-mediaelement'} = "1.0.x-dev";
echo "Added koala-framework/kwc-mediaelement to require composer.json\n";
file_put_contents('composer.json', json_encode($c, (defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0) + (defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 0) ));
}
}
echo "\n";
echo "run now 'composer update' to update dependencies\n";