jets 1.9.32 → 2.0.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/CHANGELOG.md +9 -0
- data/lib/jets/application/defaults.rb +6 -0
- data/lib/jets/cli.rb +9 -0
- data/lib/jets/commands/help/generate.md +25 -19
- data/lib/jets/commands/main.rb +3 -3
- data/lib/jets/commands/rake_tasks.rb +3 -0
- data/lib/jets/commands/templates/skeleton/app/views/layouts/application.html.erb.tt +1 -0
- data/lib/jets/commands/templates/skeleton/config/application.rb.tt +4 -0
- data/lib/jets/commands/templates/webpacker/app/javascript/src/jets/crud.js +3 -0
- data/lib/jets/commands/upgrade.rb +42 -109
- data/lib/jets/commands/upgrade/version1.rb +136 -0
- data/lib/jets/controller/base.rb +16 -0
- data/lib/jets/controller/error.rb +4 -0
- data/lib/jets/controller/error/invalid_authenticity_token.rb +6 -0
- data/lib/jets/controller/forgery_protection.rb +43 -0
- data/lib/jets/controller/middleware/local.rb +3 -3
- data/lib/jets/controller/middleware/local/route_matcher.rb +1 -1
- data/lib/jets/controller/middleware/main.rb +7 -1
- data/lib/jets/controller/rack/adapter.rb +1 -1
- data/lib/jets/controller/rack/env.rb +1 -1
- data/lib/jets/controller/rendering/rack_renderer.rb +44 -37
- data/lib/jets/controller/stage.rb +2 -1
- data/lib/jets/generator.rb +72 -8
- data/lib/jets/generator/templates/active_job/job/templates/application_job.rb.tt +6 -0
- data/lib/jets/generator/templates/active_job/job/templates/job.rb.tt +8 -0
- data/lib/jets/generator/templates/erb/scaffold/_form.html.erb +11 -16
- data/lib/jets/generator/templates/erb/scaffold/edit.html.erb +2 -2
- data/lib/jets/generator/templates/erb/scaffold/index.html.erb +5 -5
- data/lib/jets/generator/templates/erb/scaffold/new.html.erb +1 -1
- data/lib/jets/generator/templates/erb/scaffold/show.html.erb +3 -3
- data/lib/jets/generator/templates/rails/scaffold_controller/controller.rb +5 -5
- data/lib/jets/internal/app/controllers/jets/rack_controller.rb +1 -0
- data/lib/jets/overrides/rails.rb +2 -1
- data/lib/jets/overrides/rails/action_controller.rb +12 -0
- data/lib/jets/overrides/rails/url_helper.rb +66 -5
- data/lib/jets/resource/api_gateway/rest_api/routes/change/base.rb +1 -1
- data/lib/jets/resource/api_gateway/rest_api/routes/collision.rb +1 -1
- data/lib/jets/router.rb +32 -46
- data/lib/jets/router/dsl.rb +136 -0
- data/lib/jets/router/error.rb +4 -0
- data/lib/jets/router/helpers.rb +4 -0
- data/lib/jets/router/helpers/core_helper.rb +17 -0
- data/lib/jets/router/helpers/named_routes_helper.rb +8 -0
- data/lib/jets/router/method_creator.rb +54 -0
- data/lib/jets/router/method_creator/code.rb +98 -0
- data/lib/jets/router/method_creator/edit.rb +7 -0
- data/lib/jets/router/method_creator/generic.rb +11 -0
- data/lib/jets/router/method_creator/index.rb +42 -0
- data/lib/jets/router/method_creator/new.rb +7 -0
- data/lib/jets/router/method_creator/root.rb +15 -0
- data/lib/jets/router/method_creator/show.rb +7 -0
- data/lib/jets/router/resources/base.rb +7 -0
- data/lib/jets/router/resources/filter.rb +15 -0
- data/lib/jets/router/resources/options.rb +13 -0
- data/lib/jets/router/route.rb +226 -0
- data/lib/jets/router/scope.rb +65 -4
- data/lib/jets/router/util.rb +38 -0
- data/lib/jets/turbo/project/config/application.rb +1 -0
- data/lib/jets/version.rb +1 -1
- metadata +26 -2
- data/lib/jets/route.rb +0 -166
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90b750940941cb6ebaa69fc6a0cda74dc858db9f646a2c90b5a90e1b037518d8
|
4
|
+
data.tar.gz: b591655943debcf36b60618e11745d172658dd3fe7415a9ab46c6e4e2adf4c27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 694c37c3c6331c565441ae486643969bdebc914ec193ca8fdec5d36fb928915aee9ede4c8fbe689b06fef1a52f6bd8072188b4796c247e16e9b9bb810163dfbb
|
7
|
+
data.tar.gz: b28b1b16569a58d06e647a3d05ac8ecdb9d0ba7e615870d82273d6911da31386ae7c86593a97ee41933ed6aa592eae3b92b407ad5b8cb5d2a11fa0f3c98fd0fd
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,15 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [2.0.0]
|
7
|
+
- #318 Major Routing upgrade
|
8
|
+
- Routing Upgrades: nested resources, namespace, scope, singular resource
|
9
|
+
- Name routes helpers
|
10
|
+
- Forgery protection
|
11
|
+
- Generators upgrades: scaffold, controller, model, job, etc
|
12
|
+
- Autoload Rake tasks in lib/tasks.
|
13
|
+
- Update upgrading docs
|
14
|
+
|
6
15
|
## [1.9.32]
|
7
16
|
- #317 fix jets deploy when no /tmp/jets exists yet
|
8
17
|
|
@@ -139,6 +139,12 @@ class Jets::Application
|
|
139
139
|
# So tried to defined this in the jets/mailer.rb Turbine only but jets new requires it
|
140
140
|
# config.action_mailer = ActiveSupport::OrderedOptions.new
|
141
141
|
|
142
|
+
config.helpers = ActiveSupport::OrderedOptions.new
|
143
|
+
config.helpers.host = nil # nil by default. Other examples: https://myurl.com:8888
|
144
|
+
|
145
|
+
config.controllers = ActiveSupport::OrderedOptions.new
|
146
|
+
config.controllers.default_protect_from_forgery = true
|
147
|
+
|
142
148
|
config
|
143
149
|
end
|
144
150
|
|
data/lib/jets/cli.rb
CHANGED
@@ -76,6 +76,15 @@ class Jets::CLI
|
|
76
76
|
def thor_args
|
77
77
|
args = @given_args.clone
|
78
78
|
|
79
|
+
# jets generate is a special command requires doesn't puts out the help menu automatically when
|
80
|
+
# `jets generate` is called without additional args. We'll take it over early and fix it here.
|
81
|
+
autocomplete_command = Jets::Commands::Base.autocomplete(args[0])
|
82
|
+
generate = autocomplete_command == "generate"
|
83
|
+
if generate && (args.size == 1 || help_flags.include?(args.last))
|
84
|
+
puts Jets::Generator.help
|
85
|
+
exit
|
86
|
+
end
|
87
|
+
|
79
88
|
help_args = args & help_flags
|
80
89
|
unless help_args.empty?
|
81
90
|
# Allow using help flags at the end of the command to trigger help menu
|
@@ -1,22 +1,28 @@
|
|
1
1
|
This piggy backs off of the [rails scaffold generator](https://guides.rubyonrails.org/command_line.html#rails-generate).
|
2
2
|
|
3
|
-
##
|
3
|
+
## General options
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
5
|
+
-h, [--help] # Print generator's options and usage
|
6
|
+
-p, [--pretend] # Run but do not make any changes
|
7
|
+
-f, [--force] # Overwrite files that already exist
|
8
|
+
-s, [--skip] # Skip files that already exist
|
9
|
+
-q, [--quiet] # Suppress status output
|
10
|
+
|
11
|
+
Please choose a generator below.
|
12
|
+
|
13
|
+
Jets:
|
14
|
+
|
15
|
+
application_record
|
16
|
+
controller
|
17
|
+
helper
|
18
|
+
job
|
19
|
+
migration
|
20
|
+
model
|
21
|
+
resource
|
22
|
+
scaffold
|
23
|
+
scaffold_controller
|
24
|
+
task
|
25
|
+
|
26
|
+
ActiveRecord:
|
27
|
+
|
28
|
+
active_record:application_record
|
data/lib/jets/commands/main.rb
CHANGED
@@ -51,7 +51,7 @@ module Jets::Commands
|
|
51
51
|
desc "routes", "Print out your application routes"
|
52
52
|
long_desc Help.text(:routes)
|
53
53
|
def routes
|
54
|
-
puts Jets::Router.
|
54
|
+
puts Jets::Router.help(Jets::Router.routes)
|
55
55
|
end
|
56
56
|
|
57
57
|
desc "console", "REPL console with Jets environment loaded"
|
@@ -97,13 +97,13 @@ module Jets::Commands
|
|
97
97
|
end
|
98
98
|
|
99
99
|
desc "generate [type] [args]", "Generates things like scaffolds"
|
100
|
-
long_desc
|
100
|
+
long_desc Jets::Generator.help
|
101
101
|
def generate(generator, *args)
|
102
102
|
Jets::Generator.invoke(generator, *args)
|
103
103
|
end
|
104
104
|
|
105
105
|
desc "degenerate [type] [args]", "Destroys things like scaffolds"
|
106
|
-
long_desc
|
106
|
+
long_desc Jets::Generator.help
|
107
107
|
def degenerate(generator, *args)
|
108
108
|
Jets::Generator.revoke(generator, *args)
|
109
109
|
end
|
@@ -5,6 +5,7 @@
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
6
6
|
<meta name="theme-color" content="#000000">
|
7
7
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
8
|
+
<%%= csrf_meta_tags %>
|
8
9
|
<title>Jets App</title>
|
9
10
|
<%%= javascript_pack_tag "application" %>
|
10
11
|
<%%= stylesheet_pack_tag "theme" %>
|
@@ -64,4 +64,8 @@ Jets.application.configure do
|
|
64
64
|
# local testing environment you may want to log these messages to 'test.log' file to keep your
|
65
65
|
# testing suite output readable.
|
66
66
|
# config.logger = Jets::Logger.new($strerr)
|
67
|
+
|
68
|
+
<% if @options[:mode] == 'api' -%>
|
69
|
+
config.controllers.default_protect_from_forgery = false
|
70
|
+
<% end -%>
|
67
71
|
end
|
@@ -66,9 +66,12 @@ $(function() {
|
|
66
66
|
node.hide(); // immediately hide element
|
67
67
|
|
68
68
|
var resource = link.attr("href");
|
69
|
+
var token = $('meta[name=csrf-token]').attr('content');
|
70
|
+
var data = { authenticity_token: token };
|
69
71
|
var request = $.ajax({
|
70
72
|
url: resource,
|
71
73
|
method: "DELETE",
|
74
|
+
data: data,
|
72
75
|
dataType: "json"
|
73
76
|
});
|
74
77
|
|
@@ -9,138 +9,71 @@ module Jets::Commands
|
|
9
9
|
|
10
10
|
def run
|
11
11
|
puts "Upgrading to Jets structure to latest version"
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
update_webpack_binstubs
|
18
|
-
add_dynomite_to_gemfile
|
12
|
+
Version1.new.run
|
13
|
+
# version 2 upgrades
|
14
|
+
inject_csrf_meta_tags
|
15
|
+
update_crud_js
|
16
|
+
update_config_application_rb
|
19
17
|
puts "Upgrade complete."
|
20
18
|
end
|
21
19
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
Dir.glob("#{path}/*").each do |src|
|
26
|
-
config_file = "config/environments/#{File.basename(src)}"
|
27
|
-
dest = "#{Jets.root}/#{config_file}"
|
20
|
+
def inject_csrf_meta_tags
|
21
|
+
layout = "app/views/layouts/application.html.erb"
|
22
|
+
return unless File.exist?(layout)
|
28
23
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
puts "Create: #{config_file}"
|
33
|
-
FileUtils.mkdir_p(File.dirname(dest))
|
34
|
-
FileUtils.cp(src, dest)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def update_routes
|
40
|
-
routes_file = "#{Jets.root}/config/routes.rb"
|
41
|
-
return unless File.exist?(routes_file)
|
42
|
-
|
43
|
-
lines = IO.readlines(routes_file)
|
44
|
-
deprecated_code = 'root "jets/welcome#index"'
|
45
|
-
return unless lines.detect { |l| l.include?(deprecated_code) }
|
24
|
+
lines = IO.readlines(layout)
|
25
|
+
csrf_meta_tags = lines.find { |l| l =~ /<%= csrf_meta_tags %>/ }
|
26
|
+
return if csrf_meta_tags
|
46
27
|
|
47
|
-
puts "Update:
|
28
|
+
puts "Update: #{layout} with csrf_meta_tags helper"
|
48
29
|
lines.map! do |line|
|
49
|
-
if line.include?(
|
50
|
-
|
30
|
+
if line.include?("<head>")
|
31
|
+
# add csrf_meta_tags helper
|
32
|
+
"#{line} <%= csrf_meta_tags %>\n"
|
51
33
|
else
|
52
34
|
line
|
53
35
|
end
|
54
36
|
end
|
55
37
|
|
56
38
|
content = lines.join
|
57
|
-
IO.write(
|
39
|
+
IO.write(layout, content)
|
58
40
|
end
|
59
41
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
return unless lines.detect { |l| l.include?(deprecated_code) }
|
65
|
-
|
66
|
-
puts "Update: config/application.rb"
|
67
|
-
lines.map! do |line|
|
68
|
-
if line.include?(deprecated_code)
|
69
|
-
mode = Jets.config.api_generator ? 'api' : 'html'
|
70
|
-
%Q| config.mode = "#{mode}"\n| # assume 2 spaces for simplicity
|
71
|
-
else
|
72
|
-
line
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
content = lines.join
|
77
|
-
IO.write(application_file, content)
|
78
|
-
end
|
42
|
+
def update_crud_js
|
43
|
+
src = File.expand_path("templates/webpacker/app/javascript/src/jets/crud.js", File.dirname(__FILE__))
|
44
|
+
dest = "app/javascript/src/jets/crud.js"
|
45
|
+
return unless File.exist?(dest)
|
79
46
|
|
80
|
-
|
81
|
-
|
82
|
-
return
|
83
|
-
config_ru = File.read(src)
|
84
|
-
return if config_ru.include?("Jets.boot")
|
47
|
+
lines = IO.readlines(dest)
|
48
|
+
csrf = lines.find { |l| l =~ /csrf-token/ }
|
49
|
+
return if csrf
|
85
50
|
|
86
|
-
|
87
|
-
dest = src
|
88
|
-
puts "Update: config.ru"
|
51
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
89
52
|
FileUtils.cp(src, dest)
|
53
|
+
puts "Update: #{dest}"
|
90
54
|
end
|
91
55
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def remove_ruby_lazy_load_for(path)
|
101
|
-
lines = IO.readlines(path)
|
102
|
-
new_lines = lines.reject do |l|
|
103
|
-
l =~ %r{config.ruby.lazy_load}
|
104
|
-
end
|
105
|
-
return unless lines != new_lines
|
106
|
-
|
107
|
-
content = new_lines.join("")
|
108
|
-
IO.write(path, content)
|
109
|
-
puts "Update: #{path}"
|
110
|
-
end
|
111
|
-
|
112
|
-
def update_webpack_binstubs
|
113
|
-
return unless File.exist?("bin/webpack")
|
114
|
-
lines = IO.readlines("bin/webpack")
|
115
|
-
already_upgraded = lines.detect { |l| l =~ /WebpackRunner/ }
|
116
|
-
return if already_upgraded
|
117
|
-
|
118
|
-
update_project_file("bin/webpack")
|
119
|
-
update_project_file("bin/webpack-dev-server")
|
120
|
-
puts "Updated webpack binstubs."
|
121
|
-
end
|
122
|
-
|
123
|
-
def add_dynomite_to_gemfile
|
124
|
-
return unless File.exist?("app/models/application_item.rb")
|
56
|
+
def update_config_application_rb
|
57
|
+
app_rb = "config/application.rb"
|
58
|
+
lines = IO.readlines(app_rb)
|
59
|
+
api_mode = lines.find { |l| l =~ /config\.mode/ && l =~ /api/ }
|
60
|
+
return unless api_mode
|
125
61
|
|
126
|
-
|
127
|
-
|
128
|
-
return if dynomite_found
|
62
|
+
forgery = lines.find { |l| l =~ /default_protect_from_forgery/ }
|
63
|
+
return if forgery
|
129
64
|
|
130
|
-
|
131
|
-
|
65
|
+
lines.map! do |line|
|
66
|
+
if line =~ /^end/
|
67
|
+
# add default_protect_from_forgery = false
|
68
|
+
" config.controllers.default_protect_from_forgery = false\n#{line}"
|
69
|
+
else
|
70
|
+
line
|
71
|
+
end
|
132
72
|
end
|
133
|
-
puts "Updated Gemfile: add dynomite gem"
|
134
|
-
end
|
135
73
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
src = "#{templates}/#{relative_path}"
|
140
|
-
dest = relative_path
|
141
|
-
FileUtils.mkdir_p(File.dirname(dest))
|
142
|
-
FileUtils.cp(src, dest)
|
143
|
-
puts "Update: #{dest}"
|
74
|
+
content = lines.join
|
75
|
+
IO.write(app_rb, content)
|
76
|
+
puts "Update: #{app_rb} with default_protect_from_forgery"
|
144
77
|
end
|
145
78
|
end
|
146
79
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
class Jets::Commands::Upgrade
|
2
|
+
class Version1
|
3
|
+
def run
|
4
|
+
environment_configs
|
5
|
+
update_routes
|
6
|
+
update_mode_setting
|
7
|
+
update_config_ru
|
8
|
+
remove_ruby_lazy_load
|
9
|
+
update_webpack_binstubs
|
10
|
+
add_dynomite_to_gemfile
|
11
|
+
end
|
12
|
+
|
13
|
+
def environment_configs
|
14
|
+
path = File.expand_path("templates/skeleton/config/environments", File.dirname(__FILE__))
|
15
|
+
Dir.glob("#{path}/*").each do |src|
|
16
|
+
config_file = "config/environments/#{File.basename(src)}"
|
17
|
+
dest = "#{Jets.root}/#{config_file}"
|
18
|
+
|
19
|
+
puts "src #{src}"
|
20
|
+
puts "dest #{dest}"
|
21
|
+
unless File.exist?(dest)
|
22
|
+
puts "Create: #{config_file}"
|
23
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
24
|
+
FileUtils.cp(src, dest)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_routes
|
30
|
+
routes_file = "#{Jets.root}/config/routes.rb"
|
31
|
+
return unless File.exist?(routes_file)
|
32
|
+
|
33
|
+
lines = IO.readlines(routes_file)
|
34
|
+
deprecated_code = 'root "jets/welcome#index"'
|
35
|
+
return unless lines.detect { |l| l.include?(deprecated_code) }
|
36
|
+
|
37
|
+
puts "Update: config/routes.rb"
|
38
|
+
lines.map! do |line|
|
39
|
+
if line.include?(deprecated_code)
|
40
|
+
%Q| root "jets/public#show"\n| # assume 2 spaces for simplicity
|
41
|
+
else
|
42
|
+
line
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
content = lines.join
|
47
|
+
IO.write(routes_file, content)
|
48
|
+
end
|
49
|
+
|
50
|
+
def update_mode_setting
|
51
|
+
application_file = "#{Jets.root}/config/application.rb"
|
52
|
+
lines = IO.readlines(application_file)
|
53
|
+
deprecated_code = 'config.api_generator'
|
54
|
+
return unless lines.detect { |l| l.include?(deprecated_code) }
|
55
|
+
|
56
|
+
puts "Update: config/application.rb"
|
57
|
+
lines.map! do |line|
|
58
|
+
if line.include?(deprecated_code)
|
59
|
+
mode = Jets.config.api_generator ? 'api' : 'html'
|
60
|
+
%Q| config.mode = "#{mode}"\n| # assume 2 spaces for simplicity
|
61
|
+
else
|
62
|
+
line
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
content = lines.join
|
67
|
+
IO.write(application_file, content)
|
68
|
+
end
|
69
|
+
|
70
|
+
def update_config_ru
|
71
|
+
src = "#{Jets.root}/config.ru"
|
72
|
+
return unless File.exist?(src)
|
73
|
+
config_ru = File.read(src)
|
74
|
+
return if config_ru.include?("Jets.boot")
|
75
|
+
|
76
|
+
src = File.expand_path("templates/skeleton/config.ru", File.dirname(__FILE__))
|
77
|
+
dest = src
|
78
|
+
puts "Update: config.ru"
|
79
|
+
FileUtils.cp(src, dest)
|
80
|
+
end
|
81
|
+
|
82
|
+
def remove_ruby_lazy_load
|
83
|
+
app_config = "#{Jets.root}/config/application.rb"
|
84
|
+
remove_ruby_lazy_load_for(app_config)
|
85
|
+
Dir.glob("#{Jets.root}/config/environments/*.rb").each do |env_config|
|
86
|
+
remove_ruby_lazy_load_for(env_config)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def remove_ruby_lazy_load_for(path)
|
91
|
+
lines = IO.readlines(path)
|
92
|
+
new_lines = lines.reject do |l|
|
93
|
+
l =~ %r{config.ruby.lazy_load}
|
94
|
+
end
|
95
|
+
return unless lines != new_lines
|
96
|
+
|
97
|
+
content = new_lines.join("")
|
98
|
+
IO.write(path, content)
|
99
|
+
puts "Update: #{path}"
|
100
|
+
end
|
101
|
+
|
102
|
+
def update_webpack_binstubs
|
103
|
+
return unless File.exist?("bin/webpack")
|
104
|
+
lines = IO.readlines("bin/webpack")
|
105
|
+
already_upgraded = lines.detect { |l| l =~ /WebpackRunner/ }
|
106
|
+
return if already_upgraded
|
107
|
+
|
108
|
+
update_project_file("bin/webpack")
|
109
|
+
update_project_file("bin/webpack-dev-server")
|
110
|
+
puts "Updated webpack binstubs."
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_dynomite_to_gemfile
|
114
|
+
return unless File.exist?("app/models/application_item.rb")
|
115
|
+
|
116
|
+
lines = IO.readlines("Gemfile")
|
117
|
+
dynomite_found = lines.detect { |l| l =~ /dynomite/ }
|
118
|
+
return if dynomite_found
|
119
|
+
|
120
|
+
File.open('Gemfile', 'a') do |f|
|
121
|
+
f.puts 'gem "dynomite"'
|
122
|
+
end
|
123
|
+
puts "Updated Gemfile: add dynomite gem"
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
def update_project_file(relative_path)
|
128
|
+
templates = File.expand_path("upgrade/templates", File.dirname(__dir__))
|
129
|
+
src = "#{templates}/#{relative_path}"
|
130
|
+
dest = relative_path
|
131
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
132
|
+
FileUtils.cp(src, dest)
|
133
|
+
puts "Update: #{dest}"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|