From f98a5ae9b71c153b13090dc28b9375f650e4e3d1 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 6 Mar 2024 10:42:25 -0500 Subject: [PATCH] Add base feature for generating a new feature of the plugin (#317) * Stubbing out the dream syntax * Adjusting the stub files * Adjusting the stub files0 * Finish the templates * Readme update * REVERT * Adjusting the stubs * Wrapping up the stubs * Update feature name * Remove bad file * Adjusting the stub files * Finishing new stubs * Wrap up feature for generating a plugin feature * Revert plugin deletiojn --- .scaffolder/plugin-feature/config.yml | 17 +++++++++++ .scaffolder/plugin-feature/feature.php.hbs | 27 +++++++++++++++++ .scaffolder/plugin-feature/test.php.hbs | 25 ++++++++++++++++ configure.php | 34 +++++++++++++++++++++- 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 .scaffolder/plugin-feature/config.yml create mode 100644 .scaffolder/plugin-feature/feature.php.hbs create mode 100644 .scaffolder/plugin-feature/test.php.hbs diff --git a/.scaffolder/plugin-feature/config.yml b/.scaffolder/plugin-feature/config.yml new file mode 100644 index 00000000..4f2ea00e --- /dev/null +++ b/.scaffolder/plugin-feature/config.yml @@ -0,0 +1,17 @@ +name: create-wordpress-plugin@plugin-feature + +inputs: + - name: featureName + description: "Feature Name" + type: string + - name: tests + description: "Include Tests?" + type: boolean + default: true + +files: + - source: feature.php.hbs + destination: src/features/{{ wpClassFilename inputs.featureName }} + - source: test.php.hbs + if: "{{ inputs.tests }}" + destination: tests/Features/{{ psrClassFilename inputs.featureName suffix="Test.php" }} diff --git a/.scaffolder/plugin-feature/feature.php.hbs b/.scaffolder/plugin-feature/feature.php.hbs new file mode 100644 index 00000000..7f705068 --- /dev/null +++ b/.scaffolder/plugin-feature/feature.php.hbs @@ -0,0 +1,27 @@ +assertTrue( true ); + } +} diff --git a/configure.php b/configure.php index cb7584d9..c845ab62 100644 --- a/configure.php +++ b/configure.php @@ -303,7 +303,39 @@ function determine_separator( string $path ): string { * @return array */ function list_all_files_for_replacement(): array { - return explode( PHP_EOL, run( 'grep -R -l . --exclude LICENSE --exclude configure.php --exclude .phpunit.result.cache --exclude-dir .phpcs --exclude composer.lock --exclude-dir .git --exclude-dir .github --exclude-dir vendor --exclude-dir node_modules --exclude-dir modules --exclude-dir .phpcs' ) ); + $exclude = [ + 'LICENSE', + 'configure.php', + '.phpunit.result.cache', + '.phpcs', + 'composer.lock', + ]; + + $exclude_dirs = [ + '.git', + 'pantheon-mu-plugin', + 'vendor', + 'node_modules', + '.phpcs', + '.scaffolder', + ]; + + $exclude = array_map( + fn ( string $file ) => "--exclude {$file}", + $exclude, + ); + + $exclude_dirs = array_map( + fn ( string $dir ) => "--exclude-dir {$dir}", + $exclude_dirs, + ); + + return explode( + PHP_EOL, + run( + "grep -R -l . " . implode( ' ', $exclude_dirs ) . ' ' . implode( ' ', $exclude ), + ), + ); } /**