bard 0.65.0 → 0.66.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 846754c2ad0d14dc0df687db107e05ecad69a9122540fba07b2362b83ff7b4a0
4
- data.tar.gz: 04da3c9f2faa9d2d698d6d08442360a69bbe114e0333b6730257bc9b3ff18e35
3
+ metadata.gz: 1b9f7c09700f669c4d27c2d9dfa5661fc3b7eab6bb38f80fa09387af65dbfaa3
4
+ data.tar.gz: de2789065284a2506f3951f7d957b6e798d5af2ef03891540c3371ae9629e961
5
5
  SHA512:
6
- metadata.gz: e742ede7bf2afc73dd8e68e60991ef1b13a819df55b0adea253b58ba70e5102a0139bdb26fcd10e2fe51574cd7a69262224484f6b6855794d930e57bd6739ab1
7
- data.tar.gz: 17de7f6f053b646ccdf948197846f0890c2d765e86098a8b41b23d9063bfb376e16dd42bb912b7ad7ce65fc0fcfb84514b43fcac67dd187750f49d280f5c992e
6
+ metadata.gz: 3fa281ed15c4befefce3ee6035ccab28831c8ea2e619b108187c5cb94eb6da29ba53a7df6c50bd4910df50a0bd029d1734daf58de666bff7920c64a93f6f5d38
7
+ data.tar.gz: c7988b2f2f7287a4b74e6b1fb3f5d37aacb91c94741276d252df465213641056edb1906964c17368792b96d5a10b143658949a176b81e3dd2d8bb6bc54bc5ee9
data/lib/bard/base.rb CHANGED
@@ -2,6 +2,7 @@ require "thor"
2
2
  require "term/ansicolor"
3
3
  require "open3"
4
4
  require "uri"
5
+ require "bard/remote_command"
5
6
 
6
7
  class Bard::CLI < Thor
7
8
  include Term::ANSIColor
@@ -34,16 +35,7 @@ class Bard::CLI < Thor
34
35
 
35
36
  def ssh_command server_name, command, home: false
36
37
  server = @config.servers.fetch(server_name.to_sym)
37
- uri = URI.parse("ssh://#{server.ssh}")
38
- ssh_key = server.ssh_key ? "-i #{server.ssh_key} " : ""
39
- command = "#{server.env} #{command}" if server.env
40
- command = "cd #{server.path} && #{command}" unless home
41
- command = "ssh -tt #{ssh_key}#{"-p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} '#{command}'"
42
- if server.gateway
43
- uri = URI.parse("ssh://#{server.gateway}")
44
- command = "ssh -tt #{" -p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} \"#{command}\""
45
- end
46
- command
38
+ Bard::RemoteCommand.new(server, command, home).local_command
47
39
  end
48
40
 
49
41
  def copy direction, server_name, path, verbose: false
data/lib/bard/config.rb CHANGED
@@ -45,10 +45,10 @@ module Bard
45
45
  instance_eval source
46
46
  end
47
47
 
48
- attr_reader :servers
48
+ attr_reader :project_name, :servers
49
49
 
50
50
  def server key, &block
51
- @servers[key] ||= Server.new(@project_name, key)
51
+ @servers[key] ||= Server.new(project_name, key)
52
52
  @servers[key].instance_eval &block if block_given?
53
53
  @servers[key]
54
54
  end
@@ -0,0 +1,22 @@
1
+ module Bard
2
+ class RemoteCommand < Struct.new(:server, :command, :home)
3
+ def local_command
4
+ uri = URI.parse("ssh://#{server.ssh}")
5
+ ssh_key = server.ssh_key ? "-i #{server.ssh_key} " : ""
6
+ cmd = command
7
+ if server.env
8
+ cmd = "#{server.env} #{command}"
9
+ end
10
+ unless home
11
+ cmd = "cd #{server.path} && #{cmd}"
12
+ end
13
+ cmd = "ssh -tt #{ssh_key}#{"-p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} '#{cmd}'"
14
+ if server.gateway
15
+ uri = URI.parse("ssh://#{server.gateway}")
16
+ cmd = "ssh -tt #{" -p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} \"#{cmd}\""
17
+ end
18
+ cmd
19
+ end
20
+ end
21
+ end
22
+
data/lib/bard/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bard
2
- VERSION = "0.65.0"
2
+ VERSION = "0.66.0"
3
3
  end
4
4
 
data/lib/bard.rb CHANGED
@@ -7,6 +7,7 @@ require "bard/data"
7
7
  require "bard/github"
8
8
  require "bard/ping"
9
9
  require "bard/config"
10
+ require "bard/remote_command"
10
11
 
11
12
  class Bard::CLI < Thor
12
13
  include Thor::Actions
@@ -213,6 +214,16 @@ class Bard::CLI < Thor
213
214
  exit 1 if down_urls.any?
214
215
  end
215
216
 
217
+ desc "command <command> --on=production", "run the given command on the remote server"
218
+ method_options %w[on] => :string
219
+ def command command
220
+ default_from = @config.servers.key?(:production) ? "production" : "staging"
221
+ on = options.fetch(:on, default_from)
222
+ server = @config.servers[on.to_sym]
223
+ remote_command = Bard::RemoteCommand.new(server, command).local_command
224
+ run_crucial remote_command, verbose: true
225
+ end
226
+
216
227
  desc "master_key --from=production --to=local", "copy master key from from to to"
217
228
  method_options %w[from] => :string, %w[to] => :string
218
229
  def master_key
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.65.0
4
+ version: 0.66.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-14 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -157,6 +157,7 @@ files:
157
157
  - lib/bard/git.rb
158
158
  - lib/bard/github.rb
159
159
  - lib/bard/ping.rb
160
+ - lib/bard/remote_command.rb
160
161
  - lib/bard/version.rb
161
162
  - spec/bard/ci/github_actions_spec.rb
162
163
  - spec/bard_spec.rb