Class: Dev::EndOfLife::Node
- Defined in:
- lib/firespring_dev_commands/eol/node.rb
Instance Attribute Summary collapse
-
#lockfile ⇒ Object
readonly
Returns the value of attribute lockfile.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #default_products ⇒ Object
-
#initialize(node = Dev::Node.new) ⇒ Node
constructor
A new instance of Node.
- #npm_products ⇒ Object
Constructor Details
Instance Attribute Details
#lockfile ⇒ Object (readonly)
Returns the value of attribute lockfile.
4 5 6 |
# File 'lib/firespring_dev_commands/eol/node.rb', line 4 def lockfile @lockfile end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
4 5 6 |
# File 'lib/firespring_dev_commands/eol/node.rb', line 4 def node @node end |
Instance Method Details
#default_products ⇒ Object
11 12 13 |
# File 'lib/firespring_dev_commands/eol/node.rb', line 11 def default_products npm_products end |
#npm_products ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/firespring_dev_commands/eol/node.rb', line 15 def npm_products eol = Dev::EndOfLife.new major_version_only_products = %w(ckeditor vue jquery) [].tap do |ary| packages = JSON.parse(File.read(lockfile))&.fetch('packages', []) packages.each do |key, info| name = key.split('node_modules/').last product = name # Make sure what we found is supported by the EOL library next unless eol.product?(product) version = info['version'].reverse.split('.')[-2..].join('.').reverse.tr('v', '') version = version.split('.').first if major_version_only_products.include?(product) version.chop! if version.end_with?('.00') ary << Dev::EndOfLife::ProductVersion.new(product, version, name) end end end |