From 138a7a935abf35427b47264aac135049a96bdae9 Mon Sep 17 00:00:00 2001 From: Gabrielmbl Date: Thu, 15 Aug 2024 14:19:51 -0400 Subject: [PATCH] Include chrome buildpack to app_json Co-authored-by: Michael Hale --- .../chromium/pdf/install/install_generator.rb | 9 +++++++++ .../chromium/pdf/install/templates/app.json | 17 +++++++++++++++++ test/generators/install_generator_test.rb | 5 +++++ 3 files changed, 31 insertions(+) create mode 100644 lib/generators/chromium/pdf/install/templates/app.json diff --git a/lib/generators/chromium/pdf/install/install_generator.rb b/lib/generators/chromium/pdf/install/install_generator.rb index 8b9160c..1ff46ab 100644 --- a/lib/generators/chromium/pdf/install/install_generator.rb +++ b/lib/generators/chromium/pdf/install/install_generator.rb @@ -14,6 +14,15 @@ def create_pdf_job_templates copy_file 'app/jobs/generate_pdf_job.rb' copy_file 'config/initializers/good_job.rb' end + + def include_chrome_buildpack_in_app_json + say(<<~SAY, :yellow) + N.B. app.json changes are not applied to existing heroku apps. + In the case where your app already exists make sure to manually add the buildpack by running the command: + `heroku buildpacks:add heroku-community/chrome-for-testing` + SAY + copy_file 'app.json' + end end end end diff --git a/lib/generators/chromium/pdf/install/templates/app.json b/lib/generators/chromium/pdf/install/templates/app.json new file mode 100644 index 0000000..f340873 --- /dev/null +++ b/lib/generators/chromium/pdf/install/templates/app.json @@ -0,0 +1,17 @@ +{ + "buildpacks": [ + { + "url":"heroku-community/chrome-for-testing" + }, + { + "url":"heroku/metrics" + }, + { + "url": "heroku/nodejs" + }, + { + "url": "heroku/ruby" + } + ] + } + \ No newline at end of file diff --git a/test/generators/install_generator_test.rb b/test/generators/install_generator_test.rb index 11575ff..b462ed2 100644 --- a/test/generators/install_generator_test.rb +++ b/test/generators/install_generator_test.rb @@ -18,4 +18,9 @@ class InstallGeneratorTest < Rails::Generators::TestCase run_generator assert_file 'config/initializers/good_job.rb' end + + test 'app.json is created' do + run_generator + assert_file 'app.json' + end end