bard 2.0.3 → 2.1.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: 1dd77cf990608d404bbcc5cca1dd5ee5bfbb2310a08dd723495c237f66221bdd
|
|
4
|
+
data.tar.gz: 1d5e3e825ffeea97b828f7719e116a9ab506599c7f298282af7e2d4e20d5f257
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2bd4f528655c8b6e9a8d675a3a2ead6201f5b11c8c12a6abfcc011ca47fb998a80a73487e9273bfecb0ba670b2aaea8efcd1e74f2f0d6cbb7273c475169a881e
|
|
7
|
+
data.tar.gz: 812897863cd76a56f76af06cf9eaec0fa43fda334dcd5f5a43487309b823b97100dd199a57dede44a94439c6b67e0235364870e5bd623c24f68e2f3df8823726
|
|
@@ -5,17 +5,16 @@ require "bard/plugins/ssh"
|
|
|
5
5
|
module Bard
|
|
6
6
|
class DeployStrategy
|
|
7
7
|
class SSH < DeployStrategy
|
|
8
|
-
def deploy(clone: nil, branch:
|
|
8
|
+
def deploy(clone: nil, branch: "master", force: false)
|
|
9
9
|
target.require_capability!(:ssh)
|
|
10
10
|
|
|
11
11
|
if clone
|
|
12
|
-
target.run! "git clone git@github.com:botandrosedesign/#{clone} #{target.path}", home: true
|
|
12
|
+
target.run! "git clone --branch #{branch} git@github.com:botandrosedesign/#{clone} #{target.path}", home: true
|
|
13
13
|
Bard::Copy.file "config/master.key", from: target.config[:local], to: target
|
|
14
14
|
elsif force
|
|
15
15
|
target.run! "git fetch origin #{branch}"
|
|
16
16
|
target.run! "git checkout -f origin/#{branch}"
|
|
17
17
|
else
|
|
18
|
-
branch ||= target.instance_variable_get(:@branch) || "master"
|
|
19
18
|
target.run! "git pull --ff-only origin #{branch}"
|
|
20
19
|
end
|
|
21
20
|
|
data/lib/bard/plugins/deploy.rb
CHANGED
|
@@ -121,9 +121,23 @@ class Bard::CLI
|
|
|
121
121
|
|
|
122
122
|
target = config[:staging]
|
|
123
123
|
strategy = target.deploy_strategy_instance
|
|
124
|
-
strategy.deploy(branch: branch, force: true)
|
|
125
124
|
|
|
126
|
-
|
|
125
|
+
if staging_provisioned?(target)
|
|
126
|
+
strategy.deploy(branch: branch, force: true)
|
|
127
|
+
puts green("Stage Succeeded")
|
|
128
|
+
|
|
129
|
+
else # clone from scratch
|
|
130
|
+
puts yellow("Staging site for #{project_name} not found — provisioning it from scratch…")
|
|
131
|
+
strategy.deploy(clone: project_name, branch: branch)
|
|
132
|
+
puts green("Stage Succeeded")
|
|
133
|
+
|
|
134
|
+
puts "#{project_name} was rebuilt from scratch; its database and files are empty."
|
|
135
|
+
if $stdin.tty? && !no?("Restore #{project_name}'s data from production now? (bard data --from production --to staging) [Y/n]")
|
|
136
|
+
invoke :data, [], from: "production", to: "staging"
|
|
137
|
+
else
|
|
138
|
+
puts "Run #{yellow("bard data --from production --to staging")} to restore its data."
|
|
139
|
+
end
|
|
140
|
+
end
|
|
127
141
|
|
|
128
142
|
ping :staging
|
|
129
143
|
rescue Bard::Command::Error => e
|
|
@@ -131,6 +145,12 @@ class Bard::CLI
|
|
|
131
145
|
exit 1
|
|
132
146
|
end
|
|
133
147
|
|
|
148
|
+
no_commands do
|
|
149
|
+
def staging_provisioned?(target)
|
|
150
|
+
!!target.run("test -e #{target.path}/.git", home: true)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
134
154
|
option :"local-ci", type: :boolean
|
|
135
155
|
option :ci, type: :string
|
|
136
156
|
option :status, type: :boolean
|
data/lib/bard/version.rb
CHANGED
data/spec/bard/cli/stage_spec.rb
CHANGED
|
@@ -17,10 +17,12 @@ describe "bard stage" do
|
|
|
17
17
|
allow(cli).to receive(:ping)
|
|
18
18
|
allow(cli).to receive(:green).and_return("")
|
|
19
19
|
allow(cli).to receive(:red).and_return("")
|
|
20
|
-
allow(cli).to receive(:yellow)
|
|
20
|
+
allow(cli).to receive(:yellow) { |s| s }
|
|
21
21
|
allow(Bard::Git).to receive(:current_branch).and_return("main")
|
|
22
22
|
allow(config).to receive(:[]).with(:staging).and_return(staging_server)
|
|
23
23
|
allow(config).to receive(:[]).with(:production).and_return(production_server)
|
|
24
|
+
allow(cli).to receive(:project_name).and_return("acme")
|
|
25
|
+
allow(cli).to receive(:staging_provisioned?).and_return(true)
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
describe "#stage" do
|
|
@@ -28,6 +30,49 @@ describe "bard stage" do
|
|
|
28
30
|
expect(cli).to respond_to(:stage)
|
|
29
31
|
end
|
|
30
32
|
|
|
33
|
+
context "when the staging site has been reaped" do
|
|
34
|
+
before do
|
|
35
|
+
allow(cli).to receive(:staging_provisioned?).and_return(false)
|
|
36
|
+
allow(cli).to receive(:invoke)
|
|
37
|
+
allow($stdin).to receive(:tty?).and_return(false)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "provisions from scratch by cloning and checking out the branch" do
|
|
41
|
+
expect(staging_strategy).to receive(:deploy).with(clone: "acme", branch: "main")
|
|
42
|
+
cli.stage
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "restores data from production by default (Enter/no decline)" do
|
|
46
|
+
allow(staging_strategy).to receive(:deploy)
|
|
47
|
+
allow($stdin).to receive(:tty?).and_return(true)
|
|
48
|
+
allow(cli).to receive(:no?).and_return(false)
|
|
49
|
+
expect(cli).to receive(:invoke).with(:data, [], from: "production", to: "staging")
|
|
50
|
+
cli.stage
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "skips the restore when the user declines" do
|
|
54
|
+
allow(staging_strategy).to receive(:deploy)
|
|
55
|
+
allow($stdin).to receive(:tty?).and_return(true)
|
|
56
|
+
allow(cli).to receive(:no?).and_return(true)
|
|
57
|
+
expect(cli).not_to receive(:invoke)
|
|
58
|
+
cli.stage
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "prints restore instructions when non-interactive" do
|
|
62
|
+
allow(staging_strategy).to receive(:deploy)
|
|
63
|
+
expect(cli).to receive(:puts).with(/bard data --from production --to staging/)
|
|
64
|
+
cli.stage
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "when the staging site already exists" do
|
|
69
|
+
it "does not prompt to restore data" do
|
|
70
|
+
allow($stdin).to receive(:tty?).and_return(true)
|
|
71
|
+
expect(cli).not_to receive(:invoke)
|
|
72
|
+
cli.stage
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
31
76
|
context "when production server is defined" do
|
|
32
77
|
it "pushes branch and stages it" do
|
|
33
78
|
expect(cli).to receive(:run!).with("git push -u origin main", verbose: true)
|
|
@@ -38,15 +38,13 @@ describe Bard::DeployStrategy::SSH do
|
|
|
38
38
|
strategy.deploy
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
it "
|
|
42
|
-
target.instance_variable_set(:@branch, "main")
|
|
43
|
-
|
|
41
|
+
it "pulls the given branch when one is specified" do
|
|
44
42
|
expect(target).to receive(:run!)
|
|
45
43
|
.with("git pull --ff-only origin main")
|
|
46
44
|
|
|
47
45
|
allow(target).to receive(:run!).with(/bin\/setup/)
|
|
48
46
|
|
|
49
|
-
strategy.deploy
|
|
47
|
+
strategy.deploy(branch: "main")
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
context "with force: true" do
|
|
@@ -68,9 +66,9 @@ describe Bard::DeployStrategy::SSH do
|
|
|
68
66
|
allow(Bard::Copy).to receive(:file)
|
|
69
67
|
end
|
|
70
68
|
|
|
71
|
-
it "clones the repository" do
|
|
69
|
+
it "clones the repository, defaulting to master" do
|
|
72
70
|
expect(target).to receive(:run!)
|
|
73
|
-
.with("git clone git@github.com:botandrosedesign/testapp /app", home: true)
|
|
71
|
+
.with("git clone --branch master git@github.com:botandrosedesign/testapp /app", home: true)
|
|
74
72
|
allow(target).to receive(:run!).with("bin/setup")
|
|
75
73
|
allow(target).to receive(:run!).with("bard setup")
|
|
76
74
|
|
|
@@ -104,6 +102,18 @@ describe Bard::DeployStrategy::SSH do
|
|
|
104
102
|
|
|
105
103
|
strategy.deploy(clone: "testapp")
|
|
106
104
|
end
|
|
105
|
+
|
|
106
|
+
it "clones the requested branch directly when provisioning from scratch" do
|
|
107
|
+
allow(target).to receive(:run!).with("bin/setup")
|
|
108
|
+
allow(target).to receive(:run!).with("bard setup")
|
|
109
|
+
|
|
110
|
+
expect(target).to receive(:run!)
|
|
111
|
+
.with("git clone --branch feature-x git@github.com:botandrosedesign/testapp /app", home: true)
|
|
112
|
+
expect(target).not_to receive(:run!).with(/git fetch/)
|
|
113
|
+
expect(target).not_to receive(:run!).with(/git checkout/)
|
|
114
|
+
|
|
115
|
+
strategy.deploy(clone: "testapp", branch: "feature-x")
|
|
116
|
+
end
|
|
107
117
|
end
|
|
108
118
|
end
|
|
109
119
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-07-
|
|
10
|
+
date: 2026-07-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: thor
|