From 6f962c3d43011e7a74a91868578d244d3a33c809 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 17 Jul 2023 15:05:00 +1000 Subject: [PATCH] Updated dependencies to be contained and fixed the namespace. Signed-off-by: Alex Skrypnyk --- composer.d10.json | 18 -- composer.d10.lock | 50 +++- composer.lock | 227 ++++++++++++++++++ docroot/themes/contrib/civictheme/.ahoy.yml | 21 ++ .../contrib/civictheme/.circleci/build.sh | 197 +++++++++++++++ .../contrib/civictheme/.circleci/config.yml | 112 +++++++++ .../contrib/civictheme/.circleci/deploy.sh | 84 +++++++ .../contrib/civictheme/.circleci/lint.sh | 40 +++ .../civictheme/.circleci/process-artifacts.sh | 24 ++ .../contrib/civictheme/.circleci/test.sh | 55 +++++ .../themes/contrib/civictheme/.editorconfig | 26 ++ .../themes/contrib/civictheme/.gitattributes | 6 +- .../civictheme/.github/release-drafter.yml | 12 + .../.github/workflows/draft-release.yml | 22 ++ docroot/themes/contrib/civictheme/.gitignore | 1 + .../contrib/civictheme/.gitignore.release | 1 + docroot/themes/contrib/civictheme/README.md | 6 +- .../contrib/civictheme/civictheme.info.yml | 3 +- .../themes/contrib/civictheme/composer.json | 8 +- .../tests/src/Unit/CivicthemeUnitTestBase.php | 3 +- 20 files changed, 886 insertions(+), 30 deletions(-) create mode 100644 docroot/themes/contrib/civictheme/.ahoy.yml create mode 100755 docroot/themes/contrib/civictheme/.circleci/build.sh create mode 100644 docroot/themes/contrib/civictheme/.circleci/config.yml create mode 100755 docroot/themes/contrib/civictheme/.circleci/deploy.sh create mode 100755 docroot/themes/contrib/civictheme/.circleci/lint.sh create mode 100755 docroot/themes/contrib/civictheme/.circleci/process-artifacts.sh create mode 100755 docroot/themes/contrib/civictheme/.circleci/test.sh create mode 100644 docroot/themes/contrib/civictheme/.editorconfig create mode 100644 docroot/themes/contrib/civictheme/.github/release-drafter.yml create mode 100644 docroot/themes/contrib/civictheme/.github/workflows/draft-release.yml diff --git a/composer.d10.json b/composer.d10.json index 16d349fba..2a02cc404 100644 --- a/composer.d10.json +++ b/composer.d10.json @@ -6,15 +6,10 @@ "php": ">=8.1", "composer/installers": "^2", "cweagans/composer-patches": "^1.7", - "drupal/ckeditor": "^1.0", "drupal/core-composer-scaffold": "^10", "drupal/core-project-message": "^10", "drupal/core-recommended": "^10", "drupal/core": "10.0", - "drupal/jquery_ui": "^1.6", - "drupal/jquery_ui_autocomplete": "^2", - "drupal/jquery_ui_menu": "^2", - "drupal/linkit": "^6.0@beta", "drush/drush": "^11", "oomphinc/composer-installers-extender": "^2.0", "vlucas/phpdotenv": "^5.1", @@ -72,19 +67,6 @@ "drupal/drupal": "*" }, "repositories": { - "drupal/components": { - "type": "package", - "package": { - "name": "drupal/components", - "type": "drupal-module", - "version": "2.4", - "source": { - "type": "git", - "url": "https://git.drupalcode.org/project/components.git", - "reference": "8e184d5f98e56370cde9191f2810c913268b3294" - } - } - }, "drupal/drupal-driver": { "type": "vcs", "url": "https://github.com/drevops/DrupalDriver" diff --git a/composer.d10.lock b/composer.d10.lock index bc8bc936a..e9de73bfe 100644 --- a/composer.d10.lock +++ b/composer.d10.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b1004c3cdd858f2a38df430815c8aab1", + "content-hash": "c0f0659f608b0fc64ba6fb78a176dafb", "packages": [ { "name": "asm89/stack-cors", @@ -1234,13 +1234,52 @@ }, { "name": "drupal/components", - "version": "2.4", + "version": "3.0.0-beta3", "source": { "type": "git", "url": "https://git.drupalcode.org/project/components.git", - "reference": "8e184d5f98e56370cde9191f2810c913268b3294" + "reference": "3.0.0-beta3" }, - "type": "drupal-module" + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/components-3.0.0-beta3.zip", + "reference": "3.0.0-beta3", + "shasum": "47ced4332f0a655ca38ae1b54e97a8e78d59f0bc" + }, + "require": { + "drupal/core": "^9 || ^10" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "3.0.0-beta3", + "datestamp": "1651759488", + "security-coverage": { + "status": "not-covered", + "message": "Beta releases are not covered by Drupal security advisories." + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "JohnAlbin", + "homepage": "https://www.drupal.org/user/32095", + "email": "virtually.johnalbin@gmail.com" + }, + { + "name": "RobLoach", + "homepage": "https://www.drupal.org/user/61114" + } + ], + "description": "Registers folders of components defined by your theme or module as Twig namespaces", + "homepage": "https://drupal.org/project/components", + "support": { + "source": "https://git.drupalcode.org/project/components" + } }, { "name": "drupal/config_devel", @@ -13760,9 +13799,10 @@ ], "minimum-stability": "dev", "stability-flags": { - "drupal/linkit": 10, "drupal/core-dev": 10, "drupal/drupal-extension": 20, + "drupal/components": 10, + "drupal/linkit": 10, "drupal/default_content": 15 }, "prefer-stable": true, diff --git a/composer.lock b/composer.lock index d315a944a..20aa57a70 100644 --- a/composer.lock +++ b/composer.lock @@ -2798,6 +2798,101 @@ "source": "https://git.drupalcode.org/project/chosen" } }, + { + "name": "drupal/ckeditor", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/ckeditor.git", + "reference": "1.0.2" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/ckeditor-1.0.2.zip", + "reference": "1.0.2", + "shasum": "fec2ca9ad852a00c7b9584cb6040dc860364c481" + }, + "require": { + "drupal/core": "^9.4 || ^10" + }, + "require-dev": { + "drupal/classy": "*" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "1.0.2", + "datestamp": "1687261951", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "dczepierga", + "homepage": "https://www.drupal.org/user/911466" + }, + { + "name": "hass", + "homepage": "https://www.drupal.org/user/85918" + }, + { + "name": "jcisio", + "homepage": "https://www.drupal.org/user/210762" + }, + { + "name": "Jorrit", + "homepage": "https://www.drupal.org/user/161217" + }, + { + "name": "lauriii", + "homepage": "https://www.drupal.org/user/1078742" + }, + { + "name": "Magnus", + "homepage": "https://www.drupal.org/user/73919" + }, + { + "name": "mkesicki", + "homepage": "https://www.drupal.org/user/922884" + }, + { + "name": "nod_", + "homepage": "https://www.drupal.org/user/598310" + }, + { + "name": "p.wiaderny", + "homepage": "https://www.drupal.org/user/2956619" + }, + { + "name": "vokiel", + "homepage": "https://www.drupal.org/user/2793801" + }, + { + "name": "Wim Leers", + "homepage": "https://www.drupal.org/user/99777" + }, + { + "name": "wwalc", + "homepage": "https://www.drupal.org/user/184556" + }, + { + "name": "xjm", + "homepage": "https://www.drupal.org/user/65776" + } + ], + "description": "WYSIWYG editing for rich text fields using CKEditor.", + "homepage": "https://www.drupal.org/project/ckeditor", + "support": { + "source": "https://git.drupalcode.org/project/ckeditor" + } + }, { "name": "drupal/components", "version": "2.4.0", @@ -5957,6 +6052,72 @@ "source": "https://git.drupalcode.org/project/jquery_ui" } }, + { + "name": "drupal/jquery_ui_autocomplete", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/jquery_ui_autocomplete.git", + "reference": "2.0.0" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/jquery_ui_autocomplete-2.0.0.zip", + "reference": "2.0.0", + "shasum": "927d312a74002f99e1c971d3d268be1b0a532fc7" + }, + "require": { + "drupal/core": "^9.2 || ^10", + "drupal/jquery_ui": "^1.6", + "drupal/jquery_ui_menu": "^2" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "2.0.0", + "datestamp": "1670871461", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "bnjmnm", + "homepage": "https://www.drupal.org/user/2369194" + }, + { + "name": "lauriii", + "homepage": "https://www.drupal.org/user/1078742" + }, + { + "name": "nod_", + "homepage": "https://www.drupal.org/user/598310" + }, + { + "name": "phenaproxima", + "homepage": "https://www.drupal.org/user/205645" + }, + { + "name": "Wim Leers", + "homepage": "https://www.drupal.org/user/99777" + }, + { + "name": "zrpnr", + "homepage": "https://www.drupal.org/user/1448368" + } + ], + "description": "Provides jQuery UI Autocomplete library.", + "homepage": "https://www.drupal.org/project/jquery_ui_autocomplete", + "support": { + "source": "https://git.drupalcode.org/project/jquery_ui_autocomplete" + } + }, { "name": "drupal/jquery_ui_draggable", "version": "2.0.0", @@ -6064,6 +6225,71 @@ "source": "https://git.drupalcode.org/project/jquery_ui_droppable" } }, + { + "name": "drupal/jquery_ui_menu", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/jquery_ui_menu.git", + "reference": "2.0.0" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/jquery_ui_menu-2.0.0.zip", + "reference": "2.0.0", + "shasum": "5e1b56bf457669c7779a81784f49da63e3956854" + }, + "require": { + "drupal/core": "^9.2 || ^10", + "drupal/jquery_ui": "^1.6" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "2.0.0", + "datestamp": "1670871546", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "bnjmnm", + "homepage": "https://www.drupal.org/user/2369194" + }, + { + "name": "lauriii", + "homepage": "https://www.drupal.org/user/1078742" + }, + { + "name": "nod_", + "homepage": "https://www.drupal.org/user/598310" + }, + { + "name": "phenaproxima", + "homepage": "https://www.drupal.org/user/205645" + }, + { + "name": "Wim Leers", + "homepage": "https://www.drupal.org/user/99777" + }, + { + "name": "zrpnr", + "homepage": "https://www.drupal.org/user/1448368" + } + ], + "description": "Provides jQuery UI Menu library.", + "homepage": "https://www.drupal.org/project/jquery_ui_menu", + "support": { + "source": "https://git.drupalcode.org/project/jquery_ui_menu" + } + }, { "name": "drupal/key", "version": "1.17.0", @@ -21256,6 +21482,7 @@ "minimum-stability": "dev", "stability-flags": { "drupal/drupal-extension": 20, + "drupal/components": 10, "drupal/linkit": 10, "drupal/default_content": 15 }, diff --git a/docroot/themes/contrib/civictheme/.ahoy.yml b/docroot/themes/contrib/civictheme/.ahoy.yml new file mode 100644 index 000000000..dc80c33cb --- /dev/null +++ b/docroot/themes/contrib/civictheme/.ahoy.yml @@ -0,0 +1,21 @@ +# +# Ahoy configuration file. +# http://www.ahoycli.com/ +# +# Provides development experience shortcuts. +--- +ahoyapi: v2 + +commands: + + build: + usage: Build or rebuild the project. + cmd: ./.circleci/build.sh + + lint: + usage: Lint code. + cmd: ./.circleci/lint.sh + + test: + usage: Run all tests. + cmd: ./.circleci/test.sh diff --git a/docroot/themes/contrib/civictheme/.circleci/build.sh b/docroot/themes/contrib/civictheme/.circleci/build.sh new file mode 100755 index 000000000..4dbf48a36 --- /dev/null +++ b/docroot/themes/contrib/civictheme/.circleci/build.sh @@ -0,0 +1,197 @@ +#!/usr/bin/env bash +## +# Build Drupal site using SQLite database, install current theme and serve +# using in-built PHP server. +# +# Allows to use the latest Drupal core as well as specified versions (for +# testing backward compatibility). +# +# - Retrieves the scaffold from drupal-composer/drupal-project or custom scaffold. +# - Builds Drupal site codebase with current theme and it's dependencies. +# - Installs Drupal using SQLite database. +# - Starts in-built PHP-server +# - Enables theme +# - Serves site and generates one-time login link +# +# This script will re-build everything from scratch every time it runs. + +# shellcheck disable=SC2015,SC2094,SC2002 + +set -eu +[ -n "${DEBUG:-}" ] && set -x + +#------------------------------------------------------------------------------- +# Variables (passed from environment; provided for reference only). +#------------------------------------------------------------------------------- + +# Directory where Drupal site will be built. +BUILD_DIR="${BUILD_DIR:-build}" + +# Webserver hostname. +WEBSERVER_HOST="${WEBSERVER_HOST:-localhost}" + +# Webserver port. +WEBSERVER_PORT="${WEBSERVER_PORT:-8000}" + +# Drupal core version to use. If not provided - the latest stable version will be used. +# Must be coupled with DRUPAL_PROJECT_SHA below. +DRUPAL_VERSION="${DRUPAL_VERSION:-}" + +# Commit SHA of the drupal-project to install custom core version. If not +# provided - the latest version will be used. +# Must be coupled with DRUPAL_VERSION above. +DRUPAL_PROJECT_SHA="${DRUPAL_PROJECT_SHA:-}" + +# Repository for "drupal-composer/drupal-project" project. +# May be overwritten to use forked repos that may have not been accepted +# yet (i.e., when major Drupal version is about to be released). +DRUPAL_PROJECT_REPO="${DRUPAL_PROJECT_REPO:-https://github.com/drupal-composer/drupal-project.git}" + +# Drupal profile to use when installing the site. +DRUPAL_PROFILE="${DRUPAL_PROFILE:-standard}" + +# Theme name, taken from the .info file. +THEME="$(basename -s .info.yml -- ./*.info.yml)" + +# Database file path. +DB_FILE="${DB_FILE:-/tmp/site_${THEME}.sqlite}" + +#------------------------------------------------------------------------------- + +echo +echo "==> Started build in \"${BUILD_DIR}\" directory." +echo + +echo "-------------------------------" +echo " Validating requirements " +echo "-------------------------------" + +echo " > Validating tools." +! command -v git > /dev/null && echo "ERROR: Git is required for this script to run." && exit 1 +! command -v php > /dev/null && echo "ERROR: PHP is required for this script to run." && exit 1 +! command -v composer > /dev/null && echo "ERROR: Composer (https://getcomposer.org/) is required for this script to run." && exit 1 +! command -v jq > /dev/null && echo "ERROR: jq (https://stedolan.github.io/jq/) is required for this script to run." && exit 1 + +echo " > Validating Composer configuration." +composer validate --ansi --strict + +# Reset the environment. +[ -d "${BUILD_DIR}" ] && echo " > Removing existing ${BUILD_DIR} directory." && chmod -Rf 777 "${BUILD_DIR}" && rm -rf "${BUILD_DIR}" + +echo "-------------------------------" +echo " Installing Composer packages " +echo "-------------------------------" + +# Allow installing custom version of Drupal core from drupal-composer/drupal-project, +# but only coupled with drupal-project SHA (required to get correct dependencies). +if [ -n "${DRUPAL_VERSION:-}" ] && [ -n "${DRUPAL_PROJECT_SHA:-}" ]; then + echo " > Initialising Drupal site from the scaffold repo ${DRUPAL_PROJECT_REPO} commit ${DRUPAL_PROJECT_SHA}." + + # Clone Drupal core at the specific commit SHA. + git clone -n "${DRUPAL_PROJECT_REPO}" "${BUILD_DIR}" + git --git-dir="${BUILD_DIR}/.git" --work-tree="${BUILD_DIR}" checkout "${DRUPAL_PROJECT_SHA}" + rm -rf "${BUILD_DIR}/.git" > /dev/null + + echo " > Pinning Drupal to a specific version ${DRUPAL_VERSION}." + sed_opts=(-i) && [ "$(uname)" == "Darwin" ] && sed_opts=(-i '') + sed "${sed_opts[@]}" 's|\(.*"drupal\/core"\): "\(.*\)",.*|\1: '"\"$DRUPAL_VERSION\",|" "${BUILD_DIR}/composer.json" + cat "${BUILD_DIR}/composer.json" +else + echo " > Initialising Drupal site from the latest scaffold." + # There are no releases in "drupal-composer/drupal-project", so have to use "@dev". + php -d memory_limit=-1 "$(command -v composer)" create-project drupal-composer/drupal-project:@dev "${BUILD_DIR}" --no-interaction --no-install +fi + +echo " > Updating scaffold." +cat <<< "$(jq --indent 4 '.extra["enable-patching"] = true' "${BUILD_DIR}/composer.json")" > "${BUILD_DIR}/composer.json" +cat <<< "$(jq --indent 4 '.extra["phpcodesniffer-search-depth"] = 10' "${BUILD_DIR}/composer.json")" > "${BUILD_DIR}/composer.json" + +echo " > Merging configuration from theme's composer.json." +php -r "echo json_encode(array_replace_recursive(json_decode(file_get_contents('composer.json'), true),json_decode(file_get_contents('${BUILD_DIR}/composer.json'), true)),JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);" > "${BUILD_DIR}/composer2.json" && mv -f "${BUILD_DIR}/composer2.json" "${BUILD_DIR}/composer.json" + +echo " > Creating GitHub authentication token if provided." +[ -n "${GITHUB_TOKEN:-}" ] && composer config --global github-oauth.github.com "$GITHUB_TOKEN" && echo "Token: " && composer config --global github-oauth.github.com + +echo " > Installing dependencies." +php -d memory_limit=-1 "$(command -v composer)" --working-dir="${BUILD_DIR}" install + +# Suggested dependencies allow to install them for testing without requiring +# them in theme's composer.json. +echo " > Installing suggested dependencies from theme's composer.json." +composer_suggests=$(cat composer.json | jq -r 'select(.suggest != null) | .suggest | keys[]') +for composer_suggest in $composer_suggests; do + php -d memory_limit=-1 "$(command -v composer)" --working-dir="${BUILD_DIR}" require "${composer_suggest}" +done + +echo " > Installing other dev dependencies." +php -d memory_limit=-1 "$(command -v composer)" --working-dir="${BUILD_DIR}" require --dev \ + dealerdirect/phpcodesniffer-composer-installer \ + phpspec/prophecy-phpunit:^2 \ + mglaman/drupal-check \ + rector/rector:0.15.13 \ + palantirnet/drupal-rector +cp "${BUILD_DIR}/vendor/palantirnet/drupal-rector/rector.php" "${BUILD_DIR}/." + +echo "-------------------------------" +echo " Starting builtin PHP server " +echo "-------------------------------" + +# Stop previously started services. +killall -9 php > /dev/null 2>&1 || true +# Start the PHP webserver. +nohup php -S "${WEBSERVER_HOST}:${WEBSERVER_PORT}" -t "$(pwd)/${BUILD_DIR}/web" "$(pwd)/${BUILD_DIR}/web/.ht.router.php" > /tmp/php.log 2>&1 & +sleep 4 # Waiting for the server to be ready. +netstat_opts='-tulpn'; [ "$(uname)" == "Darwin" ] && netstat_opts='-anv' || true; +# Check that the server was started. +netstat "${netstat_opts[@]}" | grep -q "${WEBSERVER_PORT}" || (echo "ERROR: Unable to start inbuilt PHP server" && cat /tmp/php.log && exit 1) +# Check that the server can serve content. +curl -s -o /dev/null -w "%{http_code}" -L -I "http://${WEBSERVER_HOST}:${WEBSERVER_PORT}" | grep -q 200 || (echo "ERROR: Server is started, but site cannot be served" && exit 1) +echo " > Started builtin PHP server at http://${WEBSERVER_HOST}:${WEBSERVER_PORT} in $(pwd)/${BUILD_DIR}/web." + +echo "-------------------------------" +echo " Installing Drupal and themes " +echo "-------------------------------" + +echo " > Installing Drupal into SQLite database ${DB_FILE}." +"${BUILD_DIR}/vendor/bin/drush" -r "${BUILD_DIR}/web" si "${DRUPAL_PROFILE}" -y --db-url "sqlite://${DB_FILE}" --account-name=admin install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL +"${BUILD_DIR}/vendor/bin/drush" -r "$(pwd)/${BUILD_DIR}/web" status + +echo " > Symlinking theme code." +rm -rf "${BUILD_DIR}/web/themes/${THEME}"/* > /dev/null +mkdir -p "${BUILD_DIR}/web/themes/${THEME}" +ln -s "$(pwd)"/* "${BUILD_DIR}/web/themes/${THEME}" && rm "${BUILD_DIR}/web/themes/${THEME}/${BUILD_DIR}" + +######################################## + +echo " > Enabling theme ${THEME} dependent modules." +"${BUILD_DIR}/vendor/bin/drush" php:eval "require_once dirname(\Drupal::getContainer()->get('theme_handler')->rebuildThemeData()['civictheme']->getPathname()) . '/theme-settings.provision.inc'; civictheme_enable_modules();" + +echo " > Enabling theme ${THEME}." +"${BUILD_DIR}/vendor/bin/drush" -r "${BUILD_DIR}/web" theme:install "${THEME}" -y +"${BUILD_DIR}/vendor/bin/drush" -r "${BUILD_DIR}/web" cr + +echo " > Setting theme ${THEME} as default." +"${BUILD_DIR}/vendor/bin/drush" config:set system.theme default "${THEME}" -y + +echo " > Provisioning content from theme defaults." +"${BUILD_DIR}/vendor/bin/drush" php:eval -v "require_once dirname(\Drupal::getContainer()->get('theme_handler')->rebuildThemeData()['civictheme']->getPathname()) . '/theme-settings.provision.inc'; civictheme_provision_cli();" + +######################################## + +# Visit site to pre-warm caches. +curl -s "http://${WEBSERVER_HOST}:${WEBSERVER_PORT}" > /dev/null + +echo +echo "-------------------------------" +echo " Build finished 🚀🚀🚀" +echo "-------------------------------" +echo +echo " > Site URL: http://${WEBSERVER_HOST}:${WEBSERVER_PORT}" +echo -n " > One-time login link: " +"${BUILD_DIR}/vendor/bin/drush" -r "${BUILD_DIR}/web" -l "http://${WEBSERVER_HOST}:${WEBSERVER_PORT}" uli --no-browser +echo +echo " > Available commands:" +echo " ahoy build # rebuild" +echo " ahoy lint # check code standards" +echo " ahoy test # run tests" +echo diff --git a/docroot/themes/contrib/civictheme/.circleci/config.yml b/docroot/themes/contrib/civictheme/.circleci/config.yml new file mode 100644 index 000000000..33f7fd6c4 --- /dev/null +++ b/docroot/themes/contrib/civictheme/.circleci/config.yml @@ -0,0 +1,112 @@ +# @see https://github.com/drevops/drupal_circleci +version: 2 +aliases: + # SSH deployment key fingerprint from CircleCI App -> Project -> Settings -> SSH Permissions. + # Replace the value for your project. + - &deploy_ssh_fingerprint "47:f9:29:8b:9b:1b:e9:66:5d:b3:f6:dd:e7:60:d1:f9" + - &container_config + working_directory: ~/project + docker: + - image: cimg/php:8.2-browsers + +job-build: &job-build + steps: + - checkout + - run: .circleci/build.sh + - run: .circleci/lint.sh + - run: .circleci/test.sh + - run: + command: .circleci/process-artifacts.sh + when: always + - store_test_results: + path: /tmp/test_results + - store_artifacts: + path: /tmp/artifacts + +jobs: + build-php-8.1: + <<: *container_config + docker: + - image: cimg/php:8.1-browsers + <<: *job-build + + build-php-8.2: + <<: *container_config + docker: + - image: cimg/php:8.2-browsers + <<: *job-build + + build-php-8.1-legacy: + <<: *container_config + docker: + - image: cimg/php:8.1-browsers + environment: + DRUPAL_VERSION: 9.5 + DRUPAL_PROJECT_SHA: 9.x + <<: *job-build + + build-php-8.2-legacy: + <<: *container_config + docker: + - image: cimg/php:8.2-browsers + environment: + DRUPAL_VERSION: 9.5 + DRUPAL_PROJECT_SHA: 9.x + <<: *job-build + + build-php-8.2-next: + <<: *container_config + docker: + - image: cimg/php:8.2-browsers + environment: + DRUPAL_VERSION: 10@beta + <<: *job-build + + deploy: + <<: *container_config + environment: + DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint + steps: + - checkout + - add_ssh_keys: + fingerprints: + - *deploy_ssh_fingerprint + - run: DEPLOY_BRANCH=${DEPLOY_BRANCH:-${CIRCLE_BRANCH}} .circleci/deploy.sh + +workflows: + version: 2 + main: + jobs: + - build-php-8.1: + filters: + tags: + only: /.*/ + - build-php-8.2: + filters: + tags: + only: /.*/ + - build-php-8.1-legacy: + filters: + tags: + only: /.*/ + - build-php-8.2-legacy: + filters: + tags: + only: /.*/ + - build-php-8.2-next: + filters: + tags: + only: /.*/ + - deploy: + requires: + - build-php-8.1 + - build-php-8.2 + - build-php-8.1-legacy + - build-php-8.2-legacy + - build-php-8.2-next + filters: + tags: + only: /.*/ + branches: + # 1.0.x, 2.3.x, 9.x, 10.x, 9.x-2.x, ci, ci-test + only: /^[0-9]+.[0-9]+.x$|^[0-9]+.x(?:\-[0-9]+\.x)?$|^ci.*/ diff --git a/docroot/themes/contrib/civictheme/.circleci/deploy.sh b/docroot/themes/contrib/civictheme/.circleci/deploy.sh new file mode 100755 index 000000000..02e673366 --- /dev/null +++ b/docroot/themes/contrib/civictheme/.circleci/deploy.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +## +# Deploy code to a remote repository. +# +# - configures local git +# - adds deployment SSH key to SSH agent +# - force-pushes code to a remote code repository branch +# +# It is a good practice to create a separate Deployer user with own SSH key for +# every project. +# +# Add the following variables through CircleCI UI. +# - DEPLOY_USER_NAME - name of the user who will be committing to a remote repository. +# - DEPLOY_USER_EMAIL - email address of the user who will be committing to a remote repository. +# - DEPLOY_REMOTE - remote repository to push code to. +# - DEPLOY_PROCEED - set to 1 if the deployment should proceed. Useful for testing CI configuration before an actual code push. + +set -eu +[ -n "${DEBUG:-}" ] && set -x + +#------------------------------------------------------------------------------- +# Variables (passed from environment; provided for reference only). +#------------------------------------------------------------------------------- + +# Name of the user who will be committing to a remote repository. +DEPLOY_USER_NAME="${DEPLOY_USER_NAME:-}" + +# Email address of the user who will be committing to a remote repository. +DEPLOY_USER_EMAIL="${DEPLOY_USER_EMAIL:-}" + +# Remote repository to push code to. +DEPLOY_REMOTE="${DEPLOY_REMOTE:-}" + +# Git branch to deploy. If not provided - current branch will be used. +DEPLOY_BRANCH="${DEPLOY_BRANCH:-}" + +# The fingerprint of the SSH key of the user on behalf of which the deployment +# is performed. +DEPLOY_SSH_FINGERPRINT="${DEPLOY_SSH_FINGERPRINT:-}" + +# Set to 1 if the deployment should proceed. Useful for testing CI configuration +# before an actual code push. +DEPLOY_PROCEED="${DEPLOY_PROCEED:-0}" + +#------------------------------------------------------------------------------- + +[ -z "${DEPLOY_USER_NAME}" ] && echo "ERROR: Missing required value for DEPLOY_USER_NAME" && exit 1 +[ -z "${DEPLOY_USER_EMAIL}" ] && echo "ERROR: Missing required value for DEPLOY_USER_EMAIL" && exit 1 +[ -z "${DEPLOY_REMOTE}" ] && echo "ERROR: Missing required value for DEPLOY_REMOTE" && exit 1 +[ -z "${DEPLOY_SSH_FINGERPRINT}" ] && echo "ERROR: Missing required value for DEPLOY_SSH_FINGERPRINT" && exit 1 + +[ "${DEPLOY_PROCEED}" != "1" ] && echo "==> Skipping deployment because \$DEPLOY_PROCEED is not set to 1" && exit 0 + +# Configure git and SSH to connect to remote servers for deployment. +mkdir -p "${HOME}/.ssh/" +echo -e "Host *\n\tStrictHostKeyChecking no\n" > "${HOME}/.ssh/config" +DEPLOY_SSH_FILE="${DEPLOY_SSH_FINGERPRINT//:}" +DEPLOY_SSH_FILE="${HOME}/.ssh/id_rsa_${DEPLOY_SSH_FILE//\"}" +[ ! -f "${DEPLOY_SSH_FILE:-}" ] && echo "ERROR: Unable to find Deploy SSH key file ${DEPLOY_SSH_FILE}." && exit 1 +if [ -z "${SSH_AGENT_PID:-}" ]; then eval "$(ssh-agent)"; fi +ssh-add -D > /dev/null +ssh-add "${DEPLOY_SSH_FILE}" + +# Configure git user name and email, but only if not already set. +[ "$(git config --global user.name)" == "" ] && echo "==> Configuring global git user name ${DEPLOY_USER_NAME}." && git config --global user.name "${DEPLOY_USER_NAME}" +[ "$(git config --global user.email)" == "" ] && echo "==> Configuring global git user email ${DEPLOY_USER_EMAIL}." && git config --global user.email "${DEPLOY_USER_EMAIL}" + +# Set git to push to a matching remote branch. +git config --global push.default matching + +echo "==> Adding remote ${DEPLOY_REMOTE}." +git remote add deployremote "${DEPLOY_REMOTE}" + +echo "==> Deploying to remote ${DEPLOY_REMOTE}." + +echo " > Pushing code to branch ${DEPLOY_BRANCH}." +git push --force deployremote HEAD:"${DEPLOY_BRANCH}" + +echo " > Pushing tags." +git push --force --tags deployremote || true + +echo +echo "==> Deployment finished." +echo diff --git a/docroot/themes/contrib/civictheme/.circleci/lint.sh b/docroot/themes/contrib/civictheme/.circleci/lint.sh new file mode 100755 index 000000000..22b62022c --- /dev/null +++ b/docroot/themes/contrib/civictheme/.circleci/lint.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +## +# Run lint checks. +# + +set -eu +[ -n "${DEBUG:-}" ] && set -x + +#------------------------------------------------------------------------------- +# Variables (passed from environment; provided for reference only). +#------------------------------------------------------------------------------- + +# Directory where Drupal site will be built. +BUILD_DIR="${BUILD_DIR:-build}" + +# Module name, taken from .info file. +MODULE="$(basename -s .info.yml -- ./*.info.yml)" + +#------------------------------------------------------------------------------- + +echo "==> Lint code for module $MODULE." +echo " > Running PHPCS." +build/vendor/bin/phpcs \ + -s \ + -p \ + --standard=Drupal,DrupalPractice \ + --extensions=module,php,install,inc,test,info.yml,js \ + "${BUILD_DIR}/web/themes/${MODULE}" + +echo " > Running drupal-check." +build/vendor/bin/drupal-check \ + --drupal-root=build/web \ + "${BUILD_DIR}/web/themes/${MODULE}" || true + +echo " > Running Drupal Rector." +pushd "${BUILD_DIR}" >/dev/null || exit 1 +vendor/bin/rector process \ + "web/themes/${MODULE}" \ + --dry-run +popd >/dev/null || exit 1 diff --git a/docroot/themes/contrib/civictheme/.circleci/process-artifacts.sh b/docroot/themes/contrib/civictheme/.circleci/process-artifacts.sh new file mode 100755 index 000000000..d4fe3e703 --- /dev/null +++ b/docroot/themes/contrib/civictheme/.circleci/process-artifacts.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +## +# Process test artifacts. +# +# This runs only in CircleCI. +# + +set -eu +[ -n "${DEBUG:-}" ] && set -x + +#------------------------------------------------------------------------------- +# Variables (passed from environment; provided for reference only). +#------------------------------------------------------------------------------- + +# Directory where Drupal site will be built. +BUILD_DIR="${BUILD_DIR:-build}" + +#------------------------------------------------------------------------------- + +if [ -d "$(pwd)/${BUILD_DIR}/web/sites/simpletest/browser_output" ]; then + echo "==> Copying Simpletest test artifacts" + mkdir -p /tmp/artifacts/simpletest + cp -Rf "$(pwd)/${BUILD_DIR}/web/sites/simpletest/browser_output/." /tmp/artifacts/simpletest +fi diff --git a/docroot/themes/contrib/civictheme/.circleci/test.sh b/docroot/themes/contrib/civictheme/.circleci/test.sh new file mode 100755 index 000000000..2fb776856 --- /dev/null +++ b/docroot/themes/contrib/civictheme/.circleci/test.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +## +# Run tests. +# + +set -eu +[ -n "${DEBUG:-}" ] && set -x + +#------------------------------------------------------------------------------- +# Variables (passed from environment; provided for reference only). +#------------------------------------------------------------------------------- + +# Directory where Drupal site will be built. +BUILD_DIR="${BUILD_DIR:-build}" + +# Webserver hostname. +WEBSERVER_HOST="${WEBSERVER_HOST:-localhost}" + +# Webserver port. +WEBSERVER_PORT="${WEBSERVER_PORT:-8000}" + +# Module name, taken from .info file. +MODULE="$(basename -s .info.yml -- ./*.info.yml)" + +# Test database file path. +TEST_DB_FILE="${TEST_DB_FILE:-/tmp/test.sqlite}" + +# Directory to store test results. +TEST_RESULTS_DIR="${TEST_RESULTS_DIR:-/tmp/test_results/simpletest}" + +#------------------------------------------------------------------------------- + +echo "==> Run tests." + +# Do not fail if there are no tests. +[ ! -d "tests" ] && echo "==> No tests were found. Skipping." && exit 0 + +# Re-create test results directory. +rm -rf "${TEST_RESULTS_DIR}" > /dev/null +mkdir -p "${TEST_RESULTS_DIR}" + +# Remove existing test DB file. +rm -f "${TEST_DB_FILE}" > /dev/null + +# Run tests using script provided by Drupal. +php "./${BUILD_DIR}/web/core/scripts/run-tests.sh" \ + --sqlite "${TEST_DB_FILE}" \ + --dburl "sqlite://localhost/${TEST_DB_FILE}" \ + --url "http://${WEBSERVER_HOST}:${WEBSERVER_PORT}" \ + --non-html \ + --xml "${TEST_RESULTS_DIR}" \ + --color \ + --verbose \ + --suppress-deprecations \ + --module "${MODULE}" diff --git a/docroot/themes/contrib/civictheme/.editorconfig b/docroot/themes/contrib/civictheme/.editorconfig new file mode 100644 index 000000000..b9ce7f637 --- /dev/null +++ b/docroot/themes/contrib/civictheme/.editorconfig @@ -0,0 +1,26 @@ +# Drupal editor configuration normalization +# @see http://editorconfig.org/ + +# This is the top-most .editorconfig file; do not search in parent directories. +root = true + +# All files. +[*] +end_of_line = LF +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.js] +indent_size = 2 + +[composer.{json,lock}] +indent_size = 4 + +[*.{yml,yaml}] +indent_size = 2 + +[*.{sh,bash,bats}] +indent_size = 2 diff --git a/docroot/themes/contrib/civictheme/.gitattributes b/docroot/themes/contrib/civictheme/.gitattributes index 7121bea85..655fc9289 100644 --- a/docroot/themes/contrib/civictheme/.gitattributes +++ b/docroot/themes/contrib/civictheme/.gitattributes @@ -1,2 +1,6 @@ +.ahoy.yml export-ignore +.circleci export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore .gitignore.release export-ignore -tests export-ignore diff --git a/docroot/themes/contrib/civictheme/.github/release-drafter.yml b/docroot/themes/contrib/civictheme/.github/release-drafter.yml new file mode 100644 index 000000000..699ff479c --- /dev/null +++ b/docroot/themes/contrib/civictheme/.github/release-drafter.yml @@ -0,0 +1,12 @@ +name-template: '$NEXT_MINOR_VERSION' +tag-template: '$NEXT_MINOR_VERSION' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +template: | + ## What's new since $PREVIOUS_TAG + + $CHANGES + + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$NEXT_MINOR_VERSION + + $CONTRIBUTORS diff --git a/docroot/themes/contrib/civictheme/.github/workflows/draft-release.yml b/docroot/themes/contrib/civictheme/.github/workflows/draft-release.yml new file mode 100644 index 000000000..1cd4d69c8 --- /dev/null +++ b/docroot/themes/contrib/civictheme/.github/workflows/draft-release.yml @@ -0,0 +1,22 @@ +name: Release Drafter + +on: + push: + branches: + - master + pull_request: + types: [opened, reopened, synchronize] + +permissions: + contents: read + +jobs: + update_release_draft: + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docroot/themes/contrib/civictheme/.gitignore b/docroot/themes/contrib/civictheme/.gitignore index ce7ea7584..5a5675e6c 100644 --- a/docroot/themes/contrib/civictheme/.gitignore +++ b/docroot/themes/contrib/civictheme/.gitignore @@ -3,3 +3,4 @@ node_modules # does not allow to run NodeJS scripts. storybook-static dist +build diff --git a/docroot/themes/contrib/civictheme/.gitignore.release b/docroot/themes/contrib/civictheme/.gitignore.release index 09809f500..e670282f7 100644 --- a/docroot/themes/contrib/civictheme/.gitignore.release +++ b/docroot/themes/contrib/civictheme/.gitignore.release @@ -3,3 +3,4 @@ # are going into release. node_modules civictheme_library/.gitignore.release +build diff --git a/docroot/themes/contrib/civictheme/README.md b/docroot/themes/contrib/civictheme/README.md index 7b40a7e45..7602eca98 100644 --- a/docroot/themes/contrib/civictheme/README.md +++ b/docroot/themes/contrib/civictheme/README.md @@ -1,8 +1,10 @@ # CivicTheme Drupal theme ----- +Drupal 9+ component-based theme. + +[![CircleCI](https://dl.circleci.com/status-badge/img/gh/salsadigitalauorg/civictheme/tree/master.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/salsadigitalauorg/civictheme/tree/master) -Version: `{{ VERSION }}` +---- ## Introduction diff --git a/docroot/themes/contrib/civictheme/civictheme.info.yml b/docroot/themes/contrib/civictheme/civictheme.info.yml index 7ed56e455..1d1b74c1e 100644 --- a/docroot/themes/contrib/civictheme/civictheme.info.yml +++ b/docroot/themes/contrib/civictheme/civictheme.info.yml @@ -89,10 +89,11 @@ components: ckeditor_stylesheets: - dist/civictheme.editor.css - #;< DEVELOPMENT # Configuration shipped with this theme. # Update the list of the configuration below and run `drush cde civictheme`. +# Do not add an empty line before this comment block or the downstream code +# linting will fail on extra blank line. config_devel: install: - block.block.civictheme_content diff --git a/docroot/themes/contrib/civictheme/composer.json b/docroot/themes/contrib/civictheme/composer.json index 4dc0f3e93..4ca987396 100644 --- a/docroot/themes/contrib/civictheme/composer.json +++ b/docroot/themes/contrib/civictheme/composer.json @@ -1,5 +1,5 @@ { - "name": "salsadigitalauorg/civictheme", + "name": "drupal/civictheme", "description": "CivicTheme is a Drupal 9 component-based theme.", "type": "drupal-theme", "license": "GPL-2.0-or-later", @@ -10,8 +10,12 @@ }, "require": { "php": ">=8", - "drupal/components": "^2", + "drupal/ckeditor": "^1", + "drupal/components": "^2 || ^3@beta", "drupal/field_group": "^3.2", + "drupal/jquery_ui": "^1.6", + "drupal/jquery_ui_autocomplete": "^2", + "drupal/jquery_ui_menu": "^2", "drupal/layout_builder_restrictions": "^2.13", "drupal/linkit": "^6@beta", "drupal/menu_block": "^1.8", diff --git a/docroot/themes/contrib/civictheme/tests/src/Unit/CivicthemeUnitTestBase.php b/docroot/themes/contrib/civictheme/tests/src/Unit/CivicthemeUnitTestBase.php index a9e12c5bf..85dbb2088 100644 --- a/docroot/themes/contrib/civictheme/tests/src/Unit/CivicthemeUnitTestBase.php +++ b/docroot/themes/contrib/civictheme/tests/src/Unit/CivicthemeUnitTestBase.php @@ -19,7 +19,8 @@ abstract class CivicthemeUnitTestBase extends UnitTestCase { */ protected function setUp(): void { parent::setUp(); - require_once 'docroot/themes/contrib/civictheme/civictheme.theme'; + + require_once __DIR__ . '/../../../civictheme.theme'; } }