Fixes related to Jetpack Autoloader 2.0 package bump (https://github.com/woocommerce/woocommerce-blocks/pull/2949)

* regenerate auto load maps after version change.

* make sure composer.json is updated with version change for deploys (also necessary for correct auto-load map regeneration)

* update WC tested up to string

* Detect if `JETPACK_AUTOLOAD_DEV` is defined in `wp-config.php` when developing the plugin.
This commit is contained in:
Darren Ethier 2020-08-03 06:11:46 -04:00 committed by GitHub
parent 3d0d6cab87
commit aebedc9930
3 changed files with 45 additions and 2 deletions

View File

@ -107,9 +107,11 @@ if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" != "y" ]; then
fi
# Version changes
output 2 "Updating version numbers in files (note pre-releases will not have the readme.txt stable tag updated)..."
output 2 "Updating version numbers in files and regenerating php autoload classmap (note pre-releases will not have the readme.txt stable tag updated)..."
source $RELEASER_PATH/bin/version-changes.sh
composer dump-autoload
output 2 "Committing version change..."
echo

View File

@ -17,3 +17,6 @@ perl -i -pe 's/"version":*.+/"version": "'${VERSION}'",/' package.json
# Update version in src/Package.php
perl -i -pe "s/version \= '*.+';/version = '${VERSION}';/" src/Package.php
# Add version to composer.json
perl -i -pe 's/"type":*.+/"type":"wordpress-plugin",\n\t"version": "'${VERSION}'",/' composer.json

View File

@ -10,7 +10,7 @@
* Requires at least: 5.2
* Requires PHP: 5.6
* WC requires at least: 4.0
* WC tested up to: 4.2
* WC tested up to: 4.4
*
* @package WooCommerce\Blocks
* @internal This file is only used when running as a feature plugin.
@ -64,6 +64,44 @@ if ( version_compare( $GLOBALS['wp_version'], $minimum_wp_version, '<' ) ) {
return;
}
/**
* Returns whether the current version is a development version
* Note this relies on composer.json version, not plugin version.
* Development installs of the plugin don't have a version defined in
* composer json.
*
* @return bool True means the current version is a development version.
*/
function woocommerce_blocks_is_development_version() {
$composer_file = __DIR__ . '/composer.json';
if ( ! is_readable( $composer_file ) ) {
return false;
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- including local file
$composer_config = json_decode( file_get_contents( $composer_file ), true );
return ! isset( $composer_config['version'] );
}
/**
* If development version is detected and the Jetpack constant is not defined, show a notice.
*/
if ( woocommerce_blocks_is_development_version() && ! defined( 'JETPACK_AUTOLOAD_DEV' ) ) {
add_action(
'admin_notices',
function() {
echo '<div class="error"><p>';
printf(
/* Translators: %1$s is referring to a php constant name, %2$s is referring to the wp-config.php file. */
esc_html__( 'WooCommerce Blocks development mode requires the %1$s constant to be defined and true in your %2$s file. Otherwise you are loading the blocks package from WooCommerce core.', 'woo-gutenberg-products-block' ),
'JETPACK_AUTOLOAD_DEV',
'wp-config.php'
);
echo '</p></div>';
}
);
}
/**
* Autoload packages.
*