Livre l'infrastructure permettant aux modules metier de declarer leurs entites comme "scopees par site" via SiteAwareInterface. Strictement opt-in : aucune entite metier touchee, aucune migration sur tables existantes. Composants : - SiteAwareInterface (Shared/Domain/Contract) : getSite/setSite - CurrentSiteProvider + interface (Module/Sites/Application) : resolve ?Site selon 3 conditions (module actif, user authentifie, currentSite). Interface extraite pour mockabilite en tests (implementation reste final). - SiteScopedQueryExtension : QueryCollection + QueryItem API Platform, ajoute WHERE site = :currentSite si resource SiteAware + provider non-null + pas sites.bypass_scope. - SiteAwareInjectionProcessor : decorator de api_platform.doctrine.orm. state.persist_processor (#[AsDecorator]). Injecte currentSite sur entites SiteAware sans site ; throw 400 si provider null. - Permission sites.bypass_scope declaree dans SitesModule::permissions(). Tests : - FakeSiteAwareEntity dans tests/Fixtures/ + mapping when@test dans doctrine.yaml. Table creee a la volee via SchemaTool dans setUp. schema:update --force ajoute dans test-db-setup pour que fixtures:load ne crashe pas au purger. - 17 tests dedies au ticket 4 (CurrentSiteProvider unitaire, Injection Processor unitaire, Extension integration avec 7 cas couvrant filtrage collection + item, bypass, no-op, resource non SiteAware). - SitesModuleTest : verifie le set de 3 permissions + que le decorator est bien enregistre sur le persist processor. Documentation docs/modules/site-aware.md : guide developpeur 8 sections (quand/ne pas adopter, comment, migration, mode degrade, anti-patterns, exemple d'adoption Supplier, cascade delete). Upgrade @malio/layer-ui 1.4.0 → 1.4.2 (bug 1.4.0 : tailwind.config.ts oublie dans les files publies npm → classe rounded-malio manquante sur les DataTables). Simplification tailwind.config.ts Coltura : retrait des colors/fontFamily/borderRadius dupliques, seule la specifique projet (primary, secondary, tertiary, m.secondary, m.tertiary) est conservee. Tests : 201/201 avec et sans SitesModule actif (2 skipped en disabled). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
168 lines
5.4 KiB
Makefile
168 lines
5.4 KiB
Makefile
# Permet d'utiliser un .env.docker.local pour override
|
|
ENV_DEFAULT = infra/dev/.env.docker
|
|
ENV_LOCAL = infra/dev/.env.docker.local
|
|
ENV_FILE := $(if $(wildcard $(ENV_LOCAL)),$(ENV_LOCAL),$(ENV_DEFAULT))
|
|
|
|
# Permet d'avoir les variables du fichier .env.docker.local
|
|
include $(ENV_DEFAULT)
|
|
-include $(ENV_LOCAL)
|
|
|
|
PHP_CONTAINER = php-$(DOCKER_APP_NAME)-fpm
|
|
SYMFONY_CONSOLE = $(EXEC_PHP) php bin/console
|
|
|
|
DOCKER_COMPOSE = docker compose --env-file $(ENV_FILE)
|
|
DOCKER = docker
|
|
|
|
EXEC_PHP = $(DOCKER) exec -t -u $(APP_USER) $(PHP_CONTAINER)
|
|
EXEC_PHP_CS_FIXER = $(EXEC_PHP) php vendor/bin/php-cs-fixer
|
|
EXEC_PHP_ROOT = $(DOCKER) exec -t -u root $(PHP_CONTAINER)
|
|
EXEC_PHP_INTERACTIVE = $(DOCKER) exec -it -u $(APP_USER) $(PHP_CONTAINER)
|
|
EXEC_PHP_INTERACTIVE_ROOT = $(DOCKER) exec -it -u root $(PHP_CONTAINER)
|
|
FILES =
|
|
|
|
#========================================================================================
|
|
|
|
env-init:
|
|
@cp --update=none $(ENV_DEFAULT) $(ENV_LOCAL)
|
|
|
|
# Lance le container
|
|
start: env-init
|
|
@echo "**** START CONTAINERS ****"
|
|
CURRENT_UID=$(shell id -u) CURRENT_GID=$(shell id -g) $(DOCKER_COMPOSE) up -d
|
|
|
|
# Éteint le container
|
|
stop:
|
|
$(DOCKER_COMPOSE) stop
|
|
|
|
restart: env-init
|
|
$(DOCKER_COMPOSE) down
|
|
CURRENT_UID=$(shell id -u) CURRENT_GID=$(shell id -g) $(DOCKER_COMPOSE) up -d
|
|
|
|
install: copy-git-hook composer-install cache-clear node-use build-nuxtJS migration-migrate test-db-setup
|
|
|
|
# Supprime tout est réinstalle tout (Attention ça supprime la bdd aussi)
|
|
reset: delete_built_dir remove_orphans build-without-cache start wait install
|
|
|
|
composer-install:
|
|
$(EXEC_PHP) composer install
|
|
$(SYMFONY_CONSOLE) lexik:jwt:generate-keypair --skip-if-exists
|
|
|
|
build-nuxtJS:
|
|
$(EXEC_PHP) sh -lc "cd frontend && npm install && npm run build:dist"
|
|
|
|
dev-nuxt:
|
|
$(EXEC_PHP) sh -c "cd frontend && npm run dev"
|
|
|
|
nuxt-lint:
|
|
$(EXEC_PHP) sh -c "cd frontend && npm run lint"
|
|
|
|
nuxt-lint-fix:
|
|
$(EXEC_PHP) sh -c "cd frontend && npm run lint:fix"
|
|
|
|
# Lance les tests unitaires frontend (Vitest)
|
|
nuxt-test:
|
|
$(EXEC_PHP) sh -c "cd frontend && npm run test"
|
|
|
|
delete_built_dir:
|
|
CURRENT_UID=$(shell id -u) CURRENT_GID=$(shell id -g) $(DOCKER_COMPOSE) up -d
|
|
$(DOCKER) exec -u root $(PHP_CONTAINER) rm -rf vendor/
|
|
$(DOCKER) exec -u root $(PHP_CONTAINER) rm -rf frontend/node_modules
|
|
|
|
remove_orphans:
|
|
$(DOCKER_COMPOSE) kill
|
|
$(DOCKER_COMPOSE) down --volumes --remove-orphans
|
|
|
|
build-without-cache:
|
|
$(DOCKER_COMPOSE) build \
|
|
--build-arg="DOCKER_PHP_VERSION=$(DOCKER_PHP_VERSION)" \
|
|
--build-arg="DOCKER_NODE_VERSION=$(DOCKER_NODE_VERSION)" \
|
|
--build-arg="CURRENT_UID=$(shell id -u)" \
|
|
--build-arg="CURRENT_GID=$(shell id -g)" \
|
|
--no-cache
|
|
|
|
migration-migrate:
|
|
$(SYMFONY_CONSOLE) doctrine:migrations:migrate --no-interaction
|
|
|
|
# Cree et initialise la base de test utilisee par PHPUnit
|
|
# (le suffixe "_test" est applique automatiquement par Doctrine en APP_ENV=test)
|
|
#
|
|
# Ordre :
|
|
# 1. migrations : crees le schema metier reel.
|
|
# 2. schema:update : cree les tables mappees en `when@test` uniquement
|
|
# (ex: fake_site_aware_entity du ticket 4) qui n'ont pas de migration.
|
|
# `--force` sans `--complete` : ajoute les tables manquantes aux
|
|
# mappings sans drop les tables DB non mappees (no-op sur un schema
|
|
# deja aligne avec les migrations). Necessaire car le purger
|
|
# doctrine:fixtures:load essaie de DELETE toutes les tables connues
|
|
# via les mappings — si fake_site_aware_entity est mappe mais absent
|
|
# en DB, le purger crash.
|
|
# 3. fixtures -> sync-permissions : fixtures:load purge la table permission,
|
|
# donc sync doit passer apres.
|
|
test-db-setup:
|
|
$(SYMFONY_CONSOLE) doctrine:database:create --env=test --if-not-exists
|
|
$(SYMFONY_CONSOLE) doctrine:migrations:migrate --env=test --no-interaction
|
|
$(SYMFONY_CONSOLE) doctrine:schema:update --env=test --force
|
|
$(SYMFONY_CONSOLE) --env=test --no-interaction doctrine:fixtures:load
|
|
$(SYMFONY_CONSOLE) --env=test --no-interaction app:sync-permissions
|
|
|
|
fixtures:
|
|
$(SYMFONY_CONSOLE) --no-interaction doctrine:fixtures:load
|
|
|
|
# Synchronise le catalogue de permissions RBAC avec les declarations
|
|
# des modules actifs (CoreModule::permissions() etc.). Idempotent.
|
|
sync-permissions:
|
|
$(SYMFONY_CONSOLE) --no-interaction app:sync-permissions
|
|
|
|
# Attention, supprime votre bdd local
|
|
db-reset:
|
|
$(DOCKER_COMPOSE) down -v
|
|
$(DOCKER_COMPOSE) up -d
|
|
$(MAKE) wait
|
|
$(SYMFONY_CONSOLE) doctrine:database:create --if-not-exists
|
|
$(MAKE) migration-migrate
|
|
$(MAKE) fixtures
|
|
$(MAKE) sync-permissions
|
|
$(MAKE) test-db-setup
|
|
|
|
# Restart la bdd
|
|
db-restart:
|
|
$(DOCKER_COMPOSE) down
|
|
$(DOCKER_COMPOSE) up -d
|
|
|
|
cache-clear:
|
|
$(SYMFONY_CONSOLE) cache:clear
|
|
|
|
copy-git-hook:
|
|
$(EXEC_PHP) cp pre-commit .git/hooks/
|
|
$(EXEC_PHP) cp commit-msg .git/hooks/
|
|
$(EXEC_PHP) chmod a+x .git/hooks/pre-commit
|
|
$(EXEC_PHP) chmod a+x .git/hooks/commit-msg
|
|
|
|
shell:
|
|
$(EXEC_PHP_INTERACTIVE) bash
|
|
|
|
shell-root:
|
|
$(EXEC_PHP_INTERACTIVE_ROOT) bash
|
|
|
|
# Suivi temps réel des logs dev
|
|
logs-dev:
|
|
$(EXEC_PHP_INTERACTIVE) sh -lc "tail -f var/log/dev.log"
|
|
|
|
# Force la version node
|
|
node-use:
|
|
bash -lc 'source "$$HOME/.nvm/nvm.sh" && nvm install && nvm use'
|
|
|
|
# Utilisé par le pre-commit pour fix les fichiers modifiés
|
|
php-cs-fixer-allow-risky:
|
|
@echo "Fixing files: $(FILES)"
|
|
$(EXEC_PHP_CS_FIXER) fix --config=.php-cs-fixer.dist.php --allow-risky=yes $(FILES)
|
|
|
|
test:
|
|
$(EXEC_PHP) php -d memory_limit="512M" vendor/bin/phpunit $(FILES)
|
|
|
|
# Lance l'ensemble des tests (PHPUnit back + Vitest front)
|
|
test-all: test nuxt-test
|
|
|
|
wait:
|
|
sleep 10
|