repack 2.0.5 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6cc32e50e25193457caa1c04ebad9eff3babb30
4
- data.tar.gz: c3e31151edab8cac06cbdec1996e6f0892d18072
3
+ metadata.gz: 10d12948ef43c30268284738b43e2c56d3aaa094
4
+ data.tar.gz: 0f7e1753c40194e20ecd04286adc8786ba61d2b1
5
5
  SHA512:
6
- metadata.gz: 4911d530de15d6002f23cae6c936930faa0ecccdd69341d1bfdcf929b4138d7f2ba7040d22e405a7c0a229fe97ad2481ee7376f9cc5a81d4c95dec55b67a68c0
7
- data.tar.gz: 54c3b592dc7b6c4f9b4a71b1267744783a30967a829fcbdde072454956f669d5bd130747978d53ee4473e6122192eaf2bab0d0610415b2cdb8fdd8b9153d67da
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
- copy_file "webpack.config.heroku.js", "config/webpack.config.heroku.js"
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
- application_view = 'app/views/layouts/application.html.erb'
66
- if File.exists? application_view
67
- insert_into_file 'app/views/layouts/application.html.erb', before: /<\/body>/ do
68
- <<-'RUBY'
69
- <%= javascript_include_tag *webpack_asset_paths('application') %>
70
- RUBY
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
- insert_into_file 'app/views/layouts/application.html.erb', before: /<\/head>/ do
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
- <% if Rails.env.development? %>
75
- <script src="http://localhost:3808/webpack-dev-server.js"></script>
76
- <% end %>
99
+
100
+ = javascript_include_tag *webpack_asset_paths('application')
77
101
  RUBY
78
102
  end
79
103
  else
80
- puts "\n\n***WARNING*** HAML NOT SUPPORTED YET additional steps required\n\n"
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
- run "npm install yarn --save-dev"
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 run_yarn_install
98
- run "yarn install" if yes?("Would you like us to run 'yarn install' for you?")
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
@@ -1,3 +1,3 @@
1
1
  module Repack
2
- VERSION = "2.0.5"
2
+ VERSION = "2.1.0"
3
3
  end
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.5
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-25 00:00:00.000000000 Z
12
+ date: 2016-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails