Skip to content

Commit

Permalink
Build: Prepare tooling for Gutenberg extensions in Jetpack (#11639)
Browse files Browse the repository at this point in the history
"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
sirreal authored Mar 25, 2019
1 parent 9c47bef commit 0d14622
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 135 deletions.
13 changes: 13 additions & 0 deletions .svnignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,16 @@ docker
bin/pre-commit-hook.js
bin/travis_install.sh
yarn-error.log
extensions/**/*.css
extensions/**/*.gif
extensions/**/*.jpeg
extensions/**/*.jpg
extensions/**/*.js
extensions/**/*.json
extensions/**/*.jsx
extensions/**/*.md
extensions/**/*.png
extensions/**/*.sass
extensions/**/*.scss
extensions/**/*.svg
**/__snapshots__
42 changes: 35 additions & 7 deletions bin/build-asset-cdn-json.php
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" );
Loading

0 comments on commit 0d14622

Please sign in to comment.