From 69f0905e45429023bc3ce59b70f25486118c5540 Mon Sep 17 00:00:00 2001 From: Jeffery Antoniuk Date: Thu, 8 Aug 2024 15:08:19 -0600 Subject: [PATCH] Update to LEAF 3.0.10 & enhance update process #6 --- README.md | 105 ++++++++++-------- docker-bake.hcl | 2 +- docker/drupal/Dockerfile-composer-helper | 9 +- .../rootfs/var/www/drupal/composer.json | 17 ++- .../rootfs/var/www/drupal/composer.lock | 66 ++++++++++- .../www/drupal/config/sync/core.extension.yml | 1 + .../scripts/merge_cwrc_customizations.sh | 18 +++ 7 files changed, 155 insertions(+), 63 deletions(-) create mode 100644 docker/drupal/scripts/merge_cwrc_customizations.sh diff --git a/README.md b/README.md index 1bb1949..06e4d9b 100644 --- a/README.md +++ b/README.md @@ -44,72 +44,67 @@ The CWRC Repository customizations include Drupal modules and configurations tha ## Update +* update repository versions + * Update `docker-bake.hcl` variable `LEAF_VERSION` with the container tag from * Check if local files have changed in since that last local update + * check `docker/drupal/rootfs` (the known files as of August 2024 are included in the following bullet points) * `core.extension.yml` merge changes * example using `sdiff` in interactive mode with `l` and `r` signifying how to manually merge the local CWRC customizations with the leaf-base changes + * ToDo: investigate using `yq` to automatically update the yaml like the json later in this process * If not done then expect Drupal errors regarding missing modules -``` bash -$ sdiff -s -o /tmp/z ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml - config_translation: 0 < -%l - > getjwtonlogin: 0 -%r - > islandora_bagger_integration: 0 -%r - locale: 0 < -%l - message: 0 < - message_notify: 0 < -%l - page_manager: 0 < - page_manager_ui: 0 < -%l - private_message: 0 < - private_message_notify: 0 < -%l - user_csv_import: 0 < -%l - -$ diff /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml -$ mv /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml -``` + ``` bash + $ sdiff -s -o /tmp/z ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml + config_translation: 0 < + %l + > getjwtonlogin: 0 + %r + > islandora_bagger_integration: 0 + %r + locale: 0 < + %l + message: 0 < + message_notify: 0 < + %l + page_manager: 0 < + page_manager_ui: 0 < + %l + private_message: 0 < + private_message_notify: 0 < + %l + user_csv_import: 0 < + %l + + $ diff /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml + $ mv /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml + ``` * `composer.json` & `composer.lock` * copy from leaf-base - * `cp ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/composer.json docker/drupal/rootfs/var/www/drupal/` - * `cp ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/composer.lock docker/drupal/rootfs/var/www/drupal/` - * add back CWRC customizations - * add Git repository manually in the `repositories` section of composer.json - * the CLI function has drawbacks: - * `composer config -d docker/drupal/rootfs/var/www/drupal/ repositories.0 '{"type": "git","url": "https://github.com/cwrc/islandora_bagger_integration.git","no-api": true}'` - - ``` json - { - "type": "git", - "url": "https://github.com/cwrc/islandora_bagger_integration.git", - "no-api": true - }, - ``` - * execute the helper to build the updated `composer.json` and `composer.lock` files + ``` bash + cp ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/composer.json docker/drupal/rootfs/var/www/drupal/ + cp ../leaf-base-i8/docker/drupal/rootfs/var/www/drupal/composer.lock docker/drupal/rootfs/var/www/drupal/ + ``` + + * add back CWRC customizations + * The next step automatically adds the following via `jq` command + * updates composer.json + * updates composer.lock + * execute the helper to build the updated `composer.json` and `composer.lock` files ``` bash docker buildx bake drupal-composer-helper --set "drupal.tags=ghcr.io/cwrc/drupal:local" id=$(docker create "ghcr.io/cwrc/drupal:local") - docker cp $id:/var/www/drupal/composer.json /tmp/composer.json - docker cp $id:/var/www/drupal/composer.lock /tmp/composer.lock + docker cp $id:/var/www/drupal/composer.json docker/drupal/rootfs/var/www/drupal/ + docker cp $id:/var/www/drupal/composer.lock /docker/drupal/rootfs/var/www/drupal/ docker rm -v $id ``` * review changes - * update repository versions - ``` bash - cp /tmp/composer.lock docker/drupal/rootfs/var/www/drupal/ - cp /tmp/composer.json docker/drupal/rootfs/var/www/drupal/ - ``` +### Notes * tried using sdiff on the composer.json/lock file but * `composer.lock` doesn't like manual editing - `content-hash` is outdated @@ -120,7 +115,21 @@ $ mv /tmp/z docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml $ mv /tmp/z docker/drupal/rootfs/var/www/drupal/composer.json ``` +* tried using the composer tools to update `composer.json` and add CWRC custom Git repository in the `repositories` section of composer.json + * the `composer` CLI function has drawbacks: + * `composer config -d docker/drupal/rootfs/var/www/drupal/ repositories.0 '{"type": "git","url": "https://github.com/cwrc/islandora_bagger_integration.git","no-api": true}'` + * the following needs to be added to the `composer.json` + + ``` json + { + "type": "git", + "url": "https://github.com/cwrc/islandora_bagger_integration.git", + "no-api": true + }, + ``` + + ## Building a local image -* `docker buildx bake --set "drupal.tags=ghcr.io/cwrc/drupal:local"` \ No newline at end of file +* `docker buildx bake --set "drupal.tags=ghcr.io/cwrc/drupal:local"` diff --git a/docker-bake.hcl b/docker-bake.hcl index 9816b7d..c7df762 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -9,7 +9,7 @@ variable "REPOSITORY" { # Not the one displayed on DockerHub. # Variable names with '_TAG' and '_REPOSITORY' fail with docker/bake-action variable "LEAF_VERSION" { - default = "3.0.8" + default = "3.0.10" } variable "LEAF_REGISTRY" { default = "registry.gitlab.com/calincs/cwrc/leaf/leaf-base-i8" diff --git a/docker/drupal/Dockerfile-composer-helper b/docker/drupal/Dockerfile-composer-helper index c3e04b6..be7a5e6 100644 --- a/docker/drupal/Dockerfile-composer-helper +++ b/docker/drupal/Dockerfile-composer-helper @@ -5,18 +5,13 @@ ARG TARGETARCH # Copy local customizations COPY --link rootfs / +COPY --link scripts /scripts/ # Add CWRC customizations to # * composer.json # * composer.lock RUN --mount=type=cache,id=custom-drupal-composer-${TARGETARCH},sharing=locked,target=/root/.composer/cache \ + bash /scripts/merge_cwrc_customizations.sh && \ composer require -d /var/www/drupal 'drupal/getjwtonlogin:^2.0' 'mjordan/islandora_bagger_integration' && \ - #composer update -d /var/www/drupal 'drupal/getjwtonlogin:^2.0' 'mjordan/islandora_bagger_integration' && \ composer install -d /var/www/drupal && \ cleanup.sh - -#RUN \ -# cd /var/www/drupal && \ -# grep getjwt * && \ -# grep bag * \ -# grep a diff --git a/docker/drupal/rootfs/var/www/drupal/composer.json b/docker/drupal/rootfs/var/www/drupal/composer.json index 61369f4..001e6e0 100644 --- a/docker/drupal/rootfs/var/www/drupal/composer.json +++ b/docker/drupal/rootfs/var/www/drupal/composer.json @@ -31,11 +31,6 @@ "url": "https://github.com/mjordan/islandora_workbench_integration.git", "no-api": true }, - { - "type": "git", - "url": "https://github.com/cwrc/islandora_bagger_integration.git", - "no-api": true - }, { "type": "package", "package": { @@ -123,6 +118,11 @@ } } ] + }, + { + "type": "git", + "url": "https://github.com/cwrc/islandora_bagger_integration.git", + "no-api": true } ], "authors": [ @@ -148,6 +148,7 @@ "drupal/citation_select": "^1.0@beta", "drupal/ckeditor": "^1.0", "drupal/color": "^1.0", + "drupal/color_field": "^3.0", "drupal/colorbox": "^2.0", "drupal/condition_query": "^1.3", "drupal/conditional_fields": "4.0.0-alpha5", @@ -391,7 +392,8 @@ }, "drupal/core": { "Parent menu exist check D10.2": "patches/core/parent_menu_exist.patch", - "PO file import error": "https://www.drupal.org/files/issues/2021-12-19/2449895_92.patch" + "PO file import error": "https://www.drupal.org/files/issues/2021-12-19/2449895_92.patch", + "Default value of selected options not working": "https://www.drupal.org/files/issues/2023-11-02/5220.patch" }, "drupal/quickedit": { "Uncaught TypeError: _.where & _.pluck is not a function": "https://www.drupal.org/files/issues/2023-12-27/type-error-where-pluck-not-a-function-3410956-3.patch" @@ -411,6 +413,9 @@ }, "drupal/filefield_paths": { "return value fix": "patches/getFromSupportedWidget.patch" + }, + "drupal/layout_builder_perms": { + "Fix not valid context for entity context when editing the default layout entity types": "https://www.drupal.org/files/issues/2023-12-15/not_valid_context-3392780-reroll_patch_from_4-7_0.patch" } }, "drupal-core-project-message": { diff --git a/docker/drupal/rootfs/var/www/drupal/composer.lock b/docker/drupal/rootfs/var/www/drupal/composer.lock index e11dc90..e6e0e82 100644 --- a/docker/drupal/rootfs/var/www/drupal/composer.lock +++ b/docker/drupal/rootfs/var/www/drupal/composer.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": "469b7a52801c1224e3737f68b4551504", + "content-hash": "82c44a57ac7f44ef1c92a34dd4ce83c3", "packages": [ { "name": "academicpuma/citeproc-php", @@ -2531,6 +2531,70 @@ "source": "https://git.drupalcode.org/project/color" } }, + { + "name": "drupal/color_field", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/color_field.git", + "reference": "3.0.1" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/color_field-3.0.1.zip", + "reference": "3.0.1", + "shasum": "fd2f75db74063f817d81a537221fa1c8398e4d8f" + }, + "require": { + "drupal/core": "^9 || ^10 || ^11" + }, + "require-dev": { + "drupal/core-recommended": "^9 || ^10", + "drupal/feeds": "^3.0@beta", + "drupal/token": "~1.3" + }, + "suggest": { + "bower-asset/jquery-simple-color": "^v1.2.2: Provides JavaScript library necessary for the Color Grid widget", + "bower-asset/spectrum": "^1.8: Provides JavaScript library necessary for Spectrum widget." + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "3.0.1", + "datestamp": "1717506868", + "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": "targoo", + "homepage": "https://www.drupal.org/user/431910", + "role": "Maintainer" + }, + { + "name": "Nick Wilde", + "homepage": "https://www.drupal.org/user/nickwilde", + "role": "Maintainer" + }, + { + "name": "targoo", + "homepage": "https://www.drupal.org/user/431910" + } + ], + "description": "Provides a color field type to store the color value and opacity", + "homepage": "https://www.drupal.org/project/color_field", + "support": { + "source": "https://git.drupalcode.org/project/color_field", + "issues": "https://www.drupal.org/project/issues/color_field?version=8.x" + } + }, { "name": "drupal/colorbox", "version": "2.0.2", diff --git a/docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml b/docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml index 41044f9..22f4b53 100644 --- a/docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml +++ b/docker/drupal/rootfs/var/www/drupal/config/sync/core.extension.yml @@ -22,6 +22,7 @@ module: citation_select: 0 ckeditor: 0 color: 0 + color_field: 0 colorbox: 0 comment: 0 conditional_fields: 0 diff --git a/docker/drupal/scripts/merge_cwrc_customizations.sh b/docker/drupal/scripts/merge_cwrc_customizations.sh new file mode 100644 index 0000000..78f799e --- /dev/null +++ b/docker/drupal/scripts/merge_cwrc_customizations.sh @@ -0,0 +1,18 @@ + +merge_composer_json() { + composer_json_path="/var/www/drupal/composer.json" + # append to .repositories[] the CWRC customization: islandora bagger to the list of repositories if it doesn't already exist + # could try an `jq` with `| has(.url)` and if/else to shorten this code + # jq 'if (.repositories[] | select(.url=="https://github.com/cwrc/islandora_bagger_integration.git") | has(.url)) then ${new_repo} else . end' + ret=$(jq -e '.repositories[] | select(.url=="https://github.com/cwrc/islandora_bagger_integration.git")' ${composer_json_path} >> /dev/null) + if [ $? == 0 ] ; then + echo "URL Found"; + else + echo "URL Not Found"; + jq '.repositories += [{"type": "git", "url": "https://github.com/cwrc/islandora_bagger_integration.git", "no-api": true}]' ${composer_json_path} > ${composer_json_path}.new && \ + mv ${composer_json_path} ${composer_json_path}.bak && \ + mv ${composer_json_path}.new ${composer_json_path} + fi +} + +merge_composer_json \ No newline at end of file