jobshop 0.0.167 → 0.0.179
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/Rakefile +2 -1
- data/app/assets/javascripts/application.js +1 -0
- data/app/controllers/jobshop/application_controller.rb +3 -1
- data/app/controllers/jobshop/dashboards_controller.rb +11 -0
- data/app/controllers/jobshop/departments_controller.rb +52 -0
- data/app/controllers/jobshop/employees_controller.rb +77 -0
- data/app/controllers/jobshop/organizations_controller.rb +29 -0
- data/app/controllers/jobshop/rfqs_controller.rb +49 -0
- data/app/controllers/jobshop/roles_controller.rb +52 -0
- data/app/helpers/jobshop/application_helper.rb +10 -0
- data/app/listeners/jobshop/assignment_listener.rb +13 -0
- data/app/mailers/jobshop/rfq_responder_mailer.rb +1 -1
- data/app/models/jobshop/auditing.rb +20 -0
- data/app/models/jobshop/collection.rb +2 -7
- data/app/models/jobshop/customer.rb +6 -17
- data/app/models/jobshop/customer/category.rb +2 -8
- data/app/models/jobshop/customer/contact.rb +3 -8
- data/app/models/jobshop/department.rb +10 -0
- data/app/models/jobshop/department/assignment.rb +15 -0
- data/app/models/jobshop/employee.rb +13 -6
- data/app/models/jobshop/employment.rb +8 -8
- data/app/models/jobshop/inspection.rb +1 -1
- data/app/models/jobshop/inspection/boolean_criterion.rb +13 -17
- data/app/models/jobshop/inspection/criterion.rb +9 -10
- data/app/models/jobshop/inspection/deviation_criterion.rb +10 -12
- data/app/models/jobshop/inspection/limit_criterion.rb +12 -10
- data/app/models/jobshop/inspection/report.rb +22 -34
- data/app/models/jobshop/mailman.rb +2 -4
- data/app/models/jobshop/order.rb +3 -27
- data/app/models/jobshop/order_line.rb +4 -10
- data/app/models/jobshop/organization.rb +8 -15
- data/app/models/jobshop/organization_state.rb +10 -0
- data/app/models/jobshop/place.rb +3 -8
- data/app/models/jobshop/product.rb +4 -7
- data/app/models/jobshop/rfq.rb +32 -14
- data/app/models/jobshop/rfq/line.rb +28 -0
- data/app/models/jobshop/rfq/line/assignment.rb +25 -0
- data/app/models/jobshop/rfq/line/quantity.rb +23 -0
- data/app/models/jobshop/role.rb +3 -9
- data/app/models/jobshop/role_assignment.rb +10 -4
- data/app/models/jobshop/routing_process.rb +4 -10
- data/app/models/jobshop/routing_step.rb +3 -5
- data/app/models/jobshop/thing.rb +3 -8
- data/app/models/jobshop/user.rb +24 -11
- data/app/views/jobshop/dashboards/show.html.haml +35 -0
- data/app/views/jobshop/departments/_form.html.haml +12 -0
- data/app/views/jobshop/departments/edit.html.haml +7 -0
- data/app/views/jobshop/departments/index.html.haml +17 -0
- data/app/views/jobshop/departments/new.html.haml +5 -0
- data/app/views/jobshop/departments/show.html.haml +15 -0
- data/app/views/jobshop/employees/_form.html.haml +46 -0
- data/app/views/jobshop/employees/edit.html.haml +1 -0
- data/app/views/jobshop/employees/index.html.haml +12 -0
- data/app/views/jobshop/employees/new.html.haml +1 -0
- data/app/views/jobshop/employees/show.html.haml +16 -0
- data/app/views/jobshop/organizations/_form.html.haml +10 -0
- data/app/views/jobshop/organizations/edit.html.haml +7 -0
- data/app/views/jobshop/organizations/index.html.haml +19 -0
- data/app/views/jobshop/organizations/new.html.haml +5 -0
- data/app/views/jobshop/organizations/show.html.haml +16 -0
- data/app/views/jobshop/rfqs/_form.html.haml +60 -0
- data/app/views/jobshop/rfqs/edit.html.haml +4 -0
- data/app/views/jobshop/rfqs/index.html.haml +2 -0
- data/app/views/jobshop/roles/_form.html.haml +11 -0
- data/app/views/jobshop/roles/edit.html.haml +7 -0
- data/app/views/jobshop/roles/index.html.haml +21 -0
- data/app/views/jobshop/roles/new.html.haml +5 -0
- data/app/views/jobshop/roles/show.html.haml +3 -0
- data/app/views/layouts/jobshop/application.html.haml +50 -2
- data/config/initializers/devise.rb +2 -2
- data/config/routes.rb +18 -0
- data/db/migrate/20170311194758_initialize_jobshop.rb +4 -39
- data/db/migrate/20171216021339_create_organizations.rb +3 -8
- data/db/migrate/20171216021350_create_users.rb +28 -0
- data/db/migrate/20171216021400_create_employees.rb +27 -9
- data/db/migrate/20171216021853_create_customers.rb +29 -14
- data/db/migrate/20171216022020_create_places.rb +3 -4
- data/db/migrate/20171216022135_create_products.rb +4 -4
- data/db/migrate/20171216022605_create_orders.rb +27 -13
- data/db/migrate/20171216023018_create_roles.rb +30 -27
- data/db/migrate/20171216035357_create_things.rb +26 -23
- data/db/migrate/20171219022118_create_routing_processes.rb +28 -33
- data/db/migrate/20180107203241_create_inspections.rb +48 -115
- data/db/migrate/20181117023949_create_rfqs.rb +74 -15
- data/db/migrate/20181118014603_create_mailmen.rb +5 -6
- data/db/migrate/20190309163306_create_departments.rb +38 -0
- data/db/migrate/support/temporal_tables.sql +210 -0
- data/db/seeds.rb +92 -64
- data/exe/jobshop +1 -0
- data/lib/generators/jobshop/app/app_generator.rb +13 -3
- data/lib/generators/jobshop/app/templates/Procfile.tt +1 -1
- data/lib/generators/jobshop/app/templates/config/databases/postgresql.yml.tt +24 -0
- data/lib/generators/jobshop/app/templates/config/puma.rb.tt +44 -0
- data/lib/generators/jobshop/canary/canary_generator.rb +21 -9
- data/lib/generators/jobshop/dev_cert/dev_cert_generator.rb +124 -0
- data/lib/jobshop.rb +1 -1
- data/lib/jobshop/cli.rb +3 -3
- data/lib/jobshop/cli/app_generator.rb +15 -10
- data/lib/jobshop/cli/application.rb +7 -7
- data/lib/jobshop/cli/base.rb +65 -0
- data/lib/jobshop/cli/canary.rb +120 -22
- data/lib/jobshop/configuration.rb +1 -1
- data/lib/jobshop/engine.rb +8 -4
- data/lib/jobshop/helpers/migration.rb +27 -66
- data/lib/jobshop/mailroom/base_handler.rb +1 -1
- data/lib/jobshop/mailroom/null_handler.rb +1 -1
- data/lib/jobshop/mailroom/postmaster.rb +1 -1
- data/lib/jobshop/mailroom/rfq_handler.rb +1 -1
- data/lib/jobshop/version.rb +2 -2
- data/lib/tasks/jobshop_tasks.rake +15 -1
- metadata +114 -61
- data/app/controllers/jobshop/organizations/lookups_controller.rb +0 -18
- data/app/models/jobshop/employment_version.rb +0 -10
- data/app/models/jobshop/inspection/result.rb +0 -46
- data/app/models/jobshop/inspection/tuple.rb +0 -17
- data/app/models/jobshop/rfq_line.rb +0 -12
- data/db/migrate/20171216021554_create_people.rb +0 -43
- data/lib/generators/jobshop/app/templates/config/database.yml.tt +0 -19
@@ -1,2 +1,2 @@
|
|
1
|
-
web: bundle exec puma -
|
1
|
+
web: bundle exec puma -C config/puma.rb
|
2
2
|
postmaster: bundle exec rails jobshop:postmaster
|
@@ -0,0 +1,24 @@
|
|
1
|
+
default: &default
|
2
|
+
adapter: postgresql
|
3
|
+
encoding: unicode
|
4
|
+
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
5
|
+
<%% if ENV["SEMAPHORE"] == "true" %>
|
6
|
+
host: localhost
|
7
|
+
username: postgres
|
8
|
+
<%% end %>
|
9
|
+
|
10
|
+
development:
|
11
|
+
<<: *default
|
12
|
+
database: canary_development
|
13
|
+
#password:
|
14
|
+
#port:
|
15
|
+
#schema_search_path:
|
16
|
+
#min_messages: notice
|
17
|
+
|
18
|
+
test:
|
19
|
+
<<: *default
|
20
|
+
database: canary_test
|
21
|
+
|
22
|
+
production:
|
23
|
+
<<: *default
|
24
|
+
database: <%= abort("Please create a standalone Jobshop app if you wish to run a production environment") if ENV.fetch("RAILS_ENV", "development") == "production" %>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
2
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
3
|
+
# Any libraries that use thread pools should be configured to match
|
4
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
+
# and maximum; this matches the default thread size of Active Record.
|
6
|
+
#
|
7
|
+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
8
|
+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
9
|
+
threads min_threads_count, max_threads_count
|
10
|
+
|
11
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
12
|
+
#
|
13
|
+
port ENV.fetch("PORT") { 3000 }
|
14
|
+
|
15
|
+
# Specifies the `environment` that Puma will run in.
|
16
|
+
#
|
17
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
18
|
+
|
19
|
+
ssl_bind "127.0.0.1", "8443", {
|
20
|
+
cert: ENV.fetch("JOBSHOP_SSL_CERT_FILE") {
|
21
|
+
File.join(Dir.pwd, ".ssl/jobshop.test.cert.pem")
|
22
|
+
},
|
23
|
+
key: ENV.fetch("JOBSHOP_SSL_KEY_FILE") {
|
24
|
+
File.join(Dir.pwd, ".ssl/jobshop.test.key.pem")
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
29
|
+
# Workers are forked web server processes. If using threads and workers together
|
30
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
31
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
32
|
+
# processes).
|
33
|
+
#
|
34
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
35
|
+
|
36
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
37
|
+
# This directive tells Puma to first boot the application and load code
|
38
|
+
# before forking the application. This takes advantage of Copy On Write
|
39
|
+
# process behavior so workers use less memory.
|
40
|
+
#
|
41
|
+
# preload_app!
|
42
|
+
|
43
|
+
# Allow puma to be restarted by `rails restart` command.
|
44
|
+
plugin :tmp_restart
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "generators/jobshop/app/app_generator"
|
2
4
|
|
3
5
|
module Jobshop
|
@@ -6,13 +8,6 @@ module Jobshop
|
|
6
8
|
# Do not generate README.md
|
7
9
|
end
|
8
10
|
|
9
|
-
# Comment out username, password from production group.
|
10
|
-
def config_database_yml
|
11
|
-
return if options[:pretend]
|
12
|
-
gsub_file "config/database.yml",
|
13
|
-
/^([ ]*[^#])(username: .*|password: .*)$/, '\1# \2'
|
14
|
-
end
|
15
|
-
|
16
11
|
# The db/migrate folder isn't created automatically.
|
17
12
|
def db_migrate
|
18
13
|
unless Dir.exist?("db/migrate")
|
@@ -48,13 +43,29 @@ module Jobshop
|
|
48
43
|
end
|
49
44
|
INITIALIZER
|
50
45
|
end
|
46
|
+
|
47
|
+
def dev_cert
|
48
|
+
FileUtils.mkdir_p(".ssl")
|
49
|
+
|
50
|
+
key_file = Pathname.pwd.join("../../.ssl/jobshop.test.key.pem")
|
51
|
+
cert_file = Pathname.pwd.join("../../.ssl/jobshop.test.cert.pem")
|
52
|
+
|
53
|
+
unless key_file.file? && cert_file.file?
|
54
|
+
Dir.chdir("../..") do
|
55
|
+
Jobshop::Generators::DevCertGenerator.start
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
FileUtils.cp(key_file, ".ssl")
|
60
|
+
FileUtils.cp(cert_file, ".ssl")
|
61
|
+
end
|
51
62
|
end
|
52
63
|
|
53
64
|
module Generators
|
54
65
|
class CanaryGenerator < Jobshop::Generators::AppGenerator
|
55
66
|
def self.source_paths
|
56
|
-
[
|
57
|
-
|
67
|
+
[ Jobshop::Generators::CanaryGenerator.source_root,
|
68
|
+
Rails::Generators::AppGenerator.source_root ]
|
58
69
|
end
|
59
70
|
|
60
71
|
hide!
|
@@ -69,6 +80,7 @@ module Jobshop
|
|
69
80
|
build :db_migrate
|
70
81
|
build :expose_mailer_previews
|
71
82
|
build :localhost_tld_length
|
83
|
+
build :dev_cert
|
72
84
|
super
|
73
85
|
end
|
74
86
|
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/base"
|
4
|
+
|
5
|
+
module Jobshop
|
6
|
+
module Generators
|
7
|
+
class DevCertGenerator < Rails::Generators::Base
|
8
|
+
source_root File.expand_path("../templates", __FILE__)
|
9
|
+
|
10
|
+
desc <<-DESC
|
11
|
+
Creates a self-signed certificate to enable https in the test and
|
12
|
+
development environments
|
13
|
+
DESC
|
14
|
+
|
15
|
+
def check_pwd
|
16
|
+
unless Jobshop::CLI.canary?
|
17
|
+
say_status :error, <<~MESSAGE
|
18
|
+
This command can only be run from the root of the Jobshop source
|
19
|
+
MESSAGE
|
20
|
+
|
21
|
+
exit 0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def make_dotssl_dir
|
26
|
+
FileUtils.mkdir_p(ssl_dir)
|
27
|
+
end
|
28
|
+
|
29
|
+
def check_existing_cert
|
30
|
+
if File.file?(key_file) && File.file?(cert_file)
|
31
|
+
say_status :exists, <<~MESSAGE
|
32
|
+
Jobshop development key/certificate pair already exists
|
33
|
+
MESSAGE
|
34
|
+
|
35
|
+
exit 0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def generate_openssl_conf
|
40
|
+
if !File.file?(config_file)
|
41
|
+
<<~`CONFIG`
|
42
|
+
cat > "#{config_file}" << EOF
|
43
|
+
[req]
|
44
|
+
distinguished_name = req_distinguished_name
|
45
|
+
x509_extensions = v3_req
|
46
|
+
prompt = no
|
47
|
+
|
48
|
+
[req_distinguished_name]
|
49
|
+
CN = Jobshop IO Development Environment
|
50
|
+
|
51
|
+
[v3_req]
|
52
|
+
keyUsage = keyEncipherment, dataEncipherment
|
53
|
+
extendedKeyUsage = serverAuth
|
54
|
+
subjectAltName = @alt_names
|
55
|
+
|
56
|
+
[alt_names]
|
57
|
+
DNS.1 = #{domain_name}
|
58
|
+
DNS.2 = *.#{domain_name}
|
59
|
+
DNS.3 = localhost
|
60
|
+
IP.1 = 127.0.0.1
|
61
|
+
EOF
|
62
|
+
CONFIG
|
63
|
+
else
|
64
|
+
say_status :skip, "#{config_file} already exists..."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def run_openssl_cmd
|
69
|
+
<<~`CMD`
|
70
|
+
openssl req \\
|
71
|
+
-newkey rsa:2048 \\
|
72
|
+
-nodes -x509 -days 365 \\
|
73
|
+
-keyout #{key_file} \\
|
74
|
+
-out #{cert_file} \\
|
75
|
+
-config #{config_file} \\
|
76
|
+
2> /dev/null
|
77
|
+
CMD
|
78
|
+
|
79
|
+
if $? == 0
|
80
|
+
puts <<~MESSAGE
|
81
|
+
A self-signed, wildcard SSL key/certificate pair has been generated for #{domain_name}\n
|
82
|
+
MESSAGE
|
83
|
+
else
|
84
|
+
abort <<~MESSAGE
|
85
|
+
An error has occured and the key/certificate pair were not generated
|
86
|
+
MESSAGE
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def print_trust_instructions
|
91
|
+
puts <<~MESSAGE
|
92
|
+
In order to trust this certificate on Mac OS X, run:
|
93
|
+
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain #{cert_file}
|
94
|
+
|
95
|
+
In order to trust this certificate on Ubuntu, run:
|
96
|
+
sudo cp #{cert_file} /usr/local/share/ca-certificates/
|
97
|
+
sudo update-ca-certificates -vf
|
98
|
+
MESSAGE
|
99
|
+
end
|
100
|
+
|
101
|
+
no_tasks do
|
102
|
+
def domain_name
|
103
|
+
@domain_name ||= "jobshop.test"
|
104
|
+
end
|
105
|
+
|
106
|
+
def ssl_dir
|
107
|
+
@ssl_dir ||= Pathname.pwd.join(".ssl")
|
108
|
+
end
|
109
|
+
|
110
|
+
def config_file
|
111
|
+
@config_file ||= File.join(ssl_dir, "openssl.conf")
|
112
|
+
end
|
113
|
+
|
114
|
+
def key_file
|
115
|
+
@key_file ||= File.join(ssl_dir, "#{domain_name}.key.pem")
|
116
|
+
end
|
117
|
+
|
118
|
+
def cert_file
|
119
|
+
@cert_file ||= File.join(ssl_dir, "#{domain_name}.cert.pem")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/lib/jobshop.rb
CHANGED
data/lib/jobshop/cli.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "thor"
|
4
4
|
require "jobshop/cli/application"
|
5
5
|
require "jobshop/cli/canary"
|
6
6
|
require "jobshop/cli/app_generator"
|
7
|
+
require "jobshop/version"
|
7
8
|
|
8
9
|
module Jobshop
|
9
10
|
module CLI
|
10
11
|
class << self
|
11
12
|
def start(argv = ARGV)
|
12
13
|
if [ "-v", "--version" ].include?(argv[0])
|
13
|
-
require "jobshop/version"
|
14
|
-
|
15
14
|
puts "Jobshop #{Jobshop.gem_version}"
|
15
|
+
puts Gem.loaded_specs["jobshop"].full_gem_path
|
16
16
|
exit 0
|
17
17
|
end
|
18
18
|
|
@@ -1,10 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "generators/jobshop/app/app_generator"
|
4
4
|
|
5
|
+
require "jobshop/cli/base"
|
6
|
+
|
5
7
|
module Jobshop
|
6
8
|
module CLI
|
7
|
-
class AppGenerator <
|
9
|
+
class AppGenerator < Base
|
8
10
|
default_task :help
|
9
11
|
|
10
12
|
desc "help", "Display long help"
|
@@ -20,19 +22,22 @@ module Jobshop
|
|
20
22
|
following options may not be changed:
|
21
23
|
|
22
24
|
--database=postgresql
|
25
|
+
--skip-coffee
|
26
|
+
--skip-javascript
|
27
|
+
--skip-sprockets
|
28
|
+
--skip-turbolinks
|
23
29
|
DESC
|
24
30
|
def new(*args)
|
25
31
|
Jobshop::Generators::AppGenerator.start(
|
26
|
-
args, jobshop_options: {
|
32
|
+
args, jobshop_options: {
|
33
|
+
database: "postgresql",
|
34
|
+
skip_coffee: true,
|
35
|
+
skip_javascript: true,
|
36
|
+
skip_sprockets: true,
|
37
|
+
skip_turbolinks: true
|
38
|
+
}
|
27
39
|
)
|
28
40
|
end
|
29
|
-
|
30
|
-
|
31
|
-
no_commands do
|
32
|
-
def require_environment!
|
33
|
-
require File.expand_path("spec/canary/config/environment")
|
34
|
-
end
|
35
|
-
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jobshop/cli/base"
|
2
4
|
|
3
5
|
module Jobshop
|
4
6
|
module CLI
|
5
|
-
class Application <
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require File.expand_path("config/environment")
|
10
|
-
end
|
7
|
+
class Application < Base
|
8
|
+
desc "setup", "Set up this jobshop application"
|
9
|
+
def setup
|
10
|
+
require_environment!
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "base64"
|
4
|
+
require "open3"
|
5
|
+
|
6
|
+
module Jobshop
|
7
|
+
module CLI
|
8
|
+
class Base < Thor
|
9
|
+
no_commands do
|
10
|
+
def print_header
|
11
|
+
say(set_color(Base64.decode64(%w(
|
12
|
+
ICAgICAgIF9fX19fXyAgX19fXyBfX19fXyBfXyAgX19fX19fICBfX19fCiAg
|
13
|
+
ICAgIC8gLyBfXyBcLyBfXyApIF9fXy8vIC8gLyAvIF9fIFwvIF9fIFwKIF8g
|
14
|
+
ICAvIC8gLyAvIC8gX18gIFxfXyBcLyAvXy8gLyAvIC8gLyAvXy8gLwovIC9f
|
15
|
+
LyAvIC9fLyAvIC9fLyAvX18vIC8gX18gIC8gL18vIC8gX19fXy8KXF9fX18v
|
16
|
+
XF9fX18vX19fX18vX19fXy9fLyAvXy9cX19fXy9fLwo=ICAg ).join
|
17
|
+
).prepend("\n"), :white, :bold))
|
18
|
+
say "Version: ", nil, false
|
19
|
+
say(set_color(Jobshop.gem_version, :white, :bold))
|
20
|
+
puts
|
21
|
+
end
|
22
|
+
|
23
|
+
def require_environment!
|
24
|
+
begin
|
25
|
+
require File.expand_path("spec/canary/config/environment")
|
26
|
+
rescue LoadError
|
27
|
+
abort "Canary app does not exist. Run `jobshop reset` to create it."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def quiet_command(command, status = nil, message = nil)
|
32
|
+
say_status(status, message, :white) if status
|
33
|
+
Open3.popen3(command) do |stdin, stdout, stderr, wait_thread|
|
34
|
+
stdout_t = Thread.new do
|
35
|
+
until (line = stdout.gets).nil? do
|
36
|
+
STDOUT.write(line) if options[:verbose]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Thread.new do
|
41
|
+
until (line = stderr.gets).nil? do
|
42
|
+
STDERR.write(line) if options[:verbose]
|
43
|
+
abort_message = <<~ABORT
|
44
|
+
An error occured and setup can not continue.
|
45
|
+
|
46
|
+
#{if !options[:verbose]
|
47
|
+
"Please rerun your command with the -v option to " +
|
48
|
+
"see complete error information."
|
49
|
+
end}
|
50
|
+
ABORT
|
51
|
+
|
52
|
+
say_status :error, abort_message
|
53
|
+
|
54
|
+
stdout_t.kill
|
55
|
+
abort
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
wait_thread.join
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/jobshop/cli/canary.rb
CHANGED
@@ -1,50 +1,148 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "base64"
|
4
|
+
require "open3"
|
2
5
|
|
3
6
|
require "generators/jobshop/canary/canary_generator"
|
7
|
+
require "generators/jobshop/dev_cert/dev_cert_generator"
|
8
|
+
|
9
|
+
require "jobshop/cli/base"
|
4
10
|
|
5
11
|
module Jobshop
|
6
12
|
module CLI
|
7
|
-
class Canary <
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
class Canary < Base
|
14
|
+
|
15
|
+
desc "devcert", "Generate the self-signed key/certificate pair for HTTPS"
|
16
|
+
def devcert
|
17
|
+
Jobshop::Generators::DevCertGenerator.start
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "server", "Runs the jobshop server with heroku local"
|
21
|
+
def server
|
22
|
+
Dir.chdir("spec/canary") do
|
23
|
+
exec("heroku local")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "reset [options]", "Recreate the development app"
|
20
28
|
def reset(*args)
|
21
29
|
FileUtils.rmtree(File.expand_path("spec/canary"))
|
22
30
|
Jobshop::Generators::CanaryGenerator.start(
|
23
31
|
args.unshift(File.expand_path("spec/canary")),
|
24
32
|
jobshop_options: {
|
25
33
|
database: "postgresql",
|
34
|
+
skip_bootsnap: true,
|
26
35
|
skip_bundle: true,
|
36
|
+
skip_coffee: true,
|
27
37
|
skip_gemfile: true,
|
28
38
|
skip_git: true,
|
39
|
+
skip_javascript: true,
|
29
40
|
skip_listen: true,
|
30
|
-
|
41
|
+
skip_sprockets: true,
|
42
|
+
skip_test: true,
|
43
|
+
skip_turbolinks: true
|
31
44
|
}
|
32
45
|
)
|
33
46
|
end
|
34
47
|
|
35
|
-
desc "seed", "Seed the
|
48
|
+
desc "seed", "Seed the Canary app"
|
36
49
|
def seed
|
37
50
|
require_environment!
|
38
51
|
Jobshop::Engine.load_seed
|
39
52
|
end
|
40
53
|
|
54
|
+
desc "setup", "Setup the development environment"
|
55
|
+
method_option :fast, aliases: "-f", type: :boolean, default: false,
|
56
|
+
desc: "Don't recreate app/database. Only seed and reset password."
|
57
|
+
method_option :password, aliases: "-p", type: :string,
|
58
|
+
desc: "Set password for initial development user"
|
59
|
+
method_option :verbose, aliases: "-v", type: :boolean, default: false,
|
60
|
+
desc: "Show all output"
|
61
|
+
def setup
|
62
|
+
File.file?("jobshop.gemspec") || abort(<<~ABORT)
|
63
|
+
Please run this command from the root of the Jobshop source tree.
|
64
|
+
ABORT
|
65
|
+
|
66
|
+
print_header
|
67
|
+
quiet_command(<<~COMMAND, :check, "dependencies") unless options[:fast]
|
68
|
+
gem install bundler --conservative
|
69
|
+
bundle check || bundle install
|
70
|
+
mkdir -p .git/safe
|
71
|
+
mkdir -p spec/canary
|
72
|
+
COMMAND
|
73
|
+
|
74
|
+
Dir.chdir "spec/canary" do
|
75
|
+
quiet_command(<<~COMMAND, :prepare, "environment")
|
76
|
+
if psql -lqt | cut -d \\| -f 1 | grep -qw canary_development; then
|
77
|
+
bundle exec rails db:environment:set RAILS_ENV=development
|
78
|
+
fi
|
79
|
+
COMMAND
|
80
|
+
end unless options[:fast]
|
81
|
+
|
82
|
+
quiet_command(<<~COMMAND, :install, "jobshop development app") unless options[:fast]
|
83
|
+
jobshop reset
|
84
|
+
COMMAND
|
85
|
+
|
86
|
+
quiet_command(<<~COMMAND, :seed, "pseudorandom development data")
|
87
|
+
jobshop seed
|
88
|
+
COMMAND
|
89
|
+
|
90
|
+
say_status :config, "environment template", :white
|
91
|
+
FileUtils.cp(".env", "spec/canary/.env") if File.file?(".env")
|
92
|
+
|
93
|
+
say_status :complete, "", :white
|
94
|
+
say ""
|
95
|
+
|
96
|
+
login_link = if options[:password]
|
97
|
+
login_with_password_link(options[:password])
|
98
|
+
else
|
99
|
+
reset_password_link
|
100
|
+
end
|
101
|
+
|
102
|
+
message = <<~MESSAGE
|
103
|
+
Thank you for installing #{set_color("Jobshop", :white, :bold)}.
|
104
|
+
|
105
|
+
You can start the server by running:
|
106
|
+
|
107
|
+
jobshop server
|
108
|
+
|
109
|
+
Then open your browser and go to:
|
110
|
+
|
111
|
+
#{login_link}
|
112
|
+
|
113
|
+
MESSAGE
|
114
|
+
|
115
|
+
say message
|
116
|
+
end
|
117
|
+
|
41
118
|
no_commands do
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
119
|
+
def login_with_password_link(password)
|
120
|
+
require_environment!
|
121
|
+
|
122
|
+
resource.password = resource.password_confirmation = password
|
123
|
+
resource.save
|
124
|
+
|
125
|
+
Jobshop::Engine.routes.url_helpers.new_user_session_url(
|
126
|
+
protocol: :https, host: link_host, port: 8443,
|
127
|
+
user: { email: resource.email })
|
128
|
+
end
|
129
|
+
def reset_password_link
|
130
|
+
require_environment!
|
131
|
+
|
132
|
+
token = resource.send :set_reset_password_token
|
133
|
+
|
134
|
+
@reset_password_link ||=
|
135
|
+
Jobshop::Engine.routes.url_helpers.edit_user_password_url(
|
136
|
+
host: link_host, reset_password_token: token)
|
137
|
+
end
|
138
|
+
|
139
|
+
private def resource
|
140
|
+
@resource ||= Jobshop::Organization.order(created_at: :desc).first
|
141
|
+
.users.order(created_at: :desc).first
|
142
|
+
end
|
143
|
+
|
144
|
+
private def link_host
|
145
|
+
@link_host ||= Rails.env.development? ? "jobshop.test" : "HOSTNAME"
|
48
146
|
end
|
49
147
|
end
|
50
148
|
end
|