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
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
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