bard 2.0.1 → 2.0.2
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/bard/plugins/setup.rb +50 -29
- data/lib/bard/version.rb +1 -1
- data/spec/bard/cli/setup_spec.rb +29 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a1541cf273c6f77dc3fe0910f17aff570de984eb1858ffb97267c5fc6be80709
|
|
4
|
+
data.tar.gz: a02d6f359c62fa2bddd91dcd5052069d9901414011107fa0c98dbfcf674f7323
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 788e7863ff3543dc464dbe7f84ae70e8931017a99feed5bfcb00492204afeec60ead608cbaec06be2a4521055021d27577ef75abfa17ee688c6790d4a51b6d0f
|
|
7
|
+
data.tar.gz: e726331d4aec855d5ee6727a2ce09435f92ae42d083ee38afe4d08685da23c6f45a173e1d4b58f10a2803d7bbe92f2927ec1fc632e9d1ef2507299d62fe107f0
|
data/lib/bard/plugins/setup.rb
CHANGED
|
@@ -5,35 +5,7 @@ class Bard::CLI
|
|
|
5
5
|
desc "setup", "installs app in nginx"
|
|
6
6
|
def setup
|
|
7
7
|
path = "/etc/nginx/sites-available/#{project_name}"
|
|
8
|
-
system "sudo tee #{path} >/dev/null <<-'EOF'
|
|
9
|
-
upstream puma {
|
|
10
|
-
server 127.0.0.1:3000 fail_timeout=5;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
server {
|
|
14
|
-
listen 80;
|
|
15
|
-
server_name #{nginx_server_name};
|
|
16
|
-
root #{Dir.pwd}/public;
|
|
17
|
-
|
|
18
|
-
try_files $uri @app;
|
|
19
|
-
|
|
20
|
-
location @app {
|
|
21
|
-
proxy_pass http://puma;
|
|
22
|
-
proxy_set_header Host $host;
|
|
23
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
24
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
25
|
-
proxy_set_header X-Forwarded-Proto $scheme;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
location ~* \\-[0-9a-f]\\{64\\}\\.(ico|css|js|gif|jpe?g|png|webp)$ {
|
|
29
|
-
access_log off;
|
|
30
|
-
expires max;
|
|
31
|
-
add_header Cache-Control public;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
gzip_static on;
|
|
35
|
-
}
|
|
36
|
-
EOF"
|
|
8
|
+
system "sudo tee #{path} >/dev/null <<-'EOF'\n#{nginx_config}EOF"
|
|
37
9
|
|
|
38
10
|
dest_path = path.sub("sites-available", "sites-enabled")
|
|
39
11
|
system "sudo ln -sf #{path} #{dest_path}" if !File.exist?(dest_path)
|
|
@@ -42,6 +14,55 @@ EOF"
|
|
|
42
14
|
end
|
|
43
15
|
|
|
44
16
|
no_commands do
|
|
17
|
+
def nginx_config
|
|
18
|
+
case ENV["RAILS_ENV"]
|
|
19
|
+
when "production", "staging" then nginx_production_config
|
|
20
|
+
else nginx_development_config
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def nginx_development_config
|
|
25
|
+
<<~EOF
|
|
26
|
+
server {
|
|
27
|
+
include /etc/nginx/snippets/common.conf;
|
|
28
|
+
server_name #{nginx_server_name};
|
|
29
|
+
root #{Dir.pwd}/public;
|
|
30
|
+
}
|
|
31
|
+
EOF
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def nginx_production_config
|
|
35
|
+
<<~EOF
|
|
36
|
+
upstream puma {
|
|
37
|
+
server 127.0.0.1:3000 fail_timeout=5;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
server {
|
|
41
|
+
listen 80;
|
|
42
|
+
server_name #{nginx_server_name};
|
|
43
|
+
root #{Dir.pwd}/public;
|
|
44
|
+
|
|
45
|
+
try_files $uri @app;
|
|
46
|
+
|
|
47
|
+
location @app {
|
|
48
|
+
proxy_pass http://puma;
|
|
49
|
+
proxy_set_header Host $host;
|
|
50
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
51
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
52
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
location ~* \\-[0-9a-f]\\{64\\}\\.(ico|css|js|gif|jpe?g|png|webp)$ {
|
|
56
|
+
access_log off;
|
|
57
|
+
expires max;
|
|
58
|
+
add_header Cache-Control public;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
gzip_static on;
|
|
62
|
+
}
|
|
63
|
+
EOF
|
|
64
|
+
end
|
|
65
|
+
|
|
45
66
|
def nginx_server_name
|
|
46
67
|
case ENV["RAILS_ENV"]
|
|
47
68
|
when "production"
|
data/lib/bard/version.rb
CHANGED
data/spec/bard/cli/setup_spec.rb
CHANGED
|
@@ -12,16 +12,40 @@ describe "bard setup" do
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
describe "#setup" do
|
|
15
|
+
before { allow(cli).to receive(:nginx_server_name).and_return("test_project.localhost") }
|
|
16
|
+
|
|
15
17
|
it "should have a setup command" do
|
|
16
18
|
expect(cli).to respond_to(:setup)
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
context "in production" do
|
|
22
|
+
before do
|
|
23
|
+
allow(ENV).to receive(:[]).and_call_original
|
|
24
|
+
allow(ENV).to receive(:[]).with("RAILS_ENV").and_return("production")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "creates an nginx reverse proxy config" do
|
|
28
|
+
expect(cli).to receive(:system).with(/sudo tee \/etc\/nginx\/sites-available\/test_project.*proxy_pass http:\/\/puma/m)
|
|
29
|
+
expect(cli).to receive(:system).with(/sudo ln -sf/)
|
|
30
|
+
expect(cli).to receive(:system).with("sudo service nginx restart")
|
|
31
|
+
|
|
32
|
+
cli.setup
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "in development" do
|
|
37
|
+
before do
|
|
38
|
+
allow(ENV).to receive(:[]).and_call_original
|
|
39
|
+
allow(ENV).to receive(:[]).with("RAILS_ENV").and_return("development")
|
|
40
|
+
end
|
|
23
41
|
|
|
24
|
-
|
|
42
|
+
it "creates an nginx config that includes the shared dev snippet" do
|
|
43
|
+
expect(cli).to receive(:system).with(/sudo tee \/etc\/nginx\/sites-available\/test_project.*include \/etc\/nginx\/snippets\/common\.conf/m)
|
|
44
|
+
expect(cli).to receive(:system).with(/sudo ln -sf/)
|
|
45
|
+
expect(cli).to receive(:system).with("sudo service nginx restart")
|
|
46
|
+
|
|
47
|
+
cli.setup
|
|
48
|
+
end
|
|
25
49
|
end
|
|
26
50
|
end
|
|
27
51
|
|
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.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-07-01 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: thor
|