Git Product home page Git Product logo

info-rewrite's Introduction

Build Status

A composer plugin for rewriting Drupal .info/.info.yml files to include version information that Drupal requires.

This is only required when downloading projects that aren't full releases (for instance, dev versions).

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

composer require drupal-composer/info-rewrite:~1.0

Configuration

By default, this plugin only acts on packages of type drupal-core, drupal-module, drupal-profile, and drupal-theme (see DrupalInfo::$packageTypes). You can add additional package types in your composer.json file. Add to the config array an entry with key drupal-info-rewrite--additional-packageTypes and make its value be an array of strings which are the additional types you would like to add.

info-rewrite's People

Contributors

jhedstrom avatar lkmorlan avatar pasqualle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

info-rewrite's Issues

Changes are rolled-back by additional calls to `composer install`

If I run composer install version numbers are added. If I run it again, rollbackRewrite() removes the version numbers but they do not get added back again. I think this is because neither POST_PACKAGE_INSTALL nor POST_PACKAGE_UPDATE get run for packages that do not need to be changed on the subsequent run of composer install.

In Drupal 9: Duplicate key "core|version" detected

When running this in Drupal 9, I am seeing:

Unable to parse ....info.yml Duplicate key "core" detected at line 13 (near "core: '8.x'").

Unable to parse ....info.yml Duplicate key "version" detected at line 9 (near "version: '8.x-3.4'").

info-rewrite adds a core key, but this is often already present (though it should now be core_version_requirement). Info files often have version: VERSION. info-rewrite will probably need to update version: VERSION instead of appending a second version key with the actual version.

Event subscriptions weight

Plugin cweagans/composer-patches has POST_PACKAGE_INSTALL and POST_PACKAGE_UPDATE = 10. Your plugin has 50. Because of this some patches altered .info file cannot be applied...

This fixes this problem:

$events[PackageEvents::POST_PACKAGE_INSTALL] = ['writeInfoFiles', 5];
$events[PackageEvents::POST_PACKAGE_UPDATE] = ['writeInfoFiles', 5];

Incorrect version added for core

The component adds an extra digit to the version identifier of core files without version information, causing problems for the update manager. I updated core after installing this component and the system.info.yml reported version 8.3.2.0. The update manager reported every available security release as newer than my current version.

Fatal Error Call to a member function rollback() on null

Hi,

I hope this is the right place to post this, and if it's not, I apologize. I'm getting this error:

PHP Fatal error: Uncaught Error: Call to a member function rollback() on null in /drupalpath/vendor/drupal-composer/info-rewrite/src/DrupalInfo.php:138
Stack trace:
#0 /drupalpath/vendor/drupal-composer/info-rewrite/src/DrupalInfo.php(111): DrupalComposer\Composer\DrupalInfo->doRollback(Object(Composer\Package\AliasPackage))
#1 [internal function]: DrupalComposer\Composer\DrupalInfo->rollbackRewrite(Object(Composer\Script\Event))
#2 phar:///usr/local/Cellar/composer/1.8.0/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(176): call_user_func(Array, Object(Composer\Script\Event))
#3 phar:///usr/local/Cellar/composer/1.8.0/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(96): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Script\Event))
#4 phar:///usr/local/Cellar/composer/1.8.0/bin/composer/src/Composer/Installer.php(205): Composer\EventDispatcher\EventDispatcher->dispatchScript('pre-update-cmd', true) in /drupalpath/vendor/drupal-composer/info-rewrite/src/DrupalInfo.php on line 138

Fatal error: Uncaught Error: Call to a member function rollback() on null in /drupalpath/vendor/drupal-composer/info-rewrite/src/DrupalInfo.php:138
Stack trace:
#0 /drupalpath/vendor/drupal-composer/info-rewrite/src/DrupalInfo.php(111): DrupalComposer\Composer\DrupalInfo->doRollback(Object(Composer\Package\AliasPackage))
#1 [internal function]: DrupalComposer\Composer\DrupalInfo->rollbackRewrite(Object(Composer\Script\Event))
#2 phar:///usr/local/Cellar/composer/1.8.0/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(176): call_user_func(Array, Object(Composer\Script\Event))
#3 phar:///usr/local/Cellar/composer/1.8.0/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(96): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Script\Event))
#4 phar:///usr/local/Cellar/composer/1.8.0/bin/composer/src/Composer/Installer.php(205): Composer\EventDispatcher\EventDispatcher->dispatchScript('pre-update-cmd', true) in /drupalpath/vendor/drupal-composer/info-rewrite/src/DrupalInfo.php on line 138

I'm not sure what to do.

Call to a member function rewrite() on null

Huh this broke my composer.

$ composer require drupal/drush_language
Using version ^1.5 for drupal/drush_language
./composer.json has been updated
Gathering patches for root package.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing drupal/drush_language (1.5.0): Downloading (100%)         
PHP Fatal error:  Uncaught Error: Call to a member function rewrite() on null in phar:///home/merlin/bin/composer/src/Composer/Plugin/PluginManager.php(195) : eval()'d code:123
Stack trace:
#0 phar:///home/merlin/bin/composer/src/Composer/Plugin/PluginManager.php(195) : eval()'d code(91): DrupalComposer\Composer\DrupalInfo_composer_tmp3->doWriteInfoFiles(Object(Composer\Package\CompletePackage))
#1 [internal function]: DrupalComposer\Composer\DrupalInfo_composer_tmp3->writeInfoFiles(Object(Composer\Installer\PackageEvent))
#2 phar:///home/merlin/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(171): call_user_func(Array, Object(Composer\Installer\PackageEvent))
#3 phar:///home/merlin/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(116): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Installer\PackageEvent))
#4 phar:///home/merlin/bin/composer/src/Composer/Installer.php(609): Composer\EventDispatcher\EventDispatcher->dispatchPackageEvent('post-package-in...', true, Object(Compose in phar:///home/merlin/bin/composer/src/Composer/Plugin/PluginManager.php(195) : eval()'d code on line 123

Fatal error: Uncaught Error: Call to a member function rewrite() on null in phar:///home/merlin/bin/composer/src/Composer/Plugin/PluginManager.php(195) : eval()'d code:123
Stack trace:
#0 phar:///home/merlin/bin/composer/src/Composer/Plugin/PluginManager.php(195) : eval()'d code(91): DrupalComposer\Composer\DrupalInfo_composer_tmp3->doWriteInfoFiles(Object(Composer\Package\CompletePackage))
#1 [internal function]: DrupalComposer\Composer\DrupalInfo_composer_tmp3->writeInfoFiles(Object(Composer\Installer\PackageEvent))
#2 phar:///home/merlin/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(171): call_user_func(Array, Object(Composer\Installer\PackageEvent))
#3 phar:///home/merlin/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(116): Composer\EventDispatcher\EventDispatcher->doDispatch(Object(Composer\Installer\PackageEvent))
#4 phar:///home/merlin/bin/composer/src/Composer/Installer.php(609): Composer\EventDispatcher\EventDispatcher->dispatchPackageEvent('post-package-in...', true, Object(Compose in phar:///home/merlin/bin/composer/src/Composer/Plugin/PluginManager.php(195) : eval()'d code on line 123

Allow to remove drupal-core package

I am using Drupal core 8.9.1 and the version information also got added to drupal core (after deleting all core files and a call to composer install). I thought it's only for dev versions. I don't need it on core and would like to unset drupal-core, maybe similar to drupal-info-rewrite--additional-packageTypes or maybe just drupal-info-rewrite--set-packageTypes ... which can completely overrides the defined package types (= remove and add).

Follow-up: Changes are rolled-back by additional calls to `composer install`

I still have the problem described in #25. If I remove the modules/contrib directory and run composer install the version information gets added to the module.info.yml files calling composer install again will remove the the version information.

  • drupal-composer/info-rewrite version 1.0.0-rc1 (composer.lock)
  • Drupal Version: 8.9.1
  • Composer version: 1.10.7.

core_version_requirement' constraint

I updated the poll module dev version with info-rewrite plugin, but I get the following drush error:

The 'core_version_requirement' constraint (^8.7.7 || ^9) requires the 'core' key not be set in modules/contrib/poll/poll.info.yml

Please not add core key, if core_version_requirement is available.

Incorrect versions added for pinned versions of dev modules.

A known limitation of the Drupal packagist prevents pinned -dev versions of packages from being accurate.

Example:

composer require drupal/composer_deploy:1.x-dev#d8cf3fccf8966fb9e45659c501741a844c41a635

As of this writing, this commit should be described as version 8.x-1.1+1, meaning 1 commit ahead of release 8.x-1.1. Instead you will see this in the composer extra section.

  "drupal": {
      "version": "8.x-1.3+1-dev",
      "datestamp": "1555315985",
      "security-coverage": {
          "status": "not-covered",
          "message": "Dev releases are not covered by Drupal security advisories."
      }
  }

This is the latest commit's metadata, therefore, your pinned commit is reporting it's 2 versions ahead. Additionally, you will find that if the dependencies of the -dev package has changed between your pinned and the latest, you may not have everything you need to satisfy the needs of your pinned version.

All that to say. If we want to accurately add versions for pinned dev versions of modules we would likely have to use the git describe method Drush used back in the day. I've written a plugin that does this prior to knowing this project existed, but it's not nearly as clean. I would love to see the 2 combined as yalls code is SO much cleaner and stable. see https://github.com/generalredneck/drupal-version-info

Add changelog

Adding a changelog, and some more info to the README.md file would be good.

Writes newlines at end of all .info files

This normally wouldn't be a problem (and I would be all for it) except that the drupal packaging system does NOT provide newlines at the end of the files. This plugin seems to touch all .info files in the project... even ones not downloaded using git. This causes issues when patches are applied that change the .info file. Also this seems to be overreaching and hitting up custom modules as well.

Composer 2 compatibity

Error:
drupal-composer/info-rewrite[dev-master, 1.0.0-alpha1, ..., 1.0.0-rc1] require composer-plugin-api ^1.1 -> found composer-plugin-api[2.0.0] but it does not match the constraint.

Fix 'The package has modified files' prompt

Since this project rewrites the .info.yml file, when composer update is being run, for each re-written project, the user is prompted with:

  - Updating drupal/foo dev-1.x (c55fbbe => c55fbbe)    The package has modified files:
    M autologout.info.yml
    Discard changes [y,n,v,d,s,?]? y

Ideally we could either undo the rewrite just before this check is made, or somehow tell composer itself to ignore this particular change...

Version info added to Drupal 7 modules that already have it

This plugin indiscriminately adds version info to all Drupal 7 .info files, even if they already have it or are not installed by Composer. I think it should only add version info to projects that are installed by Composer, and only to .info files that don't already have it.

Besides not checking for existing version info, I'm guessing it ignores preserve-paths settings and looks for .info files in paths which it should ignore.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.