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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51d0207bac62321e5b90ec81fbfb797d6ae10e0f
4
- data.tar.gz: 9356e6bb0f37c5cb64268e4091c45a75efd20d14
3
+ metadata.gz: 2949e19df667dfb5b466b4682c63633c0cab41de
4
+ data.tar.gz: bf129b7bad56e0f721cf7c79f45f536604e85d8f
5
5
  SHA512:
6
- metadata.gz: 37189a870a810b0acd28d3900a6ded2cfc4f61bcc6ea5756bb900ff5dcb0604b18979d3f3fba9d61befc44fb0b785e8a9178bf6c6601d014edd3d59f2dd17a56
7
- data.tar.gz: 9ce5bb339871e6604833ab9c155733ee0befbfdb334024535e01b8fcd57468ad1b2b5be17f0431c30c492c72f0ca52b6c71f7ae657d364bf9c1cbf177b00a7f1
6
+ metadata.gz: 6985de89cbef91d51317120496a9c94637ddaf38360e5b0f1f8521a66fa093711d9fdf9a583e8396306441aa25d1dec93b8354eb4691ec65c030aa556060b069
7
+ data.tar.gz: 30113acdcaed93546ac82518f6940a03251d0e46a4d215bf932b2229ede60736c7cde8e7a506596b6df6d4583d73d7b6571bd6e5a36956eb5a22333cd76e6414
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ ruby '2.4.2'
4
+
3
5
  # Specify your gem's dependencies in make_it_so.gemspec
4
6
  gemspec
5
7
 
@@ -28,8 +28,9 @@ module MakeItSo
28
28
  end
29
29
 
30
30
  def readme
31
- file_path = 'README.md'
32
- template(file_path, File.join(app_path, file_path))
31
+ inside app_path do
32
+ create_file "README.md", "# README\n\n"
33
+ end
33
34
  end
34
35
 
35
36
  def lib
@@ -106,6 +106,10 @@ module MakeItSo
106
106
  elsif options[:karma]
107
107
  build 'karma'
108
108
  end
109
+
110
+ if options[:react] || options[:jest] || options[:karma]
111
+ build 'yarn_install'
112
+ end
109
113
  end
110
114
 
111
115
  protected
@@ -17,7 +17,7 @@ module MakeItSo
17
17
  end
18
18
 
19
19
  def base_javascripts
20
- self.gem 'jquery-rails'
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
- self.gem 'pry-rails', group: [:development, :test]
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
- self.gem 'webpacker', '~> 3.3'
51
+ @generator.gem 'webpacker', '~> 3.3'
52
52
 
53
- after_bundle do
54
- rake 'webpacker:install'
55
- rake 'webpacker:install:react'
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
- modify_json(package_json_file) do |json|
61
- ["dependencies", "devDependencies"].each do |key|
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
- json["scripts"] ||= {}
67
- json["scripts"]["start"] = "./bin/webpack-dev-server"
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
- rake 'yarn:install'
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
- self.gem 'dotenv-rails', group: [:development, :test]
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
- self.gem 'rspec-rails', group: [:development, :test]
162
- self.gem 'capybara', group: [:development, :test]
163
- self.gem 'launchy', group: [:development, :test]
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
- self.gem 'factory_bot', group: [:development, :test]
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
- self.gem 'database_cleaner', group: [:development, :test]
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
- self.gem 'valid_attribute', group: [:development, :test]
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
- self.gem 'shoulda-matchers',
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
- self.gem 'devise'
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
- self.gem 'foundation-rails', '~> 5.0'
278
+ @generator.gem 'foundation-rails', '~> 5.0'
266
279
 
267
280
  after_bundle do
268
281
  generate 'foundation:install foundation'
@@ -1,3 +1,3 @@
1
1
  module MakeItSo
2
- VERSION = "0.3.8"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/make_it_so.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
1
4
  module MakeItSo
2
5
  def self.source_root(template_category = nil)
3
6
  root = File.join(File.dirname(__FILE__), '../templates')
@@ -3,7 +3,8 @@
3
3
  "babel-preset-react": "~6.24.1",
4
4
  "prop-types": "~15.6.0",
5
5
  "react": "~15.4.2",
6
- "react-dom": "~15.4.2"
6
+ "react-dom": "~15.4.2",
7
+ "redbox-react": "1.6.0"
7
8
  },
8
9
  "devDependencies": {
9
10
  "webpack-cli": "^2.0.10",
@@ -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
@@ -21,7 +21,7 @@ module MakeItSoSpecHelpers
21
21
  end
22
22
 
23
23
  def tmp_path
24
- '/tmp/make_it_so'
24
+ File.join(Dir.tmpdir, 'make_it_so')
25
25
  end
26
26
 
27
27
  def root_path
@@ -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
+ })
@@ -0,0 +1,7 @@
1
+ import React from 'react'
2
+
3
+ export const App = (props) => {
4
+ return (<h1>Make It So React</h1>)
5
+ }
6
+
7
+ export default App
@@ -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.3.8
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-05-19 00:00:00.000000000 Z
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
@@ -1,3 +0,0 @@
1
- # Gosu Game
2
-
3
- This is a game written in Ruby using the Gosu Framework.