-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not download vendor JS files in released plugin versions
- Loading branch information
Showing
6 changed files
with
222 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* Generates the production (plugin build) version of `gutenberg.php`, | ||
* containing alternate `define` statements from the development version. | ||
* | ||
* @package gutenberg-build | ||
*/ | ||
|
||
$f = fopen( dirname( dirname( __FILE__ ) ) . '/gutenberg.php', 'r' ); | ||
|
||
$plugin_version = null; | ||
$inside_defines = false; | ||
|
||
/** | ||
* Prints `define` statements for the production version of `gutenberg.php` | ||
* (the plugin entry point). | ||
*/ | ||
function print_production_defines() { | ||
global $plugin_version; | ||
|
||
echo "define( 'GUTENBERG_VERSION', '$plugin_version' );\n"; | ||
|
||
$git_commit = trim( shell_exec( 'git rev-parse HEAD' ) ); | ||
|
||
echo "define( 'GUTENBERG_GIT_COMMIT', '$git_commit' );\n"; | ||
} | ||
|
||
while ( true ) { | ||
$line = fgets( $f ); | ||
if ( false === $line ) { | ||
break; | ||
} | ||
|
||
if ( | ||
! $plugin_version && | ||
preg_match( '@^\s*\*\s*Version:\s*([0-9.]+)@', $line, $matches ) | ||
) { | ||
$plugin_version = $matches[1]; | ||
} | ||
|
||
switch ( trim( $line ) ) { | ||
case '### BEGIN AUTO-GENERATED DEFINES': | ||
$inside_defines = true; | ||
echo $line; | ||
print_production_defines(); | ||
break; | ||
|
||
case '### END AUTO-GENERATED DEFINES': | ||
$inside_defines = false; | ||
echo $line; | ||
break; | ||
|
||
default: | ||
if ( ! $inside_defines ) { | ||
echo $line; | ||
} | ||
break; | ||
} | ||
} | ||
|
||
fclose( $f ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* Loads the minimum amount of the Gutenberg PHP code possible and lists vendor | ||
* JavaScript URLs and filenames. | ||
* | ||
* @package gutenberg-build | ||
*/ | ||
|
||
define( 'SCRIPT_DEBUG', $argc > 1 && 'debug' === strtolower( $argv[1] ) ); | ||
|
||
// Hacks to get lib/client-assets.php to load. | ||
define( 'ABSPATH', dirname( dirname( __FILE__ ) ) ); | ||
/** | ||
* Hi, phpcs | ||
*/ | ||
function add_action() {} | ||
|
||
// Instead of loading script files, just show how they need to be loaded. | ||
define( 'GUTENBERG_LIST_VENDOR_ASSETS', true ); | ||
|
||
require_once dirname( dirname( __FILE__ ) ) . '/lib/client-assets.php'; | ||
|
||
gutenberg_register_vendor_scripts(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters