terminalwire-core 0.3.0.alpha2 → 0.3.0.alpha4
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/terminalwire/binary.rb +52 -0
- data/lib/terminalwire/shells.rb +140 -0
- data/lib/terminalwire/transport.rb +0 -1
- data/lib/terminalwire/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b12cf1c4b51a6a25992e408aab4b1b48cd9aaca9249e7b6764bfdc57829c1d1
|
4
|
+
data.tar.gz: 6e19084a9e846efa2cc394b4f902658d239466a032afb40b6f3962f1c1c784d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b9b084d349b22a9e18903701fe8b6bb8d8539367e5d5be10a537f5e0d7a5aa09d998ce5fc513a077ee09659680f28af99d901b7887c623720493c8c193a2092
|
7
|
+
data.tar.gz: 450f602a9473c6604d157243f1a2a0ae105008238e38b4707f884fafb8d9a0118eb8c38504f82a7d09782c46819b759cdb40ca74a96be0ad1c66fceb327fde10
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module Terminalwire
|
5
|
+
# Generates Terminalwire binary file stubs. These files then run using
|
6
|
+
# the `terminalwire-exec` command.
|
7
|
+
class Binary
|
8
|
+
SHEBANG = "#!/usr/bin/env terminalwire-exec".freeze
|
9
|
+
|
10
|
+
ASSIGNABLE_KEYS = %w[url]
|
11
|
+
|
12
|
+
attr_reader :url
|
13
|
+
|
14
|
+
def initialize(url: nil)
|
15
|
+
self.url = url if url
|
16
|
+
end
|
17
|
+
|
18
|
+
def url=(value)
|
19
|
+
@url = URI(value)
|
20
|
+
end
|
21
|
+
|
22
|
+
def body
|
23
|
+
<<~BASH
|
24
|
+
#{SHEBANG}
|
25
|
+
url: "#{url.to_s}"
|
26
|
+
BASH
|
27
|
+
end
|
28
|
+
|
29
|
+
def assign(**hash)
|
30
|
+
ASSIGNABLE_KEYS.each do |key|
|
31
|
+
public_send "#{key}=", hash[key] if hash.key? key
|
32
|
+
end
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# Writes the binary to the given path.
|
37
|
+
def write(path)
|
38
|
+
File.open(path, "w") do |file|
|
39
|
+
file.write body
|
40
|
+
file.chmod 0755
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.open(path)
|
45
|
+
new.assign **YAML.safe_load_file(path)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.write(url:, to:)
|
49
|
+
new(url: url).write to
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
module Terminalwire
|
2
|
+
module Shells
|
3
|
+
# This is used to detect what the user is running for a shell. Terminalwire then
|
4
|
+
# then uses this information to determine what files to write to for the root policy.
|
5
|
+
#
|
6
|
+
class Shell
|
7
|
+
attr_reader :name, :login_files, :interactive_files, :logout_files
|
8
|
+
|
9
|
+
def initialize(name)
|
10
|
+
@name = name
|
11
|
+
@login_files = Set.new
|
12
|
+
@interactive_files = Set.new
|
13
|
+
@logout_files = Set.new
|
14
|
+
end
|
15
|
+
|
16
|
+
class Configuration
|
17
|
+
attr_reader :shell
|
18
|
+
|
19
|
+
def initialize(shell, &block)
|
20
|
+
@shell = shell
|
21
|
+
instance_eval(&block) if block_given?
|
22
|
+
end
|
23
|
+
|
24
|
+
def login_file(*paths)
|
25
|
+
shell.login_files.merge paths.flatten
|
26
|
+
end
|
27
|
+
alias :login_files :login_file
|
28
|
+
|
29
|
+
def interactive_file(*paths)
|
30
|
+
shell.interactive_files.merge paths.flatten
|
31
|
+
end
|
32
|
+
alias :interactive_files :interactive_file
|
33
|
+
|
34
|
+
def logout_file(*paths)
|
35
|
+
shell.logout_files.merge paths.flatten
|
36
|
+
end
|
37
|
+
alias :logout_files :logout_file
|
38
|
+
end
|
39
|
+
|
40
|
+
def configure(&block)
|
41
|
+
Configuration.new(self, &block).shell
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Encapsulates a collection of shells.
|
46
|
+
class Collection
|
47
|
+
attr_reader :shells
|
48
|
+
include Enumerable
|
49
|
+
|
50
|
+
def initialize
|
51
|
+
@shells = []
|
52
|
+
end
|
53
|
+
|
54
|
+
def shell(name, &)
|
55
|
+
shells << Shell.new(name).configure(&)
|
56
|
+
end
|
57
|
+
|
58
|
+
def each(&)
|
59
|
+
shells.each(&)
|
60
|
+
end
|
61
|
+
|
62
|
+
def login_files
|
63
|
+
shells.flat_map { |shell| shell.login_files.to_a }.reject(&:empty?)
|
64
|
+
end
|
65
|
+
|
66
|
+
def interactive_files
|
67
|
+
shells.flat_map { |shell| shell.interactive_files.to_a }.reject(&:empty?)
|
68
|
+
end
|
69
|
+
|
70
|
+
def logout_files
|
71
|
+
shells.flat_map { |shell| shell.logout_files.to_a }.reject(&:empty?)
|
72
|
+
end
|
73
|
+
|
74
|
+
def names
|
75
|
+
shells.map(&:name)
|
76
|
+
end
|
77
|
+
|
78
|
+
def find_by_shell(name)
|
79
|
+
shells.find { |shell| shell.name == name }
|
80
|
+
end
|
81
|
+
|
82
|
+
def find_by_shell_path(path)
|
83
|
+
find_by_shell(File.basename(path))
|
84
|
+
end
|
85
|
+
|
86
|
+
def files
|
87
|
+
login_files + interactive_files + logout_files
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.configure(&block)
|
91
|
+
Collection.new.tap do |collection|
|
92
|
+
collection.instance_eval(&block) if block_given?
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
All = Collection.configure do
|
98
|
+
shell "bash" do
|
99
|
+
login_files %w[~/.bash_profile ~/.bash_login ~/.profile]
|
100
|
+
interactive_file "~/.bashrc"
|
101
|
+
logout_file "~/.bash_logout"
|
102
|
+
end
|
103
|
+
|
104
|
+
shell "zsh" do
|
105
|
+
login_files %w[~/.zprofile ~/.zshenv]
|
106
|
+
interactive_file "~/.zshrc"
|
107
|
+
logout_file "~/.zlogout"
|
108
|
+
end
|
109
|
+
|
110
|
+
shell "sh" do
|
111
|
+
login_files %w[~/.profile]
|
112
|
+
end
|
113
|
+
|
114
|
+
shell "dash" do
|
115
|
+
login_files %w[~/.profile]
|
116
|
+
end
|
117
|
+
|
118
|
+
shell "fish" do
|
119
|
+
interactive_file "~/.config/fish/config.fish"
|
120
|
+
end
|
121
|
+
|
122
|
+
shell "ksh" do
|
123
|
+
login_files %w[~/.profile]
|
124
|
+
interactive_file "~/.kshrc"
|
125
|
+
end
|
126
|
+
|
127
|
+
shell "csh" do
|
128
|
+
login_files %w[~/.cshrc ~/.login]
|
129
|
+
interactive_file "~/.cshrc"
|
130
|
+
logout_file "~/.logout"
|
131
|
+
end
|
132
|
+
|
133
|
+
shell "tcsh" do
|
134
|
+
login_files %w[~/.cshrc ~/.login]
|
135
|
+
interactive_file "~/.cshrc"
|
136
|
+
logout_file "~/.logout"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
data/lib/terminalwire/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminalwire-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0.
|
4
|
+
version: 0.3.0.alpha4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-23 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: async-websocket
|
@@ -117,8 +118,10 @@ files:
|
|
117
118
|
- lib/terminalwire-core.rb
|
118
119
|
- lib/terminalwire.rb
|
119
120
|
- lib/terminalwire/adapter.rb
|
121
|
+
- lib/terminalwire/binary.rb
|
120
122
|
- lib/terminalwire/cache.rb
|
121
123
|
- lib/terminalwire/logging.rb
|
124
|
+
- lib/terminalwire/shells.rb
|
122
125
|
- lib/terminalwire/transport.rb
|
123
126
|
- lib/terminalwire/version.rb
|
124
127
|
homepage: https://terminalwire.com/ruby
|
@@ -130,6 +133,7 @@ metadata:
|
|
130
133
|
source_code_uri: https://github.com/terminalwire/ruby
|
131
134
|
changelog_uri: https://github.com/terminalwire/ruby/tags
|
132
135
|
funding_uri: https://terminalwire.com/funding
|
136
|
+
post_install_message:
|
133
137
|
rdoc_options: []
|
134
138
|
require_paths:
|
135
139
|
- lib
|
@@ -144,7 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
148
|
- !ruby/object:Gem::Version
|
145
149
|
version: '0'
|
146
150
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
151
|
+
rubygems_version: 3.5.9
|
152
|
+
signing_key:
|
148
153
|
specification_version: 4
|
149
154
|
summary: Ship a CLI for your web app. No API required.
|
150
155
|
test_files: []
|