-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 56-undefined-array-key-database
- Loading branch information
Showing
11 changed files
with
1,061 additions
and
739 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Run Pest Tests | ||
on: [ pull_request ] | ||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.3 | ||
|
||
- name: Install dependencies | ||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist | ||
|
||
- name: Run Pest tests | ||
run: ./vendor/bin/pest | ||
|
||
- name: Get Composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Veyoze CLI. | ||
* | ||
* (c) Mehran Rasulian <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace App\Actions; | ||
|
||
use App\Traits\Outputifier; | ||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Str; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
|
||
class MergeEnvironmentVariables | ||
{ | ||
use AsAction; | ||
use Outputifier; | ||
|
||
public function handle(string $source, array $newVariables): string | ||
{ | ||
$output = ''; | ||
|
||
if (! empty($source)) { | ||
$output = $this->searchReplaceExistingVariables($source, $newVariables); | ||
} | ||
|
||
foreach ($newVariables as $newKey => $newValue) { | ||
$output .= "$newKey=$newValue\n"; | ||
} | ||
|
||
return $output; | ||
} | ||
|
||
protected function searchReplaceExistingVariables(string $source, array &$newVariables): string | ||
{ | ||
$separator = Str::contains($source, ';') ? ';' : "\n"; | ||
$output = ''; | ||
|
||
foreach (explode($separator, $source) as $variable) { | ||
if (empty($variable)) { | ||
$output .= "\n"; | ||
|
||
continue; | ||
} | ||
|
||
[$key, $value] = explode('=', $variable, 2); | ||
|
||
if (empty($key)) { | ||
$this->warning("No key found for the assigned value \"$value\" inside your environment variables! Make sure to remove it."); | ||
|
||
continue; | ||
} | ||
|
||
$value = array_key_exists($key, $newVariables) ? Arr::pull($newVariables, $key) : $value; | ||
|
||
$output .= "$key=$value\n"; | ||
} | ||
|
||
return $output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.