Open remcotolsma opened 2 months ago
I had to use a custom build script in the WordPress plugin "Pronamic Pay with Rabo Smart Pay for WooCommerce", because the WordPress.org plugin review team did not allow certain files in the build.
https://github.com/pronamic/pronamic-pay-with-rabo-smart-pay-for-woocommerce/blob/14eea88aa9a4fb62e5b0a149ca0effe41bf7ea91/build/scripts/build.php#L1-L34
I had to split the build into 2 steps/stages.
$slug = 'pronamic-pay-with-rabo-smart-pay-for-woocommerce'; $src_dir = realpath( __DIR__ . '/../../' ); $build_dir = realpath( __DIR__ . '/../' ); $stage_1_dir = $build_dir . '/stage-1'; $stage_2_dir = $build_dir . '/stage-2'; $artifacts_dir = $build_dir . '/artifacts'; echo $src_dir, PHP_EOL; echo $build_dir, PHP_EOL; echo $stage_1_dir, PHP_EOL; echo $stage_2_dir, PHP_EOL; run_command( "rm -rf $stage_1_dir" ); run_command( "rm -rf $stage_2_dir" ); run_command( "mkdir $stage_1_dir" ); run_command( "mkdir $stage_2_dir" ); run_command( "rsync --recursive --verbose --exclude-from=$build_dir/scripts/stage-1-ignore.txt --exclude-from=.distignore $src_dir/ $stage_1_dir/" ); run_command( "composer install --no-dev --prefer-dist --optimize-autoloader --working-dir=$stage_1_dir" ); run_command( "rsync --recursive --verbose --exclude-from=.distignore $stage_1_dir/ $stage_2_dir/" ); run_command( "vendor/bin/phpcbf -s -v --standard=$build_dir/scripts/phpcs-text-domain-fixer.xml $stage_2_dir", null ); run_command( "vendor/bin/wp i18n make-pot $stage_2_dir --slug=$slug" ); run_command( "vendor/bin/wp dist-archive $stage_2_dir $artifacts_dir/ --create-target-dir --plugin-dirname=$slug" );
The problem in this tool is dat composer install --no-dev --prefer-dist --optimize-autoloader can still install files that are not allowed:
composer install --no-dev --prefer-dist --optimize-autoloader
https://github.com/pronamic/pronamic-cli/blob/e9ba592978a496d869152d5138a61e370d1ac9ac/src/WpBuildCommand.php#L139-L151
To work around this I perform a second rsync call to again exclude the .distignore paths, for this I use 2 folders:
rsync
.distignore
build/stage-1
build/stage-2
In this tool it's currently just one:
build/project
rsync --recursive --verbose --exclude-from=$build_dir/scripts/stage-1-ignore.txt --exclude-from=.distignore $src_dir/ $stage_1_dir/
composer install --no-dev --prefer-dist --optimize-autoloader --working-dir=$stage_1_dir
rsync --recursive --verbose --exclude-from=.distignore $stage_1_dir/ $stage_2_dir/
vendor/bin/phpcbf -s -v --standard=$build_dir/scripts/phpcs-text-domain-fixer.xml $stage_2_dir
vendor/bin/wp i18n make-pot $stage_2_dir --slug=$slug
vendor/bin/wp dist-archive $stage_2_dir $artifacts_dir/ --create-target-dir --plugin-dirname=$slug
It would be nice if this tool could be adapted to work in a similar way.
Untested, command to remove all paths listed in a .distignore file (ignoring lines starting with # — comments — and empty lines):
#
grep -v '^#' .distignore | grep -v '^$' | xargs rm -rf
I had to use a custom build script in the WordPress plugin "Pronamic Pay with Rabo Smart Pay for WooCommerce", because the WordPress.org plugin review team did not allow certain files in the build.
https://github.com/pronamic/pronamic-pay-with-rabo-smart-pay-for-woocommerce/blob/14eea88aa9a4fb62e5b0a149ca0effe41bf7ea91/build/scripts/build.php#L1-L34
I had to split the build into 2 steps/stages.
The problem in this tool is dat
composer install --no-dev --prefer-dist --optimize-autoloader
can still install files that are not allowed:https://github.com/pronamic/pronamic-cli/blob/e9ba592978a496d869152d5138a61e370d1ac9ac/src/WpBuildCommand.php#L139-L151
To work around this I perform a second
rsync
call to again exclude the.distignore
paths, for this I use 2 folders:build/stage-1
build/stage-2
In this tool it's currently just one:
build/project
rsync --recursive --verbose --exclude-from=$build_dir/scripts/stage-1-ignore.txt --exclude-from=.distignore $src_dir/ $stage_1_dir/
composer install --no-dev --prefer-dist --optimize-autoloader --working-dir=$stage_1_dir
rsync --recursive --verbose --exclude-from=.distignore $stage_1_dir/ $stage_2_dir/
vendor/bin/phpcbf -s -v --standard=$build_dir/scripts/phpcs-text-domain-fixer.xml $stage_2_dir
vendor/bin/wp i18n make-pot $stage_2_dir --slug=$slug
vendor/bin/wp dist-archive $stage_2_dir $artifacts_dir/ --create-target-dir --plugin-dirname=$slug
It would be nice if this tool could be adapted to work in a similar way.