diff --git a/src/Action/CreateListOfFilesToGenerate.php b/src/Action/CreateListOfFilesToGenerate.php index 82d4e5d..3b70591 100644 --- a/src/Action/CreateListOfFilesToGenerate.php +++ b/src/Action/CreateListOfFilesToGenerate.php @@ -6,7 +6,6 @@ namespace App\Action; use App\DataTransferObject\Config; use App\DataTransferObject\TemplateFile; -use App\Enum\Language; use App\Enum\ProjectType; use App\Enum\WebServer; use Illuminate\Support\Arr; @@ -45,14 +44,14 @@ final class CreateListOfFilesToGenerate new TemplateFile(data: 'fractal/justfile', name: 'justfile'), ]); - if (self::isDocker($configurationData)) { + if ($isDocker) { $filesToGenerate->push(new TemplateFile(data: 'fractal/.env.example', name: '.env.example')); $filesToGenerate->push(new TemplateFile(data: 'fractal/.dockerignore', name: '.dockerignore')); $filesToGenerate->push(new TemplateFile(data: 'fractal/.hadolint.yaml', name: '.hadolint.yaml')); $filesToGenerate->push(new TemplateFile(data: 'fractal/.yarnrc', name: '.yarnrc')); $filesToGenerate->push(new TemplateFile(data: 'fractal/Dockerfile', name: 'Dockerfile')); $filesToGenerate->push(new TemplateFile(data: 'fractal/docker-compose.yaml', name: 'docker-compose.yaml')); - } elseif (self::isFlake($configurationData)) { + } elseif ($isFlake) { $filesToGenerate->push(new TemplateFile(data: 'fractal/.envrc', name: '.envrc')); $filesToGenerate->push(new TemplateFile(data: 'fractal/flake.nix', name: 'flake.nix')); } @@ -118,29 +117,6 @@ final class CreateListOfFilesToGenerate break; } - // TODO: remove? - if ($isDocker) { - $filesToGenerate->push(new TemplateFile(data: 'common/.dockerignore', name: '.dockerignore')); - $filesToGenerate->push(new TemplateFile(data: 'common/.hadolint.yaml', name: '.hadolint.yaml')); - $filesToGenerate->push(new TemplateFile(data: 'env.example', name: '.env.example')); - } - - // TODO: remove? - if ($isFlake) { - $filesToGenerate->push(new TemplateFile(data: 'common/envrc', name: '.envrc')); - $filesToGenerate->push(new TemplateFile(data: 'common/flake.nix', name: 'flake.nix')); - } - - // TODO: remove? - if (false !== Arr::get($configurationData, "justfile", true)) { - $filesToGenerate[] = new TemplateFile(data: 'justfile', name: 'justfile'); - } - - // TODO: remove? - if (isset($configurationData['dockerCompose']) && $configurationData['dockerCompose'] !== null) { - $filesToGenerate[] = new TemplateFile(data: 'docker-compose.yaml', name: 'docker-compose.yaml'); - } - $filesToGenerate[] = new TemplateFile( data: 'common/.githooks/prepare-commit-msg', name: 'prepare-commit-msg', diff --git a/templates/common/.dockerignore.twig b/templates/common/.dockerignore.twig deleted file mode 100644 index 1df7806..0000000 --- a/templates/common/.dockerignore.twig +++ /dev/null @@ -1,4 +0,0 @@ -/README.md -{% if experimental.createGitHubActionsConfiguration %} -/.github/ -{%-endif-%} diff --git a/templates/common/.hadolint.yaml.twig b/templates/common/.hadolint.yaml.twig deleted file mode 100644 index d87bf88..0000000 --- a/templates/common/.hadolint.yaml.twig +++ /dev/null @@ -1,2 +0,0 @@ -ignore: - - DL3059 diff --git a/templates/common/envrc.twig b/templates/common/envrc.twig deleted file mode 100644 index cf8c94f..0000000 --- a/templates/common/envrc.twig +++ /dev/null @@ -1,3 +0,0 @@ -# {{ managedText }} - -use flake diff --git a/templates/common/flake.nix.twig b/templates/common/flake.nix.twig deleted file mode 100644 index 405959b..0000000 --- a/templates/common/flake.nix.twig +++ /dev/null @@ -1,23 +0,0 @@ -{ - inputs = { - devshell.url = "github:numtide/devshell"; - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - }; - - outputs = inputs@{ flake-parts, ... }: - flake-parts.lib.mkFlake { inherit inputs; } { - imports = [ inputs.devshell.flakeModule ]; - - systems = [ "x86_64-linux" ]; - - perSystem = { config, self', inputs', pkgs, system, ... }: { - devshells.default = { - packages = with pkgs; [ -{% for package in flake.devshell.packages %} - "{{ package }}" -{% endfor %} - ]; - }; - }; - }; -} diff --git a/templates/docker-compose.yaml.twig b/templates/docker-compose.yaml.twig deleted file mode 100644 index c6f5806..0000000 --- a/templates/docker-compose.yaml.twig +++ /dev/null @@ -1,105 +0,0 @@ -# {{ managedText | raw }} - -x-proxy: &default-proxy - networks: - - default - - web - labels: - - "traefik.docker.network=traefik_proxy" - - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host( - `${COMPOSE_PROJECT_NAME}.localhost`, - {% for host in web.extra_hosts | default([]) -%} - {{ '`' ~ host ~ '`,' }} - {%- endfor %} - )" - -x-app: &default-app - volumes: - - "${DOCKER_WEB_VOLUME:-./{{ "drupal" == type ? drupal.docroot : '' }}:{{ project_root }}{{ "drupal" == type ? '/' ~ drupal.docroot : '' }}}" - env_file: - - .env - restart: "${DOCKER_RESTART_POLICY:-unless-stopped}" - networks: - - default - deploy: - resources: - limits: - cpus: "${DOCKER_MYSQL_CPUS:-0}" - memory: "${DOCKER_MYSQL_MEMORY:-0}" - labels: - - "traefik.enabled=false" - tty: true - -services: -{% if "web" in dockerCompose.services %} - web: - <<: [*default-proxy, *default-app] - build: - context: . - target: web - depends_on: - - php - profiles: [web] -{% endif %} - -{% if "php" == language %} - {% set anchors = [ - "apache" in php.version ? "*default-proxy" : null, - "*default-app", - ] -%} - php: - <<: [{{ anchors | filter(item => item is not null) | join(", ") }}] - build: - context: . - target: build - args: - - "DOCKER_UID=${DOCKER_UID:-1000}" - volumes: - - .:{{ project_root }} - {% if "database" in dockerCompose.services -%} - depends_on: - - database - {% endif -%} - profiles: [php] -{% elseif "node" == language %} - node: - {{ type is same as "fractal" ? "<<: [*default-proxy, *default-app]" : "<<: *default-app" }} - build: - context: . - target: build - volumes: - - .:{{ project_root }} - {% if "database" in dockerCompose.services -%} - depends_on: - - database - {% endif -%} - profiles: [node] -{% endif %} - -{% if "database" in dockerCompose.services %} - database: - image: {{ database.type }}:{{ database.version }} - deploy: - resources: - limits: - cpus: "${DOCKER_MYSQL_CPUS:-0}" - memory: "${DOCKER_MYSQL_MEMORY:-0}" - volumes: - - db-data:/var/lib/mysql - {{ database.extra_databases is not empty ? '- ./tools/docker/images/database/root/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d' : '' }} - env_file: - - .env - labels: - - "traefik.enabled=false" - environment: - MYSQL_RANDOM_ROOT_PASSWORD: true - profiles: [database] - -volumes: - db-data: {} -{% endif -%} - -networks: - web: - external: true - name: traefik_proxy diff --git a/templates/env.example.twig b/templates/env.example.twig deleted file mode 100644 index 365e728..0000000 --- a/templates/env.example.twig +++ /dev/null @@ -1,20 +0,0 @@ -# {{ managedText | raw }} - -export DOCKER_UID=1000 - -{% if dockerCompose %} -export COMPOSE_PROJECT_NAME={{ name }} -export COMPOSE_PROFILES=web,php,database - -export DOCKER_WEB_VOLUME=.:{{ project_root }} -{% endif %} - -{% if experimental.useNewDatabaseCredentials %} -export MYSQL_DATABASE=app -export MYSQL_PASSWORD=app -export MYSQL_USER=app -{% else %} -export MYSQL_DATABASE=drupal -export MYSQL_PASSWORD=drupal -export MYSQL_USER=drupal -{% endif %} diff --git a/templates/justfile.twig b/templates/justfile.twig deleted file mode 100644 index d57b973..0000000 --- a/templates/justfile.twig +++ /dev/null @@ -1,121 +0,0 @@ -# {{ managedText | raw }} - -{% set isFlake = flake is defined %} - -default: - @just --list - -# Start the project -start: - cp -v --no-clobber .env.example .env - docker compose up -d - -# Stop the project -stop: - docker compose down - -{% if "php" is same as language %} -composer *args: - {{ "just _exec php composer {{ args }}" | raw }} - -alias phpunit := test - -test *args: -{% if "drupal" is same as type %} - {{ "just _exec php phpunit --colors=always {{ args }}" | raw }} -{% else %} - {{ "just _run php phpunit --colors=always {{ args }}" | raw }} -{% endif %} -{% endif %} - -{% if "drupal" is same as type %} -drush *args: - {{ "just _exec php drush {{ args }}" | raw }} - -install *args: - {{ "just _exec php drush site:install -y {{ args }}" | raw }} -{% endif %} - -{% if "node" is same as language %} -yarn *args: -{% if isFlake %} - {{ "just _exec yarn {{ args }}" | raw }} -{% else %} - {{ "just _exec node yarn {{ args }}" | raw }} -{% endif %} -{% endif %} - -{% if "fractal" is same as type %} -fractal *args: - {{ "just yarn fractal {{ args }}" | raw }} - -clean: - rm -fr build - -build *args: - {{ "just fractal build {{ args }}" | raw }} - -sync: clean build - #!/usr/bin/env bash - set -eux - aws s3 sync "build/." s3://"${BUCKET_NAME}" \ - --acl "public-read" \ - --cache-control max-age=3600 -{% endif %} - -{% if "laravel" is same as type %} -artisan *args: - {{ "just _run artisan {{ args }}" | raw }} -{% endif %} - -# Enable or disable Git hooks -git-hooks command: - #!/usr/bin/env bash - set -euo pipefail - - case "{{ '{{ command }}'|raw }}" in - "on") - echo "Enabling Git hooks..." - git config core.hooksPath .githooks - ;; - "off") - echo "Disabling Git hooks..." - git config --unset core.hooksPath - ;; - *) - echo "Error: Invalid argument. Must be either 'on' or 'off'" - ;; - esac - -{% if experimental.runGitHooksBeforePush %} -test-commit: - {% if "phpcs" in php|keys -%} - just _run php phpcs - {%- endif %} - - {% if "phpstan" in php|keys -%} - just _run php phpstan analyze --no-progress --memory-limit=512M - {%- endif %} - - just test --testdox --testsuite unit - just test --testdox --testsuite kernel -{% endif %} - -_exec +args: -{% if flake is defined %} - {{ "nix develop --command {{ args }}" | raw }} -{% else %} - {{ "docker compose exec -T {{ args }}" | raw }} -{% endif %} - -{% if flake is not defined %} -_run service command *args: - docker compose run \ - --entrypoint {{ "{{ command }}"|raw }} \ - --no-deps \ - --rm \ - -T \ - {{ "{{ service }} {{ args }}"|raw }} -{% endif %} - -# vim: ft=just diff --git a/templates/php/Dockerfile.twig b/templates/php/Dockerfile.twig deleted file mode 100644 index e9699cb..0000000 --- a/templates/php/Dockerfile.twig +++ /dev/null @@ -1,104 +0,0 @@ -# {{ managedText | raw }} - -FROM php:{{ php.version }} AS base - -COPY --from=composer:2 /usr/bin/composer /usr/bin/composer -RUN which composer && composer -V - -ARG DOCKER_UID=1000 -ENV DOCKER_UID="${DOCKER_UID}" - -WORKDIR {{ project_root }} - -RUN adduser --disabled-password --uid "${DOCKER_UID}" app \ - && chown app:app -R {{ project_root }} - -USER app - -ENV PATH="${PATH}:{{ project_root }}/bin:{{ project_root }}/vendor/bin" - -COPY --chown=app:app composer.* ./ - -################################################################################ - -FROM base AS build - -USER root - -{% if 'apache' in php.version %} -RUN a2enmod rewrite -{% endif %} - -{% if dockerfile.stages.build.packages %} -RUN apt-get update -yqq \ - && apt-get install -yqq --no-install-recommends \ - {{ dockerfile.stages.build.packages | join(' ') }} -{% endif %} - -RUN docker-php-ext-configure gd --with-jpeg - -{% if dockerfile.stages.build.extensions.install %} -RUN docker-php-ext-install {{ dockerfile.stages.build.extensions.install | join(' ') }} -{% endif %} - -COPY --chown=app:app phpunit.xml* ./ - -{% if dockerfile.stages.build.extra_files %} -COPY --chown=app:app {{ dockerfile.stages.build.extra_files | join(" ") }} ./ -{% endif %} -{% for directory in dockerfile.stages.build.extra_directories %} -COPY --chown=app:app {{ directory }} {{ directory }} -{% endfor %} - -{% for command in dockerfile.stages.build.root_commands | default([]) %} -RUN {{ command | raw }} -{% endfor %} - -USER app - -{% for command in dockerfile.stages.build.commands %} -RUN {{ command }} -{% endfor %} - -COPY --chown=app:app tools/docker/images/php/root / - -ENTRYPOINT ["/usr/local/bin/docker-entrypoint-php"] -CMD ["php-fpm"] - -{% if dockerfile.stages.test %} -################################################################################ - -FROM {{ dockerfile.stages.test.extends }} AS test - -COPY --chown=app:app . . - -RUN {% for command in dockerfile.stages.test.commands -%} -{% if not loop.first %} && {% endif %} -{{ command }} -{%- if not loop.last %} \{% endif %} - -{% endfor %} -{% endif %} - - -{% if web.type == "caddy" %} -################################################################################ - -FROM caddy:2 as web - -WORKDIR {{ project_root }} - -COPY tools/docker/images/web/root / -{% endif %} - -{% if web.type == "nginx" %} -################################################################################ - -FROM nginx:1 as web - -EXPOSE 8080 - -WORKDIR {{ project_root }} - -COPY tools/docker/images/web/root / -{% endif %} diff --git a/templates/php/docker-entrypoint-php.twig b/templates/php/docker-entrypoint-php.twig deleted file mode 100755 index a377d80..0000000 --- a/templates/php/docker-entrypoint-php.twig +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -# {{ managedText | raw }} - -[[ -f composer.json && ! -d vendor ]] && composer install - -eval "$@" diff --git a/templates/php/php.ini.twig b/templates/php/php.ini.twig deleted file mode 100644 index fa28093..0000000 --- a/templates/php/php.ini.twig +++ /dev/null @@ -1,4 +0,0 @@ -# {{ managedText }} - -max_vars_input = 1000 -memory_limit = {{ php.ini.memory_limit | default('128M') }} diff --git a/templates/php/phpcs.xml.twig b/templates/php/phpcs.xml.twig deleted file mode 100644 index 7b504a1..0000000 --- a/templates/php/phpcs.xml.twig +++ /dev/null @@ -1,40 +0,0 @@ - - - - - PHPCS configuration file for {{ name }}. - - {% for path in php.phpcs.paths|default('[]') %} - {{ path }} - {% endfor %} - - - - {% for standard in php.phpcs.standards|default(['Drupal', 'DrupalPractice']) %} - {% if not standard is same as "Drupal" %} - - {% endif %} - {% endfor %} - - {% if type is same as "drupal" and "Drupal" in php.phpcs.standards or php.phpcs.standards is empty %} - - - - - - - - - - - - - - - - - - - - {% endif %} - diff --git a/templates/php/phpstan.neon.twig b/templates/php/phpstan.neon.twig deleted file mode 100644 index 5263f21..0000000 --- a/templates/php/phpstan.neon.twig +++ /dev/null @@ -1,16 +0,0 @@ -# {{ managedText | raw }} - -parameters: - level: {{ php.phpstan.level }} - excludePaths: - - *Test.php - - *TestBase.php - paths: - {% for path in php.phpstan.paths | default(["src"]) -%} - - {{ path }} - {%- endfor %} - -{% if php.phpstan.baseline %} -includes: - - phpstan-baseline.neon -{% endif %} diff --git a/templates/php/phpunit.xml.twig b/templates/php/phpunit.xml.twig deleted file mode 100644 index 8f8f983..0000000 --- a/templates/php/phpunit.xml.twig +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - tests - - - diff --git a/templates/typescript/.yarnrc.twig b/templates/typescript/.yarnrc.twig deleted file mode 100644 index 689960c..0000000 --- a/templates/typescript/.yarnrc.twig +++ /dev/null @@ -1,3 +0,0 @@ -# {{ managedText | raw }} - ---modules-folder /node_modules diff --git a/templates/typescript/Dockerfile.twig b/templates/typescript/Dockerfile.twig deleted file mode 100644 index fc5bf8f..0000000 --- a/templates/typescript/Dockerfile.twig +++ /dev/null @@ -1,20 +0,0 @@ -FROM node:{{ node.version }} AS base - -WORKDIR {{ project_root }} - -RUN mkdir /node_modules \ - && chown node:node -R {{ project_root }} /node_modules - -COPY --chown=node:node package*.json *yarn* {{ project_root }} - -USER node - -################################################################################ - -FROM base AS build - -RUN yarn install --frozen-lockfile - -COPY --chown=node:node . . - -CMD ["bash"]