Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve lines insertion in installers #1445

Merged
merged 1 commit into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/install/coffee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
before: "module.exports"

say "Updating webpack paths to include .coffee file extension"
insert_into_file Webpacker.config.config_path, " - .coffee\n", after: /extensions:\n/
insert_into_file Webpacker.config.config_path, optimize_indentation("- .coffee", 4), after: /extensions:\n/

say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
copy_file "#{__dir__}/examples/coffee/hello_coffee.coffee",
Expand Down
2 changes: 1 addition & 1 deletion lib/install/elm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
run "yarn run elm package install -- --yes"

say "Updating webpack paths to include .elm file extension"
insert_into_file Webpacker.config.config_path, " - .elm\n", after: /extensions:\n/
insert_into_file Webpacker.config.config_path, optimize_indentation("- .elm", 4), after: /extensions:\n/

say "Updating Elm source location"
gsub_file "elm-package.json", /\"\.\"\n/,
Expand Down
2 changes: 1 addition & 1 deletion lib/install/erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
before: "module.exports"

say "Updating webpack paths to include .erb file extension"
insert_into_file Webpacker.config.config_path, " - .erb\n", after: /extensions:\n/
insert_into_file Webpacker.config.config_path, optimize_indentation("- .erb", 4), after: /extensions:\n/

say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
copy_file "#{__dir__}/examples/erb/hello_erb.js.erb",
Expand Down
2 changes: 1 addition & 1 deletion lib/install/react.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
copy_file "#{__dir__}/examples/react/hello_react.jsx", "#{Webpacker.config.source_entry_path}/hello_react.jsx"

say "Updating webpack paths to include .jsx file extension"
insert_into_file Webpacker.config.config_path, " - .jsx\n", after: /extensions:\n/
insert_into_file Webpacker.config.config_path, optimize_indentation("- .jsx", 4), after: /extensions:\n/

say "Installing all react dependencies"
run "yarn add react react-dom babel-preset-react prop-types"
Expand Down
18 changes: 9 additions & 9 deletions lib/install/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
environment check_yarn_integrity_config.call("true"), env: :development
environment check_yarn_integrity_config.call("false"), env: :production
else
inject_into_file "config/environments/development.rb", "\n #{check_yarn_integrity_config.call("true")}", after: "Rails.application.configure do", verbose: false
inject_into_file "config/environments/production.rb", "\n #{check_yarn_integrity_config.call("false")}", after: "Rails.application.configure do", verbose: false
inject_into_file "config/environments/development.rb", optimize_indentation(check_yarn_integrity_config.call("true"), 2), after: "Rails.application.configure do", verbose: false
inject_into_file "config/environments/production.rb", optimize_indentation(check_yarn_integrity_config.call("false"), 2), after: "Rails.application.configure do", verbose: false
end

if File.exists?(".gitignore")
append_to_file ".gitignore", <<-EOS
/public/packs
/public/packs-test
/node_modules
yarn-debug.log*
.yarn-integrity
EOS
append_to_file ".gitignore", optimize_indentation(<<-EOS)
/public/packs
/public/packs-test
/node_modules
yarn-debug.log*
.yarn-integrity
EOS
end

say "Installing all JavaScript dependencies"
Expand Down
4 changes: 2 additions & 2 deletions lib/install/typescript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
copy_file "#{__dir__}/examples/#{example_source}/tsconfig.json", "tsconfig.json"

say "Updating webpack paths to include .ts file extension"
insert_into_file Webpacker.config.config_path, " - .ts\n", after: /extensions:\n/
insert_into_file Webpacker.config.config_path, optimize_indentation("- .ts\n", 4), after: /extensions:\n/

say "Updating webpack paths to include .tsx file extension"
insert_into_file Webpacker.config.config_path, " - .tsx\n", after: /extensions:\n/
insert_into_file Webpacker.config.config_path, optimize_indentation("- .tsx\n", 4), after: /extensions:\n/

say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
copy_file "#{__dir__}/examples/typescript/hello_typescript.ts",
Expand Down
2 changes: 1 addition & 1 deletion lib/install/vue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
before: "module.exports"

say "Updating webpack paths to include .vue file extension"
insert_into_file Webpacker.config.config_path, " - .vue\n", after: /extensions:\n/
insert_into_file Webpacker.config.config_path, optimize_indentation("- .vue\n", 4), after: /extensions:\n/

say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
copy_file "#{__dir__}/examples/vue/hello_vue.js",
Expand Down