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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/CLAUDE.md +1 -1
- data/PLUGINS.md +31 -46
- data/bard.gemspec +2 -1
- data/features/ci.feature +1 -0
- data/features/data.feature +1 -0
- data/features/deploy.feature +1 -0
- data/features/deploy_git_workflow.feature +1 -0
- data/features/run.feature +1 -0
- data/features/step_definitions/bard_steps.rb +1 -0
- data/features/support/test_server.rb +3 -3
- data/lib/bard/cli.rb +9 -28
- data/lib/bard/command.rb +9 -88
- data/lib/bard/config.rb +38 -177
- data/lib/bard/copy.rb +28 -82
- data/lib/bard/plugins/data.rb +56 -0
- data/lib/bard/{ci → plugins/deploy/ci}/github_actions.rb +2 -2
- data/lib/bard/{ci → plugins/deploy/ci}/jenkins.rb +1 -1
- data/lib/bard/{ci → plugins/deploy/ci}/local.rb +1 -1
- data/lib/bard/{ci → plugins/deploy/ci}/runner.rb +3 -3
- data/lib/bard/{ci.rb → plugins/deploy/ci.rb} +1 -1
- data/lib/bard/plugins/deploy/ssh_strategy.rb +27 -0
- data/lib/bard/{deploy_strategy.rb → plugins/deploy/strategy.rb} +1 -4
- data/lib/bard/plugins/deploy.rb +240 -0
- data/lib/bard/{git.rb → plugins/git.rb} +6 -3
- data/lib/bard/{github.rb → plugins/github.rb} +2 -2
- data/lib/bard/{deploy_strategy/github_pages.rb → plugins/github_pages/strategy.rb} +3 -4
- data/lib/bard/plugins/github_pages.rb +11 -15
- data/lib/bard/plugins/hurt.rb +12 -4
- data/{install_files → lib/bard/plugins/install}/.github/dependabot.yml +2 -1
- data/{install_files → lib/bard/plugins/install}/.github/workflows/cache-ci.yml +1 -1
- data/{install_files → lib/bard/plugins/install}/.github/workflows/ci.yml +2 -2
- data/lib/bard/plugins/install.rb +7 -3
- data/lib/bard/plugins/open.rb +20 -0
- data/lib/bard/{ping.rb → plugins/ping/check.rb} +4 -4
- data/lib/bard/plugins/ping/target_methods.rb +23 -0
- data/lib/bard/plugins/ping.rb +8 -4
- data/lib/bard/plugins/run.rb +19 -0
- data/lib/bard/plugins/setup.rb +54 -0
- data/lib/bard/plugins/ssh/connection.rb +75 -0
- data/lib/bard/plugins/ssh/copy.rb +95 -0
- data/lib/bard/{ssh_server.rb → plugins/ssh/server.rb} +10 -42
- data/lib/bard/plugins/ssh/target_methods.rb +20 -0
- data/lib/bard/plugins/ssh.rb +10 -0
- data/lib/bard/plugins/url/target_methods.rb +23 -0
- data/lib/bard/plugins/url.rb +1 -0
- data/lib/bard/plugins/vim.rb +5 -4
- data/lib/bard/retryable.rb +25 -0
- data/lib/bard/target.rb +21 -230
- data/lib/bard/version.rb +1 -1
- data/lib/bard.rb +1 -3
- data/spec/acceptance/docker/Dockerfile +1 -1
- data/spec/bard/capability_spec.rb +8 -50
- data/spec/bard/ci/github_actions_spec.rb +1 -1
- data/spec/bard/ci/jenkins_spec.rb +1 -1
- data/spec/bard/ci/runner_spec.rb +3 -3
- data/spec/bard/ci_spec.rb +1 -1
- data/spec/bard/cli/ci_spec.rb +4 -23
- data/spec/bard/cli/data_spec.rb +7 -26
- data/spec/bard/cli/deploy_spec.rb +43 -40
- data/spec/bard/cli/hurt_spec.rb +2 -8
- data/spec/bard/cli/install_spec.rb +4 -10
- data/spec/bard/cli/master_key_spec.rb +5 -19
- data/spec/bard/cli/open_spec.rb +17 -35
- data/spec/bard/cli/ping_spec.rb +10 -25
- data/spec/bard/cli/run_spec.rb +10 -23
- data/spec/bard/cli/setup_spec.rb +10 -27
- data/spec/bard/cli/ssh_spec.rb +10 -25
- data/spec/bard/cli/stage_spec.rb +17 -32
- data/spec/bard/cli/vim_spec.rb +5 -11
- data/spec/bard/command_spec.rb +1 -10
- data/spec/bard/config_spec.rb +68 -116
- data/spec/bard/copy_spec.rb +54 -18
- data/spec/bard/deploy_strategy/ssh_spec.rb +65 -7
- data/spec/bard/deploy_strategy_spec.rb +1 -1
- data/spec/bard/dynamic_dsl_spec.rb +18 -98
- data/spec/bard/git_spec.rb +9 -5
- data/spec/bard/github_spec.rb +1 -1
- data/spec/bard/ping_spec.rb +5 -5
- data/spec/bard/ssh_copy_spec.rb +44 -0
- data/spec/bard/ssh_server_spec.rb +1 -98
- data/spec/bard/target_spec.rb +61 -108
- metadata +50 -124
- data/lib/bard/ci/retryable.rb +0 -27
- data/lib/bard/cli/ci.rb +0 -73
- data/lib/bard/cli/command.rb +0 -26
- data/lib/bard/cli/data.rb +0 -45
- data/lib/bard/cli/deploy.rb +0 -116
- data/lib/bard/cli/hurt.rb +0 -15
- data/lib/bard/cli/install.rb +0 -11
- data/lib/bard/cli/master_key.rb +0 -17
- data/lib/bard/cli/new.rb +0 -101
- data/lib/bard/cli/new_rails_template.rb +0 -197
- data/lib/bard/cli/open.rb +0 -18
- data/lib/bard/cli/ping.rb +0 -12
- data/lib/bard/cli/provision.rb +0 -34
- data/lib/bard/cli/run.rb +0 -26
- data/lib/bard/cli/setup.rb +0 -56
- data/lib/bard/cli/ssh.rb +0 -14
- data/lib/bard/cli/stage.rb +0 -35
- data/lib/bard/cli/vim.rb +0 -8
- data/lib/bard/default_config.rb +0 -35
- data/lib/bard/deploy_strategy/ssh.rb +0 -19
- data/lib/bard/deprecation.rb +0 -19
- data/lib/bard/github_pages.rb +0 -134
- data/lib/bard/plugin.rb +0 -100
- data/lib/bard/plugins/backup.rb +0 -19
- data/lib/bard/plugins/jenkins.rb +0 -6
- data/lib/bard/plugins/new.rb +0 -5
- data/lib/bard/plugins/provision.rb +0 -5
- data/lib/bard/provision/app.rb +0 -10
- data/lib/bard/provision/apt.rb +0 -16
- data/lib/bard/provision/authorizedkeys.rb +0 -25
- data/lib/bard/provision/data.rb +0 -27
- data/lib/bard/provision/deploy.rb +0 -10
- data/lib/bard/provision/http.rb +0 -16
- data/lib/bard/provision/logrotation.rb +0 -30
- data/lib/bard/provision/masterkey.rb +0 -18
- data/lib/bard/provision/mysql.rb +0 -22
- data/lib/bard/provision/passenger.rb +0 -37
- data/lib/bard/provision/repo.rb +0 -72
- data/lib/bard/provision/rvm.rb +0 -22
- data/lib/bard/provision/ssh.rb +0 -79
- data/lib/bard/provision/swapfile.rb +0 -23
- data/lib/bard/provision/user.rb +0 -42
- data/lib/bard/provision.rb +0 -16
- data/lib/bard/server.rb +0 -160
- data/spec/bard/cli/command_spec.rb +0 -50
- data/spec/bard/cli/new_spec.rb +0 -73
- data/spec/bard/cli/provision_spec.rb +0 -42
- data/spec/bard/deprecation_spec.rb +0 -281
- data/spec/bard/github_pages_spec.rb +0 -143
- data/spec/bard/plugin_spec.rb +0 -79
- data/spec/bard/provision/app_spec.rb +0 -33
- data/spec/bard/provision/apt_spec.rb +0 -39
- data/spec/bard/provision/authorizedkeys_spec.rb +0 -40
- data/spec/bard/provision/data_spec.rb +0 -54
- data/spec/bard/provision/deploy_spec.rb +0 -33
- data/spec/bard/provision/http_spec.rb +0 -57
- data/spec/bard/provision/logrotation_spec.rb +0 -34
- data/spec/bard/provision/masterkey_spec.rb +0 -63
- data/spec/bard/provision/mysql_spec.rb +0 -55
- data/spec/bard/provision/passenger_spec.rb +0 -81
- data/spec/bard/provision/repo_spec.rb +0 -208
- data/spec/bard/provision/rvm_spec.rb +0 -49
- data/spec/bard/provision/ssh_spec.rb +0 -242
- data/spec/bard/provision/swapfile_spec.rb +0 -33
- data/spec/bard/provision/user_spec.rb +0 -103
- data/spec/bard/provision_spec.rb +0 -28
- data/spec/bard/server_spec.rb +0 -127
- /data/lib/bard/{ci → plugins/deploy/ci}/state.rb +0 -0
- /data/{install_files → lib/bard/plugins/install}/apt_dependencies.rb +0 -0
- /data/{install_files → lib/bard/plugins/install}/ci +0 -0
- /data/{install_files → lib/bard/plugins/install}/setup +0 -0
- /data/{install_files → lib/bard/plugins/install}/specified_bundler.rb +0 -0
- /data/{install_files → lib/bard/plugins/install}/specified_ruby.rb +0 -0
data/lib/bard/cli/new.rb
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
require "bard/cli/command"
|
|
2
|
-
require "bard/github"
|
|
3
|
-
|
|
4
|
-
class Bard::CLI::New < Bard::CLI::Command
|
|
5
|
-
RAILS_REQUIREMENT = "~> 8.0.0"
|
|
6
|
-
desc "new <project-name>", "creates new bard app named <project-name>"
|
|
7
|
-
def new project_name
|
|
8
|
-
@project_name = project_name
|
|
9
|
-
validate
|
|
10
|
-
create_project
|
|
11
|
-
push_to_github
|
|
12
|
-
stage
|
|
13
|
-
puts green("Project #{project_name} created!")
|
|
14
|
-
puts "Please cd ../#{project_name}"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
attr_accessor :project_name
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def validate
|
|
22
|
-
if project_name !~ /^[a-z][a-z0-9]*\Z/
|
|
23
|
-
puts red("!!! ") + "Invalid project name: #{yellow(project_name)}."
|
|
24
|
-
puts "The first character must be a lowercase letter, and all following characters must be a lowercase letter or number."
|
|
25
|
-
exit 1
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def create_project
|
|
30
|
-
run! build_create_project_script
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def build_create_project_script
|
|
34
|
-
build_bash_env do
|
|
35
|
-
build_rvm_setup +
|
|
36
|
-
build_gem_install("rails", RAILS_REQUIREMENT) +
|
|
37
|
-
build_rails_new
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def build_bash_env
|
|
42
|
-
script = yield
|
|
43
|
-
<<~SH
|
|
44
|
-
env -i bash -lc '
|
|
45
|
-
export HOME=~
|
|
46
|
-
source ~/.rvm/scripts/rvm
|
|
47
|
-
#{script}
|
|
48
|
-
'
|
|
49
|
-
SH
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def build_rvm_setup
|
|
53
|
-
<<~SH
|
|
54
|
-
cd ..
|
|
55
|
-
rvm use --create #{ruby_version}@#{project_name}
|
|
56
|
-
SH
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def build_gem_install(gem_name, version_requirement)
|
|
60
|
-
<<~SH
|
|
61
|
-
GEM_VERSION=$(gem install #{gem_name} -v \"#{version_requirement}\" --no-document 2>&1 | grep -oP \"Successfully installed #{gem_name}-\\K[0-9.]+\")
|
|
62
|
-
SH
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def build_rails_new
|
|
66
|
-
<<~SH
|
|
67
|
-
rails _${GEM_VERSION}_ new #{project_name} --skip-git --skip-kamal --skip-test -m #{template_path}
|
|
68
|
-
SH
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def push_to_github
|
|
72
|
-
api = Bard::Github.new(project_name)
|
|
73
|
-
api.create_repo
|
|
74
|
-
run! <<~SH
|
|
75
|
-
cd ../#{project_name}
|
|
76
|
-
git init -b master
|
|
77
|
-
git add -A
|
|
78
|
-
git commit -m"initial commit."
|
|
79
|
-
git remote add origin git@github.com:botandrosedesign/#{project_name}
|
|
80
|
-
git push -u origin master
|
|
81
|
-
SH
|
|
82
|
-
api.add_master_key File.read("../#{project_name}/config/master.key")
|
|
83
|
-
api.add_master_branch_protection
|
|
84
|
-
api.patch(nil, allow_auto_merge: true)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def stage
|
|
88
|
-
run! <<~SH
|
|
89
|
-
cd ../#{project_name}
|
|
90
|
-
bard deploy --clone
|
|
91
|
-
SH
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def ruby_version
|
|
95
|
-
"ruby-3.4.2"
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def template_path
|
|
99
|
-
File.expand_path("new_rails_template.rb", __dir__)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
ruby_version, project_name = (`rvm current name`.chomp).split("@")
|
|
2
|
-
rails_version = Gem.loaded_specs["railties"].version
|
|
3
|
-
|
|
4
|
-
file ".ruby-version", ruby_version
|
|
5
|
-
file ".ruby-gemset", project_name
|
|
6
|
-
file ".gitignore", <<~GITIGNORE
|
|
7
|
-
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
|
8
|
-
#
|
|
9
|
-
# If you find yourself ignoring temporary files generated by your text editor
|
|
10
|
-
# or operating system, you probably want to add a global ignore instead:
|
|
11
|
-
# git config --global core.excludesfile '~/.gitignore_global'
|
|
12
|
-
|
|
13
|
-
# Ignore bundler config.
|
|
14
|
-
/.bundle
|
|
15
|
-
|
|
16
|
-
# Ignore all logfiles and tempfiles.
|
|
17
|
-
/log/*
|
|
18
|
-
/tmp/*
|
|
19
|
-
!/log/.keep
|
|
20
|
-
!/tmp/.keep
|
|
21
|
-
|
|
22
|
-
# Ignore master key for decrypting credentials and more.
|
|
23
|
-
/config/master.key
|
|
24
|
-
|
|
25
|
-
# ignore coverage reports
|
|
26
|
-
/coverage
|
|
27
|
-
|
|
28
|
-
# Ignore database dumps
|
|
29
|
-
/db/data.*
|
|
30
|
-
|
|
31
|
-
# Ignore storage (uploaded files in development and any SQLite databases).
|
|
32
|
-
/storage/*
|
|
33
|
-
|
|
34
|
-
# Ignore Syncthing
|
|
35
|
-
.stfolder/
|
|
36
|
-
|
|
37
|
-
# Thank Apple!
|
|
38
|
-
.DS_Store
|
|
39
|
-
GITIGNORE
|
|
40
|
-
|
|
41
|
-
file "Gemfile", <<~RUBY
|
|
42
|
-
source "https://rubygems.org"
|
|
43
|
-
|
|
44
|
-
gem "bootsnap", require: false
|
|
45
|
-
gem "rails", "~> #{rails_version}"
|
|
46
|
-
gem "solid_cache"
|
|
47
|
-
gem "solid_queue"
|
|
48
|
-
gem "solid_cable"
|
|
49
|
-
gem "bard-rails"
|
|
50
|
-
gem "sqlite3"
|
|
51
|
-
gem "image_processing"
|
|
52
|
-
gem "puma"
|
|
53
|
-
gem "exception_notification"
|
|
54
|
-
|
|
55
|
-
# css
|
|
56
|
-
gem "sprockets-rails"
|
|
57
|
-
gem "dartsass-sprockets"
|
|
58
|
-
gem "bard-sass"
|
|
59
|
-
|
|
60
|
-
# js
|
|
61
|
-
gem "importmap-rails"
|
|
62
|
-
gem "turbo-rails"
|
|
63
|
-
gem "stimulus-rails"
|
|
64
|
-
|
|
65
|
-
group :development do
|
|
66
|
-
gem "web-console"
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
group :development, :test do
|
|
70
|
-
gem "debug", require: "debug/prelude"
|
|
71
|
-
# gem "parallel_tests", "~>3.9.0" # 3.10 pegs CPU
|
|
72
|
-
gem "brakeman", require: false
|
|
73
|
-
gem "rubocop-rails-omakase", require: false
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
group :test do
|
|
77
|
-
gem "cucumber-rails", require: false
|
|
78
|
-
gem "cuprite-downloads"
|
|
79
|
-
gem "capybara-screenshot"
|
|
80
|
-
gem "database_cleaner"
|
|
81
|
-
gem "chop"
|
|
82
|
-
gem "email_spec"
|
|
83
|
-
gem "timecop"
|
|
84
|
-
gem "rspec-rails"
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
group :production do
|
|
88
|
-
gem "foreman-export-systemd_user"
|
|
89
|
-
end
|
|
90
|
-
RUBY
|
|
91
|
-
|
|
92
|
-
file "config/initializers/exception_notification.rb", <<~RUBY
|
|
93
|
-
require "exception_notification/rails"
|
|
94
|
-
|
|
95
|
-
ExceptionNotification.configure do |config|
|
|
96
|
-
config.ignored_exceptions = []
|
|
97
|
-
|
|
98
|
-
# Adds a condition to decide when an exception must be ignored or not.
|
|
99
|
-
# The ignore_if method can be invoked multiple times to add extra conditions.
|
|
100
|
-
config.ignore_if do |exception, options|
|
|
101
|
-
not Rails.env.production?
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
config.ignore_if do |exception, options|
|
|
105
|
-
%w[
|
|
106
|
-
ActiveRecord::RecordNotFound
|
|
107
|
-
AbstractController::ActionNotFound
|
|
108
|
-
ActionController::RoutingError
|
|
109
|
-
ActionController::InvalidAuthenticityToken
|
|
110
|
-
ActionView::MissingTemplate
|
|
111
|
-
ActionController::BadRequest
|
|
112
|
-
ActionDispatch::Http::Parameters::ParseError
|
|
113
|
-
ActionDispatch::Http::MimeNegotiation::InvalidType
|
|
114
|
-
].include?(exception.class.to_s)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
config.add_notifier :email, {
|
|
118
|
-
email_prefix: "[\#{File.basename(Dir.pwd)}] ",
|
|
119
|
-
exception_recipients: "micah@botandrose.com",
|
|
120
|
-
smtp_settings: Rails.application.credentials.exception_notification_smtp_settings,
|
|
121
|
-
}
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
if defined?(Rake::Application)
|
|
125
|
-
Rake::Application.prepend Module.new {
|
|
126
|
-
def display_error_message error
|
|
127
|
-
ExceptionNotifier.notify_exception(error)
|
|
128
|
-
super
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def invoke_task task_name
|
|
132
|
-
super
|
|
133
|
-
rescue RuntimeError => exception
|
|
134
|
-
if exception.message.starts_with?("Don't know how to build task")
|
|
135
|
-
ExceptionNotifier.notify_exception(exception)
|
|
136
|
-
end
|
|
137
|
-
raise exception
|
|
138
|
-
end
|
|
139
|
-
}
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
ActionController::Live.prepend Module.new {
|
|
143
|
-
def log_error exception
|
|
144
|
-
ExceptionNotifier.notify_exception exception, env: request.env
|
|
145
|
-
super
|
|
146
|
-
end
|
|
147
|
-
}
|
|
148
|
-
RUBY
|
|
149
|
-
|
|
150
|
-
file "app/assets/config/manifest.js", <<~RUBY
|
|
151
|
-
//= link_tree ../images
|
|
152
|
-
//= link_directory ../stylesheets .css
|
|
153
|
-
//= link_tree ../../javascript .js
|
|
154
|
-
RUBY
|
|
155
|
-
|
|
156
|
-
run "rm -f app/assets/stylesheets/application.css"
|
|
157
|
-
|
|
158
|
-
file "app/assets/stylesheets/application.sass", <<~SASS
|
|
159
|
-
body
|
|
160
|
-
border: 10px solid red
|
|
161
|
-
SASS
|
|
162
|
-
|
|
163
|
-
gsub_file "app/views/layouts/application.html.erb", " <%# Includes all stylesheet files in app/assets/stylesheets %>\n", ''
|
|
164
|
-
gsub_file "app/views/layouts/application.html.erb", 'stylesheet_link_tag :app,', 'stylesheet_link_tag :application,'
|
|
165
|
-
|
|
166
|
-
file "app/views/static/index.html.slim", <<~SLIM
|
|
167
|
-
h1 #{project_name}
|
|
168
|
-
SLIM
|
|
169
|
-
|
|
170
|
-
insert_into_file "config/database.yml", <<~YAML, after: "database: storage/test.sqlite3"
|
|
171
|
-
|
|
172
|
-
staging:
|
|
173
|
-
<<: *default
|
|
174
|
-
database: storage/staging.sqlite3
|
|
175
|
-
YAML
|
|
176
|
-
|
|
177
|
-
insert_into_file "config/database.yml", <<-YAML, after: "# database: path/to/persistent/storage/production.sqlite3"
|
|
178
|
-
|
|
179
|
-
cable:
|
|
180
|
-
<<: *default
|
|
181
|
-
# database: path/to/persistent/storage/production_cable.sqlite3
|
|
182
|
-
migrations_paths: db/cable_migrate
|
|
183
|
-
queue:
|
|
184
|
-
<<: *default
|
|
185
|
-
# database: path/to/persistent/storage/production_queue.sqlite3
|
|
186
|
-
migrations_paths: db/queue_migrate
|
|
187
|
-
YAML
|
|
188
|
-
|
|
189
|
-
gsub_file "config/database.yml", "path/to/persistent/", ""
|
|
190
|
-
|
|
191
|
-
gsub_file "config/environments/production.rb", / (config\.logger.+STDOUT.*)$/, ' # \1'
|
|
192
|
-
|
|
193
|
-
after_bundle do
|
|
194
|
-
run "bard install"
|
|
195
|
-
run "bin/setup"
|
|
196
|
-
run "bard setup"
|
|
197
|
-
end
|
data/lib/bard/cli/open.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require "bard/cli/command"
|
|
2
|
-
|
|
3
|
-
class Bard::CLI::Open < Bard::CLI::Command
|
|
4
|
-
desc "open [server=production]", "opens the url in the web browser."
|
|
5
|
-
def open server=:production
|
|
6
|
-
exec "xdg-open #{open_url server}"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
def open_url server
|
|
12
|
-
if server.to_sym == :ci
|
|
13
|
-
"https://github.com/botandrosedesign/#{project_name}/actions/workflows/ci.yml"
|
|
14
|
-
else
|
|
15
|
-
config[server].ping.first
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
data/lib/bard/cli/ping.rb
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require "bard/cli/command"
|
|
2
|
-
require "bard/ping"
|
|
3
|
-
|
|
4
|
-
class Bard::CLI::Ping < Bard::CLI::Command
|
|
5
|
-
desc "ping [server=production]", "hits the server over http to verify that its up."
|
|
6
|
-
def ping server=:production
|
|
7
|
-
server = config[server]
|
|
8
|
-
down_urls = Bard::Ping.call(config[server])
|
|
9
|
-
down_urls.each { |url| puts "#{url} is down!" }
|
|
10
|
-
exit 1 if down_urls.any?
|
|
11
|
-
end
|
|
12
|
-
end
|
data/lib/bard/cli/provision.rb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require "bard/cli/command"
|
|
2
|
-
require "bard/provision"
|
|
3
|
-
|
|
4
|
-
class Bard::CLI::Provision < Bard::CLI::Command
|
|
5
|
-
STEPS = %w[
|
|
6
|
-
SSH
|
|
7
|
-
User
|
|
8
|
-
AuthorizedKeys
|
|
9
|
-
Swapfile
|
|
10
|
-
Apt
|
|
11
|
-
MySQL
|
|
12
|
-
Repo
|
|
13
|
-
MasterKey
|
|
14
|
-
RVM
|
|
15
|
-
App
|
|
16
|
-
Passenger
|
|
17
|
-
HTTP
|
|
18
|
-
LogRotation
|
|
19
|
-
Data
|
|
20
|
-
Deploy
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
desc "provision [ssh_url] --steps=all", "takes an optional ssh url to a raw ubuntu 22.04 install, and readies it in the shape of :production"
|
|
24
|
-
option :steps, type: :array, default: STEPS
|
|
25
|
-
def provision ssh_url=config[:production].ssh&.to_s
|
|
26
|
-
# unfreeze the string for later mutation
|
|
27
|
-
ssh_url = ssh_url.dup
|
|
28
|
-
options[:steps].each do |step|
|
|
29
|
-
require "bard/provision/#{step.downcase}"
|
|
30
|
-
Bard::Provision.const_get(step).call(config, ssh_url)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
data/lib/bard/cli/run.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require "bard/command"
|
|
2
|
-
|
|
3
|
-
module Bard::CLI::Run
|
|
4
|
-
def self.included mod
|
|
5
|
-
mod.class_eval do
|
|
6
|
-
|
|
7
|
-
# HACK: we don't use Thor::Base#run, so its okay to stomp on it here
|
|
8
|
-
original_verbose, $VERBOSE = $VERBOSE, nil
|
|
9
|
-
Thor::THOR_RESERVED_WORDS -= ["run"]
|
|
10
|
-
$VERBOSE = original_verbose
|
|
11
|
-
|
|
12
|
-
option :target, type: :string, default: "production"
|
|
13
|
-
option :home, type: :boolean
|
|
14
|
-
desc "run <command>", "run the given command on the specified target"
|
|
15
|
-
def run *args
|
|
16
|
-
target = config[options[:target].to_sym]
|
|
17
|
-
target.run! *args.join(" "), verbose: true, home: options[:home]
|
|
18
|
-
rescue Bard::Command::Error => e
|
|
19
|
-
puts red("!!! ") + "Running command failed: #{yellow(e.message)}"
|
|
20
|
-
exit 1
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
data/lib/bard/cli/setup.rb
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
require "uri"
|
|
2
|
-
|
|
3
|
-
module Bard::CLI::Setup
|
|
4
|
-
def self.included mod
|
|
5
|
-
mod.class_eval do
|
|
6
|
-
|
|
7
|
-
desc "setup", "installs app in nginx"
|
|
8
|
-
def setup
|
|
9
|
-
system "sudo tee /etc/nginx/snippets/common.conf >/dev/null <<-EOF
|
|
10
|
-
listen 80;
|
|
11
|
-
|
|
12
|
-
passenger_enabled on;
|
|
13
|
-
|
|
14
|
-
location ~* \\.(ico|css|js|gif|jp?g|png|webp) {
|
|
15
|
-
access_log off;
|
|
16
|
-
if (\\$request_filename ~ \"-[0-9a-f]{32,}\\.\") {
|
|
17
|
-
expires max;
|
|
18
|
-
add_header Cache-Control public;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
gzip_static on;
|
|
23
|
-
EOF"
|
|
24
|
-
|
|
25
|
-
path = "/etc/nginx/sites-available/#{project_name}"
|
|
26
|
-
system "sudo tee #{path} >/dev/null <<-EOF
|
|
27
|
-
server {
|
|
28
|
-
include /etc/nginx/snippets/common.conf;
|
|
29
|
-
server_name #{nginx_server_name};
|
|
30
|
-
root #{Dir.pwd}/public;
|
|
31
|
-
}
|
|
32
|
-
EOF"
|
|
33
|
-
|
|
34
|
-
dest_path = path.sub("sites-available", "sites-enabled")
|
|
35
|
-
system "sudo ln -sf #{path} #{dest_path}" if !File.exist?(dest_path)
|
|
36
|
-
|
|
37
|
-
system "sudo service nginx restart"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
def nginx_server_name
|
|
43
|
-
case ENV["RAILS_ENV"]
|
|
44
|
-
when "production"
|
|
45
|
-
(config[:production].ping.map do |str|
|
|
46
|
-
"*.#{URI.parse(str).host}"
|
|
47
|
-
end + ["_"]).join(" ")
|
|
48
|
-
when "staging" then "#{project_name}.botandrose.com"
|
|
49
|
-
else "#{project_name}.localhost"
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
data/lib/bard/cli/ssh.rb
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module Bard::CLI::SSH
|
|
2
|
-
def self.included mod
|
|
3
|
-
mod.class_eval do
|
|
4
|
-
|
|
5
|
-
option :home, type: :boolean
|
|
6
|
-
desc "ssh [to=production]", "logs into the specified server via SSH"
|
|
7
|
-
def ssh to=:production
|
|
8
|
-
config[to].exec! "exec $SHELL -l", home: options[:home]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
data/lib/bard/cli/stage.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require "bard/git"
|
|
2
|
-
require "bard/command"
|
|
3
|
-
|
|
4
|
-
module Bard::CLI::Stage
|
|
5
|
-
def self.included mod
|
|
6
|
-
mod.class_eval do
|
|
7
|
-
|
|
8
|
-
desc "stage [branch=HEAD]", "pushes current branch, and stages it"
|
|
9
|
-
def stage branch=Bard::Git.current_branch
|
|
10
|
-
unless config.servers.key?(:production)
|
|
11
|
-
raise Thor::Error.new("`bard stage` is disabled until a production server is defined. Until then, please use `bard deploy` to deploy to the staging server.")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
run! "git push -u origin #{branch}", verbose: true
|
|
15
|
-
|
|
16
|
-
target = config[:staging]
|
|
17
|
-
if target.respond_to?(:deploy_strategy) && target.deploy_strategy
|
|
18
|
-
strategy = target.deploy_strategy_instance
|
|
19
|
-
strategy.deploy
|
|
20
|
-
else
|
|
21
|
-
target.run! "git fetch && git checkout -f origin/#{branch} && bin/setup"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
puts green("Stage Succeeded")
|
|
25
|
-
|
|
26
|
-
ping :staging
|
|
27
|
-
rescue Bard::Command::Error => e
|
|
28
|
-
puts red("!!! ") + "Running command failed: #{yellow(e.message)}"
|
|
29
|
-
exit 1
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
data/lib/bard/cli/vim.rb
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
require "bard/cli/command"
|
|
2
|
-
|
|
3
|
-
class Bard::CLI::Vim < Bard::CLI::Command
|
|
4
|
-
desc "vim [branch=master]", "open all files that have changed since master"
|
|
5
|
-
def vim branch="master"
|
|
6
|
-
exec "vim -p `(git diff #{branch} --name-only; git ls-files --others --exclude-standard) | grep -v '^app/assets/images/' | grep -v '^app/assets/stylesheets/' | while read f; do [ -f \"$f\" ] && ! file -b \"$f\" | grep -q \"binary\" && echo \"$f\"; done | tac`"
|
|
7
|
-
end
|
|
8
|
-
end
|
data/lib/bard/default_config.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
module Bard
|
|
2
|
-
# Default configuration that is loaded before user's bard.rb
|
|
3
|
-
# Users can override any of these targets in their bard.rb
|
|
4
|
-
DEFAULT_CONFIG = lambda do |config, project_name|
|
|
5
|
-
# Local development target
|
|
6
|
-
config.instance_eval do
|
|
7
|
-
target :local do
|
|
8
|
-
ssh false
|
|
9
|
-
path "./"
|
|
10
|
-
ping "#{project_name}.local"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Bot and Rose cloud server
|
|
14
|
-
target :gubs do
|
|
15
|
-
ssh "botandrose@cloud.hackett.world:22022",
|
|
16
|
-
path: "Sites/#{project_name}"
|
|
17
|
-
ping false
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# CI target (Jenkins)
|
|
21
|
-
target :ci do
|
|
22
|
-
ssh "jenkins@staging.botandrose.com:22022",
|
|
23
|
-
path: "jobs/#{project_name}/workspace"
|
|
24
|
-
ping false
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# Staging server
|
|
28
|
-
target :staging do
|
|
29
|
-
ssh "www@staging.botandrose.com:22022",
|
|
30
|
-
path: project_name
|
|
31
|
-
ping "#{project_name}.botandrose.com"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require "bard/deploy_strategy"
|
|
2
|
-
|
|
3
|
-
module Bard
|
|
4
|
-
class DeployStrategy
|
|
5
|
-
class SSH < DeployStrategy
|
|
6
|
-
def deploy
|
|
7
|
-
# Require SSH capability
|
|
8
|
-
target.require_capability!(:ssh)
|
|
9
|
-
|
|
10
|
-
# Determine branch
|
|
11
|
-
branch = target.instance_variable_get(:@branch) || "master"
|
|
12
|
-
|
|
13
|
-
# Run git pull and setup on remote server
|
|
14
|
-
target.run! "git pull origin #{branch}"
|
|
15
|
-
target.run! "bin/setup"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
data/lib/bard/deprecation.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Bard
|
|
2
|
-
module Deprecation
|
|
3
|
-
@warned = {}
|
|
4
|
-
|
|
5
|
-
def self.warn(message, callsite: nil)
|
|
6
|
-
callsite ||= caller_locations(2, 1).first
|
|
7
|
-
key = "#{callsite.path}:#{callsite.lineno}:#{message}"
|
|
8
|
-
return if @warned[key]
|
|
9
|
-
|
|
10
|
-
@warned[key] = true
|
|
11
|
-
location = "#{callsite.path}:#{callsite.lineno}"
|
|
12
|
-
Kernel.warn "[DEPRECATION] #{message} (called from #{location})"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.reset!
|
|
16
|
-
@warned = {}
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|