Skip to content

Commit

Permalink
Made the Nginx keys NginxTemplateSearchReplace work with TextToArray …
Browse files Browse the repository at this point in the history
…action
  • Loading branch information
mehrancodes committed Oct 6, 2023
1 parent 077467a commit 1b3bbe8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 49 deletions.
32 changes: 0 additions & 32 deletions app/Actions/SearchReplaceKeysInText.php

This file was deleted.

13 changes: 11 additions & 2 deletions app/Services/Forge/Pipeline/NginxTemplateSearchReplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace App\Services\Forge\Pipeline;

use App\Actions\SearchReplaceKeysInText;
use App\Actions\TextToArray;
use App\Services\Forge\ForgeService;
use App\Traits\Outputifier;
use Closure;
Expand All @@ -36,12 +36,21 @@ public function __invoke(ForgeService $service, Closure $next)
$service->forge->updateSiteNginxFile(
$service->setting->server,
$service->site->id,
SearchReplaceKeysInText::run(
$this->searchAndReplaceKeys(
$service->setting->nginxSubstitute,
$template
)
);

return $next($service);
}

protected function searchAndReplaceKeys(string $substitutes, string $template): string
{
foreach (TextToArray::run($substitutes) as $key => $value) {
$template = str_replace($key, $value, $template);
}

return $template;
}
}
30 changes: 15 additions & 15 deletions config/forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Git service provider (default: 'github').
'git_provider' => env('FORGE_GIT_PROVIDER', 'github'),

// Git repository URL or name.
// Git repository name.
'repository' => env('FORGE_GIT_REPOSITORY'),

// Git branch name.
Expand All @@ -22,6 +22,18 @@
// Pattern for subdomains.
'subdomain_pattern' => env('FORGE_SUBDOMAIN_PATTERN'),

// Deployment script content.
'deploy_script' => env('FORGE_DEPLOY_SCRIPT'),

// Template for Nginx configuration.
'nginx_template' => env('FORGE_NGINX_TEMPLATE'),

// Key/value pairs for customizing the Nginx template.
'nginx_substitute' => env('FORGE_NGINX_SUBSTITUTE'),

// Key/value pairs to be added to the environment file at runtime.
'env_keys' => env('FORGE_ENV_KEYS'),

// PHP version (default: 'php82').
'php_version' => env('FORGE_PHP_VERSION', 'php82'),

Expand All @@ -40,27 +52,15 @@
// Flag indicating if a database should be created (default: false).
'db_creation_required' => env('FORGE_DB_CREATION_REQUIRED', false),

// Flag to enable SSL certification (default: false).
'ssl_required' => env('FORGE_SSL_REQUIRED', false),
// Flag to enable SSL certification (default: true).
'ssl_required' => env('FORGE_SSL_REQUIRED', true),

// Flag to pause until SSL setup completes during provisioning (default: true).
'wait_on_ssl' => env('FORGE_WAIT_ON_SSL', true),

// Flag to pause until site deployment completes during provisioning (default: true).
'wait_on_deploy' => env('FORGE_WAIT_ON_DEPLOY', true),

// Template for Nginx configuration.
'nginx_template' => env('FORGE_NGINX_TEMPLATE'),

// Key/value pairs for customizing the Nginx template.
'nginx_substitute' => env('FORGE_NGINX_SUBSTITUTE'),

// Flag to enable Quick Deploy (default: true).
'quick_deploy' => env('FORGE_QUICK_DEPLOY', true),

// Deployment script content.
'deploy_script' => env('FORGE_DEPLOY_SCRIPT'),

// Key/value pairs to be added to the environment file at runtime.
'env_keys' => env('FORGE_ENV_KEYS'),
];

0 comments on commit 1b3bbe8

Please sign in to comment.