Skip to content

Commit 1d8def4

Browse files
authored
Merge pull request #364 from dotkernel/issue-363
Composer post install script
2 parents 2439e4d + 97bdca3 commit 1d8def4

File tree

5 files changed

+44
-18
lines changed

5 files changed

+44
-18
lines changed

.github/workflows/codecov.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ jobs:
4444
- name: Install dependencies with composer
4545
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
4646

47-
- name: Setup project
48-
run: |
49-
mv config/autoload/local.php.dist config/autoload/local.php
50-
mv config/autoload/mail.global.php.dist config/autoload/mail.global.php
51-
mv config/autoload/local.test.php.dist config/autoload/local.test.php
52-
5347
- name: Collect code coverage with PHPUnit
5448
run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml
5549

.github/workflows/static-analysis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,5 @@ jobs:
4444
- name: Install dependencies with composer
4545
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
4646

47-
- name: Setup project
48-
run: |
49-
mv config/autoload/local.php.dist config/autoload/local.php
50-
mv config/autoload/mail.global.php.dist config/autoload/mail.global.php
51-
mv config/autoload/local.test.php.dist config/autoload/local.test.php
52-
5347
- name: Run static analysis with PHPStan
5448
run: vendor/bin/phpstan analyse
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
6+
7+
function copyFile(array $file): void
8+
{
9+
if (is_readable($file['destination'])) {
10+
echo "File {$file['destination']} already exists." . PHP_EOL;
11+
} else {
12+
if (! copy($file['source'], $file['destination'])) {
13+
echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL;
14+
} else {
15+
echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL;
16+
}
17+
}
18+
}
19+
20+
$files = [
21+
[
22+
'source' => 'config/autoload/local.php.dist',
23+
'destination' => 'config/autoload/local.php',
24+
],
25+
[
26+
'source' => 'config/autoload/local.test.php.dist',
27+
'destination' => 'config/autoload/local.test.php',
28+
],
29+
[
30+
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
31+
'destination' => 'config/autoload/mail.global.php',
32+
],
33+
];
34+
35+
array_walk($files, 'copyFile');

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
"post-install-cmd": [
107107
"@development-enable"
108108
],
109+
"post-update-cmd": [
110+
"php bin/composer-post-install-script.php"
111+
],
109112
"development-disable": "laminas-development-mode disable",
110113
"development-enable": "laminas-development-mode enable",
111114
"development-status": "laminas-development-mode status",

config/autoload/local.php.dist

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ $databases = [
1919
];
2020

2121
return [
22-
'application' => [
22+
'application' => [
2323
'name' => 'DotKernel API',
2424
'url' => $baseUrl,
2525
'versioning' => [
2626
'documentation_url' => 'https://docs.dotkernel.org/api-documentation/v5/core-features/versioning',
2727
],
2828
],
29-
'authentication' => [
29+
'authentication' => [
3030
'private_key' => [
3131
'key_or_path' => getcwd() . '/data/oauth/private.key',
3232
'key_permissions_check' => false,
@@ -45,15 +45,15 @@ return [
4545
'message' => 'Invalid credentials.',
4646
],
4747
],
48-
'databases' => $databases,
49-
'doctrine' => [
50-
'connection' => [
48+
'databases' => $databases,
49+
'doctrine' => [
50+
'connection' => [
5151
'orm_default' => [
5252
'params' => $databases['default'],
5353
],
5454
],
5555
],
56-
'uploads' => [
56+
'uploads' => [
5757
'user' => [
5858
'url' => $baseUrl . '/uploads/user',
5959
'path' => realpath(__DIR__ . '/../../public/uploads/user'),

0 commit comments

Comments
 (0)