-
Notifications
You must be signed in to change notification settings - Fork 812
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build: Prepare tooling for Gutenberg extensions in Jetpack (#11639)
"Gutenberg" block editor extensions will be moving into the repository soon. Update related tooling accordingly to remove irrelevant source files. - SVN ignore for public releases - Git release branch tooling - CDN manifest tooling
- Loading branch information
Showing
3 changed files
with
182 additions
and
135 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 |
---|---|---|
@@ -1,20 +1,48 @@ | ||
<?php | ||
|
||
$path = dirname( dirname( __FILE__ ) ) . '/'; | ||
// The repo root path. | ||
$path = dirname( dirname( __FILE__ ) ) . '/'; | ||
|
||
// Build an iterator over all files in the repo that match the regex in the RegexIterator. | ||
$directory = new RecursiveDirectoryIterator( $path ); | ||
$iterator = new RecursiveIteratorIterator( $directory ); | ||
$regex = new RegexIterator( $iterator, '/^.+\.(css|js)$/i', RecursiveRegexIterator::GET_MATCH ); | ||
|
||
$ignore_paths = array( | ||
'_inc/client/', | ||
'bin/', | ||
'docker/', | ||
'docs/', | ||
'extensions/', | ||
'logs/', | ||
'node_modules/', | ||
'tests/', | ||
'tools/', | ||
'vendor/', | ||
); | ||
|
||
$manifest = array(); | ||
foreach ( $regex as $file => $value ) { | ||
$file = str_replace( $path, '', $file ); | ||
$directory = substr( $file, 0, strpos( $file, '/' ) ); | ||
if ( in_array( $directory, array( 'node_modules', 'tests' ) ) ) { | ||
foreach ( $regex as $path_to_file => $value ) { | ||
$path_from_repo_root = str_replace( $path, '', $path_to_file ); | ||
|
||
// Ignore top-level files. | ||
if ( false === strpos( $path_from_repo_root, '/' ) ) { | ||
continue; | ||
} | ||
$manifest[] = $file; | ||
|
||
// Ignore explicit ignore list. | ||
foreach ( $ignore_paths as $ignore_path ) { | ||
if ( 0 === strpos( $path_from_repo_root, $ignore_path ) ) { | ||
continue 2; | ||
} | ||
} | ||
|
||
$manifest[] = $path_from_repo_root; | ||
} | ||
|
||
$export = var_export( $manifest, true ); | ||
|
||
file_put_contents( $path . 'modules/photon-cdn/jetpack-manifest.php', "<?php \r\n\$assets = $export;\r\n" ); | ||
file_put_contents( $path . 'modules/photon-cdn/jetpack-manifest.php', "<?php | ||
// This file is autogenerated by bin/build-asset-cdn-json.php | ||
\$assets = $export;\r\n" ); |
Oops, something went wrong.