terminalwire-rails 0.3.0.alpha4 → 0.3.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d294202c20212330b3232e202bbba671291bf9366f7ca0d79fefd0299cfefcc
|
4
|
+
data.tar.gz: 7c7b0cb89f8f2a9b91163d36d0d8e1b7e5c20a3187505e71aa902aab3a9019aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 118f6c7f7b7a2fca1f5358d4d85d709dae82504cc4a0f5e958dc4a25fe188fe06c57fef6551d682de9e72493f680219993cdebecdeac05cfda4173f6305f2d41
|
7
|
+
data.tar.gz: 57224633096706f81f722e63d0579dec7afdfbfca1bc24414f2d3d185ad7804faedd806b170d87916ef133df5c9c8c7dd9cc80bb06952a530f2423bfd2efc761
|
data/lib/terminalwire/rails.rb
CHANGED
@@ -84,7 +84,7 @@ module Terminalwire
|
|
84
84
|
"An error occurred. Please try again."
|
85
85
|
end
|
86
86
|
|
87
|
-
def handle(adapter)
|
87
|
+
def handle(adapter:, env:)
|
88
88
|
logger.info "ThorServer: Running #{@cli_class.inspect}"
|
89
89
|
while message = adapter.read
|
90
90
|
case message
|
@@ -92,12 +92,27 @@ module Terminalwire
|
|
92
92
|
context = Terminalwire::Server::Context.new(adapter:, entitlement:)
|
93
93
|
|
94
94
|
begin
|
95
|
-
@cli_class.
|
95
|
+
@cli_class.terminalwire arguments:, context: do |cli|
|
96
|
+
cli.default_url_options = { host: env["HTTP_HOST"] }
|
97
|
+
end
|
96
98
|
context.exit
|
97
99
|
rescue StandardError => e
|
100
|
+
# Log the error
|
101
|
+
handler_error_message = <<~_
|
102
|
+
An error occured handling message in #{self.class.name}: #{e.inspect}
|
103
|
+
Error: #{e.message}
|
104
|
+
Backtrace: #{e.backtrace.join("\n")}
|
105
|
+
Handler: #{self.inspect}
|
106
|
+
Message: #{message.inspect}
|
107
|
+
_
|
108
|
+
|
109
|
+
::Rails.logger.error(handler_error_message)
|
110
|
+
# Report the error to Rails' notification system
|
111
|
+
::Rails.error.report(e, handled: true)
|
112
|
+
|
98
113
|
if ::Rails.application.config.consider_all_requests_local
|
99
114
|
# Show the full error message with stack trace in development
|
100
|
-
context.stderr.puts
|
115
|
+
context.stderr.puts handler_error_message
|
101
116
|
else
|
102
117
|
# Show a generic message in production
|
103
118
|
context.stderr.puts error_message
|
@@ -110,7 +125,41 @@ module Terminalwire
|
|
110
125
|
end
|
111
126
|
end
|
112
127
|
|
113
|
-
#
|
114
|
-
#
|
115
|
-
|
128
|
+
# If I move this, then the current production integration breaks because
|
129
|
+
# it wants `include Terminalwire::Thor`.
|
130
|
+
module Thor
|
131
|
+
class Shell < Terminalwire::Server::Thor::Shell
|
132
|
+
attr_reader :session
|
133
|
+
|
134
|
+
def initialize(context, *, **, &)
|
135
|
+
@session = Terminalwire::Rails::Session.new(context:)
|
136
|
+
super(context, *,**,&)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.included(base)
|
141
|
+
base.include Terminalwire::Server::Thor
|
142
|
+
base.extend ClassMethods
|
143
|
+
|
144
|
+
# I have to do this in a block to deal with some of Thor's DSL
|
145
|
+
base.class_eval do
|
146
|
+
protected
|
147
|
+
|
148
|
+
no_commands do
|
149
|
+
def_delegators :shell,
|
150
|
+
:session
|
151
|
+
|
152
|
+
include ::Rails.application.routes.url_helpers
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
module ClassMethods
|
158
|
+
def terminalwire(arguments:, context:)
|
159
|
+
dispatch(nil, arguments.dup, nil, shell: Shell.new(context)) do |instance|
|
160
|
+
yield instance if block_given?
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
116
165
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminalwire-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-02-13 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: terminalwire-server
|
@@ -16,14 +15,14 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - '='
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.0
|
18
|
+
version: 0.3.0
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - '='
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.3.0
|
25
|
+
version: 0.3.0
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: rails
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,7 +74,6 @@ metadata:
|
|
75
74
|
source_code_uri: https://github.com/terminalwire/ruby/tree/main/terminalwire-rails
|
76
75
|
changelog_uri: https://github.com/terminalwire/ruby/tags
|
77
76
|
funding_uri: https://terminalwire.com/funding
|
78
|
-
post_install_message:
|
79
77
|
rdoc_options: []
|
80
78
|
require_paths:
|
81
79
|
- lib
|
@@ -90,8 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
88
|
- !ruby/object:Gem::Version
|
91
89
|
version: '0'
|
92
90
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
94
|
-
signing_key:
|
91
|
+
rubygems_version: 3.6.2
|
95
92
|
specification_version: 4
|
96
93
|
summary: Ship a CLI for your web app. No API required.
|
97
94
|
test_files: []
|