ucb_rails_cli 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ucb_rails_cli/cli.rb +37 -16
- data/lib/ucb_rails_cli/templates/Gemfile_additions +1 -0
- data/lib/ucb_rails_cli/templates/config/credentials.yml.enc +1 -0
- data/lib/ucb_rails_cli/templates/config/initializers/ucb_rails_user.rb +5 -5
- data/lib/ucb_rails_cli/templates/images/favicon.ico +0 -0
- data/lib/ucb_rails_cli/templates/views/application.html.haml +1 -1
- data/lib/ucb_rails_cli/version.rb +1 -1
- metadata +4 -3
- data/lib/ucb_rails_cli/templates/config/config.yml +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0103220bf27f390a8b9fce5b8cf6dfe7d59ed9556b711be88516634fe35c599
|
4
|
+
data.tar.gz: 8bc8a61fa94110b467e793803db39818044a27b8d47b9d23f2516bce2a2fc14d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d1a23f4ffdbf192b5970fec3be34617f6017859974153ad7a269062337c52fba0fd422928c7aa4707bde7ed42d93e8198fb3443d3b2e18f2c2d1d598601ac22
|
7
|
+
data.tar.gz: e298b4378a62dca4659401765505eb4b480aa7bd0f6735c9414fed6eac97cba633dcc8bd6a2002dd18bdbe57e6e31eb8dac280cd72beffeb952223f4647787a1
|
data/lib/ucb_rails_cli/cli.rb
CHANGED
@@ -2,8 +2,13 @@ require "thor"
|
|
2
2
|
|
3
3
|
module UcbRailsCli
|
4
4
|
class Cli < Thor
|
5
|
+
MASTER_KEY_PATH = File.expand_path("~/.ucb_rails_master_key")
|
6
|
+
|
5
7
|
## error messages
|
6
8
|
INSTALL_RAILS = "Unable to find rails - please make sure you've installed Rails 5.1 or greater"
|
9
|
+
VERIFY_KEY = "Unable to find the master key for encrypted credentials\n" +
|
10
|
+
"in #{MASTER_KEY_PATH} or the RAILS_MASTER_KEY environment variable.\n" +
|
11
|
+
"Please set the master key in one of these two places before proceeding."
|
7
12
|
GEMFILE_ERROR = "Unable to add new gems to Gemfile - check the console output for more info"
|
8
13
|
LAYOUT_FILES = "Unable to copy view templates - check the console output for more info"
|
9
14
|
HELPER_FILES = "Unable to copy helpers - check the console output for more info"
|
@@ -12,7 +17,6 @@ module UcbRailsCli
|
|
12
17
|
MIGRATIONS = "Unable to copy migrations from ucb_rails_user gem - check the console output for more info"
|
13
18
|
CONTROLLERS = "Unable to copy controllers - check the console output for more info"
|
14
19
|
CONFIG_FILES = "Unable to copy config files - check the console output for more info"
|
15
|
-
GITIGNORE = "Unable to update .gitignore - check the console output for more info"
|
16
20
|
RSPEC = "Unable to install RSpec - check the console output for more info"
|
17
21
|
|
18
22
|
desc 'version', 'Display version'
|
@@ -28,6 +32,8 @@ module UcbRailsCli
|
|
28
32
|
|
29
33
|
verify_rails or exit_with_error(INSTALL_RAILS)
|
30
34
|
|
35
|
+
verify_master_key or exit_with_error(VERIFY_KEY)
|
36
|
+
|
31
37
|
create_rails_app(app_name) or exit_with_error
|
32
38
|
|
33
39
|
add_to_gemfile(app_name) or exit_with_error(GEMFILE_ERROR)
|
@@ -44,8 +50,6 @@ module UcbRailsCli
|
|
44
50
|
|
45
51
|
add_config_files(app_name) or exit_with_error(CONFIG_FILES)
|
46
52
|
|
47
|
-
update_gitignore(app_name) or exit_with_error(GITIGNORE)
|
48
|
-
|
49
53
|
install_migrations(app_name) or exit_with_error(MIGRATIONS)
|
50
54
|
|
51
55
|
setup_rspec(app_name) or exit_with_error(RSPEC)
|
@@ -61,10 +65,7 @@ From here, you should set up the database:
|
|
61
65
|
bin/rake db:create
|
62
66
|
bin/rake db:migrate
|
63
67
|
|
64
|
-
then
|
65
|
-
credentials from another developer.
|
66
|
-
|
67
|
-
At that point, you can start the server as usual:
|
68
|
+
then start the server as usual:
|
68
69
|
|
69
70
|
bin/rails server
|
70
71
|
|
@@ -91,6 +92,10 @@ Enjoy!
|
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
95
|
+
def verify_master_key
|
96
|
+
ENV["RAILS_MASTER_KEY"].to_s.length > 0 || FileTest.file?(MASTER_KEY_PATH)
|
97
|
+
end
|
98
|
+
|
94
99
|
def create_rails_app(app_name)
|
95
100
|
result = system("rails new #{app_name} #{options[:rails_options]}")
|
96
101
|
return true if result
|
@@ -101,7 +106,6 @@ Enjoy!
|
|
101
106
|
end
|
102
107
|
|
103
108
|
def add_to_gemfile(app_name)
|
104
|
-
puts "Adding gems to Gemfile..."
|
105
109
|
if system("cat #{template_dir}/Gemfile_additions >> #{app_name}/Gemfile")
|
106
110
|
puts "Installing new gems..."
|
107
111
|
system "cd #{app_name} && bundle install"
|
@@ -152,18 +156,35 @@ Enjoy!
|
|
152
156
|
|
153
157
|
def add_config_files(app_name)
|
154
158
|
puts "Installing config files..."
|
155
|
-
system("cp #{template_dir}/config/
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
159
|
+
system("cp #{template_dir}/config/initializers/ucb_rails_user.rb #{app_name}/config/initializers")
|
160
|
+
system("cp #{template_dir}/config/credentials.yml.enc #{app_name}/config/")
|
161
|
+
|
162
|
+
# add exeception_notification config to production.rb config
|
163
|
+
prod_config_addition = <<-END_CONFIG
|
164
|
+
|
165
|
+
config.middleware.use ExceptionNotification::Rack,
|
166
|
+
email: {
|
167
|
+
email_prefix: "[#{app_name}] ",
|
168
|
+
sender_address: %{"notifier" <notifier@example.com>},
|
169
|
+
exception_recipients: %w{ucb-ist-developers@berkeley.edu}
|
170
|
+
}
|
171
|
+
end
|
172
|
+
END_CONFIG
|
173
|
+
prod_config_contents =
|
174
|
+
`cat #{app_name}/config/environments/production.rb`
|
175
|
+
.gsub(/end\s\Z/, prod_config_addition)
|
176
|
+
system "echo '#{prod_config_contents}' > #{app_name}/config/environments/production.rb"
|
177
|
+
|
178
|
+
# move master key, unless in ENV
|
179
|
+
unless ENV["MASTER_KEY_PATH"].to_s.length > 0
|
180
|
+
system "cp ~/.ucb_rails_master_key #{app_name}/config/master.key"
|
181
|
+
end
|
162
182
|
end
|
163
183
|
|
164
184
|
def install_migrations(app_name)
|
165
185
|
puts "Installing migrations from ucb_rails_user..."
|
166
|
-
system "cd #{app_name} &&
|
186
|
+
system "cd #{app_name} && bundle install"
|
187
|
+
system "cd #{app_name} && bundle exec rails railties:install:migrations"
|
167
188
|
end
|
168
189
|
|
169
190
|
def setup_rspec(app_name)
|
@@ -0,0 +1 @@
|
|
1
|
+
5aYApt8O3JvcZLz7Ks7YBiyR1ByfGjQpMI75JSCj6YwkNDSFFkBlpTFyMa0ZIVzulckt2PTcatdvMf091gHQPEPhp+ak42wx3fJfOKS4ENfqWUjWdSTlvho4p8sTK74prBTZbXm2ZnxJtRsiqsW4JCgSauFWIdLK1l7paSWJxd+5+LEsgQ+UGucILgSx+XyTed30ia5GTjf9sfSbgReafsNzT7vugAS40dO+FA/klrG+GylkN9RU45CUikKYq+1UAnLSXB6E7ap9yAR2CPTUO8g8XQVry2Kre93mN6GhNrUQJdGElUR1d86Dm7q6pe2E8HZMeMiHFKQv8x/KEYnsfR1XSo1XBbGnEEAl9cTL+eZxDX0wsd2gdwc4R4l4yKCZsnnBjjfBj+viRf46cj9f9Jgf1LtJWDOxHteqSjF2Dkr++taWhyq0CtqVpbuTocgnxkunAlztEnCjY/mPd7whYbbAA5LotrxSbEXX748EpkzkHvzSbNGhamOtOxGe3bS44E5FYY3iCOYHJ9JVgCu9OqxBFbHyEni/a2ZZl4pPFnmthWK4ttd6wt+BpDBy51X8sI7qV98j1WtAlJgi+0l3/uNKKh6EypzLjbfwVo/AJ8GXJm102thes07dbXrSSK0bIANW4QHCOarkEHLe8XPI02FDvSgX73Azpyx//HFRuK5R/1YMAM7aH+cSk7EmChJJKsmM/obP/8iOg47undL68PtXBr95zLf6QaGVLU0P10hs44b0AWbsU6t37MAxBbYTGRomZvnYxQiBwWR3t9OM8cJfBWmLd25I1kzQsSjErOKSydbLnMuajuBNHxS+oUUI7eQv9CrZ3D61TMEnYxqG3mMVzDbl4E40rjFLHM9rDJPP6o7nW0rtpe8vuLvgBOwt6JVSwOjayjaEycHDJ4065QqcPmP4pdGZqol1+PozrnQB+n9MJsVo2HthZ/WSRgWqpWeEE+jJFtV7Gv6OXOZOzRFpVBW0K72X6CB9g3QeYE8fBsPpku+eAQkjJ8RURBbSardogyYuL+qd2ebQyOsOgb8j--L1pojtO3q6FJMDIz--xTFJPtWOpOvLygaaSKjX2g==
|
@@ -1,14 +1,14 @@
|
|
1
1
|
############################################################
|
2
|
-
# Load configuration from config/
|
2
|
+
# Load configuration from config/credentials.yml.enc
|
3
3
|
############################################################
|
4
4
|
|
5
|
-
|
5
|
+
credentials = Rails.application.credentials
|
6
6
|
|
7
7
|
############################################################
|
8
8
|
# ActionMailer
|
9
9
|
############################################################
|
10
10
|
|
11
|
-
|
11
|
+
UcbRailsUser::Configuration::Email.configure(credentials.email&.with_indifferent_access())
|
12
12
|
|
13
13
|
############################################################
|
14
14
|
# Exception Notification
|
@@ -20,13 +20,13 @@ config = UcbRailsUser::Configuration::Configuration.new
|
|
20
20
|
# UCB::LDAP
|
21
21
|
############################################################
|
22
22
|
|
23
|
-
UcbRailsUser::Configuration::Ldap.configure(
|
23
|
+
UcbRailsUser::Configuration::Ldap.configure(credentials.ldap&.with_indifferent_access())
|
24
24
|
|
25
25
|
############################################################
|
26
26
|
# OmniAuth
|
27
27
|
############################################################
|
28
28
|
|
29
|
-
UcbRailsUser::Configuration::Cas.configure(
|
29
|
+
UcbRailsUser::Configuration::Cas.configure(credentials.cas&.with_indifferent_access())
|
30
30
|
|
31
31
|
############################################################
|
32
32
|
# UcbRails
|
Binary file
|
@@ -11,7 +11,7 @@
|
|
11
11
|
%link{:rel => "stylesheet", :href => "https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css", :integrity => "sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B", :crossorigin => "anonymous"}
|
12
12
|
%link{:rel => "stylesheet", :href => "https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" }
|
13
13
|
%link{:rel => "stylesheet", :href => "https://jqueryui.com/resources/demos/style.css" }
|
14
|
-
|
14
|
+
= favicon_link_tag
|
15
15
|
|
16
16
|
= stylesheet_link_tag "application", :media => "all", "data-turbolinks-track" => false
|
17
17
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ucb_rails_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darin Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -90,12 +90,13 @@ files:
|
|
90
90
|
- lib/ucb_rails_cli.rb
|
91
91
|
- lib/ucb_rails_cli/cli.rb
|
92
92
|
- lib/ucb_rails_cli/templates/Gemfile_additions
|
93
|
-
- lib/ucb_rails_cli/templates/config/
|
93
|
+
- lib/ucb_rails_cli/templates/config/credentials.yml.enc
|
94
94
|
- lib/ucb_rails_cli/templates/config/initializers/ucb_rails_user.rb
|
95
95
|
- lib/ucb_rails_cli/templates/config/routes.rb
|
96
96
|
- lib/ucb_rails_cli/templates/controllers/application_controller.rb
|
97
97
|
- lib/ucb_rails_cli/templates/helpers/application_helper.rb
|
98
98
|
- lib/ucb_rails_cli/templates/images/.keep
|
99
|
+
- lib/ucb_rails_cli/templates/images/favicon.ico
|
99
100
|
- lib/ucb_rails_cli/templates/images/logo-ucberkeley-white.png
|
100
101
|
- lib/ucb_rails_cli/templates/javascripts/application.js
|
101
102
|
- lib/ucb_rails_cli/templates/stylesheets/application.css
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# You can have configuration per-environment by nesting under the
|
2
|
-
# environment key, or have a top level.
|
3
|
-
|
4
|
-
ldap:
|
5
|
-
host: "nds.berkeley.edu"
|
6
|
-
username:
|
7
|
-
password:
|
8
|
-
|
9
|
-
development:
|
10
|
-
|
11
|
-
# Default behavior will do the right thing. Only set if you want
|
12
|
-
# non-standard behavior.
|
13
|
-
# cas:
|
14
|
-
# host: 'auth.berkeley.edu'
|
15
|
-
# host: 'auth-test.berkeley.edu'
|
16
|
-
|
17
|
-
# email:
|
18
|
-
# default:
|
19
|
-
# from: user@gmail.com
|
20
|
-
# default_url_options:
|
21
|
-
# host: example.com
|
22
|
-
# delivery_method: :smtp
|
23
|
-
# # delivery_method: :sendmail
|
24
|
-
# # delivery_method: :test
|
25
|
-
# # delivery_method: :file
|
26
|
-
# raise_delivery_errors: true
|
27
|
-
# # send_mail_settings:
|
28
|
-
# # location: "/usr/sbin/sendmail"
|
29
|
-
# # arguments: "-i -t"
|
30
|
-
# smtp_settings:
|
31
|
-
# address: smtp.gmail.com
|
32
|
-
# port: 587
|
33
|
-
# domain: gmail.com
|
34
|
-
# user_name: <username>
|
35
|
-
# password: <password>
|
36
|
-
# authentication: plain
|
37
|
-
# enable_starttls_auto: true
|
38
|
-
# subject_prefix: '[My App {env}] '
|
39
|
-
|
40
|
-
# exception_notification:
|
41
|
-
# email:
|
42
|
-
# email_prefix: '[My App - Error {env}] '
|
43
|
-
# sender_address: user@example.com
|
44
|
-
# exception_recipients:
|
45
|
-
# - user1@example.com
|
46
|
-
# - user2@example.com
|
47
|
-
|
48
|
-
# Default behavior will select the correct host. No need to set anything if
|
49
|
-
# you aren't specifying username/password.
|
50
|
-
# ldap:
|
51
|
-
# host: 'nds.berkeley.edu'
|
52
|
-
# host: 'nds-test.berkeley.edu'
|
53
|
-
# username: <username>
|
54
|
-
# password: <password>
|
55
|
-
# # by default test entries returned in all but PROD
|
56
|
-
# include_test_entries: true
|
57
|
-
# include_test_entries: false
|
58
|
-
|
59
|
-
|
60
|
-
test:
|
61
|
-
email:
|
62
|
-
default:
|
63
|
-
from: test-user@examle.com
|
64
|
-
default_url_options:
|
65
|
-
host: example.com
|
66
|
-
delivery_method: :test
|
67
|
-
raise_delivery_errors: true
|
68
|
-
subject_prefix: '[My App {env}] '
|
69
|
-
|