abtion-scripts
Handy scripts for developing. Initially built for projects based on Abtion Rails, but hopefully useful for other projects as well.
Installation
Add to your project's Gemfile:
gem 'abtion-scripts'
Getting help
You can run abtion help at any time for a list of commands.
Running abtion help [command name] will print specific help for that
command.
Commands
abtion doctor will run a bunch of checks to make sure all the project dependencies are met
abtion promote will promote staging to production and run migrations on production
abtion update will pull from git, bundle if necessary, migrate the DB if necessary, remove old logs, and restart Rails
Extending/adding commands to your project
Any files in .abtion/scripts/**/*.rb will be automatically required
by the abtion command on a per-project basis. Any overrides/extensions
can be added in that directory.
Example of adding a project-specific command
If you have a custom command you'd like to add, just put it in
.abtion/scripts/custom_command.rb
Each command needs to subclass AbtionScripts::Base and implement
a run method.
As an example, here's how you might override the abtion test command to
add ESLint as a step:
class CustomTest < AbtionScripts::Test
# override the default 'test' command by naming it
# the same
def self.name
"test"
end
def run
# Other scripts can be reused by calling .run
AbtionScripts::Rspec.run
# Adding a custom step to run eslint after RSpec runs
step "Running eslint" do
system! "bin/eslint"
end
end
end
Extending doctor
Create a file called .abtion/scripts/doctor.rb, and as an example:
class Doctor < AbtionScripts::Doctor
def run_checks
# Use built-in default checks, if still desired
run_default_checks
# Add a custom check
check_aws_configured
end
private
def check_aws_configured
check(
name: "AWS env configured",
command: "cat .envrc | grep AWS_ACCESS_KEY_ID",
remedy: "cp .envrc .env # and edit"
)
end
end
If you want to cherry pick some of the default checks, you'll need
to call each of their methods manually. For a list of default checks,
run abtion doctor list. Then, create a .abtion/scripts/doctor.rb
file that looks something like this:
class Doctor < AbtionScripts::Doctor
def run_checks
# Only run these two defaults
check_envrc_file_exists
check_phantomjs_installed
# Add any custom checks here...
end
end
Copyright
Copyright (c) 2019 Abtion. See LICENSE.txt for further details.