Skip to content

Commit 8df3766

Browse files
committed
Merge branch 'kirtangajjar-add-check-update-function' into develop-v4
2 parents 67b4404 + 94b94f8 commit 8df3766

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

php/commands/src/CLI_Command.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,72 @@ private function migrate() {
166166

167167
}
168168

169+
/**
170+
* Check to see if there is a newer version of EE available.
171+
*
172+
* Queries the Github releases API. Returns available versions if there are
173+
* updates available, or success message if using the latest release.
174+
*
175+
* ## OPTIONS
176+
*
177+
* [--patch]
178+
* : Only list patch updates.
179+
*
180+
* [--minor]
181+
* : Only list minor updates.
182+
*
183+
* [--major]
184+
* : Only list major updates.
185+
*
186+
* [--field=<field>]
187+
* : Prints the value of a single field for each update.
188+
*
189+
* [--fields=<fields>]
190+
* : Limit the output to specific object fields. Defaults to version,update_type,package_url.
191+
*
192+
* [--format=<format>]
193+
* : Render output in a particular format.
194+
* ---
195+
* default: table
196+
* options:
197+
* - table
198+
* - csv
199+
* - json
200+
* - count
201+
* - yaml
202+
* ---
203+
*
204+
* ## EXAMPLES
205+
*
206+
* # Check for update.
207+
* $ ee cli check-update
208+
* Success: EE is at the latest version.
209+
*
210+
* # Check for update and new version is available.
211+
* $ ee cli check-update
212+
* +---------+-------------+------------------------------------------------------------------------------------------+
213+
* | version | update_type | package_url |
214+
* +---------+-------------+------------------------------------------------------------------------------------------+
215+
* | 0.24.1 | patch | https://github.com/EasyEngine/easyengine/releases/download/v4.0.0-beta.1/easyengine.phar |
216+
* +---------+-------------+------------------------------------------------------------------------------------------+
217+
*
218+
* @subcommand check-update
219+
*/
220+
public function check_update( $_, $assoc_args ) {
221+
$updates = $this->get_updates( $assoc_args );
222+
223+
if ( $updates ) {
224+
$formatter = new \EE\Formatter(
225+
$assoc_args,
226+
array( 'version', 'update_type', 'package_url' )
227+
);
228+
$formatter->display_items( $updates );
229+
} elseif ( empty( $assoc_args['format'] ) || 'table' == $assoc_args['format'] ) {
230+
$update_type = $this->get_update_type_str( $assoc_args );
231+
EE::success( "EasyEngine is at the latest{$update_type}version." );
232+
}
233+
}
234+
169235
/**
170236
* Update EE to the latest release.
171237
*

0 commit comments

Comments
 (0)