Skip to content

Commit 121644a

Browse files
committed
Adapt scaffolding logic
1 parent 9379287 commit 121644a

File tree

6 files changed

+82
-126
lines changed

6 files changed

+82
-126
lines changed

bin/install-package-tests.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

bin/test.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/ScaffoldPackageCommand.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ class ScaffoldPackageCommand {
4747
* default: ^2.5
4848
* ---
4949
*
50+
* [--require_wp_cli_tests=<version>]
51+
* : Required WP-CLI testing framework version for the package.
52+
* ---
53+
* default: ^3.0.11
54+
* ---
55+
5056
* [--skip-tests]
5157
* : Don't generate files for integration testing.
5258
*
@@ -103,13 +109,13 @@ public function package( $args, $assoc_args ) {
103109
EOT;
104110

105111
$files_written = $this->create_files( array(
106-
"{$package_dir}/.gitignore" => file_get_contents( "{$package_root}/.gitignore" ),
107-
"{$package_dir}/.editorconfig" => file_get_contents( "{$package_root}/.editorconfig" ),
108-
"{$package_dir}/.distignore" => file_get_contents( "{$package_root}/.distignore" ),
109-
"{$package_dir}/CONTRIBUTING.md"=> file_get_contents( "{$package_root}/CONTRIBUTING.md" ),
110-
"{$package_dir}/wp-cli.yml" => $wp_cli_yml,
111-
"{$package_dir}/command.php" => Utils\mustache_render( "{$template_path}/command.mustache", $assoc_args ),
112-
"{$package_dir}/composer.json" => Utils\mustache_render( "{$template_path}/composer.mustache", $assoc_args ),
112+
"{$package_dir}/.gitignore" => file_get_contents( "{$package_root}/.gitignore" ),
113+
"{$package_dir}/.editorconfig" => file_get_contents( "{$package_root}/.editorconfig" ),
114+
"{$package_dir}/.distignore" => file_get_contents( "{$package_root}/.distignore" ),
115+
"{$package_dir}/CONTRIBUTING.md" => file_get_contents( "{$package_root}/CONTRIBUTING.md" ),
116+
"{$package_dir}/wp-cli.yml" => $wp_cli_yml,
117+
"{$package_dir}/hello-world-command.php" => Utils\mustache_render( "{$template_path}/command.mustache", $assoc_args ),
118+
"{$package_dir}/composer.json" => Utils\mustache_render( "{$template_path}/composer.mustache", $assoc_args ),
113119
), $force );
114120

115121
if ( empty( $files_written ) ) {
@@ -612,13 +618,9 @@ public function package_tests( $args, $assoc_args ) {
612618
self::check_if_valid_package_dir( $package_dir );
613619

614620
$package_dir .= '/';
615-
$bin_dir = $package_dir . 'bin/';
616-
$utils_dir = $package_dir . 'utils/';
617621
$features_dir = $package_dir . 'features/';
618-
foreach ( array( $features_dir, $utils_dir, $bin_dir ) as $dir ) {
619-
if ( ! is_dir( $dir ) ) {
620-
Process::create( Utils\esc_cmd( 'mkdir %s', $dir ) )->run();
621-
}
622+
if ( ! is_dir( $features_dir ) ) {
623+
Process::create( Utils\esc_cmd( 'mkdir %s', $features_dir ) )->run();
622624
}
623625

624626
$package_root = dirname( dirname( __FILE__ ) );

templates/command.mustache

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@ $hello_world_command = function() {
1313
WP_CLI::success( "Hello world." );
1414
};
1515
WP_CLI::add_command( 'hello-world', $hello_world_command );
16+
<?php
17+
18+
if ( ! class_exists( 'WP_CLI' ) ) {
19+
return;
20+
}
21+
22+
$wpcli_hello_world_autoloader = __DIR__ . '/vendor/autoload.php';
23+
24+
if ( file_exists( $wpcli_hello_world_autoloader ) ) {
25+
require_once $wpcli_hello_world_autoloader;
26+
}
27+
28+
WP_CLI::add_command( 'hello-world', '\WP_CLI\HelloWorld\HelloWorldCommand' );

templates/composer.mustache

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,57 @@
1717
"wp-cli/wp-cli-tests": "^3.0.11"
1818
}
1919
}
20+
{
21+
"name": "{{name}}",
22+
"type": "wp-cli-package",
23+
"description": "{{description}}",
24+
"homepage": "{{homepage}}",
25+
"license": "{{license}}",
26+
"authors": [],
27+
"require": {
28+
"wp-cli/wp-cli": "{{require_wp_cli}}"
29+
},
30+
"require-dev": {
31+
"wp-cli/wp-cli-tests": "{{require_wp_cli_tests}}"
32+
},
33+
"config": {
34+
"process-timeout": 7200,
35+
"sort-packages": true
36+
},
37+
"extra": {
38+
"branch-alias": {
39+
"dev-master": "2.x-dev"
40+
},
41+
"bundled": false,
42+
"commands": [
43+
"hello-world"
44+
]
45+
},
46+
"autoload": {
47+
"psr-4": {
48+
"WP_CLI\\HelloWorld\\": "src/"
49+
},
50+
"files": [
51+
"hello-world-command.php"
52+
]
53+
},
54+
"minimum-stability": "dev",
55+
"prefer-stable": true,
56+
"scripts": {
57+
"behat": "run-behat-tests",
58+
"behat-rerun": "rerun-behat-tests",
59+
"lint": "run-linter-tests",
60+
"phpcs": "run-phpcs-tests",
61+
"phpunit": "run-php-unit-tests",
62+
"prepare-tests": "install-package-tests",
63+
"test": [
64+
"@lint",
65+
"@phpcs",
66+
"@phpunit",
67+
"@behat"
68+
]
69+
},
70+
"support": {
71+
"issues": "https://github.com/{{name}}/issues"
72+
}
73+
}

utils/behat-tags.php

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)