Skip to content

Commit 9115dc3

Browse files
committed
merge master
2 parents 8cad05a + 34fc5d0 commit 9115dc3

File tree

8 files changed

+130
-2789
lines changed

8 files changed

+130
-2789
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ tests/
1212
utils/
1313
vendor/
1414
wp-cli.local.yml
15-
wp-cli.yml
15+
composer.lock

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ OPTIONS
4242
The directory of the new VCCW based guest machine.
4343
4444
[--host=<hostname>]
45-
Hostname of the guest machine. Default is `vccw.dev`.
45+
Hostname of the guest machine. Default is `vccw.test`.
4646
4747
[--ip=<ip-address>]
4848
IP address of the guest machine. Default is `192.168.33.10`.

cli.php

Lines changed: 4 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -4,120 +4,9 @@
44
return;
55
}
66

7-
require_once( dirname( __FILE__ ) . "/lib/functions.php" );
8-
9-
/**
10-
* Generate a new VCCW environment.
11-
*
12-
* @subpackage commands/community
13-
* @maintainer Takayuki Miyauchi
14-
*/
15-
class WP_CLI_Scaffold_VCCW extends WP_CLI_Command
16-
{
17-
/**
18-
* Generate a new VCCW environment.
19-
*
20-
* ## OPTIONS
21-
*
22-
* <directory>
23-
* : The directory of the new VCCW based guest machine.
24-
*
25-
* [--host=<hostname>]
26-
* : Hostname of the guest machine. Default is `vccw.dev`.
27-
*
28-
* [--ip=<ip-address>]
29-
* : IP address of the guest machine. Default is `192.168.33.10`.
30-
*
31-
* [--lang=<language>]
32-
* : Language of the WordPress. Default is `en_US`.
33-
*
34-
* [--update]
35-
* : Update files of the VCCW to latest version.
36-
*
37-
* ## EXAMPLES
38-
*
39-
* $ wp scaffold vccw wordpress.dev
40-
* Generating: 100% [===========================] 0:03 / 0:06
41-
* Success: Generated.
42-
*
43-
* $ wp scaffold vccw wordpress.dev --lang=ja
44-
* Generating: 100% [===========================] 0:03 / 0:06
45-
* Success: Generated.
46-
*
47-
* @when before_wp_load
48-
*/
49-
public function __invoke( $args, $assoc_args )
50-
{
51-
if ( empty( $assoc_args["host"] ) ) {
52-
$assoc_args["host"] = "vccw.dev";
53-
}
54-
55-
if ( empty( $assoc_args["ip"] ) ) {
56-
$assoc_args["ip"] = "192.168.33.10";
57-
}
58-
59-
if ( empty( $assoc_args["lang"] ) ) {
60-
$assoc_args["lang"] = "en_US";
61-
}
62-
63-
$update = \WP_CLI\Utils\get_flag_value( $assoc_args, 'update' );
64-
65-
$path = preg_replace( "#/$#", "", $args[0] );
66-
if ( is_file( $path . '/site.yml' ) && true !== $update ) {
67-
WP_CLI::error( "`site.yml` already exists." );
68-
}
69-
70-
$url = Scaffold_VCCW::get_latest_vccw_url();
71-
if ( ! $url ) {
72-
WP_CLI::error( "Can't connect GitHub's API. Please try later." );
73-
}
74-
75-
$zip = Scaffold_VCCW::download( $url );
76-
if ( ! $zip ) {
77-
WP_CLI::error( "Can't download zip. Please try later." );
78-
}
79-
80-
$file = tempnam( sys_get_temp_dir(), "" );
81-
file_put_contents( $file, $zip );
82-
83-
try {
84-
$dir = Scaffold_VCCW::tempdir();
85-
Scaffold_VCCW::unzip( $file, $dir );
86-
} catch (Exception $e) {
87-
Scaffold_VCCW::rrmdir( $dir );
88-
WP_CLI::error( $e->getMessage() );
89-
}
90-
91-
if ( is_dir( $dir ) ) {
92-
if ( $dh = opendir( $dir ) ) {
93-
while ( ( $file = readdir( $dh ) ) !== false ) {
94-
$src = $dir . "/" . $file;
95-
if ( preg_match( "/^vccw/", $file ) && is_dir( $src ) ) {
96-
Scaffold_VCCW::rcopy( $src, $path );
97-
break;
98-
}
99-
}
100-
closedir( $dh );
101-
}
102-
}
103-
104-
Scaffold_VCCW::rrmdir( $dir );
105-
106-
if ( true === $update ) {
107-
WP_CLI::success( "Updated. Run `vagrant up`." );
108-
} else {
109-
$sitefile = WP_CLI\Utils\mustache_render(
110-
Scaffold_VCCW::get_yml_template(),
111-
array(
112-
'host' => $assoc_args["host"],
113-
'ip' => $assoc_args["ip"],
114-
'lang' => $assoc_args["lang"],
115-
)
116-
);
117-
file_put_contents( $path . '/site.yml', $sitefile );
118-
WP_CLI::success( "Generated. Run `vagrant up`." );
119-
}
120-
}
7+
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
8+
if ( file_exists( $autoload ) ) {
9+
require_once $autoload;
12110
}
12211

123-
WP_CLI::add_command( 'scaffold vccw', 'WP_CLI_Scaffold_VCCW' );
12+
WP_CLI::add_command( 'scaffold vccw', 'Scaffold_VCCW_Command' );

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"license": "MIT",
77
"authors": [],
88
"autoload": {
9+
"psr-4": {
10+
"": "src/"
11+
},
912
"files": [ "cli.php" ]
1013
},
1114
"scripts": {
@@ -17,7 +20,7 @@
1720
"require": {},
1821
"require-dev": {
1922
"behat/behat": "~2.5",
20-
"wp-cli/wp-cli": ">=0.23.0",
21-
"phpunit/phpunit": "^4.8"
23+
"wp-cli/wp-cli": "*",
24+
"phpunit/phpunit": "~5.6"
2225
}
2326
}

0 commit comments

Comments
 (0)