git_game_show 0.1.3 → 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 +4 -4
- data/lib/git_game_show/cli.rb +70 -50
- data/lib/git_game_show/game_server.rb +1 -1
- data/lib/git_game_show/player_client.rb +192 -191
- data/lib/git_game_show/updater.rb +14 -14
- data/lib/git_game_show/version.rb +1 -1
- data/lib/git_game_show.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2e16a5db208a5da525ed9c104ff9ca6a04b3ee1277c0463b1d6a4ae92e358a5
|
4
|
+
data.tar.gz: 17400bb69a005c1f30fee70e33eeff6937bc29237b745f12368e54863ebc3ef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76b2747d64550026843890bd0ac940a9808e77d60dfe33cd9c521f65aad826bbdd57cfa530f309318912a21e0b246d4c062935483ff3e1036a74c5f4bf1f7cb8
|
7
|
+
data.tar.gz: 12a34d4b1371eb806af69ce0c2feb6e7135ae66aa7b275c1d0f730eb74c6310c03446a095bdcb0facf32efd661ca414ab80c7f6883385b59f68d2befd1512376
|
data/lib/git_game_show/cli.rb
CHANGED
@@ -7,7 +7,7 @@ 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
|
-
|
10
|
+
|
11
11
|
# Check for updates if the Updater class exists
|
12
12
|
GitGameShow::Updater.check_for_updates if defined?(GitGameShow::Updater)
|
13
13
|
end
|
@@ -15,7 +15,7 @@ module GitGameShow
|
|
15
15
|
desc '', 'Show welcome screen'
|
16
16
|
def welcome
|
17
17
|
display_welcome_screen
|
18
|
-
|
18
|
+
|
19
19
|
# Check for updates if the Updater class exists
|
20
20
|
GitGameShow::Updater.check_for_updates if defined?(GitGameShow::Updater)
|
21
21
|
|
@@ -38,7 +38,7 @@ module GitGameShow
|
|
38
38
|
current_version = GitGameShow::VERSION
|
39
39
|
puts "Current version: #{current_version}"
|
40
40
|
puts "Checking for updates..."
|
41
|
-
|
41
|
+
|
42
42
|
latest_version = GitGameShow::Updater.send(:fetch_latest_version)
|
43
43
|
if latest_version.nil?
|
44
44
|
puts "Unable to connect to RubyGems.org. Please check your internet connection."
|
@@ -47,7 +47,7 @@ module GitGameShow
|
|
47
47
|
else
|
48
48
|
puts "✓ You already have the latest version (#{current_version})!".colorize(:green)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
# Return to welcome screen after checking
|
52
52
|
welcome
|
53
53
|
else
|
@@ -61,7 +61,7 @@ module GitGameShow
|
|
61
61
|
end
|
62
62
|
|
63
63
|
desc 'host [OPTIONS]', 'Host a new game session'
|
64
|
-
method_option :port, type: :numeric, default: GitGameShow::DEFAULT_CONFIG[:
|
64
|
+
method_option :port, type: :numeric, default: GitGameShow::DEFAULT_CONFIG[:internal_port],
|
65
65
|
desc: 'Port to run the server on'
|
66
66
|
method_option :password, type: :string,
|
67
67
|
desc: 'Optional password for players to join (auto-generated if not provided)'
|
@@ -100,7 +100,7 @@ module GitGameShow
|
|
100
100
|
end
|
101
101
|
|
102
102
|
# Clear the screen
|
103
|
-
|
103
|
+
display_ggs
|
104
104
|
|
105
105
|
# Ask user which IP to use
|
106
106
|
prompt = TTY::Prompt.new
|
@@ -123,6 +123,7 @@ module GitGameShow
|
|
123
123
|
ip_choice = prompt.select("How should players connect to your game?", ip_choices)
|
124
124
|
|
125
125
|
# Handle different connection options
|
126
|
+
external_port = options[:port] || GitGameShow::DEFAULT_CONFIG[:internal_port]
|
126
127
|
case ip_choice[:type]
|
127
128
|
when :local, :external
|
128
129
|
ip = ip_choice[:ip]
|
@@ -130,7 +131,7 @@ module GitGameShow
|
|
130
131
|
ip = prompt.ask("Enter your IP address or hostname:", required: true)
|
131
132
|
when :tunnel
|
132
133
|
# Clear the screen and show informative message about ngrok
|
133
|
-
|
134
|
+
display_ggs
|
134
135
|
puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
|
135
136
|
puts "┃ NGROK TUNNEL SETUP ┃"
|
136
137
|
puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
|
@@ -267,7 +268,7 @@ module GitGameShow
|
|
267
268
|
auth_needed = auth_check.include?("auth") || auth_check.include?("authtoken") || auth_check.include?("ERR") || auth_check.include?("error")
|
268
269
|
|
269
270
|
if auth_needed
|
270
|
-
|
271
|
+
display_ggs
|
271
272
|
puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
|
272
273
|
puts "┃ NGROK AUTHORIZATION REQUIRED ┃"
|
273
274
|
puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
|
@@ -352,9 +353,7 @@ module GitGameShow
|
|
352
353
|
# Use the host with the ngrok-assigned port
|
353
354
|
ip = host
|
354
355
|
# Create a new port variable instead of modifying the frozen options hash
|
355
|
-
|
356
|
-
# Log the port change
|
357
|
-
puts "Ngrok assigned port: #{ngrok_port} (original port: #{options[:port]})"
|
356
|
+
external_port = port.to_i
|
358
357
|
|
359
358
|
tunnel_url = public_url
|
360
359
|
|
@@ -363,12 +362,18 @@ module GitGameShow
|
|
363
362
|
system("pkill -f ngrok > /dev/null 2>&1 || taskkill /F /IM ngrok.exe > /dev/null 2>&1")
|
364
363
|
end
|
365
364
|
|
366
|
-
|
365
|
+
display_ggs
|
366
|
+
|
367
367
|
puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
|
368
368
|
puts "┃ TUNNEL ESTABLISHED SUCCESSFULLY! ┃"
|
369
369
|
puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
|
370
370
|
puts "┃ • Your game is now accessible over the internet ┃"
|
371
|
-
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 "┃ ┃"
|
372
377
|
puts "┃ • DO NOT close the terminal window until your game is finished ┃"
|
373
378
|
puts "┃ • The tunnel will automatically close when you exit the game ┃"
|
374
379
|
puts "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"
|
@@ -386,7 +391,7 @@ module GitGameShow
|
|
386
391
|
end
|
387
392
|
|
388
393
|
unless tunnel_url
|
389
|
-
|
394
|
+
display_ggs
|
390
395
|
puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
|
391
396
|
puts "┃ TUNNEL SETUP FAILED ┃"
|
392
397
|
puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
|
@@ -407,13 +412,13 @@ module GitGameShow
|
|
407
412
|
ip = local_ip
|
408
413
|
end
|
409
414
|
rescue => e
|
410
|
-
|
415
|
+
display_ggs
|
411
416
|
puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
|
412
|
-
puts "┃ ERROR SETTING UP NGROK TUNNEL
|
417
|
+
puts "┃ ERROR SETTING UP NGROK TUNNEL ┃"
|
413
418
|
puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"
|
414
|
-
puts "┃ • An error occurred while trying to set up the ngrok tunnel
|
415
|
-
puts "┃ • This is likely an authentication issue with ngrok
|
416
|
-
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) ┃"
|
417
422
|
puts "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"
|
418
423
|
puts ""
|
419
424
|
puts "Error details: #{e.message}"
|
@@ -425,16 +430,18 @@ module GitGameShow
|
|
425
430
|
end
|
426
431
|
end
|
427
432
|
|
428
|
-
#
|
429
|
-
#
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
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)}"
|
438
445
|
|
439
446
|
# Start the server with the improved UI and pass the join link
|
440
447
|
server.start_with_ui(secure_link)
|
@@ -457,15 +464,15 @@ module GitGameShow
|
|
457
464
|
if secure_link.start_with?('gitgame://')
|
458
465
|
uri = URI.parse(secure_link.sub('gitgame://', 'http://'))
|
459
466
|
host = uri.host
|
460
|
-
port = uri.port || GitGameShow::DEFAULT_CONFIG[:
|
467
|
+
port = uri.port || GitGameShow::DEFAULT_CONFIG[:internal_port]
|
461
468
|
password = URI.decode_www_form_component(uri.path.sub('/', ''))
|
462
|
-
|
469
|
+
|
463
470
|
# Check if this is a secure (ngrok) connection from query params
|
464
471
|
is_secure = !uri.query.nil? && uri.query.include?('secure=')
|
465
472
|
else
|
466
473
|
# Legacy format - assume it's host:port
|
467
474
|
host, port = secure_link.split(':')
|
468
|
-
port ||= GitGameShow::DEFAULT_CONFIG[:
|
475
|
+
port ||= GitGameShow::DEFAULT_CONFIG[:internal_port]
|
469
476
|
password = options[:password]
|
470
477
|
is_secure = false
|
471
478
|
|
@@ -508,9 +515,21 @@ module GitGameShow
|
|
508
515
|
|
509
516
|
private
|
510
517
|
|
511
|
-
def
|
518
|
+
def display_ggs
|
512
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
|
513
530
|
|
531
|
+
def display_game_logo
|
532
|
+
clear_screen
|
514
533
|
puts " ██████╗ ██╗████████╗".colorize(:red) + " ██████╗ █████╗ ███╗ ███╗███████╗".colorize(:green)
|
515
534
|
puts "██╔════╝ ██║╚══██╔══╝".colorize(:red) + " ██╔════╝ ██╔══██╗████╗ ████║██╔════╝".colorize(:green)
|
516
535
|
puts "██║ ███╗██║ ██║ ".colorize(:red) + " ██║ ███╗███████║██╔████╔██║█████╗ ".colorize(:green)
|
@@ -524,32 +543,33 @@ module GitGameShow
|
|
524
543
|
puts "╚════██║██╔══██║██║ ██║██║███╗██║".colorize(:blue)
|
525
544
|
puts "██████╔╝██║ ██║╚██████╔╝╚███╔███╔╝".colorize(:blue)
|
526
545
|
puts "╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ".colorize(:blue)
|
546
|
+
end
|
547
|
+
|
548
|
+
def display_welcome_screen
|
549
|
+
display_game_logo
|
527
550
|
|
528
551
|
puts "\nWelcome to Git Game Show version #{GitGameShow::VERSION}!".colorize(:light_blue)
|
529
552
|
puts "Test your team's Git knowledge with fun trivia games.\n\n"
|
530
553
|
end
|
531
554
|
|
532
|
-
|
533
|
-
|
555
|
+
def prompt_for_host_options
|
556
|
+
prompt = TTY::Prompt.new
|
534
557
|
|
535
|
-
|
536
|
-
|
537
|
-
convert: :int,
|
538
|
-
default: GitGameShow::DEFAULT_CONFIG[:rounds]) do |q|
|
539
|
-
q.validate(/^([1-9]|10)$/, "Please enter a number between 1 and 10")
|
540
|
-
end
|
541
|
-
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)",
|
542
560
|
convert: :int,
|
543
|
-
default: GitGameShow::DEFAULT_CONFIG[:
|
544
|
-
|
545
|
-
# Call the host method with the provided options (password will be auto-generated)
|
546
|
-
invoke :host, [], {
|
547
|
-
repo_path: repo_path,
|
548
|
-
rounds: rounds,
|
549
|
-
port: port
|
550
|
-
}
|
561
|
+
default: GitGameShow::DEFAULT_CONFIG[:rounds]) do |q|
|
562
|
+
q.validate(/^([1-9]|10)$/, "Please enter a number between 1 and 10")
|
551
563
|
end
|
552
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
|
+
|
553
573
|
def prompt_for_join_options
|
554
574
|
prompt = TTY::Prompt.new
|
555
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 =
|
114
|
+
start_y = 8
|
115
115
|
|
116
116
|
print @cursor.move_to(start_x, start_y)
|
117
117
|
print "┌" + "─" * (link_box_width - 2) + "┐"
|