rubion 0.3.8 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66ea41e904499824e1e29a1fd89fe83860215fe8447ce510bb8ddcbd1cbde9f9
4
- data.tar.gz: 9faa8f3ee26ceec360b6b73b3ba8b2948cad9277c98dea8c7c8357485de23b31
3
+ metadata.gz: 4c4e3c0ca5fe5a8dcb5e1283bee4f507cd40cce64796bfff6fb261cabc944bc7
4
+ data.tar.gz: 37b74184805f031a5cb839ab5e0fec28079d3735009db697523b0d90639d01bf
5
5
  SHA512:
6
- metadata.gz: 974ae2a4d695380c0c824fc81bfd49e48ed452cdb4abc3e7271a0a1c47e980a185024d8a1e0951e81046b31276c501dd4f1fcc3395a3d69d551fe2b24ba82113
7
- data.tar.gz: 92075925c5f29a06da7a3fe1a454c523846a65a27a2f4ac2085cd5475b8042c9ae3ee3de6d5cb57acf7112a665341b60508f31cc25d08d47cbe44709dbee8cc8
6
+ metadata.gz: e1547c0bcb405af894e41fbe47607045349ceff8359592c02bef854b2ec7f2d5314ac6f4d3334312cc85196a3bd02633696bda509045f5f17c6369093100a9be
7
+ data.tar.gz: 57cecf15af4f037567c43d4ae38ef6c5c383b7e4ad33bc59ef65515609d1bc45ee376f413097fa8df050aae29177b9a0079c9d4c5a6f3820efac1dd872e0eb15
@@ -236,7 +236,8 @@ module Rubion
236
236
 
237
237
  # Format version table headings with sorting indicator
238
238
  def format_version_headings
239
- base_headings = ['Name', 'Current', 'Date', 'Latest', 'Date', 'Behind By(Time)', 'Behind By(Versions)']
239
+ base_headings = ['Name', 'Current', 'Current version released on', 'Latest', 'Latest version released on',
240
+ 'Behind By(Time)', 'Behind By(Versions)']
240
241
 
241
242
  return base_headings unless @sort_by
242
243
 
@@ -245,7 +246,9 @@ module Rubion
245
246
  'name' => 0,
246
247
  'current' => 1,
247
248
  'date' => 2, # First Date column (current_date)
249
+ 'current version released on' => 2,
248
250
  'latest' => 4,
251
+ 'latest version released on' => 4,
249
252
  'behind by(time)' => 5,
250
253
  'behind by time' => 5,
251
254
  'time' => 5,
@@ -148,17 +148,43 @@ module Rubion
148
148
  def check_npm_versions
149
149
  return unless @package_manager
150
150
 
151
- command = "#{@package_manager} outdated --json 2>&1"
151
+ # Yarn v1 doesn't support --json flag, so handle it differently
152
+ if @package_manager == 'yarn'
153
+ check_yarn_outdated
154
+ else
155
+ check_npm_outdated
156
+ end
157
+ end
158
+
159
+ def check_npm_outdated
160
+ command = 'npm outdated --json 2>&1'
152
161
  stdout, stderr, status = Open3.capture3(command, chdir: @project_path)
153
162
 
154
163
  begin
155
164
  data = JSON.parse(stdout) unless stdout.empty?
156
165
  parse_npm_outdated_output(data || {})
157
- rescue JSON::ParserError
166
+ rescue JSON::ParserError => e
167
+ puts " ⚠️ Error parsing npm outdated JSON output: #{e.message}"
168
+ @result.package_versions = []
169
+ end
170
+ rescue StandardError => e
171
+ puts " ⚠️ Could not run npm outdated (#{e.message}). Skipping package version check."
172
+ @result.package_versions = []
173
+ end
174
+
175
+ def check_yarn_outdated
176
+ # Yarn v1 doesn't support --json, so parse text output
177
+ command = 'yarn outdated 2>&1'
178
+ stdout, stderr, status = Open3.capture3(command, chdir: @project_path)
179
+
180
+ begin
181
+ parse_yarn_outdated_output(stdout)
182
+ rescue StandardError => e
183
+ puts " ⚠️ Could not parse yarn outdated output (#{e.message}). Skipping package version check."
158
184
  @result.package_versions = []
159
185
  end
160
186
  rescue StandardError => e
161
- puts " ⚠️ Could not run #{@package_manager} outdated (#{e.message}). Skipping package version check."
187
+ puts " ⚠️ Could not run yarn outdated (#{e.message}). Skipping package version check."
162
188
  @result.package_versions = []
163
189
  end
164
190
 
@@ -395,6 +421,104 @@ module Rubion
395
421
  @result.package_versions = []
396
422
  end
397
423
 
424
+ def parse_yarn_outdated_output(output)
425
+ versions = []
426
+ packages_to_process = []
427
+
428
+ # Yarn v1 outdated output format:
429
+ # Package Name Current Wanted Latest
430
+ # package-name 1.0.0 1.0.0 2.0.0
431
+ # Skip header lines and parse package info
432
+ output.each_line do |line|
433
+ line = line.strip
434
+ next if line.empty?
435
+ next if line.start_with?('Package') || line.start_with?('yarn') || line.start_with?('Done')
436
+ next if line.include?('─') # Skip separator lines
437
+
438
+ # Parse format: package-name current wanted latest location
439
+ # Or: package-name current wanted latest
440
+ parts = line.split(/\s+/)
441
+ next if parts.length < 4
442
+
443
+ package_name = parts[0]
444
+ current_version = parts[1]
445
+ latest_version = parts[3] # Skip wanted (parts[2]), use latest
446
+
447
+ # Skip if versions are the same (not outdated)
448
+ next if current_version == latest_version
449
+
450
+ packages_to_process << {
451
+ name: package_name,
452
+ current_version: current_version,
453
+ latest_version: latest_version
454
+ }
455
+ end
456
+
457
+ total = packages_to_process.size
458
+
459
+ return if total == 0
460
+
461
+ # Process in parallel with threads (limit to 10 concurrent requests)
462
+ mutex = Mutex.new
463
+ thread_pool = []
464
+ max_threads = 10
465
+
466
+ packages_to_process.each_with_index do |pkg_data, index|
467
+ # Wait if we have too many threads
468
+ thread_pool.shift.join if thread_pool.size >= max_threads
469
+
470
+ thread = Thread.new do
471
+ # Fetch all version info once per package (includes dates and version list)
472
+ pkg_data_full = fetch_npm_all_versions(pkg_data[:name])
473
+
474
+ # Extract dates for current and latest versions
475
+ current_date = pkg_data_full[:versions][pkg_data[:current_version]] || 'N/A'
476
+ latest_date = pkg_data_full[:versions][pkg_data[:latest_version]] || 'N/A'
477
+
478
+ # Calculate time difference
479
+ time_diff = calculate_time_difference(current_date, latest_date)
480
+
481
+ # Count versions between current and latest
482
+ version_count = count_versions_from_list(pkg_data_full[:version_list], pkg_data[:current_version],
483
+ pkg_data[:latest_version])
484
+
485
+ # Check if this is a direct dependency
486
+ direct_dependency = is_direct_package?(pkg_data[:name])
487
+
488
+ result = {
489
+ package: pkg_data[:name],
490
+ current: pkg_data[:current_version],
491
+ current_date: current_date,
492
+ latest: pkg_data[:latest_version],
493
+ latest_date: latest_date,
494
+ time_diff: time_diff,
495
+ version_count: version_count,
496
+ direct: direct_dependency,
497
+ index: index
498
+ }
499
+
500
+ mutex.synchronize do
501
+ versions << result
502
+ print "\r📦 Checking NPM packages... #{versions.size}/#{total}"
503
+ $stdout.flush
504
+ end
505
+ end
506
+
507
+ thread_pool << thread
508
+ end
509
+
510
+ # Wait for all threads to complete
511
+ thread_pool.each(&:join)
512
+
513
+ # Sort by original index to maintain order
514
+ versions.sort_by! { |v| v[:index] }
515
+ versions.each { |v| v.delete(:index) }
516
+
517
+ puts "\r📦 Checking NPM packages... #{total}/#{total} ✓" if total > 0
518
+
519
+ @result.package_versions = versions
520
+ end
521
+
398
522
  # Dummy data for demonstration (commented out - only show real data)
399
523
  # Uncomment these methods if you need dummy data for testing
400
524
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rubion
4
- VERSION = "0.3.8"
4
+ VERSION = "0.3.10"
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - bipashant