Skip to content

Commit 3beb34d

Browse files
committed
WIP
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
1 parent ca78ef4 commit 3beb34d

File tree

11 files changed

+174
-13
lines changed

11 files changed

+174
-13
lines changed

.github/workflows/codecov.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
on:
2+
- push
3+
4+
name: Run Codecov checks
5+
6+
jobs:
7+
code-coverage:
8+
name: Code Coverage
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.1"
19+
- "8.2"
20+
- "8.3"
21+
- "8.4"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
27+
- name: Install PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: "${{ matrix.php }}"
31+
coverage: pcov
32+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
33+
tools: composer:v2, cs2pr
34+
35+
- name: Determine composer cache directory
36+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
37+
38+
- name: Cache dependencies installed with composer
39+
uses: actions/cache@v3
40+
with:
41+
path: ${{ env.COMPOSER_CACHE_DIR }}
42+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
43+
restore-keys: |
44+
php${{ matrix.php }}-composer-
45+
- name: Install dependencies with composer
46+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
47+
48+
- name: Collect code coverage with PHPUnit
49+
run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml
50+
51+
- name: Send code coverage report to Codecov.io
52+
uses: codecov/codecov-action@v3
53+
with:
54+
token: ${{ secrets.CODECOV_TOKEN }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
tags:
8+
9+
jobs:
10+
ci:
11+
uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x

.github/workflows/docs-build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: docs-build
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Build Docs
13+
uses: dotkernel/documentation-theme/github-actions/docs@main
14+
env:
15+
DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
on:
2+
- push
3+
4+
name: Run PHPStan checks
5+
6+
jobs:
7+
mutation:
8+
name: PHPStan ${{ matrix.php }}-${{ matrix.os }}
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.1"
19+
- "8.2"
20+
- "8.3"
21+
- "8.4"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Install PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: "${{ matrix.php }}"
31+
coverage: pcov
32+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
33+
tools: composer:v2, cs2pr
34+
35+
- name: Determine composer cache directory
36+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
37+
38+
- name: Cache dependencies installed with composer
39+
uses: actions/cache@v4
40+
with:
41+
path: ${{ env.COMPOSER_CACHE_DIR }}
42+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
43+
restore-keys: |
44+
php${{ matrix.php }}-composer-
45+
46+
- name: Install dependencies with composer
47+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
48+
49+
- name: Run static analysis with PHPStan
50+
run: vendor/bin/phpstan analyse

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
],
4141
"cs-check": "phpcs",
4242
"cs-fix": "phpcbf",
43-
"test": "phpunit --colors=always",
44-
"static-analysis": "phpstan analyse --memory-limit 1G"
43+
"static-analysis": "phpstan analyse --memory-limit 1G",
44+
"test": "phpunit --colors=always"
4545
}
4646
}

src/ColorEnum.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
enum ColorEnum: int
1010
{
1111
case Default = 0;
12+
case Bold = 1;
1213
case ForegroundBlack = 30;
1314
case ForegroundRed = 31;
1415
case ForegroundGreen = 32;

src/IO/Output.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,31 @@ public static function error(string $message, bool $exit = false): void
2121
{
2222
$message = ColorEnum::colorize($message, ColorEnum::ForegroundBrightRed);
2323

24-
fwrite(STDERR, '' . $message . PHP_EOL);
24+
fwrite(STDERR, $message . PHP_EOL);
2525
$exit && exit(self::FAILURE);
2626
}
2727

2828
public static function info(string $message, bool $exit = false): void
2929
{
3030
$message = ColorEnum::colorize($message, ColorEnum::ForegroundBrightBlue);
3131

32-
fwrite(STDOUT, 'ℹ️ ' . $message . PHP_EOL);
32+
fwrite(STDOUT, $message . PHP_EOL);
3333
$exit && exit(self::SUCCESS);
3434
}
3535

3636
public static function success(string $message, bool $exit = false): void
3737
{
3838
$message = ColorEnum::colorize($message, ColorEnum::ForegroundBrightGreen);
3939

40-
fwrite(STDOUT, '' . $message . PHP_EOL);
40+
fwrite(STDOUT, $message . PHP_EOL);
41+
$exit && exit(self::SUCCESS);
42+
}
43+
44+
public static function warning(string $message, bool $exit = false): void
45+
{
46+
$message = ColorEnum::colorize($message, ColorEnum::ForegroundBrightYellow);
47+
48+
fwrite(STDOUT, $message . PHP_EOL);
4149
$exit && exit(self::SUCCESS);
4250
}
4351

src/Maker.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use function array_shift;
1515
use function assert;
16-
use function count;
1716
use function is_callable;
1817
use function sprintf;
1918
use function strtolower;
@@ -36,14 +35,11 @@ public function __invoke(array $arguments): int
3635
}
3736

3837
array_shift($arguments);
39-
if (count($arguments) === 0) {
40-
Output::error('dot-maker must be called with at least one parameter', true);
41-
}
4238

43-
$argument = trim(strtolower(array_shift($arguments)));
39+
$argument = trim(strtolower((string) array_shift($arguments)));
4440
$component = TypeEnum::getClass($argument);
4541
if ($component === null) {
46-
Output::error(sprintf('unknown component: "%s"', $argument), true);
42+
Output::error(sprintf('Unknown component: "%s"', $argument), true);
4743
}
4844

4945
$config = new Config($this->configPath);

src/Type/Help.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ class Help extends AbstractType
1010
{
1111
public function __invoke(): void
1212
{
13-
Output::info('WIP');
13+
Output::info('dot-maker');
14+
Output::writeLine(<<<HELP
15+
16+
Usage: ./vendor/bin/dot-maker <component>
17+
18+
Where <component> must be one of the following strings:
19+
20+
- collection
21+
- command
22+
- command
23+
- entity
24+
- form
25+
- handler
26+
- input-filter
27+
- middleware
28+
- module
29+
- repository
30+
- service
31+
HELP);
1432
}
1533
}

src/Type/Module.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public function __invoke(): void
1717
{
1818
while (true) {
1919
$name = ucfirst(Input::prompt('Enter new module name: '));
20+
if ($name === '') {
21+
return;
22+
}
23+
2024
if (! $this->isValid($name)) {
2125
Output::error(sprintf('Invalid module name: "%s"', $name));
2226
continue;

0 commit comments

Comments
 (0)