Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions features/package.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 15 additions & 3 deletions src/Package_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 ) {
Expand Down Expand Up @@ -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 ] ) ) {
Expand All @@ -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() ) {
Expand Down