@@ -48,16 +48,20 @@ discard block |
||
48 | 48 | $this->line(''); |
49 | 49 | // Select which update file to use |
50 | 50 | $updateFile = $this->checkForUpdate(); |
51 | - if ($updateFile) { |
|
51 | + if ($updateFile) |
|
52 | + { |
|
52 | 53 | // Open up the file and verify it is at least the same version as the current setup |
53 | 54 | $valid = $this->openUpdate($updateFile); |
54 | 55 | |
55 | - if ($valid) { |
|
56 | + if ($valid) |
|
57 | + { |
|
56 | 58 | $this->call('down'); |
57 | 59 | $this->copyFiles($updateFile); |
58 | 60 | |
59 | 61 | $this->info('Update Completed'); |
60 | - } else { |
|
62 | + } |
|
63 | + else |
|
64 | + { |
|
61 | 65 | $this->error('The selected update is not a newer version'); |
62 | 66 | $this->error('Cannot downgrade Tech Bench in this manner'); |
63 | 67 | } |
@@ -71,40 +75,48 @@ discard block |
||
71 | 75 | $updates = Storage::disk('staging')->files('updates'); |
72 | 76 | |
73 | 77 | // Cycle through each file in the update directory to see if they are update files |
74 | - foreach ($updates as $update) { |
|
78 | + foreach ($updates as $update) |
|
79 | + { |
|
75 | 80 | $baseName = explode('/', $update)[1]; |
76 | 81 | |
77 | 82 | // Verify the file is in the .zip format |
78 | 83 | $fileParts = pathinfo($baseName); |
79 | - if ($fileParts['extension'] == 'zip') { |
|
84 | + if ($fileParts['extension'] == 'zip') |
|
85 | + { |
|
80 | 86 | // Verify this is actually an update file |
81 | 87 | $zip = Zip::open(config('filesystems.disks.staging.root') . |
82 | 88 | DIRECTORY_SEPARATOR . 'updates' . DIRECTORY_SEPARATOR . $baseName); |
83 | 89 | $files = $zip->listFiles(); |
84 | - if (in_array($fileParts['filename'] . '/config/version.yml', $files)) { |
|
90 | + if (in_array($fileParts['filename'] . '/config/version.yml', $files)) |
|
91 | + { |
|
85 | 92 | $updateList[] = $baseName; |
86 | 93 | } |
87 | 94 | } |
88 | 95 | } |
89 | 96 | |
90 | - if (empty($updateList)) { |
|
97 | + if (empty($updateList)) |
|
98 | + { |
|
91 | 99 | $this->error('No updates have been loaded to the system'); |
92 | 100 | $this->error('Please upload update package to the Storage/Staging/Updates folder'); |
93 | 101 | return false; |
94 | 102 | } |
95 | 103 | |
96 | 104 | // Determine if there is more than one update that can be applied |
97 | - if (count($updateList) > 1) { |
|
105 | + if (count($updateList) > 1) |
|
106 | + { |
|
98 | 107 | $this->line(''); |
99 | 108 | |
100 | 109 | $anticipate = []; |
101 | - foreach ($updateList as $key => $up) { |
|
110 | + foreach ($updateList as $key => $up) |
|
111 | + { |
|
102 | 112 | $opt = $key + 1; |
103 | 113 | $anticipate[$opt] = $up; |
104 | 114 | $this->line('[' . $opt . '] ' . $up); |
105 | 115 | } |
106 | 116 | $updateFile = $this->choice('Please select which update you would like to load', $anticipate); |
107 | - } else { |
|
117 | + } |
|
118 | + else |
|
119 | + { |
|
108 | 120 | $updateFile = $updateList[0]; |
109 | 121 | } |
110 | 122 | |
@@ -131,11 +143,13 @@ discard block |
||
131 | 143 | |
132 | 144 | $verData = []; |
133 | 145 | $i = 0; |
134 | - while (!feof($verFile)) { |
|
146 | + while (!feof($verFile)) |
|
147 | + { |
|
135 | 148 | $line = fgets($verFile); |
136 | 149 | $data = explode(':', $line); |
137 | 150 | |
138 | - if (($data[0] === ' major' || $data[0] === ' minor' || $data[0] === ' patch') && $i < 3) { |
|
151 | + if (($data[0] === ' major' || $data[0] === ' minor' || $data[0] === ' patch') && $i < 3) |
|
152 | + { |
|
139 | 153 | $verData[trim($data[0])] = trim($data[1]); |
140 | 154 | $i++; |
141 | 155 | } |
@@ -144,11 +158,16 @@ discard block |
||
144 | 158 | $curVersion = new \PragmaRX\Version\Package\Version(); |
145 | 159 | |
146 | 160 | $valid = false; |
147 | - if ($verData['major'] > $curVersion->major()) { |
|
161 | + if ($verData['major'] > $curVersion->major()) |
|
162 | + { |
|
148 | 163 | $valid = true; |
149 | - } else if ($verData['minor'] > $curVersion->minor()) { |
|
164 | + } |
|
165 | + else if ($verData['minor'] > $curVersion->minor()) |
|
166 | + { |
|
150 | 167 | $valid = true; |
151 | - } else if ($verData['patch'] >= $curVersion->patch()) { |
|
168 | + } |
|
169 | + else if ($verData['patch'] >= $curVersion->patch()) |
|
170 | + { |
|
152 | 171 | $valid = true; |
153 | 172 | } |
154 | 173 |