0

Context

  • Drush version 8.x
  • Drupal 7 site

Problem

  • Mr. HtraenuRekaos has a text file with a list of Drupal contrib modules.
  • He wants to get the recommended-install version of all the modules in the list.
  • This list is not associated with any pre-existing site, and none of the modules are currently installed.

Non-solutions

  • Mr. H has already looked at this SO post: Using wget to get the latest module version, but he does not want to use wget, he wants to use drush
  • Mr. H does not want to actually download or install the relevant modules, he only wants to get a list with the latest recommended D7.x version.

Question(s)

  • Is there a drush command that will turn before into after?

Before

MODULE_NAME_HERE ;; RECCO_VERSION_HERE contrib_module_001 ;; __blank__ foobar_module ;; __blank__ htraenurekaos ;; __blank__

After

MODULE_NAME_HERE ;; RECCO_VERSION_HERE contrib_module_001 ;; 7.x-1.6 foobar_module ;; 7.x-2.2 htraenurekaos ;; 7.x-3.6

6
  • Drush will always download the "Recommended" latest version. So why bother keeping track of the actual version numbers?
    – No Sssweat
    Jan 19, 2017 at 0:58
  • @NoSssweat: because he wants to have a record for use with a git-tracked drush makefile.
    – dreftymac
    Jan 19, 2017 at 4:23
  • In your make file, you could use put version: ~ so it automatically downloads the latest version. If you put version: '1.2' it will always download 7.x-1.2 even if a new version 7.x-1.3 is out.
    – No Sssweat
    Jan 19, 2017 at 4:28
  • @NoSssweat: and if that newer version of the module has a regression or incompatibility with any other module on the site, you've got a potentially broken site.
    – dreftymac
    Jan 19, 2017 at 4:34
  • true, but what if the newer version has a security or bug fix or adds a new awesome feature? I guess its a trade off.
    – No Sssweat
    Jan 19, 2017 at 4:50

1 Answer 1

1

Mr. H does not want to actually download or install the relevant modules, he only wants to get a list with the latest recommended D7.x version.

Well, at the very least, you can do:

drush @site.env up module_name --select for individual modules, you can also do:

drush @site.env pm-releases which has a load of options for output.

https://drushcommands.com/drush-8x/pm/pm-releases/

It has format options.

3
  • Just in case anyone is following along: drush pm-releases module_name_here --format=yaml does the trick. You have to crawl through the YAML though, and pull out the status key, and search for Recommended.
    – dreftymac
    Jan 19, 2017 at 4:39
  • I don't see any reason to go through YAML. Just use awk and the normal (table) output from Drush: drush pm-releases some_module | grep Recommended | awk '{print $2}' will return the version number.
    – hansfn
    Jan 29, 2017 at 23:36
  • @hansfn //I don't see any reason// -- having a structured data format such as JSON or YAML obviates the need to write one-off parsers or shell scripts, for those who wish to avoid the potentially brittle and easily-broken (and usually under-documented) "screen scraping" approach offered by tools such as awk, perl, and grep. not everyone will agree with this, but it is a reason
    – dreftymac
    Jun 15, 2017 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.