class Jobshop::CLI::Canary
Public Instance Methods
devcert()
click to toggle source
# File lib/jobshop/cli/canary.rb, line 16 def devcert Jobshop::Generators::DevCertGenerator.start end
link_host()
click to toggle source
# File lib/jobshop/cli/canary.rb, line 144 def link_host @link_host ||= Rails.env.development? ? "jobshop.test" : "HOSTNAME" end
login_with_password_link(password)
click to toggle source
# File lib/jobshop/cli/canary.rb, line 119 def login_with_password_link(password) require_environment! resource.password = resource.password_confirmation = password resource.save Jobshop::Engine.routes.url_helpers.new_user_session_url( protocol: :https, host: link_host, port: 8443, user: { email: resource.email }) end
reset(*args)
click to toggle source
# File lib/jobshop/cli/canary.rb, line 28 def reset(*args) FileUtils.rmtree(File.expand_path("spec/canary")) Jobshop::Generators::CanaryGenerator.start( args.unshift(File.expand_path("spec/canary")), jobshop_options: { database: "postgresql", skip_bootsnap: true, skip_bundle: true, skip_coffee: true, skip_gemfile: true, skip_git: true, skip_javascript: true, skip_listen: true, skip_sprockets: true, skip_test: true, skip_turbolinks: true } ) end
reset_password_link()
click to toggle source
# File lib/jobshop/cli/canary.rb, line 129 def reset_password_link require_environment! token = resource.send :set_reset_password_token @reset_password_link ||= Jobshop::Engine.routes.url_helpers.edit_user_password_url( host: link_host, reset_password_token: token) end
resource()
click to toggle source
# File lib/jobshop/cli/canary.rb, line 139 def resource @resource ||= Jobshop::Organization.order(created_at: :desc).first .users.order(created_at: :desc).first end
seed()
click to toggle source
# File lib/jobshop/cli/canary.rb, line 49 def seed require_environment! Jobshop::Engine.load_seed end
server()
click to toggle source
# File lib/jobshop/cli/canary.rb, line 21 def server Dir.chdir("spec/canary") do exec("heroku local") end end
setup()
click to toggle source
# File lib/jobshop/cli/canary.rb, line 61 def setup File.file?("jobshop.gemspec") || abort(<<~ABORT) Please run this command from the root of the Jobshop source tree. ABORT print_header quiet_command(<<~COMMAND, :check, "dependencies") unless options[:fast] gem install bundler --conservative bundle check || bundle install mkdir -p .git/safe mkdir -p spec/canary COMMAND Dir.chdir "spec/canary" do quiet_command(<<~COMMAND, :prepare, "environment") if psql -lqt | cut -d \\| -f 1 | grep -qw canary_development; then bundle exec rails db:environment:set RAILS_ENV=development fi COMMAND end unless options[:fast] quiet_command(<<~COMMAND, :install, "jobshop development app") unless options[:fast] jobshop reset COMMAND quiet_command(<<~COMMAND, :seed, "pseudorandom development data") jobshop seed COMMAND say_status :config, "environment template", :white FileUtils.cp(".env", "spec/canary/.env") if File.file?(".env") say_status :complete, "", :white say "" login_link = if options[:password] login_with_password_link(options[:password]) else reset_password_link end message = <<~MESSAGE Thank you for installing #{set_color("Jobshop", :white, :bold)}. You can start the server by running: jobshop server Then open your browser and go to: #{login_link} MESSAGE say message end