Skip to content

Commit 9c15c31

Browse files
authored
Merge pull request #91 from wp-cli/use-psr-4
Use PSR-4 for autoloading
2 parents cffa64e + bf7d727 commit 9c15c31

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@
1616
],
1717
"minimum-stability": "dev",
1818
"autoload": {
19-
"files": [ "command.php" ]
19+
"psr-4": { "WP_CLI\\": "src" },
20+
"files": [ "scaffold-package-command.php" ]
2021
},
2122
"require": {
22-
"wp-cli/wp-cli": "^1.0.0"
23+
"wp-cli/wp-cli": "dev-master"
2324
},
2425
"require-dev": {
2526
"behat/behat": "~2.5"
2627
},
2728
"extra": {
29+
"branch-alias": {
30+
"dev-master": "1.0.x-dev"
31+
},
2832
"commands": [
2933
"scaffold package",
3034
"scaffold package-tests",

command.php renamed to scaffold-package-command.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
return;
55
}
66

7-
require_once __DIR__ . '/inc/ScaffoldPackageCommand.php';
7+
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
8+
if ( file_exists( $autoload ) ) {
9+
require_once $autoload;
10+
}
811

912
WP_CLI::add_command( 'scaffold package', array( 'WP_CLI\ScaffoldPackageCommand', 'package' ) );
1013
WP_CLI::add_command( 'scaffold package-readme', array( 'WP_CLI\ScaffoldPackageCommand', 'package_readme' ) );

inc/ScaffoldPackageCommand.php renamed to src/ScaffoldPackageCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,16 @@ public function package( $args, $assoc_args ) {
8787

8888
$package_root = dirname( dirname( __FILE__ ) );
8989
$template_path = $package_root . '/templates/';
90+
$wp_cli_yml = <<<EOT
91+
require:
92+
- command.php
93+
EOT;
9094

9195
$files_written = $this->create_files( array(
9296
"{$package_dir}/.gitignore" => file_get_contents( "{$package_root}/.gitignore" ),
9397
"{$package_dir}/.editorconfig" => file_get_contents( "{$package_root}/.editorconfig" ),
9498
"{$package_dir}/.distignore" => file_get_contents( "{$package_root}/.distignore" ),
95-
"{$package_dir}/wp-cli.yml" => file_get_contents( "{$package_root}/wp-cli.yml" ),
99+
"{$package_dir}/wp-cli.yml" => $wp_cli_yml,
96100
"{$package_dir}/command.php" => Utils\mustache_render( "{$template_path}/command.mustache", $assoc_args ),
97101
"{$package_dir}/composer.json" => Utils\mustache_render( "{$template_path}/composer.mustache", $assoc_args ),
98102
), $force );

wp-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
require:
2-
- command.php
2+
- scaffold-package-command.php

0 commit comments

Comments
 (0)