Last active
November 1, 2024 07:32
-
-
Save theodorosploumis/f4fd02c6df152baf464a42d077d41ff4 to your computer and use it in GitHub Desktop.
Get the latest stable and supported Drupal versions on the cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# Get the latets stable and supported Drupal versions on the cli | |
require 'nokogiri' | |
require 'open-uri' | |
require 'colorize' | |
# Fetch and parse HTML document | |
doc = Nokogiri::HTML(URI.open('https://www.drupal.org/project/drupal')) | |
versions = [] | |
dates = [] | |
# Search for Version by css | |
doc.css('.views-field-field-release-version h4').each do |entry| | |
version = entry.content.gsub! 'Drupal core ', '' | |
if !version.include? "dev" | |
versions.push(version) | |
end | |
end | |
# Search for Realse dates by css | |
doc.css('.views-field-field-release-version .release-date').each do |entry| | |
date = entry.content.gsub! 'Released ', '' | |
better_date = Time.parse(date).strftime('%F') | |
dates.push(better_date) | |
end | |
# puts versions | |
# puts dates | |
versions.each_index do |i| | |
puts "#{dates[i]}".yellow + ": #{versions[i]}" | |
end |
ToDo:
- Check from git tags on https://github.com/drupal/core/tags or https://git.drupalcode.org/project/drupal/-/tags
- Check from packagist on https://packagist.org/packages/drupal/core
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run