Skip to content

Commit

Permalink
Fix error during Bedrock installs (#63)
Browse files Browse the repository at this point in the history
* lock illuminate/container on pre 5.7

* tag create bedrock install feature with issue

* update bedrock db prefix handling in .env

* update expected format of DB_PREFIX in .env
  • Loading branch information
aaemnnosttv authored Feb 22, 2020
1 parent 740f1b4 commit 480da86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"require": {
"php": ">=5.5",
"illuminate/container": "^5.1",
"illuminate/container": ">=5.1 <5.7",
"symfony/filesystem": "^2.7 || ^3 || ^4",
"wp-cli/config-command": "^1 || ^2",
"wp-cli/core-command": "^1 || ^2",
Expand Down
3 changes: 2 additions & 1 deletion features/valet-new-project-bedrock.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Feature: It can create new installs for Valet-supported WordPress projects.

@issue-62
Scenario: Create a new Bedrock install.
Given an empty directory
And a random project name as {PROJECT}
Expand Down Expand Up @@ -51,7 +52,7 @@ Feature: It can create new installs for Valet-supported WordPress projects.
When I run `wp valet new {PROJECT} --project=bedrock --in={PATH} --dbprefix=foo`
Then the {PATH}/{PROJECT}/.env file should contain:
"""
DB_PREFIX=foo
DB_PREFIX='foo'
"""
And I run `wp eval 'echo getenv("DB_PREFIX");' --path={PATH}/{PROJECT}/web/wp/`
Then STDOUT should be:
Expand Down
8 changes: 6 additions & 2 deletions src/Installer/BedrockInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,22 @@ public function configure()
'database_password',
'database_host',
'http://example.com',
'# DB_PREFIX=wp_'
],
[
$this->props->databaseName(),
$this->props->option('dbuser'),
$this->props->databasePassword(),
$this->props->option('dbhost', 'localhost'),
$this->props->fullUrl(),
sprintf('DB_PREFIX=%s', $this->props->option('dbprefix'))
],
file_get_contents($this->props->fullPath('.env.example'))
);
// DB_PREFIX value is quoted in newer versions, not in older.
$env_contents = preg_replace(
'/# DB_PREFIX=.*/',
sprintf('DB_PREFIX=\'%s\'', $this->props->option('dbprefix')),
$env_contents
);

file_put_contents($this->props->fullPath('.env'), $env_contents);
}
Expand Down

0 comments on commit 480da86

Please sign in to comment.