diff --git a/features/package.feature b/features/package.feature index a45218b4..28af2053 100644 --- a/features/package.feature +++ b/features/package.feature @@ -208,3 +208,26 @@ Feature: Manage WP-CLI packages """ {NO_SUCH_PACKAGE_COMPOSER_JSON} """ + + Scenario: List packages with --skip-update-check flag + Given an empty directory + + When I run `wp package install runcommand/hook` + Then STDERR should be empty + + When I run `wp package list --skip-update-check --fields=name,update,update_version` + Then STDOUT should contain: + """ + runcommand/hook + """ + And STDOUT should contain: + """ + none + """ + And STDOUT should not contain: + """ + available + """ + + When I run `wp package uninstall runcommand/hook` + Then STDERR should be empty diff --git a/src/Package_Command.php b/src/Package_Command.php index 9e13c0d6..e6f8273c 100644 --- a/src/Package_Command.php +++ b/src/Package_Command.php @@ -434,6 +434,9 @@ public function install( $args, $assoc_args ) { * - yaml * --- * + * [--skip-update-check] + * : Skip checking for updates. This is faster and avoids authentication issues with GitHub or Composer repositories. + * * ## AVAILABLE FIELDS * * These fields will be displayed by default for each package: @@ -458,6 +461,14 @@ public function install( $args, $assoc_args ) { * | wp-cli/server-command | Daniel Bachhuber | dev-main | available | 2.x-dev | * +-----------------------+------------------+----------+-----------+----------------+ * + * # List installed packages without checking for updates. + * $ wp package list --skip-update-check + * +-----------------------+------------------+----------+--------+----------------+ + * | name | authors | version | update | update_version | + * +-----------------------+------------------+----------+--------+----------------+ + * | wp-cli/server-command | Daniel Bachhuber | dev-main | none | | + * +-----------------------+------------------+----------+--------+----------------+ + * * @subcommand list */ public function list_( $args, $assoc_args ) { @@ -757,8 +768,9 @@ private function show_packages( $context, $packages, $assoc_args ) { ]; $assoc_args = array_merge( $defaults, $assoc_args ); - $composer = $this->get_composer(); - $list = []; + $skip_update_check = Utils\get_flag_value( $assoc_args, 'skip-update-check', false ); + $composer = $this->get_composer(); + $list = []; foreach ( $packages as $package ) { $name = $package->getPrettyName(); if ( isset( $list[ $name ] ) ) { @@ -771,7 +783,7 @@ private function show_packages( $context, $packages, $assoc_args ) { $package_output['version'] = [ $package->getPrettyVersion() ]; $update = 'none'; $update_version = ''; - if ( 'list' === $context ) { + if ( 'list' === $context && ! $skip_update_check ) { try { $latest = $this->find_latest_package( $package, $composer, null ); if ( $latest && $latest->getFullPrettyVersion() !== $package->getFullPrettyVersion() ) {