repack 2.4.5 → 2.4.6
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/README.md +27 -7
- data/example/boilerplate/god_mode/scss/alert.css.scss +1 -2
- data/lib/generators/repack/view_generator.rb +12 -6
- data/lib/repack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fab8aaa9ae24afdc4e14d927127db9c4c82f9a9
|
4
|
+
data.tar.gz: 3bac01c904f00cff49182a71257fdfd7d1d6e275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b8cce958e30c5de7c0e56e088d2a41c56af0eec86b0c03abc9633ece20374b90b55511806f8c5f5b4b51ab77f1e1240c0144f7249e582eb05b4a0273217ca32
|
7
|
+
data.tar.gz: 6f9ca0dc8d7f752eff6c250b3a2eff1b7ae7306715e6374e250553672a4635e41ea7d333afe19943d84fa787af42ab4fd8b6694fde2f7d55a91fc2f568aa29a2
|
data/README.md
CHANGED
@@ -17,6 +17,7 @@ This gem has been tested against Rails 4.2 and Ruby 2.2. Earlier versions of Rai
|
|
17
17
|
2. --router -> Webpack / React / React Router Boilerplate
|
18
18
|
3. --redux -> Webpack / React / Redux Boilerplate
|
19
19
|
4. --router --redux -> Webpack / React / Router / Redux Boilerplate
|
20
|
+
5. --god -> Webpack / React / Router / Redux / Devise / Auth
|
20
21
|
|
21
22
|
### Installation
|
22
23
|
|
@@ -56,6 +57,32 @@ If you're using the webpack dev server's live reload feature (not the React hot
|
|
56
57
|
* Webpacked assets will be compiled to `public/client`
|
57
58
|
* The manifest file is named `manifest.json`
|
58
59
|
|
60
|
+
## View Generator
|
61
|
+
1. Generate a controller
|
62
|
+
2. Add at least an index route for the controller
|
63
|
+
3. rails g repack:view name_of_view (should match controller name)
|
64
|
+
|
65
|
+
EXAMPLE:
|
66
|
+
``` bash
|
67
|
+
rails g controller Admin index
|
68
|
+
rails g repack:view admin
|
69
|
+
```
|
70
|
+
|
71
|
+
NOTE: The view generator will try to match its argument to a currently existing controller name, but if a controller cannot be found with that name, the generator will follow typical Rails convention and pluralize the view directory being created.
|
72
|
+
|
73
|
+
In an example where I have an AdminController & SessionsController:
|
74
|
+
|
75
|
+
``` bash
|
76
|
+
rails g repack:view admin
|
77
|
+
(will find the AdminController and create views/admin/index.html.erb)
|
78
|
+
|
79
|
+
rails g repack:view sessions
|
80
|
+
(will find the SessionsController and create views/sessions/index.html.erb)
|
81
|
+
|
82
|
+
rails g repack:view user
|
83
|
+
(will not find a controller, will follow Rails controller naming convention and create views/users/index.html.erb)
|
84
|
+
```
|
85
|
+
|
59
86
|
### Working with browser tests
|
60
87
|
|
61
88
|
In development, we make sure that the `webpack-dev-server` is running when browser tests are running.
|
@@ -108,13 +135,6 @@ If you're using `[chunkhash]` in your build asset filenames (which you should be
|
|
108
135
|
* Port example apps to Repack
|
109
136
|
|
110
137
|
|
111
|
-
## Experimental
|
112
|
-
A view generator has been added.
|
113
|
-
|
114
|
-
1.Generate a controller
|
115
|
-
2.Add at least an index route for the controller
|
116
|
-
3.rails g repack:view name_of_view (should be singular and match controller)
|
117
|
-
|
118
138
|
|
119
139
|
## Contributing
|
120
140
|
|
@@ -10,8 +10,9 @@ module Repack
|
|
10
10
|
@view = args[0]
|
11
11
|
end
|
12
12
|
|
13
|
+
# ASSUMPTION: entry file will be snake_cased
|
13
14
|
def update_webpack_entry
|
14
|
-
name = @view.
|
15
|
+
name = @view.underscore
|
15
16
|
path = "'#{name}': './client/#{name}.js',"
|
16
17
|
insert_into_file 'config/webpack.config.js', after: /entry: {\n/ do
|
17
18
|
<<-CONFIG
|
@@ -21,12 +22,13 @@ module Repack
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def create_entry_file
|
24
|
-
file = "client/#{@view.
|
25
|
+
file = "client/#{@view.underscore}.js"
|
25
26
|
name = @view.titleize.gsub(/ /, '')
|
26
27
|
copy_file "boilerplate/views/ViewTemplate.js", file
|
27
28
|
gsub_file file, /Placeholder/, name
|
28
29
|
end
|
29
30
|
|
31
|
+
# ASSUMPTION: container will be PascalCased
|
30
32
|
def create_container
|
31
33
|
name = @view.titleize.gsub(/ /, '')
|
32
34
|
file = "client/containers/#{name}.js"
|
@@ -34,15 +36,19 @@ module Repack
|
|
34
36
|
gsub_file file, /Placeholder/, name
|
35
37
|
end
|
36
38
|
|
39
|
+
# ASSUMPTION: Rails controllers will be PascalCased, file & directory names will be snake_cased
|
37
40
|
def create_rails_view
|
38
|
-
name = @view.
|
39
|
-
|
41
|
+
name = @view.underscore
|
42
|
+
Rails.application.eager_load! if ApplicationController.descendants.length == 0
|
43
|
+
controllers = ApplicationController.descendants.map { |cont| cont.name.gsub('Controller', '').underscore }
|
44
|
+
dirname = controllers.include?(name) ? name : name.pluralize
|
45
|
+
empty_directory "app/views/#{dirname}"
|
40
46
|
if Gem.loaded_specs.has_key? 'haml-rails'
|
41
|
-
file = "app/views/#{
|
47
|
+
file = "app/views/#{dirname}/index.html.haml"
|
42
48
|
copy_file "boilerplate/views/rails_view.html.haml", file
|
43
49
|
gsub_file file, /placeholder/, name
|
44
50
|
else
|
45
|
-
file = "app/views/#{
|
51
|
+
file = "app/views/#{dirname}/index.html.erb"
|
46
52
|
copy_file "boilerplate/views/rails_view.html.erb", file
|
47
53
|
gsub_file file, /placeholder/, name
|
48
54
|
end
|
data/lib/repack/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Jungst
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|