terminalwire 0.2.5 → 0.3.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +67 -5
- data/exe/terminalwire +1 -1
- data/exe/terminalwire-exec +1 -1
- metadata +9 -171
- data/.rspec +0 -3
- data/CHANGELOG.md +0 -5
- data/CODE_OF_CONDUCT.md +0 -132
- data/LICENSE.txt +0 -9
- data/README.md +0 -45
- data/examples/exec/localrails +0 -2
- data/lib/generators/terminalwire/install/USAGE +0 -9
- data/lib/generators/terminalwire/install/install_generator.rb +0 -38
- data/lib/generators/terminalwire/install/templates/application_terminal.rb.tt +0 -21
- data/lib/generators/terminalwire/install/templates/bin/terminalwire +0 -2
- data/lib/generators/terminalwire/install/templates/main_terminal.rb +0 -40
- data/lib/terminalwire/adapter.rb +0 -53
- data/lib/terminalwire/cache.rb +0 -114
- data/lib/terminalwire/client/entitlement/environment_variables.rb +0 -26
- data/lib/terminalwire/client/entitlement/paths.rb +0 -97
- data/lib/terminalwire/client/entitlement/policy.rb +0 -117
- data/lib/terminalwire/client/entitlement/schemes.rb +0 -26
- data/lib/terminalwire/client/entitlement.rb +0 -9
- data/lib/terminalwire/client/exec.rb +0 -44
- data/lib/terminalwire/client/handler.rb +0 -67
- data/lib/terminalwire/client/resource.rb +0 -204
- data/lib/terminalwire/client/server_license_verification.rb +0 -74
- data/lib/terminalwire/client.rb +0 -30
- data/lib/terminalwire/logging.rb +0 -8
- data/lib/terminalwire/rails.rb +0 -69
- data/lib/terminalwire/server/context.rb +0 -80
- data/lib/terminalwire/server/resource.rb +0 -120
- data/lib/terminalwire/server.rb +0 -63
- data/lib/terminalwire/thor.rb +0 -67
- data/lib/terminalwire/transport.rb +0 -58
- data/lib/terminalwire/version.rb +0 -5
- data/lib/terminalwire.rb +0 -56
- data/sig/terminalwire.rbs +0 -4
data/lib/terminalwire/thor.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
|
3
|
-
module Terminalwire
|
4
|
-
module Thor
|
5
|
-
class Shell < ::Thor::Shell::Basic
|
6
|
-
extend Forwardable
|
7
|
-
|
8
|
-
# Encapsulates all of the IO resources for a Terminalwire adapter.
|
9
|
-
attr_reader :context, :session
|
10
|
-
|
11
|
-
def_delegators :context,
|
12
|
-
:stdin, :stdout, :stderr
|
13
|
-
|
14
|
-
def initialize(context, *, **, &)
|
15
|
-
@context = context
|
16
|
-
@session = Terminalwire::Rails::Session.new(context:)
|
17
|
-
super(*,**,&)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.included(base)
|
22
|
-
base.extend ClassMethods
|
23
|
-
|
24
|
-
# I have to do this in a block to deal with some of Thor's DSL
|
25
|
-
base.class_eval do
|
26
|
-
extend Forwardable
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
no_commands do
|
31
|
-
def_delegators :shell,
|
32
|
-
:context, :session
|
33
|
-
def_delegators :context,
|
34
|
-
:stdout, :stdin, :stderr, :browser
|
35
|
-
def_delegators :stdout,
|
36
|
-
:puts, :print
|
37
|
-
def_delegators :stdin,
|
38
|
-
:gets, :getpass
|
39
|
-
|
40
|
-
# Prints text to the standard error stream.
|
41
|
-
def warn(...)
|
42
|
-
stderr.puts(...)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Prints text to the standard error stream and exits the program.
|
46
|
-
def fail(...)
|
47
|
-
stderr.puts(...)
|
48
|
-
context.exit 1
|
49
|
-
ensure
|
50
|
-
super
|
51
|
-
end
|
52
|
-
# Feels more naturual to call `client.files` etc. from
|
53
|
-
# the serve since it's more apparent that it's a client.
|
54
|
-
alias :client :context
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
module ClassMethods
|
60
|
-
def start(given_args = ARGV, config = {})
|
61
|
-
context = config.delete(:context)
|
62
|
-
config[:shell] = Shell.new(context) if context
|
63
|
-
super(given_args, config)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
require 'async/websocket/client'
|
3
|
-
|
4
|
-
module Terminalwire
|
5
|
-
module Transport
|
6
|
-
class Base
|
7
|
-
def self.connect(url)
|
8
|
-
raise NotImplementedError, "Subclass must implement .connect"
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.listen(url)
|
12
|
-
raise NotImplementedError, "Subclass must implement .listen"
|
13
|
-
end
|
14
|
-
|
15
|
-
def read
|
16
|
-
raise NotImplementedError, "Subclass must implement #read"
|
17
|
-
end
|
18
|
-
|
19
|
-
def write(data)
|
20
|
-
raise NotImplementedError, "Subclass must implement #write"
|
21
|
-
end
|
22
|
-
|
23
|
-
def close
|
24
|
-
raise NotImplementedError, "Subclass must implement #close"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class WebSocket < Base
|
29
|
-
def self.connect(url)
|
30
|
-
uri = URI(url)
|
31
|
-
endpoint = Async::HTTP::Endpoint.parse(uri)
|
32
|
-
adapter = Async::WebSocket::Client.connect(endpoint)
|
33
|
-
new(adapter)
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.listen(url)
|
37
|
-
# This would need to be implemented with a WebSocket server library
|
38
|
-
raise NotImplementedError, "WebSocket server not implemented"
|
39
|
-
end
|
40
|
-
|
41
|
-
def initialize(websocket)
|
42
|
-
@websocket = websocket
|
43
|
-
end
|
44
|
-
|
45
|
-
def read
|
46
|
-
@websocket.read&.buffer
|
47
|
-
end
|
48
|
-
|
49
|
-
def write(data)
|
50
|
-
@websocket.write(data)
|
51
|
-
end
|
52
|
-
|
53
|
-
def close
|
54
|
-
@websocket.close
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/lib/terminalwire/version.rb
DELETED
data/lib/terminalwire.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "terminalwire/version"
|
4
|
-
|
5
|
-
require 'forwardable'
|
6
|
-
require 'uri'
|
7
|
-
require 'zeitwerk'
|
8
|
-
|
9
|
-
require 'async'
|
10
|
-
require 'async/http/endpoint'
|
11
|
-
require 'async/websocket/client'
|
12
|
-
require 'async/websocket/adapters/rack'
|
13
|
-
require 'uri-builder'
|
14
|
-
|
15
|
-
module Terminalwire
|
16
|
-
class Error < StandardError; end
|
17
|
-
|
18
|
-
# Zeitwerk loader for the Terminalwire gem.
|
19
|
-
Loader = Zeitwerk::Loader.for_gem.tap do |loader|
|
20
|
-
loader.ignore("#{__dir__}/generators")
|
21
|
-
loader.setup
|
22
|
-
end
|
23
|
-
|
24
|
-
# Used by Terminalwire client to connect to Terminalire.com for license
|
25
|
-
# validations, etc.
|
26
|
-
TERMINALWIRE_URL = "https://terminalwire.com".freeze
|
27
|
-
def self.url = URI.build(TERMINALWIRE_URL)
|
28
|
-
|
29
|
-
module Resource
|
30
|
-
class Base
|
31
|
-
attr_reader :name, :adapter
|
32
|
-
|
33
|
-
def initialize(name, adapter)
|
34
|
-
@name = name.to_s
|
35
|
-
@adapter = adapter
|
36
|
-
end
|
37
|
-
|
38
|
-
def connect; end
|
39
|
-
def disconnect; end
|
40
|
-
|
41
|
-
def fail(response, **data)
|
42
|
-
respond(status: "failure", response:, **data)
|
43
|
-
end
|
44
|
-
|
45
|
-
def succeed(response, **data)
|
46
|
-
respond(status: "success", response:, **data)
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def respond(**response)
|
52
|
-
adapter.write(event: "resource", name: @name, **response)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/sig/terminalwire.rbs
DELETED