Skip to content

Commit

Permalink
Merge pull request #11 from aaemnnosttv/fix/configurable-install-path
Browse files Browse the repository at this point in the history
Configurable install path
  • Loading branch information
aaemnnosttv authored Oct 2, 2016
2 parents b6afab3 + 6b92f58 commit 8cec526
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
9 changes: 9 additions & 0 deletions features/valet-new-project-bedrock.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ Feature: It can create new installs for Valet-supported WordPress projects.

When I run `wp valet destroy {PROJECT} --yes`
Then the {PROJECT} directory should not exist

@issue-10
Scenario: It can create a new Bedrock install using the given path to the parent dir.
Given an empty directory
And a random project name as {PROJECT}
And a random string as {PATH}

When I run `wp valet new {PROJECT} --project=bedrock --in={PATH} --debug`
Then the {PATH}/{PROJECT}/.env file should exist
11 changes: 7 additions & 4 deletions features/valet-new.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,30 @@ Feature: Create a new install.
Success: {PROJECT} ready! http://{PROJECT}.dev
"""

@issue-10
Scenario: It accepts options for configuring the new install.
Given an empty directory
And a random project name as {PROJECT}
And a random string as {ADMIN}
And a random string as {PATH}

When I run `wp valet new {PROJECT} --admin_user={ADMIN} --admin_email=hello@{PROJECT}.dev --version=4.5 --dbname=wp_cli_test --dbprefix={ADMIN}_ --dbuser=wp_cli_test --dbpass=password1`
When I run `wp valet new {PROJECT} --in={PATH} --admin_user={ADMIN} --admin_email=hello@{PROJECT}.dev --version=4.5 --dbname=wp_cli_test --dbprefix={ADMIN}_ --dbuser=wp_cli_test --dbpass=password1`
Then the {PATH}/{PROJECT}/wp-config.php file should exist
Then the wp_cli_test database should exist

When I run `wp db tables --path={PROJECT}`
When I run `wp db tables --path={PATH}/{PROJECT}`
Then STDOUT should contain:
"""
{ADMIN}_users
"""

When I run `wp core version --path={PROJECT}`
When I run `wp core version --path={PATH}/{PROJECT}`
Then STDOUT should be:
"""
4.5
"""

When I run `wp user list --fields=ID,user_login,user_email --path={PROJECT}`
When I run `wp user list --fields=ID,user_login,user_email --path={PATH}/{PROJECT}`
Then STDOUT should be a table containing rows:
| ID | user_login | user_email |
| 1 | {ADMIN} | hello@{PROJECT}.dev |
Expand Down
4 changes: 4 additions & 0 deletions src/Installer/BedrockInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public function download()
{
Command::debug('Installing Bedrock via Composer');

if (! is_dir($full_path = $this->props->projectRoot())) {
mkdir($full_path, 0755, true);
}

Composer::createProject('roots/bedrock', $this->props->site_name, [
'working-dir' => $this->props->parentDirectory(),
'no-interaction' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Installer/WordPressInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function download()
'locale' => $this->props->option('locale'),
]);

if (! is_dir($full_path = $this->props->fullPath())) {
if (! is_dir($full_path = $this->props->projectRoot())) {
mkdir($full_path, 0755, true);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Props.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function parentDirectory()
public function fullPath($relative = '')
{
$parts = array_filter([
$this->option('path', getcwd()),
$this->option('in', getcwd()),
$this->site_name,
$relative
]);
Expand Down
4 changes: 4 additions & 0 deletions src/ValetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public static function boot()
* - bedrock
* ---
*
* [--in=<dir>]
* : Specify the path to the parent directory to create the install in.
* Defaults to the current working directory.
*
* [--version=<version>]
* : WordPress version to install.
* ---
Expand Down

0 comments on commit 8cec526

Please sign in to comment.