Skip to content

Commit f66f7a3

Browse files
authored
Merge pull request #460 from wayofdev/feat/tpl-updates
2 parents 40c2c37 + 583af2f commit f66f7a3

File tree

17 files changed

+3046
-1740
lines changed

17 files changed

+3046
-1740
lines changed

.env.example

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# https://docs.docker.com/compose/reference/envvars/#compose_project_name
2+
# With custom namespace provided, it will be used to prefix all services
3+
# in Docker network for current project
4+
COMPOSE_PROJECT_NAME=laravel-package-tpl
5+
APP_ENV=production
6+
7+
DB_CONNECTION=pgsql
8+
DB_HOST=pgsql
9+
DB_PORT=5432
10+
11+
DB_DATABASE=default
12+
DB_USERNAME=root
13+
DB_PASSWORD=password
14+
15+
DB_MYSQL_FORWARD_PORT=13307
16+
DB_PGSQL_FORWARD_PORT=15433
17+
18+
XDEBUG_MODE=coverage
19+
20+
CYCLE_ADAPTER_QUEUE_INTEGRATION=false
21+
CYCLE_ADAPTER_SESSION_INTEGRATION=false
22+
CYCLE_ADAPTER_CACHE_INTEGRATION=false
23+
24+
CYCLE_ATTRIBUTES_CACHE=true
25+
CYCLE_ATTRIBUTES_CACHE_DRIVER=array
26+
27+
CYCLE_SCHEMA_CACHE=true
28+
CYCLE_SCHEMA_CACHE_DRIVER=array

.gitattributes

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/.build export-ignore
2+
/.github export-ignore
3+
/docs export-ignore
4+
/tests export-ignore
5+
.editorconfig export-ignore
6+
.env export-ignore
7+
.env.example export-ignore
8+
.gitattributes export-ignore
9+
.gitignore export-ignore
10+
.php-cs-fixer.dist.php export-ignore
11+
.pre-commit-config.yaml export-ignore
12+
.yamllint.yaml export-ignore
13+
docker-compose.yaml export-ignore
14+
Makefile export-ignore
15+
package.json export-ignore
16+
phpstan.neon.dist export-ignore
17+
phpstan-baseline.neon export-ignore
18+
phpunit.xml.dist export-ignore
19+
renovate.json export-ignore

.github/labeler.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
# this file is for the labeler workflow job
44
# Documentation https://github.com/marketplace/actions/labeler
55

6-
'type: documentation':
7-
- assets/**/*
8-
- .github/*
9-
- ./*.md
10-
11-
'type: maintenance':
12-
- .github/**/*
13-
- tests/**/*
6+
"type: documentation":
7+
- changed-files:
8+
- any-glob-to-any-file: [assets/**/*, .github/*, ./*.md]
9+
10+
"type: maintenance":
11+
- changed-files:
12+
- any-glob-to-any-file: [tests/**/*, .github/workflows/*]
1413

1514
...

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/vendor/
22
/.build/
3+
.env
4+
coverage.xml

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
5+
rev: v4.5.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- id: check-added-large-files
10+
args: ['--maxkb=600']
1011
- id: fix-encoding-pragma
1112

1213
- repo: https://github.com/commitizen-tools/commitizen
13-
rev: v2.42.1
14+
rev: v3.13.0
1415
hooks:
1516
- id: commitizen
1617
stages:

.yamllint.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22

3-
extends: "default"
3+
extends: default
44

55
ignore: |
66
.build/
77
vendor/
8+
docs/
89
910
# Overwrite above default rules
1011
rules:
@@ -51,8 +52,6 @@ rules:
5152
require-starting-space: true
5253
min-spaces-from-content: 1
5354

54-
yaml-files:
55-
- "*.yaml"
56-
- "*.yml"
55+
line-length: disable
5756

5857
...

Makefile

Lines changed: 103 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
1-
# leave empty to disable
2-
# -v - verbose;
3-
# -vv - more details
4-
# -vvv - enable connection debugging
5-
DEBUG_VERBOSITY ?=
1+
-include .env
62

7-
DOCKER_CMD =
3+
# BuildKit enables higher performance docker builds and caching possibility
4+
# to decrease build times and increase productivity for free.
5+
# https://docs.docker.com/compose/environment-variables/envvars/
6+
export DOCKER_BUILDKIT ?= 1
87

9-
COMPOSER_RUN = $(DOCKER_CMD) composer
8+
# Binary to use, when executing docker-compose tasks
9+
DOCKER_COMPOSE ?= docker compose
10+
11+
# Support image with all needed binaries, like envsubst, mkcert, wait4x
12+
SUPPORT_IMAGE ?= wayofdev/build-deps:alpine-latest
13+
14+
APP_RUNNER ?= $(DOCKER_COMPOSE) run --rm --no-deps app
15+
APP_COMPOSER ?= $(APP_RUNNER) composer
16+
17+
BUILDER_PARAMS ?= docker run --rm -i \
18+
--env-file ./.env \
19+
--env COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
20+
--env COMPOSER_AUTH="$(COMPOSER_AUTH)"
21+
22+
BUILDER ?= $(BUILDER_PARAMS) $(SUPPORT_IMAGE)
23+
BUILDER_WIRED ?= $(BUILDER_PARAMS) --network project.$(COMPOSE_PROJECT_NAME) $(SUPPORT_IMAGE)
24+
25+
# Shorthand envsubst command, executed through build-deps
26+
ENVSUBST ?= $(BUILDER) envsubst
27+
28+
NPM_RUNNER ?= pnpm
1029

1130
# https://phpstan.org/user-guide/output-format
1231
export PHPSTAN_OUTPUT_FORMAT ?= table
1332

33+
EXPORT_VARS = '\
34+
$${COMPOSE_PROJECT_NAME} \
35+
$${COMPOSER_AUTH}'
36+
1437
# Self documenting Makefile code
1538
# ------------------------------------------------------------------------------------
1639
ifneq ($(TERM),)
@@ -34,7 +57,7 @@ else
3457
WHITE := ""
3558
RST := ""
3659
endif
37-
MAKE_LOGFILE = /tmpwayofdev-laravel-package-tpl.log
60+
MAKE_LOGFILE = /tmp/wayofdev-laravel-package-tpl.log
3861
MAKE_CMD_COLOR := $(BLUE)
3962

4063
default: all
@@ -64,19 +87,66 @@ all: install hooks
6487

6588
# System Actions
6689
# ------------------------------------------------------------------------------------
90+
env: ## Generate .env file from example, use `make env force=true`, to force re-create file
91+
ifeq ($(FORCE),true)
92+
@echo "${YELLOW}Force re-creating .env file from example...${RST}"
93+
$(ENVSUBST) $(EXPORT_VARS) < ./.env.example > ./.env
94+
else ifneq ("$(wildcard ./.env)","")
95+
@echo ""
96+
@echo "${YELLOW}The .env file already exists! Use FORCE=true to re-create.${RST}"
97+
else
98+
@echo "Creating .env file from example"
99+
$(ENVSUBST) $(EXPORT_VARS) < ./.env.example > ./.env
100+
endif
101+
.PHONY: env
102+
67103
prepare:
68104
mkdir -p .build/php-cs-fixer
69105
.PHONY: prepare
70106

71107

108+
# Docker Actions
109+
# ------------------------------------------------------------------------------------
110+
up: # Creates and starts containers, defined in docker-compose and override file
111+
$(DOCKER_COMPOSE) up --remove-orphans -d
112+
.PHONY: up
113+
114+
down: # Stops and removes containers of this project
115+
$(DOCKER_COMPOSE) down --remove-orphans --volumes
116+
.PHONY: down
117+
118+
restart: down up ## Runs down and up commands
119+
.PHONY: restart
120+
121+
clean: ## Stops containers if required and removes from system
122+
$(DOCKER_COMPOSE) rm --force --stop
123+
.PHONY: clean
124+
125+
ps: ## List running project containers
126+
$(DOCKER_COMPOSE) ps
127+
.PHONY: ps
128+
129+
logs: ## Show project docker logs with follow up mode enabled
130+
$(DOCKER_COMPOSE) logs -f
131+
.PHONY: logs
132+
133+
pull: ## Pull and update docker images in this project
134+
$(DOCKER_COMPOSE) pull
135+
.PHONY: pull
136+
137+
ssh: ## Login inside running docker container
138+
$(APP_RUNNER) sh
139+
.PHONY: ssh
140+
141+
72142
# Composer
73143
# ------------------------------------------------------------------------------------
74144
install: ## Installs composer dependencies
75-
$(COMPOSER_RUN) install
145+
$(APP_COMPOSER) install
76146
.PHONY: install
77147

78148
update: ## Updates composer dependencies by running composer update command
79-
$(COMPOSER_RUN) update
149+
$(APP_COMPOSER) update
80150
.PHONY: update
81151

82152

@@ -87,30 +157,47 @@ hooks: ## Install git hooks from pre-commit-config
87157
pre-commit autoupdate
88158
.PHONY: hooks
89159

160+
lint: lint-yaml lint-php lint-stan ## Runs all linting commands
161+
.PHONY: lint
162+
90163
lint-yaml: ## Lints yaml files inside project
91164
yamllint .
92165
.PHONY: lint-yaml
93166

94167
lint-php: prepare ## Fixes code to follow coding standards using php-cs-fixer
95-
$(COMPOSER_RUN) cs:fix
168+
$(APP_COMPOSER) cs:fix
96169
.PHONY: lint-php
97170

98171
lint-diff: prepare ## Runs php-cs-fixer in dry-run mode and shows diff which will by applied
99-
$(COMPOSER_RUN) cs:diff
172+
$(APP_COMPOSER) cs:diff
100173
.PHONY: lint-diff
101174

102175
lint-stan: ## Runs phpstan – static analysis tool
103-
$(COMPOSER_RUN) stan
176+
$(APP_COMPOSER) stan
104177
.PHONY: lint-stan
105178

106179
lint-stan-ci:
107-
$(COMPOSER_RUN) stan:ci
180+
$(APP_COMPOSER) stan:ci
108181
.PHONY: lint-stan-ci
109182

110183
test: ## Run project php-unit and pest tests
111-
$(COMPOSER_RUN) test
184+
$(APP_COMPOSER) test
112185
.PHONY: test
113186

114187
test-cc: ## Run project php-unit and pest tests in coverage mode and build report
115-
$(COMPOSER_RUN) test:cc
188+
$(APP_COMPOSER) test:cc
116189
.PHONY: test-cc
190+
191+
# Documentation
192+
# ------------------------------------------------------------------------------------
193+
docs-deps-update: ## Check for outdated dependencies and automatically update them using pnpm
194+
cd docs && $(NPM_RUNNER) run deps:update
195+
.PHONY: docs-deps-update
196+
197+
docs-deps-install: ## Install dependencies for documentation using pnpm
198+
cd docs && $(NPM_RUNNER) install
199+
.PHONY: docs-deps-install
200+
201+
docs-up: ## Start documentation server
202+
cd docs && $(NPM_RUNNER) dev
203+
.PHONY: docs-up

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<br>
22

33
<div align="center">
4-
<img width="456" src="https://raw.githubusercontent.com/wayofdev/ansible-role-tpl/master/assets/logo.gh-light-mode-only.png#gh-light-mode-only">
5-
<img width="456" src="https://raw.githubusercontent.com/wayofdev/ansible-role-tpl/master/assets/logo.gh-dark-mode-only.png#gh-dark-mode-only">
4+
<img width="456" src="https://raw.githubusercontent.com/wayofdev/laravel-package-tpl/master/assets/logo.gh-light-mode-only.png#gh-light-mode-only" alt="WayOfDev Logo for light theme">
5+
<img width="456" src="https://raw.githubusercontent.com/wayofdev/laravel-package-tpl/master/assets/logo.gh-dark-mode-only.png#gh-dark-mode-only" alt="WayOfDev Logo for dark theme">
66
</div>
77

88

@@ -55,15 +55,15 @@ $ make test
5555
Code quality using PHPStan:
5656

5757
```bash
58-
$ make stan
58+
$ make lint-stan
5959
```
6060

6161
### → Coding Standards Fixing
6262

6363
Fix code using The PHP Coding Standards Fixer (PHP CS Fixer) to follow our standards:
6464

6565
```bash
66-
$ make cs-fix
66+
$ make lint-php
6767
```
6868

6969
<br>

composer.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
],
1717
"require": {
1818
"php": "^8.2",
19-
"illuminate/contracts": "^v10.13"
19+
"illuminate/contracts": "^10.48 || ^11.0"
2020
},
2121
"require-dev": {
22-
"ergebnis/composer-normalize": "^2.31",
23-
"nunomaduro/larastan": "^2.6",
24-
"orchestra/testbench": "^8.5",
25-
"pestphp/pest": "^2.6",
26-
"pestphp/pest-plugin-laravel": "^2.0.0",
22+
"ergebnis/composer-normalize": "^2.42",
23+
"larastan/larastan": "^2.9",
24+
"orchestra/testbench": "^8.5 | ^9.0",
25+
"pestphp/pest": "^2.34",
26+
"pestphp/pest-plugin-laravel": "^2.3",
2727
"phpstan/extension-installer": "^1.3",
2828
"phpstan/phpstan": "^1.10",
2929
"phpstan/phpstan-deprecation-rules": "^1.1",
3030
"phpstan/phpstan-phpunit": "^1.3",
3131
"phpstan/phpstan-strict-rules": "^1.5",
32-
"phpunit/phpunit": "^10.2",
32+
"phpunit/phpunit": "^10.5",
3333
"roave/security-advisories": "dev-latest",
3434
"wayofdev/cs-fixer-config": "^1.2"
3535
},
@@ -40,8 +40,10 @@
4040
},
4141
"autoload-dev": {
4242
"psr-4": {
43-
"WayOfDev\\Package\\App\\": "tests/app/",
44-
"WayOfDev\\Package\\Tests\\": "tests/src/"
43+
"WayOfDev\\App\\": "tests/app/",
44+
"WayOfDev\\Tests\\": "tests/src/",
45+
"WayOfDev\\Database\\Factories\\": "tests/database/factories/",
46+
"WayOfDev\\Database\\Seeders\\": "tests/database/seeders/"
4547
}
4648
},
4749
"scripts": {

0 commit comments

Comments
 (0)