11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/generators/half_pipe/install_generator.rb', line 11
def create_initializer_file
template "package.json", "package.json"
template "_bowerrc", ".bowerrc"
template "bower.json", "bower.json"
template "_jshintrc", ".jshintrc"
template "Gruntfile.js", "Gruntfile.js"
"config/application.rb", %r{sprockets/railtie}
railties_requires = File.read(File.join(self.class.source_root, "railties.rb"))
gsub_file "config/application.rb", %r{require 'rails/all'}, railties_requires
gsub_file "app/views/layouts/application.html.erb", %r{\s*<%= stylesheet_link_tag\s+"application".*%>$}, ''
gsub_file "app/views/layouts/application.html.erb", %r{\s*<%= javascript_include_tag\s+"application".*%>$}, ''
insert_into_file "app/views/layouts/application.html.erb", %Q{ <%= requirejs_include_tag "/scripts/application.js" %>\n }, before: "</body>"
insert_into_file "app/views/layouts/application.html.erb", %Q{ <%= stylesheet_link_tag "/styles/main.css" %>\n }, before: "</head>"
gsub_file "config/environments/development.rb", "config.assets.debug = true", "config.middleware.use Rack::HalfPipe"
append_to_file ".gitignore", %w(node_modules bower_components public/scripts public/styles public/images).join("\n"), force: true
directory "app"
empty_directory "app/scripts"
inside "app/scripts" do
template "main.js", force: true
template "application.js", force: true
end
initializer "sass.rb" do
%Q{
require 'sass/importers/bower_importer'
require 'sass/half_pipe_functions'
Sass.load_paths << Sass::Importers::BowerImporter.new("bower_components")
}
end
run "npm install"
ENV["PATH"] = "./node_modules/.bin:#{ENV["PATH"]}"
run "bower install"
run "grunt build"
say "You may now safely migrate your assets to app/scripts and/or app/styles. Feel free to delete app/assets/javascripts and app/assets/stylesheets when you're done."
end
|