Class: Jobshop::CLI::Canary

Inherits:
Base
  • Object
show all
Defined in:
lib/jobshop/cli/canary.rb

Instance Method Summary collapse

Instance Method Details

#devcertObject



16
17
18
# File 'lib/jobshop/cli/canary.rb', line 16

def devcert
  Jobshop::Generators::DevCertGenerator.start
end

#reset(*args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 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

#seedObject



49
50
51
52
# File 'lib/jobshop/cli/canary.rb', line 49

def seed
  require_environment!
  Jobshop::Engine.load_seed
end

#serverObject



21
22
23
24
25
# File 'lib/jobshop/cli/canary.rb', line 21

def server
  Dir.chdir("spec/canary") do
    exec("heroku local")
  end
end

#setupObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# 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 ""

   = if options[:password]
    (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:

      #{}

  MESSAGE

  say message
end