bard 1.9.6 → 2.0.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.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -2
  3. data/CLAUDE.md +1 -1
  4. data/PLUGINS.md +31 -46
  5. data/bard.gemspec +2 -1
  6. data/features/ci.feature +1 -0
  7. data/features/data.feature +1 -0
  8. data/features/deploy.feature +1 -0
  9. data/features/deploy_git_workflow.feature +1 -0
  10. data/features/run.feature +1 -0
  11. data/features/step_definitions/bard_steps.rb +1 -0
  12. data/features/support/test_server.rb +3 -3
  13. data/lib/bard/cli.rb +9 -28
  14. data/lib/bard/command.rb +9 -88
  15. data/lib/bard/config.rb +38 -177
  16. data/lib/bard/copy.rb +28 -82
  17. data/lib/bard/plugins/data.rb +56 -0
  18. data/lib/bard/{ci → plugins/deploy/ci}/github_actions.rb +2 -2
  19. data/lib/bard/{ci → plugins/deploy/ci}/jenkins.rb +1 -1
  20. data/lib/bard/{ci → plugins/deploy/ci}/local.rb +1 -1
  21. data/lib/bard/{ci → plugins/deploy/ci}/runner.rb +3 -3
  22. data/lib/bard/{ci.rb → plugins/deploy/ci.rb} +1 -1
  23. data/lib/bard/plugins/deploy/ssh_strategy.rb +27 -0
  24. data/lib/bard/{deploy_strategy.rb → plugins/deploy/strategy.rb} +1 -4
  25. data/lib/bard/plugins/deploy.rb +240 -0
  26. data/lib/bard/{git.rb → plugins/git.rb} +6 -3
  27. data/lib/bard/{github.rb → plugins/github.rb} +2 -2
  28. data/lib/bard/{deploy_strategy/github_pages.rb → plugins/github_pages/strategy.rb} +3 -4
  29. data/lib/bard/plugins/github_pages.rb +11 -15
  30. data/lib/bard/plugins/hurt.rb +12 -4
  31. data/{install_files → lib/bard/plugins/install}/.github/dependabot.yml +2 -1
  32. data/{install_files → lib/bard/plugins/install}/.github/workflows/cache-ci.yml +1 -1
  33. data/{install_files → lib/bard/plugins/install}/.github/workflows/ci.yml +2 -2
  34. data/lib/bard/plugins/install.rb +7 -3
  35. data/lib/bard/plugins/open.rb +20 -0
  36. data/lib/bard/{ping.rb → plugins/ping/check.rb} +4 -4
  37. data/lib/bard/plugins/ping/target_methods.rb +23 -0
  38. data/lib/bard/plugins/ping.rb +8 -4
  39. data/lib/bard/plugins/run.rb +19 -0
  40. data/lib/bard/plugins/setup.rb +54 -0
  41. data/lib/bard/plugins/ssh/connection.rb +75 -0
  42. data/lib/bard/plugins/ssh/copy.rb +95 -0
  43. data/lib/bard/{ssh_server.rb → plugins/ssh/server.rb} +10 -42
  44. data/lib/bard/plugins/ssh/target_methods.rb +20 -0
  45. data/lib/bard/plugins/ssh.rb +10 -0
  46. data/lib/bard/plugins/url/target_methods.rb +23 -0
  47. data/lib/bard/plugins/url.rb +1 -0
  48. data/lib/bard/plugins/vim.rb +5 -4
  49. data/lib/bard/retryable.rb +25 -0
  50. data/lib/bard/target.rb +21 -230
  51. data/lib/bard/version.rb +1 -1
  52. data/lib/bard.rb +1 -3
  53. data/spec/acceptance/docker/Dockerfile +1 -1
  54. data/spec/bard/capability_spec.rb +8 -50
  55. data/spec/bard/ci/github_actions_spec.rb +1 -1
  56. data/spec/bard/ci/jenkins_spec.rb +1 -1
  57. data/spec/bard/ci/runner_spec.rb +3 -3
  58. data/spec/bard/ci_spec.rb +1 -1
  59. data/spec/bard/cli/ci_spec.rb +4 -23
  60. data/spec/bard/cli/data_spec.rb +7 -26
  61. data/spec/bard/cli/deploy_spec.rb +43 -40
  62. data/spec/bard/cli/hurt_spec.rb +2 -8
  63. data/spec/bard/cli/install_spec.rb +4 -10
  64. data/spec/bard/cli/master_key_spec.rb +5 -19
  65. data/spec/bard/cli/open_spec.rb +17 -35
  66. data/spec/bard/cli/ping_spec.rb +10 -25
  67. data/spec/bard/cli/run_spec.rb +10 -23
  68. data/spec/bard/cli/setup_spec.rb +10 -27
  69. data/spec/bard/cli/ssh_spec.rb +10 -25
  70. data/spec/bard/cli/stage_spec.rb +17 -32
  71. data/spec/bard/cli/vim_spec.rb +5 -11
  72. data/spec/bard/command_spec.rb +1 -10
  73. data/spec/bard/config_spec.rb +68 -116
  74. data/spec/bard/copy_spec.rb +54 -18
  75. data/spec/bard/deploy_strategy/ssh_spec.rb +65 -7
  76. data/spec/bard/deploy_strategy_spec.rb +1 -1
  77. data/spec/bard/dynamic_dsl_spec.rb +18 -98
  78. data/spec/bard/git_spec.rb +9 -5
  79. data/spec/bard/github_spec.rb +1 -1
  80. data/spec/bard/ping_spec.rb +5 -5
  81. data/spec/bard/ssh_copy_spec.rb +44 -0
  82. data/spec/bard/ssh_server_spec.rb +1 -98
  83. data/spec/bard/target_spec.rb +61 -108
  84. metadata +50 -124
  85. data/lib/bard/ci/retryable.rb +0 -27
  86. data/lib/bard/cli/ci.rb +0 -73
  87. data/lib/bard/cli/command.rb +0 -26
  88. data/lib/bard/cli/data.rb +0 -45
  89. data/lib/bard/cli/deploy.rb +0 -116
  90. data/lib/bard/cli/hurt.rb +0 -15
  91. data/lib/bard/cli/install.rb +0 -11
  92. data/lib/bard/cli/master_key.rb +0 -17
  93. data/lib/bard/cli/new.rb +0 -101
  94. data/lib/bard/cli/new_rails_template.rb +0 -197
  95. data/lib/bard/cli/open.rb +0 -18
  96. data/lib/bard/cli/ping.rb +0 -12
  97. data/lib/bard/cli/provision.rb +0 -34
  98. data/lib/bard/cli/run.rb +0 -26
  99. data/lib/bard/cli/setup.rb +0 -56
  100. data/lib/bard/cli/ssh.rb +0 -14
  101. data/lib/bard/cli/stage.rb +0 -35
  102. data/lib/bard/cli/vim.rb +0 -8
  103. data/lib/bard/default_config.rb +0 -35
  104. data/lib/bard/deploy_strategy/ssh.rb +0 -19
  105. data/lib/bard/deprecation.rb +0 -19
  106. data/lib/bard/github_pages.rb +0 -134
  107. data/lib/bard/plugin.rb +0 -100
  108. data/lib/bard/plugins/backup.rb +0 -19
  109. data/lib/bard/plugins/jenkins.rb +0 -6
  110. data/lib/bard/plugins/new.rb +0 -5
  111. data/lib/bard/plugins/provision.rb +0 -5
  112. data/lib/bard/provision/app.rb +0 -10
  113. data/lib/bard/provision/apt.rb +0 -16
  114. data/lib/bard/provision/authorizedkeys.rb +0 -25
  115. data/lib/bard/provision/data.rb +0 -27
  116. data/lib/bard/provision/deploy.rb +0 -10
  117. data/lib/bard/provision/http.rb +0 -16
  118. data/lib/bard/provision/logrotation.rb +0 -30
  119. data/lib/bard/provision/masterkey.rb +0 -18
  120. data/lib/bard/provision/mysql.rb +0 -22
  121. data/lib/bard/provision/passenger.rb +0 -37
  122. data/lib/bard/provision/repo.rb +0 -72
  123. data/lib/bard/provision/rvm.rb +0 -22
  124. data/lib/bard/provision/ssh.rb +0 -79
  125. data/lib/bard/provision/swapfile.rb +0 -23
  126. data/lib/bard/provision/user.rb +0 -42
  127. data/lib/bard/provision.rb +0 -16
  128. data/lib/bard/server.rb +0 -160
  129. data/spec/bard/cli/command_spec.rb +0 -50
  130. data/spec/bard/cli/new_spec.rb +0 -73
  131. data/spec/bard/cli/provision_spec.rb +0 -42
  132. data/spec/bard/deprecation_spec.rb +0 -281
  133. data/spec/bard/github_pages_spec.rb +0 -143
  134. data/spec/bard/plugin_spec.rb +0 -79
  135. data/spec/bard/provision/app_spec.rb +0 -33
  136. data/spec/bard/provision/apt_spec.rb +0 -39
  137. data/spec/bard/provision/authorizedkeys_spec.rb +0 -40
  138. data/spec/bard/provision/data_spec.rb +0 -54
  139. data/spec/bard/provision/deploy_spec.rb +0 -33
  140. data/spec/bard/provision/http_spec.rb +0 -57
  141. data/spec/bard/provision/logrotation_spec.rb +0 -34
  142. data/spec/bard/provision/masterkey_spec.rb +0 -63
  143. data/spec/bard/provision/mysql_spec.rb +0 -55
  144. data/spec/bard/provision/passenger_spec.rb +0 -81
  145. data/spec/bard/provision/repo_spec.rb +0 -208
  146. data/spec/bard/provision/rvm_spec.rb +0 -49
  147. data/spec/bard/provision/ssh_spec.rb +0 -242
  148. data/spec/bard/provision/swapfile_spec.rb +0 -33
  149. data/spec/bard/provision/user_spec.rb +0 -103
  150. data/spec/bard/provision_spec.rb +0 -28
  151. data/spec/bard/server_spec.rb +0 -127
  152. /data/lib/bard/{ci → plugins/deploy/ci}/state.rb +0 -0
  153. /data/{install_files → lib/bard/plugins/install}/apt_dependencies.rb +0 -0
  154. /data/{install_files → lib/bard/plugins/install}/ci +0 -0
  155. /data/{install_files → lib/bard/plugins/install}/setup +0 -0
  156. /data/{install_files → lib/bard/plugins/install}/specified_bundler.rb +0 -0
  157. /data/{install_files → lib/bard/plugins/install}/specified_ruby.rb +0 -0
data/lib/bard/target.rb CHANGED
@@ -1,23 +1,14 @@
1
- require "uri"
2
1
  require "bard/command"
3
- require "bard/copy"
4
- require "bard/deploy_strategy"
5
- require "bard/deprecation"
6
2
 
7
3
  module Bard
8
4
  class Target
9
5
  attr_reader :key, :config
10
- attr_accessor :server
11
6
 
12
7
  def initialize(key, config)
13
8
  @key = key
14
9
  @config = config
15
10
  @capabilities = []
16
- @ping_urls = []
17
- @strategy_options_hash = {}
18
- @deploy_strategy = nil
19
11
  @path = nil
20
- @server = nil
21
12
  end
22
13
 
23
14
  # Capability tracking
@@ -31,234 +22,25 @@ module Bard
31
22
 
32
23
  def require_capability!(capability)
33
24
  unless has_capability?(capability)
34
- error_message = case capability
35
- when :ssh
36
- "SSH not configured for this target"
37
- when :ping
38
- "Ping URL not configured for this target"
39
- else
40
- "#{capability} capability not configured for this target"
41
- end
42
- raise error_message
25
+ raise "#{capability} capability not configured for this target"
43
26
  end
44
27
  end
45
28
 
46
- # SSH configuration
47
- def ssh(uri_or_false = nil, **options)
48
- if uri_or_false.nil?
49
- # Getter - return false if explicitly disabled, otherwise return server
50
- return @ssh_disabled ? false : @server
51
- elsif uri_or_false == false
52
- # Disable SSH
53
- @server = nil
54
- @ssh_disabled = true
55
- @capabilities.delete(:ssh)
56
- else
57
- # Enable SSH
58
- require "bard/ssh_server"
59
- @server = SSHServer.new(uri_or_false, **options)
60
- @path = options[:path] if options[:path]
61
- @gateway = options[:gateway] if options[:gateway]
62
- @ssh_key = options[:ssh_key] if options[:ssh_key]
63
- @env = options[:env] if options[:env]
64
- enable_capability(:ssh)
65
-
66
- # Set SSH as default deployment strategy if none set
67
- @deploy_strategy ||= :ssh
68
-
69
- # Auto-configure ping from hostname
70
- hostname = @server.hostname
71
- ping("https://#{hostname}") if hostname
72
- end
73
- end
74
-
75
- def ssh_uri
76
- server&.ssh_uri
77
- end
78
-
79
- # Path configuration
80
- def path(new_path = nil)
81
- if new_path
82
- Deprecation.warn "Separate `path` call is deprecated; pass as keyword argument to `ssh` instead, e.g., `ssh \"user@host\", path: \"#{new_path}\"` (will be removed in v2.0)"
83
- @path = new_path
84
- else
85
- @path || config.project_name
86
- end
29
+ def path
30
+ @path || config.project_name
87
31
  end
88
32
 
89
- # Deprecated separate setter methods - use ssh(..., option: value) instead
90
- def gateway(value = nil)
91
- if value
92
- Deprecation.warn "Separate `gateway` call is deprecated; pass as keyword argument to `ssh` instead, e.g., `ssh \"user@host\", gateway: \"#{value}\"` (will be removed in v2.0)"
93
- @gateway = value
94
- else
95
- @gateway
96
- end
97
- end
98
-
99
- def ssh_key(value = nil)
100
- if value
101
- Deprecation.warn "Separate `ssh_key` call is deprecated; pass as keyword argument to `ssh` instead, e.g., `ssh \"user@host\", ssh_key: \"#{value}\"` (will be removed in v2.0)"
102
- @ssh_key = value
103
- else
104
- @ssh_key
105
- end
106
- end
107
-
108
- def env(value = nil)
109
- if value
110
- Deprecation.warn "Separate `env` call is deprecated; pass as keyword argument to `ssh` instead, e.g., `ssh \"user@host\", env: \"#{value}\"` (will be removed in v2.0)"
111
- @env = value
112
- else
113
- @env
114
- end
115
- end
116
-
117
- # Ping configuration
118
- def ping(*urls)
119
- if urls.empty?
120
- # Getter - normalize URLs like Server does
121
- @ping_urls.map { |url| normalize_ping(url) }
122
- elsif urls.first == false
123
- # Disable ping
124
- @ping_urls = []
125
- @capabilities.delete(:ping)
126
- else
127
- # Enable ping
128
- @ping_urls = urls.flatten
129
- enable_capability(:ping)
130
- end
131
- end
132
-
133
- def ping_urls
134
- @ping_urls
135
- end
136
-
137
- def ping!
138
- require_capability!(:ping)
139
- require "bard/ping"
140
- failed_urls = Bard::Ping.call(self)
141
- if failed_urls.any?
142
- raise "Ping failed for: #{failed_urls.join(', ')}"
143
- end
144
- end
145
-
146
- def open
147
- require_capability!(:ping)
148
- system "open #{ping_urls.first}"
149
- end
150
-
151
- # Deploy strategy
152
- attr_reader :deploy_strategy
153
-
154
- # GitHub Pages deployment configuration
155
- def github_pages(url = nil)
156
- if url.nil?
157
- # Getter
158
- @github_pages_url
159
- else
160
- # Setter
161
- @deploy_strategy = :github_pages
162
- @github_pages_url = url
163
- enable_capability(:github_pages)
164
- end
165
- end
166
-
167
- # Deprecated strategy configuration methods
168
- def strategy(name)
169
- Deprecation.warn "`strategy` is deprecated; use the strategy method directly, e.g., `#{name} \"url\"` instead of `strategy :#{name}` (will be removed in v2.0)"
170
- @deploy_strategy = name
171
- end
172
-
173
- def option(key, value)
174
- Deprecation.warn "`option` is deprecated; pass options as keyword arguments to the strategy method, e.g., `jets \"url\", #{key}: #{value.inspect}` (will be removed in v2.0)"
175
- @strategy_options_hash[@deploy_strategy] ||= {}
176
- @strategy_options_hash[@deploy_strategy][key] = value
177
- end
178
-
179
- def strategy_options(strategy_name)
180
- @strategy_options_hash[strategy_name] || {}
181
- end
182
-
183
- def deploy_strategy_instance
184
- raise "No deployment strategy configured for target #{key}" unless @deploy_strategy
185
-
186
- strategy_class = DeployStrategy[@deploy_strategy]
187
- raise "Unknown deployment strategy: #{@deploy_strategy}" unless strategy_class
188
-
189
- strategy_class.new(self)
190
- end
191
-
192
- # Dynamic strategy DSL via method_missing
193
- def method_missing(method, *args, **kwargs, &block)
194
- strategy_class = DeployStrategy[method]
195
-
196
- if strategy_class
197
- # This is a deployment strategy
198
- @deploy_strategy = method
199
-
200
- # Store options
201
- @strategy_options_hash[method] = kwargs
202
-
203
- # Auto-configure ping if first arg is a URL
204
- if args.first && args.first.to_s =~ /^https?:\/\//
205
- ping(args.first)
206
- end
207
-
208
- # Call the strategy's initializer if it wants to configure the target
209
- # (This will be handled by the strategy class)
210
- else
211
- super
212
- end
213
- end
214
-
215
- def respond_to_missing?(method, include_private = false)
216
- DeployStrategy[method] || super
217
- end
218
-
219
- # Remote command execution
220
33
  def run!(command, home: false, verbose: false, quiet: false, capture: false)
221
- require_capability!(:ssh)
222
- result = Command.run!(command, on: self, home: home, verbose: verbose, quiet: quiet)
34
+ result = Command.run!(command, verbose:, quiet:)
223
35
  result if capture
224
36
  end
225
37
 
226
38
  def run(command, home: false, verbose: false, quiet: false)
227
- require_capability!(:ssh)
228
- Command.run(command, on: self, home: home, verbose: verbose, quiet: quiet)
39
+ Command.run(command, verbose:, quiet:)
229
40
  end
230
41
 
231
42
  def exec!(command, home: false)
232
- require_capability!(:ssh)
233
- Command.exec!(command, on: self, home: home)
234
- end
235
-
236
- # File transfer
237
- def copy_file(path, to:, verbose: false)
238
- require_capability!(:ssh)
239
- to.require_capability!(:ssh) if to.respond_to?(:require_capability!)
240
- Copy.file(path, from: self, to: to, verbose: verbose)
241
- end
242
-
243
- def copy_dir(path, to:, verbose: false)
244
- require_capability!(:ssh)
245
- to.require_capability!(:ssh) if to.respond_to?(:require_capability!)
246
- Copy.dir(path, from: self, to: to, verbose: verbose)
247
- end
248
-
249
- # URI methods for compatibility
250
- def scp_uri(file_path = nil)
251
- full_path = "/#{path}"
252
- full_path += "/#{file_path}" if file_path
253
- URI::Generic.build(scheme: "scp", userinfo: server.user, host: server.host, port: server.port.to_i, path: full_path)
254
- end
255
-
256
- def rsync_uri(file_path = nil)
257
- uri = ssh_uri
258
- str = "#{uri.user}@#{uri.host}"
259
- str += ":#{path}"
260
- str += "/#{file_path}" if file_path
261
- str
43
+ Command.exec!(command)
262
44
  end
263
45
 
264
46
  # Utility methods
@@ -278,13 +60,22 @@ module Bard
278
60
  end
279
61
  end
280
62
 
281
- private
63
+ def ==(other)
64
+ return false unless other.is_a?(Bard::Target)
65
+ comparable_state == other.comparable_state
66
+ end
67
+ alias_method :eql?, :==
68
+
69
+ def hash
70
+ comparable_state.hash
71
+ end
72
+
73
+ protected
282
74
 
283
- def normalize_ping(value)
284
- return nil if value == false || value.nil?
285
- normalized = value.to_s
286
- normalized = "https://#{normalized}" unless normalized.start_with?("http")
287
- normalized
75
+ def comparable_state
76
+ (instance_variables - [:@key, :@config]).sort.map do |ivar|
77
+ [ivar, instance_variable_get(ivar)]
78
+ end
288
79
  end
289
80
  end
290
81
  end
data/lib/bard/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bard
2
- VERSION = "1.9.6"
2
+ VERSION = "2.0.0"
3
3
  end
4
4
 
data/lib/bard.rb CHANGED
@@ -1,3 +1 @@
1
- module Bard
2
- end
3
-
1
+ require "bard/cli"
@@ -1,4 +1,4 @@
1
- FROM ubuntu:22.04
1
+ FROM ubuntu:24.04
2
2
 
3
3
  # Prevent interactive prompts
4
4
  ENV DEBIAN_FRONTEND=noninteractive
@@ -1,5 +1,7 @@
1
1
  require "spec_helper"
2
2
  require "bard/target"
3
+ require "bard/plugins/ssh/target_methods"
4
+ require "bard/plugins/ping/target_methods"
3
5
 
4
6
  describe "Capability System" do
5
7
  let(:config) { double("config", project_name: "testapp") }
@@ -13,9 +15,9 @@ describe "Capability System" do
13
15
 
14
16
  it "can enable multiple capabilities" do
15
17
  target.enable_capability(:ssh)
16
- target.enable_capability(:ping)
18
+ target.enable_capability(:url)
17
19
  expect(target.has_capability?(:ssh)).to be true
18
- expect(target.has_capability?(:ping)).to be true
20
+ expect(target.has_capability?(:url)).to be true
19
21
  end
20
22
  end
21
23
 
@@ -38,59 +40,15 @@ describe "Capability System" do
38
40
 
39
41
  it "raises an error if capability is not enabled" do
40
42
  expect { target.require_capability!(:ssh) }
41
- .to raise_error(/SSH not configured for this target/)
42
- end
43
-
44
- it "provides custom error message for ping capability" do
45
- expect { target.require_capability!(:ping) }
46
- .to raise_error(/Ping URL not configured for this target/)
47
- end
48
-
49
- it "provides generic error message for unknown capabilities" do
50
- expect { target.require_capability!(:unknown) }
51
- .to raise_error(/unknown capability not configured for this target/)
43
+ .to raise_error(/ssh capability not configured for this target/)
52
44
  end
53
45
  end
54
46
 
55
47
  describe "capability dependency checking" do
56
- context "SSH-dependent methods" do
57
- it "run! requires SSH capability" do
58
- expect { target.run!("ls") }
59
- .to raise_error(/SSH not configured/)
60
- end
61
-
62
- it "run requires SSH capability" do
63
- expect { target.run("ls") }
64
- .to raise_error(/SSH not configured/)
65
- end
66
-
67
- it "exec! requires SSH capability" do
68
- expect { target.exec!("ls") }
69
- .to raise_error(/SSH not configured/)
70
- end
71
-
72
- it "copy_file requires SSH capability" do
73
- other_target = Bard::Target.new(:staging, config)
74
- expect { target.copy_file("test.txt", to: other_target) }
75
- .to raise_error(/SSH not configured/)
76
- end
77
-
78
- it "copy_dir requires SSH capability" do
79
- other_target = Bard::Target.new(:staging, config)
80
- expect { target.copy_dir("test/", to: other_target) }
81
- .to raise_error(/SSH not configured/)
82
- end
83
- end
84
-
85
- context "Ping-dependent methods" do
86
- it "ping! requires ping capability" do
48
+ context "URL-dependent methods" do
49
+ it "ping! requires url capability" do
87
50
  expect { target.ping! }
88
- .to raise_error(/Ping URL not configured/)
89
- end
90
-
91
- it "open requires ping capability" do
92
- expect { target.open }
93
- .to raise_error(/Ping URL not configured/)
51
+ .to raise_error(/url capability not configured/)
94
52
  end
95
53
  end
96
54
  end
@@ -1,5 +1,5 @@
1
1
  require "spec_helper"
2
- require "bard/ci/github_actions"
2
+ require "bard/plugins/deploy/ci/github_actions"
3
3
 
4
4
  BASE_URL = "https://api.github.com/repos/botandrosedesign/metrc"
5
5
 
@@ -1,5 +1,5 @@
1
1
  require "spec_helper"
2
- require "bard/ci/jenkins"
2
+ require "bard/plugins/deploy/ci/jenkins"
3
3
 
4
4
  RSpec.describe Bard::CI::Jenkins do
5
5
  let(:jenkins) { described_class.new("test-project", "master", "abc123") }
@@ -1,4 +1,4 @@
1
- require "bard/ci/runner"
1
+ require "bard/plugins/deploy/ci/runner"
2
2
 
3
3
  RSpec.describe Bard::CI::Runner do
4
4
  describe ".runners" do
@@ -9,8 +9,8 @@ RSpec.describe Bard::CI::Runner do
9
9
 
10
10
  describe ".[]" do
11
11
  before do
12
- require "bard/ci/local"
13
- require "bard/ci/github_actions"
12
+ require "bard/plugins/deploy/ci/local"
13
+ require "bard/plugins/deploy/ci/github_actions"
14
14
  end
15
15
 
16
16
  it "looks up runners by name" do
data/spec/bard/ci_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "bard/ci"
1
+ require "bard/plugins/deploy/ci"
2
2
 
3
3
  describe Bard::CI do
4
4
  subject { described_class.new("tracker", "master") }
@@ -1,33 +1,14 @@
1
1
  require "spec_helper"
2
2
  require "bard/cli"
3
- require "bard/cli/ci"
4
- require "thor"
5
3
  require "ostruct"
6
4
 
7
- class TestCICLI < Thor
8
- include Bard::CLI::CI
9
-
10
- attr_reader :options
11
-
12
- def initialize
13
- super
14
- @options = {}
15
- end
16
-
17
- def project_name
18
- "test_project"
19
- end
20
-
21
- def config
22
- @config ||= OpenStruct.new(ci: nil)
23
- end
24
- end
25
-
26
- describe Bard::CLI::CI do
27
- let(:cli) { TestCICLI.new }
5
+ describe "bard ci" do
6
+ let(:cli) { Bard::CLI.new }
28
7
  let(:ci_runner) { double("ci_runner") }
29
8
 
30
9
  before do
10
+ allow(cli).to receive(:config).and_return(OpenStruct.new(ci: nil))
11
+ allow(cli).to receive(:project_name).and_return("test_project")
31
12
  allow(cli).to receive(:puts)
32
13
  allow(cli).to receive(:print)
33
14
  allow(cli).to receive(:exit)
@@ -1,35 +1,15 @@
1
1
  require "spec_helper"
2
2
  require "bard/cli"
3
- require "bard/cli/data"
4
3
 
5
- require "thor"
6
-
7
- require "term/ansicolor"
8
-
9
- class TestCLI < Thor
10
- include Bard::CLI::Data
11
- include Term::ANSIColor
12
-
13
- attr_reader :config
14
-
15
- def initialize
16
- @config = {}
17
- end
18
-
19
- def options
20
- {}
21
- end
22
- end
23
-
24
- describe Bard::CLI::Data do
25
- let(:cli) { TestCLI.new }
4
+ describe "bard data" do
5
+ let(:cli) { Bard::CLI.new }
26
6
 
27
7
  it "should have a data command" do
28
8
  expect(cli).to respond_to(:data)
29
9
  end
30
10
 
31
11
  context "data" do
32
- let(:from) { double("from", key: :production, run!: nil, copy_file: nil, copy_dir: nil) }
12
+ let(:from) { double("from", key: :production, run!: nil, require_capability!: nil) }
33
13
  let(:to) { double("to", key: :local, run!: nil) }
34
14
 
35
15
  let(:config) do
@@ -42,17 +22,18 @@ describe Bard::CLI::Data do
42
22
  before do
43
23
  allow(cli).to receive(:config).and_return(config)
44
24
  allow(cli).to receive(:options).and_return({from: "production", to: "local"})
25
+ allow(cli).to receive(:puts)
45
26
  end
46
27
 
47
28
  it "should run the data command" do
48
29
  expect(from).to receive(:run!).with("bin/rake db:dump")
49
- expect(from).to receive(:copy_file).with("db/data.sql.gz", to: to, verbose: true)
30
+ expect(Bard::Copy).to receive(:file).with("db/data.sql.gz", from: from, to: to, verbose: true)
50
31
  expect(to).to receive(:run!).with("bin/rake db:load")
51
32
  cli.data
52
33
  end
53
34
 
54
35
  context "pushing to production" do
55
- let(:to) { double("to", key: :production, ping: ["https://example.com"]) }
36
+ let(:to) { double("to", key: :production, url: "https://example.com", run!: nil, require_capability!: nil) }
56
37
 
57
38
  before do
58
39
  allow(cli).to receive(:options).and_return({from: "local", to: "production"})
@@ -68,7 +49,7 @@ describe Bard::CLI::Data do
68
49
  it "should allow pushing to production if the user confirms" do
69
50
  expect(cli).to receive(:ask).and_return("https://example.com")
70
51
  expect(from).to receive(:run!).with("bin/rake db:dump")
71
- expect(from).to receive(:copy_file).with("db/data.sql.gz", to: to, verbose: true)
52
+ expect(Bard::Copy).to receive(:file).with("db/data.sql.gz", from: from, to: to, verbose: true)
72
53
  expect(to).to receive(:run!).with("bin/rake db:load")
73
54
  cli.data
74
55
  end