repack 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/repack/install_generator.rb +58 -16
- 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: 10d12948ef43c30268284738b43e2c56d3aaa094
|
4
|
+
data.tar.gz: 0f7e1753c40194e20ecd04286adc8786ba61d2b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d08660d630e16d6444d6047e9f0f197383bd536a2cd5de14029752fbbca8660a773a8cdba27224265f9b1e44e6637c6afe4925bbaf0d89158ee5bf7967dad6
|
7
|
+
data.tar.gz: b42d6137c4d5fb5430fe8db4d88bb30f72dfac6cc82f2d8b9e2ae7af1fad3cb567adba0af93d0225cf8aa8a044bad4cce8d266f32cf5651fc5a1c6cacc64d30d
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Repack
|
2
2
|
# :nodoc:
|
3
3
|
class InstallGenerator < ::Rails::Generators::Base
|
4
|
+
@yarn_installed = false
|
4
5
|
source_root File.expand_path("../../../../example", __FILE__)
|
5
6
|
desc "Install everything you need for a basic repack integration"
|
6
7
|
class_option :router, type: :boolean, default: false, description: 'Add React Router'
|
@@ -33,7 +34,11 @@ module Repack
|
|
33
34
|
end
|
34
35
|
def copy_webpack_conf
|
35
36
|
copy_file "webpack.config.js", "config/webpack.config.js"
|
36
|
-
|
37
|
+
puts 'Are you going to be deploying to heroku? (yes \ no)'
|
38
|
+
if gets.strip.downcase =~ /y(es)?/
|
39
|
+
puts 'copying heroku webpack config!'
|
40
|
+
copy_file "webpack.config.heroku.js", "config/webpack.config.heroku.js"
|
41
|
+
end
|
37
42
|
end
|
38
43
|
def create_webpack_application_js
|
39
44
|
empty_directory "client"
|
@@ -62,28 +67,57 @@ module Repack
|
|
62
67
|
copy_file "boilerplate/application.js", "client/application.js"
|
63
68
|
copy_file "boilerplate/App.js", "client/containers/App.js"
|
64
69
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
|
71
|
+
haml_installed = Gem.loaded_specs.has_key? 'haml-rails'
|
72
|
+
layouts_dir = 'app/views/layouts'
|
73
|
+
haml_installed = Gem.loaded_specs.has_key? 'haml-rails'
|
74
|
+
layouts_dir = 'app/views/layouts'
|
75
|
+
|
76
|
+
application_view = haml_installed ? "#{layouts_dir}/application.html.haml" : "#{layouts_dir}/application.html.erb"
|
77
|
+
|
78
|
+
if haml_installed
|
79
|
+
puts 'Convert all existing ERB views into HAML? (yes / no)'
|
80
|
+
if gets.strip.downcase =~ /y(es)?/
|
81
|
+
begin
|
82
|
+
require 'html2haml'
|
83
|
+
rescue LoadError
|
84
|
+
`gem install html2haml`
|
85
|
+
end
|
86
|
+
`find . -name \*.erb -print | sed 'p;s/.erb$/.haml/' | xargs -n2 html2haml`
|
87
|
+
`rm #{layouts_dir}/application.html.erb`
|
71
88
|
end
|
72
|
-
|
89
|
+
|
90
|
+
insert_into_file application_view, before: /%body/ do
|
91
|
+
<<-'RUBY'
|
92
|
+
- if Rails.env.development?
|
93
|
+
%script{:src => "http://localhost:3808/webpack-dev-server.js"}
|
94
|
+
RUBY
|
95
|
+
end
|
96
|
+
|
97
|
+
insert_into_file application_view, after: /= yield/ do
|
73
98
|
<<-'RUBY'
|
74
|
-
|
75
|
-
|
76
|
-
<% end %>
|
99
|
+
|
100
|
+
= javascript_include_tag *webpack_asset_paths('application')
|
77
101
|
RUBY
|
78
102
|
end
|
79
103
|
else
|
80
|
-
|
104
|
+
insert_into_file application_view, before: /<\/head>/ do
|
105
|
+
<<-'RUBY'
|
106
|
+
<% if Rails.env.development? %>
|
107
|
+
<script src="http://localhost:3808/webpack-dev-server.js"></script>
|
108
|
+
<% end %>
|
109
|
+
RUBY
|
110
|
+
end
|
111
|
+
insert_into_file application_view, before: /<\/body>/ do
|
112
|
+
<<-'RUBY'
|
113
|
+
<%= javascript_include_tag *webpack_asset_paths('application') %>
|
114
|
+
RUBY
|
115
|
+
end
|
81
116
|
end
|
82
117
|
end
|
83
118
|
def add_to_gitignore
|
84
119
|
append_to_file ".gitignore" do
|
85
120
|
<<-EOF.strip_heredoc
|
86
|
-
# Added by repack
|
87
121
|
/node_modules
|
88
122
|
/public/webpack
|
89
123
|
EOF
|
@@ -91,11 +125,19 @@ module Repack
|
|
91
125
|
end
|
92
126
|
|
93
127
|
def install_yarn
|
94
|
-
|
128
|
+
puts 'Do you want to install and use yarn as your package manager? (yes / no)'
|
129
|
+
if gets.strip.downcase =~ /y(es)?/
|
130
|
+
@yarn_installed = true
|
131
|
+
run "npm install yarn --save-dev"
|
132
|
+
end
|
95
133
|
end
|
96
134
|
|
97
|
-
def
|
98
|
-
|
135
|
+
def run_package_manager_install
|
136
|
+
if @yarn_installed
|
137
|
+
run "yarn install" if yes?("Would you like us to run 'yarn install' for you?")
|
138
|
+
else
|
139
|
+
run "npm install" if yes?("Would you like us to run 'npm install' for you?")
|
140
|
+
end
|
99
141
|
end
|
100
142
|
|
101
143
|
def whats_next
|
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.0
|
4
|
+
version: 2.1.0
|
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: 2016-10-
|
12
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|