make_it_so 0.3.8 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/lib/generators/gosu_app_generator.rb +3 -2
- data/lib/generators/rails_app_generator.rb +4 -0
- data/lib/make_it_so/rails/app_builder.rb +44 -31
- data/lib/make_it_so/version.rb +1 -1
- data/lib/make_it_so.rb +3 -0
- data/snippets/rails/react_dependencies.json +2 -1
- data/spec/features/user_generates_rails_spec.rb +7 -1
- data/spec/support/make_it_so_spec_helpers.rb +1 -1
- data/templates/rails/app/javascript/packs/new_application.js +23 -0
- data/templates/rails/app/javascript/react/components/app.js +7 -0
- data/templates/rails/app/views/layouts/application.html.erb.tt +8 -0
- metadata +4 -3
- data/templates/gosu/readme.md +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2949e19df667dfb5b466b4682c63633c0cab41de
|
4
|
+
data.tar.gz: bf129b7bad56e0f721cf7c79f45f536604e85d8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6985de89cbef91d51317120496a9c94637ddaf38360e5b0f1f8521a66fa093711d9fdf9a583e8396306441aa25d1dec93b8354eb4691ec65c030aa556060b069
|
7
|
+
data.tar.gz: 30113acdcaed93546ac82518f6940a03251d0e46a4d215bf932b2229ede60736c7cde8e7a506596b6df6d4583d73d7b6571bd6e5a36956eb5a22333cd76e6414
|
data/Gemfile
CHANGED
@@ -17,7 +17,7 @@ module MakeItSo
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def base_javascripts
|
20
|
-
|
20
|
+
@generator.gem 'jquery-rails'
|
21
21
|
inside 'app/assets/javascripts' do
|
22
22
|
template 'application.js'
|
23
23
|
jquery_files = "//= require jquery\n" +
|
@@ -33,7 +33,7 @@ module MakeItSo
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def pry_rails_dependency
|
36
|
-
|
36
|
+
@generator.gem 'pry-rails', group: [:development, :test]
|
37
37
|
end
|
38
38
|
|
39
39
|
def fix_generators
|
@@ -48,26 +48,29 @@ module MakeItSo
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def react
|
51
|
-
|
51
|
+
@generator.gem 'webpacker', '~> 3.3'
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
unparsed_json = snippet('react_dependencies.json')
|
58
|
-
parsed_json = JSON.parse(unparsed_json)
|
53
|
+
rake 'webpacker:install'
|
54
|
+
rake 'webpacker:install:react'
|
55
|
+
remove_file 'app/javascript/packs/application.js'
|
56
|
+
remove_file 'app/javascript/packs/hello_react.jsx'
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
json[key] ||= {}
|
63
|
-
json[key].merge!(parsed_json[key])
|
64
|
-
end
|
58
|
+
unparsed_json = snippet('react_dependencies.json')
|
59
|
+
parsed_json = JSON.parse(unparsed_json)
|
65
60
|
|
66
|
-
|
67
|
-
|
61
|
+
modify_json(package_json_file) do |json|
|
62
|
+
["dependencies", "devDependencies"].each do |key|
|
63
|
+
json[key] ||= {}
|
64
|
+
json[key].merge!(parsed_json[key])
|
68
65
|
end
|
69
66
|
|
70
|
-
|
67
|
+
json["scripts"] ||= {}
|
68
|
+
json["scripts"]["start"] = "./bin/webpack-dev-server"
|
69
|
+
end
|
70
|
+
|
71
|
+
inside 'app/javascript/packs' do
|
72
|
+
copy_file 'new_application.js', 'application.js'
|
73
|
+
remove_file 'new_application.js'
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
@@ -88,8 +91,6 @@ module MakeItSo
|
|
88
91
|
template 'exampleTest.js'
|
89
92
|
template 'testHelper.js'
|
90
93
|
end
|
91
|
-
|
92
|
-
rake 'yarn:install'
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
@@ -131,6 +132,7 @@ module MakeItSo
|
|
131
132
|
})
|
132
133
|
end
|
133
134
|
|
135
|
+
run 'touch .babelrc'
|
134
136
|
modify_json(File.join(destination_root, '.babelrc')) do |json|
|
135
137
|
json["env"] ||= {}
|
136
138
|
json["env"]["test"] ||= {}
|
@@ -142,13 +144,15 @@ module MakeItSo
|
|
142
144
|
}
|
143
145
|
})
|
144
146
|
end
|
145
|
-
|
146
|
-
rake 'yarn:install'
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
+
def yarn_install
|
151
|
+
run 'yarn install'
|
152
|
+
end
|
153
|
+
|
150
154
|
def dotenv
|
151
|
-
|
155
|
+
@generator.gem 'dotenv-rails', group: [:development, :test]
|
152
156
|
template '.env'
|
153
157
|
template '.env.example'
|
154
158
|
|
@@ -158,9 +162,9 @@ module MakeItSo
|
|
158
162
|
end
|
159
163
|
|
160
164
|
def rspec_dependency
|
161
|
-
|
162
|
-
|
163
|
-
|
165
|
+
@generator.gem 'rspec-rails', group: [:development, :test]
|
166
|
+
@generator.gem 'capybara', group: [:development, :test]
|
167
|
+
@generator.gem 'launchy', group: [:development, :test]
|
164
168
|
|
165
169
|
after_bundle do
|
166
170
|
#stop spring in case it is running - it will hang
|
@@ -182,7 +186,7 @@ module MakeItSo
|
|
182
186
|
end
|
183
187
|
|
184
188
|
def factory_bot_rspec
|
185
|
-
|
189
|
+
@generator.gem 'factory_bot', group: [:development, :test]
|
186
190
|
after_bundle do
|
187
191
|
inside 'spec' do
|
188
192
|
uncomment_lines 'rails_helper.rb', /spec\/support\/\*\*\/\*.rb/
|
@@ -195,7 +199,7 @@ module MakeItSo
|
|
195
199
|
end
|
196
200
|
|
197
201
|
def database_cleaner_rspec
|
198
|
-
|
202
|
+
@generator.gem 'database_cleaner', group: [:development, :test]
|
199
203
|
after_bundle do
|
200
204
|
inside 'spec' do
|
201
205
|
inside 'support' do
|
@@ -206,7 +210,7 @@ module MakeItSo
|
|
206
210
|
end
|
207
211
|
|
208
212
|
def valid_attribute_rspec
|
209
|
-
|
213
|
+
@generator.gem 'valid_attribute', group: [:development, :test]
|
210
214
|
after_bundle do
|
211
215
|
inside 'spec' do
|
212
216
|
insert_into_file 'rails_helper.rb',
|
@@ -223,7 +227,7 @@ module MakeItSo
|
|
223
227
|
end
|
224
228
|
|
225
229
|
def shoulda_rspec
|
226
|
-
|
230
|
+
@generator.gem 'shoulda-matchers',
|
227
231
|
group: [:development, :test],
|
228
232
|
require: false
|
229
233
|
after_bundle do
|
@@ -234,13 +238,22 @@ module MakeItSo
|
|
234
238
|
end
|
235
239
|
|
236
240
|
def devise_dependency
|
237
|
-
|
241
|
+
@generator.gem 'devise'
|
238
242
|
|
239
243
|
after_bundle do
|
240
244
|
generate 'devise:install'
|
241
245
|
generate 'devise:views'
|
242
246
|
generate 'devise user'
|
243
247
|
|
248
|
+
#note: temporary fix that can be removed once devise progresses #beyond v4.4.3
|
249
|
+
# https://github.com/plataformatec/devise/pull/4869/files
|
250
|
+
inside 'config/initializers' do
|
251
|
+
insert_into_file 'devise.rb',
|
252
|
+
after: "Devise.setup do |config|" do
|
253
|
+
" config.secret_key = Rails.application.secret_key_base\n"
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
244
257
|
if options[:rspec]
|
245
258
|
inside 'spec' do
|
246
259
|
directory 'features'
|
@@ -262,7 +275,7 @@ module MakeItSo
|
|
262
275
|
end
|
263
276
|
|
264
277
|
def foundation_dependency
|
265
|
-
|
278
|
+
@generator.gem 'foundation-rails', '~> 5.0'
|
266
279
|
|
267
280
|
after_bundle do
|
268
281
|
generate 'foundation:install foundation'
|
data/lib/make_it_so/version.rb
CHANGED
data/lib/make_it_so.rb
CHANGED
@@ -44,7 +44,7 @@ feature 'user generates rails app' do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
scenario 'creates a valid gemfile' do
|
47
|
-
words = ['source', '#', 'gem', 'group', 'end']
|
47
|
+
words = ['source', '#', 'gem', 'group', 'end', 'ruby']
|
48
48
|
|
49
49
|
File.readlines('Gemfile').each do |line|
|
50
50
|
unless line.strip.empty?
|
@@ -200,6 +200,12 @@ feature 'user generates rails app' do
|
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
203
|
+
it 'includes redbox-react in package.json' do
|
204
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
205
|
+
expect(json["dependencies"]["redbox-react"]).to_not be_nil
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
203
209
|
it 'includes react-dom in package.json' do
|
204
210
|
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
205
211
|
expect(json["dependencies"]["react-dom"]).to_not be_nil
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
import React from 'react'
|
3
|
+
import { render } from 'react-dom'
|
4
|
+
|
5
|
+
import App from '../react/components/app'
|
6
|
+
import RedBox from 'redbox-react'
|
7
|
+
|
8
|
+
document.addEventListener('DOMContentLoaded', () => {
|
9
|
+
let reactElement = document.getElementById('app')
|
10
|
+
|
11
|
+
if (reactElement) {
|
12
|
+
if(window.railsEnv && window.railsEnv === 'development'){
|
13
|
+
try {
|
14
|
+
render(<App />, reactElement)
|
15
|
+
} catch (e) {
|
16
|
+
render(<RedBox error={e} />, reactElement)
|
17
|
+
}
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
render(<App />, reactElement)
|
21
|
+
}
|
22
|
+
}
|
23
|
+
})
|
@@ -51,6 +51,14 @@
|
|
51
51
|
<%%= yield %>
|
52
52
|
|
53
53
|
<%%= javascript_include_tag 'application' %>
|
54
|
+
<% if options[:react] %>
|
55
|
+
<%%- if Rails.env.development? || Rails.env.test? -%>
|
56
|
+
<%%= javascript_tag do %>
|
57
|
+
window.railsEnv = '<%%= Rails.env %>'
|
58
|
+
<%%- end -%>
|
59
|
+
<%%- end -%>
|
60
|
+
<%%= javascript_pack_tag 'application' %>
|
61
|
+
<% end %>
|
54
62
|
<%%= yield :extra_footer %>
|
55
63
|
</body>
|
56
64
|
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: make_it_so
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Pickett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -183,13 +183,14 @@ files:
|
|
183
183
|
- templates/gosu/app.rb
|
184
184
|
- templates/gosu/lib/bounding_box.rb
|
185
185
|
- templates/gosu/lib/keys.rb
|
186
|
-
- templates/gosu/readme.md
|
187
186
|
- templates/gosu/spec/spec_helper.rb
|
188
187
|
- templates/rails/.env
|
189
188
|
- templates/rails/.env.example
|
190
189
|
- templates/rails/.gitkeep
|
191
190
|
- templates/rails/app/controllers/application_controller.rb
|
192
191
|
- templates/rails/app/controllers/homes_controller.rb
|
192
|
+
- templates/rails/app/javascript/packs/new_application.js
|
193
|
+
- templates/rails/app/javascript/react/components/app.js
|
193
194
|
- templates/rails/app/models/application_record.rb
|
194
195
|
- templates/rails/app/views/homes/index.html.erb
|
195
196
|
- templates/rails/app/views/layouts/application.html.erb.tt
|
data/templates/gosu/readme.md
DELETED