diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 42632f4..d502b84 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -1,4 +1,5 @@ """Post generation hook.""" + import json import os import subprocess diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index fcb17cb..edfc733 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -1,4 +1,5 @@ """Pre generation hook.""" + import re import sys from pathlib import Path diff --git a/hooks/pre_prompt.py b/hooks/pre_prompt.py index bf9d419..6f06bc6 100644 --- a/hooks/pre_prompt.py +++ b/hooks/pre_prompt.py @@ -1,4 +1,5 @@ """Pre Prompt hook.""" + import re import subprocess import sys diff --git a/local_extensions/__init__.py b/local_extensions/__init__.py index d51c664..f4f7019 100644 --- a/local_extensions/__init__.py +++ b/local_extensions/__init__.py @@ -7,11 +7,7 @@ from .semver import VersionInfo -REGISTRIES = { - "Docker Hub": "", - "GitHub": "ghcr.io/", - "GitLab": "registry.gitlab.com/" -} +REGISTRIES = {"Docker Hub": "", "GitHub": "ghcr.io/", "GitLab": "registry.gitlab.com/"} VOLTO_MIN_VERSION = 16 @@ -24,12 +20,12 @@ } -DEFAULT_NODE = 18 +DEFAULT_NODE = 20 VOLTO_NODE = { 16: 16, - 17: DEFAULT_NODE, - 18: 20, + 17: 18, + 18: DEFAULT_NODE, } diff --git a/tests/conftest.py b/tests/conftest.py index 365c84e..709b732 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Pytest configuration.""" + from copy import deepcopy import pytest diff --git a/tests/test_cutter.py b/tests/test_cutter.py index e92e68d..8ed7acf 100644 --- a/tests/test_cutter.py +++ b/tests/test_cutter.py @@ -1,4 +1,5 @@ """Test cookiecutter generation.""" + import re from pathlib import Path from typing import List diff --git a/tests/test_hooks_pre_gen_project.py b/tests/test_hooks_pre_gen_project.py index 2737898..1603ff9 100644 --- a/tests/test_hooks_pre_gen_project.py +++ b/tests/test_hooks_pre_gen_project.py @@ -1,4 +1,5 @@ """Test cookiecutter generation.""" + import pytest from hooks import pre_gen_project diff --git a/tests/test_hooks_pre_prompt.py b/tests/test_hooks_pre_prompt.py index 9d9270d..7786094 100644 --- a/tests/test_hooks_pre_prompt.py +++ b/tests/test_hooks_pre_prompt.py @@ -1,4 +1,5 @@ """Test cookiecutter generation.""" + import pytest from hooks import pre_prompt diff --git a/tests/test_project_backend.py b/tests/test_project_backend.py index 26ea56b..0ec8ec9 100644 --- a/tests/test_project_backend.py +++ b/tests/test_project_backend.py @@ -1,4 +1,5 @@ """Test Generator: /backend.""" + import pytest BACKEND_FILES = [ diff --git a/tests/test_project_cache.py b/tests/test_project_cache.py index 2b8852e..35e9c3c 100644 --- a/tests/test_project_cache.py +++ b/tests/test_project_cache.py @@ -1,4 +1,5 @@ """Test Generator: /varnish (And Cache support).""" + import pytest CACHE_FILES = [ diff --git a/tests/test_project_devops.py b/tests/test_project_devops.py index 9f1c261..a5f012c 100644 --- a/tests/test_project_devops.py +++ b/tests/test_project_devops.py @@ -1,4 +1,5 @@ """Test Generator: /devops.""" + import pytest import yaml diff --git a/tests/test_project_frontend.py b/tests/test_project_frontend.py index fcaf645..504e38b 100644 --- a/tests/test_project_frontend.py +++ b/tests/test_project_frontend.py @@ -1,4 +1,5 @@ """Test Generator: /frontend.""" + import pytest RENAMED_FILES = [ diff --git a/tests/test_project_generation.py b/tests/test_project_generation.py index c533e0c..d13a18a 100644 --- a/tests/test_project_generation.py +++ b/tests/test_project_generation.py @@ -1,4 +1,5 @@ """Test Generator: /.""" + import json import pytest diff --git a/{{ cookiecutter.project_slug }}/Makefile b/{{ cookiecutter.project_slug }}/Makefile index 51da073..6b73312 100644 --- a/{{ cookiecutter.project_slug }}/Makefile +++ b/{{ cookiecutter.project_slug }}/Makefile @@ -10,6 +10,9 @@ MAKEFLAGS+=--no-builtin-rules CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +PLONE_VERSION=$$(cat backend/version.txt) +VOLTO_VERSION = $(shell cat ./frontend/package.json | python -c "import sys, json; print(json.load(sys.stdin)['dependencies']['@plone/volto'])") + PROJECT_NAME={{ cookiecutter.project_slug }} STACK_NAME={{ cookiecutter.__devops_stack_name }} @@ -149,9 +152,9 @@ stack-rm: ## Local Stack: Remove Services and Volumes .PHONY: build-acceptance-servers build-acceptance-servers: ## Build Acceptance Servers @echo "Build acceptance backend" - @docker build backend -t {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-backend:acceptance -f backend/Dockerfile.acceptance + @docker build backend --build-arg PLONE_VERSION=${PLONE_VERSION} -t {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-backend:acceptance -f backend/Dockerfile.acceptance @echo "Build acceptance frontend" - @docker build frontend -t {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-frontend:acceptance -f frontend/Dockerfile + @docker build frontend --build-arg VOLTO_VERSION=${VOLTO_VERSION} -t {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-frontend:acceptance -f frontend/Dockerfile .PHONY: start-acceptance-servers start-acceptance-servers: build-acceptance-servers ## Start Acceptance Servers @@ -172,3 +175,24 @@ run-acceptance-tests: ## Run Acceptance tests npx wait-on --httpTimeout 20000 http-get://localhost:55001/plone http://localhost:3000 $(MAKE) -C "./frontend/" test-acceptance-headless $(MAKE) stop-acceptance-servers + +## Acceptance Frontend tests in development mode +.PHONY: start-test-acceptance-frontend-dev +start-test-acceptance-frontend-dev: ## Start the Acceptance Frontend Fixture in development mode + (cd frontend && RAZZLE_API_PATH=http://127.0.0.1:55001/plone yarn start) + +.PHONY: start-test-acceptance-server +start-test-acceptance-server: build-acceptance-servers ## Start Backend Acceptance Servers in development mode + @echo "Starting test acceptance server" + @docker run --rm -p 55001:55001 --name {{ cookiecutter.project_slug }}-backend-acceptance -d {{ cookiecutter.github_organization }}/{{ cookiecutter.project_slug }}-backend:acceptance + @echo "Started test acceptance server" + +.PHONY: test-acceptance +test-acceptance: ## Start Cypress (for use it while developing) + (cd frontend && ./node_modules/.bin/cypress open') + +.PHONY: stop-acceptance-server +stop-acceptance-server: ## Stop Backend Acceptance Server in development mode + @echo "Stopping acceptance server" + @docker stop {{ cookiecutter.project_slug }}-backend-acceptance + @echo "Stopped acceptance server" diff --git a/{{ cookiecutter.project_slug }}/backend/Dockerfile b/{{ cookiecutter.project_slug }}/backend/Dockerfile index 97cb5bc..0a463b3 100644 --- a/{{ cookiecutter.project_slug }}/backend/Dockerfile +++ b/{{ cookiecutter.project_slug }}/backend/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -ARG PLONE_VERSION={{ cookiecutter.plone_version }} -FROM plone/server-builder:${PLONE_VERSION} as builder +ARG PLONE_VERSION +FROM plone/server-builder:${PLONE_VERSION:-{{ cookiecutter.plone_version }}} as builder WORKDIR /app @@ -19,7 +19,7 @@ RUN <