Making WordPress.org

Changeset 10693


Ignore:
Timestamp:
02/17/2021 10:22:02 PM (5 years ago)
Author:
coffee2code
Message:

Developer, CLI: Add ability to specify parsing of specific version of WP via --wp_ver argument.

Only taken into account if --src_path argument is not specified.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/cli-commands.php

    r10692 r10693  
    2222     * : ID of user to attribute all parsed posts to. Default is 5911429, the ID for wordpressdotorg.
    2323     *
     24     * [--wp_ver=<wp_ver>]
     25     * : Version of WordPress to install. Only taken into account if --src_path is
     26     * not defined. Default is the latest release (or whatever version is present
     27     * in --src_path if that is defined).
     28     *
    2429     * ## EXAMPLES
    2530     *
    26      *     # Parse lastest WP.
     31     *     # Parse latest WP.
    2732     *     $ wp devhub parse
    2833     *
    2934     *     # Parse specific copy of WP.
    3035     *     $ wp devhub parse --src_path=/path/to/wordpress
     36     *
     37     *     # Parse a particular version of WP.
     38     *     $ wp evhub parse --wp_ver=5.5.2
    3139     *
    3240     * @when after_wp_load
     
    3442    public function parse( $args, $assoc_args ) {
    3543        $path = $assoc_args['src_path'] ?? null;
     44        $wp_ver = $assoc_args['wp_ver'] ?? null;
    3645
    3746        // Verify path is a file or directory.
     
    4251                WP_CLI::error( 'Provided path for WordPress source to parse does not exist.' );
    4352            }
    44          }
    45  
     53        }
     54
    4655        // If no path provided, use a temporary path.
    4756        if ( ! $path ) {
    4857            $path = WP_CLI\Utils\get_temp_dir() . 'devhub_' . time();
    49      
     58
    5059            // @todo Attempt to reuse an existing temp dir.
    5160            if ( mkdir( $path ) ) {
    52                 WP_CLI::log( "Installing latest WordPress into temporary directory ({$path})..." );
     61                if ( $wp_ver ) {
     62                    WP_CLI::log( "Installing WordPress {$wp_ver} into temporary directory ({$path})..." );
     63                } else {
     64                    WP_CLI::log( "Installing latest WordPress into temporary directory ({$path})..." );
     65                }
    5366                $cmd = "core download --path={$path}";
     67                if ( $wp_ver ) {
     68                    $cmd .= " --version={$wp_ver}";
     69                }
    5470                // Install WP into the temp directory.
    5571                WP_CLI::runcommand( $cmd, [] );
     
    5874            }
    5975        }
    60      
     76
    6177        if ( ! $path ) {
    6278            WP_CLI::error( 'Unable to create temporary directory for downloading WordPress. If retrying fails, consider obtaining the files manually and supplying that path via --src_path argument.' );
Note: See TracChangeset for help on using the changeset viewer.