shopify_app 13.0.0 → 16.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +5 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +6 -0
  4. data/.github/workflows/build.yml +38 -0
  5. data/.github/workflows/rubocop.yml +22 -0
  6. data/.gitignore +0 -2
  7. data/.rubocop.yml +14 -6
  8. data/CHANGELOG.md +95 -0
  9. data/Gemfile +5 -0
  10. data/Gemfile.lock +252 -0
  11. data/README.md +83 -45
  12. data/Rakefile +1 -0
  13. data/SECURITY.md +59 -0
  14. data/app/assets/images/storage_access.svg +1 -2
  15. data/app/assets/javascripts/shopify_app/storage_access.js +2 -1
  16. data/app/assets/javascripts/shopify_app/top_level_interaction.js +1 -1
  17. data/app/controllers/concerns/shopify_app/authenticated.rb +1 -0
  18. data/app/controllers/concerns/shopify_app/require_known_shop.rb +39 -0
  19. data/app/controllers/shopify_app/authenticated_controller.rb +1 -0
  20. data/app/controllers/shopify_app/callback_controller.rb +77 -15
  21. data/app/controllers/shopify_app/extension_verification_controller.rb +2 -7
  22. data/app/controllers/shopify_app/sessions_controller.rb +24 -7
  23. data/app/controllers/shopify_app/webhooks_controller.rb +6 -5
  24. data/app/views/shopify_app/partials/_button_styles.html.erb +41 -36
  25. data/app/views/shopify_app/partials/_card_styles.html.erb +3 -3
  26. data/app/views/shopify_app/partials/_empty_state_styles.html.erb +28 -59
  27. data/app/views/shopify_app/partials/_form_styles.html.erb +56 -0
  28. data/app/views/shopify_app/partials/_layout_styles.html.erb +16 -1
  29. data/app/views/shopify_app/partials/_typography_styles.html.erb +6 -6
  30. data/app/views/shopify_app/sessions/enable_cookies.html.erb +2 -7
  31. data/app/views/shopify_app/sessions/new.html.erb +38 -110
  32. data/app/views/shopify_app/sessions/request_storage_access.html.erb +1 -1
  33. data/app/views/shopify_app/sessions/top_level_interaction.html.erb +21 -22
  34. data/config/locales/fi.yml +1 -1
  35. data/config/locales/nl.yml +7 -7
  36. data/config/locales/th.yml +4 -4
  37. data/config/routes.rb +1 -0
  38. data/docs/Quickstart.md +7 -17
  39. data/docs/Releasing.md +16 -14
  40. data/karma.conf.js +1 -1
  41. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +5 -3
  42. data/lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb +1 -0
  43. data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +2 -1
  44. data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +4 -4
  45. data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +5 -4
  46. data/lib/generators/shopify_app/add_webhook/templates/{webhook_job.rb → webhook_job.rb.tt} +5 -0
  47. data/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +4 -3
  48. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb +3 -3
  49. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_route.rb +10 -9
  50. data/lib/generators/shopify_app/authenticated_controller/authenticated_controller_generator.rb +1 -1
  51. data/lib/generators/shopify_app/controllers/controllers_generator.rb +2 -1
  52. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +22 -3
  53. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +67 -17
  54. data/lib/generators/shopify_app/home_controller/templates/unauthenticated_home_controller.rb +10 -0
  55. data/lib/generators/shopify_app/install/install_generator.rb +11 -10
  56. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +1 -1
  57. data/lib/generators/shopify_app/install/templates/flash_messages.js +0 -2
  58. data/lib/generators/shopify_app/install/templates/omniauth.rb +2 -1
  59. data/lib/generators/shopify_app/install/templates/{shopify_app.rb → shopify_app.rb.tt} +4 -3
  60. data/lib/generators/shopify_app/install/templates/user_agent.rb +2 -1
  61. data/lib/generators/shopify_app/products_controller/products_controller_generator.rb +19 -0
  62. data/lib/generators/shopify_app/products_controller/templates/products_controller.rb +8 -0
  63. data/lib/generators/shopify_app/routes/routes_generator.rb +1 -0
  64. data/lib/generators/shopify_app/routes/templates/routes.rb +10 -9
  65. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +12 -7
  66. data/lib/generators/shopify_app/shop_model/templates/shop.rb +1 -0
  67. data/lib/generators/shopify_app/shopify_app_generator.rb +4 -3
  68. data/lib/generators/shopify_app/user_model/templates/user.rb +1 -0
  69. data/lib/generators/shopify_app/user_model/user_model_generator.rb +12 -7
  70. data/lib/generators/shopify_app/views/views_generator.rb +2 -1
  71. data/lib/shopify_app/configuration.rb +15 -8
  72. data/lib/shopify_app/controller_concerns/app_proxy_verification.rb +3 -3
  73. data/lib/shopify_app/controller_concerns/csrf_protection.rb +15 -0
  74. data/lib/shopify_app/controller_concerns/embedded_app.rb +3 -2
  75. data/lib/shopify_app/controller_concerns/itp.rb +2 -0
  76. data/lib/shopify_app/controller_concerns/localization.rb +1 -0
  77. data/lib/shopify_app/controller_concerns/login_protection.rb +85 -17
  78. data/lib/shopify_app/controller_concerns/payload_verification.rb +24 -0
  79. data/lib/shopify_app/controller_concerns/webhook_verification.rb +3 -18
  80. data/lib/shopify_app/engine.rb +26 -0
  81. data/lib/shopify_app/jobs/scripttags_manager_job.rb +1 -1
  82. data/lib/shopify_app/jobs/webhooks_manager_job.rb +1 -1
  83. data/lib/shopify_app/managers/scripttags_manager.rb +4 -3
  84. data/lib/shopify_app/managers/webhooks_manager.rb +4 -3
  85. data/lib/shopify_app/middleware/jwt_middleware.rb +42 -0
  86. data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +2 -1
  87. data/lib/shopify_app/session/in_memory_session_store.rb +7 -3
  88. data/lib/shopify_app/session/in_memory_shop_session_store.rb +10 -0
  89. data/lib/shopify_app/session/in_memory_user_session_store.rb +10 -0
  90. data/lib/shopify_app/session/jwt.rb +63 -0
  91. data/lib/shopify_app/session/null_user_session_store.rb +22 -0
  92. data/lib/shopify_app/session/session_repository.rb +13 -16
  93. data/lib/shopify_app/session/session_storage.rb +1 -0
  94. data/lib/shopify_app/session/shop_session_storage.rb +21 -9
  95. data/lib/shopify_app/session/user_session_storage.rb +19 -8
  96. data/lib/shopify_app/test_helpers/all.rb +2 -0
  97. data/lib/shopify_app/test_helpers/webhook_verification_helper.rb +17 -0
  98. data/lib/shopify_app/utils.rb +6 -5
  99. data/lib/shopify_app/version.rb +2 -1
  100. data/lib/shopify_app.rb +12 -5
  101. data/package.json +7 -8
  102. data/shopify_app.gemspec +12 -7
  103. data/yarn.lock +2098 -2115
  104. metadata +56 -12
  105. data/.travis.yml +0 -27
  106. data/package-lock.json +0 -7245
@@ -5,6 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <base target="_top">
7
7
  <title>Redirecting…</title>
8
+ <%= render 'shopify_app/partials/card_styles' %>
8
9
  <%= render 'shopify_app/partials/layout_styles' %>
9
10
  <%= render 'shopify_app/partials/typography_styles' %>
10
11
  <%= render 'shopify_app/partials/button_styles' %>
@@ -15,15 +16,9 @@
15
16
  }
16
17
  </style>
17
18
 
18
- <script>
19
- window.apiKey = "<%= ShopifyApp.configuration.api_key %>";
20
- window.shopOrigin = "https://<%= @shop %>";
21
- window.redirectUrl = "<%= @url %>";
22
- </script>
23
-
24
19
  <%= javascript_include_tag('shopify_app/top_level', crossorigin: 'anonymous', integrity: true) %>
25
20
  </head>
26
- <body>
21
+ <body data-api-key="<%= ShopifyApp.configuration.api_key %>" data-shop-origin="https://<%= @shop %>" data-redirect-url="<%= @url %>">
27
22
  <main id="TopLevelInteractionContent">
28
23
  <div class="Polaris-Page">
29
24
  <div class="Polaris-Page__Content">
@@ -31,26 +26,30 @@
31
26
  <div class="Polaris-Layout__Section">
32
27
  <div class="Polaris-Stack Polaris-Stack--vertical">
33
28
  <div class="Polaris-Stack__Item">
34
- <div class="Polaris-EmptyState">
35
- <div class="Polaris-EmptyState__Section">
36
- <div class="Polaris-EmptyState__DetailsContainer">
37
- <div class="Polaris-EmptyState__Details">
38
- <div class="Polaris-TextContainer">
39
- <h1 class="Polaris-DisplayText Polaris-DisplayText--sizeMedium"><%= I18n.t('top_level_interaction_heading', app: ShopifyApp.configuration.application_name) %></h1>
40
- <div class="Polaris-EmptyState__Content">
41
- <p><%= I18n.t('top_level_interaction_body', app: ShopifyApp.configuration.application_name) %></p>
29
+ <div class="Polaris-Card">
30
+ <div class="Polaris-Card__Section">
31
+ <div class="Polaris-EmptyState">
32
+ <div class="Polaris-EmptyState__Section">
33
+ <div class="Polaris-EmptyState__DetailsContainer">
34
+ <div class="Polaris-EmptyState__Details">
35
+ <div class="Polaris-TextContainer">
36
+ <h1 class="Polaris-DisplayText Polaris-DisplayText--sizeSmall"><%= I18n.t('top_level_interaction_heading', app: ShopifyApp.configuration.application_name) %></h1>
37
+ <div class="Polaris-EmptyState__Content">
38
+ <p><%= I18n.t('top_level_interaction_body', app: ShopifyApp.configuration.application_name) %></p>
39
+ </div>
40
+ </div>
41
+ <div class="Polaris-EmptyState__Actions">
42
+ <div class="Polaris-Stack Polaris-Stack--alignmentCenter">
43
+ <div class="Polaris-Stack__Item"><button type="button" id="TopLevelInteractionButton" class="Polaris-Button Polaris-Button--primary Polaris-Button--sizeLarge"><span class="Polaris-Button__Content"><span class="Polaris-Button__Icon"></span><span><%= I18n.t('top_level_interaction_action') %></span></span></button></div>
44
+ </div>
45
+ </div>
42
46
  </div>
43
47
  </div>
44
- <div class="Polaris-EmptyState__Actions">
45
- <div class="Polaris-Stack Polaris-Stack--alignmentCenter">
46
- <div class="Polaris-Stack__Item"><button type="button" id="TopLevelInteractionButton" class="Polaris-Button Polaris-Button--primary Polaris-Button--sizeLarge"><span class="Polaris-Button__Content"><span class="Polaris-Button__Icon"></span><span><%= I18n.t('top_level_interaction_action') %></span></span></button></div>
47
- </div>
48
+ <div class="Polaris-EmptyState__ImageContainer">
49
+ <%= image_tag 'storage_access.svg', role: "presentation", alt: "", class: "Polaris-EmptyState__Image" %>
48
50
  </div>
49
51
  </div>
50
52
  </div>
51
- <div class="Polaris-EmptyState__ImageContainer">
52
- <%= image_tag 'storage_access.svg', role: "presentation", alt: "", class: "Polaris-EmptyState__Image" %>
53
- </div>
54
53
  </div>
55
54
  </div>
56
55
  </div>
@@ -15,6 +15,6 @@ fi:
15
15
  top_level_interaction_action: Jatka
16
16
  request_storage_access_heading: "%{app} edellyttää evästeiden käyttöä"
17
17
  request_storage_access_body: Näin sovellus voi todentaa sinut tallentamalla henkilötietosi
18
- tilapäisesti. Napsauta Jatka ja salli evästeet sovelluksen käyttämiseksi.
18
+ tilapäisesti. Klikkaa Jatka ja salli evästeet sovelluksen käyttämiseksi.
19
19
  request_storage_access_footer: Evästeet vanhenevat 30 päivän kuluttua.
20
20
  request_storage_access_action: Jatka
@@ -1,20 +1,20 @@
1
1
  ---
2
2
  nl:
3
- logged_out: u bent afgemeld
3
+ logged_out: Je bent afgemeld
4
4
  could_not_log_in: Kon niet aanmelden bij Shopify-winkel
5
5
  invalid_shop_url: Ongeldig winkeldomein
6
6
  enable_cookies_heading: Schakel cookies in van %{app}
7
- enable_cookies_body: U moet cookies in deze browser handmatig inschakelen om %{app}
7
+ enable_cookies_body: Je moet cookies in deze browser handmatig inschakelen om %{app}
8
8
  binnen Shopify te gebruiken.
9
- enable_cookies_footer: Met cookies kan de app u verifiëren door uw voorkeuren en
9
+ enable_cookies_footer: Met cookies kan de app je verifiëren door je voorkeuren en
10
10
  persoonlijke informatie tijdelijk op te slaan. Ze vervallen na 30 dagen.
11
11
  enable_cookies_action: Schakel cookies in
12
- top_level_interaction_heading: Uw browser moet %{app} verifiëren
13
- top_level_interaction_body: Uw browser heeft apps nodig zoals %{app} om u toegang
14
- te vragen tot cookies voordat Shopify het voor u kan openen.
12
+ top_level_interaction_heading: Je browser moet %{app} verifiëren
13
+ top_level_interaction_body: Je browser heeft apps nodig zoals %{app} om je toegang
14
+ te vragen tot cookies voordat Shopify het voor je kan openen.
15
15
  top_level_interaction_action: Doorgaan
16
16
  request_storage_access_heading: "%{app} heeft toegang tot cookies nodig"
17
- request_storage_access_body: Hiermee kan de app u verifiëren door uw persoonlijke
17
+ request_storage_access_body: Hiermee kan de app je verifiëren door je persoonlijke
18
18
  gegevens tijdelijk op te slaan. Klik op Doorgaan en sta cookies toe om de app
19
19
  te gebruiken.
20
20
  request_storage_access_footer: Cookies verlopen na 30 dagen.
@@ -3,12 +3,12 @@ th:
3
3
  logged_out: ออกจากระบบสำเร็จ
4
4
  could_not_log_in: ไม่สามารถเข้าสู่ระบบร้านค้า Shopify ได้
5
5
  invalid_shop_url: โดเมนร้านค้าไม่ถูกต้อง
6
- enable_cookies_heading: เปิดใช้งานคุกกี้จาก %{app}
7
- enable_cookies_body: คุณต้องเปิดใช้งานคุกกี้ด้วยตนเองในเบราว์เซอร์นี้เพื่อใช้งาน
8
- %{app} ภายใน Shopify
6
+ enable_cookies_heading: เปิดใช้คุกกี้จาก %{app}
7
+ enable_cookies_body: คุณต้องเปิดใช้คุกกี้ด้วยตนเองในเบราว์เซอร์นี้เพื่อใช้งาน %{app}
8
+ ภายใน Shopify
9
9
  enable_cookies_footer: คุกกี้ช่วยให้แอปตรวจสอบความถูกต้องของคุณด้วยการจัดเก็บความชื่นชอบและข้อมูลส่วนตัวของคุณชั่วคราว
10
10
  คุกกี้จะหมดอายุหลังจาก 30 วัน
11
- enable_cookies_action: เปิดใช้งานคุกกี้
11
+ enable_cookies_action: เปิดใช้คุกกี้
12
12
  top_level_interaction_heading: เบราว์เซอร์ของคุณต้องรับรองความถูกต้องของ %{app}
13
13
  top_level_interaction_body: เบราว์เซอร์ของคุณต้องการแอปอย่าง %{app} เพื่อขอให้คุณเข้าถึงคุกกี้ก่อนที่
14
14
  Shopify จะสามารถเปิดมันให้คุณได้
data/config/routes.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ShopifyApp::Engine.routes.draw do
2
3
  controller :sessions do
3
4
  get 'login' => :new, :as => :login
data/docs/Quickstart.md CHANGED
@@ -1,7 +1,8 @@
1
1
  Quickstart
2
2
  ==========
3
3
 
4
- Get started building and deploying a new Shopify App to Heroku in just a few minutes. This guide assumes you have Ruby/Rails installed on your computer already; if you haven't done that already start with [this guide.](https://guides.rubyonrails.org/v5.0/getting_started.html#installing-rails)
4
+ Get started building and deploying a new Shopify App to Heroku in just a few minutes.
5
+ This guide assumes you have Ruby, Rails and PostgreSQL installed on your computer already; if you haven't done that already start with [this guide.](https://guides.rubyonrails.org/v5.0/getting_started.html#installing-rails)
5
6
 
6
7
  1. New Rails App (with postgres)
7
8
  --------------------------------
@@ -26,15 +27,6 @@ Head to the Heroku dashboard and create a new app, or run the following commands
26
27
  CLI:
27
28
  ```sh
28
29
  $ heroku create name
29
- $ heroku git:remote -a name
30
- ```
31
-
32
- Once you have created an app on Heroku, we need to let Git know where the Heroku server is so we can deploy to it later. Copy the app's name from your Heroku dashboard and substitute `appname.git` with the name you chose earlier:
33
-
34
- web:
35
- ```sh
36
- # https://dashboard.heroku.com/new
37
- $ git remote add heroku git@heroku.com:appname.git
38
30
  ```
39
31
 
40
32
  3. Create a new App in the Shopify Partner dashboard
@@ -48,11 +40,10 @@ $ git remote add heroku git@heroku.com:appname.git
48
40
  4. Add ShopifyApp to Gemfile
49
41
  ----------------------------
50
42
 
51
- Run these commands to add the `shopify_app` Gem to your app:
43
+ Run this command to add the `shopify_app` Gem to your app:
52
44
 
53
45
  ```sh
54
- $ echo "gem 'shopify_app'" >> Gemfile
55
- $ bundle install
46
+ $ bundle add shopify_app
56
47
  ```
57
48
 
58
49
  **Note:** we recommend using the latest version of Shopify Gem. Check the [Git tags](https://github.com/Shopify/shopify_app/tags) to see the latest release version and then add it to your Gemfile e.g `gem 'shopify_app', '~> 7.0.0'`
@@ -64,14 +55,13 @@ Generate the code for your app by running these commands:
64
55
 
65
56
  ```sh
66
57
  # Use the keys from your app you created in the partners area
67
- $ rails generate shopify_app --api_key <shopify_api_key> --secret <shopify_api_secret>
58
+ $ rails generate shopify_app
68
59
  $ git add .
69
60
  $ git commit -m 'generated shopify app'
70
61
  ```
71
62
 
72
- If you forget to set your keys or redirect uri above, you will find them in the shopify_app initializer at: `/config/initializers/shopify_app.rb`.
73
-
74
- We recommend adding a gem or utilizing environment variables (`.env`) to handle your keys before releasing your app. [Learn more about using environment variables.](https://www.honeybadger.io/blog/ruby-guide-environment-variables/)
63
+ Your API key and secret are read from environment variables. Refer to the main
64
+ README for further details on how to set this up.
75
65
 
76
66
  6. Deploy your app
77
67
  ---------
data/docs/Releasing.md CHANGED
@@ -1,17 +1,19 @@
1
- Releasing ShopifyApp
1
+ # Releasing ShopifyApp
2
2
 
3
- 1. Check the Semantic Versioning page for info on how to version the new release: http://semver.org
4
- 2. Create a pull request with the following changes:
5
- * Update the version of ShopifyApp in lib/shopify_app/version.rb
6
- * Add a CHANGELOG entry for the new release with the date
7
- * Change the title of the PR to something like: "Packaging for release X.Y.Z"
8
- 3. Merge your pull request
9
- 4. Pull from master so you have the latest version of the shopify_app
10
- 5. Tag the HEAD with the version (Leave REV blank for HEAD or provide a SHA)
11
- $ git tag vX.Y.Z
12
- 6. Push out your tags
13
- $ git push --tags
14
- 7. Use Shipit to build and push the gem
3
+ 1. Make the code changes in a separate PR that doesn't modify the version.
4
+ 1. After that is merged, check the Semantic Versioning page for info on how to version the new release: http://semver.org
5
+ 1. Create a pull request with the following changes:
6
+ - Update the version of ShopifyApp in lib/shopify_app/version.rb
7
+ - Update the version of shopify_app in package.json
8
+ - Add a CHANGELOG entry for the new release with the date
9
+ - Change the title of the PR to something like: "Packaging for release X.Y.Z"
10
+ 1. Merge your pull request
11
+ 1. Checkout and pull from master so you have the latest version of the shopify_app
12
+ 1. Tag the HEAD with the version
13
+ ```bash
14
+ $ git tag -f vX.Y.Z && git push --tags --force
15
+ ```
16
+ 1. Use Shipit to build and push the gem
15
17
 
16
- If you see an error like 'You need to create the vX.Y.X tag first', clear GIT
18
+ If you see an error like 'You need to create the vX.Y.X tag first', clear git
17
19
  cache in Shipit settings
data/karma.conf.js CHANGED
@@ -8,7 +8,7 @@ module.exports = function(config) {
8
8
  config.set({
9
9
  mode: 'development',
10
10
  basePath: '',
11
- frameworks: ['mocha-debug', 'mocha', 'chai-sinon'],
11
+ frameworks: ['mocha', 'chai-sinon'],
12
12
  files: [
13
13
  'app/assets/javascripts/**/*.js',
14
14
  'test/javascripts/**/*test.js',
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators/base'
2
3
 
3
4
  module ShopifyApp
@@ -6,7 +7,7 @@ module ShopifyApp
6
7
  source_root File.expand_path('../templates', __FILE__)
7
8
 
8
9
  hook_for :test_framework, as: :job, in: :rails do |instance, generator|
9
- instance.invoke generator, [ instance.send(:job_file_name) ]
10
+ instance.invoke(generator, [instance.send(:job_file_name)])
10
11
  end
11
12
 
12
13
  def init_after_authenticate_config
@@ -23,12 +24,13 @@ module ShopifyApp
23
24
  )
24
25
 
25
26
  unless initializer.include?(after_authenticate_job_config)
26
- shell.say("Error adding after_authenticate_job to config. Add this line manually: #{after_authenticate_job_config}", :red)
27
+ shell.say("Error adding after_authenticate_job to config. Add this line manually: "\
28
+ "#{after_authenticate_job_config}", :red)
27
29
  end
28
30
  end
29
31
 
30
32
  def add_after_authenticate_job
31
- template 'after_authenticate_job.rb', "app/jobs/#{job_file_name}_job.rb"
33
+ template('after_authenticate_job.rb', "app/jobs/#{job_file_name}_job.rb")
32
34
  end
33
35
 
34
36
  private
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Shopify
2
3
  class AfterAuthenticateJob < ActiveJob::Base
3
4
  def perform(shop_domain:)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators/base'
2
3
 
3
4
  module ShopifyApp
@@ -6,7 +7,7 @@ module ShopifyApp
6
7
  source_root File.expand_path('../templates', __FILE__)
7
8
 
8
9
  def generate_app_extension
9
- template "marketing_activities_controller.rb", "app/controllers/marketing_activities_controller.rb"
10
+ template("marketing_activities_controller.rb", "app/controllers/marketing_activities_controller.rb")
10
11
  generate_routes
11
12
  end
12
13
 
@@ -3,7 +3,7 @@
3
3
  class MarketingActivitiesController < ShopifyApp::ExtensionVerificationController
4
4
  def preload_form_data
5
5
  preload_data = {
6
- "form_data": {}
6
+ "form_data": {},
7
7
  }
8
8
  render(json: preload_data, status: :ok)
9
9
  end
@@ -31,14 +31,14 @@ class MarketingActivitiesController < ShopifyApp::ExtensionVerificationControlle
31
31
  "preview_url": placeholder_img,
32
32
  "content_type": "text/html",
33
33
  "width": 360,
34
- "height": 200
34
+ "height": 200,
35
35
  },
36
36
  "mobile": {
37
37
  "preview_url": placeholder_img,
38
38
  "content_type": "text/html",
39
39
  "width": 360,
40
- "height": 200
41
- }
40
+ "height": 200,
41
+ },
42
42
  }
43
43
  render(json: preview_response, status: :ok)
44
44
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators/base'
2
3
 
3
4
  module ShopifyApp
@@ -8,7 +9,7 @@ module ShopifyApp
8
9
  class_option :address, type: :string, aliases: "-a", required: true
9
10
 
10
11
  hook_for :test_framework, as: :job, in: :rails do |instance, generator|
11
- instance.invoke generator, [ instance.send(:job_file_name) ]
12
+ instance.invoke(generator, [instance.send(:job_file_name)])
12
13
  end
13
14
 
14
15
  def init_webhook_config
@@ -32,14 +33,14 @@ module ShopifyApp
32
33
  initializer = load_initializer
33
34
 
34
35
  unless initializer.include?(webhook_config)
35
- shell.say "Error adding webhook to config. Add this line manually: #{webhook_config}", :red
36
+ shell.say("Error adding webhook to config. Add this line manually: #{webhook_config}", :red)
36
37
  end
37
38
  end
38
39
 
39
40
  def add_webhook_job
40
41
  @job_file_name = job_file_name + '_job'
41
- @job_class_name = @job_file_name.classify
42
- template 'webhook_job.rb', "app/jobs/#{@job_file_name}.rb"
42
+ @job_class_name = @job_file_name.classify
43
+ template('webhook_job.rb', "app/jobs/#{@job_file_name}.rb")
43
44
  end
44
45
 
45
46
  private
@@ -2,6 +2,11 @@ class <%= @job_class_name %> < ActiveJob::Base
2
2
  def perform(shop_domain:, webhook:)
3
3
  shop = Shop.find_by(shopify_domain: shop_domain)
4
4
 
5
+ if shop.nil?
6
+ logger.error("#{self.class} failed: cannot find shop with domain '#{shop_domain}'")
7
+ return
8
+ end
9
+
5
10
  shop.with_shopify_session do
6
11
  end
7
12
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators/base'
2
3
 
3
4
  module ShopifyApp
@@ -6,11 +7,11 @@ module ShopifyApp
6
7
  source_root File.expand_path('../templates', __FILE__)
7
8
 
8
9
  def create_app_proxy_controller
9
- template 'app_proxy_controller.rb', 'app/controllers/app_proxy_controller.rb'
10
+ template('app_proxy_controller.rb', 'app/controllers/app_proxy_controller.rb')
10
11
  end
11
12
 
12
13
  def create_app_proxy_index_view
13
- copy_file 'index.html.erb', 'app/views/app_proxy/index.html.erb'
14
+ copy_file('index.html.erb', 'app/views/app_proxy/index.html.erb')
14
15
  end
15
16
 
16
17
  def add_app_proxy_route
@@ -18,7 +19,7 @@ module ShopifyApp
18
19
  'config/routes.rb',
19
20
  File.read(File.expand_path(find_in_source_paths('app_proxy_route.rb'))),
20
21
  after: "mount ShopifyApp::Engine, at: '/'\n"
21
- )
22
+ )
22
23
  end
23
24
  end
24
25
  end
@@ -1,8 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  class AppProxyController < ApplicationController
2
- include ShopifyApp::AppProxyVerification
3
+ include ShopifyApp::AppProxyVerification
3
4
 
4
5
  def index
5
- render layout: false, content_type: 'application/liquid'
6
+ render(layout: false, content_type: 'application/liquid')
6
7
  end
7
-
8
8
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
1
2
 
2
- namespace :app_proxy do
3
- root action: 'index'
4
- # simple routes without a specified controller will go to AppProxyController
5
-
6
- # more complex routes will go to controllers in the AppProxy namespace
7
- # resources :reviews
8
- # GET /app_proxy/reviews will now be routed to
9
- # AppProxy::ReviewsController#index, for example
10
- end
3
+ namespace :app_proxy do
4
+ root action: 'index'
5
+ # simple routes without a specified controller will go to AppProxyController
6
+
7
+ # more complex routes will go to controllers in the AppProxy namespace
8
+ # resources :reviews
9
+ # GET /app_proxy/reviews will now be routed to
10
+ # AppProxy::ReviewsController#index, for example
11
+ end
@@ -7,7 +7,7 @@ module ShopifyApp
7
7
  class AuthenticatedControllerGenerator < Rails::Generators::Base
8
8
  source_root File.expand_path('../templates', __FILE__)
9
9
 
10
- def create_home_controller
10
+ def create_authenticated_controller
11
11
  template('authenticated_controller.rb', 'app/controllers/authenticated_controller.rb')
12
12
  end
13
13
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators/base'
2
3
 
3
4
  module ShopifyApp
@@ -7,7 +8,7 @@ module ShopifyApp
7
8
 
8
9
  def create_controllers
9
10
  controllers.each do |controller|
10
- copy_file controller
11
+ copy_file(controller)
11
12
  end
12
13
  end
13
14