Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer post install script to copy .dist files #522

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
35 changes: 35 additions & 0 deletions bin/composer-post-install-script.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols

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',
],
[
MarioRadu marked this conversation as resolved.
Show resolved Hide resolved
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
alexmerlin marked this conversation as resolved.
Show resolved Hide resolved
'destination' => 'config/autoload/mail.global.php',
],
];

array_walk($files, 'copyFile');
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@
"laminas/laminas-coding-standard": "^2.5",
"laminas/laminas-development-mode": "^3.12.0",
"mezzio/mezzio-tooling": "^2.9.0",
"phpunit/phpunit": "^10.5",
"roave/security-advisories": "dev-master",
"vincentlanglet/twig-cs-fixer": "^2.12",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"symfony/var-dumper": "^7.1"
"phpunit/phpunit": "^10.5",
"roave/security-advisories": "dev-master",
"symfony/var-dumper": "^7.1",
"vincentlanglet/twig-cs-fixer": "^2.12"
},
"autoload": {
"psr-4": {
Expand All @@ -104,6 +104,9 @@
"post-create-project-cmd": [
"@development-enable"
],
"post-update-cmd": [
"php bin/composer-post-install-script.php"
],
"development-disable": "laminas-development-mode disable",
"development-enable": "laminas-development-mode enable",
"development-status": "laminas-development-mode status",
Expand Down
115 changes: 0 additions & 115 deletions config/autoload/mail.local.php.dist

This file was deleted.

Loading