diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 686c443cec..0000000000 --- a/.editorconfig +++ /dev/null @@ -1,17 +0,0 @@ -# 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/.env.example b/.env.example deleted file mode 100644 index 4d04ef831b..0000000000 --- a/.env.example +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copy and rename this file to .env at root of this project. -# - -# A common use case is to supply database credentials via the environment. Edit settings.php -# like so: -# -# $databases['default']['default'] = [ -# 'database' => $_ENV['MYSQL_DATABASE'], -# 'driver' => 'mysql', -# 'host' => $_ENV['MYSQL_HOSTNAME'], -# 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', -# 'password' => $_ENV['MYSQL_PASSWORD'], -# 'port' => $_ENV['MYSQL_PORT'], -# 'prefix' => '', -# 'username' => $_ENV['MYSQL_USER'], -# ]; -# -# Uncomment and populate as needed. -# MYSQL_DATABASE= -# MYSQL_HOSTNAME= -# MYSQL_PASSWORD= -# MYSQL_PORT= -# MYSQL_USER= - -# Another common use case is to set Drush's --uri via environment. -# DRUSH_OPTIONS_URI=http://example.com diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 3cc303fda9..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,122 +0,0 @@ -name: CI - -on: - push: - pull_request: - types: - - opened - - synchronize - - reopened - -env: - COMPOSER_MEMORY_LIMIT: -1 - SIMPLETEST_DB: sqlite://tmp/site.sqlite - SIMPLETEST_BASE_URL: "http://127.0.0.1:8080" - -jobs: - build: - runs-on: 'ubuntu-20.04' - strategy: - fail-fast: false - - matrix: - php-versions: ['8.1', '8.2'] - drupal-release: ['stable', 'beta', 'dev'] - composer-channel: ['stable', 'snapshot'] - # Drupal 10.x-dev tests fail on PHP 8.3. - # @see https://www.drupal.org/project/drupal/issues/3375693 - include: - - php-versions: '8.3' - drupal-release: 'stable' - composer-channel: 'stable' - - php-versions: '8.3' - drupal-release: 'stable' - composer-channel: 'snapshot' - - steps: - - name: Dump matrix context - env: - MATRIX_CONTEXT: ${{ toJSON(matrix) }} - run: echo "$MATRIX_CONTEXT" - - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - extensions: gd, pdo_sqlite - - - name: Update Composer - run: composer --verbose self-update --${{ matrix.composer-channel }} - - - name: Show Composer version - run: composer --version - - - name: Validate composer.json - run: composer --verbose validate - - - name: Install dependencies - run: composer --verbose install - - - 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 - - # @see https://www.drupal.org/node/3176567 - - name: Install testing dependency - if: ${{ matrix.php-versions == '8.1' }} - run: composer require --dev phpspec/prophecy-phpunit:^2 - - - name: Override Drupal version to dev for testing dev releases - if: matrix.drupal-release == 'dev' || matrix.drupal-release == 'beta' - run: | - composer config minimum-stability ${{ matrix.drupal-release }} - composer config prefer-stable false - composer --verbose require --no-update drupal/core-composer-scaffold:^10@${{ matrix.drupal-release }} - composer --verbose require --no-update drupal/core-recommended:^10@${{ matrix.drupal-release }} - composer --verbose require --no-update --dev drupal/core-dev:^10@${{ matrix.drupal-release }} - composer --verbose update - - - 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" & - 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 - - # 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/.gitignore b/.gitignore index 4669354007..ba1cf10761 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,33 @@ -# 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/ +# Ignore directories generated by Composer /vendor/ -/web/core/ -/web/modules/contrib/ -/web/themes/contrib/ -/web/profiles/contrib/ -/web/libraries/ - -# Ignore sensitive information. -/web/sites/*/settings.php - -# Ignore Drupal's file directory. -/web/sites/*/files/ +/web/sites/all/drush/ +/web/sites/all/modules/contrib/ +/web/sites/all/themes/contrib/ +/web/sites/all/libraries/ -# Ignore SimpleTest multi-site environment. -/web/sites/simpletest +# Ignore Drupal 7 core files. +/web/* +!/web/*/ +/web/includes/ +/web/misc/ +/web/modules/ +/web/profiles/README.txt +/web/profiles/minimal/ +/web/profiles/standard/ +/web/profiles/testing/ +/web/scripts/ +/web/sites/README.txt +/web/sites/all/*/README.txt +/web/sites/example.sites.php +/web/themes/ -# Ignore .env files as they could contain sensitive information. -/.env +# Ignore configuration files that may contain sensitive information. +/web/sites/*/*.settings.php +/web/sites/*/settings*.php -# Manage .gitattributes with Drupal scaffold for cross-platform compatibility. -# Remove the line below and commit the file for more granular control. -/.gitattributes +# Ignore paths that contain user-generated content. +/web/sites/*/files +/web/sites/*/private -# Manage all .gitignore files with Drupal scaffold. -# Remove the line below and commit the files for more granular control. -**/.gitignore +# Ignore files generated by PhpStorm +/.idea/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..a8ea23bc1c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +language: php +dist: trusty +sudo: false + +php: + - 5.6 + +env: + global: + - SIMPLETEST_DB=sqlite://tmp/site.sqlite + - SIMPLETEST_BASE_URL="http://127.0.0.1:8080" + matrix: + - RELEASE=stable COMPOSER_CHANNEL=stable + - RELEASE=dev COMPOSER_CHANNEL=stable + - RELEASE=stable COMPOSER_CHANNEL=snapshot + +before_install: + - echo 'sendmail_path = /bin/true' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + - phpenv config-rm xdebug.ini + - composer --verbose self-update --$COMPOSER_CHANNEL + - composer --version + +install: + - composer --verbose validate + - composer --verbose install + +script: + - if [[ $RELEASE = dev ]]; then composer --verbose update; fi; + - cd $TRAVIS_BUILD_DIR/web + - ./../vendor/bin/drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite + - ./../vendor/bin/drush runserver $SIMPLETEST_BASE_URL & + - until curl -s $SIMPLETEST_BASE_URL; do true; done > /dev/null + - ./../vendor/bin/drush diff --git a/README.md b/README.md index 2677db9623..048faa7d45 100644 --- a/README.md +++ b/README.md @@ -1,182 +1,114 @@ # 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) -![LICENSE](https://img.shields.io/github/license/drupal-composer/drupal-project) +[![Build Status](https://travis-ci.org/drupal-composer/drupal-project.svg?branch=7.x)](https://travis-ci.org/drupal-composer/drupal-project) This project template provides a starter kit for managing your site dependencies with [Composer](https://getcomposer.org/). -> [!IMPORTANT] -> [Drupal 11 branch](https://github.com/drupal-composer/drupal-project/tree/11.x) is available! +If you want to know how to use it as replacement for +[Drush Make](https://github.com/drush-ops/drush/blob/8.x/docs/make.md) visit +the [Documentation on drupal.org](https://www.drupal.org/node/2471553). -## What does the template do? +## Usage + +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. - -## Installing - -> [!NOTE] -> The instructions below refer to the [global Composer installation](https://getcomposer.org/doc/00-intro.md#globally). +> 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. -Create your project: +After that you can create the project: -```bash -composer create-project drupal-composer/drupal-project:10.x-dev some-dir --no-interaction +``` +composer create-project drupal-composer/drupal-project:7.x-dev some-dir --no-interaction ``` -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. - -## Usage - -### Adding new dependencies - -Use `composer require` to include and download dependencies for your project. +With `composer require ...` you can download new dependencies to your +installation. -```bash +``` cd some-dir -composer require drupal/devel +composer require drupal/devel:~1.0 ``` -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: +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. -```bash -composer require drupal/devel:1.0.0-beta1 -``` +## What does the template do? -Alternatively, you can globally adjust the stability settings by modifying -`composer.json` to include the desired stability level and explicitly allow it: +When installing the given `composer.json` some tasks are taken care of: -```json -{ - "minimum-stability": "beta", - "prefer-stable": true -} -``` +* Drupal will be installed in the `web`-directory. +* Modules (packages of type `drupal-module`) will be placed in `web/sites/all/modules/contrib/` +* Theme (packages of type `drupal-module`) will be placed in `web/sites/all/themes/contrib/` +* Profiles (packages of type `drupal-profile`) will be placed in `web/profiles/` +* Libraries (packages of type `drupal-library`) will be placed in `web/sites/all/libraries/` (See Libraries) +* Helps for using other PHP packages almost similar to the Drupal 8 version +* Creates default writable versions of `settings.php`. +* Creates `web/sites/default/files`-directory. +* Latest version of drush is installed locally for use at `vendor/bin/drush`. -This configuration ensures that stable releases are preferred, but allows the -installation of non-stable packages when necessary. +## Generate composer.json from existing project -### Adding libraries +With using [the "Composer Generate" drush extension](https://www.drupal.org/project/composer_generate) +you can now generate a basic `composer.json` file from an existing project. Note +that the generated `composer.json` might differ from this project's file. -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. +## How to enable the Composer autoloader in your Drupal 7 website -```bash -composer require bower-asset/dropzone -``` +The skeleton already installs the `composer_autoloader` module. Just enable it in the website before enabling +any possible module that have dependencies various packages. -### Custom installation paths for libraries +## 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: +Libraries normally would be extra packages that need to be public available (CSS and JS). +Normally this are not maintained using Composer, but if you want to have a 100% Composer deployment and benefit from patches you can use in `composer.json` this example, changing the `repositories` section and adding in `require` section: +``` -```json -{ - "extra": { - "installer-paths": { - "web/libraries/chosen": [ - "npm-asset/chosen-js" - ], - "web/libraries/{$name}": [ - "type:drupal-library", - "type:npm-asset", - "type:bower-asset" - ] - } +"repositories": [ + ... + { + "type": "package", + "package": { + "name": "kenwheeler/slick", + "version": "1.6.0", + "dist": { + "url": "https://github.com/kenwheeler/slick/archive/1.6.0.zip", + "type": "zip" + }, + "source": { + "url": "https://github.com/kenwheeler/slick.git", + "type": "git", + "reference": "1.6.0" + }, + "type": "drupal-library" } -} + } +], +"require": { + ... + "kenwheeler/slick": "~1.6.0" +}, ``` +After this run `composer update --lock` to install just the manually managed package. +_(You may run `composer require "kenwheeler/slick:~1.6.0"` as well if you add just the package definition)_ -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. - -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 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`. -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 - 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. - -## FAQs +## FAQ ### Should I commit the contrib modules I download? Composer recommends **no**. They provide [argumentation against but also -workarounds if a project decides to do it anyway](https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md). +workrounds 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? +### How can I apply patches to downloaded modules? -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` -and `post-update` command in your `composer.json`: - -```json -"scripts": { - "post-install-cmd": [ - "@composer drupal:scaffold", - "..." - ], - "post-update-cmd": [ - "@composer drupal:scaffold", - "..." - ] -}, -``` - -### How can I apply patches to included dependencies? - -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`: +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. +To add a patch to drupal module foobar insert the patches section in the extra +section of composer.json: ```json "extra": { "patches": { @@ -186,39 +118,20 @@ To add a patch to Drupal module `foobar`, insert the `patches` section in the } } ``` +### How do I switch from packagist.drupal-composer.org to packages.drupal.org? -### How do I specify a PHP version? - -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`. - -The purpose of `require.php` is to set the minimum PHP language requirements -for a package. For example, the minimum version required for Drupal 10.0 is -`8.0.2` or above, which can be specified as `>=8`. - -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 10 is `8.0.2` or above, -the actual PHP version on the hosting provider could be `8.1.0`. 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? +Follow the instructions in the [documentation on drupal.org](https://www.drupal.org/docs/develop/using-composer/using-packagesdrupalorg). -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`. +### How do I specify a PHP version ? -`config.platform` is a platform-specific. It is recommended to specify -`config.platform` as a _specific version_ (e.g.`8.1.19`) constraint to ensure -that only the package versions supported by your current environment are used. +This project supports PHP 5.3 as minimum version (see [Drupal 7 PHP requirements](https://www.drupal.org/docs/7/system-requirements/php-requirements)), however it's possible that a `composer update` will upgrade some package that will then require PHP 7+. +To prevent this you can add this code to specify the PHP version you want to use in the `config` section of `composer.json`: ```json "config": { + "sort-packages": true, "platform": { - "php": "8.1.19" + "php": "5.3.3" } }, ``` diff --git a/composer.json b/composer.json index 6867818862..4bce9710d7 100644 --- a/composer.json +++ b/composer.json @@ -1,130 +1,90 @@ { "name": "drupal-composer/drupal-project", - "description": "Project template for Drupal 10 projects with Composer", - "license": "GPL-2.0-or-later", + "description": "Project template for Drupal 7 projects with composer", "type": "project", + "license": "GPL-2.0-or-later", "authors": [ { "name": "", "role": "" } ], - "require": { - "composer/installers": "^2.1", - "cweagans/composer-patches": "^1.7", - "drupal/core-composer-scaffold": "^10.2.0", - "drupal/core-recommended": "^10.2.0", - "drush/drush": "^12.4.3", - "oomphinc/composer-installers-extender": "^2.0", - "vlucas/phpdotenv": "^5.1", - "webflo/drupal-finder": "^1.3" - }, - "require-dev": { - "drupal/core-dev": "^10.2.0", - "ergebnis/composer-normalize": "^2.42" - }, - "conflict": { - "drupal/drupal": "*" - }, "repositories": [ { "type": "composer", - "url": "https://packages.drupal.org/8" - }, - { - "type": "composer", - "url": "https://asset-packagist.org" + "url": "https://packages.drupal.org/7" } ], - "minimum-stability": "stable", - "prefer-stable": true, - "autoload": { - "classmap": [ - "scripts/composer/ScriptHandler.php" - ], - "files": [ - "load.environment.php" - ] + "require": { + "php": ">=5.3.3", + "ext-curl": "*", + "ext-gd": "*", + "ext-json": "*", + "ext-openssl": "*", + "ext-pdo": "*", + "ext-xml": "*", + "composer/installers": "^1.9", + "composer/semver": "^1.4", + "cweagans/composer-patches": "^1.7", + "drupal-composer/preserve-paths": "^0.1.6", + "drupal/composer_autoloader": "^1.0", + "drupal/drupal": "^7.62", + "drush/drush": "^8.0", + "symfony/filesystem": "~2.7 || ^3", + "webflo/drupal-finder": "^1.2.1" }, + "conflict": { + "drupal/core": "8.*" + }, + "minimum-stability": "dev", + "prefer-stable": true, "config": { + "sort-packages": true, "allow-plugins": { "composer/installers": true, "cweagans/composer-patches": true, - "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, - "tbachert/spi": true - }, - "discard-changes": true, - "sort-packages": true + "drupal-composer/preserve-paths": true + } }, - "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/" - } - }, - "installer-paths": { - "web/core": [ - "type:drupal-core" - ], - "web/libraries/{$name}": [ - "type:drupal-library", - "type:bower-asset", - "type:npm-asset" - ], - "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/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": [ - "bower-asset", - "npm-asset" - ], - "patchLevel": { - "drupal/core": "-p2" - }, - "patches": {} + "autoload": { + "classmap": [ + "scripts/composer/ScriptHandler.php" + ] }, "scripts": { "pre-install-cmd": [ "DrupalProject\\composer\\ScriptHandler::checkComposerVersion" ], - "post-install-cmd": [ - "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" - ], "pre-update-cmd": [ "DrupalProject\\composer\\ScriptHandler::checkComposerVersion" ], + "post-install-cmd": [ + "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" + ], "post-update-cmd": [ "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" + ], + "post-create-project-cmd": [ + "DrupalProject\\composer\\ScriptHandler::removeInternalFiles" + ] + }, + "extra": { + "installer-paths": { + "web/": ["type:drupal-core"], + "web/profiles/{$name}/": ["type:drupal-profile"], + "web/sites/all/drush/{$name}/": ["type:drupal-drush"], + "web/sites/all/libraries/{$name}/": ["type:drupal-library"], + "web/sites/all/modules/contrib/{$name}/": ["type:drupal-module"], + "web/sites/all/themes/contrib/{$name}/": ["type:drupal-theme"] + }, + "patches-install-hooks": true, + "patches": { + "cweagans/composer-patches": { + "Call the preserve paths hooks" : "https://github.com/jcnventura/composer-patches/compare/1.x...jcnventura:fix-preserve-paths.diff" + } + }, + "preserve-paths": [ + "web/sites" ] } } diff --git a/drush/Commands/PolicyCommands.php b/drush/Commands/PolicyCommands.php deleted file mode 100644 index 790bbeb210..0000000000 --- a/drush/Commands/PolicyCommands.php +++ /dev/null @@ -1,40 +0,0 @@ -input()->getArgument('target') == '@prod') { - throw new \Exception(dt('Per !file, you may never overwrite the production database.', ['!file' => __FILE__])); - } - } - - /** - * Limit rsync operations to production site. - * - * @throws \Exception - */ - #[Hook(type: HookManager::ARGUMENT_VALIDATOR, target: RsyncCommands::RSYNC)] - public function rsyncValidate(CommandData $commandData) { - if (preg_match("/^@prod/", $commandData->input()->getArgument('target'))) { - throw new \Exception(dt('Per !file, you may never rsync to the production site.', ['!file' => __FILE__])); - } - } -} diff --git a/drush/drush.yml b/drush/drush.yml deleted file mode 100644 index a8cbd00730..0000000000 --- a/drush/drush.yml +++ /dev/null @@ -1,6 +0,0 @@ -# -# A Drush configuration file -# -# Docs at https://github.com/drush-ops/drush/blob/master/examples/example.drush.yml -# -# Edit or remove this file as needed. diff --git a/drush/policy.drush.inc b/drush/policy.drush.inc new file mode 100644 index 0000000000..64cd62d0f6 --- /dev/null +++ b/drush/policy.drush.inc @@ -0,0 +1,38 @@ +safeLoad(); diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 0ccdb85642..77ebe3b835 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -9,28 +9,21 @@ use Composer\Script\Event; use Composer\Semver\Comparator; -use Drupal\Core\Site\Settings; -use Drupal\Core\Site\SettingsEditor; -use DrupalFinder\DrupalFinderComposerRuntime; +use DrupalFinder\DrupalFinder; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Filesystem\Path; class ScriptHandler { public static function createRequiredFiles(Event $event) { $fs = new Filesystem(); - $drupalFinder = new DrupalFinderComposerRuntime(); + $drupalFinder = new DrupalFinder(); + $drupalFinder->locateRoot(getcwd()); $drupalRoot = $drupalFinder->getDrupalRoot(); - if (is_null($drupalRoot)) { - $event->getIO()->writeError('Drupal root could not be detected.'); - exit(1); - } - $dirs = [ - 'modules', + 'sites/all/modules', 'profiles', - 'themes', + 'sites/all/themes', ]; // Required for unit testing @@ -44,20 +37,12 @@ public static function createRequiredFiles(Event $event) { // Prepare the settings file for installation if (!$fs->exists($drupalRoot . '/sites/default/settings.php') && $fs->exists($drupalRoot . '/sites/default/default.settings.php')) { $fs->copy($drupalRoot . '/sites/default/default.settings.php', $drupalRoot . '/sites/default/settings.php'); - require_once $drupalRoot . '/core/includes/bootstrap.inc'; - require_once $drupalRoot . '/core/includes/install.inc'; - new Settings([]); - $settings['settings']['config_sync_directory'] = (object) [ - 'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot), - 'required' => TRUE, - ]; - SettingsEditor::rewrite($drupalRoot . '/sites/default/settings.php', $settings); $fs->chmod($drupalRoot . '/sites/default/settings.php', 0666); $event->getIO()->write("Created a sites/default/settings.php file with chmod 0666"); } // Create the files directory with chmod 0777 - if (!$fs->exists($drupalRoot . '/sites/default/files') && !is_link($drupalRoot . '/sites/default/files')) { + if (!$fs->exists($drupalRoot . '/sites/default/files')) { $oldmask = umask(0); $fs->mkdir($drupalRoot . '/sites/default/files', 0777); umask($oldmask); @@ -65,6 +50,27 @@ public static function createRequiredFiles(Event $event) { } } + /** + * Remove project-internal files after create project. + */ + public static function removeInternalFiles(Event $event) { + $fs = new Filesystem(); + + // List of files to be removed. + $files = [ + '.travis.yml', + 'LICENSE', + 'README.md', + 'phpunit.xml.dist', + ]; + + foreach ($files as $file) { + if ($fs->exists($file)) { + $fs->remove($file); + } + } + } + /** * Checks if the installed version of Composer is compatible. * @@ -96,8 +102,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, '2.3.6')) { - $io->writeError('Drupal-project requires Composer version 2.3.6 or higher. Please update your Composer before continuing.'); + 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.'); exit(1); } }