diff --git a/.gitignore b/.gitignore index 8ff71ca..760268e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea/ vendor/ *.phar +.vscode/ tests/_output tests/_support/_generated diff --git a/composer.json b/composer.json index 36f6e4a..be81ae1 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "codeception/module-phpbrowser": "^2.0.3", "codeception/module-asserts": "^2.0.1", "codeception/module-cli": "^2.0", - "lucatume/codeception-snapshot-assertions": "^0.2.4" + "lucatume/codeception-snapshot-assertions": "^0.4.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 9e141cb..dc64a6f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "73d426c1e23f213cb7ba8f1660879ade", + "content-hash": "f209922c6af8deb6a753cf87e25cb831", "packages": [ { "name": "composer/ca-bundle", @@ -966,12 +966,12 @@ "version": "v5.2.13", "source": { "type": "git", - "url": "https://github.com/justinrainbow/json-schema.git", + "url": "https://github.com/jsonrainbow/json-schema.git", "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793", "shasum": "" }, @@ -3327,20 +3327,20 @@ }, { "name": "lucatume/codeception-snapshot-assertions", - "version": "0.2.4", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/lucatume/codeception-snapshot-assertions.git", - "reference": "077108237a121d3ddcf7070aa8519dea25459a6a" + "reference": "dd231b17a4a7f74e33a27749edab64688e3ecc2b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lucatume/codeception-snapshot-assertions/zipball/077108237a121d3ddcf7070aa8519dea25459a6a", - "reference": "077108237a121d3ddcf7070aa8519dea25459a6a", + "url": "https://api.github.com/repos/lucatume/codeception-snapshot-assertions/zipball/dd231b17a4a7f74e33a27749edab64688e3ecc2b", + "reference": "dd231b17a4a7f74e33a27749edab64688e3ecc2b", "shasum": "" }, "require": { - "codeception/codeception": "^2.5 || ^3.0 || ^4.0", + "codeception/codeception": "^4.0", "ext-dom": "*", "gajus/dindent": "^2.0" }, @@ -3366,9 +3366,9 @@ "description": "Snapshot assertions sugar for Codeception.", "support": { "issues": "https://github.com/lucatume/codeception-snapshot-assertions/issues", - "source": "https://github.com/lucatume/codeception-snapshot-assertions/tree/master" + "source": "https://github.com/lucatume/codeception-snapshot-assertions/tree/0.4.0" }, - "time": "2020-02-05T20:17:49+00:00" + "time": "2023-10-14T14:42:12+00:00" }, { "name": "myclabs/deep-copy", @@ -5599,12 +5599,12 @@ ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^7.2|^8.0" }, - "platform-dev": [], + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/docs/commands.md b/docs/commands.md index ec94b9b..2b0b5dd 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -257,6 +257,9 @@ src/styles/*.css By default, `pup` will use its own `.distignore-defaults` file to exclude a number of common patterns. You can turn the default exclusion rules off by adding `"zip_use_default_ignore": false` to your `.puprc` file. +If you have a `.distfile` or `.distinclude` in your project, `pup` will NOT use its own `.distignore-defaults` regardless of the +property's `zip_use_default_ignore` value. + The zip that is generated will be placed in your project's root directory. ### Usage diff --git a/pup b/pup index a337df7..db99929 100755 --- a/pup +++ b/pup @@ -3,7 +3,7 @@ namespace StellarWP\Pup; -const PUP_VERSION = '1.3.8'; +const PUP_VERSION = '1.3.9'; define( '__PUP_DIR__', __DIR__ ); if ( ! \Phar::running() ) { diff --git a/src/Commands/Package.php b/src/Commands/Package.php index 9c70804..cb24564 100644 --- a/src/Commands/Package.php +++ b/src/Commands/Package.php @@ -85,9 +85,10 @@ protected function execute( InputInterface $input, OutputInterface $output ) { $output->writeln( '- Synchronizing files to zip directory...' ); - $distfiles = $this->getDistfilesLines( $this->getSourceDir( $root ) ); - if ( ! empty( $distfiles ) ) { - $distfiles_message = '>>> Your project has a .distfiles file, so .distignore and pup\'s default ignore rules will not be used.'; + $distfiles = $this->getDistfilesLines( $this->getSourceDir( $root ) ); + $distincludes = $this->getDistincludeLines( $this->getSourceDir( $root ) ); + if ( ! empty( $distfiles ) || ! empty( $distincludes ) ) { + $distfiles_message = '>>> Your project has a .distfiles file or a .distinclude file or both, so pup\'s default ignore rules will not be used.'; $output->writeln( "{$distfiles_message}" ); } @@ -208,22 +209,6 @@ protected function createZip( string $dir_to_zip, string $zip_filename, string $ return 0; } - /** - * Get the default things to exclude from sync. - * - * @return array - */ - public function getDefaultIgnoreLines(): array { - $working_dir = App::getConfig()->getWorkingDir(); - $zip_dir = str_replace( $working_dir, '', App::getConfig()->getZipDir() ); - - return [ - '.puprc', - '.pup-*', - $zip_dir, - ]; - } - /** * Get the files to exclude from sync. * @@ -287,7 +272,7 @@ public function getDistfilesLines( string $source ): array { */ public function getDistincludeLines( string $source ): array { $include = []; - $include_file = '.pup-include'; + $include_file = '.pup-distinclude'; if ( ! file_exists( $source . $include_file ) ) { return []; @@ -440,12 +425,7 @@ protected function syncFiles( string $root, string $destination ): int { $distinclude = $this->getDistincludeLines( $source ); $include = array_merge( $distfiles, $distinclude ); - $ignore = $this->getDefaultIgnoreLines(); - - // We only observe .distignore if there is no .distfiles files. - if ( empty( $distfiles ) ) { - $ignore = array_merge( $ignore, $this->getIgnoreLines( $source ) ); - } + $ignore = $this->getIgnoreLines( $source ); $results = $this->migrateNegatedLines( $include, $ignore ); $include = $results['include']; diff --git a/src/Filesystem/SyncFiles/AbstractFile.php b/src/Filesystem/SyncFiles/AbstractFile.php index 5f618d3..eec7c7a 100644 --- a/src/Filesystem/SyncFiles/AbstractFile.php +++ b/src/Filesystem/SyncFiles/AbstractFile.php @@ -5,6 +5,16 @@ use Symfony\Component\Finder\Glob; class AbstractFile { + /** + * An array of our default files. + * + * @var array + */ + protected const DEFAULTS = [ + '.distignore-defaults', + '.puprc-defaults' + ]; + /** * @var string */ @@ -94,12 +104,15 @@ public function writeContents( string $target_file ): string { foreach ( $this->getPaths() as $file ) { if ( ! file_exists( $this->getRoot() . $file ) ) { - if ( ! file_exists( $file ) || strpos( $file, __PUP_DIR__ ) === false ) { - $is_default = true; + if ( ! file_exists( $file ) ) { continue; - } else { - $path = $file; } + + if ( $this->is_default( $file ) ) { + $is_default = true; + } + + $path = $file; } else { $path = $this->getRoot() . $file; } @@ -146,6 +159,10 @@ public function writeContents( string $target_file ): string { return (string) file_get_contents( $this->getRoot() . $target_file ); } + public function is_default( string $file ): bool { + return in_array( $file, array_map( fn( $default_file ) => __PUP_DIR__ . '/' . $default_file, static::DEFAULTS ), true ); + } + /** * Writes the file. * diff --git a/src/Filesystem/SyncFiles/SyncFiles.php b/src/Filesystem/SyncFiles/SyncFiles.php index f9784f4..ff2e8d6 100644 --- a/src/Filesystem/SyncFiles/SyncFiles.php +++ b/src/Filesystem/SyncFiles/SyncFiles.php @@ -59,7 +59,9 @@ public static function getDistIgnore( string $root, array $paths = [] ): DistIgn $use_ignore_defaults = App::getConfig()->getZipUseDefaultIgnore(); $files = static::getSyncFiles( '.distignore' ); - if ( $use_ignore_defaults ) { + $there_is_safelist = file_exists( $root . '/.distfiles' ) || file_exists( $root . '/.distinclude' ); + + if ( ! $there_is_safelist && $use_ignore_defaults ) { $files[] = __PUP_DIR__ . '/.distignore-defaults'; } diff --git a/tests/_data/fake-project/node_modules/a-script-i-need.js b/tests/_data/fake-project/node_modules/a-script-i-need.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/cli/AbstractBase.php b/tests/cli/AbstractBase.php index eee6148..0451abf 100644 --- a/tests/cli/AbstractBase.php +++ b/tests/cli/AbstractBase.php @@ -9,11 +9,13 @@ class AbstractBase { protected $pup; protected $pup_root; + protected $plugin_root; protected $tests_root; public function __construct() { $this->tests_root = dirname( __DIR__ ); $this->pup_root = dirname( $this->tests_root ); + $this->plugin_root = dirname( $this->pup_root ); } public function _before( CliTester $I ) { @@ -22,6 +24,7 @@ public function _before( CliTester $I ) { } public function _after( CliTester $I ) { + $I->runShellCommand( "php {$this->pup} clean" ); $this->reset_data_and_location(); } @@ -31,6 +34,7 @@ protected function reset_data_and_location() { '.puprc', '.distignore', '.distinclude', + '.distfiles', '.gitattributes', 'fake-project.1.0.0.zip', 'fake-project.1.0.0.1.zip', diff --git a/tests/cli/Commands/CloneCest.php b/tests/cli/Commands/CloneCest.php index 52bffd4..43efb47 100644 --- a/tests/cli/Commands/CloneCest.php +++ b/tests/cli/Commands/CloneCest.php @@ -33,7 +33,7 @@ public function it_should_clone_the_default_branch_of_a_git_repo( CliTester $I ) $I->assertTrue( file_exists( '.pup-build/bootstrap.php' ) ); $output = $I->grabShellOutput(); - $this->assertMatchesStringSnapshot( $output ); + $this->assertMatchesStringSnapshot( str_replace( $this->plugin_root, '{PUP_ROOT}', $output ) ); $I->runShellCommand( "php {$this->pup} clean" ); @@ -72,7 +72,7 @@ public function it_should_clone_a_specific_branch_of_a_git_repo( CliTester $I ) $I->assertTrue( file_exists( '.pup-build/new-file.txt' ) ); $output = $I->grabShellOutput(); - $this->assertMatchesStringSnapshot( $output ); + $this->assertMatchesStringSnapshot( str_replace( $this->plugin_root, '{PUP_ROOT}', $output ) ); $I->runShellCommand( "php {$this->pup} clean" ); diff --git a/tests/cli/Commands/InfoCest.php b/tests/cli/Commands/InfoCest.php index c0286bf..5fb9a83 100644 --- a/tests/cli/Commands/InfoCest.php +++ b/tests/cli/Commands/InfoCest.php @@ -23,7 +23,7 @@ public function it_should_provide_info( CliTester $I ) { $I->runShellCommand( "php {$this->pup} info" ); $I->seeResultCodeIs( 0 ); - $output = $this->removeDynamicDataFromOutput( $I->grabShellOutput() ); + $output = $this->removeDynamicDataFromOutput( str_replace( $this->plugin_root, '{PUP_ROOT}', $I->grabShellOutput() ) ); $this->assertMatchesStringSnapshot( $output ); } @@ -39,7 +39,7 @@ public function it_should_provide_info_with_puprc( CliTester $I ) { $I->runShellCommand( "php {$this->pup} info" ); $I->seeResultCodeIs( 0 ); - $output = $this->removeDynamicDataFromOutput( $I->grabShellOutput() ); + $output = $this->removeDynamicDataFromOutput( str_replace( $this->plugin_root, '{PUP_ROOT}', $I->grabShellOutput() ) ); $this->assertMatchesStringSnapshot( $output ); } @@ -55,7 +55,7 @@ public function it_should_provide_info_with_distignore( CliTester $I ) { $I->runShellCommand( "php {$this->pup} info" ); $I->seeResultCodeIs( 0 ); - $output = $this->removeDynamicDataFromOutput( $I->grabShellOutput() ); + $output = $this->removeDynamicDataFromOutput( str_replace( $this->plugin_root, '{PUP_ROOT}', $I->grabShellOutput() ) ); $this->assertMatchesStringSnapshot( $output ); @@ -73,7 +73,7 @@ public function it_should_provide_info_with_distinclude( CliTester $I ) { $I->runShellCommand( "php {$this->pup} info" ); $I->seeResultCodeIs( 0 ); - $output = $this->removeDynamicDataFromOutput( $I->grabShellOutput() ); + $output = $this->removeDynamicDataFromOutput( str_replace( $this->plugin_root, '{PUP_ROOT}', $I->grabShellOutput() ) ); $this->assertMatchesStringSnapshot( $output ); @@ -91,7 +91,7 @@ public function it_should_provide_info_with_gitattributes( CliTester $I ) { $I->runShellCommand( "php {$this->pup} info" ); $I->seeResultCodeIs( 0 ); - $output = $this->removeDynamicDataFromOutput( $I->grabShellOutput() ); + $output = $this->removeDynamicDataFromOutput( str_replace( $this->plugin_root, '{PUP_ROOT}', $I->grabShellOutput() ) ); $this->assertMatchesStringSnapshot( $output ); @@ -111,7 +111,7 @@ public function it_should_show_invalid_puprc( CliTester $I ) { $I->runShellCommand( "php {$this->pup} info" ); $I->seeResultCodeIs( 0 ); - $output = $this->removeDynamicDataFromOutput( $I->grabShellOutput() ); + $output = $this->removeDynamicDataFromOutput( str_replace( $this->plugin_root, '{PUP_ROOT}', $I->grabShellOutput() ) ); $this->assertMatchesStringSnapshot( $output ); } diff --git a/tests/cli/Commands/PackageCest.php b/tests/cli/Commands/PackageCest.php index 9f94fd9..cf123e1 100644 --- a/tests/cli/Commands/PackageCest.php +++ b/tests/cli/Commands/PackageCest.php @@ -6,27 +6,11 @@ use StellarWP\Pup\Tests\CliTester; class PackageCest extends AbstractBase { - protected function reset_data_and_location() { - chdir( __DIR__ ); - $files = [ - '.puprc', - '.distignore', - '.distinclude', - '.gitattributes', - 'fake-project.1.0.0.zip', - 'fake-project.zip', - ]; - - foreach ( $files as $file ) { - @unlink( $this->tests_root . '/_data/fake-project/' . $file ); - } - } /** * @test */ public function it_should_package_the_zip( CliTester $I ) { - $this->reset_data_and_location(); $this->write_default_puprc(); chdir( $this->tests_root . '/_data/fake-project' ); @@ -38,16 +22,12 @@ public function it_should_package_the_zip( CliTester $I ) { $output = $I->grabShellOutput(); $this->assertMatchesStringSnapshot( $output ); - - $I->runShellCommand( "php {$this->pup} clean" ); - $this->reset_data_and_location(); } /** * @test */ public function it_should_package_the_zip_without_version_number_if_unknown( CliTester $I ) { - $this->reset_data_and_location(); $this->write_default_puprc(); chdir( $this->tests_root . '/_data/fake-project' ); @@ -59,16 +39,12 @@ public function it_should_package_the_zip_without_version_number_if_unknown( Cli $output = $I->grabShellOutput(); $this->assertMatchesStringSnapshot( $output ); - - $I->runShellCommand( "php {$this->pup} clean" ); - $this->reset_data_and_location(); } /** * @test */ public function it_should_package_the_zip_and_ignore_files_from_defaults( CliTester $I ) { - $this->reset_data_and_location(); $this->write_default_puprc(); chdir( $this->tests_root . '/_data/fake-project' ); @@ -81,16 +57,12 @@ public function it_should_package_the_zip_and_ignore_files_from_defaults( CliTes $output = $I->grabShellOutput(); $this->assertMatchesStringSnapshot( $output ); - - $I->runShellCommand( "php {$this->pup} clean" ); - $this->reset_data_and_location(); } /** * @test */ public function it_should_package_the_zip_and_ignore_files_from_distignore( CliTester $I ) { - $this->reset_data_and_location(); $this->write_default_puprc(); chdir( $this->tests_root . '/_data/fake-project' ); @@ -105,16 +77,12 @@ public function it_should_package_the_zip_and_ignore_files_from_distignore( CliT $output = $I->grabShellOutput(); $this->assertMatchesStringSnapshot( $output ); - - $I->runShellCommand( "php {$this->pup} clean" ); - $this->reset_data_and_location(); } /** * @test */ public function it_should_package_the_zip_and_ignore_files_from_gitattributes( CliTester $I ) { - $this->reset_data_and_location(); $this->write_default_puprc(); chdir( $this->tests_root . '/_data/fake-project' ); @@ -129,16 +97,12 @@ public function it_should_package_the_zip_and_ignore_files_from_gitattributes( C $output = $I->grabShellOutput(); $this->assertMatchesStringSnapshot( $output ); - - $I->runShellCommand( "php {$this->pup} clean" ); - $this->reset_data_and_location(); } /** * @test */ public function it_should_package_the_zip_and_ignore_files_from_distignore_and_gitattributes( CliTester $I ) { - $this->reset_data_and_location(); $this->write_default_puprc(); chdir( $this->tests_root . '/_data/fake-project' ); @@ -154,16 +118,12 @@ public function it_should_package_the_zip_and_ignore_files_from_distignore_and_g $output = $I->grabShellOutput(); $this->assertMatchesStringSnapshot( $output ); - - $I->runShellCommand( "php {$this->pup} clean" ); - $this->reset_data_and_location(); } /** * @test */ public function it_should_package_the_zip_and_include_files_in_distinclude( CliTester $I ) { - $this->reset_data_and_location(); $this->write_default_puprc(); chdir( $this->tests_root . '/_data/fake-project' ); @@ -178,23 +138,45 @@ public function it_should_package_the_zip_and_include_files_in_distinclude( CliT $output = $I->grabShellOutput(); $this->assertMatchesStringSnapshot( $output ); + } + + /** + * @test + */ + public function it_should_package_the_zip_and_include_files_in_distfiles( CliTester $I ) { + $this->write_default_puprc(); + + chdir( $this->tests_root . '/_data/fake-project' ); + + file_put_contents( '.distfiles', "/node_modules/a-script-i-need.js\n" ); + + $I->runShellCommand( "php {$this->pup} package 1.0.0" ); + + system( 'unzip -d .pup-zip/ fake-project.1.0.0.zip' ); + + $I->runShellCommand( "ls -a .pup-zip" ); + + $output = $I->grabShellOutput(); - $I->runShellCommand( "php {$this->pup} clean" ); - $this->reset_data_and_location(); + chdir( '.pup-zip' ); + + $I->runShellCommand( "ls -a node_modules" ); + + $output .= $I->grabShellOutput(); + + $this->assertMatchesStringSnapshot( $output ); } /** * @test */ - public function it_should_package_the_zip_and_include_files_in_distinclude_even_if_in_distignore_and_gitattributes( CliTester $I ) { - $this->reset_data_and_location(); + public function it_should_package_the_zip_and_include_files_in_distfiles_and_ignore_from_distignore( CliTester $I ) { $this->write_default_puprc(); chdir( $this->tests_root . '/_data/fake-project' ); - file_put_contents( '.distinclude', ".puprc\n" ); - file_put_contents( '.distignore', ".puprc\n" ); - file_put_contents( '.gitattributes', ".puprc export-ignore\n" ); + file_put_contents( '.distfiles', "/node_modules/a-script-i-need.js\nsrc/*\nbootstrap.php\nother-file.php\n" ); + file_put_contents( '.distignore', "other-file.php\n" ); $I->runShellCommand( "php {$this->pup} package 1.0.0" ); @@ -203,9 +185,66 @@ public function it_should_package_the_zip_and_include_files_in_distinclude_even_ $I->runShellCommand( "ls -a .pup-zip" ); $output = $I->grabShellOutput(); + + chdir( '.pup-zip' ); + + $I->runShellCommand( "ls -a src" ); + + $output .= $I->grabShellOutput(); + + $I->runShellCommand( "ls -a node_modules" ); + + $output .= $I->grabShellOutput(); + $this->assertMatchesStringSnapshot( $output ); + } - $I->runShellCommand( "php {$this->pup} clean" ); - $this->reset_data_and_location(); + /** + * @test + */ + public function it_should_package_the_zip_and_use_default_distignore_when_no_safelist( CliTester $I ) { + $this->write_default_puprc(); + + chdir( $this->tests_root . '/_data/fake-project' ); + + file_put_contents( '.distignore', "other-file.php\n" ); + + $I->runShellCommand( "php {$this->pup} package 1.0.0" ); + + system( 'unzip -d .pup-zip/ fake-project.1.0.0.zip' ); + + $I->runShellCommand( "ls -a .pup-zip" ); + + $output = $I->grabShellOutput(); + + chdir( '.pup-zip' ); + + $I->runShellCommand( "ls -a src" ); + + $output .= $I->grabShellOutput(); + + $this->assertMatchesStringSnapshot( $output ); + } + + /** + * @test + */ + public function it_should_package_the_zip_and_not_include_files_in_distinclude_even_if_in_distignore_and_gitattributes( CliTester $I ) { + $this->write_default_puprc(); + + chdir( $this->tests_root . '/_data/fake-project' ); + + file_put_contents( '.distinclude', ".puprc\n" ); + file_put_contents( '.distignore', ".puprc\nnode_modules/\n" ); + file_put_contents( '.gitattributes', ".puprc export-ignore\n" ); + + $I->runShellCommand( "php {$this->pup} package 1.0.0" ); + + system( 'unzip -d .pup-zip fake-project.1.0.0.zip' ); + + $I->runShellCommand( "ls -a .pup-zip/fake-project" ); + + $output = $I->grabShellOutput(); + $this->assertMatchesStringSnapshot( $output ); } } diff --git a/tests/cli/Commands/WorkflowCest.php b/tests/cli/Commands/WorkflowCest.php index 5f9357a..28dc9a4 100644 --- a/tests/cli/Commands/WorkflowCest.php +++ b/tests/cli/Commands/WorkflowCest.php @@ -190,7 +190,6 @@ public function it_should_pass_additional_arguments_and_options_to_workflow_scri $I->seeInShellOutput( 'Option: --option-one, Value: one' ); $I->seeInShellOutput( 'Option: --option-two, Value: two' ); - $output = $I->grabShellOutput(); - $this->assertMatchesStringSnapshot( $output ); + $this->assertMatchesStringSnapshot( str_replace( $this->plugin_root, '{PUP_ROOT}', $I->grabShellOutput() ) ); } } diff --git a/tests/cli/Commands/ZipCest.php b/tests/cli/Commands/ZipCest.php index da7fdb1..c15d014 100644 --- a/tests/cli/Commands/ZipCest.php +++ b/tests/cli/Commands/ZipCest.php @@ -33,8 +33,7 @@ public function it_should_zip_with_repo_using_path( CliTester $I ) { $I->assertTrue( file_exists( 'fake-project.1.0.0.1.zip' ) ); - $output = $I->grabShellOutput(); - $this->assertMatchesStringSnapshot( $output ); + $this->assertMatchesStringSnapshot( str_replace( $this->plugin_root, '{PUP_ROOT}', $I->grabShellOutput() ) ); $I->runShellCommand( "php {$this->pup} clean" ); @@ -68,8 +67,7 @@ public function it_should_zip_with_repo_using_file_colon_slash_slash( CliTester $I->assertTrue( file_exists( 'fake-project.1.0.0.1.zip' ) ); - $output = $I->grabShellOutput(); - $this->assertMatchesStringSnapshot( $output ); + $this->assertMatchesStringSnapshot( str_replace( $this->plugin_root, '{PUP_ROOT}', $I->grabShellOutput() ) ); $I->runShellCommand( "php {$this->pup} clean" ); diff --git a/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build__0.snapshot.txt b/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build__0.snapshot.txt index a02c5e8..cfc0167 100644 --- a/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build__0.snapshot.txt @@ -7,6 +7,7 @@ Running build steps... .. .puprc bootstrap.php +node_modules other-file.php package.json src diff --git a/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build_with_custom_env_vars__0.snapshot.txt b/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build_with_custom_env_vars__0.snapshot.txt index 6bc0203..252e631 100644 --- a/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build_with_custom_env_vars__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build_with_custom_env_vars__0.snapshot.txt @@ -7,6 +7,7 @@ Running build steps... .. .puprc bootstrap.php +node_modules other-file.php package.json src diff --git a/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build_with_default_env_vars__0.snapshot.txt b/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build_with_default_env_vars__0.snapshot.txt index 37a6158..46e108b 100644 --- a/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build_with_default_env_vars__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build_with_default_env_vars__0.snapshot.txt @@ -7,6 +7,7 @@ Running build steps... .. .puprc bootstrap.php +node_modules other-file.php package.json src diff --git a/tests/cli/Commands/__snapshots__/CheckCest__it_should_ignore_fail_tbd_check_when_tbds_exist_and_fail_method_is_warn__0.snapshot.txt b/tests/cli/Commands/__snapshots__/CheckCest__it_should_ignore_fail_tbd_check_when_tbds_exist_and_fail_method_is_warn__0.snapshot.txt index dadc3c9..82f81a6 100644 --- a/tests/cli/Commands/__snapshots__/CheckCest__it_should_ignore_fail_tbd_check_when_tbds_exist_and_fail_method_is_warn__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/CheckCest__it_should_ignore_fail_tbd_check_when_tbds_exist_and_fail_method_is_warn__0.snapshot.txt @@ -2,9 +2,6 @@ [tbd] Checking for TBDs... [tbd] -------------------- -[tbd] ./src/Plugin.php -[tbd] 9: * @since TBD -[tbd] [tbd] ./src/Thing/AnotherFile.php [tbd] 5: _deprecated_file( __FILE__, 'TBD' ); [tbd] 9: * @since TBD @@ -14,6 +11,9 @@ [tbd] 28: * @deprecated TBD [tbd] 32: _deprecated_function( __METHOD__, 'TBD' ); [tbd] +[tbd] ./src/Plugin.php +[tbd] 9: * @since TBD +[tbd] [tbd] [tbd] TBDs have been found! diff --git a/tests/cli/Commands/__snapshots__/CloneCest__it_should_clone_a_specific_branch_of_a_git_repo__0.snapshot.txt b/tests/cli/Commands/__snapshots__/CloneCest__it_should_clone_a_specific_branch_of_a_git_repo__0.snapshot.txt index 0d0b2b5..20290ae 100644 --- a/tests/cli/Commands/__snapshots__/CloneCest__it_should_clone_a_specific_branch_of_a_git_repo__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/CloneCest__it_should_clone_a_specific_branch_of_a_git_repo__0.snapshot.txt @@ -1,2 +1,2 @@ -Cloning the /var/www/html/wp-content/plugins/pup/tests/_data/fake-project-git-repo repo into .pup-build... +Cloning the {PUP_ROOT}/pup/tests/_data/fake-project-git-repo repo into .pup-build... ✓ Clone complete. \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/CloneCest__it_should_clone_the_default_branch_of_a_git_repo__0.snapshot.txt b/tests/cli/Commands/__snapshots__/CloneCest__it_should_clone_the_default_branch_of_a_git_repo__0.snapshot.txt index 0d0b2b5..20290ae 100644 --- a/tests/cli/Commands/__snapshots__/CloneCest__it_should_clone_the_default_branch_of_a_git_repo__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/CloneCest__it_should_clone_the_default_branch_of_a_git_repo__0.snapshot.txt @@ -1,2 +1,2 @@ -Cloning the /var/www/html/wp-content/plugins/pup/tests/_data/fake-project-git-repo repo into .pup-build... +Cloning the {PUP_ROOT}/pup/tests/_data/fake-project-git-repo repo into .pup-build... ✓ Clone complete. \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info__0.snapshot.txt b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info__0.snapshot.txt index ec708e2..01429f5 100644 --- a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info__0.snapshot.txt @@ -2,13 +2,13 @@ CLI Info ======== -pup from /var/www/html/wp-content/plugins/pup/pup +pup from {PUP_ROOT}/pup/pup Using: PHP Working Directory ----------------- -/var/www/html/wp-content/plugins/pup/tests/_data/fake-project/ +{PUP_ROOT}/pup/tests/_data/fake-project/ File info --------- diff --git a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_distignore__0.snapshot.txt b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_distignore__0.snapshot.txt index 299eaca..1644cb3 100644 --- a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_distignore__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_distignore__0.snapshot.txt @@ -2,13 +2,13 @@ CLI Info ======== -pup from /var/www/html/wp-content/plugins/pup/pup +pup from {PUP_ROOT}/pup/pup Using: PHP Working Directory ----------------- -/var/www/html/wp-content/plugins/pup/tests/_data/fake-project/ +{PUP_ROOT}/pup/tests/_data/fake-project/ File info --------- diff --git a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_distinclude__0.snapshot.txt b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_distinclude__0.snapshot.txt index 2fa4f89..901ba92 100644 --- a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_distinclude__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_distinclude__0.snapshot.txt @@ -2,13 +2,13 @@ CLI Info ======== -pup from /var/www/html/wp-content/plugins/pup/pup +pup from {PUP_ROOT}/pup/pup Using: PHP Working Directory ----------------- -/var/www/html/wp-content/plugins/pup/tests/_data/fake-project/ +{PUP_ROOT}/pup/tests/_data/fake-project/ File info --------- diff --git a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_gitattributes__0.snapshot.txt b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_gitattributes__0.snapshot.txt index 71cb830..a40f3bf 100644 --- a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_gitattributes__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_gitattributes__0.snapshot.txt @@ -2,13 +2,13 @@ CLI Info ======== -pup from /var/www/html/wp-content/plugins/pup/pup +pup from {PUP_ROOT}/pup/pup Using: PHP Working Directory ----------------- -/var/www/html/wp-content/plugins/pup/tests/_data/fake-project/ +{PUP_ROOT}/pup/tests/_data/fake-project/ File info --------- diff --git a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_puprc__0.snapshot.txt b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_puprc__0.snapshot.txt index 016f3e6..5feacc9 100644 --- a/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_puprc__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/InfoCest__it_should_provide_info_with_puprc__0.snapshot.txt @@ -2,13 +2,13 @@ CLI Info ======== -pup from /var/www/html/wp-content/plugins/pup/pup +pup from {PUP_ROOT}/pup/pup Using: PHP Working Directory ----------------- -/var/www/html/wp-content/plugins/pup/tests/_data/fake-project/ +{PUP_ROOT}/pup/tests/_data/fake-project/ File info --------- diff --git a/tests/cli/Commands/__snapshots__/InfoCest__it_should_show_invalid_puprc__0.snapshot.txt b/tests/cli/Commands/__snapshots__/InfoCest__it_should_show_invalid_puprc__0.snapshot.txt index a600e32..e5cd9c7 100644 --- a/tests/cli/Commands/__snapshots__/InfoCest__it_should_show_invalid_puprc__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/InfoCest__it_should_show_invalid_puprc__0.snapshot.txt @@ -2,13 +2,13 @@ CLI Info ======== -pup from /var/www/html/wp-content/plugins/pup/pup +pup from {PUP_ROOT}/pup/pup Using: PHP Working Directory ----------------- -/var/www/html/wp-content/plugins/pup/tests/_data/fake-project/ +{PUP_ROOT}/pup/tests/_data/fake-project/ File info --------- diff --git a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_ignore_files_from_distignore__0.snapshot.txt b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_ignore_files_from_distignore__0.snapshot.txt index f9b9368..3f11399 100644 --- a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_ignore_files_from_distignore__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_ignore_files_from_distignore__0.snapshot.txt @@ -1,7 +1,5 @@ . .. -.distignore fake-project other-file.php -package.json src \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_ignore_files_from_distignore_and_gitattributes__0.snapshot.txt b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_ignore_files_from_distignore_and_gitattributes__0.snapshot.txt index 408b42b..7fa1da4 100644 --- a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_ignore_files_from_distignore_and_gitattributes__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_ignore_files_from_distignore_and_gitattributes__0.snapshot.txt @@ -1,7 +1,4 @@ . .. -.distignore -.gitattributes fake-project -package.json src \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distfiles__0.snapshot.txt b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distfiles__0.snapshot.txt new file mode 100644 index 0000000..98bb2f3 --- /dev/null +++ b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distfiles__0.snapshot.txt @@ -0,0 +1,6 @@ +. +.. +fake-project +node_modules. +.. +a-script-i-need.js \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distfiles_and_ignore_from_distignore__0.snapshot.txt b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distfiles_and_ignore_from_distignore__0.snapshot.txt new file mode 100644 index 0000000..c5b187e --- /dev/null +++ b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distfiles_and_ignore_from_distignore__0.snapshot.txt @@ -0,0 +1,11 @@ +. +.. +bootstrap.php +fake-project +node_modules +src. +.. +OtherFileWithBadVersion.php +Plugin.php. +.. +a-script-i-need.js \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distinclude_even_if_in_distignore_and_gitattributes__0.snapshot.txt b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distinclude_even_if_in_distignore_and_gitattributes__0.snapshot.txt deleted file mode 100644 index b039e05..0000000 --- a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_include_files_in_distinclude_even_if_in_distignore_and_gitattributes__0.snapshot.txt +++ /dev/null @@ -1,3 +0,0 @@ -. -.. -fake-project \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_not_include_files_in_distinclude_even_if_in_distignore_and_gitattributes__0.snapshot.txt b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_not_include_files_in_distinclude_even_if_in_distignore_and_gitattributes__0.snapshot.txt new file mode 100644 index 0000000..4d2073c --- /dev/null +++ b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_not_include_files_in_distinclude_even_if_in_distignore_and_gitattributes__0.snapshot.txt @@ -0,0 +1,4 @@ +. +.. +bootstrap.php +src \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_use_default_distignore_when_no_safelist__0.snapshot.txt b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_use_default_distignore_when_no_safelist__0.snapshot.txt new file mode 100644 index 0000000..c56a6de --- /dev/null +++ b/tests/cli/Commands/__snapshots__/PackageCest__it_should_package_the_zip_and_use_default_distignore_when_no_safelist__0.snapshot.txt @@ -0,0 +1,8 @@ +. +.. +bootstrap.php +fake-project +src. +.. +OtherFileWithBadVersion.php +Plugin.php \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/WorkflowCest__it_should_pass_additional_arguments_and_options_to_workflow_script__0.snapshot.txt b/tests/cli/Commands/__snapshots__/WorkflowCest__it_should_pass_additional_arguments_and_options_to_workflow_script__0.snapshot.txt index 6a023a0..02b0b3a 100644 --- a/tests/cli/Commands/__snapshots__/WorkflowCest__it_should_pass_additional_arguments_and_options_to_workflow_script__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/WorkflowCest__it_should_pass_additional_arguments_and_options_to_workflow_script__0.snapshot.txt @@ -1,11 +1,11 @@ Running test-workflow workflow steps... -> /var/www/html/wp-content/plugins/pup/tests/_data/test-workflow-script.sh 'arg1' 'arg2' '--option-one=one' '--option-two=two' ------------------------------------------------------------------------------------------------------------------------------- +> {PUP_ROOT}/pup/tests/_data/test-workflow-script.sh 'arg1' 'arg2' '--option-one=one' '--option-two=two' +------------------------------------------------------------------------------------------------------------------- Argument: arg1 Argument: arg2 Option: --option-one, Value: one Option: --option-two, Value: two -Workflow complete. +Workflow complete. \ No newline at end of file diff --git a/tests/cli/Commands/__snapshots__/WorkflowCest__it_should_run_build_as_workflow__0.snapshot.txt b/tests/cli/Commands/__snapshots__/WorkflowCest__it_should_run_build_as_workflow__0.snapshot.txt index b077de2..1817700 100644 --- a/tests/cli/Commands/__snapshots__/WorkflowCest__it_should_run_build_as_workflow__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/WorkflowCest__it_should_run_build_as_workflow__0.snapshot.txt @@ -7,6 +7,7 @@ Running build workflow steps... .. .puprc bootstrap.php +node_modules other-file.php package.json src diff --git a/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_with_repo_using_file_colon_slash_slash__0.snapshot.txt b/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_with_repo_using_file_colon_slash_slash__0.snapshot.txt index 58ae076..4993696 100644 --- a/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_with_repo_using_file_colon_slash_slash__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_with_repo_using_file_colon_slash_slash__0.snapshot.txt @@ -1,4 +1,4 @@ -Cloning the file:///var/www/html/wp-content/plugins/pup/tests/_data/fake-project-git-repo repo into .pup-build... +Cloning the file://{PUP_ROOT}/pup/tests/_data/fake-project-git-repo repo into .pup-build... ✓ Clone complete. Running build steps... @@ -9,6 +9,7 @@ Running build steps... .. .git bootstrap.php +node_modules other-file.php package.json src diff --git a/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_with_repo_using_path__0.snapshot.txt b/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_with_repo_using_path__0.snapshot.txt index b5af0b3..fb4f4b5 100644 --- a/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_with_repo_using_path__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_with_repo_using_path__0.snapshot.txt @@ -1,4 +1,4 @@ -Cloning the /var/www/html/wp-content/plugins/pup/tests/_data/fake-project-git-repo repo into .pup-build... +Cloning the {PUP_ROOT}/pup/tests/_data/fake-project-git-repo repo into .pup-build... ✓ Clone complete. Running build steps... @@ -9,6 +9,7 @@ Running build steps... .. .git bootstrap.php +node_modules other-file.php package.json src diff --git a/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_without_cloning__0.snapshot.txt b/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_without_cloning__0.snapshot.txt index 9b5f7bb..374e786 100644 --- a/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_without_cloning__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_without_cloning__0.snapshot.txt @@ -7,6 +7,7 @@ Running build steps... .. .puprc bootstrap.php +node_modules other-file.php package.json src diff --git a/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_without_running_checks_when_checks_are_empty__0.snapshot.txt b/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_without_running_checks_when_checks_are_empty__0.snapshot.txt index 139afa2..646ba69 100644 --- a/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_without_running_checks_when_checks_are_empty__0.snapshot.txt +++ b/tests/cli/Commands/__snapshots__/ZipCest__it_should_zip_without_running_checks_when_checks_are_empty__0.snapshot.txt @@ -7,6 +7,7 @@ Running build steps... .. .puprc bootstrap.php +node_modules other-file.php package.json src