@@ -27,25 +27,19 @@ $modified = [];
2727
2828// Locate each file and update it for the requested stability
2929
30- // Composer.json
3130$ file = __DIR__ . DIRECTORY_SEPARATOR . 'composer.json ' ;
3231
3332if (is_file ($ file )) {
34- // Make sure we can read it
3533 if ($ contents = file_get_contents ($ file )) {
3634 if ($ array = json_decode ($ contents , true )) {
37- // Development
3835 if ($ dev ) {
39- // Set 'minimum-stability'
4036 $ array ['minimum-stability ' ] = 'dev ' ;
4137 $ array ['prefer-stable ' ] = true ;
4238
43- // Make sure the repo is configured
4439 if (! isset ($ array ['repositories ' ])) {
4540 $ array ['repositories ' ] = [];
4641 }
4742
48- // Check for the CodeIgniter repo
4943 $ found = false ;
5044
5145 foreach ($ array ['repositories ' ] as $ repository ) {
@@ -55,45 +49,37 @@ if (is_file($file)) {
5549 }
5650 }
5751
58- // Add the repo if it was not found
5952 if (! $ found ) {
6053 $ array ['repositories ' ][] = [
6154 'type ' => 'vcs ' ,
6255 'url ' => GITHUB_URL ,
6356 ];
6457 }
6558
66- // Define the "require"
6759 $ array ['require ' ]['codeigniter4/codeigniter4 ' ] = 'dev-develop ' ;
6860 unset($ array ['require ' ]['codeigniter4/framework ' ]);
69- }
70-
71- // Release
72- else {
73- // Clear 'minimum-stability'
61+ } else {
7462 unset($ array ['minimum-stability ' ]);
7563
76- // If the repo is configured then clear it
7764 if (isset ($ array ['repositories ' ])) {
78- // Check for the CodeIgniter repo
7965 foreach ($ array ['repositories ' ] as $ i => $ repository ) {
8066 if ($ repository ['url ' ] === GITHUB_URL ) {
8167 unset($ array ['repositories ' ][$ i ]);
8268 break ;
8369 }
8470 }
71+
8572 if (empty ($ array ['repositories ' ])) {
8673 unset($ array ['repositories ' ]);
8774 }
8875 }
8976
90- // Define the "require"
9177 $ array ['require ' ]['codeigniter4/framework ' ] = LATEST_RELEASE ;
9278 unset($ array ['require ' ]['codeigniter4/codeigniter4 ' ]);
9379 }
9480
95- // Write out a new composer.json
9681 file_put_contents ($ file , json_encode ($ array , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . PHP_EOL );
82+
9783 $ modified [] = $ file ;
9884 } else {
9985 echo 'Warning: Unable to decode composer.json! Skipping... ' . PHP_EOL ;
@@ -103,7 +89,6 @@ if (is_file($file)) {
10389 }
10490}
10591
106- // Paths config and PHPUnit XMLs
10792$ files = [
10893 __DIR__ . DIRECTORY_SEPARATOR . 'app/Config/Paths.php ' ,
10994 __DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml.dist ' ,
@@ -114,17 +99,14 @@ foreach ($files as $file) {
11499 if (is_file ($ file )) {
115100 $ contents = file_get_contents ($ file );
116101
117- // Development
118102 if ($ dev ) {
119103 $ contents = str_replace ('vendor/codeigniter4/framework ' , 'vendor/codeigniter4/codeigniter4 ' , $ contents );
120- }
121-
122- // Release
123- else {
104+ } else {
124105 $ contents = str_replace ('vendor/codeigniter4/codeigniter4 ' , 'vendor/codeigniter4/framework ' , $ contents );
125106 }
126107
127108 file_put_contents ($ file , $ contents );
109+
128110 $ modified [] = $ file ;
129111 }
130112}
@@ -137,5 +119,6 @@ if (empty($modified)) {
137119 foreach ($ modified as $ file ) {
138120 echo " * {$ file }" . PHP_EOL ;
139121 }
140- echo 'Run `composer update` to sync changes with your vendor folder ' . PHP_EOL ;
122+
123+ echo 'Run `composer update` to sync changes with your vendor folder. ' . PHP_EOL ;
141124}
0 commit comments