From 930b06de05dd0ad11b9aa6a7677597b0037f0451 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 8 May 2024 22:20:57 +1000 Subject: [PATCH 01/24] Updated to Drupal 11 alpha. (#638) * Updated to Drupal 11. * Updated CI to support Drupal 11. --- .github/workflows/ci.yml | 15 +++++---------- composer.json | 6 +++--- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6bf0c73b8..87d94ef1a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,15 +13,15 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['8.1'] - drupal-release: ['stable'] + php-versions: ['8.3'] + drupal-release: ['alpha'] composer-channel: ['stable'] include: - - php-versions: '8.1' + - php-versions: '8.3' drupal-release: dev composer-channel: stable - - php-versions: '8.1' - drupal-release: stable + - php-versions: '8.3' + drupal-release: alpha composer-channel: snapshot steps: - name: Dump matrix context @@ -62,11 +62,6 @@ jobs: - run: until curl -s $SIMPLETEST_BASE_URL; do true; done > /dev/null - # https://www.drupal.org/project/drupal/issues/3182653 - # https://www.drupal.org/node/3176567 - - if: ${{ matrix.php-versions == '8.1' }} - run: composer require phpspec/prophecy-phpunit:^2 - - name: Run a single unit test to verify the testing setup. run: ./vendor/bin/phpunit -c ./web/core ./web/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php diff --git a/composer.json b/composer.json index d1f2250cd3..aa1d636089 100644 --- a/composer.json +++ b/composer.json @@ -19,14 +19,14 @@ "php": ">=8.1", "composer/installers": "^2.1", "cweagans/composer-patches": "^1.7", - "drupal/core-composer-scaffold": "^10.2.0", - "drupal/core-recommended": "^10.2.0", + "drupal/core-composer-scaffold": "^11@alpha", + "drupal/core-recommended": "^11@alpha", "drush/drush": "^12.4.3", "vlucas/phpdotenv": "^5.1", "webflo/drupal-finder": "^1.2" }, "require-dev": { - "drupal/core-dev": "^10.2.0" + "drupal/core-dev": "^11@alpha" }, "conflict": { "drupal/drupal": "*" From c549b83b03c721b725e1bc1eb6aa54a041d1b1b6 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 8 May 2024 22:49:06 +1000 Subject: [PATCH 02/24] Updated Drush to 13@beta and PHP version. (#641) --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index aa1d636089..109dc8a703 100644 --- a/composer.json +++ b/composer.json @@ -16,12 +16,12 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.3", "composer/installers": "^2.1", "cweagans/composer-patches": "^1.7", "drupal/core-composer-scaffold": "^11@alpha", "drupal/core-recommended": "^11@alpha", - "drush/drush": "^12.4.3", + "drush/drush": "^13@beta", "vlucas/phpdotenv": "^5.1", "webflo/drupal-finder": "^1.2" }, From 36386bda2dca4df6aeaf2afa813ed32c392444fb Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 8 May 2024 22:49:39 +1000 Subject: [PATCH 03/24] Enabled CI runs for forks. (#640) (#642) --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87d94ef1a4..84710abc53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,9 @@ name: CI -on: [push] +on: + push: + pull_request: + types: [opened, synchronize, reopened] env: COMPOSER_MEMORY_LIMIT: -1 From db49fc49e6093b6b4c4413643eafce14bf2a4788 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 8 May 2024 22:57:49 +1000 Subject: [PATCH 04/24] Fixed SQLite version in CI. --- .github/workflows/ci.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84710abc53..acc01a2781 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ env: jobs: build: - runs-on: 'ubuntu-20.04' + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -35,11 +35,20 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Upgrade sqlite3 + run: | + wget https://www.sqlite.org/2024/sqlite-autoconf-3450300.tar.gz -O /tmp/sqlite.tar.gz + tar -xzf /tmp/sqlite.tar.gz -C /tmp + cd /tmp/sqlite-autoconf-3450300 + ./configure CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1" --prefix=/usr/local + make && sudo make install + sudo ldconfig + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - extensions: gd, pdo_sqlite + extensions: gd, sqlite, pdo_sqlite - name: Update composer run: composer --verbose self-update --${{ matrix.composer-channel }} @@ -54,7 +63,7 @@ jobs: run: composer --verbose install - if: matrix.drupal-release == 'dev' - run: composer --verbose require --no-update drupal/core-recommended:10.0.x-dev && composer --verbose require --no-update --dev drupal/core-dev:10.0.x-dev + run: composer --verbose require --no-update drupal/core-recommended:11.0.x-dev && composer --verbose require --no-update --dev drupal/core-dev:11.0.x-dev - if: matrix.drupal-release == 'dev' run: composer --verbose update @@ -66,6 +75,6 @@ jobs: - run: until curl -s $SIMPLETEST_BASE_URL; do true; done > /dev/null - name: Run a single unit test to verify the testing setup. - run: ./vendor/bin/phpunit -c ./web/core ./web/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php + run: ./vendor/bin/phpunit -c ./web/core $(pwd)/web/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php - run: ./vendor/bin/drush From 55f4e5402b72e575c6646e2fe84080fefbf4b1ef Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Fri, 10 May 2024 20:09:58 +1000 Subject: [PATCH 05/24] Updated text references to use `11.x`. (#645) --- README.md | 8 ++++---- composer.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d87dba20b1..73c3e49389 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Composer template for Drupal projects -[![CI](https://github.com/drupal-composer/drupal-project/actions/workflows/ci.yml/badge.svg?branch=10.x)](https://github.com/drupal-composer/drupal-project/actions/workflows/ci.yml) +[![CI](https://github.com/drupal-composer/drupal-project/actions/workflows/ci.yml/badge.svg?branch=11.x)](https://github.com/drupal-composer/drupal-project/actions/workflows/ci.yml) This project template provides a starter kit for managing your site dependencies with [Composer](https://getcomposer.org/). @@ -16,7 +16,7 @@ for your setup. After that you can create the project: ``` -composer create-project drupal-composer/drupal-project:10.x-dev some-dir --no-interaction +composer create-project drupal-composer/drupal-project:11.x-dev some-dir --no-interaction ``` With `composer require ...` you can download new dependencies to your @@ -123,7 +123,7 @@ section of composer.json: ### How do I specify a PHP version? -This project supports PHP 8.1 as minimum version (see [Environment requirements of Drupal 10](https://www.drupal.org/docs/system-requirements/php-requirements)), however it's possible that a `composer update` will upgrade some package that will then require PHP 8.1+. +This project supports PHP 8.3 as minimum version (see [PHP requirements](https://www.drupal.org/docs/system-requirements/php-requirements)), however it's possible that a `composer update` will upgrade some package that will then require PHP 8.3+. To prevent this you can add this code to specify the PHP version you want to use in the `config` section of `composer.json`: @@ -131,7 +131,7 @@ To prevent this you can add this code to specify the PHP version you want to use "config": { "sort-packages": true, "platform": { - "php": "8.1.13" + "php": "8.3.1" } }, ``` diff --git a/composer.json b/composer.json index 109dc8a703..24656a9d62 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "drupal-composer/drupal-project", - "description": "Project template for Drupal 10 projects with Composer", + "description": "Project template for Drupal 11 projects with Composer", "type": "project", "license": "GPL-2.0-or-later", "authors": [ From 2a222fef086f882413c3ec8700b637fecd17374c Mon Sep 17 00:00:00 2001 From: SkywardRay <37404777+SkywardRay@users.noreply.github.com> Date: Wed, 15 Jan 2020 15:50:58 +0100 Subject: [PATCH 06/24] Update ScriptHandler.php to check for symlinks before creating files directory When using drupal inside a docker container it can be useful to make the sites/default/files directory a symlink instead. For example here in the wodby documentation https://wodby.com/docs/stacks/drupal/#files_1 I propose adding a check to is_link to prevent errors caused by $fs->exists not handling symlinks. --- scripts/composer/ScriptHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 1531a8793b..27efd7c695 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -53,7 +53,7 @@ public static function createRequiredFiles(Event $event) { } // Create the files directory with chmod 0777 - if (!$fs->exists($drupalRoot . '/sites/default/files')) { + if (!$fs->exists($drupalRoot . '/sites/default/files') && !is_link($drupalRoot . '/sites/default/files')) { $oldmask = umask(0); $fs->mkdir($drupalRoot . '/sites/default/files', 0777); umask($oldmask); From 7fab10d680fd373ef345aacee4d6709bb56f978d Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 13 May 2024 20:21:01 +1000 Subject: [PATCH 07/24] [#462] Removed PHP version from `composer.json`. --- README.md | 27 ++++++++++++++++++++++++--- composer.json | 1 - 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 73c3e49389..afe7b1b363 100644 --- a/README.md +++ b/README.md @@ -123,13 +123,34 @@ section of composer.json: ### How do I specify a PHP version? -This project supports PHP 8.3 as minimum version (see [PHP requirements](https://www.drupal.org/docs/system-requirements/php-requirements)), however it's possible that a `composer update` will upgrade some package that will then require PHP 8.3+. +There are 2 places where Composer will be looking for PHP version requirements +when resolving dependencies: +1. The `require.php` version value in `composer.json`. +2. The `config.platform` version value in `composer.json`. -To prevent this you can add this code to specify the PHP version you want to use in the `config` section of `composer.json`: +The purpose of `require.php` is to set the minimum PHP language requirements +for a package. For example, the minimum version required for Drupal 11.0 is +`8.3` or above, which can be specified as `>=8.3`. + +The purpose of `config.platform` is to set the PHP language requirements for the +specific instance of the package running in the current environment. For +example, while the minimum version required for Drupal 11 is `8.3` or above, +the actual PHP version on the hosting provider could be `8.3.1`. The value of +this field should provide your exact version of PHP with all 3 parts of the +version. + +#### Which versions to specify in my Drupal site? + +This project includes `drupal/core` which already has `require.php` added. Your +would inherit that constraint. There is no need to add `require.php` to your +`composer.json`. + +`config.platform` is a platform-specific. It is recommended to specify +`config.platform` as a _specific version_ (e.g.`8.3.1`) constraint to ensure +that only the package versions supported by your current environment are used. ```json "config": { - "sort-packages": true, "platform": { "php": "8.3.1" } diff --git a/composer.json b/composer.json index 24656a9d62..29b7066e63 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,6 @@ } ], "require": { - "php": ">=8.3", "composer/installers": "^2.1", "cweagans/composer-patches": "^1.7", "drupal/core-composer-scaffold": "^11@alpha", From b67fbaf787b481a49f82c7135fc2bb749c53755b Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Tue, 14 May 2024 18:52:35 +1000 Subject: [PATCH 08/24] [#647] Added Composer normalizer. --- composer.json | 97 +++++++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/composer.json b/composer.json index 29b7066e63..da619746c6 100644 --- a/composer.json +++ b/composer.json @@ -1,20 +1,14 @@ { "name": "drupal-composer/drupal-project", "description": "Project template for Drupal 11 projects with Composer", - "type": "project", "license": "GPL-2.0-or-later", + "type": "project", "authors": [ { "name": "", "role": "" } ], - "repositories": [ - { - "type": "composer", - "url": "https://packages.drupal.org/8" - } - ], "require": { "composer/installers": "^2.1", "cweagans/composer-patches": "^1.7", @@ -25,64 +19,85 @@ "webflo/drupal-finder": "^1.2" }, "require-dev": { - "drupal/core-dev": "^11@alpha" + "drupal/core-dev": "^11@alpha", + "ergebnis/composer-normalize": "^2.42" }, "conflict": { "drupal/drupal": "*" }, + "repositories": [ + { + "type": "composer", + "url": "https://packages.drupal.org/8" + } + ], "minimum-stability": "dev", "prefer-stable": true, + "autoload": { + "classmap": [ + "scripts/composer/ScriptHandler.php" + ], + "files": [ + "load.environment.php" + ] + }, "config": { - "discard-changes": true, - "sort-packages": true, "allow-plugins": { "composer/installers": true, "cweagans/composer-patches": true, - "drupal/core-composer-scaffold": true, "dealerdirect/phpcodesniffer-composer-installer": true, + "drupal/core-composer-scaffold": true, + "ergebnis/composer-normalize": true, "php-http/discovery": true, "phpstan/extension-installer": true - } - }, - "autoload": { - "classmap": [ - "scripts/composer/ScriptHandler.php" - ], - "files": ["load.environment.php"] - }, - "scripts": { - "pre-install-cmd": [ - "DrupalProject\\composer\\ScriptHandler::checkComposerVersion" - ], - "pre-update-cmd": [ - "DrupalProject\\composer\\ScriptHandler::checkComposerVersion" - ], - "post-install-cmd": [ - "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" - ], - "post-update-cmd": [ - "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" - ] + }, + "discard-changes": true, + "sort-packages": true }, "extra": { + "composer-exit-on-patch-failure": true, "drupal-scaffold": { "locations": { "web-root": "web/" } }, "installer-paths": { - "web/core": ["type:drupal-core"], - "web/libraries/{$name}": ["type:drupal-library"], - "web/modules/contrib/{$name}": ["type:drupal-module"], - "web/profiles/contrib/{$name}": ["type:drupal-profile"], - "web/themes/contrib/{$name}": ["type:drupal-theme"], - "drush/Commands/contrib/{$name}": ["type:drupal-drush"] + "web/core": [ + "type:drupal-core" + ], + "web/libraries/{$name}": [ + "type:drupal-library" + ], + "web/modules/contrib/{$name}": [ + "type:drupal-module" + ], + "web/profiles/contrib/{$name}": [ + "type:drupal-profile" + ], + "web/themes/contrib/{$name}": [ + "type:drupal-theme" + ], + "drush/Commands/contrib/{$name}": [ + "type:drupal-drush" + ] }, - "composer-exit-on-patch-failure": true, "patchLevel": { "drupal/core": "-p2" }, - "patches": { - } + "patches": {} + }, + "scripts": { + "pre-install-cmd": [ + "DrupalProject\\composer\\ScriptHandler::checkComposerVersion" + ], + "post-install-cmd": [ + "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" + ], + "pre-update-cmd": [ + "DrupalProject\\composer\\ScriptHandler::checkComposerVersion" + ], + "post-update-cmd": [ + "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" + ] } } From 11bf746fb15ab445f21dc351c90dd0f4b73d18ff Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Tue, 14 May 2024 19:39:22 +1000 Subject: [PATCH 09/24] Re-formatted CI and added more PHP versions to the test matrix. --- .github/workflows/ci.yml | 47 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acc01a2781..ee0a56c9d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,10 @@ name: CI on: push: pull_request: - types: [opened, synchronize, reopened] + types: + - opened + - synchronize + - reopened env: COMPOSER_MEMORY_LIMIT: -1 @@ -15,17 +18,12 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false + matrix: php-versions: ['8.3'] - drupal-release: ['alpha'] - composer-channel: ['stable'] - include: - - php-versions: '8.3' - drupal-release: dev - composer-channel: stable - - php-versions: '8.3' - drupal-release: alpha - composer-channel: snapshot + drupal-release: ['alpha', 'dev'] + composer-channel: ['stable', 'snapshot'] + steps: - name: Dump matrix context env: @@ -50,10 +48,10 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: gd, sqlite, pdo_sqlite - - name: Update composer + - name: Update Composer run: composer --verbose self-update --${{ matrix.composer-channel }} - - name: Dump composer version + - name: Show Composer version run: composer --version - name: Validate composer.json @@ -62,19 +60,20 @@ jobs: - name: Install dependencies run: composer --verbose install - - if: matrix.drupal-release == 'dev' - run: composer --verbose require --no-update drupal/core-recommended:11.0.x-dev && composer --verbose require --no-update --dev drupal/core-dev:11.0.x-dev - - - if: matrix.drupal-release == 'dev' - run: composer --verbose update - - - run: ./vendor/bin/drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite + - name: Override Drupal version to dev for testing dev releases + if: matrix.drupal-release == 'dev' + run: | + composer --verbose require --no-update drupal/core-recommended:11.0.x-dev + composer --verbose require --no-update --dev drupal/core-dev:11.0.x-dev + composer --verbose update - - run: ./vendor/bin/drush runserver $SIMPLETEST_BASE_URL & + - name: Install site + run: ./vendor/bin/drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite - - run: until curl -s $SIMPLETEST_BASE_URL; do true; done > /dev/null + - name: Start server + run: | + ./vendor/bin/drush runserver "$SIMPLETEST_BASE_URL" & + until curl -s "$SIMPLETEST_BASE_URL"; do true; done > /dev/null - - name: Run a single unit test to verify the testing setup. + - name: Run a single unit test to verify the testing setup run: ./vendor/bin/phpunit -c ./web/core $(pwd)/web/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php - - - run: ./vendor/bin/drush From 62702c23af3c18c9c671d2c3a41b673bb69aa7d7 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Tue, 14 May 2024 21:13:51 +1000 Subject: [PATCH 10/24] [11.x] Updated readme. --- README.md | 96 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index afe7b1b363..adf9680264 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,95 @@ # Composer template for Drupal projects [![CI](https://github.com/drupal-composer/drupal-project/actions/workflows/ci.yml/badge.svg?branch=11.x)](https://github.com/drupal-composer/drupal-project/actions/workflows/ci.yml) +![LICENSE](https://img.shields.io/github/license/drupal-composer/drupal-project) This project template provides a starter kit for managing your site dependencies with [Composer](https://getcomposer.org/). -## Usage +## What does the template do? -First you need to [install Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx). +* Drupal will be installed in the `web` directory. +* Generated composer autoloader `vendor/autoload.php` is used instead of + `web/vendor/autoload.php` provided by Drupal core. +* Modules (packages of type `drupal-module`) will be placed in `web/modules/contrib` directory. +* Themes (packages of type `drupal-theme`) will be placed in `web/themes/contrib` directory. +* Profiles (packages of type `drupal-profile`) will be placed in `web/profiles/contrib` directory. +* Creates default writable versions of `settings.php` and `services.yml`. +* Creates `web/sites/default/files` directory. +* Drush is installed for use as `vendor/bin/drush`. +* Provides an [example](.env.example) of the `.env` file. -> Note: The instructions below refer to the [global Composer installation](https://getcomposer.org/doc/00-intro.md#globally). +## Installing + +> [!NOTE] +> The instructions below refer to the [global Composer installation](https://getcomposer.org/doc/00-intro.md#globally). You might need to replace `composer` with `php composer.phar` (or similar) for your setup. -After that you can create the project: +Create your project: -``` +```bash composer create-project drupal-composer/drupal-project:11.x-dev some-dir --no-interaction ``` -With `composer require ...` you can download new dependencies to your -installation. - -``` -cd some-dir -composer require drupal/devel -``` - The `composer create-project` command passes ownership of all files to the project that is created. You should create a new Git repository, and commit all files not excluded by the `.gitignore` file. -## What does the template do? +## Usage -When installing the given `composer.json` some tasks are taken care of: +### Adding new dependencies -* Drupal will be installed in the `web`-directory. -* Autoloader is implemented to use the generated composer autoloader in `vendor/autoload.php`, - instead of the one provided by Drupal (`web/vendor/autoload.php`). -* Modules (packages of type `drupal-module`) will be placed in `web/modules/contrib/` -* Theme (packages of type `drupal-theme`) will be placed in `web/themes/contrib/` -* Profiles (packages of type `drupal-profile`) will be placed in `web/profiles/contrib/` -* Creates default writable versions of `settings.php` and `services.yml`. -* Creates `web/sites/default/files`-directory. -* Latest version of drush is installed locally for use at `vendor/bin/drush`. -* Latest version of DrupalConsole is installed locally for use at `vendor/bin/drupal`. -* Creates environment variables based on your .env file. See [.env.example](.env.example). +Use `composer require` to include and download dependencies for your project. -## Updating Drupal Core +```bash +cd some-dir +composer require drupal/devel +``` + +### Updating Drupal Core This project will attempt to keep all of your Drupal Core files up-to-date; the project [drupal/core-composer-scaffold](https://github.com/drupal/core-composer-scaffold) -is used to ensure that your scaffold files are updated every time drupal/core is -updated. If you customize any of the "scaffolding" files (commonly `.htaccess`), +is used to ensure that your scaffold files are updated every time `drupal/core` +is updated. + +If you customize any of the "scaffolding" files (commonly `.htaccess`), you may need to merge conflicts if any of your modified files are updated in a new release of Drupal core. -Follow the steps below to update your core files. +Follow the steps below to update your Drupal core files. 1. Run `composer update "drupal/core-*" --with-dependencies` to update Drupal Core and its dependencies. 2. Run `git diff` to determine if any of the scaffolding files have changed. Review the files for any changes and restore any customizations to `.htaccess` or `robots.txt`. -1. Commit everything all together in a single commit, so `web` will remain in +3. Commit everything all together in a single commit, so `web` will remain in sync with the `core` when checking out branches or running `git bisect`. -1. In the event that there are non-trivial conflicts in step 2, you may wish +4. In the event that there are non-trivial conflicts in step 2, you may wish to perform these steps on a branch, and use `git merge` to combine the updated core files with your customized files. This facilitates the use of a [three-way merge tool such as kdiff3](http://www.gitshah.com/2010/12/how-to-setup-kdiff-as-diff-tool-for-git.html). This setup is not necessary if your changes are simple; keeping all of your modifications at the beginning or end of the file is a good strategy to keep merges easy. -## FAQ +## FAQs ### Should I commit the contrib modules I download? Composer recommends **no**. They provide [argumentation against but also -workrounds if a project decides to do it anyway](https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md). +workarounds if a project decides to do it anyway](https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md). ### Should I commit the scaffolding files? The [Drupal Composer Scaffold](https://github.com/drupal/core-composer-scaffold) -plugin can download the scaffold files (like index.php, update.php, …) to the -web/ directory of your project. If you have not customized those files you could -choose to not check them into your version control system (e.g. git). If that is -the case for your project it might be convenient to automatically run the -drupal-scaffold plugin after every install or update of your project. You can -achieve that by registering `@composer drupal:scaffold` as post-install and -post-update command in your composer.json: +plugin can download the scaffold files (like `index.php`, `update.php` etc.) to +the `web` directory of your project. If you have not customized those files you +could choose to not check them into your version control system (e.g. git). +If that is the case for your project, it might be convenient to automatically +run the drupal-scaffold plugin after every install or update of your project. +You can achieve that by registering `@composer drupal:scaffold` as `post-install` +and `post-update` command in your `composer.json`: ```json "scripts": { @@ -102,14 +104,14 @@ post-update command in your composer.json: }, ``` -### How can I apply patches to downloaded modules? +### How can I apply patches to included dependencies? -If you need to apply patches (depending on the project being modified, a pull -request is often a better solution), you can do so with the -[composer-patches](https://github.com/cweagans/composer-patches) plugin. +If you need to apply patches, you can do so with the +[composer-patches](https://github.com/cweagans/composer-patches) plugin included +in this project. -To add a patch to drupal module foobar insert the patches section in the extra -section of composer.json: +To add a patch to Drupal module `foobar`, insert the `patches` section in the +`extra` section of `composer.json`: ```json "extra": { From b13ddf5533f394aa21fa606893d125892ff16694 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 15 May 2024 11:14:08 +1000 Subject: [PATCH 11/24] [#653] Added Composer normalizer check to CI. --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee0a56c9d6..0cb35b47b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,9 @@ jobs: - name: Install dependencies run: composer --verbose install + - name: Validate composer.json structure + run: composer normalize --dry-run + - name: Override Drupal version to dev for testing dev releases if: matrix.drupal-release == 'dev' run: | From 13ac14d474dcf695c2f4272595d33e4182da9ca1 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Fri, 17 May 2024 08:44:36 +1000 Subject: [PATCH 12/24] [#660] Fixed required Composer version constraint and added a CI job. --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ scripts/composer/ScriptHandler.php | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cb35b47b1..dda9faa891 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,3 +80,26 @@ jobs: - name: Run a single unit test to verify the testing setup run: ./vendor/bin/phpunit -c ./web/core $(pwd)/web/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php + + # Using outdated Composer version to test the Composer version constraint. + test-composer: + runs-on: ubuntu-latest + + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + extensions: gd, pdo_sqlite + tools: composer:v2.2 + + - name: Show Composer version + run: composer --version + + - name: Install dependencies + # This command should fail because of the Composer version constraint. + run: composer --verbose install && exit 1 || exit 0 diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 27efd7c695..088c2b6081 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -92,8 +92,8 @@ public static function checkComposerVersion(Event $event) { if ($version === '@package_version@' || $version === '@package_branch_alias_version@') { $io->writeError('You are running a development version of Composer. If you experience problems, please update Composer to the latest stable version.'); } - elseif (Comparator::lessThan($version, '1.0.0')) { - $io->writeError('Drupal-project requires Composer version 1.0.0 or higher. Please update your Composer before continuing.'); + elseif (Comparator::lessThan($version, '2.3.6')) { + $io->writeError('Drupal-project requires Composer version 2.3.6 or higher. Please update your Composer before continuing.'); exit(1); } } From c3959fd1fd4126b165ae162406e148dabaa10e9c Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Fri, 17 May 2024 11:46:00 +1000 Subject: [PATCH 13/24] [#278] Added support for Asset packagist. --- .github/workflows/ci.yml | 6 ++++ README.md | 62 ++++++++++++++++++++++++++++++++-------- composer.json | 14 ++++++++- 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dda9faa891..f020e69e9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,6 +63,12 @@ jobs: - name: Validate composer.json structure run: composer normalize --dry-run + - name: Require bower-asset + run: | + test ! -d web/libraries/dropzone + composer require bower-asset/dropzone + test -d web/libraries/dropzone + - name: Override Drupal version to dev for testing dev releases if: matrix.drupal-release == 'dev' run: | diff --git a/README.md b/README.md index adf9680264..a4ebe8c859 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ dependencies with [Composer](https://getcomposer.org/). ## What does the template do? * Drupal will be installed in the `web` directory. -* Generated composer autoloader `vendor/autoload.php` is used instead of +* Generated composer autoloader `vendor/autoload.php` is used instead of `web/vendor/autoload.php` provided by Drupal core. * Modules (packages of type `drupal-module`) will be placed in `web/modules/contrib` directory. * Themes (packages of type `drupal-theme`) will be placed in `web/themes/contrib` directory. @@ -47,12 +47,50 @@ cd some-dir composer require drupal/devel ``` +### Adding libraries + +You can manage front-end asset libraries with Composer thanks to the +[asset-packagist repository](https://asset-packagist.org/). Composer will detect +and install new versions of a library that meet the stated constraints. + +```bash +composer require bower-asset/dropzone +``` + +### Custom installation paths for libraries + +The installation path of a specific library can be controlled by adding it to +the `extra.installer-paths` configuration preceding `web/libraries/{$name}`. +For example, the `chosen` Drupal module expects the `chosen` library to be +located on `web/libraries/chosen`, but `composer require npm-asset/chosen-js` +installs the library into `web/libraries/chosen-js`. The following configuration +overrides installation it into the expected directory: + +```json +{ + "extra": { + "installer-paths": { + "web/libraries/chosen": [ + "npm-asset/chosen-js" + ], + "web/libraries/{$name}": [ + "type:drupal-library", + "type:npm-asset", + "type:bower-asset" + ] + } + } +} +``` + +For more details, see https://asset-packagist.org/site/about + ### Updating Drupal Core This project will attempt to keep all of your Drupal Core files up-to-date; the project [drupal/core-composer-scaffold](https://github.com/drupal/core-composer-scaffold) -is used to ensure that your scaffold files are updated every time `drupal/core` -is updated. +is used to ensure that your scaffold files are updated every time `drupal/core` +is updated. If you customize any of the "scaffolding" files (commonly `.htaccess`), you may need to merge conflicts if any of your modified files are updated in a @@ -63,7 +101,7 @@ Follow the steps below to update your Drupal core files. 1. Run `composer update "drupal/core-*" --with-dependencies` to update Drupal Core and its dependencies. 2. Run `git diff` to determine if any of the scaffolding files have changed. Review the files for any changes and restore any customizations to - `.htaccess` or `robots.txt`. + `.htaccess` or `robots.txt`. 3. Commit everything all together in a single commit, so `web` will remain in sync with the `core` when checking out branches or running `git bisect`. 4. In the event that there are non-trivial conflicts in step 2, you may wish @@ -83,12 +121,12 @@ workarounds if a project decides to do it anyway](https://getcomposer.org/doc/fa ### Should I commit the scaffolding files? The [Drupal Composer Scaffold](https://github.com/drupal/core-composer-scaffold) -plugin can download the scaffold files (like `index.php`, `update.php` etc.) to -the `web` directory of your project. If you have not customized those files you -could choose to not check them into your version control system (e.g. git). -If that is the case for your project, it might be convenient to automatically -run the drupal-scaffold plugin after every install or update of your project. -You can achieve that by registering `@composer drupal:scaffold` as `post-install` +plugin can download the scaffold files (like `index.php`, `update.php` etc.) to +the `web` directory of your project. If you have not customized those files you +could choose to not check them into your version control system (e.g. git). +If that is the case for your project, it might be convenient to automatically +run the drupal-scaffold plugin after every install or update of your project. +You can achieve that by registering `@composer drupal:scaffold` as `post-install` and `post-update` command in your `composer.json`: ```json @@ -110,7 +148,7 @@ If you need to apply patches, you can do so with the [composer-patches](https://github.com/cweagans/composer-patches) plugin included in this project. -To add a patch to Drupal module `foobar`, insert the `patches` section in the +To add a patch to Drupal module `foobar`, insert the `patches` section in the `extra` section of `composer.json`: ```json @@ -137,7 +175,7 @@ for a package. For example, the minimum version required for Drupal 11.0 is The purpose of `config.platform` is to set the PHP language requirements for the specific instance of the package running in the current environment. For example, while the minimum version required for Drupal 11 is `8.3` or above, -the actual PHP version on the hosting provider could be `8.3.1`. The value of +the actual PHP version on the hosting provider could be `8.3.1`. The value of this field should provide your exact version of PHP with all 3 parts of the version. diff --git a/composer.json b/composer.json index da619746c6..8c1c366b48 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "drupal/core-composer-scaffold": "^11@alpha", "drupal/core-recommended": "^11@alpha", "drush/drush": "^13@beta", + "oomphinc/composer-installers-extender": "^2.0", "vlucas/phpdotenv": "^5.1", "webflo/drupal-finder": "^1.2" }, @@ -29,6 +30,10 @@ { "type": "composer", "url": "https://packages.drupal.org/8" + }, + { + "type": "composer", + "url": "https://asset-packagist.org/" } ], "minimum-stability": "dev", @@ -48,6 +53,7 @@ "dealerdirect/phpcodesniffer-composer-installer": true, "drupal/core-composer-scaffold": true, "ergebnis/composer-normalize": true, + "oomphinc/composer-installers-extender": true, "php-http/discovery": true, "phpstan/extension-installer": true }, @@ -66,7 +72,9 @@ "type:drupal-core" ], "web/libraries/{$name}": [ - "type:drupal-library" + "type:drupal-library", + "type:bower-asset", + "type:npm-asset" ], "web/modules/contrib/{$name}": [ "type:drupal-module" @@ -81,6 +89,10 @@ "type:drupal-drush" ] }, + "installer-types": [ + "bower-asset", + "npm-asset" + ], "patchLevel": { "drupal/core": "-p2" }, From 806a6bf8f9afccdd45947859ad1462d900228424 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Fri, 17 May 2024 17:43:32 +1000 Subject: [PATCH 14/24] [#266] Set `minimum-stability` to `true` and added docs. --- .github/workflows/ci.yml | 3 ++- README.md | 23 +++++++++++++++++++++++ composer.json | 8 ++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f020e69e9f..765a255671 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: matrix: php-versions: ['8.3'] - drupal-release: ['alpha', 'dev'] + drupal-release: ['beta', 'dev'] composer-channel: ['stable', 'snapshot'] steps: @@ -72,6 +72,7 @@ jobs: - name: Override Drupal version to dev for testing dev releases if: matrix.drupal-release == 'dev' run: | + composer config minimum-stability dev composer --verbose require --no-update drupal/core-recommended:11.0.x-dev composer --verbose require --no-update --dev drupal/core-dev:11.0.x-dev composer --verbose update diff --git a/README.md b/README.md index a4ebe8c859..84427395b4 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,29 @@ cd some-dir composer require drupal/devel ``` +By default, this project is set to install only stable releases of dependencies, +as specified by `"minimum-stability": "stable"` in `composer.json`. If you need +to use non-stable releases (e.g., `alpha`, `beta`, `RC`), you can modify the +version constraint to allow for such versions. For instance, to require a beta +version of a module: + +```bash +composer require drupal/devel:1.0.0-beta1 +``` + +Alternatively, you can globally adjust the stability settings by modifying +`composer.json` to include the desired stability level and explicitly allow it: + +```json +{ + "minimum-stability": "beta", + "prefer-stable": true +} +``` + +This configuration ensures that stable releases are preferred, but allows the +installation of non-stable packages when necessary. + ### Adding libraries You can manage front-end asset libraries with Composer thanks to the diff --git a/composer.json b/composer.json index 8c1c366b48..ce0f3d5e90 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,15 @@ "require": { "composer/installers": "^2.1", "cweagans/composer-patches": "^1.7", - "drupal/core-composer-scaffold": "^11@alpha", - "drupal/core-recommended": "^11@alpha", + "drupal/core-composer-scaffold": "^11@beta", + "drupal/core-recommended": "^11@beta", "drush/drush": "^13@beta", "oomphinc/composer-installers-extender": "^2.0", "vlucas/phpdotenv": "^5.1", "webflo/drupal-finder": "^1.2" }, "require-dev": { - "drupal/core-dev": "^11@alpha", + "drupal/core-dev": "^11@beta", "ergebnis/composer-normalize": "^2.42" }, "conflict": { @@ -36,7 +36,7 @@ "url": "https://asset-packagist.org/" } ], - "minimum-stability": "dev", + "minimum-stability": "alpha", "prefer-stable": true, "autoload": { "classmap": [ From cbd8e4215a19c1a2b8c4c033f71d2ad51344c3d3 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 29 May 2024 06:39:14 +1000 Subject: [PATCH 15/24] [#646] Added installer paths for custom modules, profiles and themes. --- composer.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/composer.json b/composer.json index ce0f3d5e90..714c64be1a 100644 --- a/composer.json +++ b/composer.json @@ -87,6 +87,15 @@ ], "drush/Commands/contrib/{$name}": [ "type:drupal-drush" + ], + "web/modules/custom/{$name}": [ + "type:drupal-custom-module" + ], + "web/profiles/custom/{$name}": [ + "type:drupal-custom-profile" + ], + "web/themes/custom/{$name}": [ + "type:drupal-custom-theme" ] }, "installer-types": [ From e1ef058aa9937bbac466c8c9078337710afe2924 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 29 May 2024 20:05:54 +1000 Subject: [PATCH 16/24] Added site information to CI. --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 765a255671..ab3a292853 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,6 +80,9 @@ jobs: - name: Install site run: ./vendor/bin/drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite + - name: Show site information + run: ./vendor/bin/drush status + - name: Start server run: | ./vendor/bin/drush runserver "$SIMPLETEST_BASE_URL" & From a28258f7c0f12d26af710851267f2f3d39509444 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Thu, 30 May 2024 06:28:27 +1000 Subject: [PATCH 17/24] Fixed CI using dev dependencies. --- .github/workflows/ci.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab3a292853..820a9b91ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,11 +70,15 @@ jobs: test -d web/libraries/dropzone - name: Override Drupal version to dev for testing dev releases - if: matrix.drupal-release == 'dev' + if: matrix.drupal-release == 'dev' || matrix.drupal-release == 'beta' run: | - composer config minimum-stability dev - composer --verbose require --no-update drupal/core-recommended:11.0.x-dev - composer --verbose require --no-update --dev drupal/core-dev:11.0.x-dev + composer config minimum-stability ${{ matrix.drupal-release }} + composer config prefer-stable false + composer --verbose require --no-update drupal/core-composer-scaffold:^11@${{ matrix.drupal-release }} + composer --verbose require --no-update drupal/core-recommended:^11@${{ matrix.drupal-release }} + composer --verbose require --no-update --dev drupal/core-dev:^11@${{ matrix.drupal-release }} + # Remove the line below once the package is out of `alpha`. + [[ ${{ matrix.drupal-release }} == 'beta' ]] && composer require chi-teck/drupal-code-generator:^4@alpha composer --verbose update - name: Install site @@ -89,7 +93,7 @@ jobs: until curl -s "$SIMPLETEST_BASE_URL"; do true; done > /dev/null - name: Run a single unit test to verify the testing setup - run: ./vendor/bin/phpunit -c ./web/core $(pwd)/web/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php + run: ./vendor/bin/phpunit -c ./web/core "$(pwd)/web/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php" # Using outdated Composer version to test the Composer version constraint. test-composer: From 483f9fb77e3185769e7ead4da3b64946d9a848e6 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Thu, 30 May 2024 07:12:24 +1000 Subject: [PATCH 18/24] Added `alpha` testing. --- .github/workflows/ci.yml | 2 +- composer.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 820a9b91ca..276caab5c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: matrix: php-versions: ['8.3'] - drupal-release: ['beta', 'dev'] + drupal-release: ['alpha', 'beta', 'dev'] composer-channel: ['stable', 'snapshot'] steps: diff --git a/composer.json b/composer.json index 714c64be1a..208a89ab32 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,15 @@ "require": { "composer/installers": "^2.1", "cweagans/composer-patches": "^1.7", - "drupal/core-composer-scaffold": "^11@beta", - "drupal/core-recommended": "^11@beta", + "drupal/core-composer-scaffold": "^11@alpha", + "drupal/core-recommended": "^11@alpha", "drush/drush": "^13@beta", "oomphinc/composer-installers-extender": "^2.0", "vlucas/phpdotenv": "^5.1", "webflo/drupal-finder": "^1.2" }, "require-dev": { - "drupal/core-dev": "^11@beta", + "drupal/core-dev": "^11@alpha", "ergebnis/composer-normalize": "^2.42" }, "conflict": { From 05b84ac2d4307612d733a62521132750254793b7 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Sat, 8 Jun 2024 04:20:18 +0700 Subject: [PATCH 19/24] Use new Drupal Finder API. (#673) --- composer.json | 2 +- scripts/composer/ScriptHandler.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 208a89ab32..15b7c363f2 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "drush/drush": "^13@beta", "oomphinc/composer-installers-extender": "^2.0", "vlucas/phpdotenv": "^5.1", - "webflo/drupal-finder": "^1.2" + "webflo/drupal-finder": "^1.3" }, "require-dev": { "drupal/core-dev": "^11@alpha", diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 088c2b6081..837f0c7406 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -12,15 +12,14 @@ use Drupal\Core\Site\Settings; use Drupal\Core\Site\SettingsEditor; use DrupalFinder\DrupalFinder; +use DrupalFinder\DrupalFinderComposerRuntime; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Filesystem\Path; class ScriptHandler { public static function createRequiredFiles(Event $event) { $fs = new Filesystem(); - $drupalFinder = new DrupalFinder(); - $drupalFinder->locateRoot(getcwd()); + $drupalFinder = new DrupalFinderComposerRuntime(); $drupalRoot = $drupalFinder->getDrupalRoot(); $dirs = [ @@ -44,7 +43,7 @@ public static function createRequiredFiles(Event $event) { require_once $drupalRoot . '/core/includes/install.inc'; new Settings([]); $settings['settings']['config_sync_directory'] = (object) [ - 'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot), + 'value' => '../config/sync', 'required' => TRUE, ]; SettingsEditor::rewrite($drupalRoot . '/sites/default/settings.php', $settings); From e3802651e6566a3235a6b217ade066a72f27f2c6 Mon Sep 17 00:00:00 2001 From: Jesper Noordsij <45041769+jnoordsij@users.noreply.github.com> Date: Wed, 3 Jul 2024 12:57:47 +0200 Subject: [PATCH 20/24] Changes to usage of DrupalFinderComposerRuntime API in ScriptHandler (#677) Co-authored-by: Alex Skrypnyk --- scripts/composer/ScriptHandler.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 837f0c7406..9abe6d70b4 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -11,9 +11,9 @@ use Composer\Semver\Comparator; use Drupal\Core\Site\Settings; use Drupal\Core\Site\SettingsEditor; -use DrupalFinder\DrupalFinder; use DrupalFinder\DrupalFinderComposerRuntime; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Filesystem\Path; class ScriptHandler { @@ -22,6 +22,11 @@ public static function createRequiredFiles(Event $event) { $drupalFinder = new DrupalFinderComposerRuntime(); $drupalRoot = $drupalFinder->getDrupalRoot(); + if (is_null($drupalRoot)) { + $event->getIO()->writeError('Drupal root could not be detected.'); + exit(1); + } + $dirs = [ 'modules', 'profiles', @@ -43,7 +48,7 @@ public static function createRequiredFiles(Event $event) { require_once $drupalRoot . '/core/includes/install.inc'; new Settings([]); $settings['settings']['config_sync_directory'] = (object) [ - 'value' => '../config/sync', + 'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot), 'required' => TRUE, ]; SettingsEditor::rewrite($drupalRoot . '/sites/default/settings.php', $settings); From 62f98f3b6ce859c9841849aee80b1b4a7e839769 Mon Sep 17 00:00:00 2001 From: Jesper Noordsij <45041769+jnoordsij@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:04:03 +0200 Subject: [PATCH 21/24] Fix misplaced full stop in ScriptHandler --- scripts/composer/ScriptHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 9abe6d70b4..0ccdb85642 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -97,7 +97,7 @@ public static function checkComposerVersion(Event $event) { $io->writeError('You are running a development version of Composer. If you experience problems, please update Composer to the latest stable version.'); } elseif (Comparator::lessThan($version, '2.3.6')) { - $io->writeError('Drupal-project requires Composer version 2.3.6 or higher. Please update your Composer before continuing.'); + $io->writeError('Drupal-project requires Composer version 2.3.6 or higher. Please update your Composer before continuing.'); exit(1); } } From 74942299434254b65afec96548bb3fca191a3605 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Tue, 2 Jul 2024 20:32:37 +1000 Subject: [PATCH 22/24] [#678] Updated `.gitignore` configs. --- .editorconfig | 17 +++++++++++++++++ .gitignore | 26 ++++++++++++++++---------- composer.json | 5 +++++ 3 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..686c443cec --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# 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 + +[composer.{json,lock}] +indent_size = 4 diff --git a/.gitignore b/.gitignore index 12ad63d871..4669354007 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ -# Ignore directories generated by Composer +# To ignore OS temporary files use global .gitignore +# https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer + +# Ignore directories generated by Composer. /drush/contrib/ /vendor/ /web/core/ @@ -7,19 +10,22 @@ /web/profiles/contrib/ /web/libraries/ -# Ignore sensitive information +# Ignore sensitive information. /web/sites/*/settings.php -/web/sites/*/settings.local.php -# Ignore Drupal's file directory +# Ignore Drupal's file directory. /web/sites/*/files/ -# Ignore SimpleTest multi-site environment +# Ignore SimpleTest multi-site environment. /web/sites/simpletest -# Ignore files generated by common IDEs -/.idea/ -/.vscode/ - -# Ignore .env files as they are personal +# Ignore .env files as they could contain sensitive information. /.env + +# Manage .gitattributes with Drupal scaffold for cross-platform compatibility. +# Remove the line below and commit the file for more granular control. +/.gitattributes + +# Manage all .gitignore files with Drupal scaffold. +# Remove the line below and commit the files for more granular control. +**/.gitignore diff --git a/composer.json b/composer.json index 15b7c363f2..784988875e 100644 --- a/composer.json +++ b/composer.json @@ -63,6 +63,11 @@ "extra": { "composer-exit-on-patch-failure": true, "drupal-scaffold": { + "file-mapping": { + "[project-root]/.gitignore": false, + "[web-root]/INSTALL.txt": false, + "[web-root]/README.txt": false + }, "locations": { "web-root": "web/" } From 4da610d9dfb05de0703b0f8d95153df4d5cecb79 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 7 Aug 2024 10:16:36 +1000 Subject: [PATCH 23/24] Updated Drupal to use `stable` versions in `composer.json` and CI. --- .github/workflows/ci.yml | 4 +--- composer.json | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 276caab5c2..1cb83c189c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: matrix: php-versions: ['8.3'] - drupal-release: ['alpha', 'beta', 'dev'] + drupal-release: ['stable', 'beta', 'dev'] composer-channel: ['stable', 'snapshot'] steps: @@ -77,8 +77,6 @@ jobs: composer --verbose require --no-update drupal/core-composer-scaffold:^11@${{ matrix.drupal-release }} composer --verbose require --no-update drupal/core-recommended:^11@${{ matrix.drupal-release }} composer --verbose require --no-update --dev drupal/core-dev:^11@${{ matrix.drupal-release }} - # Remove the line below once the package is out of `alpha`. - [[ ${{ matrix.drupal-release }} == 'beta' ]] && composer require chi-teck/drupal-code-generator:^4@alpha composer --verbose update - name: Install site diff --git a/composer.json b/composer.json index 784988875e..5fb3a72213 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,15 @@ "require": { "composer/installers": "^2.1", "cweagans/composer-patches": "^1.7", - "drupal/core-composer-scaffold": "^11@alpha", - "drupal/core-recommended": "^11@alpha", - "drush/drush": "^13@beta", + "drupal/core-composer-scaffold": "^11", + "drupal/core-recommended": "^11", + "drush/drush": "^13", "oomphinc/composer-installers-extender": "^2.0", "vlucas/phpdotenv": "^5.1", "webflo/drupal-finder": "^1.3" }, "require-dev": { - "drupal/core-dev": "^11@alpha", + "drupal/core-dev": "^11", "ergebnis/composer-normalize": "^2.42" }, "conflict": { @@ -36,7 +36,7 @@ "url": "https://asset-packagist.org/" } ], - "minimum-stability": "alpha", + "minimum-stability": "stable", "prefer-stable": true, "autoload": { "classmap": [ From 02ff31a29df34ac70119bc3f6df30256699db6d5 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 9 Oct 2024 13:37:27 +1100 Subject: [PATCH 24/24] Added `tbachert/spi` to `config.allow-plugins` of `composer.json`. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5fb3a72213..ad45f372d8 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,8 @@ "ergebnis/composer-normalize": true, "oomphinc/composer-installers-extender": true, "php-http/discovery": true, - "phpstan/extension-installer": true + "phpstan/extension-installer": true, + "tbachert/spi": true }, "discard-changes": true, "sort-packages": true