Skip to content

Commit

Permalink
Bugfix Lima support
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoollllee committed Sep 26, 2023
1 parent 34a0258 commit 1a96a16
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ Requires these Deployer environment variables to be set:
- local_root: Absolute path to website root directory on local host machine
- trellis_dir: Absolute path to directory that contains trellis
- vm_root: Absolute path to website inside Virtual machine (should mirror local_root)
- vm_shell: Virtual Machine SSH Prefix (e.g. `vagrant ssh -- -t`)
- vm_shell: Virtual Machine SSH Pattern (e.g. `vagrant ssh -- -t cd {{vm_root}}`)

Example:

````php
set( 'local_root', dirname( __FILE__ ) );
set( 'trellis_dir', dirname( __FILE__ ) . '/../trellis' );
set( 'vm_root', '/srv/www/domain.com/current' );
set( 'vm_shell', 'trellis vm shell --workdir ' . get('vm_root') . ' --' );
````

### Valet+ environment
Expand Down
2 changes: 1 addition & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Bedrock DB config
set( 'trellis_dir', get('local_root') . '/../trellis' );
set( 'vm_root', '/srv/www/' . get('domain') . '/current' );
set( 'vm_shell', 'trellis vm shell --' ); // or 'vagrant ssh -- -t'
set( 'vm_shell', 'trellis vm shell --workdir ' . get('vm_root') . ' --' );

// Bedrock DB and Sage config
set( 'theme_path', function () { return getenv('THEME_PATH'); });
Expand Down
14 changes: 7 additions & 7 deletions recipe/bedrock_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
$backupFilename = '_db_backup_' . date('Y-m-d_H-i-s') . '.sql';
$backupAbsFile = get('local_root') . '/' . $backupFilename;
writeln("<comment>Making backup of DB on local machine to {$backupAbsFile}</comment>");
runLocally("cd {{trellis_dir}} && {{vm_shell}} \"cd {{vm_root}}; wp db export {$backupFilename}\"");
runLocally("cd {{trellis_dir}} && {{vm_shell}} wp db export {$backupFilename}");

// Empty local DB
writeln("<comment>Reset local DB</comment>");
runLocally("cd {{trellis_dir}} && {{vm_shell}} \"cd {{vm_root}}; wp db reset\"");
runLocally("cd {{trellis_dir}} && {{vm_shell}} wp db reset");

// Import export file
writeln("<comment>Importing {$downloadedExport}</comment>");
runLocally("cd {{trellis_dir}} && {{vm_shell}} \"cd {{vm_root}}; wp db import {$exportFilename}\"");
runLocally("cd {{trellis_dir}} && {{vm_shell}} wp db import {$exportFilename}");

// Load local .env file and get local WP URL
if (!$localUrl = $getLocalEnv()) {
Expand All @@ -77,11 +77,11 @@
// In the DB however, this new remote domain doesn't exist yet before search-replace. So we have
// to specify the old (remote) domain as --url parameter.
writeln("<comment>Updating the URLs in the DB</comment>");
runLocally("cd {{trellis_dir}} && {{vm_shell}} \"cd {{vm_root}}; wp search-replace '{$remoteUrl}' '{$localUrl}' --skip-themes --url='{$remoteDomain}' --network\"");
runLocally("cd {{trellis_dir}} && {{vm_shell}} wp search-replace '{$remoteUrl}' '{$localUrl}' --skip-themes --url='{$remoteDomain}' --network");
// Also replace domain (multisite WP also uses domains without protocol in DB)
runLocally("cd {{trellis_dir}} && {{vm_shell}} \"cd {{vm_root}}; wp search-replace '{$remoteDomain}' '{$localDomain}' --skip-themes --url='{$remoteDomain}' --network\"");
runLocally("cd {{trellis_dir}} && {{vm_shell}} wp search-replace '{$remoteDomain}' '{$localDomain}' --skip-themes --url='{$remoteDomain}' --network");
// Flush Permalinks
runLocally( "cd {{trellis_dir}} && {{vm_shell}} \"cd {{vm_root}}; wp rewrite flush --hard\"" );
runLocally( "cd {{trellis_dir}} && {{vm_shell}} wp rewrite flush --hard" );

// Cleanup exports on local machine
writeln("<comment>Cleaning up {$downloadedExport} on local machine</comment>");
Expand All @@ -95,7 +95,7 @@
$exportFilename = '_db_export_' . date('Y-m-d_H-i-s') . '.sql';
$exportAbsFile = get('local_root') . '/' . $exportFilename;
writeln("<comment>Exporting Virtual Machine DB to {$exportAbsFile}</comment>");
runLocally("cd {{trellis_dir}} && {{vm_shell}} \"cd {{vm_root}}; wp db export {$exportFilename}\"");
runLocally("cd {{trellis_dir}} && {{vm_shell}} wp db export {$exportFilename}");

// Upload export to server
$uploadedExport = get('current_path') . '/' . $exportFilename;
Expand Down

0 comments on commit 1a96a16

Please sign in to comment.