git_game_show 0.1.2 → 0.1.4

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: eb852185be4e80bb32062b74675572ddcc45ea5e4ec8716969b90d0d73225fe8
4
- data.tar.gz: 6ac3c1001051cb307caf4a6e1c87778fe1d94812c3b7f32f2e27045cef0f00a8
3
+ metadata.gz: e2e16a5db208a5da525ed9c104ff9ca6a04b3ee1277c0463b1d6a4ae92e358a5
4
+ data.tar.gz: 17400bb69a005c1f30fee70e33eeff6937bc29237b745f12368e54863ebc3ef7
5
5
  SHA512:
6
- metadata.gz: 824c2da32e7802bc354b28196a41eb4b8c4acd84de92208f97b3eaba61a61ba83c6724ddeabc08d62ef0ca00f6617ca6409ae82739cc4ae06e1c126f21b9449e
7
- data.tar.gz: 13fc7daecb192024caf2f64b1373556999e32608209f53de7111afbe5b575917af34e44585821526332e690b224425ebc451b5938f687776e61297fbfff4cc0f
6
+ metadata.gz: 76b2747d64550026843890bd0ac940a9808e77d60dfe33cd9c521f65aad826bbdd57cfa530f309318912a21e0b246d4c062935483ff3e1036a74c5f4bf1f7cb8
7
+ data.tar.gz: 12a34d4b1371eb806af69ce0c2feb6e7135ae66aa7b275c1d0f730eb74c6310c03446a095bdcb0facf32efd661ca414ab80c7f6883385b59f68d2befd1512376
data/bin/git-game-show CHANGED
@@ -2,4 +2,22 @@
2
2
 
3
3
  require "git_game_show"
4
4
 
5
+ # Skip auto-update check when running explicit commands
6
+ # Only check when running without arguments or with --version
7
+ if ARGV.empty? || ARGV.include?('--version') || ARGV.include?('-v')
8
+ begin
9
+ # Load the updater if available
10
+ updater_path = File.join(File.dirname(__FILE__), "../lib/git_game_show/updater.rb")
11
+ require updater_path if File.exist?(updater_path)
12
+
13
+ # Auto-check for updates (only when running the welcome screen)
14
+ if defined?(GitGameShow::Updater) && ARGV.empty?
15
+ GitGameShow::Updater.check_for_updates
16
+ end
17
+ rescue => e
18
+ # Silent fail on update check
19
+ end
20
+ end
21
+
22
+ # Start the CLI
5
23
  GitGameShow::CLI.start(ARGV)
@@ -7,16 +7,23 @@ module GitGameShow
7
7
  desc 'version', 'Display Git Game Show version'
8
8
  def version
9
9
  puts "Git Game Show version #{GitGameShow::VERSION}"
10
+
11
+ # Check for updates if the Updater class exists
12
+ GitGameShow::Updater.check_for_updates if defined?(GitGameShow::Updater)
10
13
  end
11
14
 
12
15
  desc '', 'Show welcome screen'
13
16
  def welcome
14
17
  display_welcome_screen
15
18
 
19
+ # Check for updates if the Updater class exists
20
+ GitGameShow::Updater.check_for_updates if defined?(GitGameShow::Updater)
21
+
16
22
  prompt = TTY::Prompt.new
17
23
  choice = prompt.select("What would you like to do?", [
18
24
  {name: "Host a new game", value: :host},
19
25
  {name: "Join a game", value: :join},
26
+ {name: "Check for updates", value: :update},
20
27
  {name: "Exit", value: :exit}
21
28
  ])
22
29
 
@@ -25,6 +32,28 @@ module GitGameShow
25
32
  prompt_for_host_options
26
33
  when :join
27
34
  prompt_for_join_options
35
+ when :update
36
+ if defined?(GitGameShow::Updater)
37
+ # Force check for updates
38
+ current_version = GitGameShow::VERSION
39
+ puts "Current version: #{current_version}"
40
+ puts "Checking for updates..."
41
+
42
+ latest_version = GitGameShow::Updater.send(:fetch_latest_version)
43
+ if latest_version.nil?
44
+ puts "Unable to connect to RubyGems.org. Please check your internet connection."
45
+ elsif GitGameShow::Updater.send(:newer_version_available?, current_version, latest_version)
46
+ GitGameShow::Updater.send(:display_update_prompt, current_version, latest_version)
47
+ else
48
+ puts "✓ You already have the latest version (#{current_version})!".colorize(:green)
49
+ end
50
+
51
+ # Return to welcome screen after checking
52
+ welcome
53
+ else
54
+ puts "Update feature not available. Please update manually with 'gem update git_game_show'."
55
+ welcome
56
+ end
28
57
  when :exit
29
58
  puts "Thanks for playing Git Game Show!"
30
59
  exit(0)
@@ -32,7 +61,7 @@ module GitGameShow
32
61
  end
33
62
 
34
63
  desc 'host [OPTIONS]', 'Host a new game session'
35
- method_option :port, type: :numeric, default: GitGameShow::DEFAULT_CONFIG[:port],
64
+ method_option :port, type: :numeric, default: GitGameShow::DEFAULT_CONFIG[:internal_port],
36
65
  desc: 'Port to run the server on'
37
66
  method_option :password, type: :string,
38
67
  desc: 'Optional password for players to join (auto-generated if not provided)'
@@ -71,7 +100,7 @@ module GitGameShow
71
100
  end
72
101
 
73
102
  # Clear the screen
74
- clear_screen
103
+ display_ggs
75
104
 
76
105
  # Ask user which IP to use
77
106
  prompt = TTY::Prompt.new
@@ -94,6 +123,7 @@ module GitGameShow
94
123
  ip_choice = prompt.select("How should players connect to your game?", ip_choices)
95
124
 
96
125
  # Handle different connection options
126
+ external_port = options[:port] || GitGameShow::DEFAULT_CONFIG[:internal_port]
97
127
  case ip_choice[:type]
98
128
  when :local, :external
99
129
  ip = ip_choice[:ip]
@@ -101,7 +131,7 @@ module GitGameShow
101
131
  ip = prompt.ask("Enter your IP address or hostname:", required: true)
102
132
  when :tunnel
103
133
  # Clear the screen and show informative message about ngrok
104
- clear_screen
134
+ display_ggs
105
135
  puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
106
136
  puts "┃ NGROK TUNNEL SETUP ┃"
107
137
  puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
@@ -238,7 +268,7 @@ module GitGameShow
238
268
  auth_needed = auth_check.include?("auth") || auth_check.include?("authtoken") || auth_check.include?("ERR") || auth_check.include?("error")
239
269
 
240
270
  if auth_needed
241
- clear_screen
271
+ display_ggs
242
272
  puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
243
273
  puts "┃ NGROK AUTHORIZATION REQUIRED ┃"
244
274
  puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
@@ -323,9 +353,7 @@ module GitGameShow
323
353
  # Use the host with the ngrok-assigned port
324
354
  ip = host
325
355
  # Create a new port variable instead of modifying the frozen options hash
326
- ngrok_port = port.to_i
327
- # Log the port change
328
- puts "Ngrok assigned port: #{ngrok_port} (original port: #{options[:port]})"
356
+ external_port = port.to_i
329
357
 
330
358
  tunnel_url = public_url
331
359
 
@@ -334,12 +362,18 @@ module GitGameShow
334
362
  system("pkill -f ngrok > /dev/null 2>&1 || taskkill /F /IM ngrok.exe > /dev/null 2>&1")
335
363
  end
336
364
 
337
- clear_screen
365
+ display_ggs
366
+
338
367
  puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
339
368
  puts "┃ TUNNEL ESTABLISHED SUCCESSFULLY! ┃"
340
369
  puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
341
370
  puts "┃ • Your game is now accessible over the internet ┃"
342
- puts "┃ • The ngrok tunnel is running in the background ┃"
371
+ puts "┃ • The ngrok tunnel is running in the background: ┃"
372
+ puts "┃ ┃"
373
+ puts "┃ ngrok ip: #{ip.ljust(57)}┃"
374
+ puts "┃ ngrok port: #{external_port.to_s.ljust(57)}┃"
375
+ puts "┃ ngrok public URL: #{public_url.ljust(57)}┃"
376
+ puts "┃ ┃"
343
377
  puts "┃ • DO NOT close the terminal window until your game is finished ┃"
344
378
  puts "┃ • The tunnel will automatically close when you exit the game ┃"
345
379
  puts "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"
@@ -357,7 +391,7 @@ module GitGameShow
357
391
  end
358
392
 
359
393
  unless tunnel_url
360
- clear_screen
394
+ display_ggs
361
395
  puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
362
396
  puts "┃ TUNNEL SETUP FAILED ┃"
363
397
  puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
@@ -378,13 +412,13 @@ module GitGameShow
378
412
  ip = local_ip
379
413
  end
380
414
  rescue => e
381
- clear_screen
415
+ display_ggs
382
416
  puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
383
- puts "┃ ERROR SETTING UP NGROK TUNNEL ┃"
417
+ puts "┃ ERROR SETTING UP NGROK TUNNEL ┃"
384
418
  puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
385
- puts "┃ • An error occurred while trying to set up the ngrok tunnel ┃"
386
- puts "┃ • This is likely an authentication issue with ngrok ┃"
387
- puts "┃ • Falling back to local IP (players will only be able to join locally) ┃"
419
+ puts "┃ • An error occurred while trying to set up the ngrok tunnel ┃"
420
+ puts "┃ • This is likely an authentication issue with ngrok ┃"
421
+ puts "┃ • Falling back to local IP (players will only be able to join locally) ┃"
388
422
  puts "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"
389
423
  puts ""
390
424
  puts "Error details: #{e.message}"
@@ -396,10 +430,18 @@ module GitGameShow
396
430
  end
397
431
  end
398
432
 
399
- # Generate a secure join link with embedded password
400
- # If we have a ngrok tunnel, use the ngrok port, otherwise use the original port
401
- port_to_use = defined?(ngrok_port) ? ngrok_port : options[:port]
402
- secure_link = "gitgame://#{ip}:#{port_to_use}/#{URI.encode_www_form_component(password)}"
433
+ # Now ask for the port (after network setup is complete)
434
+ # Skip if ngrok assigned a port already
435
+ unless ip_choice[:type] == :tunnel
436
+ internal_port = prompt.ask("Which port would you like to use?",
437
+ convert: :int,
438
+ default: GitGameShow::DEFAULT_CONFIG[:internal_port])
439
+
440
+ # Update the server's port
441
+ server.instance_variable_set(:@port, internal_port)
442
+ end
443
+
444
+ secure_link = "gitgame://#{ip}:#{external_port}/#{URI.encode_www_form_component(password)}"
403
445
 
404
446
  # Start the server with the improved UI and pass the join link
405
447
  server.start_with_ui(secure_link)
@@ -422,13 +464,17 @@ module GitGameShow
422
464
  if secure_link.start_with?('gitgame://')
423
465
  uri = URI.parse(secure_link.sub('gitgame://', 'http://'))
424
466
  host = uri.host
425
- port = uri.port || GitGameShow::DEFAULT_CONFIG[:port]
467
+ port = uri.port || GitGameShow::DEFAULT_CONFIG[:internal_port]
426
468
  password = URI.decode_www_form_component(uri.path.sub('/', ''))
469
+
470
+ # Check if this is a secure (ngrok) connection from query params
471
+ is_secure = !uri.query.nil? && uri.query.include?('secure=')
427
472
  else
428
473
  # Legacy format - assume it's host:port
429
474
  host, port = secure_link.split(':')
430
- port ||= GitGameShow::DEFAULT_CONFIG[:port]
475
+ port ||= GitGameShow::DEFAULT_CONFIG[:internal_port]
431
476
  password = options[:password]
477
+ is_secure = false
432
478
 
433
479
  # If no password provided in legacy format, ask for it
434
480
  unless password
@@ -450,7 +496,8 @@ module GitGameShow
450
496
  host: host,
451
497
  port: port.to_i,
452
498
  password: password,
453
- name: name
499
+ name: name,
500
+ secure: is_secure
454
501
  )
455
502
 
456
503
  puts "=== Git Game Show Client ===".colorize(:green)
@@ -468,9 +515,21 @@ module GitGameShow
468
515
 
469
516
  private
470
517
 
471
- def display_welcome_screen
518
+ def display_ggs
472
519
  clear_screen
520
+ lines = [
521
+ " ██████╗ ".colorize(:red) + " ██████╗ ".colorize(:green) + " █████╗".colorize(:blue),
522
+ "██╔════╝ ".colorize(:red) + " ██╔════╝ ".colorize(:green) + " ██╔═══╝".colorize(:blue),
523
+ "██║ ███╗".colorize(:red) + " ██║ ███╗".colorize(:green) + " ███████╗".colorize(:blue),
524
+ "██║ ██║".colorize(:red) + " ██║ ██║".colorize(:green) + " ╚════██║".colorize(:blue),
525
+ "╚██████╔╝".colorize(:red) + " ╚██████╔╝".colorize(:green) + " ██████╔╝".colorize(:blue),
526
+ " ╚═════╝ ".colorize(:red) + " ╚═════╝ ".colorize(:green) + " ╚═════╝ ".colorize(:blue),
527
+ ]
528
+ lines.each { |line| puts line }
529
+ end
473
530
 
531
+ def display_game_logo
532
+ clear_screen
474
533
  puts " ██████╗ ██╗████████╗".colorize(:red) + " ██████╗ █████╗ ███╗ ███╗███████╗".colorize(:green)
475
534
  puts "██╔════╝ ██║╚══██╔══╝".colorize(:red) + " ██╔════╝ ██╔══██╗████╗ ████║██╔════╝".colorize(:green)
476
535
  puts "██║ ███╗██║ ██║ ".colorize(:red) + " ██║ ███╗███████║██╔████╔██║█████╗ ".colorize(:green)
@@ -484,32 +543,33 @@ module GitGameShow
484
543
  puts "╚════██║██╔══██║██║ ██║██║███╗██║".colorize(:blue)
485
544
  puts "██████╔╝██║ ██║╚██████╔╝╚███╔███╔╝".colorize(:blue)
486
545
  puts "╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ".colorize(:blue)
546
+ end
547
+
548
+ def display_welcome_screen
549
+ display_game_logo
487
550
 
488
551
  puts "\nWelcome to Git Game Show version #{GitGameShow::VERSION}!".colorize(:light_blue)
489
552
  puts "Test your team's Git knowledge with fun trivia games.\n\n"
490
553
  end
491
554
 
492
- def prompt_for_host_options
493
- prompt = TTY::Prompt.new
555
+ def prompt_for_host_options
556
+ prompt = TTY::Prompt.new
494
557
 
495
- repo_path = prompt.ask("Enter the path to the Git repository (leave empty for current directory):", default: '.')
496
- rounds = prompt.ask("How many rounds would you like to play? (1-10)",
497
- convert: :int,
498
- default: GitGameShow::DEFAULT_CONFIG[:rounds]) do |q|
499
- q.validate(/^([1-9]|10)$/, "Please enter a number between 1 and 10")
500
- end
501
- port = prompt.ask("Which port would you like to use?",
558
+ repo_path = prompt.ask("Enter the path to the Git repository (leave empty for current directory):", default: '.')
559
+ rounds = prompt.ask("How many rounds would you like to play? (1-10)",
502
560
  convert: :int,
503
- default: GitGameShow::DEFAULT_CONFIG[:port])
504
-
505
- # Call the host method with the provided options (password will be auto-generated)
506
- invoke :host, [], {
507
- repo_path: repo_path,
508
- rounds: rounds,
509
- port: port
510
- }
561
+ default: GitGameShow::DEFAULT_CONFIG[:rounds]) do |q|
562
+ q.validate(/^([1-9]|10)$/, "Please enter a number between 1 and 10")
511
563
  end
512
564
 
565
+ # Call the host method with the provided options (password will be auto-generated)
566
+ # Port will be asked after network setup
567
+ invoke :host, [], {
568
+ repo_path: repo_path,
569
+ rounds: rounds
570
+ }
571
+ end
572
+
513
573
  def prompt_for_join_options
514
574
  prompt = TTY::Prompt.new
515
575
 
@@ -111,7 +111,7 @@ module GitGameShow
111
111
 
112
112
  link_box_width = [@join_link.length + 6, @main_width - 10].min
113
113
  start_x = (@main_width - link_box_width) / 2
114
- start_y = 13
114
+ start_y = 8
115
115
 
116
116
  print @cursor.move_to(start_x, start_y)
117
117
  print "┌" + "─" * (link_box_width - 2) + "┐"