Skip to content

Commit 18effbe

Browse files
authored
Merge pull request #211 from wp-cli/copilot/add-skip-update-check-flag
2 parents 08e3dbb + 6473d10 commit 18effbe

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

features/package.feature

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,26 @@ Feature: Manage WP-CLI packages
208208
"""
209209
{NO_SUCH_PACKAGE_COMPOSER_JSON}
210210
"""
211+
212+
Scenario: List packages with --skip-update-check flag
213+
Given an empty directory
214+
215+
When I run `wp package install runcommand/hook`
216+
Then STDERR should be empty
217+
218+
When I run `wp package list --skip-update-check --fields=name,update,update_version`
219+
Then STDOUT should contain:
220+
"""
221+
runcommand/hook
222+
"""
223+
And STDOUT should contain:
224+
"""
225+
none
226+
"""
227+
And STDOUT should not contain:
228+
"""
229+
available
230+
"""
231+
232+
When I run `wp package uninstall runcommand/hook`
233+
Then STDERR should be empty

src/Package_Command.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,9 @@ public function install( $args, $assoc_args ) {
434434
* - yaml
435435
* ---
436436
*
437+
* [--skip-update-check]
438+
* : Skip checking for updates. This is faster and avoids authentication issues with GitHub or Composer repositories.
439+
*
437440
* ## AVAILABLE FIELDS
438441
*
439442
* These fields will be displayed by default for each package:
@@ -458,6 +461,14 @@ public function install( $args, $assoc_args ) {
458461
* | wp-cli/server-command | Daniel Bachhuber | dev-main | available | 2.x-dev |
459462
* +-----------------------+------------------+----------+-----------+----------------+
460463
*
464+
* # List installed packages without checking for updates.
465+
* $ wp package list --skip-update-check
466+
* +-----------------------+------------------+----------+--------+----------------+
467+
* | name | authors | version | update | update_version |
468+
* +-----------------------+------------------+----------+--------+----------------+
469+
* | wp-cli/server-command | Daniel Bachhuber | dev-main | none | |
470+
* +-----------------------+------------------+----------+--------+----------------+
471+
*
461472
* @subcommand list
462473
*/
463474
public function list_( $args, $assoc_args ) {
@@ -757,8 +768,9 @@ private function show_packages( $context, $packages, $assoc_args ) {
757768
];
758769
$assoc_args = array_merge( $defaults, $assoc_args );
759770

760-
$composer = $this->get_composer();
761-
$list = [];
771+
$skip_update_check = Utils\get_flag_value( $assoc_args, 'skip-update-check', false );
772+
$composer = $this->get_composer();
773+
$list = [];
762774
foreach ( $packages as $package ) {
763775
$name = $package->getPrettyName();
764776
if ( isset( $list[ $name ] ) ) {
@@ -771,7 +783,7 @@ private function show_packages( $context, $packages, $assoc_args ) {
771783
$package_output['version'] = [ $package->getPrettyVersion() ];
772784
$update = 'none';
773785
$update_version = '';
774-
if ( 'list' === $context ) {
786+
if ( 'list' === $context && ! $skip_update_check ) {
775787
try {
776788
$latest = $this->find_latest_package( $package, $composer, null );
777789
if ( $latest && $latest->getFullPrettyVersion() !== $package->getFullPrettyVersion() ) {

0 commit comments

Comments
 (0)