Skip to content

Commit f1d7f04

Browse files
authored
Merge branch 'main' into update/cpt-scaffold
2 parents 9330fbe + dd56e0b commit f1d7f04

15 files changed

+152
-219
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Testing
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
push:
67
branches:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ The following files are also included unless the `--skip-tests` is used:
238238
options:
239239
- circle
240240
- gitlab
241+
- bitbucket
241242
- github
242243
---
243244

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"wp-cli/wp-cli": "^2.5"
15+
"wp-cli/wp-cli": "^2.12"
1616
},
1717
"require-dev": {
1818
"wp-cli/extension-command": "^1.2 || ^2",
@@ -24,7 +24,8 @@
2424
"allow-plugins": {
2525
"dealerdirect/phpcodesniffer-composer-installer": true,
2626
"johnpbloch/wordpress-core-installer": true
27-
}
27+
},
28+
"lock": false
2829
},
2930
"extra": {
3031
"branch-alias": {

features/scaffold-plugin-tests.feature

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -172,42 +172,29 @@ Feature: Scaffold plugin unit tests
172172
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
173173
"""
174174
- step:
175-
image: php:5.6
176-
name: "PHP 5.6"
175+
image: php:7.4
176+
name: "PHP 7.4"
177177
script:
178178
# Install Dependencies
179-
- docker-php-ext-install mysqli
180-
- apt-get update && apt-get install -y subversion --no-install-recommends
179+
- apt-get update && apt-get install -y subversion git zip libzip-dev --no-install-recommends
181180
"""
182181
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
183182
"""
184183
- step:
185-
image: php:7.0
186-
name: "PHP 7.0"
184+
image: php:8.0
185+
name: "PHP 8.0"
187186
script:
188187
# Install Dependencies
189-
- docker-php-ext-install mysqli
190-
- apt-get update && apt-get install -y subversion --no-install-recommends
188+
- apt-get update && apt-get install -y subversion git zip libzip-dev --no-install-recommends
191189
"""
192190
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
193191
"""
194192
- step:
195-
image: php:7.1
196-
name: "PHP 7.1"
193+
image: php:8.2
194+
name: "PHP 8.2"
197195
script:
198196
# Install Dependencies
199-
- docker-php-ext-install mysqli
200-
- apt-get update && apt-get install -y subversion --no-install-recommends
201-
"""
202-
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
203-
"""
204-
- step:
205-
image: php:7.2
206-
name: "PHP 7.2"
207-
script:
208-
# Install Dependencies
209-
- docker-php-ext-install mysqli
210-
- apt-get update && apt-get install -y subversion --no-install-recommends
197+
- apt-get update && apt-get install -y subversion git zip libzip-dev --no-install-recommends
211198
"""
212199
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
213200
"""
@@ -309,3 +296,16 @@ Feature: Scaffold plugin unit tests
309296
"""
310297
require dirname( dirname( __FILE__ ) ) . '/bar.php';
311298
"""
299+
300+
Scenario: Accept bitbucket as valid CI in plugin scaffold
301+
Given a WP install
302+
When I run `wp plugin path`
303+
Then save STDOUT as {PLUGIN_DIR}
304+
305+
When I run `wp scaffold plugin hello-world --ci=bitbucket`
306+
Then STDOUT should not be empty
307+
And the {PLUGIN_DIR}/hello-world/.editorconfig file should exist
308+
And the {PLUGIN_DIR}/hello-world/hello-world.php file should exist
309+
And the {PLUGIN_DIR}/hello-world/readme.txt file should exist
310+
And the {PLUGIN_DIR}/hello-world/bitbucket-pipelines.yml file should exist
311+
And the {PLUGIN_DIR}/hello-world/tests directory should exist

features/scaffold-theme-tests.feature

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -168,42 +168,29 @@ Feature: Scaffold theme unit tests
168168
And the {THEME_DIR}/t12child/bitbucket-pipelines.yml file should contain:
169169
"""
170170
- step:
171-
image: php:5.6
172-
name: "PHP 5.6"
171+
image: php:7.4
172+
name: "PHP 7.4"
173173
script:
174174
# Install Dependencies
175-
- docker-php-ext-install mysqli
176-
- apt-get update && apt-get install -y subversion --no-install-recommends
175+
- apt-get update && apt-get install -y subversion git zip libzip-dev --no-install-recommends
177176
"""
178177
And the {THEME_DIR}/t12child/bitbucket-pipelines.yml file should contain:
179178
"""
180179
- step:
181-
image: php:7.0
182-
name: "PHP 7.0"
180+
image: php:8.0
181+
name: "PHP 8.0"
183182
script:
184183
# Install Dependencies
185-
- docker-php-ext-install mysqli
186-
- apt-get update && apt-get install -y subversion --no-install-recommends
184+
- apt-get update && apt-get install -y subversion git zip libzip-dev --no-install-recommends
187185
"""
188186
And the {THEME_DIR}/t12child/bitbucket-pipelines.yml file should contain:
189187
"""
190188
- step:
191-
image: php:7.1
192-
name: "PHP 7.1"
189+
image: php:8.2
190+
name: "PHP 8.2"
193191
script:
194192
# Install Dependencies
195-
- docker-php-ext-install mysqli
196-
- apt-get update && apt-get install -y subversion --no-install-recommends
197-
"""
198-
And the {THEME_DIR}/t12child/bitbucket-pipelines.yml file should contain:
199-
"""
200-
- step:
201-
image: php:7.2
202-
name: "PHP 7.2"
203-
script:
204-
# Install Dependencies
205-
- docker-php-ext-install mysqli
206-
- apt-get update && apt-get install -y subversion --no-install-recommends
193+
- apt-get update && apt-get install -y subversion git zip libzip-dev --no-install-recommends
207194
"""
208195
And the {THEME_DIR}/t12child/bitbucket-pipelines.yml file should contain:
209196
"""

features/scaffold.feature

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ Feature: WordPress code scaffolding
209209
And the {PLUGIN_DIR}/hello-world/.editorconfig file should exist
210210
And the {PLUGIN_DIR}/hello-world/hello-world.php file should exist
211211
And the {PLUGIN_DIR}/hello-world/readme.txt file should exist
212-
And the {PLUGIN_DIR}/hello-world/package.json file should exist
213-
And the {PLUGIN_DIR}/hello-world/Gruntfile.js file should exist
212+
And the {PLUGIN_DIR}/hello-world/composer.json file should exist
214213
And the {PLUGIN_DIR}/hello-world/.gitignore file should contain:
215214
"""
216215
.DS_Store
@@ -219,6 +218,7 @@ Feature: WordPress code scaffolding
219218
Thumbs.db
220219
wp-cli.local.yml
221220
node_modules/
221+
vendor/
222222
"""
223223
And the {PLUGIN_DIR}/hello-world/.distignore file should contain:
224224
"""
@@ -254,14 +254,10 @@ Feature: WordPress code scaffolding
254254
Tested up to: {WP_VERSION}
255255
"""
256256

257-
When I run `cat {PLUGIN_DIR}/hello-world/package.json`
258-
Then STDOUT should be JSON containing:
259-
"""
260-
{"author":"Hello World Author"}
261-
"""
262-
And STDOUT should be JSON containing:
257+
When I run `cat {PLUGIN_DIR}/hello-world/composer.json`
258+
Then STDOUT should contain:
263259
"""
264-
{"version":"0.1.0"}
260+
wp-cli/i18n-command
265261
"""
266262

267263
Scenario: Scaffold a plugin by prompting

src/Scaffold_Command.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,10 @@ public function child_theme( $args, $assoc_args ) {
508508
'theme_uri' => '',
509509
];
510510

511-
$data = wp_parse_args( $assoc_args, $defaults );
512-
$data['slug'] = $theme_slug;
513-
$data['parent_theme_function_safe'] = str_replace( [ ' ', '-' ], '_', $data['parent_theme'] );
514-
$data['description'] = ucfirst( $data['parent_theme'] ) . ' child theme.';
511+
$data = wp_parse_args( $assoc_args, $defaults );
512+
$data['slug'] = $theme_slug;
513+
$data['prefix_safe'] = str_replace( [ ' ', '-' ], '_', $theme_slug );
514+
$data['description'] = ucfirst( $data['parent_theme'] ) . ' child theme.';
515515

516516
$theme_dir = WP_CONTENT_DIR . "/themes/{$theme_slug}";
517517

@@ -624,6 +624,7 @@ private function get_output_path( $assoc_args, $subdir ) {
624624
* options:
625625
* - circle
626626
* - gitlab
627+
* - bitbucket
627628
* - github
628629
* ---
629630
*
@@ -686,8 +687,7 @@ public function plugin( $args, $assoc_args ) {
686687
$files_to_create = [
687688
$plugin_path => self::mustache_render( 'plugin.mustache', $data ),
688689
$plugin_readme_path => self::mustache_render( 'plugin-readme.mustache', $data ),
689-
"{$plugin_dir}/package.json" => self::mustache_render( 'plugin-packages.mustache', $data ),
690-
"{$plugin_dir}/Gruntfile.js" => self::mustache_render( 'plugin-gruntfile.mustache', $data ),
690+
"{$plugin_dir}/composer.json" => self::mustache_render( 'plugin-composer.mustache', $data ),
691691
"{$plugin_dir}/.gitignore" => self::mustache_render( 'plugin-gitignore.mustache', $data ),
692692
"{$plugin_dir}/.distignore" => self::mustache_render( 'plugin-distignore.mustache', $data ),
693693
"{$plugin_dir}/.editorconfig" => file_get_contents( self::get_template_path( '.editorconfig' ) ),

templates/child_theme_functions.mustache

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
* @package {{slug}}
88
*/
99

10-
add_action( 'wp_enqueue_scripts', '{{parent_theme_function_safe}}_parent_theme_enqueue_styles' );
10+
add_action( 'wp_enqueue_scripts', '{{prefix_safe}}_parent_theme_enqueue_styles' );
1111

1212
/**
1313
* Enqueue scripts and styles.
1414
*/
15-
function {{parent_theme_function_safe}}_parent_theme_enqueue_styles() {
16-
wp_enqueue_style( '{{parent_theme}}-style', get_template_directory_uri() . '/style.css' );
17-
wp_enqueue_style( '{{slug}}-style',
15+
function {{prefix_safe}}_parent_theme_enqueue_styles() {
16+
wp_enqueue_style( '{{parent_theme}}-style', get_template_directory_uri() . '/style.css', array(), '0.1.0' );
17+
wp_enqueue_style(
18+
'{{slug}}-style',
1819
get_stylesheet_directory_uri() . '/style.css',
19-
[ '{{parent_theme}}-style' ]
20+
array( '{{parent_theme}}-style' ),
21+
'0.1.0'
2022
);
2123
}

templates/install-wp-tests.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ download() {
2222
curl -s "$1" > "$2";
2323
elif [ `which wget` ]; then
2424
wget -nv -O "$2" "$1"
25+
else
26+
echo "Error: Neither curl nor wget is installed."
27+
exit 1
28+
fi
29+
}
30+
31+
# Check if svn is installed
32+
check_svn_installed() {
33+
if ! command -v svn > /dev/null; then
34+
echo "Error: svn is not installed. Please install svn and try again."
35+
exit 1
2536
fi
2637
}
2738

@@ -64,6 +75,7 @@ install_wp() {
6475
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
6576
mkdir -p $TMPDIR/wordpress-trunk
6677
rm -rf $TMPDIR/wordpress-trunk/*
78+
check_svn_installed
6779
svn export --quiet https://core.svn.wordpress.org/trunk $TMPDIR/wordpress-trunk/wordpress
6880
mv $TMPDIR/wordpress-trunk/wordpress/* $WP_CORE_DIR
6981
else
@@ -108,6 +120,7 @@ install_test_suite() {
108120
# set up testing suite
109121
mkdir -p $WP_TESTS_DIR
110122
rm -rf $WP_TESTS_DIR/{includes,data}
123+
check_svn_installed
111124
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
112125
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
113126
fi

templates/phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
backupGlobals="false"
55
colors="true"
66
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
87
convertWarningsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertDeprecationsToExceptions="true"
910
>
1011
<testsuites>
1112
<testsuite name="testing">

0 commit comments

Comments
 (0)