Passed
Push — dev5 ( a3bb6d...a23557 )
by Ron
07:18
created
app/Console/Commands/updateRun.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
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
             //  Open up the file and verify it is at least the same version as the current setup
53 53
             $valid = $this->openUpdate($updateFile);
54 54
 
55
-            if ($valid) {
55
+            if($valid) {
56 56
                 $this->call('down');
57 57
                 $this->copyFiles($updateFile);
58 58
 
@@ -71,37 +71,37 @@  discard block
 block discarded – undo
71 71
         $updates    = Storage::disk('staging')->files('updates');
72 72
 
73 73
         //  Cycle through each file in the update directory to see if they are update files
74
-        foreach ($updates as $update) {
74
+        foreach($updates as $update) {
75 75
             $baseName = explode('/', $update)[1];
76 76
 
77 77
             //  Verify the file is in the .zip format
78 78
             $fileParts = pathinfo($baseName);
79
-            if ($fileParts['extension'] == 'zip') {
79
+            if($fileParts['extension'] == 'zip') {
80 80
                 //  Verify this is actually an update file
81
-                $zip = Zip::open(config('filesystems.disks.staging.root') .
82
-                    DIRECTORY_SEPARATOR . 'updates' . DIRECTORY_SEPARATOR . $baseName);
81
+                $zip = Zip::open(config('filesystems.disks.staging.root').
82
+                    DIRECTORY_SEPARATOR.'updates'.DIRECTORY_SEPARATOR.$baseName);
83 83
                 $files = $zip->listFiles();
84
-                if (in_array($fileParts['filename'] . '/config/version.yml', $files)) {
84
+                if(in_array($fileParts['filename'].'/config/version.yml', $files)) {
85 85
                     $updateList[] = $baseName;
86 86
                 }
87 87
             }
88 88
         }
89 89
 
90
-        if (empty($updateList)) {
90
+        if(empty($updateList)) {
91 91
             $this->error('No updates have been loaded to the system');
92 92
             $this->error('Please upload update package to the Storage/Staging/Updates folder');
93 93
             return false;
94 94
         }
95 95
 
96 96
         //  Determine if there is more than one update that can be applied
97
-        if (count($updateList) > 1) {
97
+        if(count($updateList) > 1) {
98 98
             $this->line('');
99 99
 
100 100
             $anticipate = [];
101
-            foreach ($updateList as $key => $up) {
101
+            foreach($updateList as $key => $up) {
102 102
                 $opt = $key + 1;
103 103
                 $anticipate[$opt] = $up;
104
-                $this->line('[' . $opt . '] ' . $up);
104
+                $this->line('['.$opt.'] '.$up);
105 105
             }
106 106
             $updateFile = $this->choice('Please select which update you would like to load', $anticipate);
107 107
         } else {
@@ -117,25 +117,25 @@  discard block
 block discarded – undo
117 117
         $fileParts = pathinfo($file);
118 118
         $folder = $fileParts['filename'];
119 119
 
120
-        $zip = Zip::open(config('filesystems.disks.staging.root') .
121
-            DIRECTORY_SEPARATOR . 'updates' . DIRECTORY_SEPARATOR . $file);
120
+        $zip = Zip::open(config('filesystems.disks.staging.root').
121
+            DIRECTORY_SEPARATOR.'updates'.DIRECTORY_SEPARATOR.$file);
122 122
 
123
-        $zip->extract(config('filesystems.disks.staging.root') .
124
-            DIRECTORY_SEPARATOR . 'updates' . DIRECTORY_SEPARATOR . 'tmp');
123
+        $zip->extract(config('filesystems.disks.staging.root').
124
+            DIRECTORY_SEPARATOR.'updates'.DIRECTORY_SEPARATOR.'tmp');
125 125
         $zip->close();
126 126
 
127
-        $verFile = fopen(config('filesystems.disks.staging.root') .
128
-            DIRECTORY_SEPARATOR . 'updates' . DIRECTORY_SEPARATOR . 'tmp' .
129
-            DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . 'config' .
130
-            DIRECTORY_SEPARATOR . 'version.yml', 'r');
127
+        $verFile = fopen(config('filesystems.disks.staging.root').
128
+            DIRECTORY_SEPARATOR.'updates'.DIRECTORY_SEPARATOR.'tmp'.
129
+            DIRECTORY_SEPARATOR.$folder.DIRECTORY_SEPARATOR.'config'.
130
+            DIRECTORY_SEPARATOR.'version.yml', 'r');
131 131
 
132 132
         $verData = [];
133 133
         $i = 0;
134
-        while (!feof($verFile)) {
134
+        while(!feof($verFile)) {
135 135
             $line = fgets($verFile);
136 136
             $data = explode(':', $line);
137 137
 
138
-            if (($data[0] === '  major' || $data[0] === '  minor' || $data[0] === '  patch') && $i < 3) {
138
+            if(($data[0] === '  major' || $data[0] === '  minor' || $data[0] === '  patch') && $i < 3) {
139 139
                 $verData[trim($data[0])] = trim($data[1]);
140 140
                 $i++;
141 141
             }
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
         $curVersion = new \PragmaRX\Version\Package\Version();
145 145
 
146 146
         $valid = false;
147
-        if ($verData['major'] > $curVersion->major()) {
147
+        if($verData['major'] > $curVersion->major()) {
148 148
             $valid = true;
149
-        } else if ($verData['minor'] > $curVersion->minor()) {
149
+        } else if($verData['minor'] > $curVersion->minor()) {
150 150
             $valid = true;
151
-        } else if ($verData['patch'] >= $curVersion->patch()) {
151
+        } else if($verData['patch'] >= $curVersion->patch()) {
152 152
             $valid = true;
153 153
         }
154 154
 
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
         $fileParts = pathinfo($updateFile);
162 162
         $folder = $fileParts['filename'];
163 163
 
164
-        $updateFile = config('filesystems.disks.staging.root') .
165
-            DIRECTORY_SEPARATOR . 'updates' . DIRECTORY_SEPARATOR . 'tmp' .
166
-            DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR;
164
+        $updateFile = config('filesystems.disks.staging.root').
165
+            DIRECTORY_SEPARATOR.'updates'.DIRECTORY_SEPARATOR.'tmp'.
166
+            DIRECTORY_SEPARATOR.$folder.DIRECTORY_SEPARATOR;
167 167
 
168 168
         // Copy files
169
-        File::copyDirectory($updateFile . 'app',       base_path() . DIRECTORY_SEPARATOR . 'app');
170
-        File::copyDirectory($updateFile . 'bootstrap', base_path() . DIRECTORY_SEPARATOR . 'bootstrap');
171
-        File::copyDirectory($updateFile . 'config',    base_path() . DIRECTORY_SEPARATOR . 'config');
172
-        File::copyDirectory($updateFile . 'database',  base_path() . DIRECTORY_SEPARATOR . 'database');
173
-        File::copyDirectory($updateFile . 'resources', base_path() . DIRECTORY_SEPARATOR . 'resources');
174
-        File::copyDirectory($updateFile . 'routes',    base_path() . DIRECTORY_SEPARATOR . 'routes');
169
+        File::copyDirectory($updateFile.'app', base_path().DIRECTORY_SEPARATOR.'app');
170
+        File::copyDirectory($updateFile.'bootstrap', base_path().DIRECTORY_SEPARATOR.'bootstrap');
171
+        File::copyDirectory($updateFile.'config', base_path().DIRECTORY_SEPARATOR.'config');
172
+        File::copyDirectory($updateFile.'database', base_path().DIRECTORY_SEPARATOR.'database');
173
+        File::copyDirectory($updateFile.'resources', base_path().DIRECTORY_SEPARATOR.'resources');
174
+        File::copyDirectory($updateFile.'routes', base_path().DIRECTORY_SEPARATOR.'routes');
175 175
 
176 176
         //  Run Composer Updates
177
-        exec('cd ' . base_path() . ' && composer install --no-dev --no-interaction --optimize-autoloader --no-ansi');
177
+        exec('cd '.base_path().' && composer install --no-dev --no-interaction --optimize-autoloader --no-ansi');
178 178
         // exec('cd'.base_path().  ' && ziggy:generate');
179 179
         $this->call('ziggy:generate');
180 180
         //  Run NPM
Please login to merge, or discard this patch.
Braces   +34 added lines, -15 removed lines patch added patch discarded remove patch
@@ -48,16 +48,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.