Skip to content

Commit

Permalink
Merge pull request #364 from dotkernel/issue-363
Browse files Browse the repository at this point in the history
Composer post install script
  • Loading branch information
arhimede authored Dec 10, 2024
2 parents 2439e4d + 97bdca3 commit 1d8def4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 18 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.global.php.dist config/autoload/mail.global.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.global.php.dist config/autoload/mail.global.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',
],
[
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
'destination' => 'config/autoload/mail.global.php',
],
];

array_walk($files, 'copyFile');
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
"post-install-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
12 changes: 6 additions & 6 deletions config/autoload/local.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ $databases = [
];

return [
'application' => [
'application' => [
'name' => 'DotKernel API',
'url' => $baseUrl,
'versioning' => [
'documentation_url' => 'https://docs.dotkernel.org/api-documentation/v5/core-features/versioning',
],
],
'authentication' => [
'authentication' => [
'private_key' => [
'key_or_path' => getcwd() . '/data/oauth/private.key',
'key_permissions_check' => false,
Expand All @@ -45,15 +45,15 @@ return [
'message' => 'Invalid credentials.',
],
],
'databases' => $databases,
'doctrine' => [
'connection' => [
'databases' => $databases,
'doctrine' => [
'connection' => [
'orm_default' => [
'params' => $databases['default'],
],
],
],
'uploads' => [
'uploads' => [
'user' => [
'url' => $baseUrl . '/uploads/user',
'path' => realpath(__DIR__ . '/../../public/uploads/user'),
Expand Down

0 comments on commit 1d8def4

Please sign in to comment.