Skip to content

Commit

Permalink
Tweaks for local path
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc45 committed Mar 13, 2024
1 parent 9b9521a commit a13b805
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/src/Environment/Environments/EnvInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ abstract class EnvInfo implements \JsonSerializable {
*
* @var array<string, string> $volumes Each element of the array is:
* - Key: Container path (string)
* - Value: Local path (string)
* - Value: Local path (string) (Optional ":<FLAGS>", such as ":ro" for read-only)
*/
public $volumes = [];

public $volume_flags = [];

/**
* @var array<string> Array of docker images associated with this environment.
* @example [ 'qit_php_123456', 'qit_db_123456', 'qit_nginx_123456' ]
Expand Down
2 changes: 1 addition & 1 deletion src/src/Environment/Environments/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function generate_docker_compose(): void {
}
}

$this->env_info->volumes = $volumes;
$this->env_info->volumes = array_merge( $this->env_info->volumes, $volumes );

$process->setEnv( array_merge( $process->getEnv(), [
'QIT_ENV_ID' => $this->env_info->env_id,
Expand Down
7 changes: 4 additions & 3 deletions src/src/Environment/ExtensionDownload/ExtensionDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ public function download( EnvInfo $env_info, string $cache_dir, array $plugins =
if ( is_file( $e->path ) ) {
$this->extension_zip->extract_zip( $e->path, "$env_info->temporary_env/html/wp-content/{$e->type}s" );
} elseif ( is_dir( $e->path ) ) {
$env_info->volumes["/app/wp-content/{$e->type}s/{$e->extension_identifier}"] = $e->path;
if ( ! getenv( 'QIT_ALLOW_WRITE' ) ) {
// Set it as read-only to prevent dev messing up their local copy inadvertly (default behavior).
$env_info->volume_flags["/app/wp-content/{$e->type}s/{$e->extension_identifier}"] = 'ro';
// Set it as read-only to prevent dev messing up their local copy inadvertently (default behavior).
$env_info->volumes["/app/wp-content/{$e->type}s/{$e->extension_identifier}:ro"] = $e->path;
} else {
$env_info->volumes["/app/wp-content/{$e->type}s/{$e->extension_identifier}"] = $e->path;
}
} else {
throw new \RuntimeException( 'Download failed.' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ protected function find_type_in_dir( Extension $extension ): void {
// Search for 'Plugin Name:' in '.php' files
if ( $file->getExtension() === 'php' ) {
$contents = file_get_contents( $file->getPathname() );
if ( strpos( $contents, 'Plugin Name:' ) !== false ) {
if ( stripos( $contents, 'Plugin Name:' ) !== false ) {
$extension->type = 'plugin';
break;
}
} elseif ( $file->getExtension() === 'css' ) {
$contents = file_get_contents( $file->getPathname() );
if ( strpos( $contents, 'Theme Name:' ) !== false ) {
if ( stripos( $contents, 'Theme Name:' ) !== false ) {
$extension->type = 'theme';
break;
}
Expand Down

0 comments on commit a13b805

Please sign in to comment.