Skip to content

Commit

Permalink
feat: update application
Browse files Browse the repository at this point in the history
  • Loading branch information
Alcides Ramos committed Oct 5, 2024
1 parent 245037f commit 4332c56
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 130 deletions.
3 changes: 2 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vendor/*
vendor/*
.coverage
63 changes: 49 additions & 14 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ RANDOM_ORDER_SEED := $(shell head -200 /dev/urandom | cksum | cut -f1 -d " ")
.PHONY: help
help:
@clear
@echo "╔══════════════════════════════════════════════════════════════════════════════╗"
@echo "║ ║"
@echo "${YELLOW}.:${RESET} AVAILABLE COMMANDS ${YELLOW}:.${RESET}"
@echo "║ ║"
@echo "╚══════════════════════════════════════════════════════════════════════════════╝"
@echo ""
@echo "${BLACK}"
@echo "╔════════════════════════════════════════════════════════════════════════════════════════════════════════╗"
@echo "$(call pad,96)"
@echo "$(call pad,32) ${YELLOW}.:${RESET} AVAILABLE COMMANDS ${YELLOW}:.${BLACK} $(call pad,32)"
@echo "$(call pad,96)"
@echo "╚════════════════════════════════════════════════════════════════════════════════════════════════════════╝"
@echo "${RESET}"
@grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "· ${YELLOW}%-30s${RESET} %s\n", $$1, $$2}'
@echo ""

Expand All @@ -68,38 +69,59 @@ define taskDone
@echo ""
endef

# $(1)=TEXT $(2)=EXTRA
define showInfo
@echo " ${YELLOW}ℹ${RESET} $(1) $(2)"
endef

define pad
$(shell printf "%-$(1)s" " ")
endef

###
# COMPOSER
###

.PHONY: composer-dump
composer-dump: ## [COMPOSER] Executes <composer dump-auto> inside the container
$(DOCKER_RUN_AS_USER) composer dump-auto --ansi --no-plugins --profile --classmap-authoritative --apcu --strict-psr
$(call showInfo,"Executing \<composer dump-auto\>...")
@echo ""
@$(DOCKER_RUN_AS_USER) composer dump-auto --ansi --no-plugins --profile --classmap-authoritative --apcu --strict-psr
$(call taskDone)

.PHONY: composer-install
composer-install: ## [COMPOSER] Executes <composer install> inside the container
$(DOCKER_RUN_AS_USER) composer install --ansi --no-plugins --classmap-authoritative --audit --apcu-autoloader
$(call showInfo,"Executing \<composer install\>...")
@echo ""
@$(DOCKER_RUN_AS_USER) composer install --ansi --no-plugins --classmap-authoritative --audit --apcu-autoloader
$(call taskDone)

.PHONY: composer-remove
composer-remove: require-package ## [COMPOSER] Executes <composer remove> inside the container
$(DOCKER_RUN_AS_USER) composer remove --ansi --no-plugins --classmap-authoritative --apcu-autoloader --with-all-dependencies --unused
$(call showInfo,"Executing \<composer remove\>...")
@echo ""
@$(DOCKER_RUN_AS_USER) composer remove --ansi --no-plugins --classmap-authoritative --apcu-autoloader --with-all-dependencies --unused
$(call taskDone)

.PHONY: composer-require-dev
composer-require-dev: ## [COMPOSER] Executes <composer require --dev> inside the container
$(DOCKER_RUN_AS_USER) composer require --ansi --no-plugins --classmap-authoritative --apcu-autoloader --with-all-dependencies --prefer-stable --sort-packages --dev
$(call showInfo,"Executing \<composer require --dev\>...")
@echo ""
@$(DOCKER_RUN_AS_USER) composer require --ansi --no-plugins --classmap-authoritative --apcu-autoloader --with-all-dependencies --prefer-stable --sort-packages --dev
$(call taskDone)

.PHONY: composer-require
composer-require: ## [COMPOSER] Executes <composer require> inside the container
$(DOCKER_RUN_AS_USER) composer require --ansi --no-plugins --classmap-authoritative --apcu-autoloader --with-all-dependencies --prefer-stable --sort-packages
$(call showInfo,"Executing \<composer require\>...")
@echo ""
@$(DOCKER_RUN_AS_USER) composer require --ansi --no-plugins --classmap-authoritative --apcu-autoloader --with-all-dependencies --prefer-stable --sort-packages
$(call taskDone)

.PHONY: composer-update
composer-update: ## [COMPOSER] Executes <composer update> inside the container
$(DOCKER_RUN_AS_USER) composer update --ansi --no-plugins --classmap-authoritative --apcu-autoloader --with-all-dependencies
$(call showInfo,"Executing \<composer update\>...")
@echo ""
@$(DOCKER_RUN_AS_USER) composer update --ansi --no-plugins --classmap-authoritative --apcu-autoloader --with-all-dependencies
$(call taskDone)

###
Expand All @@ -109,36 +131,49 @@ composer-update: ## [COMPOSER] Executes <composer update> inside the container
.PHONY: check-syntax
check-syntax: ## [QA] Executes <check-syntax> inside the container <filter=[app|path]>
@$(eval filter ?= 'app')
$(call showInfo,"Check code syntax...")
@echo ""
@vendor/bin/parallel-lint --colors -e php -j 10 $(filter)
$(call taskDone)

.PHONY: check-style
check-style: ## [QA] Executes <check-style> inside the container <filter=[app|path]>
@$(eval filter ?= 'app')
$(call showInfo,"Checking code style...")
@echo ""
@vendor/bin/phpcs -p --colors --standard=phpcs.xml $(filter)
$(call taskDone)

.PHONY: fix-style
fix-style: ## [QA] Executes <fix-style> inside the container <filter=[app|path]>
@$(eval filter ?= 'app')
$(call showInfo,"Fixing code style...")
@echo ""
@vendor/bin/phpcbf -p --colors --standard=phpcs.xml $(filter)
$(call taskDone)

.PHONY: phpstan
phpstan: ## [QA] Executes <phpstan> inside the container <filter=[app|path]>
@$(eval filter ?= 'app')
$(call showInfo,"Executing PHPStan...")
@echo ""
@vendor/bin/phpstan analyse --ansi --memory-limit=1G --no-progress --configuration=phpstan.neon $(filter)
$(call taskDone)

.PHONY: tests
tests: ## [QA] Executes <phpunit> inside the container <testsuite=[Unit|...]> <filter=[.|method + filename]>
@$(eval testsuite ?= 'Unit')
@$(eval filter ?= '.')
$(call showInfo,"Executing PHPUnit...")
@echo ""
@XDEBUG_MODE=off vendor/bin/phpunit --testsuite=$(testsuite) --filter=$(filter) --configuration=phpunit.xml --coverage-text --testdox --colors --order-by=random --random-order-seed=$(RANDOM_ORDER_SEED)
$(call taskDone)

.PHONY: coverage
coverage: ## [QA] Executes <phpunit with pcov coverage support> inside the container
@rm -Rf /coverage/*
@XDEBUG_MODE=off vendor/bin/phpunit --coverage-html=/coverage --configuration=phpunit.xml --coverage-text --testdox --colors --order-by=random --random-order-seed=$(RANDOM_ORDER_SEED)
$(call showInfo,"Generating Code Coverage report...")
@echo ""
@rm -Rf .coverage
@mkdir .coverage
@XDEBUG_MODE=off vendor/bin/phpunit --coverage-html=.coverage --configuration=phpunit.xml --coverage-text --testdox --colors --order-by=random --random-order-seed=$(RANDOM_ORDER_SEED)
$(call taskDone)
12 changes: 8 additions & 4 deletions src/app/Providers/Foo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

namespace App\Providers;

use DateTimeImmutable;

final class Foo
{
public static function dump(): string
public static function getDateTime(?string $format): string
{
$date = date('d-M-Y H:i:s');
$line = 'Executed method [ ' . __FUNCTION__ . ' ] in [ ' . getenv('ENV') . ' ] mode' . PHP_EOL;
return (new DateTimeImmutable())->format($format ?? 'Y-m-d H:i:s');
}

return sprintf('[%s] %s: %s', $date, self::class, $line);
public function ping(): string
{
return 'pong';
}
}
3 changes: 2 additions & 1 deletion src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"autoload-dev": {
"psr-4": {
"Tests\\Unit\\": "tests/Unit"
"UnitTests\\": "tests/Unit"
}
},
"config": {
Expand All @@ -38,6 +38,7 @@
}
},
"require-dev": {
"nunomaduro/mock-final-classes": "^1.2",
"php-parallel-lint/php-console-highlighter": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpmd/phpmd": "^2.15",
Expand Down
Loading

0 comments on commit 4332c56

Please sign in to comment.