Skip to content

Commit

Permalink
post install script
Browse files Browse the repository at this point in the history
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
  • Loading branch information
MarioRadu committed Dec 3, 2024
1 parent 88f96ab commit 22b787d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ jobs:
- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

# - name: Setup project
# run: |
# mv config/autoload/local.php.dist config/autoload/local.php
# mv config/autoload/mail.local.php.dist config/autoload/mail.local.php
# mv config/autoload/local.test.php.dist config/autoload/local.test.php

- name: Collect code coverage with PHPUnit
run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml

Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,5 @@ jobs:
- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

# - name: Setup project
# run: |
# mv config/autoload/local.php.dist config/autoload/local.php
# mv config/autoload/mail.local.php.dist config/autoload/mail.local.php
# mv config/autoload/local.test.php.dist config/autoload/local.test.php

- name: Run static analysis with PHPStan
run: vendor/bin/phpstan analyse
33 changes: 33 additions & 0 deletions bin/composer-post-install-script.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

Check warning on line 1 in bin/composer-post-install-script.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.2, latest], ubuntu-latest, laminas/laminas-continuous-integration-ac...

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 5 and the first side effect is on line 18.

Check warning on line 1 in bin/composer-post-install-script.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.2, latest], ubuntu-latest, laminas/laminas-continuous-integration-ac...

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 5 and the first side effect is on line 18.

declare(strict_types=1);

function copyFile(array $file): void
{
if (is_readable($file['destination'])) {
echo "File {$file['destination']} already exists." . PHP_EOL;
} else {
if (! copy($file['source'], $file['destination'])) {
echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL;
} else {
echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL;
}
}
}

$files = [
[
'source' => 'config/autoload/local.php.dist',
'destination' => 'config/autoload/local.php',
],
[
'source' => 'config/autoload/local.test.php.dist',
'destination' => 'config/autoload/local.test.php',
],
[
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
'destination' => 'config/autoload/mail.global.php',
],
];

array_walk($files, 'copyFile');
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@
"@development-enable"
],
"post-install-cmd": [
"php -r \"if (is_readable('config/autoload/local.php')) { echo 'File already exists' . PHP_EOL; } else { copy('config/autoload/local.php.dist', 'config/autoload/local.php'); echo 'File copied successfully'; }\"",
"php -r \"if (is_readable('config/autoload/local.test.php')) { echo 'File already exists' . PHP_EOL; } else { copy('config/autoload/local.test.php.dist', 'config/autoload/local.test.php'); echo 'File copied successfully'; }\"",
"php -r \"if (is_readable('config/autoload/mail.local.php')) { echo 'File already exists' . PHP_EOL; } else { copy('vendor/dotkernel/dot-mail/config/mail.global.php.dist', 'config/autoload/mail.local.php'); echo 'File copied successfully'; }\""
"php bin/composer-post-install-script.php"
],
"development-disable": "laminas-development-mode disable",
"development-enable": "laminas-development-mode enable",
Expand Down

0 comments on commit 22b787d

Please sign in to comment.