make_it_so 0.4.2 → 0.6.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 +5 -5
- data/CHANGELOG.md +34 -0
- data/Gemfile +18 -1
- data/README.md +5 -4
- data/lib/generators/rails_app_generator.rb +17 -10
- data/lib/make_it_so.rb +3 -0
- data/lib/make_it_so/command_line_interface.rb +4 -2
- data/lib/make_it_so/rails.rb +1 -2
- data/lib/make_it_so/rails/app_builder.rb +102 -86
- data/lib/make_it_so/rails/prerequisite_check.rb +29 -0
- data/lib/make_it_so/version.rb +1 -1
- data/make_it_so.gemspec +1 -3
- data/snippets/rails/js_enzyme_testing_deps.json +6 -0
- data/snippets/rails/js_jest_testing_deps.json +15 -5
- data/snippets/rails/{js_testing_deps.json → js_karma_jasmine_testing_deps.json} +8 -7
- data/snippets/rails/react_dependencies.json +14 -3
- data/snippets/rails/user_factory.rb +2 -2
- data/spec/features/rails/user_generates_rails_spec.rb +410 -0
- data/spec/features/rails/user_generates_rails_with_karma_spec.rb +68 -0
- data/spec/features/rails/user_generates_rails_without_js_test_lib_spec.rb +51 -0
- data/spec/support/make_it_so_spec_helpers.rb +23 -0
- data/templates/rails/app/assets/javascripts/application.foundation.js +18 -0
- data/templates/rails/app/assets/javascripts/application.js +16 -0
- data/templates/rails/app/javascript/packs/new_application.js +1 -1
- data/templates/rails/app/javascript/react/components/{app.js → App.js} +1 -1
- data/templates/rails/app/javascript/react/components/example.test.js +5 -0
- data/templates/rails/app/views/layouts/application.html.erb.tt +1 -8
- data/templates/rails/babel.config.js +77 -0
- data/templates/rails/karma.conf.js +2 -5
- data/templates/rails/spec/javascript/example.test.js +5 -0
- data/templates/rails/spec/javascript/support/enzyme.js +1 -3
- data/templates/rails/spec/javascript/testHelper.js +6 -1
- metadata +24 -48
- data/Appraisals +0 -4
- data/gemfiles/rails_4_0.gemfile +0 -11
- data/gemfiles/rails_4_0.gemfile.lock +0 -88
- data/gemfiles/rails_4_1.gemfile +0 -11
- data/gemfiles/rails_4_1.gemfile.lock +0 -92
- data/gemfiles/rails_4_2.gemfile +0 -11
- data/gemfiles/rails_4_2.gemfile.lock +0 -106
- data/spec/features/user_generates_rails_spec.rb +0 -352
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 62d0d492e8ebf31a42c217e5294c22c11e8e27fda46526c9ed9466e63e3cbc0a
|
4
|
+
data.tar.gz: 4d9e66ac27776841fb882234c0da8dc98458836a9f44650c0a82dd6a284fb813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a56507b200ab5a6b5237b1b33abc919d8e7cb871e5b9533862024b6c47c02c983d155d04d91e7b819cb405a1ad04f783067802c0490b54d40c0c9c4bfb8353d
|
7
|
+
data.tar.gz: ebf9b7057c86b84dd9d1fa8ffcb7ab9837306efe1e81ebddac6f6a4ad4855024baafa76e12e935aaef7f8ec15e38f1541a3ec06e9701d7d4936079ee60ee36c4
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
- add @types/jest for VSCode intellisense
|
10
|
+
|
11
|
+
## [0.5.1] - 2019-10-08
|
12
|
+
|
13
|
+
- skip bootsnap by default
|
14
|
+
- added prerequisite rails version check
|
15
|
+
- adjust webpacker routines to run `after_bundle`
|
16
|
+
- only stop spring if it is being installed
|
17
|
+
|
18
|
+
## [0.5.0] - 2019-09-02
|
19
|
+
|
20
|
+
### Added
|
21
|
+
|
22
|
+
- `react-router` is now installed by default
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
- `--karma` and `--jest` options have been removed in favor of a `--js-test-lib` param.
|
27
|
+
- The default behavior of `make_it_so` now generates `jest` as the default test lib instead of `karma`
|
28
|
+
- `foundation-rails` was updated to v6.5
|
29
|
+
- `modernizr` was removed
|
30
|
+
- Development runtime was upgraded to ruby v2.6.3
|
31
|
+
|
32
|
+
[Unreleased]:https://github.com/LaunchAcademy/make_it_so/compare/v0.5.0...HEAD
|
33
|
+
[0.5.1]:https://github.com/LaunchAcademy/make_it_so/compare/v0.5.0...v0.5.1
|
34
|
+
[0.5.0]:https://github.com/LaunchAcademy/make_it_so/compare/v0.4.5...v0.5.0
|
data/Gemfile
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'lib/make_it_so/rails'
|
4
|
+
|
5
|
+
ruby '2.7.3'
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in make_it_so.gemspec
|
6
8
|
gemspec
|
7
9
|
|
8
10
|
group :development do
|
9
11
|
gem 'pry'
|
12
|
+
gem 'solargraph'
|
13
|
+
|
14
|
+
[
|
15
|
+
'rails',
|
16
|
+
'activejob',
|
17
|
+
'actionmailer'
|
18
|
+
].each do |gem_name|
|
19
|
+
gem gem_name, MakeItSo::Rails::VERSION
|
20
|
+
end
|
21
|
+
|
22
|
+
gem 'sprockets-rails', '3.2.2'
|
23
|
+
gem 'listen'
|
24
|
+
gem 'rspec-rails'
|
25
|
+
gem 'devise'
|
26
|
+
gem 'webpacker'
|
10
27
|
end
|
data/README.md
CHANGED
@@ -30,8 +30,9 @@ make_it_so rails <app_name>
|
|
30
30
|
Then run:
|
31
31
|
|
32
32
|
```ruby
|
33
|
-
|
34
|
-
rake db:
|
33
|
+
yarn install
|
34
|
+
bundle exec rake db:create
|
35
|
+
bundle exec rake db:migrate
|
35
36
|
```
|
36
37
|
|
37
38
|
By default, the generator will create a Rails app with the following options activated:
|
@@ -41,7 +42,7 @@ By default, the generator will create a Rails app with the following options act
|
|
41
42
|
- Postgres
|
42
43
|
- Foundation
|
43
44
|
- React
|
44
|
-
-
|
45
|
+
- Jest
|
45
46
|
|
46
47
|
To take advantage of view-specific javascript, inject a script tag at the end of the body tag. Javascript should always be the last thing loaded on the page. In view logic you can do the following:
|
47
48
|
|
@@ -53,7 +54,7 @@ var widget = new Something.Widget('foo');
|
|
53
54
|
<% end %>
|
54
55
|
```
|
55
56
|
|
56
|
-
|
57
|
+
Using the `--js-test-lib` flag, it is also possible to set up a Karma/Jasmine test framework instead of Jest (`--js-test-lib karma`) or to omit either framework (`--js-test-lib false`).
|
57
58
|
|
58
59
|
### Sinatra
|
59
60
|
|
@@ -42,20 +42,27 @@ module MakeItSo
|
|
42
42
|
default: true,
|
43
43
|
desc: 'Skip spring gem'
|
44
44
|
|
45
|
-
class_option :
|
45
|
+
class_option :skip_active_storage,
|
46
46
|
type: :boolean,
|
47
47
|
default: true,
|
48
|
-
desc:
|
48
|
+
desc: "Skip Active Storage"
|
49
49
|
|
50
|
-
class_option :
|
50
|
+
class_option :react,
|
51
51
|
type: :boolean,
|
52
52
|
default: true,
|
53
|
-
desc: 'Generate
|
53
|
+
desc: 'Generate React setup'
|
54
54
|
|
55
|
-
class_option :
|
55
|
+
class_option :js_test_lib,
|
56
|
+
type: :string,
|
57
|
+
default: "jest",
|
58
|
+
desc:
|
59
|
+
"Generate Jest testing framework (default), Karma/Jasmine ('karma'), or no framework ('false')"
|
60
|
+
|
61
|
+
class_option :skip_bootsnap,
|
56
62
|
type: :boolean,
|
57
|
-
default:
|
58
|
-
desc:
|
63
|
+
default: true,
|
64
|
+
desc:
|
65
|
+
"Skip bootsnap"
|
59
66
|
|
60
67
|
def initialize(*args)
|
61
68
|
super
|
@@ -101,13 +108,13 @@ module MakeItSo
|
|
101
108
|
build 'react'
|
102
109
|
end
|
103
110
|
|
104
|
-
if options[:jest
|
111
|
+
if options[:js_test_lib] == "jest"
|
105
112
|
build 'jest'
|
106
|
-
elsif options[:karma
|
113
|
+
elsif options[:js_test_lib] == "karma"
|
107
114
|
build 'karma'
|
108
115
|
end
|
109
116
|
|
110
|
-
if options[:react] || options[:
|
117
|
+
if options[:react] || options[:js_test_lib]
|
111
118
|
build 'yarn_install'
|
112
119
|
end
|
113
120
|
end
|
data/lib/make_it_so.rb
CHANGED
@@ -4,9 +4,11 @@ module MakeItSo
|
|
4
4
|
desc "rails <app_name>",
|
5
5
|
"generates a rails application based on your specifications"
|
6
6
|
option :devise, type: :boolean
|
7
|
-
option :
|
7
|
+
option :js_test_lib, default: "jest"
|
8
8
|
def rails(app_name)
|
9
|
-
MakeItSo::
|
9
|
+
if MakeItSo::Rails::PrerequisiteCheck.new.check
|
10
|
+
MakeItSo::RailsAppGenerator.start(ARGV[1..-1])
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
desc "sinatra <app_name>",
|
data/lib/make_it_so/rails.rb
CHANGED
@@ -50,41 +50,42 @@ module MakeItSo
|
|
50
50
|
def react
|
51
51
|
@generator.gem 'webpacker', '~> 3.3'
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
53
|
+
after_bundle do
|
54
|
+
rake 'webpacker:install'
|
55
|
+
rake 'webpacker:install:react'
|
56
|
+
remove_file 'app/javascript/packs/application.js'
|
57
|
+
remove_file 'app/javascript/packs/hello_react.jsx'
|
58
|
+
|
59
|
+
unparsed_json = snippet('react_dependencies.json')
|
60
|
+
parsed_json = JSON.parse(unparsed_json)
|
61
|
+
|
62
|
+
modify_json(package_json_file) do |json|
|
63
|
+
["dependencies", "devDependencies"].each do |key|
|
64
|
+
json[key] ||= {}
|
65
|
+
json[key].merge!(parsed_json[key])
|
66
|
+
end
|
67
|
+
|
68
|
+
json["scripts"] ||= {}
|
69
|
+
json["scripts"]["start"] = "./bin/webpack-dev-server"
|
70
|
+
|
71
|
+
json["dependencies"].delete("babel-preset-react")
|
65
72
|
end
|
66
73
|
|
67
|
-
|
68
|
-
|
69
|
-
|
74
|
+
inside 'app/javascript/packs' do
|
75
|
+
copy_file 'new_application.js', 'application.js'
|
76
|
+
remove_file 'new_application.js'
|
77
|
+
end
|
70
78
|
|
71
|
-
inside 'app/javascript/packs' do
|
72
|
-
copy_file 'new_application.js', 'application.js'
|
73
|
-
remove_file 'new_application.js'
|
74
79
|
end
|
75
80
|
end
|
76
81
|
|
77
82
|
def karma
|
78
83
|
after_bundle do
|
79
|
-
|
80
|
-
|
84
|
+
add_test_dependency_snippets(
|
85
|
+
["js_karma_jasmine_testing_deps.json", "js_enzyme_testing_deps.json"]
|
86
|
+
)
|
81
87
|
|
82
|
-
|
83
|
-
json["devDependencies"] ||= {}
|
84
|
-
json["devDependencies"].merge!(parsed_json["devDependencies"])
|
85
|
-
json["scripts"] ||= {}
|
86
|
-
json["scripts"]["test"] = "node_modules/.bin/karma start karma.conf.js"
|
87
|
-
end
|
88
|
+
create_enzyme_config
|
88
89
|
|
89
90
|
template 'karma.conf.js'
|
90
91
|
inside 'spec/javascript' do
|
@@ -95,54 +96,24 @@ module MakeItSo
|
|
95
96
|
append_to_file '.gitignore' do
|
96
97
|
"coverage/*\n"
|
97
98
|
end
|
99
|
+
|
100
|
+
remove_file '.babelrc'
|
101
|
+
remove_file 'babel.config.js'
|
102
|
+
template 'babel.config.js'
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
101
106
|
def jest
|
102
107
|
after_bundle do
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
run 'mkdir -p spec/javascript/support'
|
107
|
-
inside 'spec/javascript/support' do
|
108
|
-
template 'enzyme.js'
|
109
|
-
end
|
108
|
+
add_test_dependency_snippets(
|
109
|
+
["js_jest_testing_deps.json", "js_enzyme_testing_deps.json"]
|
110
|
+
)
|
110
111
|
|
111
|
-
|
112
|
-
json["devDependencies"] ||= {}
|
113
|
-
json["devDependencies"].merge!(parsed_json["devDependencies"])
|
114
|
-
json["scripts"] ||= {}
|
115
|
-
json["scripts"]["test"] = "node_modules/.bin/jest"
|
116
|
-
json["scripts"]["test:dev"] = "node_modules/.bin/jest --notify --watch"
|
117
|
-
json["jest"] ||= {}
|
118
|
-
json["jest"].merge!({
|
119
|
-
"automock": false,
|
120
|
-
"roots": [
|
121
|
-
"spec/javascript"
|
122
|
-
],
|
123
|
-
"moduleDirectories": [
|
124
|
-
"node_modules",
|
125
|
-
"app/javascript"
|
126
|
-
],
|
127
|
-
"setupFiles": [
|
128
|
-
"./spec/javascript/support/enzyme.js"
|
129
|
-
],
|
130
|
-
"testURL": "http://localhost/"
|
131
|
-
})
|
132
|
-
end
|
112
|
+
create_enzyme_config
|
133
113
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
json["env"]["test"] ||= {}
|
138
|
-
json["env"]["test"].merge!({
|
139
|
-
"env": {
|
140
|
-
"test": {
|
141
|
-
"presets": ["react", "env"],
|
142
|
-
}
|
143
|
-
}
|
144
|
-
})
|
145
|
-
end
|
114
|
+
remove_file '.babelrc'
|
115
|
+
remove_file 'babel.config.js'
|
116
|
+
template 'babel.config.js'
|
146
117
|
end
|
147
118
|
end
|
148
119
|
|
@@ -161,14 +132,16 @@ module MakeItSo
|
|
161
132
|
end
|
162
133
|
|
163
134
|
def rspec_dependency
|
164
|
-
@generator.gem 'rspec-rails', group: [:development, :test]
|
135
|
+
@generator.gem 'rspec-rails', '3.8.2', group: [:development, :test]
|
165
136
|
@generator.gem 'capybara', group: [:development, :test]
|
166
137
|
@generator.gem 'launchy', group: [:development, :test]
|
167
138
|
|
168
139
|
after_bundle do
|
169
|
-
|
170
|
-
|
171
|
-
|
140
|
+
if !options[:skip_spring]
|
141
|
+
#stop spring in case it is running - it will hang
|
142
|
+
#https://github.com/rails/rails/issues/13381
|
143
|
+
run 'spring stop'
|
144
|
+
end
|
172
145
|
generate 'rspec:install'
|
173
146
|
inside 'spec' do
|
174
147
|
empty_directory 'support'
|
@@ -188,7 +161,11 @@ module MakeItSo
|
|
188
161
|
@generator.gem 'factory_bot', group: [:development, :test]
|
189
162
|
after_bundle do
|
190
163
|
inside 'spec' do
|
191
|
-
|
164
|
+
insert_into_file 'rails_helper.rb',
|
165
|
+
after: rails_helper_insertion_hook do
|
166
|
+
|
167
|
+
"require File.join(File.dirname(__FILE__), 'support/factory_bot')\n"
|
168
|
+
end
|
192
169
|
|
193
170
|
inside 'support' do
|
194
171
|
template 'factory_bot.rb'
|
@@ -230,8 +207,16 @@ module MakeItSo
|
|
230
207
|
group: [:development, :test],
|
231
208
|
require: false
|
232
209
|
after_bundle do
|
233
|
-
inside 'spec
|
234
|
-
|
210
|
+
inside 'spec' do
|
211
|
+
insert_into_file 'rails_helper.rb',
|
212
|
+
after: rails_helper_insertion_hook do
|
213
|
+
|
214
|
+
"require File.join(File.dirname(__FILE__), 'support/shoulda')\n"
|
215
|
+
end
|
216
|
+
|
217
|
+
inside 'support' do
|
218
|
+
template 'shoulda.rb'
|
219
|
+
end
|
235
220
|
end
|
236
221
|
end
|
237
222
|
end
|
@@ -247,7 +232,7 @@ module MakeItSo
|
|
247
232
|
#note: temporary fix that can be removed once devise progresses #beyond v4.4.3
|
248
233
|
# https://github.com/plataformatec/devise/pull/4869/files
|
249
234
|
inside 'config/initializers' do
|
250
|
-
insert_into_file 'devise.rb',
|
235
|
+
insert_into_file 'devise.rb',
|
251
236
|
after: "Devise.setup do |config|" do
|
252
237
|
" config.secret_key = Rails.application.secret_key_base\n"
|
253
238
|
end
|
@@ -274,29 +259,60 @@ module MakeItSo
|
|
274
259
|
end
|
275
260
|
|
276
261
|
def foundation_dependency
|
277
|
-
@generator.gem 'foundation-rails', '~> 5
|
262
|
+
@generator.gem 'foundation-rails', '~> 6.5'
|
278
263
|
|
279
264
|
after_bundle do
|
280
265
|
generate 'foundation:install foundation'
|
281
|
-
# foundation
|
282
|
-
# must remove it
|
283
|
-
# there is a pull request open to skip this:
|
284
|
-
# https://github.com/zurb/foundation-rails/pull/108
|
266
|
+
# foundation install always messes with the JS manifest
|
285
267
|
remove_file 'app/views/layouts/foundation.html.erb'
|
286
268
|
|
287
269
|
inside 'app/assets/javascripts' do
|
288
|
-
|
289
|
-
|
290
|
-
after: "//= require jquery_ujs\n"
|
270
|
+
remove_file 'application.js'
|
271
|
+
template 'application.foundation.js', 'application.js'
|
291
272
|
end
|
273
|
+
# foundation-rails generates an application layout so we
|
274
|
+
# must remove it
|
275
|
+
remove_file 'app/views/layouts/foundation.html.erb'
|
276
|
+
|
277
|
+
|
292
278
|
end
|
293
279
|
end
|
294
280
|
|
295
281
|
protected
|
296
|
-
PACKAGE_PATH = 'package.json'
|
297
|
-
WEBCONFIG_PATH = 'webpack.config.js'
|
298
282
|
|
299
|
-
|
283
|
+
PACKAGE_PATH = "package.json"
|
284
|
+
WEBCONFIG_PATH = "webpack.config.js"
|
285
|
+
|
286
|
+
def add_test_dependency_snippets(snippet_paths)
|
287
|
+
snippet_paths.each do |snippet_path|
|
288
|
+
snippet = snippet(snippet_path)
|
289
|
+
parsed_snippet = JSON.parse(snippet)
|
290
|
+
keys = parsed_snippet.keys
|
291
|
+
|
292
|
+
modify_json(package_json_file) do |json|
|
293
|
+
keys.each do |key|
|
294
|
+
json[key] ||= {}
|
295
|
+
json[key].merge!(parsed_snippet[key])
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
def create_enzyme_config
|
302
|
+
run 'mkdir -p spec/javascript/support'
|
303
|
+
devDependencies = parsed_package_json["devDependencies"].keys
|
304
|
+
enzymeAdapter = devDependencies.select{ |d| d =~ /^enzyme-adapter-react-[0-9]*/ }[0]
|
305
|
+
|
306
|
+
inside 'spec/javascript/support' do
|
307
|
+
template 'enzyme.js'
|
308
|
+
gsub_file 'enzyme.js', 'ADAPTER NAME GOES HERE', enzymeAdapter
|
309
|
+
end
|
310
|
+
|
311
|
+
inside 'app/javascript/react/components' do
|
312
|
+
template "example.test.js"
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
300
316
|
def parsed_package_json
|
301
317
|
@package_json ||= parse_json_file(package_json_file)
|
302
318
|
end
|