From a06d8d50cd99feb45b560c27d1d2581e703aa824 Mon Sep 17 00:00:00 2001 From: Noah Silvera Date: Mon, 21 Jun 2021 15:45:53 -0700 Subject: Add install generator Prior to this commit, users were required to manually configure this extension after installing the gem. We add an install generator so users can run a single command to handle this. We include this command in the sandbox script so the sandbox is ready to use this extension by default. Co-authored-by: Noah Silvera --- README.md | 12 ++++-------- bin/sandbox | 1 + .../super_good/solidus_taxjar/install_generator.rb | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 lib/generators/super_good/solidus_taxjar/install_generator.rb diff --git a/README.md b/README.md index d16074b..de1d84a 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,11 @@ This is not a fork of [spree_taxjar](https://github.com/vinsol-spree-contrib/spr $ bundle -2. Next, configure Solidus to use this gem: +2. Next, configure Solidus to use this gem by running the install generator: - ```ruby - # Put this in config/initializers/solidus.rb - - Spree.config do |config| - config.tax_calculator_class = SuperGood::SolidusTaxjar::TaxCalculator - end - ``` + ```sh + bundle exec rails generate super_good:solidus_taxjar:install + ``` 3. Also, configure your error handling: diff --git a/bin/sandbox b/bin/sandbox index 90b8b81..53731cf 100755 --- a/bin/sandbox +++ b/bin/sandbox @@ -75,6 +75,7 @@ unbundled bundle exec rails generate spree:install \ $@ unbundled bundle exec rails generate solidus:auth:install +unbundled bundle exec rails generate super_good:solidus_taxjar:install echo echo "🚀 Sandbox app successfully created for $extension_name!" diff --git a/lib/generators/super_good/solidus_taxjar/install_generator.rb b/lib/generators/super_good/solidus_taxjar/install_generator.rb new file mode 100644 index 0000000..73974ba --- /dev/null +++ b/lib/generators/super_good/solidus_taxjar/install_generator.rb @@ -0,0 +1,18 @@ +module SuperGood + module SolidusTaxjar + module Generators + class InstallGenerator < Rails::Generators::Base + def create_initializer_file + solidus_initializer_path = "config/initializers/solidus.rb" + + create_file(solidus_initializer_path) unless File.exists?(solidus_initializer_path) + append_to_file(solidus_initializer_path, <<~INIT) + Spree.config do |config| + config.tax_calculator_class = SuperGood::SolidusTaxjar::TaxCalculator + end + INIT + end + end + end + end +end -- cgit v1.2.3 From b96799b59bae6e6a1b974604a7830b29bf44b8e1 Mon Sep 17 00:00:00 2001 From: Nicholas Van Doorn Date: Tue, 22 Jun 2021 09:17:40 -0700 Subject: Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index db68775..724fc2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - [#37](https://github.com/SuperGoodSoft/solidus_taxjar/pull/37) Added a basic Taxjar settings admin interface which displays placeholder text. - [#64](https://github.com/SuperGoodSoft/solidus_taxjar/pull/64) Provide Spree::Address.address2 to TaxJar address validation if it is present. - [#80](https://github.com/SuperGoodSoft/solidus_taxjar/pull/80) Support order_recalculated event in < 2.11 +- [#81](https://github.com/SuperGoodSoft/solidus_taxjar/pull/81) Add install generator ## v0.18.1 -- cgit v1.2.3